Skip to content

Commit

Permalink
fix server tag error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 4, 2020
1 parent 6cc1d76 commit 601c78d
Showing 1 changed file with 11 additions and 19 deletions.
Expand Up @@ -95,9 +95,7 @@ public void serverTag(ReplaceableTagEvent event) {

if (attribute.startsWith("economy")) {
if (Depends.economy == null) {
if (!attribute.hasAlternative()) {
Debug.echoError("No economy loaded! Have you installed Vault and a compatible economy plugin?");
}
attribute.echoError("No economy loaded! Have you installed Vault and a compatible economy plugin?");
return;
}
attribute = attribute.fulfill(1);
Expand Down Expand Up @@ -1085,7 +1083,7 @@ else if (recipe instanceof CookingRecipe<?>) {
List<WorldScriptContainer> EventsOne = OldEventManager.events.get("ON " + eventName);
List<WorldScriptContainer> EventsTwo = OldEventManager.events.get("ON " + OldEventManager.StripIdentifiers(eventName));
if (EventsOne == null && EventsTwo == null) {
Debug.echoError("No world scripts will handle the event '" + eventName + "'");
attribute.echoError("No world scripts will handle the event '" + eventName + "'");
}
else {
ListTag list = new ListTag();
Expand Down Expand Up @@ -1150,9 +1148,7 @@ else if (recipe instanceof CookingRecipe<?>) {
File f = new File(DenizenAPI.getCurrentInstance().getDataFolder(), attribute.getContext(1));
try {
if (!Utilities.canReadFile(f)) {
if (!attribute.hasAlternative()) {
Debug.echoError("Invalid path specified. Invalid paths have been denied by the server administrator.");
}
attribute.echoError("Invalid path specified. Invalid paths have been denied by the server administrator.");
return;
}
}
Expand All @@ -1174,15 +1170,11 @@ else if (recipe instanceof CookingRecipe<?>) {
File folder = new File(DenizenAPI.getCurrentInstance().getDataFolder(), attribute.getContext(1));
try {
if (!Utilities.canReadFile(folder)) {
if (!attribute.hasAlternative()) {
Debug.echoError("Invalid path specified. Invalid paths have been denied by the server administrator.");
}
attribute.echoError("Invalid path specified. Invalid paths have been denied by the server administrator.");
return;
}
if (!folder.exists() || !folder.isDirectory()) {
if (!attribute.hasAlternative()) {
Debug.echoError("Invalid path specified. No directory exists at that path.");
}
attribute.echoError("Invalid path specified. No directory exists at that path.");
return;
}
}
Expand Down Expand Up @@ -1322,14 +1314,14 @@ else if (recipe instanceof CookingRecipe<?>) {
if (attribute.startsWith("group_prefix")) {

if (Depends.permissions == null) {
Debug.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
attribute.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
return;
}

String group = attribute.getContext(1);

if (!Arrays.asList(Depends.permissions.getGroups()).contains(group)) {
Debug.echoError("Invalid group! '" + (group != null ? group : "") + "' could not be found.");
attribute.echoError("Invalid group! '" + (group != null ? group : "") + "' could not be found.");
return;
}

Expand Down Expand Up @@ -1363,14 +1355,14 @@ else if (recipe instanceof CookingRecipe<?>) {
if (attribute.startsWith("group_suffix")) {

if (Depends.permissions == null) {
Debug.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
attribute.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
return;
}

String group = attribute.getContext(1);

if (!Arrays.asList(Depends.permissions.getGroups()).contains(group)) {
Debug.echoError("Invalid group! '" + (group != null ? group : "") + "' could not be found.");
attribute.echoError("Invalid group! '" + (group != null ? group : "") + "' could not be found.");
return;
}

Expand Down Expand Up @@ -1403,7 +1395,7 @@ else if (recipe instanceof CookingRecipe<?>) {
// -->
if (attribute.startsWith("list_permission_groups")) {
if (Depends.permissions == null) {
Debug.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
attribute.echoError("No permission system loaded! Have you installed Vault and a compatible permissions plugin?");
return;
}
event.setReplaced(new ListTag(Arrays.asList(Depends.permissions.getGroups())).getAttribute(attribute.fulfill(1)));
Expand Down Expand Up @@ -1501,7 +1493,7 @@ else if (CoreUtilities.toLowerCase(entry.getKey()).contains(matchInput) && match
&& attribute.hasContext(1)) {
ScriptTag script = ScriptTag.valueOf(attribute.getContext(1));
if (script == null || !(script.getContainer() instanceof AssignmentScriptContainer)) {
Debug.echoError("Invalid script specified.");
attribute.echoError("Invalid script specified.");
}
else {
ListTag npcs = new ListTag();
Expand Down

0 comments on commit 601c78d

Please sign in to comment.