SteamWar/BauSystem2.0
Archiviert
12
0

Finalize Slot Command and some more touches on NoClipCommand

Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Chaoscaot 2021-06-04 00:22:43 +02:00
Ursprung c62ea3a33e
Commit 69f499afb6
3 geänderte Dateien mit 87 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -219,6 +219,7 @@ 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_SLOT_INVALID_SLOT=§cInvalid Slot
# Material
MATERIAL_BLAST-RESISTANCE = §8- §eBlast Resistance§8: §7{0}

Datei anzeigen

@ -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())) {

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<Integer> 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"));
}
}