mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Added default home location optiom
This commit is contained in:
parent
f0cd6fa0ec
commit
3a40614bb2
@ -583,20 +583,24 @@ public class SQLManager implements AbstractDB {
|
|||||||
public void updateTables() {
|
public void updateTables() {
|
||||||
try {
|
try {
|
||||||
final DatabaseMetaData data = this.connection.getMetaData();
|
final DatabaseMetaData data = this.connection.getMetaData();
|
||||||
ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode");
|
ResultSet rs = data.getColumns(null, null, this.prefix + "plot_comments", "plot");
|
||||||
if (!rs.next()) {
|
if (rs.next()) {
|
||||||
rs.close();
|
rs = data.getColumns(null, null, this.prefix + "plot_comments", "hashcode");
|
||||||
final Statement statement = this.connection.createStatement();
|
if (!rs.next()) {
|
||||||
statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`");
|
rs.close();
|
||||||
if (PlotSquared.getMySQL() != null) {
|
final Statement statement = this.connection.createStatement();
|
||||||
statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`");
|
||||||
|
if (PlotSquared.getMySQL() != null) {
|
||||||
|
statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL," + "`timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")");
|
||||||
|
}
|
||||||
|
statement.executeBatch();
|
||||||
|
statement.close();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
statement.addBatch("CREATE TABLE IF NOT EXISTS `" + this.prefix + "plot_comments` (" + "`world` VARCHAR(40) NOT NULL, `hashcode` INT(11) NOT NULL," + "`comment` VARCHAR(40) NOT NULL," + "`inbox` VARCHAR(40) NOT NULL, `timestamp` INT(11) NOT NULL," + "`sender` VARCHAR(40) NOT NULL" + ")");
|
|
||||||
}
|
|
||||||
statement.executeBatch();
|
|
||||||
statement.close();
|
|
||||||
}
|
}
|
||||||
|
rs.close();
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -89,6 +89,8 @@ public abstract class PlotWorld {
|
|||||||
public boolean WORLD_BORDER;
|
public boolean WORLD_BORDER;
|
||||||
public int TYPE = 0;
|
public int TYPE = 0;
|
||||||
public int TERRAIN = 0;
|
public int TERRAIN = 0;
|
||||||
|
public boolean HOME_ALLOW_NONMEMBER;
|
||||||
|
public PlotLoc DEFAULT_HOME;
|
||||||
|
|
||||||
public PlotWorld(final String worldname) {
|
public PlotWorld(final String worldname) {
|
||||||
this.worldname = worldname;
|
this.worldname = worldname;
|
||||||
@ -143,6 +145,25 @@ public abstract class PlotWorld {
|
|||||||
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
this.SELL_PRICE = config.getDouble("economy.prices.sell");
|
||||||
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
this.PLOT_CHAT = config.getBoolean("chat.enabled");
|
||||||
this.WORLD_BORDER = config.getBoolean("world.border");
|
this.WORLD_BORDER = config.getBoolean("world.border");
|
||||||
|
|
||||||
|
this.HOME_ALLOW_NONMEMBER = config.getBoolean("home.allow-nonmembers");
|
||||||
|
String homeDefault = config.getString("home.default");
|
||||||
|
if (homeDefault.equalsIgnoreCase("side")) {
|
||||||
|
DEFAULT_HOME = null;
|
||||||
|
}
|
||||||
|
else if (homeDefault.equalsIgnoreCase("center")) {
|
||||||
|
DEFAULT_HOME = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
String[] split = homeDefault.split(",");
|
||||||
|
DEFAULT_HOME = new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
DEFAULT_HOME = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<String> flags = config.getStringList("flags.default");
|
List<String> flags = config.getStringList("flags.default");
|
||||||
if (flags == null || flags.size() == 0) {
|
if (flags == null || flags.size() == 0) {
|
||||||
flags = config.getStringList("flags");
|
flags = config.getStringList("flags");
|
||||||
@ -201,6 +222,10 @@ public abstract class PlotWorld {
|
|||||||
options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT);
|
options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT);
|
||||||
options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT);
|
options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT);
|
||||||
options.put("world.border", PlotWorld.WORLD_BORDER_DEFAULT);
|
options.put("world.border", PlotWorld.WORLD_BORDER_DEFAULT);
|
||||||
|
|
||||||
|
options.put("home.default", "side");
|
||||||
|
options.put("home.allow-nonmembers", false);
|
||||||
|
|
||||||
if (Settings.ENABLE_CLUSTERS && (this.TYPE != 0)) {
|
if (Settings.ENABLE_CLUSTERS && (this.TYPE != 0)) {
|
||||||
options.put("generator.terrain", this.TERRAIN);
|
options.put("generator.terrain", this.TERRAIN);
|
||||||
options.put("generator.type", this.TYPE);
|
options.put("generator.type", this.TYPE);
|
||||||
|
@ -97,7 +97,25 @@ public class MainUtil {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location getPlotFront(Plot plot) {
|
public static Location getDefaultHome(Plot plot) {
|
||||||
|
PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||||
|
if (plotworld.DEFAULT_HOME != null) {
|
||||||
|
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
||||||
|
final PlotManager manager = PlotSquared.getPlotManager(plot.world);
|
||||||
|
final int x;
|
||||||
|
final int z;
|
||||||
|
if (plotworld.DEFAULT_HOME.x == Integer.MAX_VALUE && plotworld.DEFAULT_HOME.z == Integer.MAX_VALUE) {
|
||||||
|
final Location top = getPlotTopLoc(plot.world, plot.id);
|
||||||
|
x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
||||||
|
z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
x = bot.getX() + plotworld.DEFAULT_HOME.x;
|
||||||
|
z = bot.getZ() + plotworld.DEFAULT_HOME.z;
|
||||||
|
}
|
||||||
|
final int y = Math.max(getHeighestBlock(plot.world, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(plot.world), plot).getY());
|
||||||
|
return new Location(plot.world, x, y, z);
|
||||||
|
}
|
||||||
final Location top = getPlotTopLoc(plot.world, plot.id);
|
final Location top = getPlotTopLoc(plot.world, plot.id);
|
||||||
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
final Location bot = getPlotBottomLoc(plot.world, plot.id);
|
||||||
final int x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
final int x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
||||||
@ -110,18 +128,15 @@ public class MainUtil {
|
|||||||
public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) {
|
public static boolean teleportPlayer(final PlotPlayer player, final Location from, final Plot plot) {
|
||||||
final Plot bot = MainUtil.getBottomPlot(plot);
|
final Plot bot = MainUtil.getBottomPlot(plot);
|
||||||
|
|
||||||
// TODO
|
|
||||||
// boolean result = PlotSquared.IMP.callPlayerTeleportToPlotEvent(player, from, plot);
|
|
||||||
boolean result = EventUtil.manager.callTeleport(player, from, plot);
|
boolean result = EventUtil.manager.callTeleport(player, from, plot);
|
||||||
// TOOD ^ remove that
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
final Location location;
|
final Location location;
|
||||||
if (plot.isAdded(player.getUUID())) {
|
if (PlotSquared.getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||||
location = MainUtil.getPlotHome(bot.world, bot);
|
location = MainUtil.getPlotHome(bot.world, bot);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
location = getPlotFront(plot);
|
location = getDefaultHome(plot);
|
||||||
}
|
}
|
||||||
if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||||
sendMessage(player, C.TELEPORTED_TO_PLOT);
|
sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||||
@ -531,7 +546,6 @@ public class MainUtil {
|
|||||||
h = (prime * h) + pos1.getZ();
|
h = (prime * h) + pos1.getZ();
|
||||||
state = h;
|
state = h;
|
||||||
System.currentTimeMillis();
|
System.currentTimeMillis();
|
||||||
final Location location = MainUtil.getPlotHomeDefault(plot);
|
|
||||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
||||||
runners.put(plot, 1);
|
runners.put(plot, 1);
|
||||||
if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) {
|
if (plotworld.TERRAIN != 0 || Settings.FAST_CLEAR) {
|
||||||
@ -622,16 +636,6 @@ public class MainUtil {
|
|||||||
return 64;
|
return 64;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
// for (int i = 1; i < world.getMaxHeight(); i++) {
|
|
||||||
// id = world.getBlockAt(x, i, z).getTypeId();
|
|
||||||
// if (id == 0) {
|
|
||||||
// if (safe) {
|
|
||||||
// return i;
|
|
||||||
// }
|
|
||||||
// safe = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return 64;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -648,30 +652,13 @@ public class MainUtil {
|
|||||||
final Location bot = getPlotBottomLoc(w, plotid);
|
final Location bot = getPlotBottomLoc(w, plotid);
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(w);
|
final PlotManager manager = PlotSquared.getPlotManager(w);
|
||||||
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
|
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
|
||||||
final Location top = getPlotTopLoc(w, plotid);
|
return getDefaultHome(plot);
|
||||||
final int x = ((top.getX() - bot.getX()) / 2) + bot.getX();
|
|
||||||
final int z = ((top.getZ() - bot.getZ()) / 2) + bot.getZ();
|
|
||||||
final int y = Math.max(getHeighestBlock(w, x, z), manager.getSignLoc(PlotSquared.getPlotWorld(w), plot).getY());
|
|
||||||
return new Location(w, x, y, z);
|
|
||||||
} else {
|
} else {
|
||||||
final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y);
|
final int y = Math.max(getHeighestBlock(w, home.x, home.z), home.y);
|
||||||
return bot.add(home.x, y, home.z);
|
return bot.add(home.x, y, home.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve the location of the default plot home position
|
|
||||||
*
|
|
||||||
* @param plot Plot
|
|
||||||
*
|
|
||||||
* @return the location
|
|
||||||
*/
|
|
||||||
public static Location getPlotHomeDefault(final Plot plot) {
|
|
||||||
final Location l = getPlotBottomLoc(plot.world, plot.getId()).subtract(0, 0, 0);
|
|
||||||
l.setY(getHeighestBlock(plot.world, l.getX(), l.getZ()));
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the plot home
|
* Get the plot home
|
||||||
*
|
*
|
||||||
|
@ -770,7 +770,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
if (plot.id.equals(id)) {
|
if (plot.id.equals(id)) {
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
final Player player = (Player) entity;
|
final Player player = (Player) entity;
|
||||||
BukkitUtil.getPlayer(player).teleport(MainUtil.getPlotFront(plot));
|
BukkitUtil.getPlayer(player).teleport(MainUtil.getDefaultHome(plot));
|
||||||
PlotListener.plotExit(player, plot);
|
PlotListener.plotExit(player, plot);
|
||||||
} else {
|
} else {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
|
Loading…
Reference in New Issue
Block a user