-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3755564
commit f027042
Showing
8 changed files
with
239 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/me/angeschossen/lands/api/events/land/block/LandBlockInteractEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package me.angeschossen.lands.api.events.land.block; | ||
|
||
import me.angeschossen.lands.api.land.Land; | ||
import me.angeschossen.lands.api.land.block.LandBlock; | ||
import me.angeschossen.lands.api.player.LandPlayer; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
/** | ||
* Called whenever a player interacts with a mainblock or caputeflag etc. | ||
* Landblock types: {@link me.angeschossen.lands.api.land.block.LandBlockType} | ||
*/ | ||
public class LandBlockInteractEvent extends LandBlockEvent{ | ||
public static final HandlerList handlerList = new HandlerList(); | ||
|
||
public LandBlockInteractEvent(@NotNull Land land, @Nullable LandPlayer landPlayer, @NotNull LandBlock landBlock) { | ||
super(land, landPlayer, landBlock); | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlerList; | ||
} | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return handlerList; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
.../java/me/angeschossen/lands/api/events/memberholder/MemberHolderRelationChangedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package me.angeschossen.lands.api.events.memberholder; | ||
|
||
import com.github.angeschossen.pluginframework.api.utils.Checks; | ||
import com.google.common.collect.ImmutableMap; | ||
import me.angeschossen.lands.api.memberholder.MemberHolder; | ||
import me.angeschossen.lands.api.relations.Relation; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Called whenever the relationship between lands or nations changes. | ||
*/ | ||
public class MemberHolderRelationChangedEvent extends MemberHolderEvent implements Cancellable { | ||
|
||
public static final HandlerList handlerList = new HandlerList(); | ||
|
||
private final @NotNull MemberHolder target; | ||
private final @NotNull Relation relation; | ||
private boolean cancelled; | ||
|
||
/** | ||
* Create instance of this event. | ||
* | ||
* @param initiator land or nation that initiated the change | ||
* @param target the target land or nation | ||
* @param relation the new relation status | ||
*/ | ||
public MemberHolderRelationChangedEvent(@NotNull MemberHolder initiator, @NotNull MemberHolder target, @NotNull Relation relation) { | ||
super(initiator); | ||
|
||
this.target = Checks.requireNonNull(target, "target"); | ||
this.relation = Checks.requireNonNull(relation, "relation"); | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean b) { | ||
this.cancelled = b; | ||
} | ||
|
||
/** | ||
* Get the current relation. | ||
* | ||
* @return current relation between the two | ||
*/ | ||
public @NotNull Relation getCurrentRelation() { | ||
return memberHolder.getRelation(target); | ||
} | ||
|
||
/** | ||
* Get the new relation. | ||
* | ||
* @return the new relation between the two | ||
*/ | ||
public @NotNull Relation getNewRelation() { | ||
return relation; | ||
} | ||
|
||
/** | ||
* Get the target of the change. | ||
* | ||
* @return never null | ||
*/ | ||
public @NotNull MemberHolder getTarget() { | ||
return target; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlerList; | ||
} | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return handlerList; | ||
} | ||
|
||
@Override | ||
public void setExpressionVariables(ImmutableMap.@NotNull Builder<String, Object> builder) { | ||
super.setExpressionVariables(builder); | ||
|
||
target.setExpressionVariables("target_" + target.getExpressionPrefix(), builder, null); | ||
} | ||
|
||
@Override | ||
public void setAffectedPlayers(ImmutableMap.@NotNull Builder<String, Collection<UUID>> builder) { | ||
super.setAffectedPlayers(builder); | ||
|
||
target.setAffectedPlayers("target_" + target.getExpressionPrefix(), builder); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/me/angeschossen/lands/api/events/player/role/PlayerToggleRoleFlagEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package me.angeschossen.lands.api.events.player.role; | ||
|
||
import com.github.angeschossen.pluginframework.api.utils.Checks; | ||
import com.google.common.collect.ImmutableMap; | ||
import me.angeschossen.lands.api.events.role.RoleEvent; | ||
import me.angeschossen.lands.api.player.LandPlayer; | ||
import me.angeschossen.lands.api.role.Role; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Called whenever a player toggles a role flag. | ||
*/ | ||
public class PlayerToggleRoleFlagEvent extends RoleEvent implements Cancellable { | ||
public static final HandlerList handlerList = new HandlerList(); | ||
private final @NotNull LandPlayer landPlayer; | ||
private boolean cancelled; | ||
|
||
/** | ||
* Create instance of this event. | ||
* | ||
* @param role role for which the flag is changed | ||
* @param landPlayer the player that changes the state | ||
*/ | ||
public PlayerToggleRoleFlagEvent(@NotNull Role role, @NotNull LandPlayer landPlayer) { | ||
super(role); | ||
|
||
this.landPlayer = Checks.requireNonNull(landPlayer, "landPlayer"); | ||
} | ||
|
||
/** | ||
* Get the player. | ||
* @return player that toggles the flag | ||
*/ | ||
public @NotNull LandPlayer getLandPlayer() { | ||
return landPlayer; | ||
} | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return handlerList; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean b) { | ||
this.cancelled = b; | ||
} | ||
|
||
@Override | ||
public void setAffectedPlayers(ImmutableMap.@NotNull Builder<String, Collection<UUID>> builder) { | ||
landPlayer.setAffectedPlayers("player_", builder); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/me/angeschossen/lands/api/events/role/RoleEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package me.angeschossen.lands.api.events.role; | ||
|
||
import com.github.angeschossen.pluginframework.api.utils.Checks; | ||
import com.google.common.collect.ImmutableMap; | ||
import me.angeschossen.lands.api.events.plugin.LandsEvent; | ||
import me.angeschossen.lands.api.role.Role; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Collection; | ||
import java.util.UUID; | ||
|
||
public abstract class RoleEvent extends LandsEvent { | ||
protected final @NotNull Role role; | ||
|
||
protected RoleEvent(@NotNull Role role) { | ||
this.role = Checks.requireNonNull(role, "role"); | ||
} | ||
|
||
/** | ||
* Get the role. | ||
* | ||
* @return role affected by this event | ||
*/ | ||
public @NotNull Role getRole() { | ||
return role; | ||
} | ||
|
||
@Override | ||
public void setExpressionVariables(ImmutableMap.@NotNull Builder<String, Object> builder) { | ||
role.setExpressionVariables("role_", builder, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters