mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-28 03:34:42 +02:00
Fixes #524
This commit is contained in:
@ -19,16 +19,19 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.plot.IPlotMain;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.BlockUpdateUtil;
|
||||
@ -547,9 +550,40 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGenerator(String world) {
|
||||
public void setGenerator(String worldname) {
|
||||
World world = BukkitUtil.getWorld(worldname);
|
||||
if (world == null) {
|
||||
// create world
|
||||
|
||||
System.out.print("CREATING WORLD: " + worldname);
|
||||
System.out.print("CREATING WORLD: " + worldname);
|
||||
System.out.print("CREATING WORLD: " + worldname);
|
||||
System.out.print("CREATING WORLD: " + worldname);
|
||||
|
||||
ConfigurationSection worldConfig = PS.get().config.getConfigurationSection("worlds." + worldname);
|
||||
String manager = worldConfig.getString("generator.plugin");
|
||||
if (manager == null) {
|
||||
manager = "PlotSquared";
|
||||
}
|
||||
String generator = worldConfig.getString("generator.init");
|
||||
if (generator == null) {
|
||||
generator = manager;
|
||||
}
|
||||
|
||||
int type = worldConfig.getInt("generator.type");
|
||||
int terrain = worldConfig.getInt("generator.terrain");
|
||||
SetupObject setup = new SetupObject();
|
||||
setup.plotManager = manager;
|
||||
setup.setupGenerator = generator;
|
||||
setup.type = type;
|
||||
setup.terrain = terrain;
|
||||
setup.step = new ConfigurationNode[0];
|
||||
setup.world = worldname;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
SetGenCB.setGenerator(BukkitUtil.getWorld(world));
|
||||
SetGenCB.setGenerator(BukkitUtil.getWorld(worldname));
|
||||
} catch (Exception e) {
|
||||
log("Failed to reload world: " + world);
|
||||
Bukkit.getServer().unloadWorld(world, false);
|
||||
|
@ -99,7 +99,6 @@ public class AugmentedPopulator extends BlockPopulator {
|
||||
public void populate(final World world, final Random rand, final Chunk chunk) {
|
||||
final int cx = chunk.getX();
|
||||
final int cz = chunk.getZ();
|
||||
PS.log("== POPULATING FOR: " + world + " | " + cx + "," + cz);
|
||||
final int bx = cx << 4;
|
||||
final int bz = cz << 4;
|
||||
final int tx = bx + 15;
|
||||
|
@ -134,6 +134,7 @@ import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.RegExUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
@ -480,16 +481,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
plotEntry(pp, plot);
|
||||
}
|
||||
|
||||
public int getInt(double value) {
|
||||
return (int) (value < 0 ? value - 1 : value);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void PlayerMove(final PlayerMoveEvent event) {
|
||||
org.bukkit.Location from = event.getFrom();
|
||||
org.bukkit.Location to = event.getTo();
|
||||
int x2;
|
||||
if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
|
||||
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
@ -502,7 +499,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
PlotManager plotManager = PS.get().getPlotManager(worldname);
|
||||
PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
|
||||
PlotId id = plotManager.getPlotId(plotworld, x2, 0, MathMan.roundInt(to.getZ()));
|
||||
Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (id == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot)) {
|
||||
@ -552,7 +549,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
int z2;
|
||||
if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) {
|
||||
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ())) ) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
@ -1405,7 +1402,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
final org.bukkit.Location to = event.getTo();
|
||||
|
||||
int x2;
|
||||
if (getInt(from.getX()) != (x2 = getInt(to.getX()))) {
|
||||
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
@ -1418,7 +1415,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
PlotManager plotManager = PS.get().getPlotManager(worldname);
|
||||
PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
|
||||
PlotId id = plotManager.getPlotId(plotworld, x2, 0, MathMan.roundInt(to.getZ()));
|
||||
Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (id == null) {
|
||||
if (lastPlot == null) {
|
||||
@ -1471,7 +1468,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
||||
return;
|
||||
}
|
||||
int z2;
|
||||
if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) {
|
||||
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ())) ) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@ -10,6 +11,7 @@ import org.bukkit.WorldCreator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
@ -69,14 +71,17 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
if (object.setupGenerator != null) {
|
||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.setupGenerator);
|
||||
setGenerator(world, object.setupGenerator);
|
||||
} else {
|
||||
if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.setupGenerator);
|
||||
setGenerator(world, object.setupGenerator);
|
||||
} else {
|
||||
final WorldCreator wc = new WorldCreator(object.world);
|
||||
wc.generator(object.setupGenerator);
|
||||
wc.environment(Environment.NORMAL);
|
||||
Bukkit.createWorld(wc);
|
||||
setGenerator(world, object.setupGenerator);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -92,6 +97,21 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
}
|
||||
return object.world;
|
||||
}
|
||||
|
||||
public void setGenerator(String world, String generator) {
|
||||
if (Bukkit.getWorlds().size() == 0 || !Bukkit.getWorlds().get(0).getName().equals(world)) {
|
||||
return;
|
||||
}
|
||||
File file = new File("bukkit.yml").getAbsoluteFile();
|
||||
System.out.print(file.getAbsolutePath());
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(file);
|
||||
yml.set("worlds." + world + ".generator", generator);
|
||||
try {
|
||||
yml.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGenerator(PlotWorld plotworld) {
|
||||
|
@ -137,7 +137,7 @@ public class BukkitUtil extends BlockManager {
|
||||
}
|
||||
|
||||
public static Location getLocation(final org.bukkit.Location loc) {
|
||||
return new Location(loc.getWorld().getName(), (int) loc.getX(), (int) loc.getY(), (int) loc.getZ());
|
||||
return new Location(loc.getWorld().getName(), MathMan.roundInt(loc.getX()), MathMan.roundInt(loc.getY()), MathMan.roundInt(loc.getZ()));
|
||||
}
|
||||
|
||||
public static org.bukkit.Location getLocation(final Location loc) {
|
||||
@ -172,7 +172,7 @@ public class BukkitUtil extends BlockManager {
|
||||
|
||||
public static Location getLocationFull(final Entity entity) {
|
||||
org.bukkit.Location loc = entity.getLocation();
|
||||
return new Location(loc.getWorld().getName(), (int) loc.getX(), (int) loc.getY(), (int) loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||
return new Location(loc.getWorld().getName(), MathMan.roundInt(loc.getX()), MathMan.roundInt(loc.getY()), MathMan.roundInt(loc.getZ()), loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -64,7 +64,6 @@ public class SendChunk {
|
||||
if (!chunk.isLoaded()) {
|
||||
continue;
|
||||
}
|
||||
boolean unload = true;
|
||||
final Object c = methodGetHandle.of(chunk).call();
|
||||
final Object w = world.of(c).get();
|
||||
final Object p = players.of(w).get();
|
||||
@ -74,7 +73,6 @@ public class SendChunk {
|
||||
diffx = Math.abs(x - (chunk.getX() << 4));
|
||||
diffz = Math.abs(z - (chunk.getZ() << 4));
|
||||
if ((diffx <= view) && (diffz <= view)) {
|
||||
unload = false;
|
||||
if (v1_7_10) {
|
||||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
chunk.load(true);
|
||||
@ -86,9 +84,6 @@ public class SendChunk {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (unload) {
|
||||
chunk.unload(true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user