Modernize Paper and region API usage
This commit is contained in:
2
TODO.md
2
TODO.md
@@ -16,7 +16,7 @@
|
||||
| MET-012 | Done | Replace deprecated configuration APIs with the modern Bukkit/Paper configuration API, including load, save, and reload behavior. |
|
||||
| MET-013 | Done | Replace Player-keyed storage with UUID-based storage wherever player identity is persisted or tracked. |
|
||||
| MET-014 | Done | Review player lookup logic and use exact or otherwise explicit name-matching behavior where appropriate. |
|
||||
| MET-015 | Ready | Refactor remaining code that uses deprecated or removed Bukkit, Spigot, or Paper APIs so it is compatible with the target Paper API. |
|
||||
| MET-015 | Done | Refactor remaining code that uses deprecated or removed Bukkit, Spigot, or Paper APIs so it is compatible with the target Paper API. |
|
||||
| MET-016 | Ready | Add fast unit tests for plot and home allocation, reservation validation, player lookup and UUID-based ownership, configuration persistence, command validation, and event behavior. Keep domain rules independent of a running Minecraft server and mock external plugin boundaries as needed. |
|
||||
| MET-017 | Ready | Add a separate Gradle `integrationTest` source set/task for tests requiring an actual Paper server and compatible WorldGuard/WorldEdit plugins. Verify plugin loading, command registration and dispatch, region-backed reservations and home allocation, and persistence across a server restart. Run it only when explicitly requested; keep it out of the normal `test` and `build` tasks. |
|
||||
| MET-018 | Ready | Build the plugin with Gradle and use the provided server scripts to smoke-test it on modern Paper with its required plugins installed. |
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
@Embeddable
|
||||
public class Cuboid implements Comparable<Cuboid> {
|
||||
private int id;
|
||||
|
||||
@@ -38,13 +34,13 @@ public class Cuboid implements Comparable<Cuboid> {
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public Cuboid(BlockVector min, BlockVector max) {
|
||||
this.minX = min.getBlockX();
|
||||
this.minY = min.getBlockY();
|
||||
this.minZ = min.getBlockZ();
|
||||
this.maxX = max.getBlockX();
|
||||
this.maxY = max.getBlockY();
|
||||
this.maxZ = max.getBlockZ();
|
||||
public Cuboid(BlockVector3 min, BlockVector3 max) {
|
||||
this.minX = min.x();
|
||||
this.minY = min.y();
|
||||
this.minZ = min.z();
|
||||
this.maxX = max.x();
|
||||
this.maxY = max.y();
|
||||
this.maxZ = max.z();
|
||||
}
|
||||
|
||||
public Cuboid() {
|
||||
@@ -56,46 +52,46 @@ public class Cuboid implements Comparable<Cuboid> {
|
||||
this.maxZ = 0;
|
||||
}
|
||||
|
||||
public Cuboid(Selection selection) {
|
||||
this.minX = selection.getMinimumPoint().getBlockX();
|
||||
this.minY = selection.getMinimumPoint().getBlockY();
|
||||
this.minZ = selection.getMinimumPoint().getBlockZ();
|
||||
this.maxX = selection.getMaximumPoint().getBlockX();
|
||||
this.maxY = selection.getMaximumPoint().getBlockY();
|
||||
this.maxZ = selection.getMaximumPoint().getBlockZ();
|
||||
public Cuboid(Region selection) {
|
||||
this.minX = selection.getMinimumPoint().x();
|
||||
this.minY = selection.getMinimumPoint().y();
|
||||
this.minZ = selection.getMinimumPoint().z();
|
||||
this.maxX = selection.getMaximumPoint().x();
|
||||
this.maxY = selection.getMaximumPoint().y();
|
||||
this.maxZ = selection.getMaximumPoint().z();
|
||||
}
|
||||
|
||||
public BlockVector getMin(){
|
||||
return new BlockVector(minX, minY, minZ);
|
||||
public BlockVector3 getMin(){
|
||||
return BlockVector3.at(minX, minY, minZ);
|
||||
}
|
||||
|
||||
public BlockVector getMax(){
|
||||
return new BlockVector(maxX, maxY, maxZ);
|
||||
public BlockVector3 getMax(){
|
||||
return BlockVector3.at(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Cuboid o) {
|
||||
BlockVector min = getMin();
|
||||
BlockVector otherMin = o.getMin();
|
||||
BlockVector3 min = getMin();
|
||||
BlockVector3 otherMin = o.getMin();
|
||||
|
||||
if(min.getBlockX() < otherMin.getBlockX()){
|
||||
if(min.x() < otherMin.x()){
|
||||
return -1;
|
||||
}else if(min.getBlockX() > otherMin.getBlockX()){
|
||||
}else if(min.x() > otherMin.x()){
|
||||
return 1;
|
||||
}else if(min.getBlockZ() < otherMin.getBlockZ()){
|
||||
}else if(min.z() < otherMin.z()){
|
||||
return -1;
|
||||
}else if(min.getBlockZ() > otherMin.getBlockZ()){
|
||||
}else if(min.z() > otherMin.z()){
|
||||
return 1;
|
||||
}else if(min.getBlockY() < otherMin.getBlockY()){
|
||||
}else if(min.y() < otherMin.y()){
|
||||
return -1;
|
||||
}else if(min.getBlockY() > otherMin.getBlockY()){
|
||||
}else if(min.y() > otherMin.y()){
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int compareBlockVectors(BlockVector v1, BlockVector v2){
|
||||
public static int compareBlockVectors(BlockVector3 v1, BlockVector3 v2){
|
||||
if(v1 == null){
|
||||
if(v2 == null){
|
||||
return 0;
|
||||
@@ -105,24 +101,24 @@ public class Cuboid implements Comparable<Cuboid> {
|
||||
}else if(v2 == null){
|
||||
return 1;
|
||||
}
|
||||
if(v1.getBlockX() < v2.getBlockX()){
|
||||
if(v1.x() < v2.x()){
|
||||
return -1;
|
||||
}else if(v1.getBlockX() > v2.getBlockX()){
|
||||
}else if(v1.x() > v2.x()){
|
||||
return 1;
|
||||
}else if(v1.getBlockZ() < v2.getBlockZ()){
|
||||
}else if(v1.z() < v2.z()){
|
||||
return -1;
|
||||
}else if(v1.getBlockZ() > v2.getBlockZ()){
|
||||
}else if(v1.z() > v2.z()){
|
||||
return 1;
|
||||
}else if(v1.getBlockY() < v2.getBlockY()){
|
||||
}else if(v1.y() < v2.y()){
|
||||
return -1;
|
||||
}else if(v1.getBlockY() > v2.getBlockY()){
|
||||
}else if(v1.y() > v2.y()){
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBlockLessThan(BlockVector v1, BlockVector v2) {
|
||||
public static boolean isBlockLessThan(BlockVector3 v1, BlockVector3 v2) {
|
||||
return compareBlockVectors(v1, v2) < 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,13 @@ import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeMoveComman
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotGoCommand;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotReserveCommand;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.eventlisteners.PlayerJoinListener;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@@ -209,7 +211,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
gridSizeY = world.getMaxHeight();
|
||||
gridSizeZ = plotSizeZ + roadWidth;
|
||||
|
||||
regionManager = worldGuard.getRegionManager(world);
|
||||
regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world));
|
||||
if(regionManager == null){
|
||||
throw new RuntimeException("WorldGuard regions don't seem to be enabled.");
|
||||
}
|
||||
@@ -218,15 +220,15 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
if(_cityRegion == null){
|
||||
_cityRegion = new ProtectedCuboidRegion("City", getPlotMin(0, 0, 1), this.getPlotMax(0, 0, 1));
|
||||
_cityRegion.setPriority(0);
|
||||
_cityRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.LAVA_FLOW, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.SNOW_FALL, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.PVP, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.ENDER_BUILD, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.TNT, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.LAVA_FLOW, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(Flags.SNOW_FALL, StateFlag.State.DENY);
|
||||
regionManager.addRegion(_cityRegion);
|
||||
}
|
||||
|
||||
@@ -236,15 +238,15 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
if(_spawnRegion == null){
|
||||
_spawnRegion = new ProtectedCuboidRegion("Spawn", getPlotMin(0, 0, 1), getPlotMax(0, 0, 1));
|
||||
_spawnRegion.setPriority(1);
|
||||
_spawnRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.LAVA_FLOW, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.SNOW_FALL, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.PVP, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.ENDER_BUILD, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.TNT, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.LAVA_FLOW, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(Flags.SNOW_FALL, StateFlag.State.DENY);
|
||||
regionManager.addRegion(_spawnRegion);
|
||||
|
||||
_spawnCuboid = new Cuboid(_spawnRegion.getMinimumPoint(), _spawnRegion.getMaximumPoint());
|
||||
@@ -372,8 +374,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
private Cuboid getCuboid(int row, int col) {
|
||||
//This is only used for debug info
|
||||
BlockVector min = getPlotMin(row, col, 1);
|
||||
BlockVector max = getPlotMax(row, col, 1);
|
||||
BlockVector3 min = getPlotMin(row, col, 1);
|
||||
BlockVector3 max = getPlotMax(row, col, 1);
|
||||
return new Cuboid(min, max);
|
||||
}
|
||||
|
||||
@@ -696,8 +698,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
material != Material.WATER &&
|
||||
material != Material.LAVA &&
|
||||
material != Material.TORCH &&
|
||||
material != Material.REDSTONE_TORCH_OFF &&
|
||||
material != Material.REDSTONE_TORCH_ON;
|
||||
material != Material.REDSTONE_TORCH;
|
||||
}
|
||||
|
||||
private boolean isPhysicsMaterial(Material material) {
|
||||
@@ -796,8 +797,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
if(cityRegion instanceof ProtectedCuboidRegion){
|
||||
ProtectedCuboidRegion region = (ProtectedCuboidRegion)cityRegion;
|
||||
|
||||
BlockVector min;
|
||||
BlockVector max;
|
||||
BlockVector3 min;
|
||||
BlockVector3 max;
|
||||
|
||||
min = getPlotMin(-size/2, -size/2, 1);
|
||||
max = getPlotMax(size/2, size/2, 1);
|
||||
@@ -821,35 +822,35 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
return iSize;
|
||||
}
|
||||
|
||||
public BlockVector getPlotMin(int row, int col, int plotMultiplier){
|
||||
BlockVector gridMin = getGridMin(row, col, plotMultiplier);
|
||||
public BlockVector3 getPlotMin(int row, int col, int plotMultiplier){
|
||||
BlockVector3 gridMin = getGridMin(row, col, plotMultiplier);
|
||||
|
||||
BlockVector bv = new BlockVector(gridMin.getBlockX() + roadWidth/2, gridMin.getBlockY(), gridMin.getBlockZ() + roadWidth/2);
|
||||
getLogger().info(String.format("getPlotMin (%d, %d, %d)", bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()));
|
||||
BlockVector3 bv = BlockVector3.at(gridMin.x() + roadWidth/2, gridMin.y(), gridMin.z() + roadWidth/2);
|
||||
getLogger().info(String.format("getPlotMin (%d, %d, %d)", bv.x(), bv.y(), bv.z()));
|
||||
return bv;
|
||||
}
|
||||
|
||||
public BlockVector getPlotMax(int row, int col, int plotMultiplier){
|
||||
BlockVector gridMax = getGridMax(row, col, plotMultiplier);
|
||||
public BlockVector3 getPlotMax(int row, int col, int plotMultiplier){
|
||||
BlockVector3 gridMax = getGridMax(row, col, plotMultiplier);
|
||||
|
||||
BlockVector bv = new BlockVector(gridMax.getBlockX() - (roadWidth - roadWidth/2), gridMax.getBlockY(), gridMax.getBlockZ() - (roadWidth-roadWidth/2));
|
||||
getLogger().info(String.format("getPlotMax (%d, %d, %d)", bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()));
|
||||
BlockVector3 bv = BlockVector3.at(gridMax.x() - (roadWidth - roadWidth/2), gridMax.y(), gridMax.z() - (roadWidth-roadWidth/2));
|
||||
getLogger().info(String.format("getPlotMax (%d, %d, %d)", bv.x(), bv.y(), bv.z()));
|
||||
return bv;
|
||||
}
|
||||
|
||||
public BlockVector getGridMin(int row, int col, int plotMultiplier){
|
||||
public BlockVector3 getGridMin(int row, int col, int plotMultiplier){
|
||||
int level = 0;
|
||||
|
||||
BlockVector bv = new BlockVector(col * gridSizeX, level * gridSizeY, row * gridSizeZ);
|
||||
getLogger().info(String.format("getGridMin (%d, %d, %d)", bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()));
|
||||
BlockVector3 bv = BlockVector3.at(col * gridSizeX, level * gridSizeY, row * gridSizeZ);
|
||||
getLogger().info(String.format("getGridMin (%d, %d, %d)", bv.x(), bv.y(), bv.z()));
|
||||
return bv;
|
||||
}
|
||||
|
||||
public BlockVector getGridMax(int row, int col, int plotMultiplier){
|
||||
public BlockVector3 getGridMax(int row, int col, int plotMultiplier){
|
||||
int level = 0;
|
||||
|
||||
BlockVector bv = new BlockVector((col+plotMultiplier) * gridSizeX*plotMultiplier-1, (level+1/*plotMultiplier*/) * gridSizeY-1, (row+plotMultiplier) * gridSizeZ-1);
|
||||
getLogger().info(String.format("getGridMax (%d, %d, %d)", bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()));
|
||||
BlockVector3 bv = BlockVector3.at((col+plotMultiplier) * gridSizeX*plotMultiplier-1, (level+1/*plotMultiplier*/) * gridSizeY-1, (row+plotMultiplier) * gridSizeZ-1);
|
||||
getLogger().info(String.format("getGridMax (%d, %d, %d)", bv.x(), bv.y(), bv.z()));
|
||||
return bv;
|
||||
}
|
||||
|
||||
@@ -861,7 +862,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
return (cuboid.minZ - roadWidth/2)/gridSizeZ;
|
||||
}
|
||||
|
||||
private void setHomeOccupied(UUID ownerId, String ownerName, int homeNumber, BlockVector minimumPoint, BlockVector maximumPoint) {
|
||||
private void setHomeOccupied(UUID ownerId, String ownerName, int homeNumber, BlockVector3 minimumPoint, BlockVector3 maximumPoint) {
|
||||
PlayerHome home = new PlayerHome(ownerId, ownerName, homeNumber, minimumPoint, maximumPoint);
|
||||
if(!_occupiedPlots.contains(home)){
|
||||
_occupiedPlots.add(home);
|
||||
@@ -897,13 +898,13 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
getLogger().info("Metropolis Generating home in " + homeCuboid.toString());
|
||||
|
||||
ProtectedCuboidRegion newHomeRegion = new ProtectedCuboidRegion(regionName, homeCuboid.getMin(), homeCuboid.getMax());
|
||||
newHomeRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(Flags.PVP, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(Flags.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(Flags.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(Flags.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(Flags.ENDER_BUILD, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(Flags.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(Flags.TNT, StateFlag.State.DENY);
|
||||
|
||||
DefaultDomain d = newHomeRegion.getOwners();
|
||||
d.addPlayer(playerId);
|
||||
@@ -925,12 +926,12 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
}
|
||||
getLogger().info(String.format(
|
||||
"New home region (%d, %d, %d) (%d, %d, %d)",
|
||||
newHomeRegion.getMinimumPoint().getBlockX(),
|
||||
newHomeRegion.getMinimumPoint().getBlockY(),
|
||||
newHomeRegion.getMinimumPoint().getBlockZ(),
|
||||
newHomeRegion.getMaximumPoint().getBlockX(),
|
||||
newHomeRegion.getMaximumPoint().getBlockY(),
|
||||
newHomeRegion.getMaximumPoint().getBlockZ()
|
||||
newHomeRegion.getMinimumPoint().x(),
|
||||
newHomeRegion.getMinimumPoint().y(),
|
||||
newHomeRegion.getMinimumPoint().z(),
|
||||
newHomeRegion.getMaximumPoint().x(),
|
||||
newHomeRegion.getMaximumPoint().y(),
|
||||
newHomeRegion.getMaximumPoint().z()
|
||||
));
|
||||
|
||||
setHomeOccupied(playerId, playerName, homeNumber, newHomeRegion.getMinimumPoint(), newHomeRegion.getMaximumPoint());
|
||||
@@ -957,7 +958,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
private void generateSign(Cuboid plotCuboid, String playerName) {
|
||||
Block signBlock = world.getBlockAt(plotCuboid.getCenterX(), roadLevel+1, plotCuboid.getCenterZ());
|
||||
signBlock.setType(Material.SIGN_POST);
|
||||
signBlock.setType(Material.OAK_SIGN);
|
||||
Sign sign = (Sign)signBlock.getState();
|
||||
sign.setLine(0, "Home of");
|
||||
|
||||
@@ -982,15 +983,15 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
public void reserveCuboid(String regionName, Cuboid cuboid) {
|
||||
ProtectedCuboidRegion reservedRegion = new ProtectedCuboidRegion(regionName, cuboid.getMin(), cuboid.getMax());
|
||||
reservedRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(DefaultFlag.LAVA_FLOW, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(DefaultFlag.SNOW_FALL, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.PVP, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.ENDER_BUILD, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.TNT, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.LAVA_FLOW, StateFlag.State.DENY);
|
||||
reservedRegion.setFlag(Flags.SNOW_FALL, StateFlag.State.DENY);
|
||||
regionManager.addRegion(reservedRegion);
|
||||
|
||||
_occupiedPlots.add(Plot.get(reservedRegion));
|
||||
|
||||
@@ -3,22 +3,15 @@ package com.majinnaibu.bukkitplugins.metropolis;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.avaje.ebean.validation.NotNull;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
@Entity()
|
||||
@Table(name="Metropolis_PlayerHome")
|
||||
public class PlayerHome extends Plot{
|
||||
private UUID playerId;
|
||||
@NotNull
|
||||
private String playerName;
|
||||
public UUID getPlayerId(){return this.playerId;}
|
||||
public String getPlayerName(){return this.playerName;}
|
||||
@@ -26,7 +19,7 @@ public class PlayerHome extends Plot{
|
||||
|
||||
private int number;
|
||||
|
||||
public PlayerHome(UUID ownerId, String ownerName, int homeNumber, BlockVector min, BlockVector max) {
|
||||
public PlayerHome(UUID ownerId, String ownerName, int homeNumber, BlockVector3 min, BlockVector3 max) {
|
||||
super(String.format("h_%d_%s", homeNumber, ownerId), min, max);
|
||||
this.playerId = ownerId;
|
||||
this.playerName = ownerName;
|
||||
|
||||
@@ -1,39 +1,28 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import com.avaje.ebean.validation.NotNull;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
@Entity()
|
||||
@Table(name="Metropolis_Plot")
|
||||
public class Plot implements Comparable<Plot>{
|
||||
@Id
|
||||
private int _id;
|
||||
public int getId(){return _id;}
|
||||
public void setId(int id){_id = id;}
|
||||
|
||||
@NotNull
|
||||
|
||||
private Cuboid _cuboid;
|
||||
public Cuboid getCuboid(){return _cuboid;}
|
||||
public void setCuboid(Cuboid cuboid){_cuboid = cuboid;}
|
||||
|
||||
@NotNull
|
||||
private String _regionName;
|
||||
public String getRegionName(){return _regionName;}
|
||||
public void setRegionName(String regionName){_regionName = regionName;}
|
||||
|
||||
public Plot(String regionName, BlockVector min, BlockVector max){
|
||||
public Plot(String regionName, BlockVector3 min, BlockVector3 max){
|
||||
_cuboid = new Cuboid(min, max);
|
||||
_regionName = regionName;
|
||||
}
|
||||
@@ -48,17 +37,17 @@ public class Plot implements Comparable<Plot>{
|
||||
_regionName = "";
|
||||
}
|
||||
|
||||
public BlockVector getPlotMin(int roadWidth) {
|
||||
return new BlockVector(_cuboid.minX - roadWidth/2, _cuboid.minY, _cuboid.minZ - roadWidth/2);
|
||||
public BlockVector3 getPlotMin(int roadWidth) {
|
||||
return BlockVector3.at(_cuboid.minX - roadWidth/2, _cuboid.minY, _cuboid.minZ - roadWidth/2);
|
||||
}
|
||||
|
||||
public int getRow(int roadWidth, int plotSizeZ){
|
||||
BlockVector min = getPlotMin(roadWidth);
|
||||
return min.getBlockZ() / plotSizeZ;
|
||||
BlockVector3 min = getPlotMin(roadWidth);
|
||||
return min.z() / plotSizeZ;
|
||||
}
|
||||
|
||||
public int getCol(int roadWidth, int plotSizeX){
|
||||
return getPlotMin(roadWidth).getBlockX() / plotSizeX;
|
||||
return getPlotMin(roadWidth).x() / plotSizeX;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.Flags;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
@@ -19,25 +19,25 @@ public class MetropolisFlagResetCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
ProtectedRegion cityRegion = _plugin.regionManager.getRegion("City");
|
||||
cityRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.LAVA_FLOW, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(DefaultFlag.SNOW_FALL, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.PVP, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.ENDER_BUILD, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.TNT, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.LAVA_FLOW, StateFlag.State.DENY);
|
||||
cityRegion.setFlag(Flags.SNOW_FALL, StateFlag.State.DENY);
|
||||
|
||||
for(ProtectedRegion homeRegion: _plugin.regionManager.getRegions().values()){
|
||||
if(homeRegion.getId().startsWith("h_")){
|
||||
homeRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(Flags.PVP, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(Flags.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(Flags.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(Flags.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(Flags.ENDER_BUILD, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(Flags.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(Flags.TNT, StateFlag.State.DENY);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
public class MetropolisPlotReserveCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
@@ -27,9 +29,15 @@ public class MetropolisPlotReserveCommand implements CommandExecutor {
|
||||
Cuboid cuboid = new Cuboid();
|
||||
|
||||
if(sender instanceof Player && args.length == 1){
|
||||
Selection selection = _plugin.worldEdit.getSelection((Player) sender);
|
||||
cuboid = new Cuboid(selection);
|
||||
}else if(args.length == 6){
|
||||
try {
|
||||
Region selection = _plugin.worldEdit.getSession((Player) sender)
|
||||
.getSelection(BukkitAdapter.adapt(_plugin.getWorld()));
|
||||
cuboid = new Cuboid(selection);
|
||||
} catch (IncompleteRegionException ex) {
|
||||
sender.sendMessage("Select a WorldEdit region first.");
|
||||
return false;
|
||||
}
|
||||
}else if(args.length == 7){
|
||||
try{
|
||||
minX = Integer.parseInt(args[1]);
|
||||
minY = Integer.parseInt(args[2]);
|
||||
@@ -41,7 +49,7 @@ public class MetropolisPlotReserveCommand implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}else if(args.length == 4){
|
||||
}else if(args.length == 5){
|
||||
try{
|
||||
minX = Integer.parseInt(args[1]);
|
||||
minY = 0;
|
||||
|
||||
Reference in New Issue
Block a user