tweak blockpos abstraction

This commit is contained in:
nossr50 2019-02-13 10:22:58 -08:00
parent 9383b1c65c
commit 3a7b6fef7d
10 changed files with 67 additions and 52 deletions

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.core.data.blockmeta.chunkmeta;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import com.gmail.nossr50.core.mcmmo.block.Block;
import com.gmail.nossr50.core.mcmmo.block.BlockState;
import com.gmail.nossr50.core.mcmmo.entity.Entity;
import com.gmail.nossr50.core.mcmmo.world.World;
import java.io.IOException;

View File

@ -1,6 +1,6 @@
package com.gmail.nossr50.core.data.blockmeta.chunkmeta;
import org.bukkit.World;
import com.gmail.nossr50.core.mcmmo.world.World;
public class ChunkStoreFactory {
protected static ChunkStore getChunkStore(World world, int x, int z) {

View File

@ -1,11 +1,11 @@
package com.gmail.nossr50.core.data.blockmeta.chunkmeta;
import com.gmail.nossr50.core.data.blockmeta.blockmeta.conversion.BlockStoreConversionZDirectory;
import com.gmail.nossr50.mcMMO;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import com.gmail.nossr50.core.McmmoCore;
import com.gmail.nossr50.core.data.blockmeta.conversion.BlockStoreConversionZDirectory;
import com.gmail.nossr50.core.mcmmo.block.Block;
import com.gmail.nossr50.core.mcmmo.block.BlockState;
import com.gmail.nossr50.core.mcmmo.entity.Entity;
import com.gmail.nossr50.core.mcmmo.world.World;
import java.io.*;
import java.util.*;
@ -90,7 +90,7 @@ public class HashChunkManager implements ChunkManager {
directory.mkdirs();
UUID key = world.getUID();
UUID key = world.getUUID();
HashMap<Long, McMMOSimpleRegionFile> worldRegions = regionFiles.get(key);
@ -131,7 +131,7 @@ public class HashChunkManager implements ChunkManager {
return;
}
UUID key = world.getUID();
UUID key = world.getUUID();
if (!oldData.containsKey(key)) {
oldData.put(key, (new File(world.getWorldFolder(), "mcmmo_data")).exists());
@ -260,7 +260,7 @@ public class HashChunkManager implements ChunkManager {
public synchronized void saveAll() {
closeAll();
for (World world : mcMMO.p.getServer().getWorlds()) {
for (World world : McmmoCore.getServer().getWorlds()) {
saveWorld(world);
}
}
@ -269,7 +269,7 @@ public class HashChunkManager implements ChunkManager {
public synchronized void unloadAll() {
closeAll();
for (World world : mcMMO.p.getServer().getWorlds()) {
for (World world : McmmoCore.getServer().getWorlds()) {
unloadWorld(world);
}
}
@ -315,7 +315,7 @@ public class HashChunkManager implements ChunkManager {
return false;
}
return isTrue(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld());
return isTrue(blockState.getBlock().getX(), blockState.getBlock().getY(), blockState.getBlock().getZ(), blockState.getBlock().getWorld());
}
@Override
@ -361,7 +361,7 @@ public class HashChunkManager implements ChunkManager {
return;
}
setTrue(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld());
setTrue(blockState.getBlock().getX(), blockState.getBlock().getY(), blockState.getBlock().getZ(), blockState.getBlock().getWorld());
}
@Override
@ -406,7 +406,7 @@ public class HashChunkManager implements ChunkManager {
return;
}
setFalse(blockState.getX(), blockState.getY(), blockState.getZ(), blockState.getWorld());
setFalse(blockState.getBlock().getX(), blockState.getBlock().getY(), blockState.getBlock().getZ(), blockState.getBlock().getWorld());
}
@Override

View File

@ -1,9 +1,9 @@
package com.gmail.nossr50.core.data.blockmeta.chunkmeta;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import com.gmail.nossr50.core.mcmmo.block.Block;
import com.gmail.nossr50.core.mcmmo.block.BlockState;
import com.gmail.nossr50.core.mcmmo.entity.Entity;
import com.gmail.nossr50.core.mcmmo.world.World;
import java.io.IOException;

View File

@ -24,7 +24,7 @@ public class PrimitiveChunkStore implements ChunkStore {
public PrimitiveChunkStore(World world, int cx, int cz) {
this.cx = cx;
this.cz = cz;
this.worldUid = world.getUID();
this.worldUid = world.getUUID();
this.store = new boolean[16][16][world.getMaxHeight()];
}

View File

@ -6,31 +6,10 @@ package com.gmail.nossr50.core.mcmmo.block;
* @see Property
* @see BlockState
*/
public class Block {
private final String unlocalizedName; //The name before it is localized (english)
private BlockState blockState;
public Block(String unlocalizedName, BlockState blockState) {
this.unlocalizedName = unlocalizedName;
this.blockState = blockState;
}
public interface Block extends BlockPos {
/**
* Gets the name of this block in English
*
* @return name of this block in English
* Get the state for this block
* @return the block state
*/
public String getUnlocalizedName() {
return unlocalizedName;
}
/**
* Gets the state of this block
*
* @return the state of this block
*/
public BlockState getBlockState() {
return blockState;
}
BlockState getBlockState();
}

View File

@ -0,0 +1,21 @@
package com.gmail.nossr50.core.mcmmo.block;
import com.gmail.nossr50.core.mcmmo.world.World;
/**
* Block positions are handled a bit differently than other locations
*/
public interface BlockPos {
int getX();
int getY();
int getZ();
/**
* Gets the world for this block
* @return this block's world
*/
World getWorld();
}

View File

@ -19,21 +19,21 @@ public interface Location {
*
* @return x-axis position
*/
//double getX();
default double getX() { return getVector().getX(); }
/**
* Returns the position of this location on the y-axis
*
* @return y-axis position
*/
//double getY();
default double getY() { return getVector().getY(); }
/**
* Returns the position of this location on the z-axis
*
* @return z-axis position
*/
//double getZ();
default double getZ() { return getVector().getZ(); }
/**
* The world for this Location

View File

@ -2,6 +2,8 @@ package com.gmail.nossr50.core.mcmmo.world;
import com.gmail.nossr50.core.mcmmo.Unique;
import java.io.File;
/**
* Represents a world in MC
*/
@ -12,4 +14,17 @@ public interface World extends Unique {
* @return the name of this world
*/
String getName();
/**
* Gets the folder on disk for this world
*
* @return the folder on disk for this world
*/
File getWorldFolder();
/**
* Gets the max height for this world
* @return the max height
*/
int getMaxHeight();
}

View File

@ -32,7 +32,7 @@ public interface Platform {
*
* @return true if the platform is loaded
*/
Boolean isPlatformLoaded();
boolean isPlatformLoaded();
/**
* Gets the PlatformSoftwareType for this platform