diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 77abd12c..69c3f87a 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -218,7 +218,8 @@ LOADTIMER_SUMARY_STATS_FREQ = §7Belade Frequenz: §e{0}/m§8, §7Schuss Frequen # Other OTHER_ITEMS_TELEPORT_GUI-NAME = Teleportieren -OTHER_ITEMS_TELEPORT_PLAYER-OFFLINE = §cDer Spieler ist Offline +OTHER_ITEMS_TELEPORT_PLAYER-OFFLINE=§cDer Spieler ist Offline +OTHER_SLOT_INVALID_SLOT=§cInvalid Slot # Material MATERIAL_BLAST-RESISTANCE = §8- §eBlast Resistance§8: §7{0} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java index 789b0696..bbd8e9de 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java @@ -69,7 +69,7 @@ public class NoClipCommand extends SWCommand implements Listener { } } }); - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getInstance(), PacketType.Play.Client.USE_ITEM, PacketType.Play.Client.BLOCK_DIG, PacketType.Play.Client.WINDOW_CLICK) { + ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(BauSystem.getInstance(), PacketType.Play.Client.USE_ITEM, PacketType.Play.Client.BLOCK_DIG, PacketType.Play.Client.WINDOW_CLICK, PacketType.Play.Client.SPECTATE) { @Override public void onPacketReceiving(PacketEvent event) { if (NOCLIPS.contains(event.getPlayer())) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/SlotCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/SlotCommand.java new file mode 100644 index 00000000..eaee813c --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/other/SlotCommand.java @@ -0,0 +1,84 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2021 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.other; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.SWUtils; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import java.util.Arrays; + +@Linked(LinkageType.COMMAND) +public class SlotCommand extends SWCommand { + + protected SlotCommand() { + super("slot", "s"); + } + + @Register(help = true) + public void genericHelp(Player player, String... args) { + + } + + @Register + public void slotCommand(Player player, Integer slot) { + if (slot < 1 || slot > 9) { + BauSystem.MESSAGE.send("OTHER_SLOT_INVALID_SLOT", player); + return; + } + player.getInventory().setHeldItemSlot(slot - 1); + } + + @Register("pick") + public void eyedropBlock(Player player) { + Block block = player.getTargetBlockExact(6); + ItemStack itemStack; + if (block == null) { + itemStack = new ItemStack(Material.AIR); + } else { + itemStack = new ItemStack(block.getType()); + } + SWUtils.giveItemToPlayer(player, itemStack); + } + + @Register("drop") + public void dropBlock(Player player) { + player.getInventory().setItemInMainHand(new ItemStack(Material.AIR)); + } + + @ClassMapper(value = Integer.class, local = true) + private TypeMapper integerTypeMapper() { + return SWCommandUtils.createMapper(s -> { + try { + return Integer.parseInt(s); + } catch (NumberFormatException e) { + return null; + } + }, (commandSender, s) -> Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9")); + } +}