Compare commits
30 Commits
Author | SHA1 | Date | |
---|---|---|---|
5602041fdf | |||
133243abea | |||
8ebbe282cc | |||
24a017d794 | |||
4f3bfd0403 | |||
f22052e5f2 | |||
bc801863e1 | |||
c237f2b8c3 | |||
7700c588ff | |||
851ec03788 | |||
a2e75a7142 | |||
c762eff2a1 | |||
cbaa562e1d | |||
a225838f26 | |||
ed1948b8b4 | |||
f9948d8ccc | |||
1c5c03cf63 | |||
e71074a453 | |||
c8ee265de5 | |||
18c041434e | |||
94d64821a6 | |||
3e7c4cbc13 | |||
2df3a217e4 | |||
9078098fb0 | |||
dc14a8dac2 | |||
6a221a3cbe | |||
4187194a3d | |||
fac39de66f | |||
f03efaa6e6 | |||
6016d2af9b |
@@ -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:**
|
||||||
|
@@ -16,8 +16,10 @@ public class AFKManager {
|
|||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
private final long afkAfterMillis;
|
private final long afkAfterMillis;
|
||||||
private final long kickAfterMillis;
|
private final long kickAfterMillis;
|
||||||
|
private final long joinGracePeriodMillis = 5000; // 5 Sekunden Schonfrist
|
||||||
|
|
||||||
private final Map<UUID, Long> lastActivity = new HashMap<>();
|
private final Map<UUID, Long> lastActivity = new HashMap<>();
|
||||||
|
private final Map<UUID, Long> joinTimes = new HashMap<>();
|
||||||
private final Set<UUID> afkPlayers = new HashSet<>();
|
private final Set<UUID> afkPlayers = new HashSet<>();
|
||||||
private final Map<UUID, BossBar> bossBars = new WeakHashMap<>();
|
private final Map<UUID, BossBar> bossBars = new WeakHashMap<>();
|
||||||
private final Map<UUID, Integer> colorIndex = new HashMap<>();
|
private final Map<UUID, Integer> colorIndex = new HashMap<>();
|
||||||
@@ -37,6 +39,9 @@ public class AFKManager {
|
|||||||
public void updateActivity(Player player) {
|
public void updateActivity(Player player) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
lastActivity.put(uuid, System.currentTimeMillis());
|
lastActivity.put(uuid, System.currentTimeMillis());
|
||||||
|
if (!joinTimes.containsKey(uuid)) {
|
||||||
|
joinTimes.put(uuid, System.currentTimeMillis()); // Join-Zeit speichern
|
||||||
|
}
|
||||||
|
|
||||||
if (afkPlayers.contains(uuid)) {
|
if (afkPlayers.contains(uuid)) {
|
||||||
afkPlayers.remove(uuid);
|
afkPlayers.remove(uuid);
|
||||||
@@ -47,6 +52,7 @@ public class AFKManager {
|
|||||||
public void reset(Player player) {
|
public void reset(Player player) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
lastActivity.remove(uuid);
|
lastActivity.remove(uuid);
|
||||||
|
joinTimes.remove(uuid); // Join-Zeit entfernen
|
||||||
afkPlayers.remove(uuid);
|
afkPlayers.remove(uuid);
|
||||||
removeAFKBossBar(player);
|
removeAFKBossBar(player);
|
||||||
}
|
}
|
||||||
@@ -59,6 +65,17 @@ public class AFKManager {
|
|||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// AFK-Prüfung überspringen, wenn Spieler in der Schonfrist ist
|
||||||
|
if (joinTimes.containsKey(uuid) && (currentTime - joinTimes.get(uuid) < joinGracePeriodMillis)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// AFK-Prüfung für Kreativ- oder Zuschauermodus überspringen
|
||||||
|
if (player.getGameMode() == org.bukkit.GameMode.CREATIVE ||
|
||||||
|
player.getGameMode() == org.bukkit.GameMode.SPECTATOR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!lastActivity.containsKey(uuid)) {
|
if (!lastActivity.containsKey(uuid)) {
|
||||||
lastActivity.put(uuid, currentTime);
|
lastActivity.put(uuid, currentTime);
|
||||||
return;
|
return;
|
||||||
@@ -70,10 +87,11 @@ public class AFKManager {
|
|||||||
if (diff >= afkAfterMillis) {
|
if (diff >= afkAfterMillis) {
|
||||||
if (!afkPlayers.contains(uuid)) {
|
if (!afkPlayers.contains(uuid)) {
|
||||||
afkPlayers.add(uuid);
|
afkPlayers.add(uuid);
|
||||||
// BossBar wird im Listener angezeigt
|
showAFKBossBar(player, "§cDu bist AFK!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kickAfterMillis > 0 && diff >= kickAfterMillis) {
|
if (kickAfterMillis > 0 && diff >= kickAfterMillis) {
|
||||||
|
plugin.getLogger().info("Spieler " + player.getName() + " wird wegen AFK gekickt. Inaktiv seit: " + (diff / 1000) + " Sekunden");
|
||||||
player.kickPlayer("§cDu wurdest wegen AFK gekickt.");
|
player.kickPlayer("§cDu wurdest wegen AFK gekickt.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -86,7 +104,7 @@ public class AFKManager {
|
|||||||
|
|
||||||
public void showAFKBossBar(Player player, String message) {
|
public void showAFKBossBar(Player player, String message) {
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
removeAFKBossBar(player); // sicherstellen, dass nur eine BossBar aktiv ist
|
removeAFKBossBar(player); // Sicherstellen, dass nur eine BossBar aktiv ist
|
||||||
|
|
||||||
BossBar bar = Bukkit.createBossBar(message, BarColor.YELLOW, BarStyle.SOLID, BarFlag.CREATE_FOG);
|
BossBar bar = Bukkit.createBossBar(message, BarColor.YELLOW, BarStyle.SOLID, BarFlag.CREATE_FOG);
|
||||||
bar.addPlayer(player);
|
bar.addPlayer(player);
|
||||||
@@ -121,7 +139,7 @@ public class AFKManager {
|
|||||||
colorIndex.put(uuid, (index + 1) % colorCycle.size());
|
colorIndex.put(uuid, (index + 1) % colorCycle.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
task.runTaskTimer(plugin, 0L, 20L); // alle 20 Ticks (1 Sekunde)
|
task.runTaskTimer(plugin, 0L, 20L); // Alle 20 Ticks (1 Sekunde)
|
||||||
colorTasks.put(uuid, task);
|
colorTasks.put(uuid, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,37 @@
|
|||||||
|
package de.viper.survivalplus.Manager;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class BlockManager {
|
||||||
|
|
||||||
|
private final Map<UUID, Set<UUID>> blockedPlayers = new HashMap<>();
|
||||||
|
|
||||||
|
public void blockPlayer(Player blocker, Player toBlock) {
|
||||||
|
blockedPlayers.computeIfAbsent(blocker.getUniqueId(), k -> new HashSet<>()).add(toBlock.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unblockPlayer(Player blocker, Player toUnblock) {
|
||||||
|
Set<UUID> blocked = blockedPlayers.get(blocker.getUniqueId());
|
||||||
|
if (blocked != null) {
|
||||||
|
blocked.remove(toUnblock.getUniqueId());
|
||||||
|
if (blocked.isEmpty()) {
|
||||||
|
blockedPlayers.remove(blocker.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBlocked(Player blocker, Player potentialBlocked) {
|
||||||
|
return blockedPlayers.getOrDefault(blocker.getUniqueId(), Collections.emptySet())
|
||||||
|
.contains(potentialBlocked.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<UUID> getBlockedPlayers(Player player) {
|
||||||
|
return blockedPlayers.getOrDefault(player.getUniqueId(), Collections.emptySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear(Player player) {
|
||||||
|
blockedPlayers.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
@@ -7,21 +7,13 @@ import de.viper.survivalplus.listeners.ArmorStandDestroyListener;
|
|||||||
import de.viper.survivalplus.tasks.AutoClearTask;
|
import de.viper.survivalplus.tasks.AutoClearTask;
|
||||||
import de.viper.survivalplus.recipe.BackpackRecipe;
|
import de.viper.survivalplus.recipe.BackpackRecipe;
|
||||||
import de.viper.survivalplus.Manager.StatsManager;
|
import de.viper.survivalplus.Manager.StatsManager;
|
||||||
import de.viper.survivalplus.commands.StatsCommand;
|
import de.viper.survivalplus.Manager.BlockManager;
|
||||||
import de.viper.survivalplus.commands.TrashCommand;
|
|
||||||
import de.viper.survivalplus.commands.WorkbenchCommand;
|
|
||||||
import de.viper.survivalplus.commands.AnvilCommand;
|
|
||||||
import de.viper.survivalplus.listeners.MobLeashLimitListener;
|
|
||||||
import de.viper.survivalplus.listeners.MobCapListener;
|
|
||||||
import de.viper.survivalplus.listeners.SpawnProtectionListener;
|
|
||||||
import de.viper.survivalplus.util.LockSystem;
|
import de.viper.survivalplus.util.LockSystem;
|
||||||
import de.viper.survivalplus.commands.TeleportCommands;
|
|
||||||
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
@@ -32,6 +24,7 @@ import org.bukkit.event.HandlerList;
|
|||||||
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.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class SurvivalPlus extends JavaPlugin {
|
public class SurvivalPlus extends JavaPlugin {
|
||||||
@@ -54,13 +47,10 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
private FileConfiguration mobCapConfig;
|
private FileConfiguration mobCapConfig;
|
||||||
|
|
||||||
private SpawnProtectionListener spawnProtectionListener;
|
private SpawnProtectionListener spawnProtectionListener;
|
||||||
|
|
||||||
|
|
||||||
private int autoClearTaskId = -1;
|
private int autoClearTaskId = -1;
|
||||||
|
|
||||||
private StatsManager statsManager;
|
private StatsManager statsManager;
|
||||||
|
|
||||||
// Listener als Feld speichern, damit man sie beim Reload abmelden kann
|
// Listener als Felder speichern
|
||||||
private MobLeashLimitListener mobLeashLimitListener;
|
private MobLeashLimitListener mobLeashLimitListener;
|
||||||
private MobCapListener mobCapListener;
|
private MobCapListener mobCapListener;
|
||||||
private SleepListener sleepListener;
|
private SleepListener sleepListener;
|
||||||
@@ -68,105 +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;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
updateConfigFiles(); // Config-Dateien aktualisieren
|
||||||
|
createHomesFile();
|
||||||
|
createGravesFile();
|
||||||
|
createBackpackFile();
|
||||||
|
createFriendsFile();
|
||||||
|
createLeashesFile();
|
||||||
|
createMobCapFile();
|
||||||
|
|
||||||
|
// PluginManager holen
|
||||||
|
PluginManager pluginManager = getServer().getPluginManager();
|
||||||
|
|
||||||
@Override
|
// FriendCommand instanzieren
|
||||||
public void onEnable() {
|
FriendCommand friendCommand = new FriendCommand(this, friendsConfig, langConfig, getLogger());
|
||||||
saveDefaultConfig();
|
|
||||||
createLangFile();
|
|
||||||
createHomesFile();
|
|
||||||
createGravesFile();
|
|
||||||
createHelpFile();
|
|
||||||
createBackpackFile();
|
|
||||||
createFriendsFile();
|
|
||||||
createLeashesFile();
|
|
||||||
createMobCapFile();
|
|
||||||
|
|
||||||
|
// StatsManager vor den Listenern initialisieren
|
||||||
|
statsManager = new StatsManager(this);
|
||||||
|
|
||||||
BackpackRecipe.register(this, langConfig);
|
// Listener initialisieren (sitListener zuerst!)
|
||||||
|
sitListener = new SitListener(this);
|
||||||
|
afkListener = new AFKListener(this);
|
||||||
|
graveListener = new GraveListener(this);
|
||||||
|
playerJoinListener = new PlayerJoinListener(friendCommand);
|
||||||
|
|
||||||
|
// Commands registrieren
|
||||||
|
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());
|
||||||
|
|
||||||
sitListener = new SitListener(this);
|
TeleportCommands teleportCommands = new TeleportCommands(this);
|
||||||
afkListener = new AFKListener(this);
|
getCommand("tp").setExecutor(teleportCommands);
|
||||||
graveListener = new GraveListener(this);
|
getCommand("tphere").setExecutor(teleportCommands);
|
||||||
|
getCommand("tpa").setExecutor(teleportCommands);
|
||||||
|
getCommand("tpaccept").setExecutor(teleportCommands);
|
||||||
|
getCommand("tpdeny").setExecutor(teleportCommands);
|
||||||
|
|
||||||
// Commands
|
getCommand("kit").setExecutor(new KitCommand(this));
|
||||||
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(new FriendCommand(this, friendsConfig, langConfig, getLogger()));
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
// BlockManager erstellen
|
||||||
|
BlockManager blockManager = new BlockManager();
|
||||||
|
|
||||||
// === Stats ===
|
// Konfiguration laden
|
||||||
statsManager = new StatsManager(this);
|
FileConfiguration config = getConfig();
|
||||||
getServer().getPluginManager().registerEvents(new StatsListener(this, statsManager), this);
|
|
||||||
getCommand("stats").setExecutor(new StatsCommand(this, statsManager));
|
|
||||||
|
|
||||||
// === Event Listener ===
|
// Listener registrieren
|
||||||
PluginManager pm = getServer().getPluginManager();
|
BackpackRecipe.register(this, langConfig);
|
||||||
|
|
||||||
pm.registerEvents(new InventoryClickListener(this), this);
|
pluginManager.registerEvents(new ChatBlockListener(blockManager), this);
|
||||||
pm.registerEvents(sitListener, this);
|
pluginManager.registerEvents(new InventoryClickListener(this), this);
|
||||||
pm.registerEvents(afkListener, this);
|
pluginManager.registerEvents(sitListener, this);
|
||||||
pm.registerEvents(graveListener, this);
|
pluginManager.registerEvents(afkListener, this);
|
||||||
pm.registerEvents(new BackpackListener(backpackConfig, langConfig, getLogger(), backpackFile), 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);
|
||||||
|
|
||||||
sleepListener = new SleepListener(this);
|
// Befehle mit BlockManager und Konfiguration registrieren
|
||||||
pm.registerEvents(sleepListener, this);
|
getCommand("block").setExecutor(new BlockCommand(blockManager, config));
|
||||||
|
getCommand("blocklist").setExecutor(new BlockListCommand(blockManager, config));
|
||||||
|
getCommand("unblock").setExecutor(new UnblockCommand(blockManager, config));
|
||||||
|
|
||||||
oreAlarmListener = new OreAlarmListener(this);
|
// Stats-Befehl registrieren
|
||||||
pm.registerEvents(oreAlarmListener, this);
|
getCommand("stats").setExecutor(new StatsCommand(this, statsManager));
|
||||||
|
|
||||||
mobLeashLimitListener = new MobLeashLimitListener(this, getConfig());
|
sleepListener = new SleepListener(this);
|
||||||
pm.registerEvents(mobLeashLimitListener, this);
|
pluginManager.registerEvents(sleepListener, this);
|
||||||
|
|
||||||
mobCapListener = new MobCapListener(this, getConfig());
|
oreAlarmListener = new OreAlarmListener(this);
|
||||||
pm.registerEvents(mobCapListener, this);
|
pluginManager.registerEvents(oreAlarmListener, this);
|
||||||
|
|
||||||
pm.registerEvents(new de.viper.survivalplus.listeners.LoginListener(this), this);
|
mobLeashLimitListener = new MobLeashLimitListener(this, getConfig());
|
||||||
pm.registerEvents(new DebugArmorStandListener(), this);
|
pluginManager.registerEvents(mobLeashLimitListener, this);
|
||||||
pm.registerEvents(new ArmorStandDestroyListener(), this);
|
|
||||||
|
|
||||||
// SpawnProtectionListener hinzufügen
|
mobCapListener = new MobCapListener(this, getConfig());
|
||||||
spawnProtectionListener = new SpawnProtectionListener(this);
|
pluginManager.registerEvents(mobCapListener, this);
|
||||||
pm.registerEvents(spawnProtectionListener, this);
|
|
||||||
|
|
||||||
LockSystem lockSystem = new LockSystem(this);
|
spawnProtectionListener = new SpawnProtectionListener(this);
|
||||||
getServer().getPluginManager().registerEvents(lockSystem, this);
|
pluginManager.registerEvents(spawnProtectionListener, this);
|
||||||
getCommand("lock").setExecutor(lockSystem);
|
|
||||||
|
|
||||||
// AutoClear Task starten
|
LockSystem lockSystem = new LockSystem(this);
|
||||||
startAutoClearTask();
|
pluginManager.registerEvents(lockSystem, this);
|
||||||
|
getCommand("lock").setExecutor(lockSystem);
|
||||||
|
|
||||||
// Beispiel ArmorStand
|
// AutoClear Task starten
|
||||||
spawnArmorStandExample();
|
startAutoClearTask();
|
||||||
|
|
||||||
getLogger().info(getMessage("plugin.enabled"));
|
// 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");
|
||||||
@@ -186,16 +193,16 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (autoClearTaskId != -1) {
|
if (autoClearTaskId != -1) {
|
||||||
Bukkit.getScheduler().cancelTask(autoClearTaskId);
|
Bukkit.getScheduler().cancelTask(autoClearTaskId);
|
||||||
}
|
|
||||||
saveStats();
|
|
||||||
saveLeashesConfig();
|
|
||||||
saveMobCapConfig();
|
|
||||||
|
|
||||||
getLogger().info(getMessage("plugin.disabled"));
|
|
||||||
}
|
}
|
||||||
|
saveStats();
|
||||||
|
saveLeashesConfig();
|
||||||
|
saveMobCapConfig();
|
||||||
|
|
||||||
|
getLogger().info(getMessage("plugin.disabled"));
|
||||||
|
}
|
||||||
|
|
||||||
public void saveStats() {
|
public void saveStats() {
|
||||||
if (statsManager != null) {
|
if (statsManager != null) {
|
||||||
@@ -207,6 +214,84 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
return ChatColor.translateAlternateColorCodes('&', getMessage("plugin.info"));
|
return ChatColor.translateAlternateColorCodes('&', getMessage("plugin.info"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === Config Updating Logic ===
|
||||||
|
private void updateConfigFiles() {
|
||||||
|
updateConfigFile("config.yml");
|
||||||
|
updateConfigFile("lang.yml");
|
||||||
|
updateConfigFile("help.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateConfigFile(String fileName) {
|
||||||
|
File file = new File(getDataFolder(), fileName);
|
||||||
|
FileConfiguration currentConfig = YamlConfiguration.loadConfiguration(file);
|
||||||
|
InputStream defaultStream = getResource(fileName);
|
||||||
|
|
||||||
|
if (defaultStream == null) {
|
||||||
|
getLogger().warning(fileName + " nicht im JAR gefunden. Erstelle leere Datei.");
|
||||||
|
if (!file.exists()) {
|
||||||
|
try {
|
||||||
|
file.createNewFile();
|
||||||
|
if (fileName.equals("config.yml")) {
|
||||||
|
saveDefaultConfig();
|
||||||
|
} else if (fileName.equals("lang.yml")) {
|
||||||
|
createLangFile();
|
||||||
|
} else if (fileName.equals("help.yml")) {
|
||||||
|
createHelpFile();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
getLogger().severe("Fehler beim Erstellen der " + fileName + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FileConfiguration defaultConfig = defaultStream != null ?
|
||||||
|
YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream)) : new YamlConfiguration();
|
||||||
|
|
||||||
|
// Merge default config into current config
|
||||||
|
mergeConfigs(defaultConfig, currentConfig);
|
||||||
|
|
||||||
|
// Save updated config
|
||||||
|
try {
|
||||||
|
currentConfig.save(file);
|
||||||
|
getLogger().info(fileName + " erfolgreich aktualisiert.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
getLogger().severe("Fehler beim Speichern der " + fileName + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update instance variables
|
||||||
|
if (fileName.equals("config.yml")) {
|
||||||
|
reloadConfig();
|
||||||
|
} else if (fileName.equals("lang.yml")) {
|
||||||
|
langFile = file;
|
||||||
|
langConfig = currentConfig;
|
||||||
|
} else if (fileName.equals("help.yml")) {
|
||||||
|
helpFile = file;
|
||||||
|
helpConfig = currentConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mergeConfigs(FileConfiguration defaultConfig, FileConfiguration currentConfig) {
|
||||||
|
for (String key : defaultConfig.getKeys(true)) {
|
||||||
|
if (!currentConfig.contains(key)) {
|
||||||
|
currentConfig.set(key, defaultConfig.get(key));
|
||||||
|
} else if (defaultConfig.isConfigurationSection(key) && currentConfig.isConfigurationSection(key)) {
|
||||||
|
// Rekursiv für Untersektionen
|
||||||
|
mergeConfigs(defaultConfig.getConfigurationSection(key), currentConfig.getConfigurationSection(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mergeConfigs(ConfigurationSection defaultSection, ConfigurationSection currentSection) {
|
||||||
|
for (String key : defaultSection.getKeys(false)) {
|
||||||
|
if (!currentSection.contains(key)) {
|
||||||
|
currentSection.set(key, defaultSection.get(key));
|
||||||
|
} else if (defaultSection.isConfigurationSection(key) && currentSection.isConfigurationSection(key)) {
|
||||||
|
mergeConfigs(defaultSection.getConfigurationSection(key), currentSection.getConfigurationSection(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// === Lang.yml ===
|
// === Lang.yml ===
|
||||||
private void createLangFile() {
|
private void createLangFile() {
|
||||||
langFile = new File(getDataFolder(), "lang.yml");
|
langFile = new File(getDataFolder(), "lang.yml");
|
||||||
@@ -226,12 +311,7 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reloadLangConfig() {
|
public void reloadLangConfig() {
|
||||||
try {
|
updateConfigFile("lang.yml");
|
||||||
langConfig = YamlConfiguration.loadConfiguration(langFile);
|
|
||||||
getLogger().info("lang.yml erfolgreich neu geladen.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().severe("Fehler beim Neuladen der lang.yml: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileConfiguration getLangConfig() {
|
public FileConfiguration getLangConfig() {
|
||||||
@@ -242,7 +322,12 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
private void createHomesFile() {
|
private void createHomesFile() {
|
||||||
homesFile = new File(getDataFolder(), "homes.yml");
|
homesFile = new File(getDataFolder(), "homes.yml");
|
||||||
if (!homesFile.exists()) {
|
if (!homesFile.exists()) {
|
||||||
saveResource("homes.yml", false);
|
try {
|
||||||
|
homesFile.createNewFile();
|
||||||
|
getLogger().info("homes.yml wurde erstellt.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
getLogger().severe("Fehler beim Erstellen der homes.yml: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
homesConfig = YamlConfiguration.loadConfiguration(homesFile);
|
homesConfig = YamlConfiguration.loadConfiguration(homesFile);
|
||||||
}
|
}
|
||||||
@@ -260,11 +345,21 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reloadHomesConfig() {
|
||||||
|
homesConfig = YamlConfiguration.loadConfiguration(homesFile);
|
||||||
|
getLogger().info("homes.yml erfolgreich neu geladen.");
|
||||||
|
}
|
||||||
|
|
||||||
// === Graves.yml ===
|
// === Graves.yml ===
|
||||||
private void createGravesFile() {
|
private void createGravesFile() {
|
||||||
gravesFile = new File(getDataFolder(), "graves.yml");
|
gravesFile = new File(getDataFolder(), "graves.yml");
|
||||||
if (!gravesFile.exists()) {
|
if (!gravesFile.exists()) {
|
||||||
saveResource("graves.yml", false);
|
try {
|
||||||
|
gravesFile.createNewFile();
|
||||||
|
getLogger().info("graves.yml wurde erstellt.");
|
||||||
|
} catch (IOException e) {
|
||||||
|
getLogger().severe("Fehler beim Erstellen der graves.yml: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gravesConfig = YamlConfiguration.loadConfiguration(gravesFile);
|
gravesConfig = YamlConfiguration.loadConfiguration(gravesFile);
|
||||||
}
|
}
|
||||||
@@ -282,6 +377,11 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reloadGravesConfig() {
|
||||||
|
gravesConfig = YamlConfiguration.loadConfiguration(gravesFile);
|
||||||
|
getLogger().info("graves.yml erfolgreich neu geladen.");
|
||||||
|
}
|
||||||
|
|
||||||
// === Help.yml ===
|
// === Help.yml ===
|
||||||
private void createHelpFile() {
|
private void createHelpFile() {
|
||||||
helpFile = new File(getDataFolder(), "help.yml");
|
helpFile = new File(getDataFolder(), "help.yml");
|
||||||
@@ -297,8 +397,8 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
helpConfig.set("footer", "§6=====================");
|
helpConfig.set("footer", "§6=====================");
|
||||||
helpConfig.save(helpFile);
|
helpConfig.save(helpFile);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (IOException e) {
|
||||||
getLogger().severe("Fehler beim Laden der help.yml: " + e.getMessage());
|
getLogger().severe("Fehler beim Erstellen der help.yml: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
helpConfig = YamlConfiguration.loadConfiguration(helpFile);
|
helpConfig = YamlConfiguration.loadConfiguration(helpFile);
|
||||||
@@ -309,12 +409,7 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reloadHelpConfig() {
|
public void reloadHelpConfig() {
|
||||||
try {
|
updateConfigFile("help.yml");
|
||||||
helpConfig = YamlConfiguration.loadConfiguration(helpFile);
|
|
||||||
getLogger().info("help.yml erfolgreich neu geladen.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().severe("Fehler beim Neuladen der help.yml: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Backpack.yml ===
|
// === Backpack.yml ===
|
||||||
@@ -344,6 +439,11 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reloadBackpackConfig() {
|
||||||
|
backpackConfig = YamlConfiguration.loadConfiguration(backpackFile);
|
||||||
|
getLogger().info("backpacks.yml erfolgreich neu geladen.");
|
||||||
|
}
|
||||||
|
|
||||||
// === Friends.yml ===
|
// === Friends.yml ===
|
||||||
private void createFriendsFile() {
|
private void createFriendsFile() {
|
||||||
friendsFile = new File(getDataFolder(), "friends.yml");
|
friendsFile = new File(getDataFolder(), "friends.yml");
|
||||||
@@ -371,6 +471,11 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reloadFriendsConfig() {
|
||||||
|
friendsConfig = YamlConfiguration.loadConfiguration(friendsFile);
|
||||||
|
getLogger().info("friends.yml erfolgreich neu geladen.");
|
||||||
|
}
|
||||||
|
|
||||||
// === Leashes.yml ===
|
// === Leashes.yml ===
|
||||||
private void createLeashesFile() {
|
private void createLeashesFile() {
|
||||||
leashesFile = new File(getDataFolder(), "leashes.yml");
|
leashesFile = new File(getDataFolder(), "leashes.yml");
|
||||||
@@ -399,12 +504,8 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reloadLeashesConfig() {
|
public void reloadLeashesConfig() {
|
||||||
try {
|
leashesConfig = YamlConfiguration.loadConfiguration(leashesFile);
|
||||||
leashesConfig = YamlConfiguration.loadConfiguration(leashesFile);
|
getLogger().info("leashes.yml erfolgreich neu geladen.");
|
||||||
getLogger().info("leashes.yml erfolgreich neu geladen.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().severe("Fehler beim Neuladen der leashes.yml: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === MobCap.yml ===
|
// === MobCap.yml ===
|
||||||
@@ -435,12 +536,8 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reloadMobCapConfig() {
|
public void reloadMobCapConfig() {
|
||||||
try {
|
mobCapConfig = YamlConfiguration.loadConfiguration(mobCapFile);
|
||||||
mobCapConfig = YamlConfiguration.loadConfiguration(mobCapFile);
|
getLogger().info("mobcap.yml erfolgreich neu geladen.");
|
||||||
getLogger().info("mobcap.yml erfolgreich neu geladen.");
|
|
||||||
} catch (Exception e) {
|
|
||||||
getLogger().severe("Fehler beim Neuladen der mobcap.yml: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// === AutoClearTask ===
|
// === AutoClearTask ===
|
||||||
@@ -465,11 +562,8 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
// === Reload Plugin ===
|
// === Reload Plugin ===
|
||||||
public void reloadPlugin() {
|
public void reloadPlugin() {
|
||||||
try {
|
try {
|
||||||
// Config-Dateien neu laden
|
// Config-Dateien aktualisieren
|
||||||
reloadConfig();
|
updateConfigFiles();
|
||||||
getLogger().info("config.yml erfolgreich neu geladen.");
|
|
||||||
reloadLangConfig();
|
|
||||||
reloadHelpConfig();
|
|
||||||
reloadBackpackConfig();
|
reloadBackpackConfig();
|
||||||
reloadFriendsConfig();
|
reloadFriendsConfig();
|
||||||
reloadHomesConfig();
|
reloadHomesConfig();
|
||||||
@@ -484,6 +578,9 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
|
|
||||||
|
// FriendCommand instanzieren für PlayerJoinListener
|
||||||
|
FriendCommand friendCommand = new FriendCommand(this, friendsConfig, langConfig, getLogger());
|
||||||
|
|
||||||
// Listener neu erstellen und registrieren
|
// Listener neu erstellen und registrieren
|
||||||
mobLeashLimitListener = new MobLeashLimitListener(this, getConfig());
|
mobLeashLimitListener = new MobLeashLimitListener(this, getConfig());
|
||||||
mobLeashLimitListener.reloadConfig(getConfig());
|
mobLeashLimitListener.reloadConfig(getConfig());
|
||||||
@@ -512,20 +609,26 @@ 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);
|
||||||
|
pm.registerEvents(playerJoinListener, this);
|
||||||
|
|
||||||
pm.registerEvents(new InventoryClickListener(this), this);
|
pm.registerEvents(new InventoryClickListener(this), this);
|
||||||
pm.registerEvents(new BackpackListener(backpackConfig, langConfig, getLogger(), backpackFile), this);
|
pm.registerEvents(new BackpackListener(backpackConfig, langConfig, getLogger(), backpackFile), this);
|
||||||
pm.registerEvents(new StatsListener(this, statsManager), this);
|
pm.registerEvents(new StatsListener(this, statsManager), this);
|
||||||
pm.registerEvents(new LoginListener(this), this);
|
pm.registerEvents(new LoginListener(this), this);
|
||||||
pm.registerEvents(new DebugArmorStandListener(), this);
|
pm.registerEvents(new DebugArmorStandListener(), this);
|
||||||
pm.registerEvents(new ArmorStandDestroyListener(), this);
|
pm.registerEvents(new ArmorStandDestroyListener(), this);
|
||||||
|
pm.registerEvents(new FirstJoinListener(), this);
|
||||||
|
|
||||||
spawnProtectionListener = new SpawnProtectionListener(this);
|
spawnProtectionListener = new SpawnProtectionListener(this);
|
||||||
pm.registerEvents(spawnProtectionListener, this);
|
pm.registerEvents(spawnProtectionListener, this);
|
||||||
|
|
||||||
LockSystem lockSystem = new LockSystem(this);
|
LockSystem lockSystem = new LockSystem(this);
|
||||||
getServer().getPluginManager().registerEvents(lockSystem, this);
|
pm.registerEvents(lockSystem, this);
|
||||||
getCommand("lock").setExecutor(lockSystem);
|
getCommand("lock").setExecutor(lockSystem);
|
||||||
|
|
||||||
|
// Commands neu registrieren
|
||||||
|
getCommand("friend").setExecutor(friendCommand);
|
||||||
|
|
||||||
getLogger().info(getMessage("plugin.reloaded"));
|
getLogger().info(getMessage("plugin.reloaded"));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -533,24 +636,4 @@ public class SurvivalPlus extends JavaPlugin {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadBackpackConfig() {
|
|
||||||
backpackConfig = YamlConfiguration.loadConfiguration(backpackFile);
|
|
||||||
getLogger().info("backpacks.yml erfolgreich neu geladen.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reloadFriendsConfig() {
|
|
||||||
friendsConfig = YamlConfiguration.loadConfiguration(friendsFile);
|
|
||||||
getLogger().info("friends.yml erfolgreich neu geladen.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reloadHomesConfig() {
|
|
||||||
homesConfig = YamlConfiguration.loadConfiguration(homesFile);
|
|
||||||
getLogger().info("homes.yml erfolgreich neu geladen.");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reloadGravesConfig() {
|
|
||||||
gravesConfig = YamlConfiguration.loadConfiguration(gravesFile);
|
|
||||||
getLogger().info("graves.yml erfolgreich neu geladen.");
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -0,0 +1,47 @@
|
|||||||
|
package de.viper.survivalplus.commands;
|
||||||
|
|
||||||
|
import de.viper.survivalplus.Manager.BlockManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.*;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
public class BlockCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final BlockManager blockManager;
|
||||||
|
private final FileConfiguration config;
|
||||||
|
|
||||||
|
public BlockCommand(BlockManager blockManager, FileConfiguration config) {
|
||||||
|
this.blockManager = blockManager;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
|
if (!(sender instanceof Player player)) {
|
||||||
|
sender.sendMessage(config.getString("messages.general.only_players"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length != 1) {
|
||||||
|
player.sendMessage(config.getString("messages.block.usage"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player target = Bukkit.getPlayerExact(args[0]);
|
||||||
|
if (target == null || target == player) {
|
||||||
|
player.sendMessage(config.getString("messages.block.invalid_player"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockManager.hasBlocked(player, target)) {
|
||||||
|
player.sendMessage(config.getString("messages.block.already_blocked").replace("%player%", target.getName()));
|
||||||
|
} else {
|
||||||
|
blockManager.blockPlayer(player, target);
|
||||||
|
player.sendMessage(config.getString("messages.block.blocked").replace("%player%", target.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,43 @@
|
|||||||
|
package de.viper.survivalplus.commands;
|
||||||
|
|
||||||
|
import de.viper.survivalplus.Manager.BlockManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.*;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class BlockListCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final BlockManager blockManager;
|
||||||
|
private final FileConfiguration config;
|
||||||
|
|
||||||
|
public BlockListCommand(BlockManager blockManager, FileConfiguration config) {
|
||||||
|
this.blockManager = blockManager;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
|
if (!(sender instanceof Player player)) {
|
||||||
|
sender.sendMessage(config.getString("messages.general.only_players"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var blocked = blockManager.getBlockedPlayers(player);
|
||||||
|
if (blocked.isEmpty()) {
|
||||||
|
player.sendMessage(config.getString("messages.blocklist.no_blocked_players"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String list = blocked.stream()
|
||||||
|
.map(Bukkit::getOfflinePlayer)
|
||||||
|
.map(p -> p.getName() != null ? p.getName() : "Unbekannt")
|
||||||
|
.collect(Collectors.joining(", "));
|
||||||
|
|
||||||
|
player.sendMessage(config.getString("messages.blocklist.blocked_players").replace("%list%", list));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,5 +1,7 @@
|
|||||||
package de.viper.survivalplus.commands;
|
package de.viper.survivalplus.commands;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -11,7 +13,9 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@@ -87,6 +91,14 @@ public class FriendCommand implements CommandExecutor {
|
|||||||
handleFriendDelete(player, args[1]);
|
handleFriendDelete(player, args[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "confirm":
|
||||||
|
if (args.length != 2) {
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.error.confirm-usage", "&cVerwendung: /friend confirm <Spielername>")));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
handleFriendConfirmDelete(player, args[1]);
|
||||||
|
break;
|
||||||
|
|
||||||
case "tp":
|
case "tp":
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.error.tp-usage", "&cVerwendung: /friend tp <Spielername>")));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.error.tp-usage", "&cVerwendung: /friend tp <Spielername>")));
|
||||||
@@ -142,10 +154,20 @@ public class FriendCommand implements CommandExecutor {
|
|||||||
|
|
||||||
pendingRequests.add(playerUUID.toString());
|
pendingRequests.add(playerUUID.toString());
|
||||||
friendsConfig.set(targetUUID + ".pending_requests", pendingRequests);
|
friendsConfig.set(targetUUID + ".pending_requests", pendingRequests);
|
||||||
friendsConfig.set(targetUUID + ".name", targetName); // Speichere den Namen für Offline-Lookups
|
friendsConfig.set(targetUUID + ".name", targetName);
|
||||||
saveFriendsConfig();
|
saveFriendsConfig();
|
||||||
|
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.add.sent", "&aFreundschaftsanfrage an %s gesendet!").replace("%s", targetName)));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.add.sent", "&aFreundschaftsanfrage an %s gesendet!").replace("%s", targetName)));
|
||||||
target.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.add.received", "&aDu hast eine Freundschaftsanfrage von %s erhalten! Verwende /friend accept %s oder /friend deny %s.").replace("%s", player.getName())));
|
|
||||||
|
TextComponent message = new TextComponent(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.add.received", "&aDu hast eine Freundschaftsanfrage von %s erhalten! ").replace("%s", player.getName())));
|
||||||
|
TextComponent accept = new TextComponent(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.add.accept-button", "&a[Accept]")));
|
||||||
|
accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend accept " + player.getName()));
|
||||||
|
TextComponent deny = new TextComponent(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.add.deny-button", "&c [Deny]")));
|
||||||
|
deny.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend deny " + player.getName()));
|
||||||
|
message.addExtra(accept);
|
||||||
|
message.addExtra(deny);
|
||||||
|
target.spigot().sendMessage(message);
|
||||||
|
|
||||||
logger.info("Freundschaftsanfrage von " + player.getName() + " an " + targetName + " gesendet.");
|
logger.info("Freundschaftsanfrage von " + player.getName() + " an " + targetName + " gesendet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,9 +204,9 @@ public class FriendCommand implements CommandExecutor {
|
|||||||
requesterFriends.add(playerUUID.toString());
|
requesterFriends.add(playerUUID.toString());
|
||||||
|
|
||||||
friendsConfig.set(playerUUID + ".friends", playerFriends);
|
friendsConfig.set(playerUUID + ".friends", playerFriends);
|
||||||
friendsConfig.set(playerUUID + ".name", player.getName()); // Speichere den Namen für Offline-Lookups
|
friendsConfig.set(playerUUID + ".name", player.getName());
|
||||||
friendsConfig.set(requesterUUID + ".friends", requesterFriends);
|
friendsConfig.set(requesterUUID + ".friends", requesterFriends);
|
||||||
friendsConfig.set(requesterUUID + ".name", requesterName); // Speichere den Namen für Offline-Lookups
|
friendsConfig.set(requesterUUID + ".name", requesterName);
|
||||||
|
|
||||||
saveFriendsConfig();
|
saveFriendsConfig();
|
||||||
|
|
||||||
@@ -231,11 +253,26 @@ public class FriendCommand implements CommandExecutor {
|
|||||||
if (friendUUIDs.isEmpty()) {
|
if (friendUUIDs.isEmpty()) {
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.list.empty", "&7Du hast keine Freunde.")));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.list.empty", "&7Du hast keine Freunde.")));
|
||||||
} else {
|
} else {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat(langConfig.getString("friend.list.date-format", "dd.MM.yyyy HH:mm:ss"));
|
||||||
for (String friendUUID : friendUUIDs) {
|
for (String friendUUID : friendUUIDs) {
|
||||||
String friendName = getNameFromUUID(UUID.fromString(friendUUID));
|
String friendName = getNameFromUUID(UUID.fromString(friendUUID));
|
||||||
Player friend = Bukkit.getPlayer(UUID.fromString(friendUUID));
|
Player friend = Bukkit.getPlayer(UUID.fromString(friendUUID));
|
||||||
String status = friend != null ? langConfig.getString("friend.list.online", "&aOnline") : langConfig.getString("friend.list.offline", "&7Offline");
|
TextComponent entry = new TextComponent();
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.list.entry", "&e%s: %s").replaceFirst("%s", friendName).replaceFirst("%s", status)));
|
|
||||||
|
if (friend != null) {
|
||||||
|
entry.addExtra(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.list.entry", "&e%s: %s").replaceFirst("%s", friendName).replaceFirst("%s", langConfig.getString("friend.list.online", "&aOnline"))));
|
||||||
|
} else {
|
||||||
|
long lastOnline = friendsConfig.getLong(friendUUID + ".last-online", 0);
|
||||||
|
String lastOnlineStr = lastOnline > 0 ? dateFormat.format(new Date(lastOnline)) : langConfig.getString("friend.list.unknown", "&7Unbekannt");
|
||||||
|
entry.addExtra(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.list.entry-offline", "&e%s: %s &7(Zuletzt online: %s)").replaceFirst("%s", friendName).replaceFirst("%s", langConfig.getString("friend.list.offline", "&7Offline")).replace("%s", lastOnlineStr)));
|
||||||
|
}
|
||||||
|
|
||||||
|
TextComponent removeButton = new TextComponent(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.list.remove-button", "&c[X]")));
|
||||||
|
removeButton.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend del " + friendName));
|
||||||
|
entry.addExtra(" ");
|
||||||
|
entry.addExtra(removeButton);
|
||||||
|
|
||||||
|
player.spigot().sendMessage(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.list.footer", "&6=====================")));
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.list.footer", "&6=====================")));
|
||||||
@@ -249,6 +286,34 @@ public class FriendCommand implements CommandExecutor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
List<String> playerFriends = friendsConfig.getStringList(playerUUID + ".friends");
|
||||||
|
|
||||||
|
if (!playerFriends.contains(friendUUID.toString())) {
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.error.not-friends", "&c%s ist nicht in deiner Freundesliste!").replace("%s", friendName)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TextComponent confirmMessage = new TextComponent(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.del.confirm", "&cMöchtest du %s wirklich aus deiner Freundesliste entfernen? ").replace("%s", friendName)));
|
||||||
|
TextComponent confirmButton = new TextComponent(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.del.confirm-button", "&a[Confirm]")));
|
||||||
|
confirmButton.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend confirm " + friendName));
|
||||||
|
TextComponent cancelButton = new TextComponent(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.del.cancel-button", "&c[Cancel]")));
|
||||||
|
cancelButton.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/friend list"));
|
||||||
|
confirmMessage.addExtra(confirmButton);
|
||||||
|
confirmMessage.addExtra(" ");
|
||||||
|
confirmMessage.addExtra(cancelButton);
|
||||||
|
player.spigot().sendMessage(confirmMessage);
|
||||||
|
|
||||||
|
logger.info(player.getName() + " wurde zur Bestätigung aufgefordert, " + friendName + " aus der Freundesliste zu entfernen.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleFriendConfirmDelete(Player player, String friendName) {
|
||||||
|
UUID friendUUID = getUUIDFromName(friendName);
|
||||||
|
if (friendUUID == null) {
|
||||||
|
player.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.error.player-not-found", "&cSpieler %s nicht gefunden!").replace("%s", friendName)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
UUID playerUUID = player.getUniqueId();
|
UUID playerUUID = player.getUniqueId();
|
||||||
List<String> playerFriends = friendsConfig.getStringList(playerUUID + ".friends");
|
List<String> playerFriends = friendsConfig.getStringList(playerUUID + ".friends");
|
||||||
List<String> friendFriends = friendsConfig.getStringList(friendUUID + ".friends");
|
List<String> friendFriends = friendsConfig.getStringList(friendUUID + ".friends");
|
||||||
@@ -305,7 +370,6 @@ public class FriendCommand implements CommandExecutor {
|
|||||||
if (target != null) {
|
if (target != null) {
|
||||||
return target.getUniqueId();
|
return target.getUniqueId();
|
||||||
}
|
}
|
||||||
// Fallback für Offline-Spieler
|
|
||||||
for (String key : friendsConfig.getKeys(false)) {
|
for (String key : friendsConfig.getKeys(false)) {
|
||||||
try {
|
try {
|
||||||
UUID uuid = UUID.fromString(key);
|
UUID uuid = UUID.fromString(key);
|
||||||
@@ -328,7 +392,7 @@ public class FriendCommand implements CommandExecutor {
|
|||||||
if (storedName != null) {
|
if (storedName != null) {
|
||||||
return storedName;
|
return storedName;
|
||||||
}
|
}
|
||||||
return uuid.toString(); // Fallback auf UUID, falls Name nicht gefunden
|
return uuid.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveFriendsConfig() {
|
private void saveFriendsConfig() {
|
||||||
@@ -340,4 +404,20 @@ public class FriendCommand implements CommandExecutor {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void notifyFriendsOfJoin(Player player) {
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
for (String friendUUIDStr : friendsConfig.getStringList(playerUUID + ".friends")) {
|
||||||
|
Player friend = Bukkit.getPlayer(UUID.fromString(friendUUIDStr));
|
||||||
|
if (friend != null) {
|
||||||
|
friend.sendMessage(ChatColor.translateAlternateColorCodes('&', langConfig.getString("friend.join.notify", "&aDein Freund %s ist dem Server beigetreten.").replace("%s", player.getName())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLastOnline(Player player) {
|
||||||
|
UUID playerUUID = player.getUniqueId();
|
||||||
|
friendsConfig.set(playerUUID + ".last-online", System.currentTimeMillis());
|
||||||
|
saveFriendsConfig();
|
||||||
|
}
|
||||||
}
|
}
|
65
src/main/java/de/viper/survivalplus/commands/KitCommand.java
Normal file
65
src/main/java/de/viper/survivalplus/commands/KitCommand.java
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package de.viper.survivalplus.commands;
|
||||||
|
|
||||||
|
import de.viper.survivalplus.SurvivalPlus;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class KitCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final SurvivalPlus plugin;
|
||||||
|
|
||||||
|
public KitCommand(SurvivalPlus plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
// Hole die Konfiguration
|
||||||
|
FileConfiguration config = plugin.getConfig();
|
||||||
|
|
||||||
|
// Hole die Items aus der Konfiguration
|
||||||
|
List<String> items = config.getStringList("first-join-kit.items");
|
||||||
|
|
||||||
|
for (String itemString : items) {
|
||||||
|
// Teile den Item-String auf
|
||||||
|
String[] itemParts = itemString.split(",");
|
||||||
|
String materialName = itemParts[0].toUpperCase();
|
||||||
|
int amount = Integer.parseInt(itemParts[1]);
|
||||||
|
String displayName = itemParts.length > 2 ? itemParts[2] : "";
|
||||||
|
|
||||||
|
// Erstelle das Item
|
||||||
|
Material material = Material.getMaterial(materialName);
|
||||||
|
if (material == null) {
|
||||||
|
player.sendMessage("Unbekanntes Item: " + materialName);
|
||||||
|
continue; // Falls das Item ungültig ist, überspringe es
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = new ItemStack(material, amount);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
||||||
|
// Setze den Display-Namen (falls vorhanden)
|
||||||
|
if (meta != null && !displayName.isEmpty()) {
|
||||||
|
meta.setDisplayName(displayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
player.getInventory().addItem(item); // Gib das Item an den Spieler
|
||||||
|
|
||||||
|
}
|
||||||
|
player.sendMessage("Du hast dein Kit erhalten!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,48 @@
|
|||||||
|
package de.viper.survivalplus.commands;
|
||||||
|
|
||||||
|
import de.viper.survivalplus.Manager.BlockManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.*;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
public class UnblockCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final BlockManager blockManager;
|
||||||
|
private final FileConfiguration config;
|
||||||
|
|
||||||
|
public UnblockCommand(BlockManager blockManager, FileConfiguration config) {
|
||||||
|
this.blockManager = blockManager;
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|
||||||
|
if (!(sender instanceof Player player)) {
|
||||||
|
sender.sendMessage(config.getString("messages.general.only_players"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length != 1) {
|
||||||
|
player.sendMessage(config.getString("messages.unblock.usage"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player target = Bukkit.getPlayerExact(args[0]);
|
||||||
|
if (target == null || target == player) {
|
||||||
|
player.sendMessage(config.getString("messages.unblock.invalid_player"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (blockManager.hasBlocked(player, target)) {
|
||||||
|
blockManager.unblockPlayer(player, target);
|
||||||
|
player.sendMessage(config.getString("messages.unblock.unblocked").replace("%player%", target.getName()));
|
||||||
|
target.sendMessage(config.getString("messages.unblock.unblocked_by").replace("%player%", player.getName()));
|
||||||
|
} else {
|
||||||
|
player.sendMessage(config.getString("messages.unblock.not_blocked").replace("%player%", target.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@@ -51,7 +51,7 @@ public class AFKListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
afkTask.runTaskTimer(plugin, 20L, 100L);
|
afkTask.runTaskTimer(plugin, 60L, 100L); // Start nach 3 Sekunden (60 Ticks), dann alle 5 Sekunden (100 Ticks)
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleActivity(Player player) {
|
private void handleActivity(Player player) {
|
||||||
|
@@ -0,0 +1,26 @@
|
|||||||
|
package de.viper.survivalplus.listeners;
|
||||||
|
|
||||||
|
import de.viper.survivalplus.Manager.BlockManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
public class ChatBlockListener implements Listener {
|
||||||
|
|
||||||
|
private final BlockManager blockManager;
|
||||||
|
|
||||||
|
public ChatBlockListener(BlockManager blockManager) {
|
||||||
|
this.blockManager = blockManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onChat(AsyncPlayerChatEvent event) {
|
||||||
|
Player sender = event.getPlayer();
|
||||||
|
|
||||||
|
event.getRecipients().removeIf(recipient ->
|
||||||
|
blockManager.hasBlocked(recipient, sender) || blockManager.hasBlocked(sender, recipient)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,35 @@
|
|||||||
|
package de.viper.survivalplus.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.PotionMeta;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
public class FirstJoinListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerFirstJoin(PlayerJoinEvent event) {
|
||||||
|
if (event.getPlayer().hasPlayedBefore()) {
|
||||||
|
return; // Nur für den ersten Join
|
||||||
|
}
|
||||||
|
|
||||||
|
// Erstelle ein ItemStack für einen Trank (z.B. Heiltrank)
|
||||||
|
ItemStack potion = new ItemStack(Material.POTION, 1);
|
||||||
|
|
||||||
|
if (potion.getItemMeta() instanceof PotionMeta) {
|
||||||
|
PotionMeta potionMeta = (PotionMeta) potion.getItemMeta();
|
||||||
|
PotionEffect effect = new PotionEffect(PotionEffectType.REGENERATION, 600, 1);
|
||||||
|
potionMeta.addCustomEffect(effect, true);
|
||||||
|
potion.setItemMeta(potionMeta);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Füge das Trank-Item zum Inventar des Spielers hinzu
|
||||||
|
PlayerInventory inventory = event.getPlayer().getInventory();
|
||||||
|
inventory.addItem(potion);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,28 @@
|
|||||||
|
package de.viper.survivalplus.listeners;
|
||||||
|
|
||||||
|
import de.viper.survivalplus.commands.FriendCommand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class PlayerJoinListener implements Listener {
|
||||||
|
private final FriendCommand friendCommand;
|
||||||
|
|
||||||
|
public PlayerJoinListener(FriendCommand friendCommand) {
|
||||||
|
this.friendCommand = friendCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
friendCommand.notifyFriendsOfJoin(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
friendCommand.updateLastOnline(player);
|
||||||
|
}
|
||||||
|
}
|
@@ -44,3 +44,10 @@ spawnprotection:
|
|||||||
protect-pvp: true
|
protect-pvp: true
|
||||||
bypass-permission: survivalplus.spawnprotection.bypass
|
bypass-permission: survivalplus.spawnprotection.bypass
|
||||||
|
|
||||||
|
# Start Kit (Minecraft item, Menge, Custom-Name)
|
||||||
|
first-join-kit:
|
||||||
|
items:
|
||||||
|
- "bread,2,§6Bernd das Brot"
|
||||||
|
- "apple,1,§7Dornröschen Apfel"
|
||||||
|
- "wooden_sword,1,§eSchwert"
|
||||||
|
- "suspicious_stew,1,§6Heldensuppe"
|
||||||
|
@@ -4,10 +4,10 @@ footer: "&6==========================="
|
|||||||
commands:
|
commands:
|
||||||
gm:
|
gm:
|
||||||
description: "&eWechselt den Spielmodus (survival, creative, adventure, spectator)."
|
description: "&eWechselt den Spielmodus (survival, creative, adventure, spectator)."
|
||||||
usage: "&b/gm < survival | creative | adventure | spectator >"
|
usage: "&b/gm <survival | creative | adventure | spectator>"
|
||||||
sp:
|
sp:
|
||||||
description: "&eHauptbefehl für SurvivalPlus mit Unterbefehlen."
|
description: "&eHauptbefehl für SurvivalPlus mit Unterbefehlen."
|
||||||
usage: "&b/sp < reload | help >"
|
usage: "&b/sp <reload | help | info>"
|
||||||
sethome:
|
sethome:
|
||||||
description: "&eSetzt einen neuen Homepunkt."
|
description: "&eSetzt einen neuen Homepunkt."
|
||||||
usage: "&b/sethome <name>"
|
usage: "&b/sethome <name>"
|
||||||
@@ -45,8 +45,8 @@ commands:
|
|||||||
description: "&eTeleportiert dich zurück zum letzten Ort."
|
description: "&eTeleportiert dich zurück zum letzten Ort."
|
||||||
usage: "&b/back"
|
usage: "&b/back"
|
||||||
friend:
|
friend:
|
||||||
description: "&eVerwalte Freunde (add, remove, list)."
|
description: "&eVerwalte deine Freundesliste (hinzufügen, entfernen, anzeigen, teleportieren). Unterstützt anklickbare Anfragen und Bestätigungen."
|
||||||
usage: "&b/friend < add | remove | list > [Spieler]"
|
usage: "&b/friend <add | accept | deny | list | del | confirm | tp> [Spieler]"
|
||||||
ir:
|
ir:
|
||||||
description: "&eBenennt Items um."
|
description: "&eBenennt Items um."
|
||||||
usage: "&b/ir <Name>"
|
usage: "&b/ir <Name>"
|
||||||
@@ -70,8 +70,7 @@ commands:
|
|||||||
usage: "&b/stats"
|
usage: "&b/stats"
|
||||||
lock:
|
lock:
|
||||||
description: "&eSchützt Container mit dem LockSystem."
|
description: "&eSchützt Container mit dem LockSystem."
|
||||||
usage: "&b/lock < lock | unlock | info >"
|
usage: "&b/lock <lock | unlock | info>"
|
||||||
|
|
||||||
tp:
|
tp:
|
||||||
description: "&eTeleportiert dich zu einem anderen Spieler."
|
description: "&eTeleportiert dich zu einem anderen Spieler."
|
||||||
usage: "&b/tp <Spieler>"
|
usage: "&b/tp <Spieler>"
|
||||||
|
@@ -1,8 +1,15 @@
|
|||||||
sp:
|
sp:
|
||||||
no-permission: "§cDu hast keine Berechtigung für diesen Befehl!"
|
no-permission: "§cDu hast keine Berechtigung für diesen Befehl!"
|
||||||
plugin.reloaded: "§aSurvivalPlus wurde erfolgreich neu geladen!"
|
plugin.reloaded: "§aSurvivalPlus wurde erfolgreich neu geladen!"
|
||||||
sp.invalid-subcommand: "§cUngültiger Unterbefehl! Verwendung: /sp [reload | help]"
|
invalid-subcommand: "§cUngültiger Unterbefehl! Verwendung: /sp [ reload | help | info ]"
|
||||||
sp.help-not-found: "§cHilfedatei (help.yml) konnte nicht geladen werden!"
|
help-not-found: "§cHilfedatei (help.yml) konnte nicht geladen werden!"
|
||||||
|
info:
|
||||||
|
header: "§7===== SurvivalPlus Info ====="
|
||||||
|
name: "§ePlugin-Name: §f"
|
||||||
|
version: "§eVersion: §f"
|
||||||
|
author: "§eErsteller: §f"
|
||||||
|
description: "§eBeschreibung: §f"
|
||||||
|
footer: "§7=========================="
|
||||||
|
|
||||||
plugin:
|
plugin:
|
||||||
enabled: "&aSurvivalPlus wurde erfolgreich aktiviert!"
|
enabled: "&aSurvivalPlus wurde erfolgreich aktiviert!"
|
||||||
@@ -131,16 +138,56 @@ friend:
|
|||||||
deny-usage: "&cVerwendung: /friend deny <Spielername>"
|
deny-usage: "&cVerwendung: /friend deny <Spielername>"
|
||||||
list-usage: "&cVerwendung: /friend list"
|
list-usage: "&cVerwendung: /friend list"
|
||||||
del-usage: "&cVerwendung: /friend del <Spielername>"
|
del-usage: "&cVerwendung: /friend del <Spielername>"
|
||||||
|
confirm-usage: "&cVerwendung: /friend confirm <Spielername>"
|
||||||
tp-usage: "&cVerwendung: /friend tp <Spielername>"
|
tp-usage: "&cVerwendung: /friend tp <Spielername>"
|
||||||
|
|
||||||
|
add:
|
||||||
|
sent: "&aFreundschaftsanfrage an %s gesendet!"
|
||||||
|
received: "&aDu hast eine Freundschaftsanfrage von %s erhalten! "
|
||||||
|
accept-button: "&a[Accept]"
|
||||||
|
deny-button: "&c [Deny]"
|
||||||
|
|
||||||
|
accept:
|
||||||
|
success: "&aDu bist jetzt mit %s befreundet!"
|
||||||
|
notify: "&a%s hat deine Freundschaftsanfrage akzeptiert!"
|
||||||
|
|
||||||
|
deny:
|
||||||
|
success: "&aFreundschaftsanfrage von %s abgelehnt."
|
||||||
|
notify: "&c%s hat deine Freundschaftsanfrage abgelehnt."
|
||||||
|
|
||||||
|
list:
|
||||||
|
header: "&6=== Deine Freundesliste ==="
|
||||||
|
entry: "&e%s: %s"
|
||||||
|
entry-offline: "&e%s: %s &7(Zuletzt online: %s)"
|
||||||
|
online: "&aOnline"
|
||||||
|
offline: "&7Offline"
|
||||||
|
unknown: "&7Unbekannt"
|
||||||
|
date-format: "dd.MM.yyyy HH:mm:ss"
|
||||||
|
remove-button: "&c[X]"
|
||||||
|
footer: "&6====================="
|
||||||
|
|
||||||
|
del:
|
||||||
|
success: "&a%s wurde aus deiner Freundesliste entfernt."
|
||||||
|
notify: "&c%s hat dich aus seiner Freundesliste entfernt."
|
||||||
|
confirm: "&cMöchtest du %s wirklich aus deiner Freundesliste entfernen? "
|
||||||
|
confirm-button: "&a[Confirm]"
|
||||||
|
cancel-button: "&c[Cancel]"
|
||||||
|
|
||||||
|
tp:
|
||||||
|
success: "&aDu wurdest zu %s teleportiert!"
|
||||||
|
notify: "&a%s hat sich zu dir teleportiert."
|
||||||
|
|
||||||
|
join:
|
||||||
|
notify: "&aDein Freund %s ist dem Server beigetreten."
|
||||||
|
|
||||||
ir:
|
ir:
|
||||||
only-player: "&cDieser Befehl kann nur von Spielern ausgeführt werden."
|
only-player: "&cDieser Befehl kann nur von Spielern ausgeführt werden."
|
||||||
no-permission: "&cDu hast keine Berechtigung, diesen Befehl zu benutzen."
|
no-permission: "&cDu hast keine Berechtigung, diesen Befehl zu benutzen."
|
||||||
no-name: "&cBitte gib einen neuen Namen an."
|
no-name: "&cBitte gib einen neuen Namen an."
|
||||||
usage: "&eBenutze: /ir <NeuerName>"
|
usage: "&eBenutze: /ir <NeuerName>"
|
||||||
no-item: "&cDu hältst kein Item in der Hand."
|
no-item: "&cDu hältst kein Item in der Hand."
|
||||||
cant-rename: "&cDieses Item kann nicht umbenannt werden."
|
cant-rename: "&cDieses Item kann nicht umbenannt werden."
|
||||||
success: "&aDas Item wurde erfolgreich in {name} umbenannt!"
|
success: "&aDas Item wurde erfolgreich in {name} umbenannt!"
|
||||||
|
|
||||||
afk:
|
afk:
|
||||||
set: "&7Du bist jetzt AFK."
|
set: "&7Du bist jetzt AFK."
|
||||||
@@ -168,7 +215,6 @@ welcome:
|
|||||||
welcome.first-join-sound: ENTITY_FIREWORK_ROCKET_LAUNCH
|
welcome.first-join-sound: ENTITY_FIREWORK_ROCKET_LAUNCH
|
||||||
welcome.first-join-sound-volume: 1.0
|
welcome.first-join-sound-volume: 1.0
|
||||||
welcome.first-join-sound-pitch: 1.0
|
welcome.first-join-sound-pitch: 1.0
|
||||||
|
|
||||||
return-message: "&6Willkommen zurück, &e{player}&6!"
|
return-message: "&6Willkommen zurück, &e{player}&6!"
|
||||||
welcome.return-sound: ENTITY_FIREWORK_ROCKET_BLAST
|
welcome.return-sound: ENTITY_FIREWORK_ROCKET_BLAST
|
||||||
welcome.return-sound-volume: 1.0
|
welcome.return-sound-volume: 1.0
|
||||||
@@ -207,15 +253,14 @@ lock:
|
|||||||
unknown-subcommand: "§cUnbekannter Befehl."
|
unknown-subcommand: "§cUnbekannter Befehl."
|
||||||
|
|
||||||
friendadd:
|
friendadd:
|
||||||
usage: "§cBenutzung: /lock friendadd <Spieler>"
|
usage: "§cBenutzung: /lock friendadd <Spieler>"
|
||||||
not-found: "§cSpieler nicht gefunden oder nicht online!"
|
not-found: "§cSpieler nicht gefunden oder nicht online!"
|
||||||
success: "§a{player} wurde erfolgreich als Freund hinzugefügt!"
|
success: "§a{player} wurde erfolgreich als Freund hinzugefügt!"
|
||||||
|
|
||||||
friendremove:
|
friendremove:
|
||||||
usage: "§cBenutzung: /lock friendremove <Spieler>"
|
usage: "§cBenutzung: /lock friendremove <Spieler>"
|
||||||
not-found: "§cSpieler nicht gefunden oder nicht online!"
|
not-found: "§cSpieler nicht gefunden oder nicht online!"
|
||||||
success: "§a{player} wurde erfolgreich als Freund entfernt!"
|
success: "§a{player} wurde erfolgreich als Freund entfernt!"
|
||||||
|
|
||||||
|
|
||||||
teleport-usage: "§cVerwendung: /tp <Spieler>"
|
teleport-usage: "§cVerwendung: /tp <Spieler>"
|
||||||
teleport-success: "§aDu wurdest zu %player% teleportiert!"
|
teleport-success: "§aDu wurdest zu %player% teleportiert!"
|
||||||
@@ -239,3 +284,21 @@ no-tpa-request: "§cDu hast keine ausstehende Teleportanfrage."
|
|||||||
no-permission: "§cDu hast keine Berechtigung für diesen Befehl!"
|
no-permission: "§cDu hast keine Berechtigung für diesen Befehl!"
|
||||||
only-players: "§cDieser Befehl kann nur von Spielern ausgeführt werden!"
|
only-players: "§cDieser Befehl kann nur von Spielern ausgeführt werden!"
|
||||||
player-not-found: "§cSpieler %player% nicht gefunden!"
|
player-not-found: "§cSpieler %player% nicht gefunden!"
|
||||||
|
|
||||||
|
block:
|
||||||
|
usage: "Benutze: /block <Spieler>"
|
||||||
|
invalid_player: "Ungültiger Spieler."
|
||||||
|
blocked: "Du hast §e%player%§c blockiert."
|
||||||
|
already_blocked: "Du hast §e%player%§c schon blockiert."
|
||||||
|
unblocked: "Du hast §e%player%§a entblockt."
|
||||||
|
|
||||||
|
unblock:
|
||||||
|
usage: "Benutze: /unblock <Spieler>"
|
||||||
|
invalid_player: "Ungültiger Spieler."
|
||||||
|
not_blocked: "Du hast §e%player%§c nicht blockiert."
|
||||||
|
unblocked: "Du hast §e%player%§a entblockt."
|
||||||
|
unblocked_by: "Du wurdest von §e%player%§a entblockt."
|
||||||
|
|
||||||
|
blocklist:
|
||||||
|
no_blocked_players: "§7Du hast aktuell niemanden blockiert."
|
||||||
|
blocked_players: "§7Blockierte Spieler: §e%list%"
|
@@ -160,7 +160,20 @@ commands:
|
|||||||
description: Lehne eine Teleportanfrage ab
|
description: Lehne eine Teleportanfrage ab
|
||||||
usage: /tpdeny
|
usage: /tpdeny
|
||||||
|
|
||||||
|
block:
|
||||||
|
description: Blockiere einen Spieler
|
||||||
|
usage: /block <Spieler>
|
||||||
|
permission: survivalplus.block
|
||||||
|
|
||||||
|
unblock:
|
||||||
|
description: Entblocke einen Spieler
|
||||||
|
usage: /unblock <Spieler>
|
||||||
|
permission: survivalplus.unlock
|
||||||
|
|
||||||
|
blocklist:
|
||||||
|
description: Zeige eine Liste der blockierten Spieler
|
||||||
|
usage: /blocklist
|
||||||
|
permission: survivalplus.blocklist
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
survivalplus.*:
|
survivalplus.*:
|
||||||
@@ -341,3 +354,9 @@ permissions:
|
|||||||
description: Erlaube das Ablehnen von Teleportanfragen
|
description: Erlaube das Ablehnen von Teleportanfragen
|
||||||
default: true
|
default: true
|
||||||
|
|
||||||
|
survivalplus.block:
|
||||||
|
description: Erlaubt das Blockieren anderer Spieler im Chat
|
||||||
|
default: true
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user