feat: add messages and checks for commnad portal permissions

This commit is contained in:
Sekwah 2024-09-05 10:31:50 +01:00
parent 22cda5d2cc
commit 4fcb9e549a

View File

@ -47,6 +47,43 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
@Override @Override
public boolean preActivated(TagTarget target, PlayerContainer player, public boolean preActivated(TagTarget target, PlayerContainer player,
ActivationData activeData, String[] argData) { ActivationData activeData, String[] argData) {
var commandPortals = configRepository.getCommandPortals();
if(!commandPortals.enabled) {
player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.disabled"));
return false;
}
for (String command : argData) {
char executionCommand = command.charAt(0);
switch (executionCommand) {
case '!':
if (!commandPortals.op) {
player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.op.disabled"));
return false;
}
break;
case '#':
if (!commandPortals.console) {
player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.console.disabled"));
return false;
}
break;
case '^':
if (!commandPortals.permsWildcard) {
player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.permswildcard.disabled"));
return false;
}
break;
default:
break;
}
}
return true; return true;
} }
@ -98,7 +135,8 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
if (argData != null) { if (argData != null) {
var commandPortals = configRepository.getCommandPortals(); var commandPortals = configRepository.getCommandPortals();
if(!commandPortals.enabled) { if(!commandPortals.enabled) {
player.sendMessage(Lang.translate("tag.command.disabled")); player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.disabled"));
return false; return false;
} }
for (String command : argData) { for (String command : argData) {
@ -106,33 +144,39 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
return switch (executionCommand) { return switch (executionCommand) {
case '!' -> { case '!' -> {
if (!commandPortals.op) { if (!commandPortals.op) {
player.sendMessage(Lang.translate("tag.command.op.disabled")); player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.op.disabled"));
yield false; yield false;
} }
if (!player.hasPermission("advancedportals.createportal.commandlevel.op")) { if (!player.hasPermission("advancedportals.createportal.commandlevel.op")) {
player.sendMessage(Lang.translateInsertVariables("tag.command.nopermission", "OP")); player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translateInsertVariables("tag.command.nopermission", "OP"));
yield false; yield false;
} }
yield true; yield true;
} }
case '#' -> { case '#' -> {
if (!commandPortals.console) { if (!commandPortals.console) {
player.sendMessage(Lang.translate("tag.command.console.disabled")); player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.console.disabled"));
yield false; yield false;
} }
if (!player.hasPermission("advancedportals.createportal.commandlevel.console")) { if (!player.hasPermission("advancedportals.createportal.commandlevel.console")) {
player.sendMessage(Lang.translateInsertVariables("tag.command.nopermission","Console")); player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translateInsertVariables("tag.command.nopermission","Console"));
yield false; yield false;
} }
yield true; yield true;
} }
case '^' -> { case '^' -> {
if (!commandPortals.permsWildcard) { if (!commandPortals.permsWildcard) {
player.sendMessage(Lang.translate("tag.command.permswildcard.disabled")); player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.permswildcard.disabled"));
yield false; yield false;
} }
if (!player.hasPermission("advancedportals.createportal.commandlevel.permswild")) { if (!player.hasPermission("advancedportals.createportal.commandlevel.permswild")) {
player.sendMessage(Lang.translateInsertVariables("tag.command.nopermission", "*")); player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translateInsertVariables("tag.command.nopermission", "*"));
yield false; yield false;
} }
yield true; yield true;