Skip to content

Commit

Permalink
match core - eventPaths has to be per-instance for bukkit_priority
Browse files Browse the repository at this point in the history
also age property docs
  • Loading branch information
mcmonkey4eva committed Nov 23, 2021
1 parent 47bad6c commit 612a306
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -591,30 +591,30 @@ public void initListener(Listener listener) {
if (priorityHandlers == null) {
priorityHandlers = new HashMap<>();
}
for (ScriptPath path : new ArrayList<>(eventData.eventPaths)) {
for (ScriptPath path : new ArrayList<>(eventPaths)) {
String bukkitPriority = path.switches.get("bukkit_priority");
if (bukkitPriority != null) {
try {
EventPriority priority = EventPriority.valueOf(bukkitPriority.toUpperCase());
BukkitScriptEvent handler = priorityHandlers.get(priority);
if (handler == null) {
handler = (BukkitScriptEvent) clone();
handler.eventData.eventPaths = new ArrayList<>();
handler.eventPaths = new ArrayList<>();
handler.priorityHandlers = null;
handler.registeredHandlers = null;
priorityHandlers.put(priority, handler);
handler.initForPriority(priority, (Listener) handler);
}
handler.eventData.eventPaths.add(path);
eventData.eventPaths.remove(path);
handler.eventPaths.add(path);
eventPaths.remove(path);
}
catch (IllegalArgumentException ex) {
Debug.echoError("Invalid 'bukkit_priority' switch for event '" + path.event + "' in script '" + path.container.getName() + "'.");
Debug.echoError(ex);
}
}
}
if (!eventData.eventPaths.isEmpty()) {
if (!eventPaths.isEmpty()) {
initForPriority(EventPriority.NORMAL, listener);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void init() {
List<MatchHelper> matchList = new ArrayList<>();
HashSet<String> flags = new HashSet<>();
onlyTrackPlayers = true;
for (ScriptPath path : eventData.eventPaths) {
for (ScriptPath path : eventPaths) {
if (!path.eventArgLowerAt(0).equals("player")) {
onlyTrackPlayers = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void destroy() {
public void init() {
registeredHandlers = new ArrayList<>();
HashSet<String> eventsGrabbed = new HashSet<>();
for (ScriptPath path : new ArrayList<>(eventData.eventPaths)) {
for (ScriptPath path : new ArrayList<>(eventPaths)) {
String eventName = path.switches.get("event");
if (!eventsGrabbed.add(eventName)) {
continue;
Expand All @@ -147,11 +147,11 @@ public void init() {
}
}
InternalEventScriptEvent handler = (InternalEventScriptEvent) clone();
handler.eventData.eventPaths = new ArrayList<>();
handler.eventData.eventPaths.add(path);
handler.eventPaths = new ArrayList<>();
handler.eventPaths.add(path);
handler.registeredHandlers = null;
handler.initForPriority(priority, this, (Class<? extends Event>) clazz);
eventData.eventPaths.remove(path);
eventPaths.remove(path);
}
catch (ClassNotFoundException ex) {
Debug.echoError("Cannot initialize Internal Bukkit Event for event '" + eventName + "': that event class does not exist.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ public ObjectTag getObjectAttribute(Attribute attribute) {
// @mechanism EntityTag.age
// @group properties
// @description
// If the entity is ageable, returns the entity's age number (-24000 to 0)
// If the entity is ageable, returns the entity's age number.
// Age moves 1 towards zero each tick.
// A newly spawned baby is -24000.
// A standard adult is 0.
// An adult that just bred is 6000.
// -->
if (attribute.startsWith("age")) {
return new ElementTag(getAge())
Expand Down Expand Up @@ -195,7 +199,7 @@ public void adjust(Mechanism mechanism) {
// @input ElementTag
// @description
// Sets the entity's age.
// Inputs can be 'baby', 'adult', or a valid age number (-24000 to 0)
// Inputs can be 'baby', 'adult', or a valid age number. A default baby is -24000, a default adult is 0, an adult that just bred is 6000.
// Optionally, add '|locked' or 'unlocked' to lock/unlock the entity into/from the current age.
// (EG, age:baby|locked or age:-24000|unlocked)
// Also available: <@link mechanism EntityTag.age_lock>
Expand Down

0 comments on commit 612a306

Please sign in to comment.