bugfix for < 1.13 Server

Fixed a bug where you could not reload the plugin (/t2c-alias reload) when using a server below 1.13
This commit is contained in:
2022-12-21 10:35:35 +01:00
parent f00ac77743
commit 2d49a7a4b7
2 changed files with 12 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import net.t2code.alias.Spigot.Main;
import net.t2code.alias.Spigot.cmdManagement.RegisterCommands;
import net.t2code.alias.Util;
import net.t2code.t2codelib.SPIGOT.api.messages.T2Csend;
import net.t2code.t2codelib.SPIGOT.api.minecraftVersion.T2CmcVersion;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
@@ -21,15 +22,19 @@ public class AliasRegister {
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
bukkitCommandMap.setAccessible(true);
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
// onUnRegister(bukkitCommandMap);
// onUnRegister(bukkitCommandMap);
for (String alias : Main.allAliases) {
register(alias, commandMap);
// wrap(alias, commandMap);
}
Main.getPlugin().getBukkitCommandWrap().sync();
if (Bukkit.getOnlinePlayers().size() >= 1)
for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
if (!(T2CmcVersion.isMc1_8() || T2CmcVersion.isMc1_9() || T2CmcVersion.isMc1_10() || T2CmcVersion.isMc1_11() || T2CmcVersion.isMc1_12())) {
Main.getPlugin().getBukkitCommandWrap().sync();
if (Bukkit.getOnlinePlayers().size() >= 1)
for (Player player : Bukkit.getOnlinePlayers()) player.updateCommands();
}
} catch (Exception e) {
e.printStackTrace();
}