Better command handling in console

This commit is contained in:
mathiascode 2019-09-22 05:39:45 +03:00
parent 8ee75e8129
commit 660354e123
1 changed files with 18 additions and 14 deletions

View File

@ -24,20 +24,24 @@ class CommandWeapons implements CommandExecutor {
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
final Player player = (Player) sender;
final Inventory inventory = Bukkit.createInventory(null, 18, "Weapons");
addWeapon(inventory, Material.ANVIL, "§rAnvil Dropper");
addWeapon(inventory, Material.SPECTRAL_ARROW, "§rArcher");
addWeapon(inventory, Material.FIRE_CHARGE, "§rArmageddon");
addWeapon(inventory, Material.MAGMA_CREAM, "§rBlobinator");
addWeapon(inventory, Material.EGG, "§rGrenade");
addWeapon(inventory, Material.BLAZE_POWDER, "§rLaser");
addWeapon(inventory, Material.STICK, "§rLightning Stick");
addWeapon(inventory, Material.GOLDEN_HORSE_ARMOR, "§rMachine Gun");
addWeapon(inventory, Material.BLAZE_ROD, "§rNuker");
addWeapon(inventory, Material.IRON_HORSE_ARMOR, "§rSniper");
player.openInventory(inventory);
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage("Command has to be run by a player");
} else {
final Player player = (Player) sender;
final Inventory inventory = Bukkit.createInventory(null, 18, "Weapons");
addWeapon(inventory, Material.ANVIL, "§rAnvil Dropper");
addWeapon(inventory, Material.SPECTRAL_ARROW, "§rArcher");
addWeapon(inventory, Material.FIRE_CHARGE, "§rArmageddon");
addWeapon(inventory, Material.MAGMA_CREAM, "§rBlobinator");
addWeapon(inventory, Material.EGG, "§rGrenade");
addWeapon(inventory, Material.BLAZE_POWDER, "§rLaser");
addWeapon(inventory, Material.STICK, "§rLightning Stick");
addWeapon(inventory, Material.GOLDEN_HORSE_ARMOR, "§rMachine Gun");
addWeapon(inventory, Material.BLAZE_ROD, "§rNuker");
addWeapon(inventory, Material.IRON_HORSE_ARMOR, "§rSniper");
player.openInventory(inventory);
}
return true;
}
}