Skip to content

Commit

Permalink
Merge pull request #14 from TWME-TW/dev
Browse files Browse the repository at this point in the history
0.4.7 Fixed an error caused when reloading the server
  • Loading branch information
TWME-TW authored Jun 11, 2024
2 parents b2ce08a + fd891ac commit bf93c7e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.twme</groupId>
<artifactId>DebugStickPro</artifactId>
<version>0.4.6</version>
<version>0.4.7</version>
<packaging>jar</packaging>

<name>DebugStickPro</name>
Expand Down
34 changes: 33 additions & 1 deletion src/main/java/dev/twme/debugstickpro/DebugStickPro.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@
import dev.twme.debugstickpro.hook.CoreProtectUtil;
import dev.twme.debugstickpro.listeners.*;
import dev.twme.debugstickpro.localization.LangFileManager;
import dev.twme.debugstickpro.localization.PlayerLanguageManager;
import dev.twme.debugstickpro.mode.freeze.FreezeBlockManager;
import dev.twme.debugstickpro.playerdata.PlayerData;
import dev.twme.debugstickpro.playerdata.PlayerDataManager;
import dev.twme.debugstickpro.utils.DebugStickItem;
import dev.twme.debugstickpro.utils.Log;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;

import java.util.UUID;

public final class DebugStickPro extends JavaPlugin {
/**
* This is the instance of the plugin
Expand Down Expand Up @@ -52,11 +60,14 @@ public void onEnable() {
Log.warning("CoreProtect is not loaded or is not compatible with this version of the plugin.");
}


ConfigLoader.getInstance().load();

LangFileManager.initialization();

if (!Bukkit.getOnlinePlayers().isEmpty()) {
Log.warning("The server is reloaded. The plugin may not work normally");
onServerReloadCommand();
}

registerCommands();
registerListeners();
Expand Down Expand Up @@ -86,6 +97,27 @@ public void onDisable() {
FreezeBlockManager.removeOnServerClose();
}

/*
* When a stupid admin executes the /reload command
*/
public void onServerReloadCommand() {
for (Player player : Bukkit.getOnlinePlayers()) {
PlayerLanguageManager.setPlayerLocale(player.getUniqueId(), player.locale().toString());

UUID playerUUID = player.getUniqueId();
PlayerDataManager.setPlayerData(playerUUID, new PlayerData());

if (!player.hasPermission("debugstickpro.use")) {
return;
}
ItemStack item = player.getInventory().getItemInMainHand();

if (DebugStickItem.isDebugStickItem(item)) {
PlayerDataManager.addPlayerToDisplayList(playerUUID);
}
}
}

/**
* This method registers the commands
*/
Expand Down

0 comments on commit bf93c7e

Please sign in to comment.