mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-01 05:57:09 +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();
|
cl = new CommandLoader();
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, cl::loadCommands, 1);
|
cl.loadCommands();
|
||||||
// Deferring command loading allowing TFD4J and Shop to load before registering our commands.
|
|
||||||
|
|
||||||
BackupManager backups = new BackupManager();
|
BackupManager backups = new BackupManager();
|
||||||
backups.createAllBackups();
|
backups.createAllBackups();
|
||||||
|
@ -31,6 +31,13 @@ public class Interceptor
|
|||||||
.getName()
|
.getName()
|
||||||
.equalsIgnoreCase(command))
|
.equalsIgnoreCase(command))
|
||||||
.forEach(entry -> overrides.put(entry.getKey(), entry.getValue())); // Intercept.
|
.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()
|
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()
|
private Map<String, Command> getPluginCommands()
|
||||||
{
|
{
|
||||||
final Map<String, Command> pluginCommands = new HashMap<>();
|
final Map<String, Command> pluginCommands = new HashMap<>();
|
||||||
|
Loading…
Reference in New Issue
Block a user