added /clear <Player> command and registered it in BauSystem.java
update: clear als void formuliert + statt admin world berechtigumg um andere zu clearen + mehr leerzeilen + kleinere optimierungen
Dieser Commit ist enthalten in:
Ursprung
c0a70570c1
Commit
432af1d6f6
@ -1,8 +1,8 @@
|
|||||||
package de.steamwar.bausystem.commands;
|
package de.steamwar.bausystem.commands;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bausystem.Permission;
|
||||||
import de.steamwar.sql.UserGroup;
|
import de.steamwar.bausystem.world.Welt;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -14,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandClear extends BukkitCommand {
|
public class CommandClear extends BukkitCommand {
|
||||||
|
|
||||||
public CommandClear() {
|
public CommandClear() {
|
||||||
super("clear");
|
super("clear");
|
||||||
description = "Leere dein Inventar oder das eines anderem Spielers.";
|
description = "Leere dein Inventar oder das eines anderem Spielers.";
|
||||||
@ -24,42 +25,32 @@ public class CommandClear extends BukkitCommand {
|
|||||||
return false;
|
return false;
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (args.length == 1){
|
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 Invenatre 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().clear();
|
||||||
player.getInventory().setHelmet(new ItemStack(Material.AIR));
|
player.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||||
player.getInventory().setChestplate(new ItemStack(Material.AIR));
|
player.getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||||
player.getInventory().setLeggings(new ItemStack(Material.AIR));
|
player.getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||||
player.getInventory().setBoots(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 {
|
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||||
Validate.notNull(sender, "Sender cannot be null");
|
Validate.notNull(sender, "Sender cannot be null");
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren