Update from Git Manager GUI
This commit is contained in:
@@ -19,7 +19,12 @@ import de.nexuslobby.utils.DoubleJump;
|
||||
import de.nexuslobby.utils.PlayerHider;
|
||||
import de.nexuslobby.utils.MaintenanceListener;
|
||||
import de.nexuslobby.utils.ConfigUpdater;
|
||||
import de.nexuslobby.utils.UpdateChecker;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@@ -27,6 +32,7 @@ import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -45,6 +51,9 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
private File visualsFile;
|
||||
private FileConfiguration visualsConfig;
|
||||
|
||||
private boolean updateAvailable = false;
|
||||
private String latestVersion = "";
|
||||
|
||||
public static NexusLobby getInstance() {
|
||||
return instance;
|
||||
}
|
||||
@@ -56,10 +65,8 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
initCustomConfigs();
|
||||
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
|
||||
moduleManager = new ModuleManager(this);
|
||||
|
||||
// Initialisierung der GUI-Werkzeuge
|
||||
ArmorStandGUI.init();
|
||||
|
||||
registerModules();
|
||||
@@ -72,31 +79,48 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
registerCommands();
|
||||
checkUpdates();
|
||||
|
||||
getLogger().info("NexusLobby wurde erfolgreich gestartet.");
|
||||
}
|
||||
|
||||
private void checkUpdates() {
|
||||
new UpdateChecker(this).getVersion(version -> {
|
||||
if (!this.getDescription().getVersion().equalsIgnoreCase(version)) {
|
||||
this.updateAvailable = true;
|
||||
this.latestVersion = version;
|
||||
getLogger().warning("====================================================");
|
||||
getLogger().warning("Update gefunden! v" + getDescription().getVersion() + " -> v" + version);
|
||||
getLogger().warning("Autor: M_Viper");
|
||||
getLogger().warning("====================================================");
|
||||
} else {
|
||||
getLogger().info("NexusLobby ist aktuell (v" + version + ").");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reloadPlugin() {
|
||||
getLogger().info("Plugin Reload wird gestartet...");
|
||||
|
||||
|
||||
if (moduleManager != null) {
|
||||
moduleManager.disableAll();
|
||||
}
|
||||
|
||||
reloadConfig();
|
||||
initCustomConfigs();
|
||||
visualsConfig = null;
|
||||
reloadVisualsConfig();
|
||||
Config.load();
|
||||
|
||||
if (portalManager != null) {
|
||||
portalManager.loadPortals();
|
||||
}
|
||||
ArmorStandGUI.init();
|
||||
|
||||
if (moduleManager != null) {
|
||||
moduleManager.enableAll();
|
||||
}
|
||||
|
||||
ArmorStandGUI.init();
|
||||
Config.load();
|
||||
|
||||
getLogger().info("Plugin Reload abgeschlossen.");
|
||||
getLogger().info("Plugin Reload abgeschlossen. Änderungen wurden übernommen.");
|
||||
}
|
||||
|
||||
private void registerModules() {
|
||||
@@ -127,24 +151,49 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
getServer().getPluginManager().registerEvents(new ASTListener(), this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
// Priorität auf LOWEST, damit das Inventar VOR den Modulen geleert wird
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
event.setJoinMessage(null);
|
||||
|
||||
// FEHLERBEHEBUNG: Inventar leeren, um doppelte Items zu vermeiden
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null); // Auch Rüstung entfernen
|
||||
|
||||
BuildCommand.removePlayerFromBuildMode(player);
|
||||
|
||||
String defaultGmName = getConfig().getString("default-gamemode", "ADVENTURE");
|
||||
try {
|
||||
GameMode gm = GameMode.valueOf(defaultGmName.toUpperCase());
|
||||
player.setGameMode(gm);
|
||||
player.setGameMode(GameMode.valueOf(defaultGmName.toUpperCase()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
|
||||
if (player.hasPermission("nexuslobby.admin") && updateAvailable) {
|
||||
player.sendMessage(" ");
|
||||
player.sendMessage("§8[§6Nexus§8] §aEin neues §6Update §afür §eNexusLobby §aist verfügbar!");
|
||||
player.sendMessage("§8» §7Version: §c" + getDescription().getVersion() + " §8-> §a" + latestVersion);
|
||||
|
||||
TextComponent link = new TextComponent("§8» §6Klicke §e§l[HIER] §6zum Herunterladen.");
|
||||
link.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://git.viper.ipv64.net/M_Viper/NexusLobby/releases"));
|
||||
link.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("§7Öffnet die Gitea Release-Seite").create()));
|
||||
|
||||
player.spigot().sendMessage(link);
|
||||
player.sendMessage(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private void initCustomConfigs() {
|
||||
saveDefaultConfig();
|
||||
if (!getDataFolder().exists()) {
|
||||
getDataFolder().mkdirs();
|
||||
}
|
||||
|
||||
File configFile = new File(getDataFolder(), "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
saveResource("config.yml", false);
|
||||
}
|
||||
ConfigUpdater.updateConfig("config.yml");
|
||||
reloadConfig();
|
||||
|
||||
@@ -152,13 +201,11 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
if (!settingsFile.exists()) {
|
||||
saveResource("settings.yml", false);
|
||||
}
|
||||
ConfigUpdater.updateConfig("settings.yml");
|
||||
|
||||
visualsFile = new File(getDataFolder(), "visuals.yml");
|
||||
if (!visualsFile.exists()) {
|
||||
saveResource("visuals.yml", false);
|
||||
}
|
||||
ConfigUpdater.updateConfig("visuals.yml");
|
||||
|
||||
reloadVisualsConfig();
|
||||
Config.load();
|
||||
@@ -169,6 +216,7 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
visualsFile = new File(getDataFolder(), "visuals.yml");
|
||||
}
|
||||
visualsConfig = YamlConfiguration.loadConfiguration(visualsFile);
|
||||
getLogger().info("visuals.yml erfolgreich vom Speicher geladen.");
|
||||
}
|
||||
|
||||
public FileConfiguration getVisualsConfig() {
|
||||
@@ -181,9 +229,7 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getServer().getMessenger().unregisterOutgoingPluginChannel(this, "BungeeCord");
|
||||
if (moduleManager != null) {
|
||||
moduleManager.disableAll();
|
||||
}
|
||||
if (moduleManager != null) moduleManager.disableAll();
|
||||
getLogger().info("NexusLobby disabled");
|
||||
}
|
||||
|
||||
@@ -206,13 +252,11 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
if (getCommand("settings") != null) getCommand("settings").setExecutor(new LobbySettingsCommand(lobbySettingsModule));
|
||||
if (getCommand("build") != null) getCommand("build").setExecutor(new BuildCommand());
|
||||
|
||||
// --- NEXUS TOOLS & CMD REGISTRIERUNG ---
|
||||
if (getCommand("nexustools") != null) {
|
||||
getCommand("nexustools").setExecutor(new ArmorStandCommand());
|
||||
getCommand("nexustools").setTabCompleter(tabCompleter);
|
||||
}
|
||||
|
||||
// Wir registrieren nexuscmd (ehemals ascmd)
|
||||
if (getCommand("nexuscmd") != null) {
|
||||
getCommand("nexuscmd").setExecutor(new ArmorStandCmdExecutor());
|
||||
getCommand("nexuscmd").setTabCompleter(tabCompleter);
|
||||
@@ -226,27 +270,17 @@ public class NexusLobby extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
public class NexusLobbyExpansion extends PlaceholderExpansion {
|
||||
@Override
|
||||
public @NotNull String getIdentifier() { return "nexuslobby"; }
|
||||
@Override
|
||||
public @NotNull String getAuthor() { return String.join(", ", NexusLobby.this.getDescription().getAuthors()); }
|
||||
@Override
|
||||
public @NotNull String getVersion() { return NexusLobby.this.getDescription().getVersion(); }
|
||||
@Override
|
||||
public boolean persist() { return true; }
|
||||
@Override public @NotNull String getIdentifier() { return "nexuslobby"; }
|
||||
@Override public @NotNull String getAuthor() { return String.join(", ", NexusLobby.this.getDescription().getAuthors()); }
|
||||
@Override public @NotNull String getVersion() { return NexusLobby.this.getDescription().getVersion(); }
|
||||
@Override public boolean persist() { return true; }
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, @NotNull String params) {
|
||||
if (player == null) return "";
|
||||
if (params.equalsIgnoreCase("maintenance_status")) {
|
||||
return MaintenanceListener.isMaintenance() ? "§cAktiv" : "§aDeaktiviert";
|
||||
}
|
||||
if (params.equalsIgnoreCase("version")) {
|
||||
return NexusLobby.this.getDescription().getVersion();
|
||||
}
|
||||
if (params.equalsIgnoreCase("build_mode")) {
|
||||
return BuildCommand.isInBuildMode(player) ? "§aAktiv" : "§cInaktiv";
|
||||
}
|
||||
if (params.equalsIgnoreCase("maintenance_status")) return MaintenanceListener.isMaintenance() ? "§cAktiv" : "§aDeaktiviert";
|
||||
if (params.equalsIgnoreCase("version")) return NexusLobby.this.getDescription().getVersion();
|
||||
if (params.equalsIgnoreCase("build_mode")) return BuildCommand.isInBuildMode(player) ? "§aAktiv" : "§cInaktiv";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user