From 790ed4f99388ce0eca65545b25384de435a9e7f1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 11 Feb 2016 08:11:40 +0000 Subject: [PATCH] Fix tools for block type/colour selections. --- .../game/arcade/game/games/draw/Draw.java | 15 ++++----- .../arcade/game/games/draw/tools/Tool.java | 33 ++++++++++++++++--- .../game/games/draw/tools/ToolCircle.java | 9 +++-- .../game/games/draw/tools/ToolLine.java | 9 +++-- .../game/games/draw/tools/ToolSquare.java | 10 ++++-- 5 files changed, 56 insertions(+), 20 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java index 9a140789c..82939c072 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/Draw.java @@ -958,13 +958,10 @@ public class Draw extends SoloGame _lockDrawer = b; } - @EventHandler - public void sprayCan(UpdateEvent e) - { - if (!IsLive()) - return; - - //if (e.getType() != UpdateType.TICK) - //todo spray can BOW PULL BACK - } + //fdmsdmfsdfpmsd + /** + * TODO: + * - Spray Can + * - Undo/Redo + */ } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/Tool.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/Tool.java index c1b609934..f2c59da59 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/Tool.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/Tool.java @@ -18,6 +18,28 @@ import org.bukkit.event.player.PlayerInteractEvent; public abstract class Tool { + public class BlockInfo + { + private Material _type; + private byte _data; + + public BlockInfo(Material type, byte data) + { + _type = type; + _data = data; + } + + public Material getType() + { + return _type; + } + + public byte getData() + { + return _data; + } + } + protected Draw Host; protected Player _drawer; @@ -25,8 +47,8 @@ public abstract class Tool protected Material _material; - protected HashMap _past = new HashMap(); - protected HashMap _new = new HashMap(); + protected HashMap _past = new HashMap(); + protected HashMap _new = new HashMap(); public Tool(Draw host, Material mat) { @@ -68,7 +90,7 @@ public abstract class Tool return; } - _new = new HashMap(); + _new = new HashMap(); //Calculate New Block end = _drawer.getTargetBlock((HashSet) null, 64); @@ -81,7 +103,10 @@ public abstract class Tool for (Block block : _past.keySet()) { if (!_new.containsKey(block)) - block.setData(_past.get(block)); + { + block.setType(_past.get(block).getType()); + block.setData(_past.get(block).getData()); + } } _past = _new; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolCircle.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolCircle.java index b1403520d..820b1d8b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolCircle.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolCircle.java @@ -48,10 +48,15 @@ public class ToolCircle extends Tool return; byte color = block.getData(); + Material type = block.getType(); if (_past.containsKey(block)) - color = _past.get(block); + { + type = _past.get(block).getType(); + color = _past.get(block).getData(); + } - _new.put(block, color); + _new.put(block, new BlockInfo(type, color)); block.setData(Host.getColor()); + block.setType(Host.getBrushMaterial()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolLine.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolLine.java index 1223098ac..2f69b1912 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolLine.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolLine.java @@ -32,10 +32,15 @@ public class ToolLine extends Tool continue; byte color = lineBlock.getData(); + Material type = lineBlock.getType(); if (_past.containsKey(lineBlock)) - color = _past.get(lineBlock); + { + type = _past.get(lineBlock).getType(); + color = _past.get(lineBlock).getData(); + } - _new.put(lineBlock, color); + _new.put(lineBlock, new BlockInfo(type, color)); + lineBlock.setType(Host.getBrushMaterial()); lineBlock.setData(Host.getColor()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolSquare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolSquare.java index 4fd70021f..fc8fac2be 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolSquare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/tools/ToolSquare.java @@ -71,12 +71,16 @@ public class ToolSquare extends Tool if (!Host.getCanvas().contains(block)) return; - + + Material type = block.getType(); byte color = block.getData(); if (_past.containsKey(block)) - color = _past.get(block); + { + type = _past.get(block).getType(); + color = _past.get(block).getData(); + } - _new.put(block, color); + _new.put(block, new BlockInfo(type, color)); block.setData(Host.getColor()); } }