Renamed DeletedIslandDO to IslandDeletion

This commit is contained in:
Florian CUNY 2019-01-13 10:21:06 +01:00
parent 0f253c35ef
commit dc7d5b40f2
5 changed files with 25 additions and 26 deletions

View File

@ -6,7 +6,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.DeletedIslandDO;
import world.bentobox.bentobox.database.objects.IslandDeletion;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags;
@ -180,15 +180,15 @@ public class IslandEvent extends IslandBaseEvent {
*
*/
public static class IslandDeleteChunksEvent extends IslandBaseEvent {
private final DeletedIslandDO deletedIslandInfo;
private final IslandDeletion deletedIslandInfo;
private IslandDeleteChunksEvent(Island island, UUID player, boolean admin, Location location, DeletedIslandDO deletedIsland) {
private IslandDeleteChunksEvent(Island island, UUID player, boolean admin, Location location, IslandDeletion deletedIsland) {
// Final variables have to be declared in the constructor
super(island, player, admin, location);
this.deletedIslandInfo = deletedIsland;
}
public DeletedIslandDO getDeletedIslandInfo() {
public IslandDeletion getDeletedIslandInfo() {
return deletedIslandInfo;
}
}
@ -197,15 +197,15 @@ public class IslandEvent extends IslandBaseEvent {
*
*/
public static class IslandDeletedEvent extends IslandBaseEvent {
private final DeletedIslandDO deletedIslandInfo;
private final IslandDeletion deletedIslandInfo;
private IslandDeletedEvent(Island island, UUID player, boolean admin, Location location, DeletedIslandDO deletedIsland) {
private IslandDeletedEvent(Island island, UUID player, boolean admin, Location location, IslandDeletion deletedIsland) {
// Final variables have to be declared in the constructor
super(island, player, admin, location);
this.deletedIslandInfo = deletedIsland;
}
public DeletedIslandDO getDeletedIslandInfo() {
public IslandDeletion getDeletedIslandInfo() {
return deletedIslandInfo;
}
}
@ -287,7 +287,7 @@ public class IslandEvent extends IslandBaseEvent {
private Reason reason = Reason.UNKNOWN;
private boolean admin;
private Location location;
private DeletedIslandDO deletedIslandInfo;
private IslandDeletion deletedIslandInfo;
public IslandEventBuilder island(Island island) {
this.island = island;
@ -327,7 +327,7 @@ public class IslandEvent extends IslandBaseEvent {
return this;
}
public IslandEventBuilder deletedIslandInfo(DeletedIslandDO deletedIslandInfo) {
public IslandEventBuilder deletedIslandInfo(IslandDeletion deletedIslandInfo) {
this.deletedIslandInfo = deletedIslandInfo;
return this;
}

View File

@ -9,9 +9,10 @@ import com.google.gson.annotations.Expose;
/**
* Data object to store islands in deletion
*
* @author tastybento
* @since 1.1
*/
public class DeletedIslandDO implements DataObject {
public class IslandDeletion implements DataObject {
@Expose
private String uniqueId = "";
@ -31,9 +32,9 @@ public class DeletedIslandDO implements DataObject {
@Expose
private int maxZChunk;
public DeletedIslandDO() {}
public IslandDeletion() {}
public DeletedIslandDO(Island island) {
public IslandDeletion(Island island) {
uniqueId = UUID.randomUUID().toString();
location = island.getCenter();
minXChunk = (location.getBlockX() - island.getMaxEverProtectionRange()) >> 4;
@ -42,7 +43,7 @@ public class DeletedIslandDO implements DataObject {
maxZChunk = (island.getMaxEverProtectionRange() + location.getBlockZ() - 1) >> 4;
}
public DeletedIslandDO(Location location, int minXChunk, int maxXChunk, int minZChunk, int maxZChunk) {
public IslandDeletion(Location location, int minXChunk, int maxXChunk, int minZChunk, int maxZChunk) {
this.uniqueId = UUID.randomUUID().toString();
this.location = location;
this.minXChunk = minXChunk;
@ -62,10 +63,10 @@ public class DeletedIslandDO implements DataObject {
if (obj == null) {
return false;
}
if (!(obj instanceof DeletedIslandDO)) {
if (!(obj instanceof IslandDeletion)) {
return false;
}
DeletedIslandDO other = (DeletedIslandDO) obj;
IslandDeletion other = (IslandDeletion) obj;
if (uniqueId == null) {
if (other.uniqueId != null) {
return false;
@ -173,7 +174,5 @@ public class DeletedIslandDO implements DataObject {
public void setUniqueId(String uniqueId) {
this.uniqueId = uniqueId;
}
}

View File

@ -14,7 +14,7 @@ import world.bentobox.bentobox.api.events.BentoBoxReadyEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandDeleteChunksEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.IslandDeletedEvent;
import world.bentobox.bentobox.database.Database;
import world.bentobox.bentobox.database.objects.DeletedIslandDO;
import world.bentobox.bentobox.database.objects.IslandDeletion;
import world.bentobox.bentobox.util.DeleteIslandChunks;
import world.bentobox.bentobox.util.Util;
@ -29,12 +29,12 @@ public class IslandDeletionManager implements Listener {
/**
* Queue of islands to delete
*/
private Database<DeletedIslandDO> handler;
private Database<IslandDeletion> handler;
private Set<Location> inDeletion;
public IslandDeletionManager(BentoBox plugin) {
this.plugin = plugin;
handler = new Database<>(plugin, DeletedIslandDO.class);
handler = new Database<>(plugin, IslandDeletion.class);
inDeletion = new HashSet<>();
}
@ -45,7 +45,7 @@ public class IslandDeletionManager implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBentoBoxReady(BentoBoxReadyEvent e) {
// Load list of islands that were mid deletion and delete them
List<DeletedIslandDO> toBeDeleted = handler.loadObjects();
List<IslandDeletion> toBeDeleted = handler.loadObjects();
if (toBeDeleted != null && toBeDeleted.size() > 0) {
plugin.log("There are " + toBeDeleted.size() + " islands pending deletion.");
toBeDeleted.forEach(di -> {

View File

@ -30,7 +30,7 @@ import world.bentobox.bentobox.api.events.island.IslandEvent.Reason;
import world.bentobox.bentobox.api.localization.TextVariables;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.database.Database;
import world.bentobox.bentobox.database.objects.DeletedIslandDO;
import world.bentobox.bentobox.database.objects.IslandDeletion;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.bentobox.lists.Flags;
import world.bentobox.bentobox.managers.island.IslandCache;
@ -261,7 +261,7 @@ public class IslandsManager {
// Remove players from island
removePlayersFromIsland(island);
// Remove blocks from world
new DeleteIslandChunks(plugin, new DeletedIslandDO(island));
new DeleteIslandChunks(plugin, new IslandDeletion(island));
}
}

View File

@ -6,7 +6,7 @@ import org.bukkit.scheduler.BukkitTask;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.events.island.IslandEvent;
import world.bentobox.bentobox.api.events.island.IslandEvent.Reason;
import world.bentobox.bentobox.database.objects.DeletedIslandDO;
import world.bentobox.bentobox.database.objects.IslandDeletion;
/**
* Deletes islands fast using chunk regeneration
@ -25,7 +25,7 @@ public class DeleteIslandChunks {
private BukkitTask task;
@SuppressWarnings("deprecation")
public DeleteIslandChunks(BentoBox plugin, DeletedIslandDO di) {
public DeleteIslandChunks(BentoBox plugin, IslandDeletion di) {
// Fire event
IslandEvent.builder().deletedIslandInfo(di).reason(Reason.DELETE_CHUNKS).build();
x = di.getMinXChunk();