Skip to content

Commit

Permalink
feat: add messages and checks for commnad portal permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
sekwah41 committed Nov 18, 2024
1 parent 22cda5d commit 4fcb9e5
Showing 1 changed file with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,43 @@ public String splitString() {
@Override
public boolean preActivated(TagTarget target, PlayerContainer player,
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;
}

Expand Down Expand Up @@ -98,41 +135,48 @@ public boolean created(TagTarget target, PlayerContainer player,
if (argData != null) {
var commandPortals = configRepository.getCommandPortals();
if(!commandPortals.enabled) {
player.sendMessage(Lang.translate("tag.command.disabled"));
player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.disabled"));
return false;
}
for (String command : argData) {
char executionCommand = command.charAt(0);
return switch (executionCommand) {
case '!' -> {
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;
}
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 true;
}
case '#' -> {
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;
}
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 true;
}
case '^' -> {
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;
}
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 true;
Expand Down

0 comments on commit 4fcb9e5

Please sign in to comment.