Remove static abuse - Chunklet stuff

This commit is contained in:
nossr50 2019-09-24 14:30:33 -07:00
parent ec4fbe678e
commit bde66ee4e1
6 changed files with 34 additions and 8 deletions

View File

@ -87,6 +87,7 @@ public class mcMMO extends JavaPlugin {
/* Not-Managers but my naming scheme sucks */ /* Not-Managers but my naming scheme sucks */
private DatabaseManagerFactory databaseManagerFactory; private DatabaseManagerFactory databaseManagerFactory;
private ChunkManagerFactory chunkManagerFactory;
private CommandTools commandTools; private CommandTools commandTools;
private SkillTools skillTools; //TODO: Remove once a new skill system is in place private SkillTools skillTools; //TODO: Remove once a new skill system is in place
private BlockTools blockTools; private BlockTools blockTools;
@ -200,7 +201,9 @@ public class mcMMO extends JavaPlugin {
nbtManager = new NBTManager(this); nbtManager = new NBTManager(this);
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager //Init Chunk Manager Factory
chunkManagerFactory = new ChunkManagerFactory(this);
placeStore = chunkManagerFactory.getChunkManager(); // Get our ChunkletManager
if (getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) { if (getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) {
getPermissionTools().generateWorldTeleportPermissions(); getPermissionTools().generateWorldTeleportPermissions();

View File

@ -1,7 +1,15 @@
package com.gmail.nossr50.util.blockmeta.chunkmeta; package com.gmail.nossr50.util.blockmeta.chunkmeta;
import com.gmail.nossr50.mcMMO;
public class ChunkManagerFactory { public class ChunkManagerFactory {
public static ChunkManager getChunkManager() { private final mcMMO pluginRef;
return new HashChunkManager();
public ChunkManagerFactory(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
public ChunkManager getChunkManager() {
return new HashChunkManager(pluginRef);
} }
} }

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.util.blockmeta.chunkmeta; package com.gmail.nossr50.util.blockmeta.chunkmeta;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory; import com.gmail.nossr50.util.blockmeta.conversion.BlockStoreConversionZDirectory;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -14,6 +15,11 @@ public class HashChunkManager implements ChunkManager {
public ArrayList<BlockStoreConversionZDirectory> converters = new ArrayList<>(); public ArrayList<BlockStoreConversionZDirectory> converters = new ArrayList<>();
private HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>> regionFiles = new HashMap<>(); private HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>> regionFiles = new HashMap<>();
private HashMap<UUID, Boolean> oldData = new HashMap<>(); private HashMap<UUID, Boolean> oldData = new HashMap<>();
private final mcMMO pluginRef;
public HashChunkManager(mcMMO pluginRef) {
this.pluginRef = pluginRef;
}
@Override @Override
public synchronized void closeAll() { public synchronized void closeAll() {
@ -438,7 +444,7 @@ public class HashChunkManager implements ChunkManager {
} }
if (!conversionSet) { if (!conversionSet) {
BlockStoreConversionZDirectory converter = new BlockStoreConversionZDirectory(); BlockStoreConversionZDirectory converter = new BlockStoreConversionZDirectory(pluginRef);
converter.start(world, cxDir, czDir); converter.start(world, cxDir, czDir);
converters.add(converter); converters.add(converter);
} }

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.util.blockmeta.conversion; package com.gmail.nossr50.util.blockmeta.conversion;
import com.gmail.nossr50.core.ChunkConversionOptions; import com.gmail.nossr50.core.ChunkConversionOptions;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import java.io.File; import java.io.File;
@ -12,8 +13,10 @@ public class BlockStoreConversionMain implements Runnable {
BlockStoreConversionXDirectory[] converters; BlockStoreConversionXDirectory[] converters;
private int taskID; private int taskID;
private org.bukkit.World world; private org.bukkit.World world;
private final mcMMO pluginRef;
public BlockStoreConversionMain(org.bukkit.World world) { public BlockStoreConversionMain(mcMMO pluginRef, org.bukkit.World world) {
this.pluginRef = pluginRef;
this.taskID = -1; this.taskID = -1;
this.world = world; this.world = world;
this.scheduler = pluginRef.getServer().getScheduler(); this.scheduler = pluginRef.getServer().getScheduler();

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.util.blockmeta.conversion; package com.gmail.nossr50.util.blockmeta.conversion;
import com.gmail.nossr50.core.ChunkConversionOptions; import com.gmail.nossr50.core.ChunkConversionOptions;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import java.io.File; import java.io.File;
@ -12,8 +13,10 @@ public class BlockStoreConversionXDirectory implements Runnable {
BlockStoreConversionZDirectory[] converters; BlockStoreConversionZDirectory[] converters;
private int taskID; private int taskID;
private org.bukkit.World world; private org.bukkit.World world;
private final mcMMO pluginRef;
public BlockStoreConversionXDirectory() { public BlockStoreConversionXDirectory(mcMMO pluginRef) {
this.pluginRef = pluginRef;
this.taskID = -1; this.taskID = -1;
} }
@ -53,7 +56,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
for (int i = 0; (i < ChunkConversionOptions.getConversionRate()) && (i < this.zDirs.length); i++) { for (int i = 0; (i < ChunkConversionOptions.getConversionRate()) && (i < this.zDirs.length); i++) {
if (this.converters[i] == null) { if (this.converters[i] == null) {
this.converters[i] = new BlockStoreConversionZDirectory(); this.converters[i] = new BlockStoreConversionZDirectory(pluginRef);
} }
this.converters[i].start(this.world, this.dataDir, this.zDirs[i]); this.converters[i].start(this.world, this.dataDir, this.zDirs[i]);

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.util.blockmeta.conversion; package com.gmail.nossr50.util.blockmeta.conversion;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.ChunkletStore; import com.gmail.nossr50.util.blockmeta.ChunkletStore;
import com.gmail.nossr50.util.blockmeta.HashChunkletManager; import com.gmail.nossr50.util.blockmeta.HashChunkletManager;
import com.gmail.nossr50.util.blockmeta.PrimitiveChunkletStore; import com.gmail.nossr50.util.blockmeta.PrimitiveChunkletStore;
@ -22,8 +23,10 @@ public class BlockStoreConversionZDirectory implements Runnable {
private PrimitiveChunkletStore primitiveChunklet = null; private PrimitiveChunkletStore primitiveChunklet = null;
private PrimitiveExChunkletStore primitiveExChunklet = null; private PrimitiveExChunkletStore primitiveExChunklet = null;
private PrimitiveChunkStore currentChunk; private PrimitiveChunkStore currentChunk;
private final mcMMO pluginRef;
public BlockStoreConversionZDirectory() { public BlockStoreConversionZDirectory(mcMMO pluginRef) {
this.pluginRef = pluginRef;
this.taskID = -1; this.taskID = -1;
} }