Pumpkin-Docs/docs/tr_TR/plugin-dev/migrating-from-bukkit/configuration.md
Alexander Medvedev 5c23b676ed feat: d binding
2026-09-17 09:23:24 +02:00

70 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Yapılandırma ve Veri Depolamayı Taşıma
Bukkit eklentileri büyük ölçüde `config.yml`, `YamlConfiguration` ve Bukkit yapılandırma serileştirme sistemine dayanır.
Pumpkin'da ise WebAssembly eklentileri; yapılandırma dosyalarının **TOML**, **JSON** veya **YAML** gibi standart formatlar kullanılarak yerel olarak işlenebildiği güvenli bir yalıtılmış ortamda (sandbox) çalışır.
---
## Temel Farklar
| Özellik | Bukkit / Spigot | Pumpkin |
| :--- | :--- | :--- |
| **Yapılandırma Dosyası Formatı** | `config.yml` (YAML formatı) | Esnek: TOML, JSON veya özel dosyalar |
| **Varsayılan Yapılandırma Oluşturma** | `saveDefaultConfig()` | Eklenti dizininden veya gömülü WASM varlığından yapılandırmayı okuma |
| **Veri Ayrıştırma (Parsing)** | `getConfig().getString(...)` | Yerel serde / JSON / TOML seri durumdan çıkarma (deserialization) |
| **Dosya G/Ç Yalıtımı (Sandboxing)** | Herhangi bir konuma doğrudan dosya sistemi erişimi | WASM eklentisine tanınan yalıtılmış dizin erişimi |
---
## Kod Karşılaştırması: Yapılandırma Yükleme
### 1. Bukkit Uygulaması (Java)
```java [ConfigExample.java]
public class ConfigExample extends JavaPlugin {
@Override
public void onEnable() {
saveDefaultConfig(); // Saves config.yml from jar resources
FileConfiguration config = getConfig();
String welcomeMsg = config.getString("welcome-message", "Default welcome!");
int maxItems = config.getInt("max-items", 10);
getLogger().info("Loaded message: " + welcomeMsg);
}
}
```
### 2. Pumpkin Uygulaması (Rust)
Pumpkin'da, temiz TOML yapılandırma dosyalarını ayrıştırmak için `serde::Deserialize` türetmesi yapabilirsiniz:
```rust [config.rs]
use serde::Deserialize;
use std::fs;
#[derive(Deserialize, Debug)]
pub struct PluginConfig {
pub welcome_message: String,
pub max_items: i32,
}
impl Default for PluginConfig {
fn default() -> Self {
Self {
welcome_message: "Default welcome!".to_string(),
max_items: 10,
}
}
}
pub fn load_config() -> PluginConfig {
let config_path = "plugins/my_plugin/config.toml";
if let Ok(content) = fs::read_to_string(config_path) {
toml::from_str(&content).unwrap_or_default()
} else {
PluginConfig::default()
}
}
```