Skip to content

Commit

Permalink
improve cancelled determination issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 18, 2019
1 parent f7f157a commit 7781684
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 23 deletions.
Expand Up @@ -170,12 +170,9 @@ else if (aH.Argument.valueOf(lower).matchesArgumentList(dItem.class)) {
}
}
}
else if (determination.equalsIgnoreCase("cancelled")) {
cancelled = true;
}

// String containing new Death Message
else if (event instanceof PlayerDeathEvent) {
else if (event instanceof PlayerDeathEvent && !isDefaultDetermination(determination)) {
message = new Element(determination);
}
else {
Expand Down
Expand Up @@ -90,7 +90,7 @@ public void destroy() {

@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
if (!CoreUtilities.toLowerCase(determination).equals("cancelled")) {
if (!isDefaultDetermination(determination)) {
try {
color = DyeColor.valueOf(determination.toUpperCase());
return true;
Expand Down
Expand Up @@ -138,7 +138,7 @@ else if (lower.startsWith("recipients:")) {
recipients.add(player.getPlayerEntity());
}
}
else if (!lower.startsWith("cancelled")) {
else if (!isDefaultDetermination(determination)) {
message = new Element(determination);
}
else {
Expand Down
Expand Up @@ -100,7 +100,7 @@ public void destroy() {

@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
if (determination.length() > 0 && !determination.equalsIgnoreCase("cancelled")) {
if (determination.length() > 0 && !isDefaultDetermination(determination)) {
new_text = dList.valueOf(determination);
return true;
}
Expand Down
Expand Up @@ -83,10 +83,6 @@ public boolean applyDetermination(ScriptContainer container, String determinatio
amount = aH.getIntegerFrom(determination);
return true;
}
if (lower.equals("cancelled")) {
amount = 0;
return true;
}
return super.applyDetermination(container, determination);
}

Expand All @@ -111,7 +107,11 @@ public void onPlayerChangesXP(PlayerExpChangeEvent event) {
amount = event.getAmount();
player = dPlayer.mirrorBukkitPlayer(event.getPlayer());
this.event = event;
cancelled = false;
fire();
if (cancelled) {
amount = 0;
}
event.setAmount(amount);
}
}
Expand Up @@ -105,9 +105,6 @@ public void destroy() {

@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
if (CoreUtilities.toLowerCase(determination).equals("cancelled")) {
manual_cancelled = true;
}
return super.applyDetermination(container, determination);
}

Expand Down Expand Up @@ -151,10 +148,10 @@ public void onPlayerDragsInInv(InventoryDragEvent event) {
raw_slots.add(String.valueOf(raw_slot + 1));
}
cancelled = event.isCancelled();
manual_cancelled = false;
boolean wasCancelled = cancelled;
this.event = event;
fire();
if (cancelled && manual_cancelled) {
if (cancelled && !wasCancelled) {
final InventoryHolder holder = inventory.getHolder();
new BukkitRunnable() {
@Override
Expand Down
Expand Up @@ -71,7 +71,7 @@ public void destroy() {
@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
String lower = CoreUtilities.toLowerCase(determination);
if (determination.length() > 0 && !lower.startsWith("cancelled")) {
if (determination.length() > 0 && !isDefaultDetermination(determination)) {
commands.clear();
commands.addAll(dList.valueOf(determination));
return true;
Expand Down
Expand Up @@ -23,14 +23,14 @@ public class PlayerStandsOnScriptEvent extends BukkitScriptEvent implements List
//
// @Regex ^on player stands on [^\s]+( in ((notable (cuboid|ellipsoid))|([^\s]+)))?$
//
// @Cancellable true
//
// @Triggers when a player stands on a pressure plate, tripwire, or redstone ore.
// @Context
// <context.location> returns the dLocation the player is interacting with.
// <context.material> returns the dMaterial the player is interacting with.
//
// @Determine
// "CANCELLED" to stop the interaction from happening.
// "CANCELLED:FALSE" to uncancel the event. Some plugins may have this cancelled by default.
//
// -->

Expand Down
Expand Up @@ -91,10 +91,6 @@ public boolean applyDetermination(ScriptContainer container, String determinatio
type = dEntity.valueOf(determination).getBukkitEntityType();
return true;
}
if (lower.equals("cancelled")) {
is_hatching = false;
return true;
}
return super.applyDetermination(container, determination);
}

Expand Down Expand Up @@ -126,7 +122,11 @@ public void onPlayerThrowsEgg(PlayerEggThrowEvent event) {
egg = new dEntity(event.getEgg());
type = event.getHatchingType();
this.event = event;
cancelled = false;
fire();
if (cancelled) {
is_hatching = false;
}
dEntity.forgetEntity(eggEntity);
event.setHatching(is_hatching);
event.setHatchingType(type);
Expand Down

0 comments on commit 7781684

Please sign in to comment.