diff --git a/pom.xml b/pom.xml
index e37f58efd..c4f55bf16 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
UTF-8
PlotSquared
- 2.12.11
+ 2.12.12
PlotSquared
jar
diff --git a/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
index be8caf093..e5e07faab 100644
--- a/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
+++ b/src/main/java/com/intellectualcrafters/plot/BukkitMain.java
@@ -5,8 +5,12 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.net.URLClassLoader;
+import java.nio.file.Files;
import java.util.ArrayDeque;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Stack;
@@ -133,18 +137,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
} else {
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
}
-// File file = new File(this.getDirectory() + File.separator + "disabled.yml");
-// if (file.exists()) {
-// file.delete();
-// try {
-// String[] split = new String(Files.readAllBytes(file.toPath())).split(",");
-// for (String plugin : split) {
-// loadPlugin(plugin);
-// }
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-// }
List worlds = Bukkit.getWorlds();
if (worlds.size() > 0) {
UUIDHandler.cacheAll(worlds.get(0).getName());
@@ -162,12 +154,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public void onDisable() {
PS.get().disable();
- try {
- unloadRecursively(this);
- }
- catch (Exception e) {
- e.printStackTrace();
- };
THIS = null;
}
@@ -192,7 +178,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
@Override
public void disable() {
- onDisable();
+ if (THIS != null) {
+ onDisable();
+ }
}
@Override
@@ -420,163 +408,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
}, 20);
}
- public boolean unloadPlugin(Plugin plugin) {
- try {
- plugin.getClass().getClassLoader().getResources("*");
- } catch (IOException e1) {
- e1.printStackTrace();
- }
- PluginManager pm = Bukkit.getServer().getPluginManager();
- Map ln;
- List pl;
- try {
- Field lnF = pm.getClass().getDeclaredField("lookupNames");
- lnF.setAccessible(true);
- ln = (Map) lnF.get(pm);
-
- Field plF = pm.getClass().getDeclaredField("plugins");
- plF.setAccessible(true);
- pl = (List) plF.get(pm);
- } catch (Exception e) {
- e.printStackTrace();
- return false;
- }
- pm.disablePlugin(plugin);
- synchronized (pm) {
- ln.remove(plugin.getName());
- pl.remove(plugin);
- }
- JavaPluginLoader jpl = (JavaPluginLoader) plugin.getPluginLoader();
- Field loadersF = null;
- try {
- loadersF = jpl.getClass().getDeclaredField("loaders");
- loadersF.setAccessible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- try {
- Map loaderMap = (Map) loadersF.get(jpl);
- loaderMap.remove(plugin.getDescription().getName());
- } catch (Exception e) {
- e.printStackTrace();
- }
- closeClassLoader(plugin);
- System.gc();
- System.gc();
- return true;
- }
-
- public boolean closeClassLoader(Plugin plugin) {
- try {
- ((URLClassLoader) plugin.getClass().getClassLoader()).close();
- return true;
- } catch (IOException e) {
- e.printStackTrace();
- }
- return false;
- }
-
- public boolean unloadRecursively(Plugin plugin) {
- try {
- Stack pluginFiles = unloadRecursively(plugin.getName(), plugin, new Stack());
- File file = new File(this.getDirectory() + File.separator + "disabled.yml");
- file.createNewFile();
- String prefix = "";
- String all = "";
- while (pluginFiles.size() > 0) {
- String pop = pluginFiles.pop();
- all += prefix + pop.substring(0, pop.length() - 4);
- prefix = ",";
- }
- if (all.length() != 0) {
- PrintWriter out = new PrintWriter(this.getDirectory() + File.separator + "disabled.yml");
- out.write(all);
- out.close();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- return true;
- }
-
- @Override
- public void loadPlugin(String name) {
- try {
- PluginManager manager = Bukkit.getServer().getPluginManager();
- Plugin plugin = manager.getPlugin(name);
- if (plugin != null) {
- manager.enablePlugin(plugin);
- return;
- }
- plugin = manager.loadPlugin(new File("plugins" + File.separator + name + (name.endsWith(".jar") ? "" : ".jar")));
- plugin.onLoad();
- manager.enablePlugin(plugin);
- } catch (Exception e) {}
- }
-
- @Override
- public File getFile() {
- return getFile(this);
- }
-
- public File getFile(JavaPlugin p) {
- try {
- Field f = JavaPlugin.class.getDeclaredField("file");
- f.setAccessible(true);
- return (File) f.get(p);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public Stack unloadRecursively(String doNotLoad, Plugin plugin, Stack pluginFiles) {
- if (!plugin.getName().equals(doNotLoad)) {
- File file = getFile((JavaPlugin) plugin);
- pluginFiles.push(file.getName());
- }
- PluginManager pm = Bukkit.getPluginManager();
- for (Plugin p : pm.getPlugins()) {
- List depend = p.getDescription().getDepend();
- if (depend != null) {
- for (String s : depend) {
- if (s.equals(plugin.getName())) {
- unloadRecursively(doNotLoad, p, pluginFiles);
- }
- }
- }
- List softDepend = p.getDescription().getSoftDepend();
- if (softDepend != null) {
- for (String s : softDepend) {
- if (s.equals(plugin.getName())) {
- unloadRecursively(doNotLoad, p, pluginFiles);
- }
- }
- }
- }
- if (unloadPlugin(plugin)) {
- List depend = plugin.getDescription().getDepend();
- if (depend != null) {
- for (String s : depend) {
- Plugin p = pm.getPlugin(s);
- if (p != null) {
- unloadRecursively(doNotLoad, p, pluginFiles);
- }
- }
- }
- List softDepend = plugin.getDescription().getSoftDepend();
- if (softDepend != null) {
- for (String s : softDepend) {
- Plugin p = pm.getPlugin(s);
- if (p != null) {
- unloadRecursively(doNotLoad, p, pluginFiles);
- }
- }
- }
- }
- return pluginFiles;
- }
-
@Override
final public ChunkGenerator getDefaultWorldGenerator(final String world, final String id) {
WorldEvents.lastWorld = world;
diff --git a/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/src/main/java/com/intellectualcrafters/plot/IPlotMain.java
index 4ec0296c0..9e5880565 100644
--- a/src/main/java/com/intellectualcrafters/plot/IPlotMain.java
+++ b/src/main/java/com/intellectualcrafters/plot/IPlotMain.java
@@ -24,8 +24,6 @@ public interface IPlotMain {
public File getDirectory();
- public File getFile();
-
public void disable();
public String getVersion();
@@ -81,6 +79,4 @@ public interface IPlotMain {
public PlayerManager initPlayerManager();
public boolean checkVersion(int major, int minor, int minor2);
-
- public void loadPlugin(String plugin);
}
diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java
index 93df9817f..f14f890f1 100644
--- a/src/main/java/com/intellectualcrafters/plot/PS.java
+++ b/src/main/java/com/intellectualcrafters/plot/PS.java
@@ -10,7 +10,6 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
-import java.nio.file.StandardCopyOption;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
@@ -32,8 +31,6 @@ import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.bukkit.Bukkit;
-
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Configuration;
@@ -919,15 +916,14 @@ public class PS {
}
}
- public boolean update(URL url) {
+ public boolean update(PlotPlayer sender, URL url) {
if (url == null) {
return false;
}
try {
- File jar = PS.get().IMP.getFile();
File newJar = new File("plugins/update/PlotSquared.jar");
- PS.log("&6Downloading from provided URL: &7" + url);
- PS.log("&7 - User-Agent: " + "Mozilla/4.0");
+ MainUtil.sendMessage(sender, "$1Downloading from provided URL: &7" + url);
+ MainUtil.sendMessage(sender, "$2 - User-Agent: " + "Mozilla/4.0");
URLConnection con = url.openConnection();
con.addRequestProperty("User-Agent", "Mozilla/4.0");
InputStream stream = con.getInputStream();
@@ -935,31 +931,16 @@ public class PS {
if (!parent.exists()) {
parent.mkdirs();
}
- PS.log("&7 - Output: " + newJar);
+ MainUtil.sendMessage(sender, "$2 - Output: " + newJar);
newJar.delete();
Files.copy(stream, newJar.toPath());
stream.close();
- PS.log("&6Disabling PlotSquared");
- PS.get().IMP.disable();
- System.out.println("Deleting file: " + jar);
- jar.delete();
- System.out.println("Copying: " + jar + " >> " + newJar);
- try {
- Files.move(newJar.toPath(), jar.toPath(), StandardCopyOption.REPLACE_EXISTING);
- } catch (IOException e) {
- System.out.println("Failed to reload PlotSquared");
- System.out.println(" - Restart the server manually");
- System.out.println("============ Stacktrace ============");
- e.printStackTrace();
- System.out.println("====================================");
- return false;
- }
- Bukkit.reload();
+ MainUtil.sendMessage(sender, "$1The update will take effect when the server is restarted next");
return true;
}
catch (Exception e) {
- System.out.println("Failed to update PlotSquared");
- System.out.println(" - Please update manually");
+ MainUtil.sendMessage(sender, "Failed to update PlotSquared");
+ MainUtil.sendMessage(sender, " - Please update manually");
System.out.println("============ Stacktrace ============");
e.printStackTrace();
System.out.println("====================================");
@@ -1114,7 +1095,6 @@ public class PS {
for (final String flag : intFlags) {
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue()));
}
- FlagManager.addFlag(new AbstractFlag("modified-blocks", new FlagValue.IntegerValue()), true);
FlagManager.addFlag(new AbstractFlag("analysis", new FlagValue.IntegerListValue()), true);
FlagManager.addFlag(new AbstractFlag("disable-physics", new FlagValue.BooleanValue()));
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
@@ -1277,6 +1257,7 @@ public class PS {
options.put("chunk-processor.enabled", Settings.CHUNK_PROCESSOR);
options.put("chunk-processor.max-blockstates", Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES);
options.put("chunk-processor.max-entities", Settings.CHUNK_PROCESSOR_MAX_ENTITIES);
+ options.put("chunk-processor.disable-physics", Settings.CHUNK_PROCESSOR_DISABLE_PHYSICS);
// Comments
options.put("comments.notifications.enabled", Settings.COMMENT_NOTIFICATIONS);
@@ -1378,7 +1359,8 @@ public class PS {
// Chunk processor
Settings.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled");
Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES = config.getInt("chunk-processor.max-blockstates");
- Settings.CHUNK_PROCESSOR_MAX_ENTITIES= config.getInt("chunk-processor.max-entities");
+ Settings.CHUNK_PROCESSOR_MAX_ENTITIES = config.getInt("chunk-processor.max-entities");
+ Settings.CHUNK_PROCESSOR_DISABLE_PHYSICS = config.getBoolean("chunk-processor.disable-physics");
// Comments
Settings.COMMENT_NOTIFICATIONS = config.getBoolean("comments.notifications.enabled");
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Update.java b/src/main/java/com/intellectualcrafters/plot/commands/Update.java
index 1d46629ba..ab90cefa2 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Update.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Update.java
@@ -51,10 +51,6 @@ public class Update extends SubCommand {
@Override
public boolean execute(final PlotPlayer plr, final String... args) {
- if (plr != null) {
- MainUtil.sendMessage(plr, C.NOT_CONSOLE);
- return false;
- }
URL url;
if (args.length == 0) {
url = PS.get().update;
@@ -77,7 +73,9 @@ public class Update extends SubCommand {
MainUtil.sendMessage(plr, "&cTo manually specify an update URL: /plot update ");
return false;
}
- PS.get().update(url);
+ if (PS.get().update(plr, url) && url == PS.get().update) {
+ PS.get().update = null;
+ }
return true;
}
}
diff --git a/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/src/main/java/com/intellectualcrafters/plot/config/Settings.java
index e7d0d3f15..44bcf5dec 100644
--- a/src/main/java/com/intellectualcrafters/plot/config/Settings.java
+++ b/src/main/java/com/intellectualcrafters/plot/config/Settings.java
@@ -65,6 +65,7 @@ public class Settings {
public static boolean CHUNK_PROCESSOR = false;
public static int CHUNK_PROCESSOR_MAX_BLOCKSTATES = 4096;
public static int CHUNK_PROCESSOR_MAX_ENTITIES = 512;
+ public static boolean CHUNK_PROCESSOR_DISABLE_PHYSICS = false;
/**
* TNT listener
*/
diff --git a/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java b/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java
index 66d1d28f7..756b2502f 100644
--- a/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java
+++ b/src/main/java/com/intellectualcrafters/plot/listeners/ChunkListener.java
@@ -62,19 +62,11 @@ public class ChunkListener implements Listener {
}
}
- @EventHandler(priority=EventPriority.LOWEST)
+ @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void onBlockPhysics(BlockPhysicsEvent event) {
- long now = System.currentTimeMillis();
- if (now - last < 20) {
- if (count > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
- event.setCancelled(true);
- }
- count++;
+ if (Settings.CHUNK_PROCESSOR_DISABLE_PHYSICS) {
+ event.setCancelled(true);
}
- else {
- count = 0;
- }
- last = now;
}
@EventHandler(priority=EventPriority.LOWEST)
diff --git a/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java
index e5e6f260d..64dd40956 100644
--- a/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java
+++ b/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java
@@ -292,7 +292,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (cmd != null) {
return;
}
- if (split[0].equals("plotme") || split[0].equals("ap")) {
+ if (split[0].equals("plotme") || split[0].equals("ap") || split[0].equals("plotz")) {
final Player player = event.getPlayer();
if (Settings.USE_PLOTME_ALIAS) {
player.performCommand("plots " + StringUtils.join(Arrays.copyOfRange(split, 1, split.length), " "));
@@ -317,7 +317,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
}
}
- @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
BukkitUtil.removePlayer(player.getName());
@@ -336,7 +336,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
}
}
if (PS.get().update != null && pp.hasPermission("plots.admin")) {
- MainUtil.sendMessage(pp, "&6An update for PlotSquared is available: &7/plot update");
+ TaskManager.runTaskLater(new Runnable() {
+ @Override
+ public void run() {
+ MainUtil.sendMessage(pp, "&6An update for PlotSquared is available: &7/plot update");
+ }
+ }, 20);
}
final Location loc = BukkitUtil.getLocation(player.getLocation());
final Plot plot = MainUtil.getPlot(loc);