Compare commits
1 Commits
77ae1d6ed9
...
1.0.7
Author | SHA1 | Date | |
---|---|---|---|
73fed5acc5 |
4
pom.xml
4
pom.xml
@@ -6,7 +6,8 @@
|
|||||||
|
|
||||||
<groupId>de.viper</groupId>
|
<groupId>de.viper</groupId>
|
||||||
<artifactId>SurvivalPlus</artifactId>
|
<artifactId>SurvivalPlus</artifactId>
|
||||||
<version>1.0.8-Beta</version>
|
<version>1.0.7-Beta</version>
|
||||||
|
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SurvivalPlus</name>
|
<name>SurvivalPlus</name>
|
||||||
@@ -112,7 +113,6 @@
|
|||||||
<include>warps.yml</include>
|
<include>warps.yml</include>
|
||||||
<include>tablist.yml</include>
|
<include>tablist.yml</include>
|
||||||
<include>blockedcommands.yml</include>
|
<include>blockedcommands.yml</include>
|
||||||
<include>claims.yml</include>
|
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -11,7 +11,6 @@ import de.viper.survivalplus.recipe.BackpackRecipe;
|
|||||||
import de.viper.survivalplus.Manager.StatsManager;
|
import de.viper.survivalplus.Manager.StatsManager;
|
||||||
import de.viper.survivalplus.Manager.BlockManager;
|
import de.viper.survivalplus.Manager.BlockManager;
|
||||||
import de.viper.survivalplus.util.LockSystem;
|
import de.viper.survivalplus.util.LockSystem;
|
||||||
import de.viper.survivalplus.util.Claim;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -39,19 +38,24 @@ import de.viper.survivalplus.Manager.CommandBlocker;
|
|||||||
import de.viper.survivalplus.Manager.WarpManager;
|
import de.viper.survivalplus.Manager.WarpManager;
|
||||||
import de.viper.survivalplus.commands.SetWarpCommand;
|
import de.viper.survivalplus.commands.SetWarpCommand;
|
||||||
import de.viper.survivalplus.commands.WarpsCommand;
|
import de.viper.survivalplus.commands.WarpsCommand;
|
||||||
|
|
||||||
import de.viper.survivalplus.fun.FunChallengeManager;
|
import de.viper.survivalplus.fun.FunChallengeManager;
|
||||||
import de.viper.survivalplus.listeners.ChallengeCollectListener;
|
import de.viper.survivalplus.listeners.ChallengeCollectListener;
|
||||||
import de.viper.survivalplus.commands.StartFunChallengeCommand;
|
import de.viper.survivalplus.commands.StartFunChallengeCommand;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
// Zusätzliche Imports für Block-/Permission-Handling
|
||||||
import org.bukkit.GameRule;
|
import org.bukkit.GameRule;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@@ -64,8 +68,6 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SurvivalPlus extends JavaPlugin {
|
public class SurvivalPlus extends JavaPlugin {
|
||||||
|
|
||||||
@@ -87,12 +89,15 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
private FileConfiguration mobCapConfig;
|
private FileConfiguration mobCapConfig;
|
||||||
private FileConfiguration tablistConfig;
|
private FileConfiguration tablistConfig;
|
||||||
private File tablistFile;
|
private File tablistFile;
|
||||||
|
|
||||||
private File nicknamesFile;
|
private File nicknamesFile;
|
||||||
private FileConfiguration nicknamesConfig;
|
private FileConfiguration nicknamesConfig;
|
||||||
private SpawnProtectionListener spawnProtectionListener;
|
private SpawnProtectionListener spawnProtectionListener;
|
||||||
private int autoClearTaskId = -1;
|
private int autoClearTaskId = -1;
|
||||||
private StatsManager statsManager;
|
private StatsManager statsManager;
|
||||||
private NewbieProtectionListener newbieListener;
|
private NewbieProtectionListener newbieListener;
|
||||||
|
|
||||||
|
// Listener als Felder speichern
|
||||||
private MobLeashLimitListener mobLeashLimitListener;
|
private MobLeashLimitListener mobLeashLimitListener;
|
||||||
private MobCapListener mobCapListener;
|
private MobCapListener mobCapListener;
|
||||||
private SleepListener sleepListener;
|
private SleepListener sleepListener;
|
||||||
@@ -104,28 +109,32 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
private FunChallengeManager challengeManager;
|
private FunChallengeManager challengeManager;
|
||||||
private NamespacedKey droppedKey;
|
private NamespacedKey droppedKey;
|
||||||
private Map<UUID, Integer> progressMap = new HashMap<>();
|
private Map<UUID, Integer> progressMap = new HashMap<>();
|
||||||
|
|
||||||
|
// WarpManager als Feld
|
||||||
private WarpManager warpManager;
|
private WarpManager warpManager;
|
||||||
|
|
||||||
|
// FunChallengeManager als Feld
|
||||||
private FunChallengeManager funChallengeManager;
|
private FunChallengeManager funChallengeManager;
|
||||||
|
|
||||||
private File blockedCommandsFile;
|
private File blockedCommandsFile;
|
||||||
private FileConfiguration blockedCommandsConfig;
|
private FileConfiguration blockedCommandsConfig;
|
||||||
|
|
||||||
|
// Felder für Executor-Instanzen
|
||||||
private LockSystem lockSystem;
|
private LockSystem lockSystem;
|
||||||
private PluginCommand pluginCommand;
|
private PluginCommand pluginCommand;
|
||||||
private Map<String, Claim> claims = new HashMap<>();
|
|
||||||
private File claimsFile;
|
|
||||||
private FileConfiguration claimsConfig;
|
|
||||||
private Map<UUID, Integer> playerClaimCounts = new HashMap<>();
|
|
||||||
private Map<UUID, Location> point1Selections = new HashMap<>();
|
|
||||||
private Map<UUID, Location> point2Selections = new HashMap<>();
|
|
||||||
|
|
||||||
|
// ------------------- Tablist Config -------------------
|
||||||
public void reloadTablistConfig() {
|
public void reloadTablistConfig() {
|
||||||
|
// Lädt die tablist.yml aus dem Plugin-Ordner neu
|
||||||
if (tablistFile == null) tablistFile = new File(getDataFolder(), "tablist.yml");
|
if (tablistFile == null) tablistFile = new File(getDataFolder(), "tablist.yml");
|
||||||
if (!tablistFile.exists()) {
|
if (!tablistFile.exists()) {
|
||||||
saveResource("tablist.yml", false);
|
saveResource("tablist.yml", false); // kopiert die default tablist.yml, falls sie fehlt
|
||||||
}
|
}
|
||||||
tablistConfig = YamlConfiguration.loadConfiguration(tablistFile);
|
tablistConfig = YamlConfiguration.loadConfiguration(tablistFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileConfiguration getTablistConfig() {
|
public FileConfiguration getTablistConfig() {
|
||||||
|
// Stellt sicher, dass die Config geladen ist
|
||||||
if (tablistConfig == null) {
|
if (tablistConfig == null) {
|
||||||
reloadTablistConfig();
|
reloadTablistConfig();
|
||||||
}
|
}
|
||||||
@@ -165,11 +174,15 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
} catch (IOException ignored) {}
|
} catch (IOException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
// Default-Config sicherstellen
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
|
// bStats initialisieren
|
||||||
int pluginId = 26886;
|
int pluginId = 26886;
|
||||||
Metrics metrics = new Metrics(this, pluginId);
|
Metrics metrics = new Metrics(this, pluginId);
|
||||||
|
|
||||||
metrics.addCustomChart(new SimplePie(
|
metrics.addCustomChart(new SimplePie(
|
||||||
"default_gamemode",
|
"default_gamemode",
|
||||||
() -> Bukkit.getDefaultGameMode().toString()
|
() -> Bukkit.getDefaultGameMode().toString()
|
||||||
@@ -182,6 +195,8 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
"plugin_language",
|
"plugin_language",
|
||||||
() -> getConfig().getString("language", "default")
|
() -> getConfig().getString("language", "default")
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// Konfigurationen/Dateien laden
|
||||||
updateConfigFiles();
|
updateConfigFiles();
|
||||||
createHomesFile();
|
createHomesFile();
|
||||||
createGravesFile();
|
createGravesFile();
|
||||||
@@ -191,8 +206,11 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
createMobCapFile();
|
createMobCapFile();
|
||||||
createNicknamesFile();
|
createNicknamesFile();
|
||||||
reloadBlockedCommandsConfig();
|
reloadBlockedCommandsConfig();
|
||||||
loadClaims();
|
|
||||||
|
// PluginManager holen (vor Listener-Registrierung!)
|
||||||
PluginManager pluginManager = getServer().getPluginManager();
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
|
|
||||||
|
// Permission registrieren: survivalplus.notify für OPs standardmäßig aktiv
|
||||||
try {
|
try {
|
||||||
Permission notifyPerm = new Permission("survivalplus.notify", PermissionDefault.OP);
|
Permission notifyPerm = new Permission("survivalplus.notify", PermissionDefault.OP);
|
||||||
if (pluginManager.getPermission("survivalplus.notify") == null) {
|
if (pluginManager.getPermission("survivalplus.notify") == null) {
|
||||||
@@ -202,45 +220,57 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().warning("Fehler beim Registrieren der Permission survivalplus.notify: " + e.getMessage());
|
getLogger().warning("Fehler beim Registrieren der Permission survivalplus.notify: " + e.getMessage());
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
Permission claimPerm = new Permission("survivalplus.claim.use", PermissionDefault.TRUE);
|
// NamespacedKey für Item-Drop-Markierung erzeugen
|
||||||
Permission trustPerm = new Permission("survivalplus.claim.trust", PermissionDefault.TRUE);
|
|
||||||
if (pluginManager.getPermission("survivalplus.claim.use") == null) {
|
|
||||||
pluginManager.addPermission(claimPerm);
|
|
||||||
getLogger().info("Permission survivalplus.claim.use erfolgreich registriert.");
|
|
||||||
}
|
|
||||||
if (pluginManager.getPermission("survivalplus.claim.trust") == null) {
|
|
||||||
pluginManager.addPermission(trustPerm);
|
|
||||||
getLogger().info("Permission survivalplus.claim.trust erfolgreich registriert.");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().warning("Fehler beim Registrieren der Claim-Permissions: " + e.getMessage());
|
|
||||||
}
|
|
||||||
droppedKey = new NamespacedKey(this, "droppedItem");
|
droppedKey = new NamespacedKey(this, "droppedItem");
|
||||||
|
|
||||||
|
// FunChallengeManager initialisieren und laden
|
||||||
funChallengeManager = new FunChallengeManager();
|
funChallengeManager = new FunChallengeManager();
|
||||||
funChallengeManager.load(getConfig());
|
funChallengeManager.load(getConfig());
|
||||||
|
|
||||||
|
// Listener registrieren mit droppedKey
|
||||||
pluginManager.registerEvents(new ChallengeCollectListener(funChallengeManager, droppedKey), this);
|
pluginManager.registerEvents(new ChallengeCollectListener(funChallengeManager, droppedKey), this);
|
||||||
pluginManager.registerEvents(new ChallengeSmeltListener(funChallengeManager), this);
|
pluginManager.registerEvents(new ChallengeSmeltListener(funChallengeManager), this);
|
||||||
|
|
||||||
|
// FriendCommand
|
||||||
FriendCommand friendCommand = new FriendCommand(this, friendsConfig, langConfig, getLogger());
|
FriendCommand friendCommand = new FriendCommand(this, friendsConfig, langConfig, getLogger());
|
||||||
|
|
||||||
getCommand("day").setExecutor(new DayCommand(this));
|
getCommand("day").setExecutor(new DayCommand(this));
|
||||||
getCommand("night").setExecutor(new NightCommand(this));
|
getCommand("night").setExecutor(new NightCommand(this));
|
||||||
|
|
||||||
CommandBlocker commandBlocker = new CommandBlocker(this);
|
CommandBlocker commandBlocker = new CommandBlocker(this);
|
||||||
pluginCommand = new PluginCommand(this);
|
pluginCommand = new PluginCommand(this);
|
||||||
getCommand("sp").setExecutor(pluginCommand);
|
getCommand("sp").setExecutor(pluginCommand);
|
||||||
|
|
||||||
|
// TradeManager und ReportManager initialisieren
|
||||||
TradeManager tradeManager = new TradeManager(this);
|
TradeManager tradeManager = new TradeManager(this);
|
||||||
ReportManager reportManager = new ReportManager(this);
|
ReportManager reportManager = new ReportManager(this);
|
||||||
|
|
||||||
|
// Report Commands registrieren
|
||||||
getCommand("report").setExecutor(new ReportCommand(this, reportManager));
|
getCommand("report").setExecutor(new ReportCommand(this, reportManager));
|
||||||
getCommand("showreport").setExecutor(new ShowReportCommand(this, reportManager));
|
getCommand("showreport").setExecutor(new ShowReportCommand(this, reportManager));
|
||||||
getCommand("clearreport").setExecutor(new ClearReportCommand(this, reportManager));
|
getCommand("clearreport").setExecutor(new ClearReportCommand(this, reportManager));
|
||||||
|
|
||||||
|
// Trade Commands registrieren
|
||||||
getCommand("trade").setExecutor(new TradeCommand(this, tradeManager));
|
getCommand("trade").setExecutor(new TradeCommand(this, tradeManager));
|
||||||
getCommand("tradeaccept").setExecutor(new TradeAcceptCommand(this, tradeManager));
|
getCommand("tradeaccept").setExecutor(new TradeAcceptCommand(this, tradeManager));
|
||||||
|
|
||||||
|
// StatsManager initialisieren
|
||||||
statsManager = new StatsManager(this);
|
statsManager = new StatsManager(this);
|
||||||
|
|
||||||
|
// warpManager initialisieren
|
||||||
warpManager = new WarpManager(this);
|
warpManager = new WarpManager(this);
|
||||||
|
|
||||||
|
// TablistManager starten
|
||||||
TablistManager tablistManager = new TablistManager(this);
|
TablistManager tablistManager = new TablistManager(this);
|
||||||
|
|
||||||
|
// Listener-Instanzen
|
||||||
sitListener = new SitListener(this);
|
sitListener = new SitListener(this);
|
||||||
afkListener = new AFKListener(this);
|
afkListener = new AFKListener(this);
|
||||||
graveListener = new GraveListener(this);
|
graveListener = new GraveListener(this);
|
||||||
playerJoinListener = new PlayerJoinListener(friendCommand);
|
playerJoinListener = new PlayerJoinListener(friendCommand);
|
||||||
|
|
||||||
|
// Commands registrieren (Rest)
|
||||||
getCommand("gm").setExecutor(new GamemodeCommand(this));
|
getCommand("gm").setExecutor(new GamemodeCommand(this));
|
||||||
getCommand("sp").setExecutor(new PluginCommand(this));
|
getCommand("sp").setExecutor(new PluginCommand(this));
|
||||||
getCommand("sethome").setExecutor(new HomeCommand(this));
|
getCommand("sethome").setExecutor(new HomeCommand(this));
|
||||||
@@ -279,13 +309,18 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
getCommand("kit").setExecutor(new KitCommand(this));
|
getCommand("kit").setExecutor(new KitCommand(this));
|
||||||
getCommand("heal").setExecutor(new HealCommand(this));
|
getCommand("heal").setExecutor(new HealCommand(this));
|
||||||
getCommand("sp").setExecutor(commandBlocker);
|
getCommand("sp").setExecutor(commandBlocker);
|
||||||
|
|
||||||
|
// LootChestManager + Befehle
|
||||||
LootChestManager lootChestManager = new LootChestManager(this);
|
LootChestManager lootChestManager = new LootChestManager(this);
|
||||||
pluginManager.registerEvents(lootChestManager, this);
|
pluginManager.registerEvents(lootChestManager, this);
|
||||||
getCommand("lootchests").setExecutor(lootChestManager);
|
getCommand("lootchests").setExecutor(lootChestManager);
|
||||||
getCommand("tploot").setExecutor(lootChestManager);
|
getCommand("tploot").setExecutor(lootChestManager);
|
||||||
getCommand("claim").setExecutor(new ClaimCommand(this));
|
|
||||||
|
// BlockManager
|
||||||
BlockManager blockManager = new BlockManager();
|
BlockManager blockManager = new BlockManager();
|
||||||
FileConfiguration config = getConfig();
|
FileConfiguration config = getConfig();
|
||||||
|
|
||||||
|
// Listener registrieren
|
||||||
BackpackRecipe.register(this, langConfig);
|
BackpackRecipe.register(this, langConfig);
|
||||||
pluginManager.registerEvents(new ChatBlockListener(blockManager), this);
|
pluginManager.registerEvents(new ChatBlockListener(blockManager), this);
|
||||||
pluginManager.registerEvents(new InventoryClickListener(this), this);
|
pluginManager.registerEvents(new InventoryClickListener(this), this);
|
||||||
@@ -309,10 +344,12 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
pluginManager.registerEvents(new WarpInventoryListener(this, warpManager), this);
|
pluginManager.registerEvents(new WarpInventoryListener(this, warpManager), this);
|
||||||
pluginManager.registerEvents(new ChallengeSmeltListener(funChallengeManager), this);
|
pluginManager.registerEvents(new ChallengeSmeltListener(funChallengeManager), this);
|
||||||
pluginManager.registerEvents(new BlockDetectionListener(this), this);
|
pluginManager.registerEvents(new BlockDetectionListener(this), this);
|
||||||
pluginManager.registerEvents(new ClaimListener(this), this);
|
|
||||||
lockSystem = new LockSystem(this);
|
lockSystem = new LockSystem(this);
|
||||||
pluginManager.registerEvents(lockSystem, this);
|
pluginManager.registerEvents(lockSystem, this);
|
||||||
getCommand("sp").setExecutor(lockSystem);
|
getCommand("sp").setExecutor(lockSystem);
|
||||||
|
|
||||||
|
// Kombinierter Executor für /sp, um alle Subcommands zu handhaben
|
||||||
getCommand("sp").setExecutor(new CommandExecutor() {
|
getCommand("sp").setExecutor(new CommandExecutor() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@@ -332,61 +369,87 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
return pluginCommand.onCommand(sender, command, label, args);
|
return pluginCommand.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
pluginManager.registerEvents(new RepairSignListener(getConfig(), getLangConfig()), this);
|
pluginManager.registerEvents(new RepairSignListener(getConfig(), getLangConfig()), this);
|
||||||
pluginManager.registerEvents(new ToolUpgradeListener(this), this);
|
pluginManager.registerEvents(new ToolUpgradeListener(this), this);
|
||||||
pluginManager.registerEvents(new NickLoadListener(this), this);
|
pluginManager.registerEvents(new NickLoadListener(this), this);
|
||||||
|
|
||||||
|
// AutoClear starten
|
||||||
startAutoClearTask();
|
startAutoClearTask();
|
||||||
spawnArmorStandExample();
|
spawnArmorStandExample();
|
||||||
getLogger().info(getMessage("plugin.enabled"));
|
getLogger().info(getMessage("plugin.enabled"));
|
||||||
|
|
||||||
|
// === Gamerule keepInventory aus Config setzen ===
|
||||||
if (getConfig().getBoolean("set-keepinventory", true)) {
|
if (getConfig().getBoolean("set-keepinventory", true)) {
|
||||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||||
if (Bukkit.getWorlds().isEmpty()) return;
|
if (Bukkit.getWorlds().isEmpty()) return;
|
||||||
|
|
||||||
Bukkit.getWorlds().forEach(world -> {
|
Bukkit.getWorlds().forEach(world -> {
|
||||||
world.setGameRule(GameRule.KEEP_INVENTORY, false);
|
world.setGameRule(GameRule.KEEP_INVENTORY, false);
|
||||||
getLogger().info("Gamerule keepInventory in Welt '" + world.getName() + "' wurde auf false gesetzt.");
|
getLogger().info("Gamerule keepInventory in Welt '" + world.getName() + "' wurde auf false gesetzt.");
|
||||||
});
|
});
|
||||||
}, 20L);
|
}, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Force Survival Mode aktivieren ===
|
||||||
if (getConfig().getBoolean("force-survival", true)) {
|
if (getConfig().getBoolean("force-survival", true)) {
|
||||||
pluginManager.registerEvents(new ForceSurvivalListener(this), this);
|
pluginManager.registerEvents(new ForceSurvivalListener(this), this);
|
||||||
getLogger().info("Force-Survival ist aktiv. Spieler werden beim Joinen in Survival gesetzt.");
|
getLogger().info("Force-Survival ist aktiv. Spieler werden beim Joinen in Survival gesetzt.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Animierte Tablist konfigurieren und starten ===
|
||||||
try {
|
try {
|
||||||
|
// tablist.yml laden / defaults setzen
|
||||||
if (tablistFile == null) tablistFile = new File(getDataFolder(), "tablist.yml");
|
if (tablistFile == null) tablistFile = new File(getDataFolder(), "tablist.yml");
|
||||||
if (!tablistFile.exists()) {
|
if (!tablistFile.exists()) {
|
||||||
saveResource("tablist.yml", false);
|
saveResource("tablist.yml", false);
|
||||||
}
|
}
|
||||||
tablistConfig = YamlConfiguration.loadConfiguration(tablistFile);
|
tablistConfig = YamlConfiguration.loadConfiguration(tablistFile);
|
||||||
|
|
||||||
|
// Standardwerte aus Resource als Defaults setzen (falls vorhanden)
|
||||||
InputStream defStream = getResource("tablist.yml");
|
InputStream defStream = getResource("tablist.yml");
|
||||||
if (defStream != null) {
|
if (defStream != null) {
|
||||||
tablistConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defStream)));
|
tablistConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defStream)));
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().info("Animierte Tablist wurde geladen!");
|
getLogger().info("Animierte Tablist wurde geladen!");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getLogger().log(Level.WARNING, "Fehler beim Laden der Tablist-Konfiguration", e);
|
getLogger().log(Level.WARNING, "Fehler beim Laden der Tablist-Konfiguration", e);
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskLater(this, this::applyBlockRules, 20L);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void applyBlockRules() {
|
// === Gamerules anwenden (kurze Verzögerung, damit Welten geladen sind) ===
|
||||||
|
Bukkit.getScheduler().runTaskLater(this, this::applyBlockRules, 20L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liest Config und setzt GameRule sowie entfernt verbotene Blöcke aus Inventaren online
|
||||||
|
*/
|
||||||
|
public void applyBlockRules() {
|
||||||
boolean cmdAllowed = getConfig().getBoolean("blocks.command-blocks.enabled", true);
|
boolean cmdAllowed = getConfig().getBoolean("blocks.command-blocks.enabled", true);
|
||||||
boolean structAllowed = getConfig().getBoolean("blocks.structure-blocks.enabled", true);
|
boolean structAllowed = getConfig().getBoolean("blocks.structure-blocks.enabled", true);
|
||||||
|
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
try {
|
try {
|
||||||
|
// moderner API-Aufruf
|
||||||
world.setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, cmdAllowed);
|
world.setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, cmdAllowed);
|
||||||
} catch (NoSuchMethodError | NoClassDefFoundError e) {
|
} catch (NoSuchMethodError | NoClassDefFoundError e) {
|
||||||
|
// Fallback für ältere Server-Implementationen
|
||||||
world.setGameRuleValue(GameRule.COMMAND_BLOCK_OUTPUT.getName(), Boolean.toString(cmdAllowed));
|
world.setGameRuleValue(GameRule.COMMAND_BLOCK_OUTPUT.getName(), Boolean.toString(cmdAllowed));
|
||||||
}
|
}
|
||||||
getLogger().info("Gamerule commandBlockOutput in Welt '" + world.getName() + "' gesetzt auf " + cmdAllowed);
|
getLogger().info("Gamerule commandBlockOutput in Welt '" + world.getName() + "' gesetzt auf " + cmdAllowed);
|
||||||
}
|
}
|
||||||
removeForbiddenBlocksFromInventories(cmdAllowed, structAllowed);
|
|
||||||
getLogger().info("Block-Regeln angewendet: CommandBlocks erlaubt=" + cmdAllowed + ", StructureBlocks erlaubt=" + structAllowed);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeForbiddenBlocksFromInventories(boolean cmdAllowed, boolean structAllowed) {
|
// Entferne verbotenes Zeug aus Inventaren aller online-Spieler direkt beim Start
|
||||||
|
removeForbiddenBlocksFromInventories(cmdAllowed, structAllowed);
|
||||||
|
|
||||||
|
getLogger().info("Block-Regeln angewendet: CommandBlocks erlaubt=" + cmdAllowed + ", StructureBlocks erlaubt=" + structAllowed);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Entfernt Command-/Structure-Blöcke aus Inventaren falls deaktiviert, ausgenommen Admins */
|
||||||
|
private void removeForbiddenBlocksFromInventories(boolean cmdAllowed, boolean structAllowed) {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
if (p.hasPermission("survivalplus.notify")) {
|
if (p.hasPermission("survivalplus.notify")) {
|
||||||
continue;
|
continue; // Admins dürfen Blöcke behalten
|
||||||
}
|
}
|
||||||
Inventory inv = p.getInventory();
|
Inventory inv = p.getInventory();
|
||||||
boolean removedCommandBlock = false;
|
boolean removedCommandBlock = false;
|
||||||
@@ -401,13 +464,15 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
removedStructureBlock = true;
|
removedStructureBlock = true;
|
||||||
p.sendMessage(ChatColor.RED + "[SurvivalPlus] Structure-Blöcke wurden aus deinem Inventar entfernt, da sie deaktiviert sind.");
|
p.sendMessage(ChatColor.RED + "[SurvivalPlus] Structure-Blöcke wurden aus deinem Inventar entfernt, da sie deaktiviert sind.");
|
||||||
}
|
}
|
||||||
|
// Benachrichtige Admins über entfernte Blöcke
|
||||||
if ((removedCommandBlock || removedStructureBlock) && getConfig().getBoolean("blocks.notify-admins-on-possession", true)) {
|
if ((removedCommandBlock || removedStructureBlock) && getConfig().getBoolean("blocks.notify-admins-on-possession", true)) {
|
||||||
notifyAdmins(p.getName(), removedCommandBlock, removedStructureBlock);
|
notifyAdmins(p.getName(), removedCommandBlock, removedStructureBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyAdmins(String playerName, boolean hadCommandBlock, boolean hadStructureBlock) {
|
/** Benachrichtigt Admins über entfernte Blöcke */
|
||||||
|
private void notifyAdmins(String playerName, boolean hadCommandBlock, boolean hadStructureBlock) {
|
||||||
String baseTag = ChatColor.GRAY + "[" + ChatColor.GREEN + "SurvivalPlus" + ChatColor.GRAY + "] ";
|
String baseTag = ChatColor.GRAY + "[" + ChatColor.GREEN + "SurvivalPlus" + ChatColor.GRAY + "] ";
|
||||||
for (Player admin : Bukkit.getOnlinePlayers()) {
|
for (Player admin : Bukkit.getOnlinePlayers()) {
|
||||||
if (admin.hasPermission("survivalplus.notify")) {
|
if (admin.hasPermission("survivalplus.notify")) {
|
||||||
@@ -421,143 +486,7 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createClaimsFile() {
|
|
||||||
claimsFile = new File(getDataFolder(), "claims.yml");
|
|
||||||
if (!claimsFile.exists()) {
|
|
||||||
try {
|
|
||||||
claimsFile.createNewFile();
|
|
||||||
} catch (IOException e) {
|
|
||||||
getLogger().log(Level.SEVERE, "Fehler beim Erstellen der claims.yml", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
claimsConfig = YamlConfiguration.loadConfiguration(claimsFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadClaims() {
|
|
||||||
createClaimsFile();
|
|
||||||
for (String key : claimsConfig.getKeys(false)) {
|
|
||||||
try {
|
|
||||||
UUID owner = UUID.fromString(claimsConfig.getString(key + ".owner"));
|
|
||||||
String worldName = claimsConfig.getString(key + ".world");
|
|
||||||
int x1 = claimsConfig.getInt(key + ".x1");
|
|
||||||
int z1 = claimsConfig.getInt(key + ".z1");
|
|
||||||
int x2 = claimsConfig.getInt(key + ".x2");
|
|
||||||
int z2 = claimsConfig.getInt(key + ".z2");
|
|
||||||
Claim claim = new Claim(owner, worldName, x1, z1, x2, z2);
|
|
||||||
List<String> trustedList = claimsConfig.getStringList(key + ".trusted");
|
|
||||||
for (String trustedStr : trustedList) {
|
|
||||||
claim.addTrusted(UUID.fromString(trustedStr));
|
|
||||||
}
|
|
||||||
claims.put(key, claim);
|
|
||||||
playerClaimCounts.merge(owner, 1, Integer::sum);
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().warning("Invalid claim data for key: " + key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void saveClaims() {
|
|
||||||
for (Map.Entry<String, Claim> entry : claims.entrySet()) {
|
|
||||||
String key = entry.getKey();
|
|
||||||
Claim claim = entry.getValue();
|
|
||||||
claimsConfig.set(key + ".owner", claim.getOwner().toString());
|
|
||||||
claimsConfig.set(key + ".x1", claim.getX1());
|
|
||||||
claimsConfig.set(key + ".z1", claim.getZ1());
|
|
||||||
claimsConfig.set(key + ".x2", claim.getX2());
|
|
||||||
claimsConfig.set(key + ".z2", claim.getZ2());
|
|
||||||
claimsConfig.set(key + ".world", claim.getWorldName());
|
|
||||||
List<String> trustedList = new ArrayList<>();
|
|
||||||
for (UUID trusted : claim.getTrusted()) {
|
|
||||||
trustedList.add(trusted.toString());
|
|
||||||
}
|
|
||||||
claimsConfig.set(key + ".trusted", trustedList);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
claimsConfig.save(claimsFile);
|
|
||||||
} catch (IOException e) {
|
|
||||||
getLogger().log(Level.SEVERE, "Fehler beim Speichern der claims.yml", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Claim getClaim(Location location) {
|
|
||||||
for (Claim claim : claims.values()) {
|
|
||||||
if (claim.isInside(location)) {
|
|
||||||
return claim;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addClaim(Claim claim, Player player) {
|
|
||||||
String key = claim.getWorldName() + ":" + claim.getX1() + ":" + claim.getZ1() + ":" + claim.getX2() + ":" + claim.getZ2();
|
|
||||||
claims.put(key, claim);
|
|
||||||
playerClaimCounts.merge(player.getUniqueId(), 1, Integer::sum);
|
|
||||||
saveClaims();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeClaim(Location location, Player player) {
|
|
||||||
String key = null;
|
|
||||||
for (Map.Entry<String, Claim> entry : claims.entrySet()) {
|
|
||||||
if (entry.getValue().isInside(location)) {
|
|
||||||
key = entry.getKey();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (key != null) {
|
|
||||||
claims.remove(key);
|
|
||||||
playerClaimCounts.merge(player.getUniqueId(), -1, Integer::sum);
|
|
||||||
saveClaims();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeClaimByKey(String key, UUID playerUUID) {
|
|
||||||
claims.remove(key);
|
|
||||||
playerClaimCounts.merge(playerUUID, -1, Integer::sum);
|
|
||||||
saveClaims();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, Claim> getClaims() {
|
|
||||||
return claims;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getClaimCount(Player player) {
|
|
||||||
return playerClaimCounts.getOrDefault(player.getUniqueId(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoint1(Player player, Location location) {
|
|
||||||
point1Selections.put(player.getUniqueId(), location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPoint2(Player player, Location location) {
|
|
||||||
point2Selections.put(player.getUniqueId(), location);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getPoint1(Player player) {
|
|
||||||
return point1Selections.get(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getPoint2(Player player) {
|
|
||||||
return point2Selections.get(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearSelections(Player player) {
|
|
||||||
point1Selections.remove(player.getUniqueId());
|
|
||||||
point2Selections.remove(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasOverlap(Claim newClaim) {
|
|
||||||
for (Claim existingClaim : claims.values()) {
|
|
||||||
if (existingClaim.overlaps(newClaim)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,226 +0,0 @@
|
|||||||
package de.viper.survivalplus.commands;
|
|
||||||
|
|
||||||
import de.viper.survivalplus.SurvivalPlus;
|
|
||||||
import de.viper.survivalplus.util.Claim;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
public class ClaimCommand implements CommandExecutor {
|
|
||||||
private SurvivalPlus plugin;
|
|
||||||
private static final int MAX_CLAIMS = 10;
|
|
||||||
private static final int MAX_AREA = 10000; // 100x100 blocks
|
|
||||||
|
|
||||||
public ClaimCommand(SurvivalPlus plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(plugin.getMessage("commands.player-only"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (args.length == 0) {
|
|
||||||
if (!player.hasPermission("survivalplus.claim.use")) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.no-permission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Location point1 = plugin.getPoint1(player);
|
|
||||||
Location point2 = plugin.getPoint2(player);
|
|
||||||
if (point1 == null || point2 == null) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.points-not-set"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!point1.getWorld().equals(point2.getWorld())) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.different-worlds"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
int x1 = point1.getBlockX();
|
|
||||||
int z1 = point1.getBlockZ();
|
|
||||||
int x2 = point2.getBlockX();
|
|
||||||
int z2 = point2.getBlockZ();
|
|
||||||
int width = Math.abs(x2 - x1) + 1;
|
|
||||||
int length = Math.abs(z2 - z1) + 1;
|
|
||||||
if (width * length > MAX_AREA) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.too-large").replace("%max%", String.valueOf(MAX_AREA)));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Claim newClaim = new Claim(player, point1.getWorld().getName(), x1, z1, x2, z2);
|
|
||||||
if (plugin.hasOverlap(newClaim)) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.overlap"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (plugin.getClaimCount(player) >= MAX_CLAIMS) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.max-reached").replace("%max%", String.valueOf(MAX_CLAIMS)));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
plugin.addClaim(newClaim, player);
|
|
||||||
player.sendMessage(plugin.getMessage("claim.success").replace("%count%", String.valueOf(plugin.getClaimCount(player))).replace("%max%", String.valueOf(MAX_CLAIMS)));
|
|
||||||
plugin.clearSelections(player);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args[0].toLowerCase()) {
|
|
||||||
case "mark":
|
|
||||||
if (!player.hasPermission("survivalplus.claim.use")) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.no-permission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 2 || (!args[1].equals("1") && !args[1].equals("2"))) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.usage-mark"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Location location = player.getLocation();
|
|
||||||
if (args[1].equals("1")) {
|
|
||||||
plugin.setPoint1(player, location);
|
|
||||||
player.sendMessage(plugin.getMessage("claim.point1-set").replace("%x%", String.valueOf(location.getBlockX())).replace("%z%", String.valueOf(location.getBlockZ())));
|
|
||||||
} else {
|
|
||||||
plugin.setPoint2(player, location);
|
|
||||||
player.sendMessage(plugin.getMessage("claim.point2-set").replace("%x%", String.valueOf(location.getBlockX())).replace("%z%", String.valueOf(location.getBlockZ())));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case "unclaim":
|
|
||||||
if (args.length == 1) {
|
|
||||||
if (!player.hasPermission("survivalplus.claim.use")) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.no-permission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Claim claim = plugin.getClaim(player.getLocation());
|
|
||||||
if (claim == null || !claim.getOwner().equals(player.getUniqueId())) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.not-owner"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
plugin.removeClaim(player.getLocation(), player);
|
|
||||||
player.sendMessage(plugin.getMessage("claim.unclaimed"));
|
|
||||||
return true;
|
|
||||||
} else if (args.length == 2 && player.isOp()) {
|
|
||||||
Player target = Bukkit.getPlayer(args[1]);
|
|
||||||
UUID targetUUID;
|
|
||||||
if (target != null) {
|
|
||||||
targetUUID = target.getUniqueId();
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
targetUUID = UUID.fromString(args[1]);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.player-not-found"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int removedCount = removePlayerClaims(targetUUID);
|
|
||||||
if (removedCount > 0) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.op-unclaimed")
|
|
||||||
.replace("%player%", args[1])
|
|
||||||
.replace("%count%", String.valueOf(removedCount)));
|
|
||||||
} else {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.no-claims-found")
|
|
||||||
.replace("%player%", args[1]));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.usage"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
case "trust":
|
|
||||||
if (!player.hasPermission("survivalplus.claim.trust")) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.no-permission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 2) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.usage-trust"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player target = Bukkit.getPlayer(args[1]);
|
|
||||||
if (target == null) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.player-not-found"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Claim claim = plugin.getClaim(player.getLocation());
|
|
||||||
if (claim == null || !claim.getOwner().equals(player.getUniqueId())) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.not-owner"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
claim.addTrusted(target.getUniqueId());
|
|
||||||
player.sendMessage(plugin.getMessage("claim.trusted").replace("%player%", args[1]));
|
|
||||||
plugin.saveClaims();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "untrust":
|
|
||||||
if (!player.hasPermission("survivalplus.claim.trust")) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.no-permission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (args.length < 2) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.usage-untrust"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
target = Bukkit.getPlayer(args[1]);
|
|
||||||
if (target == null) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.player-not-found"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
claim = plugin.getClaim(player.getLocation());
|
|
||||||
if (claim == null || !claim.getOwner().equals(player.getUniqueId())) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.not-owner"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
claim.removeTrusted(target.getUniqueId());
|
|
||||||
player.sendMessage(plugin.getMessage("claim.untrusted").replace("%player%", args[1]));
|
|
||||||
plugin.saveClaims();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "info":
|
|
||||||
if (!player.hasPermission("survivalplus.claim.use")) {
|
|
||||||
player.sendMessage(plugin.getMessage("commands.no-permission"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
claim = plugin.getClaim(player.getLocation());
|
|
||||||
if (claim == null) {
|
|
||||||
player.sendMessage(plugin.getMessage("claim.no-claim-at-location"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String ownerName = Bukkit.getOfflinePlayer(claim.getOwner()).getName();
|
|
||||||
if (ownerName == null) {
|
|
||||||
ownerName = claim.getOwner().toString(); // Fallback to UUID if name not found
|
|
||||||
}
|
|
||||||
player.sendMessage(plugin.getMessage("claim.info")
|
|
||||||
.replace("%owner%", ownerName)
|
|
||||||
.replace("%world%", claim.getWorldName())
|
|
||||||
.replace("%x1%", String.valueOf(claim.getX1()))
|
|
||||||
.replace("%z1%", String.valueOf(claim.getZ1()))
|
|
||||||
.replace("%x2%", String.valueOf(claim.getX2()))
|
|
||||||
.replace("%z2%", String.valueOf(claim.getZ2())));
|
|
||||||
return true;
|
|
||||||
|
|
||||||
default:
|
|
||||||
player.sendMessage(plugin.getMessage("claim.usage"));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int removePlayerClaims(UUID targetUUID) {
|
|
||||||
Map<String, Claim> claims = new HashMap<>(plugin.getClaims());
|
|
||||||
int removedCount = 0;
|
|
||||||
for (Map.Entry<String, Claim> entry : claims.entrySet()) {
|
|
||||||
if (entry.getValue().getOwner().equals(targetUUID)) {
|
|
||||||
plugin.removeClaimByKey(entry.getKey(), targetUUID);
|
|
||||||
removedCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (removedCount > 0) {
|
|
||||||
plugin.saveClaims();
|
|
||||||
}
|
|
||||||
return removedCount;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,34 +0,0 @@
|
|||||||
package de.viper.survivalplus.listeners;
|
|
||||||
|
|
||||||
import de.viper.survivalplus.SurvivalPlus;
|
|
||||||
import de.viper.survivalplus.util.Claim;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
|
|
||||||
public class ClaimListener implements Listener {
|
|
||||||
private SurvivalPlus plugin;
|
|
||||||
|
|
||||||
public ClaimListener(SurvivalPlus plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
|
||||||
Claim claim = plugin.getClaim(event.getBlock().getLocation());
|
|
||||||
if (claim != null && !claim.canInteract(event.getPlayer().getUniqueId()) && !event.getPlayer().isOp()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
event.getPlayer().sendMessage(plugin.getMessage("claim.no-break"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
|
||||||
Claim claim = plugin.getClaim(event.getBlock().getLocation());
|
|
||||||
if (claim != null && !claim.canInteract(event.getPlayer().getUniqueId()) && !event.getPlayer().isOp()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
event.getPlayer().sendMessage(plugin.getMessage("claim.no-place"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,91 +0,0 @@
|
|||||||
package de.viper.survivalplus.util;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class Claim {
|
|
||||||
private UUID owner;
|
|
||||||
private Set<UUID> trusted = new HashSet<>();
|
|
||||||
private int x1, z1, x2, z2;
|
|
||||||
private String worldName;
|
|
||||||
|
|
||||||
public Claim(Player owner, String worldName, int x1, int z1, int x2, int z2) {
|
|
||||||
this.owner = owner.getUniqueId();
|
|
||||||
this.worldName = worldName;
|
|
||||||
this.x1 = Math.min(x1, x2);
|
|
||||||
this.z1 = Math.min(z1, z2);
|
|
||||||
this.x2 = Math.max(x1, x2);
|
|
||||||
this.z2 = Math.max(z1, z2);
|
|
||||||
trusted.add(owner.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public Claim(UUID owner, String worldName, int x1, int z1, int x2, int z2) {
|
|
||||||
this.owner = owner;
|
|
||||||
this.worldName = worldName;
|
|
||||||
this.x1 = Math.min(x1, x2);
|
|
||||||
this.z1 = Math.min(z1, z2);
|
|
||||||
this.x2 = Math.max(x1, x2);
|
|
||||||
this.z2 = Math.max(z1, z2);
|
|
||||||
trusted.add(owner);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean canInteract(UUID uuid) {
|
|
||||||
return trusted.contains(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTrusted(UUID uuid) {
|
|
||||||
trusted.add(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeTrusted(UUID uuid) {
|
|
||||||
trusted.remove(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getOwner() {
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<UUID> getTrusted() {
|
|
||||||
return trusted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX1() {
|
|
||||||
return x1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getZ1() {
|
|
||||||
return z1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getX2() {
|
|
||||||
return x2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getZ2() {
|
|
||||||
return z2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWorldName() {
|
|
||||||
return worldName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInside(Location location) {
|
|
||||||
if (!location.getWorld().getName().equals(worldName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int x = location.getBlockX();
|
|
||||||
int z = location.getBlockZ();
|
|
||||||
return x >= x1 && x <= x2 && z >= z1 && z <= z2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean overlaps(Claim other) {
|
|
||||||
if (!this.worldName.equals(other.worldName)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !(this.x2 < other.x1 || this.x1 > other.x2 || this.z2 < other.z1 || this.z1 > other.z2);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -273,23 +273,6 @@ commands:
|
|||||||
description: "&eHeilt einen Spieler vollständig."
|
description: "&eHeilt einen Spieler vollständig."
|
||||||
usage: "&b/heal [spieler]"
|
usage: "&b/heal [spieler]"
|
||||||
|
|
||||||
claim:
|
|
||||||
description: "&eVerwaltet Claims für den Anti-Grief-Schutz."
|
|
||||||
usage: "&b/claim [mark <1|2>| unclaim | trust <spieler> | untrust <spieler>]"
|
|
||||||
subcommands:
|
|
||||||
mark:
|
|
||||||
description: "&eMarkiert die erste oder zweite Ecke eines zu schützenden Bereichs."
|
|
||||||
usage: "&b/claim mark <1|2>"
|
|
||||||
unclaim:
|
|
||||||
description: "&eGibt den geschützten Bereich frei, in dem du stehst."
|
|
||||||
usage: "&b/claim unclaim"
|
|
||||||
trust:
|
|
||||||
description: "&eFügt einen Spieler als vertrauenswürdig hinzu, sodass er im Bereich bauen kann."
|
|
||||||
usage: "&b/claim trust <spieler>"
|
|
||||||
untrust:
|
|
||||||
description: "&eEntfernt die Vertrauensberechtigung eines Spielers für den Bereich."
|
|
||||||
usage: "&b/claim untrust <spieler>"
|
|
||||||
|
|
||||||
messages:
|
messages:
|
||||||
header: "&6=== Befehle ==="
|
header: "&6=== Befehle ==="
|
||||||
footer: "&6================"
|
footer: "&6================"
|
||||||
|
@@ -402,25 +402,5 @@ inventory:
|
|||||||
no-permission-others: "§cDu hast keine Berechtigung, das Inventar anderer Spieler anzusehen!"
|
no-permission-others: "§cDu hast keine Berechtigung, das Inventar anderer Spieler anzusehen!"
|
||||||
player-only: "§cDieser Befehl ist nur für Spieler!"
|
player-only: "§cDieser Befehl ist nur für Spieler!"
|
||||||
|
|
||||||
claim:
|
|
||||||
points-not-set: "&cDu musst zuerst zwei Punkte markieren! Verwende /claim mark <1|2>."
|
|
||||||
different-worlds: "&cDie markierten Punkte müssen in derselben Welt liegen!"
|
|
||||||
too-large: "&cDer Bereich ist zu groß! Maximal erlaubt: %max% Blöcke²."
|
|
||||||
overlap: "&cDieser Bereich überschneidet sich mit einem bestehenden Claim!"
|
|
||||||
max-reached: "&cDu hast das Maximum von %max% Claims erreicht!"
|
|
||||||
success: "&aBereich beansprucht! (%count%/%max%)"
|
|
||||||
unclaimed: "&aBereich freigegeben!"
|
|
||||||
not-owner: "&cDies ist nicht dein Claim!"
|
|
||||||
point1-set: "&aPunkt 1 gesetzt bei x=%x%, z=%z%."
|
|
||||||
point2-set: "&aPunkt 2 gesetzt bei x=%x%, z=%z%."
|
|
||||||
trusted: "&a%player% ist jetzt in diesem Claim vertraut!"
|
|
||||||
untrusted: "&a%player% ist in diesem Claim nicht mehr vertraut!"
|
|
||||||
no-break: "&cDu kannst in diesem beanspruchten Bereich keine Blöcke abbauen!"
|
|
||||||
no-place: "&cDu kannst in diesem beanspruchten Bereich keine Blöcke platzieren!"
|
|
||||||
op-unclaimed: "&a%count% Claims von %player% wurden entfernt!"
|
|
||||||
no-claims-found: "&cKeine Claims für %player% gefunden!"
|
|
||||||
no-claim-at-location: "&cKein Claim an dieser Position!"
|
|
||||||
info: "&eClaim-Info:\n&7Besitzer: &e%owner%\n&7Welt: &e%world%\n&7Koordinaten: &eX1: %x1%, Z1: %z1% bis X2: %x2%, Z2: %z2%"
|
|
||||||
|
|
||||||
force-survival:
|
force-survival:
|
||||||
join-message: "§aDu wurdest in den Survivalmodus gesetzt!"
|
join-message: "§aDu wurdest in den Survivalmodus gesetzt!"
|
@@ -1,6 +1,9 @@
|
|||||||
name: SurvivalPlus
|
name: SurvivalPlus
|
||||||
version: 1.0.8
|
<<<<<<< HEAD
|
||||||
|
version: 1.0.7
|
||||||
|
=======
|
||||||
|
version: 1.0.6
|
||||||
|
>>>>>>> aadc1e75cc9b97929c3cde4fa3d098d281ba32f7
|
||||||
main: de.viper.survivalplus.SurvivalPlus
|
main: de.viper.survivalplus.SurvivalPlus
|
||||||
api-version: 1.21
|
api-version: 1.21
|
||||||
softdepend: [LuckPerms, PlaceholderAPI]
|
softdepend: [LuckPerms, PlaceholderAPI]
|
||||||
@@ -265,17 +268,6 @@ commands:
|
|||||||
permission: survivalplus.heal
|
permission: survivalplus.heal
|
||||||
permission-message: "§cDu hast keine Berechtigung, Spieler zu heilen!"
|
permission-message: "§cDu hast keine Berechtigung, Spieler zu heilen!"
|
||||||
|
|
||||||
claim:
|
|
||||||
description: Manages claims for anti-griefing
|
|
||||||
usage: /<command> [unclaim | trust <player> | untrust <player>]
|
|
||||||
aliases: [cl]
|
|
||||||
survivalplus.claim.use:
|
|
||||||
description: Allows claiming and unclaiming chunks
|
|
||||||
default: true
|
|
||||||
survivalplus.claim.trust:
|
|
||||||
description: Allows trusting/untrusting players in claims
|
|
||||||
default: true
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
survivalplus.*:
|
survivalplus.*:
|
||||||
description: Gibt Zugriff auf alle SurvivalPlus-Befehle
|
description: Gibt Zugriff auf alle SurvivalPlus-Befehle
|
||||||
|
Reference in New Issue
Block a user