added /clear <Player> command and registered it in BauSystem.java
Dieser Commit ist enthalten in:
Ursprung
2170da811a
Commit
c0a70570c1
@ -55,10 +55,11 @@ public class BauSystem extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
try {
|
||||
CommandRemover.removeAll("tp", "gamemode", "time");
|
||||
CommandRemover.removeAll("tp", "gamemode", "time", "clear");
|
||||
CommandInjector.injectCommand(new CommandTeleport());
|
||||
CommandInjector.injectCommand(new CommandGamemode());
|
||||
CommandInjector.injectCommand(new CommandTime());
|
||||
CommandInjector.injectCommand(new CommandClear());
|
||||
} catch (Exception e) {
|
||||
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
||||
Bukkit.shutdown();
|
||||
|
71
BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java
Normale Datei
71
BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java
Normale Datei
@ -0,0 +1,71 @@
|
||||
package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.UserGroup;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandClear extends BukkitCommand {
|
||||
public CommandClear() {
|
||||
super("clear");
|
||||
description = "Leere dein Inventar oder das eines anderem Spielers.";
|
||||
usageMessage = "/clear [Spieler]";
|
||||
}
|
||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||
if (!(sender instanceof Player))
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
if (args.length == 1){
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||
player.getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||
player.getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||
player.getInventory().setBoots(new ItemStack(Material.AIR));
|
||||
player.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert.");
|
||||
return true;
|
||||
}
|
||||
if (args.length == 2){
|
||||
// check if admin
|
||||
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
|
||||
UserGroup userGroup = steamwarUser.getUserGroup();
|
||||
if(userGroup != UserGroup.Admin &&
|
||||
userGroup != UserGroup.Developer &&
|
||||
userGroup != UserGroup.Moderator &&
|
||||
userGroup != UserGroup.Supporter)
|
||||
return false;
|
||||
// check if target is player
|
||||
if(!(Bukkit.getPlayerExact(args[0]) instanceof Player)){
|
||||
player.sendMessage(BauSystem.PREFIX + "Das ist kein Spieler.");
|
||||
return false;
|
||||
}
|
||||
// clear
|
||||
Player target = Bukkit.getPlayerExact(args[0]);
|
||||
target.getInventory().clear();
|
||||
target.getInventory().setHelmet(new ItemStack (Material.AIR));
|
||||
target.getInventory().setChestplate(new ItemStack (Material.AIR));
|
||||
target.getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||
target.getInventory().setBoots(new ItemStack (Material.AIR));
|
||||
// Message
|
||||
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() +" geleert.");
|
||||
player.sendMessage(BauSystem.PREFIX + "Das Inventar von" + target.getDisplayName() +" wurde geleert.");
|
||||
return true;
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "/clear [Spieler]");
|
||||
return false;
|
||||
}
|
||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||
Validate.notNull(sender, "Sender cannot be null");
|
||||
Validate.notNull(args, "Arguments cannot be null");
|
||||
Validate.notNull(alias, "Alias cannot be null");
|
||||
|
||||
return super.tabComplete(sender, alias, args);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren