Tabii ki, işte tüm kodları bir metin içinde ve Bukkit Configuration API kullanarak yazılmış hali:
```java
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
public class CustomMenuPlugin extends JavaPlugin implements Listener {
private FileConfiguration config;
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
saveDefaultConfig();
config = getConfig();
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (event.getView().getTitle().equals("Özel Menü")) {
event.setCancelled(true);
if (event.getRawSlot() < event.getInventory().getSize()) {
Player player = (Player) event.getWhoClicked();
// Eşya ekleyip almak için gerekli işlemleri burada yapın
savePlayerInventory(player, event.getInventory());
}
}
}
public void savePlayerInventory(Player player, Inventory inventory) {
ConfigurationSection playerSection = config.getConfigurationSection("custom-menu.player-inventories");
if (playerSection == null) {
playerSection = config.createSection("custom-menu.player-inventories");
}
playerSection.set(player.getUniqueId().toString(), inventory.getContents());
saveConfig();
}
public Inventory loadPlayerInventory(Player player) {
ConfigurationSection playerSection = config.getConfigurationSection("custom-menu.player-inventories");
if (playerSection != null && playerSection.contains(player.getUniqueId().toString())) {
Inventory inventory = getServer().createInventory(null, 27, "Özel Menü");
inventory.setContents(playerSection.getList(player.getUniqueId().toString()).toArray(new org.bukkit.inventory.ItemStack[0]));
return inventory;
}
return null;
}
}
```
Bu kod, oyuncuların menüye eşya ekleyip almasını ve bu işlemleri YAML dosyasında kaydetmesini sağlar. Ayrıca, `savePlayerInventory` ve `loadPlayerInventory` fonksiyonları, oyuncuların envanterini kaydetmek ve yüklemek için kullanılır.