Merge branch 'ClearCommand' of SteamWar/BauSystem into master
Dieser Commit ist enthalten in:
Commit
6dee5df474
@ -55,10 +55,11 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
CommandRemover.removeAll("tp", "gamemode", "time");
|
CommandRemover.removeAll("tp", "gamemode", "time", "clear");
|
||||||
CommandInjector.injectCommand(new CommandTeleport());
|
CommandInjector.injectCommand(new CommandTeleport());
|
||||||
CommandInjector.injectCommand(new CommandGamemode());
|
CommandInjector.injectCommand(new CommandGamemode());
|
||||||
CommandInjector.injectCommand(new CommandTime());
|
CommandInjector.injectCommand(new CommandTime());
|
||||||
|
CommandInjector.injectCommand(new CommandClear());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
getLogger().log(Level.SEVERE, "Failed to replace commands", e);
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
|
52
BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java
Normale Datei
52
BauSystem_Main/src/de/steamwar/bausystem/commands/CommandClear.java
Normale Datei
@ -0,0 +1,52 @@
|
|||||||
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.Permission;
|
||||||
|
import de.steamwar.bausystem.world.Welt;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class CommandClear extends BukkitCommand {
|
||||||
|
|
||||||
|
public CommandClear() {
|
||||||
|
super("clear");
|
||||||
|
description = "Leere dein Inventar oder das eines anderen 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){
|
||||||
|
clear(player);
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// check if admin
|
||||||
|
if(Welt.noPermission(player, Permission.world)){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "$cDu darfst hier keine fremden Inventare leeren.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Player target = Bukkit.getPlayerExact(args[1]);
|
||||||
|
if(!(target instanceof Player)){
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "Das ist kein Spieler.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
clear(target);
|
||||||
|
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von" + player.getDisplayName() +" geleert.");
|
||||||
|
player.sendMessage(BauSystem.PREFIX + "Das Inventar von" + target.getDisplayName() +" wurde geleert.");
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
private void clear(Player player){
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren