This commit is contained in:
boy0001
2015-08-09 19:58:29 +10:00
parent 051449157a
commit e28c68ee74
14 changed files with 113 additions and 49 deletions

View File

@ -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) {

View File

@ -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());
}
////////////////////////////////////////////////////////////////////////

View File

@ -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);
}
}
}