Skip to content
Permalink
Browse files
Add 'anchor_spawn' boolean to player_spawn event
  • Loading branch information
PseudoKnight committed Jul 4, 2020
1 parent 52b1b1c commit c8c2794dd274246a6c5e11ba63bdb7ae5cbdcb57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
@@ -699,6 +699,16 @@ public MCLocation getRespawnLocation() {
public Boolean isBedSpawn() {
return pre.isBedSpawn();
}

@Override
public boolean isAnchorSpawn() {
try {
return pre.isAnchorSpawn();
} catch (NoSuchMethodError ex) {
// probably before 1.16.1
return false;
}
}
}

@abstraction(type = Implementation.Type.BUKKIT)
@@ -9,4 +9,6 @@ public interface MCPlayerRespawnEvent extends MCPlayerEvent {
MCLocation getRespawnLocation();

Boolean isBedSpawn();

boolean isAnchorSpawn();
}
@@ -1205,18 +1205,17 @@ public String getName() {
@Override
public String docs() {
return "{x: <expression>| y: <expression>| z: <expression>| world: <string match>| player: <macro>}"
+ "Fires when a player respawns. Technically during this time, the player is not considered to be"
+ "Fires when a player respawns. Technically during this time, the player may not be considered"
+ " 'online'. This can cause problems if you try to run an external command with run() or"
+ " something."
+ " CommandHelper takes into account the fact that the player is offline, and works around this, so"
+ " all CH functions should respond correctly, as if the player was online, however other plugins"
+ " or"
+ " plain text commands that are run may not."
+ " something. CommandHelper takes into account the fact that the player is offline, and works"
+ " around this, so all functions should respond correctly as if the player was online,"
+ " however other plugins or plain text commands that are run may not."
+ "{player: The player that is respawning | "
+ "location: The location they are going to respawn at | "
+ "bed_spawn: True if the respawn location is the player's bed}"
+ "bed_spawn: True if the respawn location is the player's bed"
+ "anchor_spawn: True if the respawn location is the player's respawn anchor}"
+ "{location}"
+ "{player|location|bed_spawn}";
+ "{}";
}

@Override
@@ -1253,6 +1252,7 @@ public Map<String, Mixed> evaluate(BindableEvent e) throws EventException {
CArray location = ObjectGenerator.GetGenerator().location(event.getRespawnLocation());
map.put("location", location);
map.put("bed_spawn", CBoolean.get(event.isBedSpawn()));
map.put("anchor_spawn", CBoolean.get(event.isAnchorSpawn()));
return map;
} else {
throw new EventException("Cannot convert e to PlayerRespawnEvent");

0 comments on commit c8c2794

Please sign in to comment.