mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-12-28 20:47:37 +00:00
Attempt to intercept native commands
This commit is contained in:
parent
33ac3a36ca
commit
6c0856d647
@ -161,8 +161,7 @@ public class TotalFreedomMod extends JavaPlugin
|
||||
}
|
||||
|
||||
cl = new CommandLoader();
|
||||
Bukkit.getScheduler().runTaskLater(plugin, cl::loadCommands, 1);
|
||||
// Deferring command loading allowing TFD4J and Shop to load before registering our commands.
|
||||
cl.loadCommands();
|
||||
|
||||
BackupManager backups = new BackupManager();
|
||||
backups.createAllBackups();
|
||||
|
@ -31,6 +31,13 @@ public class Interceptor
|
||||
.getName()
|
||||
.equalsIgnoreCase(command))
|
||||
.forEach(entry -> overrides.put(entry.getKey(), entry.getValue())); // Intercept.
|
||||
|
||||
getFallbackCommands().entrySet()
|
||||
.stream()
|
||||
.filter(entry -> entry.getValue() // Check that the command is the one we want to intercept
|
||||
.getName()
|
||||
.equalsIgnoreCase(command))
|
||||
.forEach(entry -> overrides.put(entry.getKey(), entry.getValue())); // Intercept.
|
||||
}
|
||||
|
||||
public void setOverrides()
|
||||
@ -42,6 +49,16 @@ public class Interceptor
|
||||
});
|
||||
}
|
||||
|
||||
private Map<String, Command> getFallbackCommands() {
|
||||
final Map<String, Command> fallbackCommands = new HashMap<>();
|
||||
for (final Map.Entry<String, Command> entry : Bukkit.getCommandMap().getKnownCommands().entrySet()) {
|
||||
if (!(entry.getValue() instanceof PluginIdentifiableCommand)) {
|
||||
fallbackCommands.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
return fallbackCommands;
|
||||
}
|
||||
|
||||
private Map<String, Command> getPluginCommands()
|
||||
{
|
||||
final Map<String, Command> pluginCommands = new HashMap<>();
|
||||
|
Loading…
Reference in New Issue
Block a user