Moved project out of subfolder.
This commit is contained in:
@@ -0,0 +1,231 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
@Embeddable
|
||||
public class Cuboid implements Comparable<Cuboid> {
|
||||
private int id;
|
||||
|
||||
public int minX;
|
||||
public int minY;
|
||||
public int minZ;
|
||||
|
||||
public int maxX;
|
||||
public int maxY;
|
||||
public int maxZ;
|
||||
|
||||
public int getId(){
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Cuboid(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
|
||||
this.minX = minX;
|
||||
this.minY = minY;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
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() {
|
||||
this.minX = 0;
|
||||
this.minY = 0;
|
||||
this.minZ = 0;
|
||||
this.maxX = 0;
|
||||
this.maxY = 0;
|
||||
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 BlockVector getMin(){
|
||||
return new BlockVector(minX, minY, minZ);
|
||||
}
|
||||
|
||||
public BlockVector getMax(){
|
||||
return new BlockVector(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Cuboid o) {
|
||||
BlockVector min = getMin();
|
||||
BlockVector otherMin = o.getMin();
|
||||
|
||||
if(min.getBlockX() < otherMin.getBlockX()){
|
||||
return -1;
|
||||
}else if(min.getBlockX() > otherMin.getBlockX()){
|
||||
return 1;
|
||||
}else if(min.getBlockZ() < otherMin.getBlockZ()){
|
||||
return -1;
|
||||
}else if(min.getBlockZ() > otherMin.getBlockZ()){
|
||||
return 1;
|
||||
}else if(min.getBlockY() < otherMin.getBlockY()){
|
||||
return -1;
|
||||
}else if(min.getBlockY() > otherMin.getBlockY()){
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int compareBlockVectors(BlockVector v1, BlockVector v2){
|
||||
Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
if(v1 == null){
|
||||
if(v2 == null){
|
||||
log.info("in Cuboid.compareBlockVectors v1 and v2 are null");
|
||||
return 0;
|
||||
}else{
|
||||
log.info("in Cubiod.compareBlockVectors v1 is null");
|
||||
return -1;
|
||||
}
|
||||
}else if(v2 == null){
|
||||
log.info("in Cubiod.compareBlockVectors v2 is null");
|
||||
return 1;
|
||||
}
|
||||
log.info(String.format("v1.x: %d, v1.y: %d, v1.z: %d, v2.x: %d, v2.y: %d, v2.z: %d", v1.getBlockX(), v1.getBlockY(), v1.getBlockZ(), v2.getBlockX(), v2.getBlockY(), v2.getBlockZ()));
|
||||
if(v1.getBlockX() < v2.getBlockX()){
|
||||
return -1;
|
||||
}else if(v1.getBlockX() > v2.getBlockX()){
|
||||
return 1;
|
||||
}else if(v1.getBlockZ() < v2.getBlockZ()){
|
||||
return -1;
|
||||
}else if(v1.getBlockZ() > v2.getBlockZ()){
|
||||
return 1;
|
||||
}else if(v1.getBlockY() < v2.getBlockY()){
|
||||
return -1;
|
||||
}else if(v1.getBlockY() > v2.getBlockY()){
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBlockLessThan(BlockVector v1, BlockVector v2) {
|
||||
return compareBlockVectors(v1, v2) < 0;
|
||||
}
|
||||
|
||||
public Cuboid inset(int amount){
|
||||
return inset(amount, amount, amount);
|
||||
}
|
||||
|
||||
public Cuboid inset(int x, int z){
|
||||
return inset(x, 0, z);
|
||||
}
|
||||
|
||||
public Cuboid inset(int x, int y, int z){
|
||||
return new Cuboid(this.minX + x, this.minY, this.minZ + z, this.maxX - x, this.maxY, this.maxZ - z);
|
||||
}
|
||||
|
||||
public int getVolume() {
|
||||
return (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ);
|
||||
}
|
||||
public int getMinX(){return minX;}
|
||||
public void setMinX(int minX){this.minX = minX;}
|
||||
public int getMinY(){return minY;}
|
||||
public void setMinY(int minY){this.minY = minY;}
|
||||
public int getMinZ(){return minZ;}
|
||||
public void setMinZ(int minZ){this.minZ = minZ;}
|
||||
public int getMaxX(){return maxX;}
|
||||
public void setMaxX(int maxX){this.maxX = maxX;}
|
||||
public int getMaxY(){return maxY;}
|
||||
public void setMaxY(int maxY){this.maxY = maxY;}
|
||||
public int getMaxZ(){return maxZ;}
|
||||
public void setMaxZ(int maxZ){this.maxZ = maxZ;}
|
||||
|
||||
public Cuboid outset(int amount) {
|
||||
return outset(amount, amount, amount);
|
||||
}
|
||||
|
||||
public Cuboid outset(int x, int z){
|
||||
return outset(x, 0, z);
|
||||
}
|
||||
|
||||
public Cuboid outset(int x, int y, int z) {
|
||||
return new Cuboid(this.minX - x, this.minY - y, this.minZ - z, this.maxX + x, this.maxY + y, this.maxZ + z);
|
||||
}
|
||||
|
||||
public int getCenterX(){
|
||||
return (this.minX + this.maxX) /2;
|
||||
}
|
||||
|
||||
public int getCenterY(){
|
||||
return (this.minY + this.maxY)/2;
|
||||
}
|
||||
|
||||
public int getCenterZ(){
|
||||
return (this.minZ + this.maxZ)/2;
|
||||
}
|
||||
|
||||
public boolean intersects(Cuboid other) {
|
||||
if (this.maxX >= other.minX && this.minX <= other.maxX)
|
||||
{
|
||||
if (this.maxZ >= other.minZ && this.minZ <= other.maxZ)
|
||||
{
|
||||
if (this.maxY >= other.minY && this.minY <= other.maxY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean contains(Location bedSpawn) {
|
||||
if(this.minX > bedSpawn.getBlockX() || this.maxX < bedSpawn.getBlockX()){
|
||||
return false;
|
||||
}else if(this.minZ > bedSpawn.getBlockZ() || this.maxZ < bedSpawn.getBlockZ()){
|
||||
return false;
|
||||
}else if(this.minY > bedSpawn.getBlockY() || this.maxY < bedSpawn.getBlockY()){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("{Cuboid minX=%d, minY=%d, minZ=%d, maxX=%d, maxY=%d, maxZ=%d}", minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,100 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.avaje.ebean.validation.NotNull;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
@Entity()
|
||||
@Table(name="Metropolis_PlayerHome")
|
||||
public class PlayerHome extends Plot{
|
||||
@NotNull
|
||||
private String playerName;
|
||||
public String getPlayerName(){return this.playerName;}
|
||||
public void setPlayerName(String playerName){this.playerName = playerName;}
|
||||
|
||||
private int number;
|
||||
|
||||
public PlayerHome(String owner, BlockVector min, BlockVector max) {
|
||||
super("h_" + owner, min, max);
|
||||
this.playerName = owner;
|
||||
}
|
||||
|
||||
public PlayerHome() {
|
||||
this.playerName = "";
|
||||
}
|
||||
|
||||
public PlayerHome(ProtectedRegion homeRegion){
|
||||
try{
|
||||
String rname = homeRegion.getId();
|
||||
|
||||
if(rname.startsWith("h_")){
|
||||
int secondUnderscore = rname.indexOf('_', 2);
|
||||
if(secondUnderscore > 2){
|
||||
try{
|
||||
this.number = Integer.parseInt(rname.substring(2, secondUnderscore));
|
||||
this.playerName = rname.substring(secondUnderscore+1);
|
||||
}catch(Exception ex){
|
||||
this.number = 0;
|
||||
}
|
||||
}else{
|
||||
this.number = 0;
|
||||
this.playerName = rname.substring(2);
|
||||
}
|
||||
|
||||
setCuboid(new Cuboid(homeRegion.getMinimumPoint(), homeRegion.getMaximumPoint()));
|
||||
}
|
||||
else{
|
||||
throw new RuntimeException("Method not implemented.");
|
||||
}
|
||||
}catch(Exception ex){
|
||||
throw new RuntimeException("Method not implemented.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if(!(other instanceof PlayerHome)){
|
||||
return super.equals(other);
|
||||
}
|
||||
|
||||
PlayerHome otherPlayerHome = (PlayerHome)other;
|
||||
|
||||
if(!this.playerName.equals(otherPlayerHome.playerName)){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!getCuboid().equals(otherPlayerHome.getCuboid())){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public String toFriendlyString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(String.format("Metropolis Home {Owner: %s min: (%d, %d, %d) max: (%d, %d, %d)}", getPlayerName(), getCuboid().getMinX(), getCuboid().getMinY(), getCuboid().getMinZ(), getCuboid().getMaxX(), getCuboid().getMaxY(), getCuboid().getMaxZ()));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static PlayerHome get(ProtectedRegion homeRegion){
|
||||
if(homeRegion instanceof ProtectedCuboidRegion){
|
||||
return new PlayerHome((ProtectedCuboidRegion) homeRegion);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(int number){
|
||||
this.number = number;
|
||||
}
|
||||
}
|
||||
130
src/main/java/com/majinnaibu/bukkitplugins/metropolis/Plot.java
Normal file
130
src/main/java/com/majinnaibu/bukkitplugins/metropolis/Plot.java
Normal file
@@ -0,0 +1,130 @@
|
||||
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.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){
|
||||
_cuboid = new Cuboid(min, max);
|
||||
_regionName = regionName;
|
||||
}
|
||||
|
||||
public Plot(ProtectedCuboidRegion cuboid){
|
||||
_cuboid = new Cuboid(cuboid.getMinimumPoint(), cuboid.getMaximumPoint());
|
||||
_regionName = cuboid.getId();
|
||||
}
|
||||
|
||||
public Plot(){
|
||||
_cuboid = new Cuboid();
|
||||
_regionName = "";
|
||||
}
|
||||
|
||||
public BlockVector getPlotMin(int roadWidth) {
|
||||
return new BlockVector(_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;
|
||||
}
|
||||
|
||||
public int getCol(int roadWidth, int plotSizeX){
|
||||
return getPlotMin(roadWidth).getBlockX() / plotSizeX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if(!(other instanceof Plot)){
|
||||
return super.equals(other);
|
||||
}
|
||||
|
||||
Plot otherPlayerHome = (Plot)other;
|
||||
|
||||
if(!getCuboid().equals(otherPlayerHome.getCuboid())){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Plot another) {
|
||||
return getCuboid().compareTo(another.getCuboid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(String.format("{PlayerHome }"));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static Plot get(ProtectedRegion region){
|
||||
if(region instanceof ProtectedCuboidRegion){
|
||||
return new Plot((ProtectedCuboidRegion) region);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String toFriendlyString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append(String.format("Metropolis Reserved Plot {min: (%d, %d, %d) max: (%d, %d, %d)}", getCuboid().getMinX(), getCuboid().getMinY(), getCuboid().getMinZ(), getCuboid().getMaxX(), getCuboid().getMaxY(), getCuboid().getMaxZ()));
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public boolean contains(Location bedSpawn) {
|
||||
return _cuboid.contains(bedSpawn);
|
||||
}
|
||||
|
||||
public Location getViableSpawnLocation(World world) {
|
||||
Cuboid cuboid = getCuboid();
|
||||
for(int y=cuboid.maxY-1; y>= cuboid.minY; y--){
|
||||
for(int x=cuboid.minX; x<= cuboid.maxX; x++){
|
||||
for(int z=cuboid.minZ; z<= cuboid.maxZ; z++){
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
Block blockAbove = world.getBlockAt(x, y+1, z);
|
||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
||||
if(block.getType() == Material.AIR & blockAbove.getType() == Material.AIR && blockUnder.getType() != Material.AIR){
|
||||
return new Location(world, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
public class UserOverride {
|
||||
private String _username;
|
||||
private int _plotMultiplier;
|
||||
private int _maxPlots;
|
||||
|
||||
public String getUsername(){return _username;}
|
||||
public int getPlotMultiplier(){return _plotMultiplier;}
|
||||
public int getMaxPlots(){return _maxPlots;}
|
||||
|
||||
public UserOverride(String username, int plotMultiplier, int maxPlots){
|
||||
_username = username;
|
||||
_plotMultiplier = plotMultiplier;
|
||||
_maxPlots = maxPlots;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisCommand implements CommandExecutor {
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
sender.sendMessage("Metropolis: version "+ _plugin.pdf.getVersion());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisDebugGenerateTestHomesCommand implements CommandExecutor {
|
||||
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisDebugGenerateTestHomesCommand(MetropolisPlugin plugin) {
|
||||
_plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
try{
|
||||
int numHomes = Integer.parseInt(args[0]);
|
||||
for(int i=1; i<= numHomes; i++){
|
||||
_plugin.generateHome(String.format("test%d", i));
|
||||
}
|
||||
|
||||
return true;
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
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.StateFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class MetropolisFlagResetCommand implements CommandExecutor {
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisFlagResetCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@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);
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage("Metropolis: flags have been reset");
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisHomeAcquire implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeAcquire(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if(!(sender instanceof Player)){
|
||||
sender.sendMessage("This command can only be used by players");
|
||||
return false;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(_plugin.getNumPlots(player.getName()) >= _plugin.getMaxPlots(player.getName())){
|
||||
sender.sendMessage("You cannot have any more plots");
|
||||
return false;
|
||||
}
|
||||
|
||||
_plugin.assignPlot(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class MetropolisHomeEvictCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin = null;
|
||||
|
||||
public MetropolisHomeEvictCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
//get the player and region
|
||||
String playerName = "";
|
||||
|
||||
if(args.length == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args.length >= 1){
|
||||
playerName = args[0];
|
||||
}
|
||||
|
||||
OfflinePlayer player = _plugin.getServer().getOfflinePlayer(playerName);
|
||||
if(player == null){
|
||||
sender.sendMessage(String.format("The requested player {%s}does not appear to exist.", playerName));
|
||||
return false;
|
||||
}
|
||||
|
||||
ProtectedRegion region = _plugin.getRegion(String.format("h_%s", player.getName()));
|
||||
if(region == null){
|
||||
sender.sendMessage(String.format("The player {%s} has no home to be evicted from."));
|
||||
return false;
|
||||
}
|
||||
|
||||
//remove the player as owner and/or member of the region
|
||||
region.getMembers().removePlayer(playerName);
|
||||
region.getOwners().removePlayer(playerName);
|
||||
|
||||
//if the region has no owners delete the region
|
||||
if(region.getMembers().size() == 0 && region.getOwners().size() == 0){
|
||||
_plugin.removeRegion(region.getId());
|
||||
}
|
||||
|
||||
_plugin.saveRegions();
|
||||
|
||||
//?optionally regen the region
|
||||
//_plugin.worldEdit.getCommand("regen").execute(_plugin.getServer().getConsoleSender(), "regen", new String[]{});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisHomeGenerateCommand implements CommandExecutor {
|
||||
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeGenerateCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(args.length < 1){
|
||||
return false;
|
||||
}
|
||||
|
||||
_plugin.generateHome(args[0]);
|
||||
|
||||
sender.sendMessage("[Metropolis] Home generated for " + args[0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
||||
|
||||
public class MetropolisHomeGoCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin = null;
|
||||
|
||||
public MetropolisHomeGoCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
if(sender instanceof Player){
|
||||
player = (Player)sender;
|
||||
|
||||
if(args.length >= 1){
|
||||
if(player.hasPermission("")){
|
||||
player = _plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if(player == null){
|
||||
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage("Permission denied");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if(args.length >= 1){
|
||||
player = _plugin.getServer().getPlayer(args[0]);
|
||||
|
||||
if(player == null){
|
||||
sender.sendMessage(String.format("Unable to find player %s", args[0]));
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
sender.sendMessage("You must be a player");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerHome home = _plugin.getPlayerHome(player);
|
||||
|
||||
Location loc = null;
|
||||
Location bedSpawn = player.getBedSpawnLocation();
|
||||
|
||||
if(home.contains(bedSpawn)){
|
||||
loc = bedSpawn;
|
||||
}else {
|
||||
loc = home.getViableSpawnLocation(_plugin.getWorld());
|
||||
}
|
||||
|
||||
if(loc != null){
|
||||
player.teleport(loc);
|
||||
}else{
|
||||
if(sender == player){
|
||||
sender.sendMessage("There is no valid spawn location in your home");
|
||||
}else{
|
||||
sender.sendMessage(String.format("There is no valid spawn location in %s's home", player.getName()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.Plot;
|
||||
|
||||
public class MetropolisHomeListCommand implements CommandExecutor {
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeListCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for(Plot cityBlock : _plugin.getCityBlocks()){
|
||||
sender.sendMessage(String.format("%s", cityBlock.toFriendlyString()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class MetropolisHomeMoveCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisHomeMoveCommand(MetropolisPlugin plugin) {
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
OfflinePlayer player = null;
|
||||
int newHomeNumber = 0;
|
||||
|
||||
if(sender instanceof OfflinePlayer){
|
||||
player = (OfflinePlayer)sender;
|
||||
}
|
||||
|
||||
if(args.length == 1){
|
||||
try{
|
||||
newHomeNumber = Integer.parseInt(args[0]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
}else if(args.length >= 2){
|
||||
try{
|
||||
newHomeNumber = Integer.parseInt(args[0]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
|
||||
player = _plugin.getOfflinePlayer(args[1]);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(player == null || !_plugin.homeExists(player.getName(), newHomeNumber)){
|
||||
return false;
|
||||
}
|
||||
|
||||
_plugin.setHome(player.getName(), newHomeNumber);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.Plot;
|
||||
|
||||
public class MetropolisPlotGoCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisPlotGoCommand(MetropolisPlugin plugin) {
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
Plot plot = null;
|
||||
|
||||
if(sender instanceof Player){
|
||||
player = (Player) sender;
|
||||
}
|
||||
|
||||
if(args.length == 1 && player != null){
|
||||
plot = _plugin.getPlot(args[0]);
|
||||
}else if(args.length >= 2){
|
||||
player = _plugin.getPlayer(args[1]);
|
||||
plot = _plugin.getPlot(args[0]);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(plot == null || player == null){
|
||||
return false;
|
||||
}
|
||||
|
||||
String errorMessage = _plugin.teleportPlayerToPlot(player, plot);
|
||||
if(errorMessage != null){
|
||||
sender.sendMessage(errorMessage);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
public class MetropolisPlotReserveCommand implements CommandExecutor {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisPlotReserveCommand(MetropolisPlugin metropolisPlugin) {
|
||||
_plugin = metropolisPlugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
int minX = 0;
|
||||
int minY = 0;
|
||||
int minZ = 0;
|
||||
int maxX = 0;
|
||||
int maxY = 0;
|
||||
int maxZ = 0;
|
||||
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{
|
||||
minX = Integer.parseInt(args[1]);
|
||||
minY = Integer.parseInt(args[2]);
|
||||
minZ = Integer.parseInt(args[3]);
|
||||
maxX = Integer.parseInt(args[4]);
|
||||
maxY = Integer.parseInt(args[5]);
|
||||
maxZ = Integer.parseInt(args[6]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}else if(args.length == 4){
|
||||
try{
|
||||
minX = Integer.parseInt(args[1]);
|
||||
minY = 0;
|
||||
minZ = Integer.parseInt(args[2]);
|
||||
maxX = Integer.parseInt(args[3]);
|
||||
maxY = _plugin.getWorld().getMaxHeight();
|
||||
maxZ = Integer.parseInt(args[4]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
cuboid = new Cuboid(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
String regionName = args[0];
|
||||
|
||||
_plugin.reserveCuboid(regionName, cuboid);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.eventlisteners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
|
||||
public class DebugListener implements Listener {
|
||||
MetropolisPlugin _plugin;
|
||||
|
||||
public DebugListener(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onEvent(PlayerInteractEvent event){
|
||||
//event.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.eventlisteners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.Cuboid;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
private MetropolisPlugin _plugin = null;
|
||||
|
||||
public PlayerJoinListener(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event){
|
||||
Player player = event.getPlayer();
|
||||
if(player == null){
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerHome home = _plugin.getPlayerHome(player);
|
||||
if(home==null){MetropolisPlugin.log.info("home is null");}
|
||||
else if(home.getCuboid() == null){MetropolisPlugin.log.info("home.getCuboid() is null");}
|
||||
else if(home.getCuboid().getVolume() == 0){MetropolisPlugin.log.info("home.getCuboid().getVolume() is 0");}
|
||||
|
||||
if(home == null || home.getCuboid() == null || home.getCuboid().getVolume() == 0){
|
||||
MetropolisPlugin.log.info(String.format("Metropolis: Unable to get or create home for player %s", player.getName()));
|
||||
}else{
|
||||
Cuboid cuboid = home.getCuboid();
|
||||
player.sendMessage(String.format("Metropolis: Welcome %s your home is between (%d, %d, %d) and (%d, %d, %d)", player.getName(), cuboid.getMinX(), cuboid.getMinY(), cuboid.getMinZ(), cuboid.getMaxX(), cuboid.getMaxY(), cuboid.getMaxZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.util;
|
||||
|
||||
public class Material {
|
||||
public static final int signTypeId = 63;
|
||||
}
|
||||
19
src/main/resources/Examples/Multiple Plot Sizes.txt
Normal file
19
src/main/resources/Examples/Multiple Plot Sizes.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
Goal: Have 1 plot size for mods and 1 plot size for normals.
|
||||
Implementation:
|
||||
1. Set the plotSize in the config to the larger plot size there are other possible sizes but powers of 2 work really well so lets give mods a 64x64 plot. Roads are recomended but will eat into the plot on all sides so the roadsize can be ignored for this example.
|
||||
2. Start the server and run /metropolis-home-generate <username> for each mod.
|
||||
3. If you have not completed a full ring then run /metropolis-home-generate <test n> where n starts at 1 and increases until you have filled a full ring. This will reserve those plots for later or anyone who happens to have that username, but that can be dealth with later.
|
||||
4. Stop the server and change the plotSize to a smaller number like 32.
|
||||
5. Restart the server and let your users log in.
|
||||
|
||||
Notes:
|
||||
All users will be assigned a small plot when they first connect. When you make them a mod just delete their current region and change the name of one of the reserved home regions to h_<their username>.
|
||||
/region remove h_jonnynewadmin
|
||||
/region select test_1
|
||||
/region remove test_1
|
||||
/region define h_johnnynewadmin
|
||||
JohnnyNewAdmin's old home will become available for resettlement. If you want to copy johnny's old blocks into his new home region I'd suggest WorldEdit.
|
||||
This process including optionally copying the blocks will be an upcoming feature. Probably in 0.5.x and maybe in 0.6.
|
||||
|
||||
If you later run out of larger plots you can just set the size back to the larger number and let more generate. Moving and evictions will be coming soon and make this easier.
|
||||
You can manually just create a region for a user before they login named like h_<username> if you want a specific user to have a really big space as well.
|
||||
0
src/main/resources/Examples/Multiple Plots.txt
Normal file
0
src/main/resources/Examples/Multiple Plots.txt
Normal file
35
src/main/resources/config.yml
Normal file
35
src/main/resources/config.yml
Normal file
@@ -0,0 +1,35 @@
|
||||
plot:
|
||||
sizeX: 32
|
||||
sizeY: 256
|
||||
sizeZ: 32
|
||||
offsetX: 0
|
||||
offsetY: 0
|
||||
offsetZ: 0
|
||||
multiplier: 1
|
||||
maxPerPlayer: 1
|
||||
initial: 1
|
||||
floor:
|
||||
generate: true
|
||||
clearSpaceAbove: 66
|
||||
material: 2
|
||||
supports:
|
||||
generate: true
|
||||
material: 1
|
||||
sign:
|
||||
generate: true
|
||||
road:
|
||||
width: 4
|
||||
clearSpaceAbove: 66
|
||||
level: 62
|
||||
material: 4
|
||||
supports:
|
||||
generate: true
|
||||
material: 1
|
||||
spawn:
|
||||
generate: true
|
||||
setAsWorldSpawn: true
|
||||
material: 2
|
||||
wall:
|
||||
generate: true
|
||||
material: 7
|
||||
height: 66
|
||||
10
src/main/resources/plugin.yml
Normal file
10
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
name: Metropolis
|
||||
main: com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin
|
||||
depend: [WorldGuard]
|
||||
softdepend: [WorldEdit,CommandBook]
|
||||
version: 0.5
|
||||
database: false
|
||||
commands:
|
||||
metropolis:
|
||||
description: This command displays the current metropolis version.
|
||||
usage: /metropolis
|
||||
Reference in New Issue
Block a user