-
-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add plot group creation/deletion events (#7476)
- Loading branch information
1 parent
770ad6c
commit de07e43
Showing
5 changed files
with
173 additions
and
14 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
50 changes: 50 additions & 0 deletions
50
Towny/src/main/java/com/palmergames/bukkit/towny/event/plot/group/PlotGroupAddEvent.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,50 @@ | ||
package com.palmergames.bukkit.towny.event.plot.group; | ||
|
||
import com.palmergames.bukkit.towny.event.CancellableTownyEvent; | ||
import com.palmergames.bukkit.towny.object.PlotGroup; | ||
import com.palmergames.bukkit.towny.object.TownBlock; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Called when a townblock is added into a plot group | ||
*/ | ||
public class PlotGroupAddEvent extends CancellableTownyEvent { | ||
private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
private final PlotGroup plotGroup; | ||
private final TownBlock townBlock; | ||
private final Player player; | ||
|
||
public PlotGroupAddEvent(final PlotGroup group, final TownBlock townBlock, final Player player) { | ||
this.plotGroup = group; | ||
this.townBlock = townBlock; | ||
this.player = player; | ||
} | ||
|
||
@NotNull | ||
public PlotGroup getPlotGroup() { | ||
return plotGroup; | ||
} | ||
|
||
@NotNull | ||
public TownBlock getTownBlock() { | ||
return townBlock; | ||
} | ||
|
||
@NotNull | ||
public Player getPlayer() { | ||
return player; | ||
} | ||
|
||
@NotNull | ||
public static HandlerList getHandlerList() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return HANDLER_LIST; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Towny/src/main/java/com/palmergames/bukkit/towny/event/plot/group/PlotGroupCreatedEvent.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,24 @@ | ||
package com.palmergames.bukkit.towny.event.plot.group; | ||
|
||
import com.palmergames.bukkit.towny.object.PlotGroup; | ||
import com.palmergames.bukkit.towny.object.TownBlock; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Called when a plot group is created. | ||
*/ | ||
public class PlotGroupCreatedEvent extends PlotGroupAddEvent { | ||
public PlotGroupCreatedEvent(PlotGroup group, TownBlock townBlock, Player player) { | ||
super(group, townBlock, player); | ||
} | ||
|
||
/** | ||
* @return The initial townblock that this plot group is being created with. | ||
*/ | ||
@Override | ||
@NotNull | ||
public TownBlock getTownBlock() { | ||
return super.getTownBlock(); | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
Towny/src/main/java/com/palmergames/bukkit/towny/event/plot/group/PlotGroupDeletedEvent.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,67 @@ | ||
package com.palmergames.bukkit.towny.event.plot.group; | ||
|
||
import com.palmergames.bukkit.towny.event.CancellableTownyEvent; | ||
import com.palmergames.bukkit.towny.object.PlotGroup; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class PlotGroupDeletedEvent extends CancellableTownyEvent { | ||
private static final HandlerList HANDLER_LIST = new HandlerList(); | ||
private final PlotGroup plotGroup; | ||
private final Player player; | ||
private final Cause deletionCause; | ||
|
||
public PlotGroupDeletedEvent(@NotNull PlotGroup group, @Nullable Player player, @NotNull Cause deletionCause) { | ||
this.plotGroup = group; | ||
this.player = player; | ||
this.deletionCause = deletionCause; | ||
} | ||
|
||
/** | ||
* @return The plot group that is being deleted. | ||
*/ | ||
@NotNull | ||
public PlotGroup getPlotGroup() { | ||
return plotGroup; | ||
} | ||
|
||
/** | ||
* @return The player associated with the deletion, if applicable. | ||
*/ | ||
@Nullable | ||
public Player getPlayer() { | ||
return player; | ||
} | ||
|
||
public Cause getDeletionCause() { | ||
return deletionCause; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return HANDLER_LIST; | ||
} | ||
|
||
public enum Cause { | ||
UNKNOWN, | ||
/** | ||
* The plot group was deleted by a player via the /plot group delete command. | ||
*/ | ||
DELETED, | ||
/** | ||
* The plot group was deleted because all of its townblocks were removed. | ||
*/ | ||
NO_TOWNBLOCKS, | ||
/** | ||
* The plot group was deleted because the town it was in being deleted/ruined. | ||
*/ | ||
TOWN_DELETED, | ||
} | ||
} |
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