Dateien nach "src/main/java/de/nexuslobby/commands" hochladen

This commit is contained in:
2026-01-22 14:54:41 +00:00
parent 64a2d82404
commit 09558932be
6 changed files with 393 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
package de.nexuslobby.commands;
import de.nexuslobby.NexusLobby;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import java.util.Arrays;
public class GivePortalToolCommand implements CommandExecutor {
private final NexusLobby plugin;
public GivePortalToolCommand(NexusLobby plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Nur Spieler können dieses Item erhalten.");
return true;
}
Player p = (Player) sender;
// Erstelle das Item
ItemStack wand = new ItemStack(Material.BLAZE_ROD);
ItemMeta meta = wand.getItemMeta();
// Design des Items
meta.setDisplayName("§cPortal-Werkzeug");
meta.setLore(Arrays.asList(
"§7Linksklick: Setze Position 1",
"§7Rechtsklick: Setze Position 2",
" ",
"§eNexusLobby Portal System"
));
// Füge einen unsichtbaren Tag hinzu (NBT), damit wir das Item eindeutig erkennen
NamespacedKey key = new NamespacedKey(plugin, "nexuslobby_portal_wand");
meta.getPersistentDataContainer().set(key, PersistentDataType.BYTE, (byte) 1);
wand.setItemMeta(meta);
p.getInventory().addItem(wand);
p.sendMessage(plugin.getName() + " §aDu hast das Portal-Werkzeug erhalten!");
p.playSound(p.getLocation(), org.bukkit.Sound.ENTITY_ITEM_PICKUP, 1.0f, 1.0f);
return true;
}
}