mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-06 00:18:36 +01:00
Added #getOldIsland() in island reset-related events (#1179)
* Reaching Old Island information in Island reset events * Added javadocs since tags * added javadoc since tags for new field/method in builder Co-authored-by: Florian CUNY <poslovitch@bentobox.world>
This commit is contained in:
parent
795925f0cd
commit
1e71d67a9b
@ -337,12 +337,29 @@ public class IslandEvent extends IslandBaseEvent {
|
||||
* May be cancelled.
|
||||
*/
|
||||
public static class IslandResetEvent extends IslandBaseEvent {
|
||||
private @NonNull Island oldIsland;
|
||||
private @NonNull BlueprintBundle blueprintBundle;
|
||||
|
||||
private IslandResetEvent(Island island, UUID player, boolean admin, Location location, @NonNull BlueprintBundle blueprintBundle) {
|
||||
private IslandResetEvent(Island island, UUID player, boolean admin, Location location, @NonNull BlueprintBundle blueprintBundle, @NonNull Island oldIsland) {
|
||||
// Final variables have to be declared in the constructor
|
||||
super(island, player, admin, location);
|
||||
this.blueprintBundle = blueprintBundle;
|
||||
this.oldIsland = oldIsland;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.12.0
|
||||
*/
|
||||
@NonNull
|
||||
public Island getOldIsland() {
|
||||
return oldIsland;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.12.0
|
||||
*/
|
||||
public void setOldIsland(Island oldIsland) {
|
||||
this.oldIsland = oldIsland;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -365,9 +382,27 @@ public class IslandEvent extends IslandBaseEvent {
|
||||
*
|
||||
*/
|
||||
public static class IslandResettedEvent extends IslandBaseEvent {
|
||||
private IslandResettedEvent(Island island, UUID player, boolean admin, Location location) {
|
||||
private @NonNull Island oldIsland;
|
||||
|
||||
private IslandResettedEvent(Island island, UUID player, boolean admin, Location location, Island oldIsland) {
|
||||
// Final variables have to be declared in the constructor
|
||||
super(island, player, admin, location);
|
||||
this.oldIsland = oldIsland;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.12.0
|
||||
*/
|
||||
@NonNull
|
||||
public Island getOldIsland() {
|
||||
return oldIsland;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 1.12.0
|
||||
*/
|
||||
public void setOldIsland(Island oldIsland) {
|
||||
this.oldIsland = oldIsland;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@ -472,11 +507,27 @@ public class IslandEvent extends IslandBaseEvent {
|
||||
*/
|
||||
private int oldRange;
|
||||
|
||||
/**
|
||||
* Stores old island object
|
||||
* @since 1.12.0
|
||||
*/
|
||||
private Island oldIsland;
|
||||
|
||||
public IslandEventBuilder island(Island island) {
|
||||
this.island = island;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param oldIsland old island object
|
||||
* @return IslandEventBuilder
|
||||
* @since 1.12.0
|
||||
*/
|
||||
public IslandEventBuilder oldIsland(Island oldIsland) {
|
||||
this.oldIsland = oldIsland;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* True if this is an admin driven event
|
||||
* @param admin - true if due to admin event
|
||||
@ -585,11 +636,11 @@ public class IslandEvent extends IslandBaseEvent {
|
||||
Bukkit.getPluginManager().callEvent(lock);
|
||||
return lock;
|
||||
case RESET:
|
||||
IslandResetEvent reset = new IslandResetEvent(island, player, admin, location, blueprintBundle);
|
||||
IslandResetEvent reset = new IslandResetEvent(island, player, admin, location, blueprintBundle, oldIsland);
|
||||
Bukkit.getPluginManager().callEvent(reset);
|
||||
return reset;
|
||||
case RESETTED:
|
||||
IslandResettedEvent resetted = new IslandResettedEvent(island, player, admin, location);
|
||||
IslandResettedEvent resetted = new IslandResettedEvent(island, player, admin, location, oldIsland);
|
||||
Bukkit.getPluginManager().callEvent(resetted);
|
||||
return resetted;
|
||||
case UNBAN:
|
||||
|
@ -207,6 +207,7 @@ public class NewIsland {
|
||||
.island(island)
|
||||
.location(island.getCenter())
|
||||
.blueprintBundle(plugin.getBlueprintsManager().getBlueprintBundles(addon).get(name))
|
||||
.oldIsland(oldIsland)
|
||||
.build();
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
@ -267,6 +268,7 @@ public class NewIsland {
|
||||
.reason(reasonDone)
|
||||
.island(island)
|
||||
.location(island.getCenter())
|
||||
.oldIsland(oldIsland)
|
||||
.build();
|
||||
};
|
||||
if (noPaste) {
|
||||
|
Loading…
Reference in New Issue
Block a user