mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-25 09:31:46 +01:00
Put island deletion under one class manager
The goal is to make BentoBox less of a monster class and have fewer dependent classes.
This commit is contained in:
parent
7b8e18afff
commit
9bd0104a3d
@ -39,7 +39,6 @@ import world.bentobox.bentobox.managers.BlueprintsManager;
|
|||||||
import world.bentobox.bentobox.managers.CommandsManager;
|
import world.bentobox.bentobox.managers.CommandsManager;
|
||||||
import world.bentobox.bentobox.managers.FlagsManager;
|
import world.bentobox.bentobox.managers.FlagsManager;
|
||||||
import world.bentobox.bentobox.managers.HooksManager;
|
import world.bentobox.bentobox.managers.HooksManager;
|
||||||
import world.bentobox.bentobox.managers.IslandChunkDeletionManager;
|
|
||||||
import world.bentobox.bentobox.managers.IslandDeletionManager;
|
import world.bentobox.bentobox.managers.IslandDeletionManager;
|
||||||
import world.bentobox.bentobox.managers.IslandWorldManager;
|
import world.bentobox.bentobox.managers.IslandWorldManager;
|
||||||
import world.bentobox.bentobox.managers.IslandsManager;
|
import world.bentobox.bentobox.managers.IslandsManager;
|
||||||
@ -74,7 +73,6 @@ public class BentoBox extends JavaPlugin implements Listener {
|
|||||||
private HooksManager hooksManager;
|
private HooksManager hooksManager;
|
||||||
private PlaceholdersManager placeholdersManager;
|
private PlaceholdersManager placeholdersManager;
|
||||||
private IslandDeletionManager islandDeletionManager;
|
private IslandDeletionManager islandDeletionManager;
|
||||||
private IslandChunkDeletionManager islandChunkDeletionManager;
|
|
||||||
private WebManager webManager;
|
private WebManager webManager;
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
@ -306,7 +304,6 @@ public class BentoBox extends JavaPlugin implements Listener {
|
|||||||
// MV unregister
|
// MV unregister
|
||||||
manager.registerEvents(this, this);
|
manager.registerEvents(this, this);
|
||||||
// Island Delete Manager
|
// Island Delete Manager
|
||||||
islandChunkDeletionManager = new IslandChunkDeletionManager(this);
|
|
||||||
islandDeletionManager = new IslandDeletionManager(this);
|
islandDeletionManager = new IslandDeletionManager(this);
|
||||||
manager.registerEvents(islandDeletionManager, this);
|
manager.registerEvents(islandDeletionManager, this);
|
||||||
}
|
}
|
||||||
@ -545,13 +542,6 @@ public class BentoBox extends JavaPlugin implements Listener {
|
|||||||
return islandDeletionManager;
|
return islandDeletionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the islandChunkDeletionManager
|
|
||||||
*/
|
|
||||||
public IslandChunkDeletionManager getIslandChunkDeletionManager() {
|
|
||||||
return islandChunkDeletionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return an optional of the Bstats instance
|
* @return an optional of the Bstats instance
|
||||||
* @since 1.1
|
* @since 1.1
|
||||||
|
@ -31,11 +31,13 @@ public class IslandDeletionManager implements Listener {
|
|||||||
*/
|
*/
|
||||||
private final Database<IslandDeletion> handler;
|
private final Database<IslandDeletion> handler;
|
||||||
private final Set<Location> inDeletion;
|
private final Set<Location> inDeletion;
|
||||||
|
private final IslandChunkDeletionManager islandChunkDeletionManager;
|
||||||
|
|
||||||
public IslandDeletionManager(BentoBox plugin) {
|
public IslandDeletionManager(BentoBox plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
handler = new Database<>(plugin, IslandDeletion.class);
|
handler = new Database<>(plugin, IslandDeletion.class);
|
||||||
inDeletion = new HashSet<>();
|
inDeletion = new HashSet<>();
|
||||||
|
islandChunkDeletionManager = new IslandChunkDeletionManager(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +58,7 @@ public class IslandDeletionManager implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
plugin.log("Resuming deletion of island at " + di.getLocation().getWorld().getName() + " " + Util.xyz(di.getLocation().toVector()));
|
plugin.log("Resuming deletion of island at " + di.getLocation().getWorld().getName() + " " + Util.xyz(di.getLocation().toVector()));
|
||||||
inDeletion.add(di.getLocation());
|
inDeletion.add(di.getLocation());
|
||||||
plugin.getIslandChunkDeletionManager().add(di);
|
this.islandChunkDeletionManager.add(di);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -86,4 +88,12 @@ public class IslandDeletionManager implements Listener {
|
|||||||
public boolean inDeletion(Location location) {
|
public boolean inDeletion(Location location) {
|
||||||
return inDeletion.contains(location);
|
return inDeletion.contains(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the islandChunkDeletionManager
|
||||||
|
*/
|
||||||
|
public IslandChunkDeletionManager getIslandChunkDeletionManager() {
|
||||||
|
return islandChunkDeletionManager;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ public class IslandsManager {
|
|||||||
// Remove players from island
|
// Remove players from island
|
||||||
removePlayersFromIsland(island);
|
removePlayersFromIsland(island);
|
||||||
// Remove blocks from world
|
// Remove blocks from world
|
||||||
plugin.getIslandChunkDeletionManager().add(new IslandDeletion(island));
|
plugin.getIslandDeletionManager().getIslandChunkDeletionManager().add(new IslandDeletion(island));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,9 +67,6 @@ public class IslandDeletionManagerTest {
|
|||||||
private BukkitScheduler scheduler;
|
private BukkitScheduler scheduler;
|
||||||
@Mock
|
@Mock
|
||||||
private IslandWorldManager iwm;
|
private IslandWorldManager iwm;
|
||||||
@Mock
|
|
||||||
private IslandChunkDeletionManager chunkDeletionManager;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -102,8 +99,6 @@ public class IslandDeletionManagerTest {
|
|||||||
// IWM
|
// IWM
|
||||||
when(plugin.getIWM()).thenReturn(iwm);
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
when(iwm.getIslandDistance(any())).thenReturn(64);
|
when(iwm.getIslandDistance(any())).thenReturn(64);
|
||||||
// Chunk deletion manager
|
|
||||||
when(plugin.getIslandChunkDeletionManager()).thenReturn(chunkDeletionManager);
|
|
||||||
|
|
||||||
// Island Deletion Manager
|
// Island Deletion Manager
|
||||||
idm = new IslandDeletionManager(plugin);
|
idm = new IslandDeletionManager(plugin);
|
||||||
|
@ -109,6 +109,8 @@ public class IslandsManagerTest extends AbstractCommonSetup {
|
|||||||
@Mock
|
@Mock
|
||||||
private IslandWorldManager iwm;
|
private IslandWorldManager iwm;
|
||||||
@Mock
|
@Mock
|
||||||
|
private IslandDeletionManager deletionManager;
|
||||||
|
@Mock
|
||||||
private IslandChunkDeletionManager chunkDeletionManager;
|
private IslandChunkDeletionManager chunkDeletionManager;
|
||||||
@Mock
|
@Mock
|
||||||
private IslandCache islandCache;
|
private IslandCache islandCache;
|
||||||
@ -161,9 +163,6 @@ public class IslandsManagerTest extends AbstractCommonSetup {
|
|||||||
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
when(iwm.inWorld(any(Location.class))).thenReturn(true);
|
||||||
when(plugin.getIWM()).thenReturn(iwm);
|
when(plugin.getIWM()).thenReturn(iwm);
|
||||||
|
|
||||||
// Chunk deletion manager
|
|
||||||
when(plugin.getIslandChunkDeletionManager()).thenReturn(chunkDeletionManager);
|
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
Settings s = mock(Settings.class);
|
Settings s = mock(Settings.class);
|
||||||
when(plugin.getSettings()).thenReturn(s);
|
when(plugin.getSettings()).thenReturn(s);
|
||||||
@ -311,7 +310,9 @@ public class IslandsManagerTest extends AbstractCommonSetup {
|
|||||||
.getNearbyEntities(any(Location.class), Mockito.anyDouble(), Mockito.anyDouble(), Mockito.anyDouble()))
|
.getNearbyEntities(any(Location.class), Mockito.anyDouble(), Mockito.anyDouble(), Mockito.anyDouble()))
|
||||||
.thenReturn(collection);
|
.thenReturn(collection);
|
||||||
|
|
||||||
|
// Deletion Manager
|
||||||
|
when(deletionManager.getIslandChunkDeletionManager()).thenReturn(chunkDeletionManager);
|
||||||
|
when(plugin.getIslandDeletionManager()).thenReturn(deletionManager);
|
||||||
|
|
||||||
// database must be mocked here
|
// database must be mocked here
|
||||||
db = mock(Database.class);
|
db = mock(Database.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user