1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Removed /sf elevator

This commit is contained in:
TheBusyBiscuit 2020-04-08 20:33:10 +02:00
parent 64064db132
commit d03cb64c02
3 changed files with 17 additions and 71 deletions

View File

@ -25,6 +25,5 @@ public final class Commands {
commands.add(new OpenGuideCommand(plugin, cmd));
commands.add(new SearchCommand(plugin, cmd));
commands.add(new DebugFishCommand(plugin, cmd));
commands.add(new ElevatorCommand(plugin, cmd));
}
}

View File

@ -1,66 +0,0 @@
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.ElevatorPlate;
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
class ElevatorCommand extends SubCommand {
private final ElevatorPlate elevatorPlate;
ElevatorCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
super(plugin, cmd);
elevatorPlate = ((ElevatorPlate) SlimefunItem.getByID("ELEVATOR_PLATE"));
}
@Override
public void recordUsage(Map<SubCommand, Integer> commandUsage) {
// This command is only for internal purposes, we do not wanna record the
// usage of this one.
}
@Override
public String getName() {
return "elevator";
}
@Override
public boolean isHidden() {
return true;
}
@Override
public void onExecute(CommandSender sender, String[] args) {
if (sender instanceof Player && args.length == 4) {
Player p = (Player) sender;
int x = Integer.parseInt(args[1]);
int y = Integer.parseInt(args[2]);
int z = Integer.parseInt(args[3]);
if (BlockStorage.getLocationInfo(p.getWorld().getBlockAt(x, y, z).getLocation(), "floor") != null) {
elevatorPlate.getUsers().add(p.getUniqueId());
float yaw = p.getEyeLocation().getYaw() + 180;
if (yaw > 180) yaw = -180 + (yaw - 180);
p.teleport(new Location(p.getWorld(), x + 0.5, y + 0.4, z + 0.5, yaw, p.getEyeLocation().getPitch()));
String floor = BlockStorage.getLocationInfo(p.getWorld().getBlockAt(x, y, z).getLocation(), "floor");
p.sendTitle(ChatColor.RESET + ChatColors.color(floor), " ", 20, 60, 20);
}
}
}
}

View File

@ -7,7 +7,9 @@ import java.util.Set;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -15,7 +17,6 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.cscorelib2.chat.json.ChatComponent;
import io.github.thebusybiscuit.cscorelib2.chat.json.ClickEvent;
import io.github.thebusybiscuit.cscorelib2.chat.json.ClickEventAction;
import io.github.thebusybiscuit.cscorelib2.chat.json.CustomBookInterface;
import io.github.thebusybiscuit.cscorelib2.chat.json.HoverEvent;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
@ -35,6 +36,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
private final Set<UUID> users = new HashSet<>();
private final NamespacedKey elevatorKey = new NamespacedKey(SlimefunPlugin.instance, "elevator");
public ElevatorPlate(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput);
@ -115,12 +117,23 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
if (block.getY() == b.getY()) {
line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.RESET + floor);
line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocal().getMessage(p, "machines.ELEVATOR.current-floor")), ChatColor.RESET + floor, ""));
line.setHoverEvent(new HoverEvent(ChatColor.RESET + floor, "", ChatColors.color(SlimefunPlugin.getLocal().getMessage(p, "machines.ELEVATOR.current-floor")), ChatColor.RESET + floor, ""));
}
else {
line = new ChatComponent("\n" + ChatColor.GRAY.toString() + (floors.size() - i) + ". " + ChatColor.RESET + floor);
line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocal().getMessage(p, "machines.ELEVATOR.click-to-teleport")), ChatColor.RESET + floor, ""));
line.setClickEvent(new ClickEvent(ClickEventAction.RUN_COMMAND, "/sf elevator " + block.getX() + ' ' + block.getY() + ' ' + block.getZ() + " "));
line.setHoverEvent(new HoverEvent(ChatColor.RESET + floor, "", ChatColors.color(SlimefunPlugin.getLocal().getMessage(p, "machines.ELEVATOR.click-to-teleport")), ChatColor.RESET + floor, ""));
line.setClickEvent(new ClickEvent(elevatorKey, player -> {
users.add(player.getUniqueId());
float yaw = player.getEyeLocation().getYaw() + 180;
if (yaw > 180) {
yaw = -180 + (yaw - 180);
}
player.teleport(new Location(player.getWorld(), block.getX() + 0.5, block.getY() + 0.4, block.getZ() + 0.5, yaw, player.getEyeLocation().getPitch()));
player.sendTitle(ChatColor.RESET + ChatColors.color(floor), " ", 20, 60, 20);
}));
}
page.append(line);