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;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.MovableTool;
import com.boydti.fawe.object.brush.ResettableTool;
@ -46,12 +47,16 @@ public class BrushListener implements Listener {
}
ScrollTool scrollable = (ScrollTool) tool;
if (scrollable.increment(player, ri)) {
final PlayerInventory inv = bukkitPlayer.getInventory();
final ItemStack item = inv.getItem(slot);
final ItemStack newItem = inv.getItem(oldSlot);
inv.setItem(slot, newItem);
inv.setItem(oldSlot, item);
bukkitPlayer.updateInventory();
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES) {
bukkitPlayer.getInventory().setHeldItemSlot(oldSlot);
} else {
final PlayerInventory inv = bukkitPlayer.getInventory();
final ItemStack item = inv.getItem(slot);
final ItemStack newItem = inv.getItem(oldSlot);
inv.setItem(slot, newItem);
inv.setItem(oldSlot, item);
bukkitPlayer.updateInventory();
}
}
}
}

View File

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