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>
</properties>
<artifactId>FastAsyncWorldEdit</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<name>FastAsyncWorldEdit</name>
<packaging>jar</packaging>
<build>
@ -113,14 +113,14 @@
</plugins>
</build>
<repositories>
<repository>
<id>techcable-repo</id>
<url>http://repo.techcable.net/content/groups/public/</url>
</repository>
<repository>
<id>empcraft-repo</id>
<url>http://empcraft.com/maven2</url>
</repository>
<repository>
<id>techcable-repo</id>
<url>http://repo.techcable.net/content/groups/public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<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;
}
@Override
public void onEnable() {
try {
@ -66,7 +66,7 @@ public class FaweBukkit extends JavaPlugin implements IFawe {
getServer().shutdown();
}
}
@Override
public void debug(final String 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 ArrayList<FaweMaskManager> managers = new ArrayList<>();
if ((worldguardPlugin != null) && worldguardPlugin.isEnabled()) {
managers.add(new Worldguard(worldguardPlugin, this));
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
try {
managers.add(new Worldguard(worldguardPlugin, this));
Fawe.debug("Plugin 'WorldGuard' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else {
Fawe.debug("Plugin 'WorldGuard' not found. Worldguard features disabled.");
}
final Plugin plotmePlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotMe");
if ((plotmePlugin != null) && plotmePlugin.isEnabled()) {
managers.add(new PlotMeFeature(plotmePlugin, this));
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
try {
managers.add(new PlotMeFeature(plotmePlugin, this));
Fawe.debug("Plugin 'PlotMe' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else {
Fawe.debug("Plugin 'PlotMe' not found. PlotMe features disabled.");
}
final Plugin townyPlugin = Bukkit.getServer().getPluginManager().getPlugin("Towny");
if ((townyPlugin != null) && townyPlugin.isEnabled()) {
managers.add(new TownyFeature(townyPlugin, this));
Fawe.debug("Plugin 'Towny' found. Using it now.");
try {
managers.add(new TownyFeature(townyPlugin, this));
Fawe.debug("Plugin 'Towny' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else {
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");
if ((residencePlugin != null) && residencePlugin.isEnabled()) {
managers.add(new ResidenceFeature(residencePlugin, this));
Fawe.debug("Plugin 'Residence' found. Using it now.");
try {
managers.add(new ResidenceFeature(residencePlugin, this));
Fawe.debug("Plugin 'Residence' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else {
Fawe.debug("Plugin 'Residence' not found. Factions features disabled.");
}
final Plugin griefpreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
if ((griefpreventionPlugin != null) && griefpreventionPlugin.isEnabled()) {
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
try {
managers.add(new GriefPreventionFeature(griefpreventionPlugin, this));
Fawe.debug("Plugin 'GriefPrevention' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else {
Fawe.debug("Plugin 'GriefPrevention' not found. GriefPrevention features disabled.");
}
final Plugin plotsquaredPlugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
if ((plotsquaredPlugin != null) && plotsquaredPlugin.isEnabled()) {
managers.add(new PlotSquaredFeature(plotsquaredPlugin, this));
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
try {
managers.add(new PlotSquaredFeature(plotsquaredPlugin, this));
Fawe.debug("Plugin 'PlotSquared' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else {
Fawe.debug("Plugin 'PlotSquared' not found. PlotSquared features disabled.");
}
final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
if ((preciousstonesPlugin != null) && preciousstonesPlugin.isEnabled()) {
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
try {
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
} catch (Throwable e) {
e.printStackTrace();
}
} else {
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 classCraftChunk = getRefClass("{cb}.CraftChunk");
private final RefClass classWorld = getRefClass("{nms}.World");
private final RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
private final RefField mustSave = classChunk.getField("mustSave");
private final RefClass classBlockPosition = getRefClass("{nms}.BlockPosition");
private final RefClass classChunkSection = getRefClass("{nms}.ChunkSection");
@ -71,7 +70,6 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
private RefConstructor classChunkSectionConstructor;
private RefMethod methodX;
private RefMethod methodAreNeighborsLoaded;
private RefMethod methodD;
private RefField fieldSections;
private RefField fieldWorld;
private RefMethod methodGetIdArray;
@ -88,7 +86,6 @@ public class BukkitQueue_1_8 extends BukkitQueue_0 {
send = classConnection.getMethod("sendPacket", classPacket.getRealClass());
classBlockPositionConstructor = classBlockPosition.getConstructor(int.class, int.class, int.class);
methodX = classWorld.getMethod("x", classBlockPosition.getRealClass());
methodD = classChunk.getMethod("d", int.class, int.class, int.class);
fieldSections = classChunk.getField("sections");
fieldWorld = classChunk.getField("world");
methodGetIdArray = classChunkSection.getMethod("getIdArray");

View File

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

View File

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