mirror of
https://github.com/songoda/UltimateModeration.git
synced 2024-11-22 18:26:10 +01:00
Added the ability to block commands.
This commit is contained in:
parent
ed55fadd9d
commit
89212cdaba
@ -63,6 +63,7 @@ public class UltimateModeration extends JavaPlugin {
|
||||
this.commandManager = new CommandManager(this);
|
||||
|
||||
// Register Listeners
|
||||
Bukkit.getPluginManager().registerEvents(new CommandListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new DeathListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new MoveListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new DropListener(this), this);
|
||||
|
@ -42,7 +42,6 @@ public class CommandToggleChat extends AbstractCommand {
|
||||
continue;
|
||||
|
||||
player.sendMessage(Methods.formatText(locale.getMessage("command.togglechat.bypass")));
|
||||
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.SettingsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public CommandListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
List<String> blockedCommands = SettingsManager.Setting.BLOCKED_COMMANDS.getStringList();
|
||||
|
||||
for (String cmd : blockedCommands) {
|
||||
if (event.getMessage().toUpperCase().startsWith("/" + cmd.toUpperCase())
|
||||
&& !player.hasPermission("um.commandblock.bypass")) {
|
||||
event.setCancelled(true);
|
||||
event.setMessage("-");
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.blocked"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -173,6 +173,8 @@ public class SettingsManager implements Listener {
|
||||
VANISH_BATS("Main.Release Bats On Vanish", true),
|
||||
VANISH_PARTICLE("Main.Vanish Particle", "EXPLOSION_NORMAL"),
|
||||
|
||||
BLOCKED_COMMANDS("Main.Blocked Commands", Arrays.asList("Fly", "Op", "Plugins", "Pl")),
|
||||
|
||||
GLASS_TYPE_1("Interfaces.Glass Type 1", 7),
|
||||
GLASS_TYPE_2("Interfaces.Glass Type 2", 11),
|
||||
GLASS_TYPE_3("Interfaces.Glass Type 3", 3),
|
||||
|
@ -24,4 +24,6 @@ command.revive.success = "&7You have revived &6%player% &7successfully."
|
||||
command.revive.revived = "&7You have been revived."
|
||||
|
||||
command.spy.returned = "&7You were returned to your previous location"
|
||||
command.spy.success = "&7You are now spying on &6%player%&7. Use the command &6/spy &7to return to your previous location&7"
|
||||
command.spy.success = "&7You are now spying on &6%player%&7. Use the command &6/spy &7to return to your previous location&7"
|
||||
|
||||
command.blocked = "&cYou cannot use that command..."
|
Loading…
Reference in New Issue
Block a user