mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-18 16:35:25 +01:00
tweak blockpos abstraction
This commit is contained in:
parent
9383b1c65c
commit
3a7b6fef7d
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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()];
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public interface Platform {
|
||||
*
|
||||
* @return true if the platform is loaded
|
||||
*/
|
||||
Boolean isPlatformLoaded();
|
||||
boolean isPlatformLoaded();
|
||||
|
||||
/**
|
||||
* Gets the PlatformSoftwareType for this platform
|
||||
|
Loading…
x
Reference in New Issue
Block a user