Add crash-mitigation option.

This commit is contained in:
Jesse Boyd 2016-02-09 21:15:03 +11:00
parent 9f1bf51467
commit 7cfb33dd3b
5 changed files with 54 additions and 25 deletions

10
pom.xml
View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>FastAsyncWorldEdit</artifactId> <artifactId>FastAsyncWorldEdit</artifactId>
<version>1.3.0</version> <version>1.3.1</version>
<name>FastAsyncWorldEdit</name> <name>FastAsyncWorldEdit</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>
@ -113,14 +113,14 @@
</plugins> </plugins>
</build> </build>
<repositories> <repositories>
<repository>
<id>techcable-repo</id>
<url>http://repo.techcable.net/content/groups/public/</url>
</repository>
<repository> <repository>
<id>empcraft-repo</id> <id>empcraft-repo</id>
<url>http://empcraft.com/maven2</url> <url>http://empcraft.com/maven2</url>
</repository> </repository>
<repository>
<id>techcable-repo</id>
<url>http://repo.techcable.net/content/groups/public/</url>
</repository>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>http://hub.spigotmc.org/nexus/content/groups/public/</url> <url>http://hub.spigotmc.org/nexus/content/groups/public/</url>

View File

@ -49,7 +49,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
} }
return worldedit; return worldedit;
} }
@Override @Override
public void onEnable() { public void onEnable() {
try { try {
@ -66,7 +66,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
getServer().shutdown(); getServer().shutdown();
} }
} }
@Override @Override
public void debug(final String s) { public void debug(final String s) {
getLogger().info(ChatColor.translateAlternateColorCodes('&', s)); getLogger().info(ChatColor.translateAlternateColorCodes('&', s));
@ -146,22 +146,34 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
final Plugin worldguardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"); final Plugin worldguardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
final ArrayList<FaweMaskManager> managers = new ArrayList<>(); final ArrayList<FaweMaskManager> managers = new ArrayList<>();
if ((worldguardPlugin != null) && worldguardPlugin.isEnabled()) { if ((worldguardPlugin != null) && worldguardPlugin.isEnabled()) {
managers.add(new Worldguard(worldguardPlugin, this)); try {
Fawe.debug("Plugin 'WorldGuard' found. Using it now."); managers.add(new Worldguard(worldguardPlugin, this));
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else { } else {
Fawe.debug("Plugin 'WorldGuard' not found. Worldguard features disabled."); Fawe.debug("Plugin 'WorldGuard' not found. Worldguard features disabled.");
} }
final Plugin plotmePlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotMe"); final Plugin plotmePlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotMe");
if ((plotmePlugin != null) && plotmePlugin.isEnabled()) { if ((plotmePlugin != null) && plotmePlugin.isEnabled()) {
managers.add(new PlotMeFeature(plotmePlugin, this)); try {
Fawe.debug("Plugin 'PlotMe' found. Using it now."); managers.add(new PlotMeFeature(plotmePlugin, this));
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else { } else {
Fawe.debug("Plugin 'PlotMe' not found. PlotMe features disabled."); Fawe.debug("Plugin 'PlotMe' not found. PlotMe features disabled.");
} }
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny"); final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
if ((townyPlugin != null) && townyPlugin.isEnabled()) { if ((townyPlugin != null) && townyPlugin.isEnabled()) {
managers.add(new TownyFeature(townyPlugin, this)); try {
Fawe.debug("Plugin 'Towny' found. Using it now."); managers.add(new TownyFeature(townyPlugin, this));
Fawe.debug("Plugin 'Towny' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else { } else {
Fawe.debug("Plugin 'Towny' not found. Towny features disabled."); Fawe.debug("Plugin 'Towny' not found. Towny features disabled.");
} }
@ -179,29 +191,45 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
} }
final Plugin residencePlugin = Bukkit.getServer().getPluginManager().getPlugin("Residence"); final Plugin residencePlugin = Bukkit.getServer().getPluginManager().getPlugin("Residence");
if ((residencePlugin != null) && residencePlugin.isEnabled()) { if ((residencePlugin != null) && residencePlugin.isEnabled()) {
managers.add(new ResidenceFeature(residencePlugin, this)); try {
Fawe.debug("Plugin 'Residence' found. Using it now."); managers.add(new ResidenceFeature(residencePlugin, this));
Fawe.debug("Plugin 'Residence' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else { } else {
Fawe.debug("Plugin 'Residence' not found. Factions features disabled."); Fawe.debug("Plugin 'Residence' not found. Factions features disabled.");
} }
final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention"); final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
if ((griefpreventionPlugin != null) && griefpreventionPlugin.isEnabled()) { if ((griefpreventionPlugin != null) && griefpreventionPlugin.isEnabled()) {
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this)); try {
Fawe.debug("Plugin 'GriefPrevention' found. Using it now."); managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else { } else {
Fawe.debug("Plugin 'GriefPrevention' not found. GriefPrevention features disabled."); Fawe.debug("Plugin 'GriefPrevention' not found. GriefPrevention features disabled.");
} }
final Plugin plotsquaredPlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); final Plugin plotsquaredPlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
if ((plotsquaredPlugin != null) && plotsquaredPlugin.isEnabled()) { if ((plotsquaredPlugin != null) && plotsquaredPlugin.isEnabled()) {
managers.add(new PlotSquaredFeature(plotsquaredPlugin, this)); try {
Fawe.debug("Plugin 'PlotSquared' found. Using it now."); managers.add(new PlotSquaredFeature(plotsquaredPlugin, this));
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else { } else {
Fawe.debug("Plugin 'PlotSquared' not found. PlotSquared features disabled."); Fawe.debug("Plugin 'PlotSquared' not found. PlotSquared features disabled.");
} }
final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones"); final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
if ((preciousstonesPlugin != null) && preciousstonesPlugin.isEnabled()) { if ((preciousstonesPlugin != null) && preciousstonesPlugin.isEnabled()) {
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this)); try {
Fawe.debug("Plugin 'PreciousStones' found. Using it now."); managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else { } else {
Fawe.debug("Plugin 'PreciousStones' not found. PreciousStones features disabled."); Fawe.debug("Plugin 'PreciousStones' not found. PreciousStones features disabled.");
} }

View File

@ -56,7 +56,6 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer"); private final RefClass classCraftPlayer = getRefClass("{cb}.entity.CraftPlayer");
private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); private final RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
private final RefClass classWorld = getRefClass("{nms}.World"); private final RefClass classWorld = getRefClass("{nms}.World");
private final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
private final RefField mustSave = classChunk.getField("mustSave"); private final RefField mustSave = classChunk.getField("mustSave");
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition"); private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection"); private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
@ -71,7 +70,6 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
private RefConstructor classChunkSectionConstructor; private RefConstructor classChunkSectionConstructor;
private RefMethod methodX; private RefMethod methodX;
private RefMethod methodAreNeighborsLoaded; private RefMethod methodAreNeighborsLoaded;
private RefMethod methodD;
private RefField fieldSections; private RefField fieldSections;
private RefField fieldWorld; private RefField fieldWorld;
private RefMethod methodGetIdArray; private RefMethod methodGetIdArray;
@ -88,7 +86,6 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
send = classConnection.getMethod("sendPacket", classPacket.getRealClass()); send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class); classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
methodX = classWorld.getMethod("x", classBlockPosition.getRealClass()); methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
methodD = classChunk.getMethod("d", int.class, int.class, int.class);
fieldSections = classChunk.getField("sections"); fieldSections = classChunk.getField("sections");
fieldWorld = classChunk.getField("world"); fieldWorld = classChunk.getField("world");
methodGetIdArray = classChunkSection.getMethod("getIdArray"); methodGetIdArray = classChunkSection.getMethod("getIdArray");

View File

@ -21,6 +21,7 @@ public class Settings {
public static boolean COMMAND_PROCESSOR = false; public static boolean COMMAND_PROCESSOR = false;
public static List<String> WE_BLACKLIST = Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"); public static List<String> WE_BLACKLIST = Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks");
public static long MEM_FREE = 95; public static long MEM_FREE = 95;
public static boolean ENABLE_HARD_LIMIT = true;
public static void setup(final File file) { public static void setup(final File file) {
if (!file.exists()) { if (!file.exists()) {
@ -42,6 +43,7 @@ public class Settings {
options.put("command-blacklist", WE_BLACKLIST); options.put("command-blacklist", WE_BLACKLIST);
options.put("command-processor", COMMAND_PROCESSOR); options.put("command-processor", COMMAND_PROCESSOR);
options.put("max-memory-percent", MEM_FREE); options.put("max-memory-percent", MEM_FREE);
options.put("crash-mitigation", ENABLE_HARD_LIMIT);
options.put("fix-all-lighting", FIX_ALL_LIGHTING); options.put("fix-all-lighting", FIX_ALL_LIGHTING);
for (final Entry<String, Object> node : options.entrySet()) { for (final Entry<String, Object> node : options.entrySet()) {
@ -58,6 +60,7 @@ public class Settings {
MEM_FREE = config.getInt("max-memory-percent"); MEM_FREE = config.getInt("max-memory-percent");
REQUIRE_SELECTION = config.getBoolean("require-selection-in-mask"); REQUIRE_SELECTION = config.getBoolean("require-selection-in-mask");
WE_BLACKLIST = config.getStringList("command-blacklist"); WE_BLACKLIST = config.getStringList("command-blacklist");
ENABLE_HARD_LIMIT = config.getBoolean("crash-mitigation");
try { try {

View File

@ -3,6 +3,7 @@ package com.boydti.fawe.util;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweChunk;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
@ -25,7 +26,7 @@ public class SetQueue {
if (!MemUtil.isMemoryFree()) { if (!MemUtil.isMemoryFree()) {
final int mem = MemUtil.calculateMemory(); final int mem = MemUtil.calculateMemory();
if (mem != Integer.MAX_VALUE) { if (mem != Integer.MAX_VALUE) {
if (mem <= 1) { if (mem <= 1 && Settings.ENABLE_HARD_LIMIT) {
queue.saveMemory(); queue.saveMemory();
return; return;
} }