Skip to content

Commit

Permalink
more event impls and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Nov 14, 2021
1 parent 39836e0 commit e495aba
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 194 deletions.
Expand Up @@ -16,8 +16,6 @@ public class BlockBuiltScriptEvent extends BukkitScriptEvent implements Listener
// @Events
// <block> being built (on <block>)
//
// @Regex ^on [^\s]+ being built$
//
// @Group Block
//
// @Location true
Expand Down
Expand Up @@ -26,11 +26,7 @@ public class AreaEnterExitScriptEvent extends BukkitScriptEvent implements Liste

// <--[event]
// @Events
// entity enters/exits cuboid/ellipsoid/polygon
// <entity> enters <area>
// <entity> exits <area>
//
// @Regex ^on [^\s]+ (enters|exits) [^\s]+$
// <entity> enters|exits <area>
//
// @Group Entity
//
Expand All @@ -53,6 +49,7 @@ public class AreaEnterExitScriptEvent extends BukkitScriptEvent implements Liste

public AreaEnterExitScriptEvent() {
instance = this;
registerCouldMatcher("<entity> enters|exits <area>");
}

public static AreaEnterExitScriptEvent instance;
Expand All @@ -62,21 +59,6 @@ public AreaEnterExitScriptEvent() {
public boolean isEntering;
public Location to;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventArgLowerAt(1).equals("enters") && !path.eventArgLowerAt(1).equals("exits")) {
return false;
}
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
String areaName = path.eventArgLowerAt(2);
if (!couldMatchArea(areaName) && !areaName.equals("notable")) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {
if (isEntering && !path.eventArgLowerAt(1).equals("enters")) {
Expand Down
Expand Up @@ -13,11 +13,9 @@ public class DragonPhaseChangeScriptEvent extends BukkitScriptEvent implements L

// <--[event]
// @Events
// dragon changes phase
// ender_dragon changes phase
// <entity> changes phase
//
// @Regex ^on [^\s]+ changes phase$
//
// @Group Entity
//
// @Location true
Expand All @@ -40,23 +38,14 @@ public class DragonPhaseChangeScriptEvent extends BukkitScriptEvent implements L

public DragonPhaseChangeScriptEvent() {
instance = this;
registerCouldMatcher("<entity> changes phase");
registerSwitches("from", "to");
}

public static DragonPhaseChangeScriptEvent instance;
public EntityTag entity;
public EnderDragonChangePhaseEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventLower.contains("changes phase")) {
return false;
}
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {
String target = path.eventArgLowerAt(0);
Expand Down
Expand Up @@ -16,11 +16,8 @@ public class EntityAirLevelChangeScriptEvent extends BukkitScriptEvent implement

// <--[event]
// @Events
// entity changes air level
// <entity> changes air level
//
// @Regex ^on [^\s]+ changes air level$
//
// @Synonyms player loses oxygen,player drowns,player is drowning,oxygen depletion
//
// @Group Entity
Expand All @@ -46,23 +43,13 @@ public class EntityAirLevelChangeScriptEvent extends BukkitScriptEvent implement

public EntityAirLevelChangeScriptEvent() {
instance = this;
registerCouldMatcher("<entity> changes air level");
}

public static EntityAirLevelChangeScriptEvent instance;
public EntityTag entity;
public EntityAirChangeEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventLower.contains("changes air level")) {
return false;
}
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {
String target = path.eventArgLowerAt(0);
Expand Down
Expand Up @@ -15,11 +15,8 @@ public class EntityBreedScriptEvent extends BukkitScriptEvent implements Listene

// <--[event]
// @Events
// entity breeds
// <entity> breeds
//
// @Regex ^on [^\s]+ breeds$
//
// @Group Entity
//
// @Location true
Expand All @@ -43,6 +40,7 @@ public class EntityBreedScriptEvent extends BukkitScriptEvent implements Listene

public EntityBreedScriptEvent() {
instance = this;
registerCouldMatcher("<entity> breeds");
}

public static EntityBreedScriptEvent instance;
Expand All @@ -54,17 +52,6 @@ public EntityBreedScriptEvent() {
private int experience;
public EntityBreedEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventArgLowerAt(1).equals("breeds")) {
return false;
}
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {
if (!tryEntity(entity, path.eventArgLowerAt(0))) {
Expand Down
Expand Up @@ -16,13 +16,7 @@ public class EntityChangesBlockScriptEvent extends BukkitScriptEvent implements

// <--[event]
// @Events
// entity changes block
// entity changes block (into <material>)
// entity changes <material> (into <material>)
// <entity> changes block (into <material>)
// <entity> changes <material> (into <material>)
//
// @Regex ^on [^\s]+ changes [^\s]+( into [^\s]+)?$
// <entity> changes <block> (into <block>)
//
// @Group Entity
//
Expand All @@ -44,6 +38,7 @@ public class EntityChangesBlockScriptEvent extends BukkitScriptEvent implements

public EntityChangesBlockScriptEvent() {
instance = this;
registerCouldMatcher("<entity> changes <block> (into <block>)");
}

public static EntityChangesBlockScriptEvent instance;
Expand All @@ -53,20 +48,6 @@ public EntityChangesBlockScriptEvent() {
public MaterialTag new_material;
public EntityChangeBlockEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventArgLowerAt(1).equals("changes")) {
return false;
}
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
if (!couldMatchBlock(path.eventArgLowerAt(2))) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {
String entName = path.eventArgLowerAt(0);
Expand Down
Expand Up @@ -19,11 +19,8 @@ public class EntityCombustsScriptEvent extends BukkitScriptEvent implements List

// <--[event]
// @Events
// entity combusts
// <entity> combusts
//
// @Regex ^on [^\s]+ combusts$
//
// @Group Entity
//
// @Location true
Expand All @@ -49,23 +46,13 @@ public class EntityCombustsScriptEvent extends BukkitScriptEvent implements List

public EntityCombustsScriptEvent() {
instance = this;
registerCouldMatcher("<entity> combusts");
}

public static EntityCombustsScriptEvent instance;
public EntityTag entity;
public EntityCombustEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventArgLowerAt(1).equals("combusts")) {
return false;
}
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {
if (!tryEntity(entity, path.eventArgLowerAt(0))) {
Expand Down
Expand Up @@ -17,11 +17,8 @@ public class EntityCreatePortalScriptEvent extends BukkitScriptEvent implements

// <--[event]
// @Events
// entity creates portal
// <entity> creates portal
//
// @Regex ^on [^\s]+ creates portal$
//
// @Group Entity
//
// @Location true
Expand All @@ -41,23 +38,13 @@ public class EntityCreatePortalScriptEvent extends BukkitScriptEvent implements

public EntityCreatePortalScriptEvent() {
instance = this;
registerCouldMatcher("<entity> creates portal");
}

public static EntityCreatePortalScriptEvent instance;
public EntityTag entity;
public EntityCreatePortalEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventLower.contains("creates portal")) {
return false;
}
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {
if (!tryEntity(entity, path.eventArgLowerAt(0))) {
Expand Down
Expand Up @@ -14,11 +14,8 @@ public class EntityExplosionPrimesScriptEvent extends BukkitScriptEvent implemen

// <--[event]
// @Events
// entity explosion primes
// <entity> explosion primes
//
// @Regex ^on [^\s]+ explosion primes$
//
// @Group Entity
//
// @Location true
Expand All @@ -35,23 +32,13 @@ public class EntityExplosionPrimesScriptEvent extends BukkitScriptEvent implemen

public EntityExplosionPrimesScriptEvent() {
instance = this;
registerCouldMatcher("<entity> explosion primes");
}

public static EntityExplosionPrimesScriptEvent instance;
public EntityTag entity;
public ExplosionPrimeEvent event;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventLower.contains("explosion primes")) {
return false;
}
if (!couldMatchEntity(path.eventArgLowerAt(0))) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {

Expand Down
Expand Up @@ -17,8 +17,6 @@ public class PlayerJumpScriptEvent extends BukkitScriptEvent implements Listener
// @Events
// player jumps
//
// @Regex ^on player jumps$
//
// @Group Player
//
// @Location true
Expand All @@ -36,18 +34,14 @@ public class PlayerJumpScriptEvent extends BukkitScriptEvent implements Listener

public PlayerJumpScriptEvent() {
instance = this;
registerCouldMatcher("player jumps");
}

public static PlayerJumpScriptEvent instance;

public LocationTag location;
public PlayerTag player;

@Override
public boolean couldMatch(ScriptPath path) {
return path.eventLower.startsWith("player jumps");
}

@Override
public boolean matches(ScriptPath path) {
if (!runInCheck(path, location)) {
Expand Down
Expand Up @@ -20,8 +20,6 @@ public class PlayerKickedScriptEvent extends BukkitScriptEvent implements Listen
// @Events
// player kicked (for flying)
//
// @Regex ^on player kicked( for flying)?$
//
// @Group Player
//
// @Cancellable true
Expand All @@ -44,6 +42,7 @@ public class PlayerKickedScriptEvent extends BukkitScriptEvent implements Listen

public PlayerKickedScriptEvent() {
instance = this;
registerCouldMatcher("player kicked (for flying)");
}

public static PlayerKickedScriptEvent instance;
Expand All @@ -54,11 +53,6 @@ public boolean isFlying() {
return NMSHandler.getPlayerHelper().getFlyKickCooldown(player.getPlayerEntity()) == 0;
}

@Override
public boolean couldMatch(ScriptPath path) {
return path.eventLower.startsWith("player kicked");
}

@Override
public boolean matches(ScriptPath path) {
if (path.eventArgLowerAt(3).equals("flying")) {
Expand Down

0 comments on commit e495aba

Please sign in to comment.