Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
5602041fdf | |||
133243abea | |||
8ebbe282cc | |||
24a017d794 | |||
4f3bfd0403 |
@@ -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:**
|
||||||
|
@@ -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);
|
||||||
|
@@ -1,54 +1,57 @@
|
|||||||
package de.viper.survivalplus.commands;
|
package de.viper.survivalplus.commands;
|
||||||
|
|
||||||
import de.viper.survivalplus.SurvivalPlus;
|
import de.viper.survivalplus.SurvivalPlus;
|
||||||
import de.viper.survivalplus.listeners.SitListener;
|
import de.viper.survivalplus.listeners.SitListener;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
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 org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
public class SitCommand implements CommandExecutor {
|
public class SitCommand implements CommandExecutor {
|
||||||
private final SurvivalPlus plugin;
|
private final SurvivalPlus plugin;
|
||||||
private final SitListener sitListener;
|
private final SitListener sitListener;
|
||||||
|
|
||||||
public SitCommand(SurvivalPlus plugin, SitListener sitListener) {
|
public SitCommand(SurvivalPlus plugin, SitListener sitListener) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.sitListener = sitListener;
|
this.sitListener = sitListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(plugin.getLangConfig().getString("player-only", "§cDieser Befehl ist nur für Spieler!"));
|
sender.sendMessage(plugin.getLangConfig().getString("player-only", "§cDieser Befehl ist nur für Spieler!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
FileConfiguration lang = plugin.getLangConfig();
|
FileConfiguration lang = plugin.getLangConfig();
|
||||||
|
|
||||||
if (!player.hasPermission("survivalplus.sit")) {
|
if (!player.hasPermission("survivalplus.sit")) {
|
||||||
player.sendMessage(lang.getString("no-permission", "§cDu hast keine Berechtigung für diesen Befehl!"));
|
player.sendMessage(lang.getString("no-permission", "§cDu hast keine Berechtigung für diesen Befehl!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
player.sendMessage(lang.getString("sit.usage", "§cVerwendung: /sit"));
|
player.sendMessage(lang.getString("sit.usage", "§cVerwendung: /sit"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prüfe, ob der Spieler bereits sitzt
|
// Prüfe, ob der Spieler bereits sitzt
|
||||||
if (sitListener.isSitting(player)) {
|
if (sitListener.isSitting(player)) {
|
||||||
sitListener.standUp(player);
|
sitListener.standUp(player);
|
||||||
player.sendMessage(lang.getString("sit.stand-up", "§aDu bist aufgestanden!"));
|
player.sendMessage(lang.getString("sit.stand-up", "§aDu bist aufgestanden!"));
|
||||||
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);
|
||||||
sitListener.sitPlayer(player, location);
|
location.setY(location.getBlockY() + 0.25);
|
||||||
return true;
|
location.setZ(location.getBlockZ() + 0.5);
|
||||||
}
|
|
||||||
}
|
sitListener.sitPlayer(player, location);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,128 +1,128 @@
|
|||||||
package de.viper.survivalplus.listeners;
|
package de.viper.survivalplus.listeners;
|
||||||
|
|
||||||
import de.viper.survivalplus.SurvivalPlus;
|
import de.viper.survivalplus.SurvivalPlus;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class SitListener implements Listener {
|
public class SitListener implements Listener {
|
||||||
private final SurvivalPlus plugin;
|
private final SurvivalPlus plugin;
|
||||||
private final Map<UUID, ArmorStand> sittingPlayers = new HashMap<>();
|
private final Map<UUID, ArmorStand> sittingPlayers = new HashMap<>();
|
||||||
|
|
||||||
public SitListener(SurvivalPlus plugin) {
|
public SitListener(SurvivalPlus plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSitting(Player player) {
|
public boolean isSitting(Player player) {
|
||||||
return sittingPlayers.containsKey(player.getUniqueId());
|
return sittingPlayers.containsKey(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sitPlayer(Player player, Location location) {
|
public void sitPlayer(Player player, Location location) {
|
||||||
if (sittingPlayers.containsKey(player.getUniqueId())) {
|
if (sittingPlayers.containsKey(player.getUniqueId())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erstelle einen unsichtbaren ArmorStand als Sitz
|
// Erstelle einen unsichtbaren ArmorStand als Sitz
|
||||||
ArmorStand armorStand = player.getWorld().spawn(location, ArmorStand.class);
|
ArmorStand armorStand = player.getWorld().spawn(location, ArmorStand.class);
|
||||||
armorStand.setGravity(false);
|
armorStand.setGravity(false);
|
||||||
armorStand.setMarker(true);
|
armorStand.setMarker(true);
|
||||||
armorStand.setInvisible(true);
|
armorStand.setInvisible(true);
|
||||||
armorStand.setInvulnerable(true);
|
armorStand.setInvulnerable(true);
|
||||||
armorStand.addPassenger(player);
|
armorStand.addPassenger(player);
|
||||||
|
|
||||||
sittingPlayers.put(player.getUniqueId(), armorStand);
|
sittingPlayers.put(player.getUniqueId(), armorStand);
|
||||||
FileConfiguration lang = plugin.getLangConfig();
|
FileConfiguration lang = plugin.getLangConfig();
|
||||||
player.sendMessage(lang.getString("sit.success", "§aDu hast dich hingesetzt!"));
|
player.sendMessage(lang.getString("sit.success", "§aDu hast dich hingesetzt!"));
|
||||||
plugin.getLogger().log(Level.FINE, "Spieler " + player.getName() + " sitzt bei " + locationToString(location));
|
plugin.getLogger().log(Level.FINE, "Spieler " + player.getName() + " sitzt bei " + locationToString(location));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void standUp(Player player) {
|
public void standUp(Player player) {
|
||||||
UUID playerId = player.getUniqueId();
|
UUID playerId = player.getUniqueId();
|
||||||
ArmorStand armorStand = sittingPlayers.remove(playerId);
|
ArmorStand armorStand = sittingPlayers.remove(playerId);
|
||||||
if (armorStand != null) {
|
if (armorStand != null) {
|
||||||
armorStand.remove();
|
armorStand.remove();
|
||||||
FileConfiguration lang = plugin.getLangConfig();
|
FileConfiguration lang = plugin.getLangConfig();
|
||||||
player.sendMessage(lang.getString("sit.stand-up", "§aDu bist aufgestanden!"));
|
player.sendMessage(lang.getString("sit.stand-up", "§aDu bist aufgestanden!"));
|
||||||
plugin.getLogger().log(Level.FINE, "Spieler " + player.getName() + " ist aufgestanden");
|
plugin.getLogger().log(Level.FINE, "Spieler " + player.getName() + " ist aufgestanden");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
if (event.getHand() != EquipmentSlot.HAND || event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
if (event.getHand() != EquipmentSlot.HAND || event.getAction() != Action.RIGHT_CLICK_BLOCK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
FileConfiguration lang = plugin.getLangConfig();
|
FileConfiguration lang = plugin.getLangConfig();
|
||||||
|
|
||||||
if (!player.hasPermission("survivalplus.sit")) {
|
if (!player.hasPermission("survivalplus.sit")) {
|
||||||
player.sendMessage(lang.getString("no-permission", "§cDu hast keine Berechtigung für diesen Befehl!"));
|
player.sendMessage(lang.getString("no-permission", "§cDu hast keine Berechtigung für diesen Befehl!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
if (block == null || !isStair(block.getType())) {
|
if (block == null || !isStair(block.getType())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wenn der Spieler bereits sitzt, stehe auf
|
// Wenn der Spieler bereits sitzt, stehe auf
|
||||||
if (sittingPlayers.containsKey(player.getUniqueId())) {
|
if (sittingPlayers.containsKey(player.getUniqueId())) {
|
||||||
standUp(player);
|
standUp(player);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setze den Spieler genau auf der Treppenstufe
|
// Setze den Spieler genau auf der Treppenstufe
|
||||||
Location location = block.getLocation();
|
Location location = block.getLocation();
|
||||||
location.setX(location.getX() + 0.5);
|
location.setX(location.getX() + 0.5);
|
||||||
location.setY(location.getY() + 0.5); // Genau auf der Treppenstufe (halbe Blockhöhe)
|
location.setY(location.getY() + 0.5); // Genau auf der Treppenstufe (halbe Blockhöhe)
|
||||||
location.setZ(location.getZ() + 0.5);
|
location.setZ(location.getZ() + 0.5);
|
||||||
sitPlayer(player, location);
|
sitPlayer(player, location);
|
||||||
event.setCancelled(true); // Verhindere andere Interaktionen mit der Treppe
|
event.setCancelled(true); // Verhindere andere Interaktionen mit der Treppe
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID playerId = player.getUniqueId();
|
UUID playerId = player.getUniqueId();
|
||||||
if (!sittingPlayers.containsKey(playerId)) {
|
if (!sittingPlayers.containsKey(playerId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prüfe, ob der Spieler sich bewegt hat (nur Positionsänderung, nicht Kopfbewegung)
|
// Prüfe, ob der Spieler sich bewegt hat (nur Positionsänderung, nicht Kopfbewegung)
|
||||||
Location from = event.getFrom();
|
Location from = event.getFrom();
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
if (from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ()) {
|
if (from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ()) {
|
||||||
standUp(player);
|
standUp(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
standUp(player);
|
standUp(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStair(Material material) {
|
private boolean isStair(Material material) {
|
||||||
return material.name().endsWith("_STAIRS");
|
return material.name().endsWith("_STAIRS");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String locationToString(Location loc) {
|
private String locationToString(Location loc) {
|
||||||
return String.format("x=%.2f, y=%.2f, z=%.2f, world=%s", loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName());
|
return String.format("x=%.2f, y=%.2f, z=%.2f, world=%s", loc.getX(), loc.getY(), loc.getZ(), loc.getWorld().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user