mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
Added plugin events.
This commit is contained in:
parent
70dd42fc7c
commit
14f97ba24a
1 changed files with 48 additions and 6 deletions
|
@ -47,6 +47,7 @@ public class GameEvent implements Serializable {
|
|||
protected String data;
|
||||
protected Zone zone;
|
||||
protected ArrayList<UUID> appliedEffects = new ArrayList<>();
|
||||
protected UUID pluginEventType = null;
|
||||
|
||||
public enum EventType {
|
||||
|
||||
|
@ -269,15 +270,15 @@ public class GameEvent implements Serializable {
|
|||
NUMBER_OF_TRIGGERS,
|
||||
//combat events
|
||||
COMBAT_DAMAGE_APPLIED,
|
||||
SELECTED_ATTACKER, SELECTED_BLOCKER;
|
||||
SELECTED_ATTACKER, SELECTED_BLOCKER,
|
||||
//custom events
|
||||
PLUGIN_EVENT;
|
||||
}
|
||||
|
||||
public GameEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
this(type, targetId, sourceId, playerId, 0, false);
|
||||
}
|
||||
|
||||
public GameEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
||||
private GameEvent(EventType type, UUID pluginEventType,
|
||||
UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
||||
this.type = type;
|
||||
this.pluginEventType = pluginEventType;
|
||||
this.targetId = targetId;
|
||||
this.sourceId = sourceId;
|
||||
this.amount = amount;
|
||||
|
@ -285,6 +286,22 @@ public class GameEvent implements Serializable {
|
|||
this.flag = flag;
|
||||
}
|
||||
|
||||
public GameEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
this(type, null, targetId, sourceId, playerId, 0, false);
|
||||
}
|
||||
|
||||
public GameEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
||||
this(type, null, targetId, sourceId, playerId, amount, flag);
|
||||
}
|
||||
|
||||
public GameEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
this(EventType.PLUGIN_EVENT, pluginEventType, targetId, sourceId, playerId, 0, false);
|
||||
}
|
||||
|
||||
public GameEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId, int amount, boolean flag) {
|
||||
this(EventType.PLUGIN_EVENT, pluginEventType, targetId, sourceId, playerId, amount, flag);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(EventType type, UUID targetId, UUID sourceId, UUID playerId, int amount) {
|
||||
return new GameEvent(type, targetId, sourceId, playerId, amount, false);
|
||||
}
|
||||
|
@ -304,10 +321,31 @@ public class GameEvent implements Serializable {
|
|||
return event;
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId, int amount) {
|
||||
return new GameEvent(pluginEventType, targetId, sourceId, playerId, amount, false);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID sourceId, UUID playerId) {
|
||||
return new GameEvent(pluginEventType, targetId, sourceId, playerId);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID playerId) {
|
||||
return new GameEvent(pluginEventType, targetId, null, playerId);
|
||||
}
|
||||
|
||||
public static GameEvent getEvent(UUID pluginEventType, UUID targetId, UUID playerId, String data, int amount) {
|
||||
GameEvent event = getEvent(pluginEventType, targetId, playerId);
|
||||
event.setAmount(amount);
|
||||
event.setData(data);
|
||||
return event;
|
||||
}
|
||||
|
||||
public EventType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public UUID getPluginEventType() { return pluginEventType; }
|
||||
|
||||
public UUID getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
@ -374,6 +412,10 @@ public class GameEvent implements Serializable {
|
|||
return appliedEffects;
|
||||
}
|
||||
|
||||
public boolean isPluginEvent(UUID pluginEventType) {
|
||||
return type == EventType.PLUGIN_EVENT && this.pluginEventType.equals(pluginEventType);
|
||||
}
|
||||
|
||||
public void setAppliedEffects(ArrayList<UUID> appliedEffects) {
|
||||
if (this.appliedEffects == null) {
|
||||
this.appliedEffects = new ArrayList<>();
|
||||
|
|
Loading…
Reference in a new issue