Fix persistent brush scroll action

This commit is contained in:
Jesse Boyd 2017-09-01 15:14:20 +10:00
parent 8f2bfabc1a
commit b9d267a908
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
2 changed files with 15 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.bukkit.listener; package com.boydti.fawe.bukkit.listener;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.MovableTool; import com.boydti.fawe.object.brush.MovableTool;
import com.boydti.fawe.object.brush.ResettableTool; import com.boydti.fawe.object.brush.ResettableTool;
@ -46,6 +47,9 @@ public class BrushListener implements Listener {
} }
ScrollTool scrollable = (ScrollTool) tool; ScrollTool scrollable = (ScrollTool) tool;
if (scrollable.increment(player, ri)) { if (scrollable.increment(player, ri)) {
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES) {
bukkitPlayer.getInventory().setHeldItemSlot(oldSlot);
} else {
final PlayerInventory inv = bukkitPlayer.getInventory(); final PlayerInventory inv = bukkitPlayer.getInventory();
final ItemStack item = inv.getItem(slot); final ItemStack item = inv.getItem(slot);
final ItemStack newItem = inv.getItem(oldSlot); final ItemStack newItem = inv.getItem(oldSlot);
@ -55,6 +59,7 @@ public class BrushListener implements Listener {
} }
} }
} }
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {

View File

@ -580,6 +580,9 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
if (mode == VisualMode.NONE) { if (mode == VisualMode.NONE) {
return; return;
} }
BrushSettings current = getContext();
Brush brush = current.getBrush();
if (brush == null) return;
FawePlayer<Object> fp = FawePlayer.wrap(player); FawePlayer<Object> fp = FawePlayer.wrap(player);
EditSession editSession = new EditSessionBuilder(player.getWorld()) EditSession editSession = new EditSessionBuilder(player.getWorld())
.player(fp) .player(fp)
@ -599,9 +602,8 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
break; break;
} }
case OUTLINE: { case OUTLINE: {
BrushSettings current = getContext();
new PatternTraverser(current).reset(editSession); new PatternTraverser(current).reset(editSession);
current.getBrush().build(editSession, position, current.getMaterial(), current.getSize()); brush.build(editSession, position, current.getMaterial(), current.getSize());
break; break;
} }
} }