mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-28 13:36:33 +01:00
Shift trigger logic to new sign categories
This commit is contained in:
parent
82cb68c3b5
commit
56ef3dd202
@ -64,29 +64,6 @@ public abstract class Button extends AbstractDSign {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (isErroneous()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Trigger trigger : getTriggers()) {
|
||||
if (!trigger.isTriggered()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (trigger.getPlayer() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (push(trigger.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
push();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the same as {@link #push(org.bukkit.entity.Player)}.
|
||||
*
|
||||
|
@ -119,28 +119,4 @@ public abstract class Deactivatable extends AbstractDSign {
|
||||
return isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (isErroneous()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Trigger trigger : getTriggers()) {
|
||||
if (!trigger.isTriggered()) {
|
||||
deactivate();
|
||||
return;
|
||||
}
|
||||
|
||||
if (trigger.getPlayer() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (activate(trigger.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activate();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -170,9 +170,23 @@ public interface DungeonSign {
|
||||
void trigger(Player player);
|
||||
|
||||
/**
|
||||
* Updates the sign.
|
||||
* Checks if the triggers of the sign have been triggered. If they all are, the sign itself is triggered.
|
||||
*
|
||||
* @param lastFired the last trigger that has been triggered
|
||||
*/
|
||||
void update();
|
||||
default void updateTriggers(Trigger lastFired) {
|
||||
if (isErroneous()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Trigger trigger : getTriggers()) {
|
||||
if (!trigger.isTriggered()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
trigger(lastFired != null ? lastFired.getPlayer() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sign to air if it is not erroneous and if its type requires this.
|
||||
|
@ -15,6 +15,7 @@
|
||||
package de.erethon.dungeonsxl.api.sign;
|
||||
|
||||
import de.erethon.dungeonsxl.api.DungeonsAPI;
|
||||
import de.erethon.dungeonsxl.api.Trigger;
|
||||
import de.erethon.dungeonsxl.api.world.InstanceWorld;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -32,9 +33,11 @@ public abstract class Passive extends AbstractDSign {
|
||||
|
||||
/**
|
||||
* Does nothing.
|
||||
*
|
||||
* @param lastFired unused
|
||||
*/
|
||||
@Override
|
||||
public final void update() {
|
||||
public final void updateTriggers(Trigger lastFired) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -106,7 +106,7 @@ public abstract class Trigger implements de.erethon.dungeonsxl.api.Trigger {
|
||||
|
||||
public void updateDSigns() {
|
||||
for (DungeonSign dSign : dSigns.toArray(new DungeonSign[dSigns.size()])) {
|
||||
dSign.update();
|
||||
dSign.updateTriggers(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user