mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-11-15 07:05:53 +01:00
Use weak map for brush cache
This commit is contained in:
parent
687d1ac890
commit
27152ef8ac
@ -5,7 +5,6 @@ import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.bukkit.FaweBukkit;
|
||||
import com.boydti.fawe.bukkit.util.ItemUtil;
|
||||
import com.boydti.fawe.object.brush.BrushSettings;
|
||||
import com.boydti.fawe.object.collection.SoftHashMap;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@ -19,10 +18,11 @@ import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class BrushBoundBaseBlock extends BaseBlock implements BrushHolder {
|
||||
private static SoftHashMap<Object, BrushTool> brushCache = new SoftHashMap<>();
|
||||
private static WeakHashMap<Object, BrushTool> brushCache = new WeakHashMap<>();
|
||||
private static Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
private final LocalSession session;
|
||||
|
@ -38,7 +38,7 @@ public class BrushSettings {
|
||||
SCROLL_ACTION,
|
||||
}
|
||||
|
||||
private Map<SettingType, Object> constructor = new ConcurrentHashMap<>();
|
||||
private final Map<SettingType, Object> constructor = new ConcurrentHashMap<>();
|
||||
|
||||
private Brush brush = null;
|
||||
private Mask mask = null;
|
||||
|
@ -95,6 +95,10 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
||||
Type type = new TypeToken<Map<String, Object>>() {
|
||||
}.getType();
|
||||
Map<String, Object> root = gson.fromJson(json, type);
|
||||
if (root == null) {
|
||||
Fawe.debug("Failed to load " + json);
|
||||
return new BrushTool();
|
||||
}
|
||||
Map<String, Object> primary = (Map<String, Object>) root.get("primary");
|
||||
Map<String, Object> secondary = (Map<String, Object>) root.getOrDefault("secondary", primary);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user