Closes #58 - Disable OP commands on Sponge

This commit is contained in:
Luck 2016-12-07 21:27:50 +00:00
parent 251f51b01c
commit 4ecb2c7c27
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 15 additions and 0 deletions

View File

@ -41,6 +41,7 @@ public enum Message {
PLAYER_OFFLINE("&cOffline", false),
LOADING_ERROR("Permissions data could not be loaded. Please contact an administrator.", true),
OP_DISABLED("&bThe vanilla OP system is disabled on this server.", false),
OP_DISABLED_SPONGE("&2Server Operator status has no effect when a permission plugin is installed. Please edit user data directly.", true),
LOG("&3LOG &3&l> {0}", true),
COMMAND_NOT_RECOGNISED("Command not recognised.", true),

View File

@ -8,6 +8,7 @@ player-online: "&aOnline"
player-offline: "&cOffline"
loading-error: "Permissions data could not be loaded. Please contact an administrator."
op-disabled: "&bThe vanilla OP system is disabled on this server."
op-disabled-sponge: "&2Server Operator status has no effect when a permission plugin is installed. Please edit user data directly."
log: "&3LOG &3&l> {0}"
command-not-recognised: "Command not recognised."

View File

@ -29,9 +29,11 @@ import me.lucko.luckperms.common.core.model.User;
import me.lucko.luckperms.common.utils.AbstractListener;
import me.lucko.luckperms.sponge.timings.LPTiming;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.Order;
import org.spongepowered.api.event.command.SendCommandEvent;
import org.spongepowered.api.event.network.ClientConnectionEvent;
import org.spongepowered.api.profile.GameProfile;
import org.spongepowered.api.text.serializer.TextSerializers;
@ -114,4 +116,15 @@ public class SpongeListener extends AbstractListener {
onLeave(e.getTargetEntity().getUniqueId());
}
}
@Listener
public void onSendCommand(SendCommandEvent e) {
CommandSource source = e.getCause().first(CommandSource.class).orElse(null);
if (source == null) return;
final String name = e.getCommand().toLowerCase();
if (name.equals("op") || name.equals("deop")) {
Message.OP_DISABLED_SPONGE.send(plugin.getSenderFactory().wrap(source));
}
}
}