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:
JaTiTV 2022-12-21 10:35:35 +01:00
parent f00ac77743
commit 2d49a7a4b7
2 changed files with 12 additions and 7 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId> <groupId>net.t2code</groupId>
<artifactId>Alias</artifactId> <artifactId>Alias</artifactId>
<version>1.1.6</version> <version>1.1.7-DEV</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>T2C-Alias</name> <name>T2C-Alias</name>
@ -82,9 +82,9 @@
<version>3.0</version> <version>3.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.t2code.minecraft.1_19.r1</groupId> <groupId>net.t2code.minecraft.1_13.r1</groupId>
<artifactId>spigot</artifactId> <artifactId>spigot</artifactId>
<version>1.19r1</version> <version>1.13r1</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

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