public class SimplePlugin extends JavaPlugin {
private InventoryManager inventoryManager;
@Override
public void onEnable() {
final Inventory shopInventory = this.getServer().createInventory(null, 9*3, "Ekwipunek sklepu");
shopInventory.setItem(0, new ItemStack(Material.GLASS));
this.inventoryManager = new InventoryManager(shopInventory);
}
public InventoryManager getInventoryManager() {
return this.inventoryManager;
}
}
public class InventoryManager {
private final Inventory shopInventory;
public InventoryManager(Inventory shopInventory) {
this.shopInventory = shopInventory;
}
public void openShopInventory(Player player) {
player.openInventory(this.shopInventory);
}
}
i w komendzie wtedy tylko:
public class SimpleCommand implements CommandExecutor {
private final InventoryManager inventoryManager;
public SimpleCommand(InventoryManager inventoryManager) {
this.inventoryManager = inventoryManager;
}
@Override
public boolean onCommand(CommandSender sender, ....) {
if (!(sender instanceof Player)) {
sender.sendMessage("this command is only executable by player");
return true;
}
final Player player = (Player) sender;
this.inventoryManager.openShopInventory(player);
player.sendMessage(ChatColor.RED + "Otworzono ekwipunek sklepu!");
}
}
naprawde, zacznij sobie pierw od pisania malych programów, tak zeby kod ladnie wygladal i bylo to czytelne dla kazdego kto by ten kod czytał i żeby był w stanie ten twój kod zedytować i sie w nim połapać, bo jak zaczynasz od mc to później takie problemy są, że niby coś tam w bukkicie umiesz, ale nawet nie wiesz jak to działa i kod wychodzi tak jak wychodzi =/