Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package io.github.hsyyid.home;
- import org.spongepowered.api.entity.player.Player;
- import org.spongepowered.api.text.Texts;
- import org.spongepowered.api.text.format.TextColors;
- import org.spongepowered.api.util.blockray.BlockRay;
- import org.spongepowered.api.util.blockray.BlockRay.BlockRayBuilder;
- import org.spongepowered.api.util.blockray.BlockRayHit;
- import org.spongepowered.api.util.command.CommandException;
- import org.spongepowered.api.util.command.CommandResult;
- import org.spongepowered.api.util.command.CommandSource;
- import org.spongepowered.api.util.command.args.CommandContext;
- import org.spongepowered.api.util.command.source.CommandBlockSource;
- import org.spongepowered.api.util.command.source.ConsoleSource;
- import org.spongepowered.api.util.command.spec.CommandExecutor;
- import org.spongepowered.api.world.Location;
- import org.spongepowered.api.world.TeleportHelper;
- public class JumpExecutor implements CommandExecutor
- {
- public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
- {
- if(src instanceof Player)
- {
- Player player = (Player) src;
- BlockRayBuilder blockRayBuilder = BlockRay.from(player);
- BlockRay ray = blockRayBuilder.blockLimit(30).build();
- if(ray.hasNext())
- {
- BlockRayHit hit = ray.next();
- Location location = new Location(player.getWorld(), hit.getBlockX(), hit.getBlockY(), hit.getBlockZ());
- TeleportHelper helper = Main.helper;
- Location safe = helper.getSafeLocation(location).get();
- player.setLocation(safe);
- }
- }
- else if(src instanceof ConsoleSource) {
- src.sendMessage(Texts.of(TextColors.DARK_RED,"Error! ", TextColors.RED, "Must be an in-game player to use /jump!"));
- }
- else if(src instanceof CommandBlockSource) {
- src.sendMessage(Texts.of(TextColors.DARK_RED,"Error! ", TextColors.RED, "Must be an in-game player to use /jump!"));
- }
- return CommandResult.success();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment