Fix bucket

This commit is contained in:
Shaun Bennett 2016-02-26 04:21:26 -06:00
parent 268536ce68
commit 4472c52432
1 changed files with 40 additions and 60 deletions

View File

@ -10,6 +10,7 @@ import java.util.List;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -99,7 +100,7 @@ public class Draw extends SoloGame
{ {
//new KitSlowAndSteady(manager), //new KitSlowAndSteady(manager),
//new KitSelector(manager), //new KitSelector(manager),
//new KitTools(manager), // new KitTools(manager),
new KitArtist(manager) new KitArtist(manager)
}, },
@ -164,8 +165,8 @@ public class Draw extends SoloGame
"Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" ,
"Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" ,
"Kirby" , "Brush" , "Violin", "Car", "Sun", "Eye", "Bow", "Axe", "Face", "Mushroom", "Guitar", "Kirby" , "Brush" , "Violin", "Car", "Sun", "Eye", "Bow", "Axe", "Face", "Mushroom", "Guitar",
"Book", "Pickle", "Banana", "Crab", "Sugar", "Book", "Soda", "Cookie", "Burger", "Fries", "Speaker", "Pickle", "Banana", "Crab", "Sugar", "Soda", "Cookie", "Burger", "Fries", "Speaker",
"Pillow", "Rug", "Purse", "Monitor", "Bow", "Pen", "Cat", "Kitten", "Puppy", "Bed", "Bowl", "Button", "Pillow", "Rug", "Purse", "Monitor", "Bow", "Pen", "Cat", "Kitten", "Puppy", "Bed", "Button",
"Computer", "Key", "Spoon", "Lamp", "Bottle", "Card", "Newspaper", "Glasses", "Mountain", "Minecraft", "Computer", "Key", "Spoon", "Lamp", "Bottle", "Card", "Newspaper", "Glasses", "Mountain", "Minecraft",
"Shirt", "Truck", "Car", "Phone", "Cork", "iPod", "Paper", "Bag", "USB", "CD", "Wallet", "Cow", "Pig", "Shirt", "Truck", "Car", "Phone", "Cork", "iPod", "Paper", "Bag", "USB", "CD", "Wallet", "Cow", "Pig",
"Sheep", "Tomato", "Painting", "Chair", "Keyboard", "Chocolate", "Duck", "Clock", "Balloon", "Remote", "Sheep", "Tomato", "Painting", "Chair", "Keyboard", "Chocolate", "Duck", "Clock", "Balloon", "Remote",
@ -179,7 +180,7 @@ public class Draw extends SoloGame
"Piano", "Guitar", "Trumpet", "Drums", "Flute", "Helicopter", "Plane", "Football", "Tennis", "Hockey", "Piano", "Guitar", "Trumpet", "Drums", "Flute", "Helicopter", "Plane", "Football", "Tennis", "Hockey",
"Water", "Ocean", "Microsoft", "Twitter", "Godzilla", "Building", "House", "Rainbow", "Barbie", "Girl", "Boy", "Water", "Ocean", "Microsoft", "Twitter", "Godzilla", "Building", "House", "Rainbow", "Barbie", "Girl", "Boy",
"Children", "Bomb", "Explosion", "Gun", "Tank", "Penguin", "Eagle", "America", "Kangaroo", "Sea", "Raspberry", "Children", "Bomb", "Explosion", "Gun", "Tank", "Penguin", "Eagle", "America", "Kangaroo", "Sea", "Raspberry",
"Strawberry", "Jam", "Sandwich" "Strawberry", "Jam", "Sandwich", "Owl", "Watermelon", "Australia", "Canada", "United States", "Diary"
}; };
_holidayWords = new String[] _holidayWords = new String[]
@ -215,14 +216,19 @@ public class Draw extends SoloGame
@Override @Override
public void ParseData() public void ParseData()
{ {
int count = 0;
for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false)) for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false))
{ {
if (b.getType() != Material.AIR) if (b.getType() != Material.AIR)
{
_canvas.add(b); _canvas.add(b);
count++;
}
} }
System.out.println("==="); System.out.println("===");
System.out.println("Draw loc: " + WorldData.GetDataLocs("RED").size()); System.out.println("Draw loc: " + WorldData.GetDataLocs("RED").size());
System.out.println("Canvas Count: " + count);
System.out.println("==="); System.out.println("===");
_drawerLocation = WorldData.GetDataLocs("RED").get(0); _drawerLocation = WorldData.GetDataLocs("RED").get(0);
@ -236,6 +242,9 @@ public class Draw extends SoloGame
return; return;
Reset(); Reset();
for (Player player : GetPlayers(true))
player.setGameMode(GameMode.ADVENTURE);
} }
@EventHandler @EventHandler
@ -772,67 +781,33 @@ public class Draw extends SoloGame
return; return;
} }
// Play sound to all players. Material material = target.getType();
for (Player player : UtilServer.getPlayers()) byte data = target.getData();
if (data == _brushColor && material == _brushMaterial)
return;
System.out.println("Fill...");
fillRecursive(target, material, data);
for (Player other : UtilServer.getPlayers())
other.playSound(other.getLocation(), Sound.SPLASH, 0.4f, 1.5f);
}
private void fillRecursive(Block block, final Material fillMaterial, final byte fillData)
{
if (!_canvas.contains(block) || block.getType() != fillMaterial || block.getData() != fillData)
{ {
player.playSound(player.getLocation(), Sound.SPLASH, 0.4f, 1.5f); return;
} }
// Save the current block info to check later if it's the same. block.setTypeIdAndData(_brushMaterial.getId(), _brushColor, false);
BlockInfo originalInfo = new BlockInfo(target.getType(), target.getData());
// List of blocks needing to be changed. List<Block> around = UtilBlock.getSurrounding(block, false);
ArrayList<Block> pending = new ArrayList<>();
// Add the current target block to pending changes. for (Block next : around)
boolean targetBlock = true;
pending.add(target);
// Cycle through all pending blocks if there are any left.
pendingBlocks: while (!pending.isEmpty())
{ {
// Find the center block and remove it from the list sequentially. fillRecursive(next, fillMaterial, fillData);
Block center = pending.get(0);
pending.remove(0);
// Check if it's the original target block.
if (!targetBlock)
{
// It's not: make sure that it's the same as the original block info.
if (center.getType() != originalInfo.getType())
{
// Not the same block type.
continue pendingBlocks;
}
if (center.getData() != originalInfo.getData())
{
// Not the same block data/colour.
continue pendingBlocks;
}
}
else
{
// Set so that we know the next block isn't the original target.
targetBlock = false;
}
// Set the center block type and data/colour.
center.setType(_brushMaterial);
center.setData(_brushColor);
// Cycle through the surrounding blocks and see if they need filling in.
blocks: for (Block other : UtilBlock.getSurrounding(center, false))
{
if (pending.contains(other))
{
// Already awaiting a change. :+1:
continue blocks;
}
// Add it to the pending list for change later.
pending.add(other);
}
} }
} }
@ -847,7 +822,12 @@ public class Draw extends SoloGame
if (!_drawers.HasPlayer(player)) if (!_drawers.HasPlayer(player))
return; return;
Location loc = UtilPlayer.getTarget(player, UtilBlock.blockPassSet, 400).getLocation(); Block target = UtilPlayer.getTarget(player, UtilBlock.blockPassSet, 400);
if (target == null)
return;
Location loc = target.getLocation();
List<Block> possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0), List<Block> possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0),
WorldData.GetDataLocs("GREEN").get(1)); WorldData.GetDataLocs("GREEN").get(1));