mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-01 05:18:00 +01:00
Use Bukkits console sender
This commit is contained in:
parent
86c640f0cc
commit
930a115175
2
pom.xml
2
pom.xml
@ -13,7 +13,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.1-R5-SNAPSHOT</version>
|
||||
<version>1.1-R6-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
@ -1,49 +0,0 @@
|
||||
package cc.co.evenprime.bukkit.nocheat.actions;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.permissions.PermissibleBase;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
/**
|
||||
* This class is used to execute commands of other plugins.
|
||||
* It ignores any feedback of other plugins and claims to be
|
||||
* OP when asked.
|
||||
*
|
||||
*/
|
||||
public class NoCheatCommandSender extends PermissibleBase implements ConsoleCommandSender {
|
||||
|
||||
private static final ServerOperator serverOperator = new ServerOperator() {
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
//
|
||||
}
|
||||
};
|
||||
|
||||
public NoCheatCommandSender() {
|
||||
super(serverOperator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "NoCheatCommandSender";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
// We don't want messages
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer() {
|
||||
return Bukkit.getServer();
|
||||
}
|
||||
|
||||
}
|
@ -4,12 +4,10 @@ import java.util.Locale;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheat;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatLogEvent;
|
||||
import cc.co.evenprime.bukkit.nocheat.NoCheatPlayer;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.Action;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.NoCheatCommandSender;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.ParameterName;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ActionList;
|
||||
import cc.co.evenprime.bukkit.nocheat.actions.types.ConsolecommandAction;
|
||||
@ -21,11 +19,10 @@ import cc.co.evenprime.bukkit.nocheat.data.Statistics.Id;
|
||||
|
||||
public abstract class Check {
|
||||
|
||||
private final String name;
|
||||
private final String name;
|
||||
// used to bundle information of multiple checks
|
||||
private final String groupId;
|
||||
private static final CommandSender noCheatCommandSender = new NoCheatCommandSender();
|
||||
protected final NoCheat plugin;
|
||||
private final String groupId;
|
||||
protected final NoCheat plugin;
|
||||
|
||||
public Check(NoCheat plugin, String groupId, String name) {
|
||||
this.plugin = plugin;
|
||||
@ -89,7 +86,7 @@ public abstract class Check {
|
||||
final String command = action.getCommand(player, check);
|
||||
|
||||
try {
|
||||
plugin.getServer().dispatchCommand(noCheatCommandSender, command);
|
||||
plugin.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
} catch(CommandException e) {
|
||||
System.out.println("[NoCheat] failed to execute the command '" + command + "': " + e.getMessage() + ", please check if everything is setup correct.");
|
||||
} catch(Exception e) {
|
||||
|
Loading…
Reference in New Issue
Block a user