5 Commits
1.0.1 ... main

4 changed files with 283 additions and 276 deletions

View File

@@ -1,6 +1,6 @@
# 🧩 SurvivalPlus # 🧩 SurvivalPlus
**Version:** 1.0.0 **Version:** 1.0.1
**Autor:** M_Viper **Autor:** M_Viper
**API-Version:** 1.21 **API-Version:** 1.21
**Beschreibung:** **Beschreibung:**

View File

@@ -58,118 +58,122 @@ public class SurvivalPlus extends JavaPlugin {
private AFKListener afkListener; private AFKListener afkListener;
private GraveListener graveListener; private GraveListener graveListener;
private SitListener sitListener; private SitListener sitListener;
private PlayerJoinListener playerJoinListener; // Neuer Listener private PlayerJoinListener playerJoinListener;
@Override @Override
public void onEnable() { public void onEnable() {
updateConfigFiles(); // Config-Dateien aktualisieren updateConfigFiles(); // Config-Dateien aktualisieren
createHomesFile(); createHomesFile();
createGravesFile(); createGravesFile();
createBackpackFile(); createBackpackFile();
createFriendsFile(); createFriendsFile();
createLeashesFile(); createLeashesFile();
createMobCapFile(); createMobCapFile();
// FirstJoinListener registrieren // PluginManager holen
PluginManager pluginManager = getServer().getPluginManager(); PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new FirstJoinListener(), this);
// FriendCommand instanzieren für PlayerJoinListener // FriendCommand instanzieren
FriendCommand friendCommand = new FriendCommand(this, friendsConfig, langConfig, getLogger()); FriendCommand friendCommand = new FriendCommand(this, friendsConfig, langConfig, getLogger());
// Commands // StatsManager vor den Listenern initialisieren
getCommand("gm").setExecutor(new GamemodeCommand(this)); statsManager = new StatsManager(this);
getCommand("sp").setExecutor(new PluginCommand(this));
getCommand("sethome").setExecutor(new HomeCommand(this));
getCommand("delhome").setExecutor(new HomeCommand(this));
getCommand("homelist").setExecutor(new HomeCommand(this));
getCommand("inv").setExecutor(new InventoryCommand(this));
getCommand("ec").setExecutor(new EnderchestCommand(this));
getCommand("setspawn").setExecutor(new SetSpawnCommand(this));
getCommand("setworldspawn").setExecutor(new SetWorldSpawnCommand(this));
getCommand("clearchat").setExecutor(new ClearChatCommand());
getCommand("clearitems").setExecutor(new ClearItemsCommand(this));
getCommand("closedoors").setExecutor(new CloseDoorsCommand(this));
getCommand("sit").setExecutor(new SitCommand(this, sitListener));
getCommand("back").setExecutor(new BackCommand(this));
getCommand("friend").setExecutor(friendCommand);
getCommand("ir").setExecutor(new ItemRenameCommand(this));
getCommand("showarmorstands").setExecutor(new ShowArmorStandsCommand(this));
getCommand("cleardebugarmorstands").setExecutor(new ClearDebugArmorStandsCommand(this));
getCommand("trash").setExecutor(new TrashCommand());
getCommand("workbench").setExecutor(new WorkbenchCommand());
getCommand("anvil").setExecutor(new AnvilCommand());
TeleportCommands teleportCommands = new TeleportCommands(this);
getCommand("tp").setExecutor(teleportCommands);
getCommand("tphere").setExecutor(teleportCommands);
getCommand("tpa").setExecutor(teleportCommands);
getCommand("tpaccept").setExecutor(teleportCommands);
getCommand("tpdeny").setExecutor(teleportCommands);
getCommand("kit").setExecutor(new KitCommand(this));
// BlockManager erstellen // Listener initialisieren (sitListener zuerst!)
BlockManager blockManager = new BlockManager(); sitListener = new SitListener(this);
afkListener = new AFKListener(this);
graveListener = new GraveListener(this);
playerJoinListener = new PlayerJoinListener(friendCommand);
// Konfiguration laden // Commands registrieren
FileConfiguration config = getConfig(); getCommand("gm").setExecutor(new GamemodeCommand(this));
getCommand("sp").setExecutor(new PluginCommand(this));
getCommand("sethome").setExecutor(new HomeCommand(this));
getCommand("delhome").setExecutor(new HomeCommand(this));
getCommand("homelist").setExecutor(new HomeCommand(this));
getCommand("inv").setExecutor(new InventoryCommand(this));
getCommand("ec").setExecutor(new EnderchestCommand(this));
getCommand("setspawn").setExecutor(new SetSpawnCommand(this));
getCommand("setworldspawn").setExecutor(new SetWorldSpawnCommand(this));
getCommand("clearchat").setExecutor(new ClearChatCommand());
getCommand("clearitems").setExecutor(new ClearItemsCommand(this));
getCommand("closedoors").setExecutor(new CloseDoorsCommand(this));
getCommand("sit").setExecutor(new SitCommand(this, sitListener));
getCommand("back").setExecutor(new BackCommand(this));
getCommand("friend").setExecutor(friendCommand);
getCommand("ir").setExecutor(new ItemRenameCommand(this));
getCommand("showarmorstands").setExecutor(new ShowArmorStandsCommand(this));
getCommand("cleardebugarmorstands").setExecutor(new ClearDebugArmorStandsCommand(this));
getCommand("trash").setExecutor(new TrashCommand());
getCommand("workbench").setExecutor(new WorkbenchCommand());
getCommand("anvil").setExecutor(new AnvilCommand());
// Listener registrieren TeleportCommands teleportCommands = new TeleportCommands(this);
BackpackRecipe.register(this, langConfig); getCommand("tp").setExecutor(teleportCommands);
getCommand("tphere").setExecutor(teleportCommands);
getCommand("tpa").setExecutor(teleportCommands);
getCommand("tpaccept").setExecutor(teleportCommands);
getCommand("tpdeny").setExecutor(teleportCommands);
sitListener = new SitListener(this); getCommand("kit").setExecutor(new KitCommand(this));
afkListener = new AFKListener(this);
graveListener = new GraveListener(this);
playerJoinListener = new PlayerJoinListener(friendCommand); // PlayerJoinListener registrieren
pluginManager.registerEvents(new ChatBlockListener(blockManager), this); // BlockManager erstellen
pluginManager.registerEvents(new InventoryClickListener(this), this); BlockManager blockManager = new BlockManager();
pluginManager.registerEvents(sitListener, this);
pluginManager.registerEvents(afkListener, this);
pluginManager.registerEvents(graveListener, this);
pluginManager.registerEvents(new BackpackListener(backpackConfig, langConfig, getLogger(), backpackFile), this);
pluginManager.registerEvents(new StatsListener(this, statsManager), this);
pluginManager.registerEvents(new LoginListener(this), this);
pluginManager.registerEvents(new DebugArmorStandListener(), this);
pluginManager.registerEvents(new ArmorStandDestroyListener(), this);
pluginManager.registerEvents(playerJoinListener, this); // Listener hinzufügen
// Befehle mit BlockManager und Konfiguration registrieren // Konfiguration laden
getCommand("block").setExecutor(new BlockCommand(blockManager, config)); FileConfiguration config = getConfig();
getCommand("blocklist").setExecutor(new BlockListCommand(blockManager, config));
getCommand("unblock").setExecutor(new UnblockCommand(blockManager, config));
// Stats // Listener registrieren
statsManager = new StatsManager(this); BackpackRecipe.register(this, langConfig);
pluginManager.registerEvents(new StatsListener(this, statsManager), this);
getCommand("stats").setExecutor(new StatsCommand(this, statsManager));
sleepListener = new SleepListener(this); pluginManager.registerEvents(new ChatBlockListener(blockManager), this);
pluginManager.registerEvents(sleepListener, this); pluginManager.registerEvents(new InventoryClickListener(this), this);
pluginManager.registerEvents(sitListener, this);
pluginManager.registerEvents(afkListener, this);
pluginManager.registerEvents(graveListener, this);
pluginManager.registerEvents(new BackpackListener(backpackConfig, langConfig, getLogger(), backpackFile), this);
pluginManager.registerEvents(new StatsListener(this, statsManager), this);
pluginManager.registerEvents(new LoginListener(this), this);
pluginManager.registerEvents(new DebugArmorStandListener(), this);
pluginManager.registerEvents(new ArmorStandDestroyListener(), this);
pluginManager.registerEvents(new FirstJoinListener(), this);
pluginManager.registerEvents(playerJoinListener, this);
oreAlarmListener = new OreAlarmListener(this); // Befehle mit BlockManager und Konfiguration registrieren
pluginManager.registerEvents(oreAlarmListener, this); getCommand("block").setExecutor(new BlockCommand(blockManager, config));
getCommand("blocklist").setExecutor(new BlockListCommand(blockManager, config));
getCommand("unblock").setExecutor(new UnblockCommand(blockManager, config));
mobLeashLimitListener = new MobLeashLimitListener(this, getConfig()); // Stats-Befehl registrieren
pluginManager.registerEvents(mobLeashLimitListener, this); getCommand("stats").setExecutor(new StatsCommand(this, statsManager));
mobCapListener = new MobCapListener(this, getConfig()); sleepListener = new SleepListener(this);
pluginManager.registerEvents(mobCapListener, this); pluginManager.registerEvents(sleepListener, this);
spawnProtectionListener = new SpawnProtectionListener(this); oreAlarmListener = new OreAlarmListener(this);
pluginManager.registerEvents(spawnProtectionListener, this); pluginManager.registerEvents(oreAlarmListener, this);
LockSystem lockSystem = new LockSystem(this); mobLeashLimitListener = new MobLeashLimitListener(this, getConfig());
pluginManager.registerEvents(lockSystem, this); pluginManager.registerEvents(mobLeashLimitListener, this);
getCommand("lock").setExecutor(lockSystem);
// AutoClear Task starten mobCapListener = new MobCapListener(this, getConfig());
startAutoClearTask(); pluginManager.registerEvents(mobCapListener, this);
// Beispiel ArmorStand spawnProtectionListener = new SpawnProtectionListener(this);
spawnArmorStandExample(); pluginManager.registerEvents(spawnProtectionListener, this);
getLogger().info(getMessage("plugin.enabled")); LockSystem lockSystem = new LockSystem(this);
} pluginManager.registerEvents(lockSystem, this);
getCommand("lock").setExecutor(lockSystem);
// AutoClear Task starten
startAutoClearTask();
// Beispiel ArmorStand spawnen
spawnArmorStandExample();
getLogger().info(getMessage("plugin.enabled"));
}
private void spawnArmorStandExample() { private void spawnArmorStandExample() {
World world = Bukkit.getWorld("world"); World world = Bukkit.getWorld("world");
@@ -605,7 +609,7 @@ public class SurvivalPlus extends JavaPlugin {
sitListener = new SitListener(this); sitListener = new SitListener(this);
pm.registerEvents(sitListener, this); pm.registerEvents(sitListener, this);
playerJoinListener = new PlayerJoinListener(friendCommand); // PlayerJoinListener neu registrieren playerJoinListener = new PlayerJoinListener(friendCommand);
pm.registerEvents(playerJoinListener, this); pm.registerEvents(playerJoinListener, this);
pm.registerEvents(new InventoryClickListener(this), this); pm.registerEvents(new InventoryClickListener(this), this);

View File

@@ -45,9 +45,12 @@ public class SitCommand implements CommandExecutor {
return true; return true;
} }
// Setze den Spieler direkt auf dem Block // Setze den Spieler mittig auf den Block und leicht oberhalb (Fix)
Location location = player.getLocation(); Location location = player.getLocation();
location.setY(location.getBlockY()); // Direkt auf dem Block (keine Y-Verschiebung) location.setX(location.getBlockX() + 0.5);
location.setY(location.getBlockY() + 0.25);
location.setZ(location.getBlockZ() + 0.5);
sitListener.sitPlayer(player, location); sitListener.sitPlayer(player, location);
return true; return true;
} }