Skip to content

Commit

Permalink
improve gpclaimenterevent
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 21, 2019
1 parent b7f8103 commit b81a972
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import net.aufdemrand.denizen.BukkitScriptEntryData;
import net.aufdemrand.denizen.events.BukkitScriptEvent;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizen.objects.dLocation;
import net.aufdemrand.denizen.objects.dPlayer;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.ScriptEntryData;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
Expand Down Expand Up @@ -62,14 +62,17 @@ public boolean couldMatch(ScriptContainer scriptContainer, String s) {
}

@Override
public boolean matches(ScriptContainer scriptContainer, String s) {
String lower = CoreUtilities.toLowerCase(s);
String claim_test = lower.substring(lower.lastIndexOf(' ') + 1);
String direction = lower.substring("gp player ".length(), lower.lastIndexOf(' ')).trim();
public boolean matches(ScriptPath path) {
String direction = path.eventArgAt(2);
String claim_test = path.eventArgLowerAt(3);

return (claim_test.equals("gpclaim") && ((direction.equals("enters") && new_claim != null) || (direction.equals("exits") && old_claim != null)))
|| (direction.equals("enters") && new_claim != null && claim_test.equals(CoreUtilities.toLowerCase(new_claim.simple())))
|| (direction.equals("exits") && old_claim != null && claim_test.equals(CoreUtilities.toLowerCase(old_claim.simple())));
if (direction.equals("enters") && new_claim != null) {
return claim_test.equals("gpclaim") || claim_test.equals(CoreUtilities.toLowerCase(new_claim.simple()));
}
else if (direction.equals("exits") && old_claim != null) {
return claim_test.equals("gpclaim") || claim_test.equals(CoreUtilities.toLowerCase(old_claim.simple()));
}
return false;
}

@Override
Expand All @@ -85,7 +88,7 @@ public boolean applyDetermination(ScriptContainer container, String determinatio
@Override
public ScriptEntryData getScriptEntryData() {
// TODO: Store the player?
return new BukkitScriptEntryData(event != null ? dEntity.getPlayerFrom(event.getPlayer()) : null, null);
return new BukkitScriptEntryData(event != null ? new dPlayer(event.getPlayer()) : null, null);
}

@Override
Expand Down

0 comments on commit b81a972

Please sign in to comment.