mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
World border
This commit is contained in:
parent
c8d396a1a5
commit
a29484a825
@ -928,22 +928,19 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - plotworld: &7" + plotWorld.getClass().getName());
|
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - plotworld: &7" + plotWorld.getClass().getName());
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - manager: &7" + plotManager.getClass().getName());
|
sendConsoleSenderMessage(C.PREFIX.s() + "&3 - manager: &7" + plotManager.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.contains(path)) {
|
if (!config.contains(path)) {
|
||||||
config.createSection(path);
|
config.createSection(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
plotWorld.saveConfiguration(config.getConfigurationSection(path));
|
plotWorld.saveConfiguration(config.getConfigurationSection(path));
|
||||||
plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path));
|
plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now add it
|
// Now add it
|
||||||
addPlotWorld(world, plotWorld, plotManager);
|
addPlotWorld(world, plotWorld, plotManager);
|
||||||
|
PlotHelper.setupBorder(world);
|
||||||
} else {
|
} else {
|
||||||
if (worlds.contains(world)) {
|
if (worlds.contains(world)) {
|
||||||
sendConsoleSenderMessage("&cWorld '" + world + "' in settings.yml is not using PlotSquared generator!");
|
sendConsoleSenderMessage("&cWorld '" + world + "' in settings.yml is not using PlotSquared generator!");
|
||||||
|
@ -37,6 +37,10 @@ import com.intellectualsites.translation.bukkit.BukkitTranslation;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public enum C {
|
public enum C {
|
||||||
|
/*
|
||||||
|
* Border
|
||||||
|
*/
|
||||||
|
BORDER("&cYou are outside the current map border"),
|
||||||
/*
|
/*
|
||||||
* Unclaim
|
* Unclaim
|
||||||
*/
|
*/
|
||||||
|
@ -93,7 +93,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
* @author Empire92
|
* @author Empire92
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused") public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void onWorldLoad(final WorldLoadEvent event) {
|
public static void onWorldLoad(final WorldLoadEvent event) {
|
||||||
@ -136,6 +136,24 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
|||||||
if (!isPlotWorld(player.getWorld())) {
|
if (!isPlotWorld(player.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String worldname = q.getWorld().getName();
|
||||||
|
if (PlotHelper.worldBorder.containsKey(worldname)) {
|
||||||
|
int border = PlotHelper.worldBorder.get(worldname);
|
||||||
|
boolean passed = false;
|
||||||
|
if (t.getBlockX() >= border) {
|
||||||
|
q.setX(border);
|
||||||
|
passed = true;
|
||||||
|
}
|
||||||
|
if (t.getBlockZ() >= border) {
|
||||||
|
q.setZ(border);
|
||||||
|
passed = true;
|
||||||
|
}
|
||||||
|
if (passed) {
|
||||||
|
event.setTo(q);
|
||||||
|
PlayerFunctions.sendMessage(player, C.BORDER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (enteredPlot(f, q)) {
|
if (enteredPlot(f, q)) {
|
||||||
final Plot plot = getCurrentPlot(q);
|
final Plot plot = getCurrentPlot(q);
|
||||||
final boolean admin = PlotMain.hasPermission(player, "plots.admin.entry.denied");
|
final boolean admin = PlotMain.hasPermission(player, "plots.admin.entry.denied");
|
||||||
|
@ -58,6 +58,7 @@ public abstract class PlotWorld {
|
|||||||
public final static boolean SPAWN_EGGS_DEFAULT = false;
|
public final static boolean SPAWN_EGGS_DEFAULT = false;
|
||||||
public final static boolean SPAWN_CUSTOM_DEFAULT = true;
|
public final static boolean SPAWN_CUSTOM_DEFAULT = true;
|
||||||
public final static boolean SPAWN_BREEDING_DEFAULT = false;
|
public final static boolean SPAWN_BREEDING_DEFAULT = false;
|
||||||
|
public final static boolean WORLD_BORDER_DEFAULT = false;
|
||||||
// TODO make this configurable
|
// TODO make this configurable
|
||||||
// make non static and static_default_valu + add config option
|
// make non static and static_default_valu + add config option
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -285,6 +286,7 @@ public abstract class PlotWorld {
|
|||||||
public boolean SPAWN_EGGS;
|
public boolean SPAWN_EGGS;
|
||||||
public boolean SPAWN_CUSTOM;
|
public boolean SPAWN_CUSTOM;
|
||||||
public boolean SPAWN_BREEDING;
|
public boolean SPAWN_BREEDING;
|
||||||
|
public boolean WORLD_BORDER;
|
||||||
|
|
||||||
public PlotWorld(final String worldname) {
|
public PlotWorld(final String worldname) {
|
||||||
this.worldname = worldname;
|
this.worldname = worldname;
|
||||||
@ -308,6 +310,7 @@ public abstract class PlotWorld {
|
|||||||
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
|
this.MERGE_PRICE = config.getDouble("economy.prices.merge");
|
||||||
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");
|
||||||
List<String> flags = config.getStringList("flags.default");
|
List<String> flags = config.getStringList("flags.default");
|
||||||
if (flags == null) {
|
if (flags == null) {
|
||||||
this.DEFAULT_FLAGS = new Flag[] {};
|
this.DEFAULT_FLAGS = new Flag[] {};
|
||||||
@ -357,6 +360,7 @@ public abstract class PlotWorld {
|
|||||||
options.put("event.spawn.egg", PlotWorld.SPAWN_EGGS_DEFAULT);
|
options.put("event.spawn.egg", PlotWorld.SPAWN_EGGS_DEFAULT);
|
||||||
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);
|
||||||
final ConfigurationNode[] settings = getSettingNodes();
|
final ConfigurationNode[] settings = getSettingNodes();
|
||||||
/*
|
/*
|
||||||
* Saving generator specific settings
|
* Saving generator specific settings
|
||||||
|
@ -64,9 +64,27 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
public static boolean canSendChunk = false;
|
public static boolean canSendChunk = false;
|
||||||
public static ArrayList<String> runners_p = new ArrayList<>();
|
public static ArrayList<String> runners_p = new ArrayList<>();
|
||||||
static long state = 1;
|
static long state = 1;
|
||||||
public static HashMap<String, PlotId> lastPlot;
|
public static HashMap<String, PlotId> lastPlot = new HashMap<>();
|
||||||
public static HashMap<String, Integer> worldBorder;
|
public static HashMap<String, Integer> worldBorder = new HashMap<>();
|
||||||
|
|
||||||
|
public static int getBorder(World world) {
|
||||||
|
String worldname = world.getName();
|
||||||
|
if (worldBorder.containsKey(worldname)) {
|
||||||
|
return worldBorder.get(worldname);
|
||||||
|
}
|
||||||
|
return Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupBorder(String world) {
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
|
if (!plotworld.WORLD_BORDER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Plot plot : PlotMain.getPlots(world).values()) {
|
||||||
|
updateWorldBorder(plot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* direction 0 = north, 1 = south, etc:
|
* direction 0 = north, 1 = south, etc:
|
||||||
*
|
*
|
||||||
@ -434,8 +452,27 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void updateWorldBorder(Plot plot) {
|
||||||
|
String world = plot.world;
|
||||||
|
PlotManager manager = PlotMain.getPlotManager(world);
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings(world);
|
||||||
|
Location bot = manager.getPlotBottomLocAbs(plotworld, plot.id);
|
||||||
|
Location top = manager.getPlotTopLocAbs(plotworld, plot.id);
|
||||||
|
int border = worldBorder.get(plot.world);
|
||||||
|
int botmax = Math.max(Math.abs(bot.getBlockX()), Math.abs(bot.getBlockZ()));
|
||||||
|
int topmax = Math.max(Math.abs(top.getBlockX()), Math.abs(top.getBlockZ()));
|
||||||
|
int max = Math.max(botmax, topmax);
|
||||||
|
if (max > border ) {
|
||||||
|
worldBorder.put(plot.world, max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean createPlot(final Player player, final Plot plot) {
|
public static boolean createPlot(final Player player, final Plot plot) {
|
||||||
|
|
||||||
|
if (PlotHelper.worldBorder.containsKey(plot.world)) {
|
||||||
|
updateWorldBorder(plot);
|
||||||
|
}
|
||||||
final World w = plot.getWorld();
|
final World w = plot.getWorld();
|
||||||
final Plot p = new Plot(plot.id, UUIDHandler.getUUID(player), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
final Plot p = new Plot(plot.id, UUIDHandler.getUUID(player), plot.settings.getBiome(), new ArrayList<UUID>(), new ArrayList<UUID>(), w.getName());
|
||||||
PlotMain.updatePlot(p);
|
PlotMain.updatePlot(p);
|
||||||
|
Loading…
Reference in New Issue
Block a user