From ad1d444af8857a074a898cff36860dea0c86114a Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 23 Dec 2015 09:52:52 +0000 Subject: [PATCH 01/22] Kit changes and new words. --- .../game/arcade/game/games/draw/Draw.java | 91 +++++++++++++++---- .../game/games/draw/kits/KitArtist.java | 38 ++++++++ 2 files changed, 113 insertions(+), 16 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java 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 53d88aeda..5ce6c89c6 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 @@ -92,9 +92,10 @@ public class Draw extends SoloGame new Kit[] { - new KitSlowAndSteady(manager), - new KitSelector(manager), - new KitTools(manager), + //new KitSlowAndSteady(manager), + //new KitSelector(manager), + //new KitTools(manager), + new KitArtist(manager) }, new String[] @@ -108,11 +109,73 @@ public class Draw extends SoloGame this.Damage = false; this.HungerSet = 20; this.WorldTimeSet = 8000; - + _words = new String[] - { - "Bird", "Volcano", "Sloth", "Love", "Dance", "Hair", "Glasses", "Domino", "Dice", "Computer", "Top Hat", "Beard", "Wind", "Rain", "Minecraft", "Push", "Fighting", "Juggle", "Clown", "Miner", "Creeper", "Ghast", "Spider", "Punch", "Roll", "River", "Desert", "Cold", "Pregnant", "Photo", "Quick", "Mario", "Luigi", "Bridge", "Turtle", "Door Knob", "Mineplex", "Binoculars", "Telescope", "Planet", "Mountain Bike", "Moon", "Comet", "Flower", "Squirrel", "Horse Riding", "Chef", "Elephant", "Yoshi", "Shotgun", "Pistol", "James Bond", "Money", "Salt and Pepper", "Truck", "Helicopter", "Hot Air Balloon", "Sprout", "Yelling", "Muscles", "Skinny", "Zombie", "Lava", "Snake", "Motorbike", "Whale", "Boat", "Letterbox", "Window", "Lollipop", "Handcuffs", "Police", "Uppercut", "Windmill", "Eyepatch", "Campfire", "Rainbow", "Storm", "Pikachu", "Charmander", "Tornado", "Crying", "King", "Hobo", "Worm", "Snail", "XBox", "Playstation", "Nintendo", "Duck", "Pull", "Dinosaur", "Alligator", "Ankle", "Angel", "Acorn", "Bread", "Booty", "Bacon", "Crown", "Donut", "Drill", "Leash", "Magic", "Wizard", "Igloo", "Plant", "Screw", "Rifle", "Puppy", "Stool", "Stamp", "Letter", "Witch", "Zebra", "Wagon", "Compass", "Watch", "Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish", "Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl", "Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti", "Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel", "Cheese", "Beans", "Water", "Chicken", "Cannibal", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster", "Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone", "Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate", "Lightning", "Stomach", "Belly Button", "Fishing Rod", "Iron Ore", "Diamonds", "Emeralds", "Nether Portal", "Ender Dragon", "Rabbit", "Harry Potter", "Torch", "Light", "Battery", "Zombie Pigman", "Telephone", "Tent", "Hand", "Traffic Lights", "Anvil", "Tail", "Umbrella", "Piston", "Skeleton", "Spikes", "Bridge", "Bomb", "Spoon", "Rainbow", "Staircase", "Poop", "Dragon", "Fire", "Apple", "Shoe", "Squid", "Cookie", "Tooth", "Camera", "Sock", "Monkey", "Unicorn", "Smile", "Pool", "Rabbit", "Cupcake", "Pancake", "Princess", "Castle", "Flag", "Planet", "Stars", "Camp Fire", "Rose", "Spray", "Pencil", "Ice Cream", "Toilet", "Moose", "Bear", "Beer", "Batman", "Eggs", "Teapot", "Golf Club", "Tennis Racket", "Shield", "Crab", "Pot of Gold", "Cactus", "Television", "Pumpkin Pie", "Chimney", "Stable", "Nether", "Wither", "Beach", "Stop Sign", "Chestplate", "Pokeball", "Christmas Tree", "Present", "Snowflake", "Laptop", "Superman", "Football", "Basketball", "Creeper", "Tetris", "Jump", "Ninja", "Baby", "Troll Face", "Grim Reaper", "Temple", "Explosion", "Vomit", "Ants", "Barn", "Burn", "Baggage", "Frisbee", "Iceberg", "Sleeping", "Dream", "Snorlax", "Balloons", "Elevator", "Alligator", "Bikini", "Butterfly", "Bumblebee", "Pizza", "Jellyfish", "Sideburns", "Speedboat", "Treehouse", "Water Gun", "Drink", "Hook", "Dance", "Fall", "Summer", "Autumn", "Spring", "Winter", "Night Time", "Galaxy", "Sunrise", "Sunset", "Picnic", "Snowflake", "Holding Hands", "America", "Laptop", "Anvil", "Bagel", "Bench", "Cigar", "Darts", "Muffin", "Queen", "Wheat", "Dolphin", "Scarf", "Swing", "Thumb", "Tomato", "Alcohol", "Armor", "Alien", "Beans", "Cheek", "Phone", "Keyboard", "Orange", "Calculator", "Paper", "Desk", "Disco", "Elbow", "Drool", "Giant", "Golem", "Grave", "Llama", "Moose", "Party", "Panda", "Plumber", "Salsa", "Salad", "Skunk", "Skull", "Stump", "Sugar", "Ruler", "Bookcase", "Hamster", "Soup", "Teapot", "Towel", "Waist", "Archer", "Anchor", "Bamboo", "Branch", "Booger", "Carrot", "Cereal", "Coffee", "Wolf", "Crayon", "Finger", "Forest", "Hotdog", "Burger", "Obsidian", "Pillow", "Swing", "YouTube", "Farm", "Rain", "Cloud", "Frozen", "Garbage", "Music", "Twitter", "Facebook", "Santa Hat", "Rope", "Neck", "Sponge", "Sushi", "Noodles", "Soup", "Tower", "Berry", "Capture", "Prison", "Robot", "Trash", "School", "Skype", "Snowman", "Crowd", "Bank", "Mudkip", "Joker", "Lizard", "Tiger", "Royal", "Erupt", "Wizard", "Stain", "Cinema", "Notebook", "Blanket", "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Kirby" , "Brush" , "Violin", "Car", "Sun", "Eye", "Bow", "Axe", "Face", "Mushroom", "Guitar", "Book", - }; + { + "Bird", "Volcano", "Sloth", "Love", "Dance", "Hair", "Glasses", "Domino", "Dice", "Computer", "Top Hat", + "Beard", "Wind", "Rain", "Minecraft", "Push", "Fighting", "Juggle", "Clown", "Miner", "Creeper", + "Ghast", "Spider", "Punch", "Roll", "River", "Desert", "Cold", "Pregnant", "Photo", "Quick", "Mario", + "Luigi", "Bridge", "Turtle", "Door Knob", "Mineplex", "Binoculars", "Telescope", "Planet", + "Mountain Bike", "Moon", "Comet", "Flower", "Squirrel", "Horse Riding", "Chef", "Elephant", "Yoshi", + "Shotgun", "Pistol", "James Bond", "Money", "Salt and Pepper", "Truck", "Helicopter", "Hot Air Balloon", + "Sprout", "Yelling", "Muscles", "Skinny", "Zombie", "Lava", "Snake", "Motorbike", "Whale", "Boat", + "Letterbox", "Window", "Lollipop", "Handcuffs", "Police", "Uppercut", "Windmill", "Eyepatch", "Campfire", + "Rainbow", "Storm", "Pikachu", "Charmander", "Tornado", "Crying", "King", "Hobo", "Worm", "Snail", + "XBox", "Playstation", "Nintendo", "Duck", "Pull", "Dinosaur", "Alligator", "Ankle", "Angel", "Acorn", + "Bread", "Booty", "Bacon", "Crown", "Donut", "Drill", "Leash", "Magic", "Wizard", "Igloo", "Plant", + "Screw", "Rifle", "Puppy", "Stool", "Stamp", "Letter", "Witch", "Zebra", "Wagon", "Compass", "Watch", + "Clock", "Time", "Cyclops", "Coconut", "Hang", "Penguin", "Confused", "Bucket", "Lion", "Rubbish", + "Spaceship", "Bowl", "Shark", "Pizza", "Pyramid", "Dress", "Pants", "Shorts", "Boots", "Boy", "Girl", + "Math", "Sunglasses", "Frog", "Chair", "Cake", "Grapes", "Kiss", "Snorlax", "Earth", "Spaghetti", + "Couch", "Family", "Milk", "Blood", "Pig", "Giraffe", "Mouse", "Couch", "Fat", "Chocolate", "Camel", + "Cheese", "Beans", "Water", "Chicken", "Zipper", "Book", "Swimming", "Horse", "Paper", "Toaster", + "Television", "Hammer", "Piano", "Sleeping", "Yawn", "Sheep", "Night", "Chest", "Lamp", "Redstone", + "Grass", "Plane", "Ocean", "Lake", "Melon", "Pumpkin", "Gift", "Fishing", "Pirate", + "Lightning", "Stomach", "Belly Button", "Fishing Rod", "Iron Ore", "Diamonds", "Emeralds", + "Nether Portal", "Ender Dragon", "Rabbit", "Harry Potter", "Torch", "Light", "Battery", "Zombie Pigman", + "Telephone", "Tent", "Hand", "Traffic Lights", "Anvil", "Tail", "Umbrella", "Piston", "Skeleton", + "Spikes", "Bridge", "Bomb", "Spoon", "Rainbow", "Staircase", "Poop", "Dragon", "Fire", "Apple", "Shoe", + "Squid", "Cookie", "Tooth", "Camera", "Sock", "Monkey", "Unicorn", "Smile", "Pool", "Rabbit", + "Cupcake", "Pancake", "Princess", "Castle", "Flag", "Planet", "Stars", "Camp Fire", "Rose", "Spray", + "Pencil", "Ice Cream", "Toilet", "Moose", "Bear", "Beer", "Batman", "Eggs", "Teapot", "Golf Club", + "Tennis Racket", "Shield", "Crab", "Pot of Gold", "Cactus", "Television", "Pumpkin Pie", "Chimney", + "Stable", "Nether", "Wither", "Beach", "Stop Sign", "Chestplate", "Pokeball", "Christmas Tree", + "Present", "Snowflake", "Laptop", "Superman", "Football", "Basketball", "Creeper", "Tetris", "Jump", + "Ninja", "Baby", "Troll Face", "Grim Reaper", "Temple", "Explosion", "Vomit", "Ants", "Barn", "Burn", + "Baggage", "Frisbee", "Iceberg", "Sleeping", "Dream", "Snorlax", "Balloons", "Elevator", "Alligator", + "Bikini", "Butterfly", "Bumblebee", "Pizza", "Jellyfish", "Sideburns", "Speedboat", "Treehouse", + "Water Gun", "Drink", "Hook", "Dance", "Fall", "Summer", "Autumn", "Spring", "Winter", "Night Time", + "Galaxy", "Sunrise", "Sunset", "Picnic", "Snowflake", "Holding Hands", "America", "Laptop", "Anvil", + "Bagel", "Bench", "Cigar", "Darts", "Muffin", "Queen", "Wheat", "Dolphin", "Scarf", "Swing", "Thumb", + "Tomato", "Armor", "Alien", "Beans", "Cheek", "Phone", "Keyboard", "Orange", "Calculator", + "Paper", "Desk", "Disco", "Elbow", "Drool", "Giant", "Golem", "Grave", "Llama", "Moose", "Party", + "Panda", "Plumber", "Salsa", "Salad", "Skunk", "Skull", "Stump", "Sugar", "Ruler", "Bookcase", + "Hamster", "Soup", "Teapot", "Towel", "Waist", "Archer", "Anchor", "Bamboo", "Branch", "Booger", + "Carrot", "Cereal", "Coffee", "Wolf", "Crayon", "Finger", "Forest", "Hotdog", "Burger", "Obsidian", + "Pillow", "Swing", "YouTube", "Farm", "Rain", "Cloud", "Frozen", "Garbage", "Music", "Twitter", + "Facebook", "Santa Hat", "Rope", "Neck", "Sponge", "Sushi", "Noodles", "Soup", "Tower", "Berry", + "Capture", "Prison", "Robot", "Trash", "School", "Skype", "Snowman", "Crowd", "Bank", "Mudkip", + "Joker", "Lizard", "Tiger", "Royal", "Erupt", "Wizard", "Stain", "Cinema", "Notebook", "Blanket", + "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , + "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , + "Kirby" , "Brush" , "Violin", "Car", "Sun", "Eye", "Bow", "Axe", "Face", "Mushroom", "Guitar", + "Book", "Pickle", "Banana", "Crab", "Sugar", "Book", "Soda", "Cookie", "Burger", "Fries", "Speaker", + "Pillow", "Rug", "Purse", "Monitor", "Bow", "Pen", "Cat", "Kitten", "Puppy", "Bed", "Bowl", "Button", + "Computer", "Key", "Spoon", "Lamp", "Bottle", "Card", "Newspaper", "Glasses", "Mountain", "Minecraft", + "Shirt", "Truck", "Car", "Phone", "Cork", "iPod", "Paper", "Bag", "USB", "CD", "Wallet", "Cow", "Pig", + "Sheep", "Tomato", "Painting", "Chair", "Keyboard", "Chocolate", "Duck", "Clock", "Balloon", "Remote", + "Bread", "Ring", "Necklace", "Hippo", "Flag", "Window", "Door", "Radio", "Television", "Boat", + "Fridge", "House", "Piano", "Guitar", "Trumpet", "Drums", "Speaker", "Helmet", "Tree", "Slippers", + "Table", "Doll", "Headphones", "Box", "Flower", "Book", "Carrot", "Egg", "Sun", "Hill", "Candle", + "Food", "Mouse", "Money", "Emerald", "Magnet", "Camera", "Movie", "Video Game", "Teddy", "Lake", + "Violin", "Cheese", "Burger", "Peasant", "King", "Queen", "Prince", "Princess", "Mother", "Father", "Taco", + "Racecar", "Car", "Truck", "Tree", "Elephant", "Lion", "Pig", "Cow", "Chicken", "Dog", "Cat", "Moon", "Stars", + "Sun", "Diamond", "Gold", "Redstone", "Skateboard", "Bike", "Swimming Pool", "Cookie", "Computer", "Laptop", + "Piano", "Guitar", "Trumpet", "Drums", "Flute", "Helicopter", "Plane", "Football", "Tennis", "Hockey", + "Water", "Ocean", "Microsoft", "Twitter", "Godzilla", "Building", "House", "Rainbow", "Barbie", "Girl", "Boy", + "Children", "Bomb", "Explosion", "Gun", "Tank", "Penguin", "Eagle", "America", "Kangaroo", "Sea", "Raspberry", + "Strawberry", "Jam", "Sandwich" + }; _holidayWords = new String[] { @@ -273,15 +336,11 @@ public class Draw extends SoloGame drawer.setFlying(true); drawer.setFlySpeed(0.4f); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte)0, 1, "Thin Paint Brush")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte)0, 1, "Thick Paint Brush")); - - if (GetKit(drawer) instanceof KitTools) - { - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte)0, 1, "Line Tool")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool")); - } + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte) 0, 1, "Thin Paint Brush")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, "Thick Paint Brush")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte) 0, 1, "Line Tool")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BUCKET, (byte)0, 1, "Paint Bucket")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, "Clear Canvas")); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java new file mode 100644 index 000000000..36776e64c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.game.games.draw.kits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +/** + * Created by William (WilliamTiger). + * 23/12/15 + */ +public class KitArtist extends Kit +{ + public KitArtist(ArcadeManager manager) + { + super(manager, "Artist", KitAvailability.Free, + new String[] + { + "Show off your drawing skills!" + }, + new Perk[] + { + + }, + EntityType.ZOMBIE, new ItemStack(Material.STONE_SWORD)); + } + + @Override + public void GiveItems(Player player) + { + + } +} From c48df36459924535d38a0b08d0b9166f26b03292 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 23 Dec 2015 10:26:14 +0000 Subject: [PATCH 02/22] Canvas reset with starting picture. --- .../game/arcade/game/games/draw/Draw.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 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 5ce6c89c6..39d381c1c 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 @@ -54,6 +54,7 @@ import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.stats.KeenEyeStatTracker; import nautilus.game.arcade.stats.MrSquiggleStatTracker; import nautilus.game.arcade.stats.PureLuckStatTracker; +import sun.misc.REException; public class Draw extends SoloGame { @@ -204,11 +205,18 @@ public class Draw extends SoloGame @Override public void ParseData() { - for (Location loc : WorldData.GetCustomLocs("159")) - _canvas.add(loc.getBlock()); + for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("LIME").get(0), WorldData.GetDataLocs("LIME").get(1))) + _canvas.add(b); _drawerLocation = WorldData.GetDataLocs("RED").get(0); _textLocation = WorldData.GetDataLocs("YELLOW").get(0); + } + + @EventHandler + public void clearBoardStart(GameStateChangeEvent e) + { + if (e.GetState() != GameState.Live) + return; Reset(); } @@ -706,8 +714,9 @@ public class Draw extends SoloGame { for (Block block : _canvas) { - if (block.getTypeId() != 35 || block.getData() != 0) - block.setTypeIdAndData(35, (byte)0, false); +// if (block.getTypeId() != 35 || block.getData() != 0) +// block.setTypeIdAndData(35, (byte)0, false); + block.setTypeIdAndData(35, (byte) 0, false); } _brushColor = 15; From 79dea726aa1f1752fb09fdfcf300400a6dae335d Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 23 Dec 2015 10:59:12 +0000 Subject: [PATCH 03/22] Added check for falling from map. --- .../game/arcade/game/games/draw/Draw.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 39d381c1c..5a27c4be4 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 @@ -221,6 +221,21 @@ public class Draw extends SoloGame Reset(); } + @EventHandler + public void playerFallCloudy(PlayerMoveEvent e) + { + if (!GetPlayers(true).contains(e.getPlayer())) + return; + + if (!WorldData.MapName.equalsIgnoreCase("Cloudy")) + return; + + if (e.getTo().getBlockY() <= 130) + { + GetTeam(e.getPlayer()).SpawnTeleport(e.getPlayer()); + } + } + @Override @EventHandler public void CustomTeamGeneration(GameStateChangeEvent event) From 1066becd680d73a0da559e31a7a72f878b34eb4c Mon Sep 17 00:00:00 2001 From: William Burns Date: Sat, 26 Dec 2015 20:21:46 +0000 Subject: [PATCH 04/22] push --- .../src/nautilus/game/arcade/game/games/draw/Draw.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5a27c4be4..48baf2b27 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 @@ -205,7 +205,7 @@ public class Draw extends SoloGame @Override public void ParseData() { - for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("LIME").get(0), WorldData.GetDataLocs("LIME").get(1))) + for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("LIME").get(0), WorldData.GetDataLocs("LIME").get(1), false)) _canvas.add(b); _drawerLocation = WorldData.GetDataLocs("RED").get(0); From 733bfadf68590ae7869c61ca519067d8faf39eb8 Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 15 Jan 2016 18:52:26 +0000 Subject: [PATCH 05/22] Added spray can tool --- .../game/arcade/game/games/draw/Draw.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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 48baf2b27..144037e8e 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 @@ -364,6 +364,7 @@ public class Draw extends SoloGame drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte) 0, 1, "Line Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_BLOCK, (byte)0, 1, "Spray Can")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BUCKET, (byte)0, 1, "Paint Bucket")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, "Clear Canvas")); @@ -562,7 +563,7 @@ public class Draw extends SoloGame for (Player player : _drawers.GetPlayers(true)) { - if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) + if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_BLOCK)) continue; if (!player.isBlocking()) @@ -592,6 +593,21 @@ public class Draw extends SoloGame other.setData(_brushColor); } } + + //Spray Can + if (UtilGear.isMat(player.getItemInHand(), Material.IRON_BLOCK)) + { + for (Block other : UtilBlock.getSurrounding(block, false)) + { + if (!_canvas.contains(other)) + continue; + + if (Math.random() > 0.75) + continue; + + other.setData(_brushColor); + } + } //Join Dots if (_brushPrevious != null) @@ -618,6 +634,21 @@ public class Draw extends SoloGame other.setData(_brushColor); } } + + //Spray Can + if (UtilGear.isMat(player.getItemInHand(), Material.IRON_BLOCK)) + { + for (Block other : UtilBlock.getSurrounding(fixBlock, false)) + { + if (!_canvas.contains(other)) + continue; + + if (Math.random() > 0.75) + continue; + + other.setData(_brushColor); + } + } } } From f22297418c07d4a95158a63b819f6314648050d5 Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 15 Jan 2016 19:08:25 +0000 Subject: [PATCH 06/22] Clear full canvas at start fix --- .../src/nautilus/game/arcade/game/games/draw/Draw.java | 5 +++++ 1 file changed, 5 insertions(+) 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 144037e8e..f5303b566 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 @@ -10,6 +10,7 @@ import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -219,6 +220,10 @@ public class Draw extends SoloGame return; Reset(); + + for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false)) + if (b.getType().equals(Material.WOOL) && b.getData() == DyeColor.WHITE.getWoolData()) + b.setType(Material.AIR); } @EventHandler From 7af8d78fc3840c40465f45c88ef742b85de5e9b0 Mon Sep 17 00:00:00 2001 From: William Burns Date: Tue, 19 Jan 2016 14:00:23 +0000 Subject: [PATCH 07/22] Add resource pack and other fixes --- .../src/nautilus/game/arcade/GameType.java | 2 +- .../game/arcade/game/games/draw/Draw.java | 21 +++++++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 5f647dcd9..343e41aa7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -86,7 +86,7 @@ public enum GameType DragonRiders(DragonRiders.class, GameDisplay.DragonRiders), Dragons(Dragons.class, GameDisplay.Dragons), DragonsTeams(DragonsTeams.class, GameDisplay.DragonsTeams), - Draw(Draw.class, GameDisplay.Draw), + Draw(Draw.class, GameDisplay.Draw, "http://chivebox.com/mineplex/ResDrawMyThing.zip", true), Evolution(Evolution.class, GameDisplay.Evolution), Gravity(Gravity.class, GameDisplay.Gravity), Halloween(Halloween.class, GameDisplay.Halloween, "http://file.mineplex.com/ResHalloween.zip", true), 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 f5303b566..891c94cd3 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 @@ -363,16 +363,15 @@ public class Draw extends SoloGame drawer.setAllowFlight(true); drawer.setFlying(true); drawer.setFlySpeed(0.4f); - - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte) 0, 1, "Thin Paint Brush")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, "Thick Paint Brush")); + + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, "Paint Brush")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte) 0, 1, "Line Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_BLOCK, (byte)0, 1, "Spray Can")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte)0, 1, "Spray Can")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BUCKET, (byte)0, 1, "Paint Bucket")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.TNT, (byte)0, 1, "Clear Canvas")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_HOE, (byte)0, 1, "Paint Bucket")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_HOE, (byte)0, 1, "Clear Canvas")); Announce(C.cGold + C.Bold + "Round " + (_roundCount+1) + ": " + C.cYellow + C.Bold + drawer.getName() + " is drawing!"); } @@ -568,7 +567,7 @@ public class Draw extends SoloGame for (Player player : _drawers.GetPlayers(true)) { - if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_BLOCK)) + if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) continue; if (!player.isBlocking()) @@ -600,7 +599,7 @@ public class Draw extends SoloGame } //Spray Can - if (UtilGear.isMat(player.getItemInHand(), Material.IRON_BLOCK)) + if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD)) { for (Block other : UtilBlock.getSurrounding(block, false)) { @@ -641,7 +640,7 @@ public class Draw extends SoloGame } //Spray Can - if (UtilGear.isMat(player.getItemInHand(), Material.IRON_BLOCK)) + if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD)) { for (Block other : UtilBlock.getSurrounding(fixBlock, false)) { @@ -674,7 +673,7 @@ public class Draw extends SoloGame Player player = event.getPlayer(); - if (!UtilGear.isMat(player.getItemInHand(), Material.TNT)) + if (!UtilGear.isMat(player.getItemInHand(), Material.GOLD_HOE)) return; if (!_drawers.HasPlayer(player)) @@ -703,7 +702,7 @@ public class Draw extends SoloGame Player player = event.getPlayer(); - if (!UtilGear.isMat(player.getItemInHand(), Material.BUCKET)) + if (!UtilGear.isMat(player.getItemInHand(), Material.IRON_HOE)) return; if (!_drawers.HasPlayer(player)) From b3045d38e79a68e776bd9fcf56801d2c18b181b1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 10 Feb 2016 16:34:00 +0000 Subject: [PATCH 08/22] Add colour selection for multiple block types. --- .../game/arcade/game/games/draw/Draw.java | 118 +++++++++--------- .../game/games/draw/kits/KitArtist.java | 4 +- 2 files changed, 62 insertions(+), 60 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 b66ce1ff1..9a140789c 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 @@ -68,6 +68,7 @@ public class Draw extends SoloGame //Brush private byte _brushColor = 15; + private Material _brushMaterial = Material.WOOL; private Location _brushPrevious = null; private boolean _lockDrawer = true; @@ -215,8 +216,11 @@ public class Draw extends SoloGame @Override public void ParseData() { - for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("LIME").get(0), WorldData.GetDataLocs("LIME").get(1), false)) - _canvas.add(b); + for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false)) + { + if (b.getType() != Material.AIR) + _canvas.add(b); + } _drawerLocation = WorldData.GetDataLocs("RED").get(0); _textLocation = WorldData.GetDataLocs("YELLOW").get(0); @@ -229,10 +233,6 @@ public class Draw extends SoloGame return; Reset(); - - for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false)) - if (b.getType().equals(Material.WOOL) && b.getData() == DyeColor.WHITE.getWoolData()) - b.setType(Material.AIR); } @EventHandler @@ -373,11 +373,12 @@ public class Draw extends SoloGame drawer.setFlying(true); drawer.setFlySpeed(0.4f); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte) 0, 1, "Pencil")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_SWORD, (byte) 0, 1, "Paint Brush")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.STONE_SWORD, (byte) 0, 1, "Line Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_SWORD, (byte)0, 1, "Square Tool")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.DIAMOND_SWORD, (byte)0, 1, "Circle Tool")); - drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.WOOD_SWORD, (byte)0, 1, "Spray Can")); + drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.BOW, (byte)0, 1, "Spray Can")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_HOE, (byte)0, 1, "Paint Bucket")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_HOE, (byte)0, 1, "Clear Canvas")); @@ -564,7 +565,7 @@ public class Draw extends SoloGame for (Tool tool : _tools) tool.update(); } - + @EventHandler public void Paint(UpdateEvent event) { @@ -578,23 +579,24 @@ public class Draw extends SoloGame { if (!UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD) && !UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) continue; - + if (!player.isBlocking()) { _brushPrevious = null; continue; } - + Block block = player.getTargetBlock((HashSet) null, 200); - if (block == null || !_canvas.contains(block)) + if (block == null || !_canvas.contains(block)) continue; - if (block.getData() == _brushColor) + if (block.getData() == _brushColor && block.getType() == _brushMaterial) continue; - + //Color + block.setType(_brushMaterial); block.setData(_brushColor); - + //Thick Brush if (UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) { @@ -602,40 +604,27 @@ public class Draw extends SoloGame { if (!_canvas.contains(other)) continue; - + + block.setType(_brushMaterial); other.setData(_brushColor); } } - //Spray Can - if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD)) - { - for (Block other : UtilBlock.getSurrounding(block, false)) - { - if (!_canvas.contains(other)) - continue; - - if (Math.random() > 0.75) - continue; - - other.setData(_brushColor); - } - } - //Join Dots if (_brushPrevious != null) - { + { while (UtilMath.offset(_brushPrevious, block.getLocation().add(0.5, 0.5, 0.5)) > 0.5) - { + { _brushPrevious.add(UtilAlg.getTrajectory(_brushPrevious, block.getLocation().add(0.5, 0.5, 0.5)).multiply(0.5)); Block fixBlock = _brushPrevious.getBlock(); - + if (!_canvas.contains(fixBlock)) continue; - + + fixBlock.setType(_brushMaterial); fixBlock.setData(_brushColor); - + //Thick Brush if (UtilGear.isMat(player.getItemInHand(), Material.IRON_SWORD)) { @@ -643,33 +632,19 @@ public class Draw extends SoloGame { if (!_canvas.contains(other)) continue; - - other.setData(_brushColor); - } - } - - //Spray Can - if (UtilGear.isMat(player.getItemInHand(), Material.WOOD_SWORD)) - { - for (Block other : UtilBlock.getSurrounding(fixBlock, false)) - { - if (!_canvas.contains(other)) - continue; - - if (Math.random() > 0.75) - continue; + other.setType(_brushMaterial); other.setData(_brushColor); } } } } - + for (Player other : UtilServer.getPlayers()) other.playSound(other.getLocation(), Sound.FIZZ, 0.2f, 2f); - + _lockDrawer = false; - + _brushPrevious = block.getLocation().add(0.5, 0.5, 0.5); } } @@ -697,6 +672,7 @@ public class Draw extends SoloGame //Restore _brushColor = color; + _brushMaterial = Material.WOOL; _lockDrawer = false; for (Player other : UtilServer.getPlayers()) @@ -723,29 +699,34 @@ public class Draw extends SoloGame //Fill byte color = block.getData(); + Material material = block.getType(); - if (color == _brushColor) + if (color == _brushColor && material == _brushMaterial) return; - FillRecurse(block, color); + FillRecurse(block, color, material); for (Player other : UtilServer.getPlayers()) other.playSound(other.getLocation(), Sound.SPLASH, 0.4f, 1.5f); } - public void FillRecurse(Block block, byte color) + public void FillRecurse(Block block, byte color, Material material) { + if (block.getType() != material) + return; + if (block.getData() != color) return; if (!_canvas.contains(block)) return; + block.setType(_brushMaterial); block.setData(_brushColor); for (Block other : UtilBlock.getSurrounding(block, false)) { - FillRecurse(other, color); + FillRecurse(other, color, material); } } @@ -761,10 +742,15 @@ public class Draw extends SoloGame return; Block block = player.getTargetBlock((HashSet) null, 200); - if (block == null || block.getType() != Material.WOOL || _canvas.contains(block)) + + List possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0), + WorldData.GetDataLocs("GREEN").get(1)); + + if (block == null || !possibleBlocks.contains(block)) return; _brushColor = block.getData(); + _brushMaterial = block.getType(); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 2f, 1f); } @@ -779,6 +765,7 @@ public class Draw extends SoloGame } _brushColor = 15; + _brushMaterial = Material.WOOL; if (_textBlocks != null) { @@ -961,8 +948,23 @@ public class Draw extends SoloGame return _brushColor; } + public Material getBrushMaterial() + { + return _brushMaterial; + } + public void setLock(boolean b) { _lockDrawer = b; } + + @EventHandler + public void sprayCan(UpdateEvent e) + { + if (!IsLive()) + return; + + //if (e.getType() != UpdateType.TICK) + //todo spray can BOW PULL BACK + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java index 36776e64c..ad2eb8a45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java @@ -21,13 +21,13 @@ public class KitArtist extends Kit super(manager, "Artist", KitAvailability.Free, new String[] { - "Show off your drawing skills!" + "The world is but a canvas to our imagination." }, new Perk[] { }, - EntityType.ZOMBIE, new ItemStack(Material.STONE_SWORD)); + EntityType.ZOMBIE, new ItemStack(Material.IRON_SWORD)); } @Override From 790ed4f99388ce0eca65545b25384de435a9e7f1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 11 Feb 2016 08:11:40 +0000 Subject: [PATCH 09/22] 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()); } } From 700f5ec44ac4be6468e37e5de64fffa6bcce317e Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 24 Feb 2016 07:58:50 +0000 Subject: [PATCH 10/22] Add Redo/Undo system (WIP). --- .../arcade/game/games/draw/BlockInfo.java | 25 +++++ .../game/arcade/game/games/draw/Draw.java | 100 ++++++++++++++++-- .../arcade/game/games/draw/UndoRedoData.java | 99 +++++++++++++++++ .../arcade/game/games/draw/tools/Tool.java | 25 +---- .../game/games/draw/tools/ToolCircle.java | 3 +- .../game/games/draw/tools/ToolLine.java | 1 + .../game/games/draw/tools/ToolSquare.java | 2 + 7 files changed, 223 insertions(+), 32 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/BlockInfo.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/UndoRedoData.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/BlockInfo.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/BlockInfo.java new file mode 100644 index 000000000..830b5ee0c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/BlockInfo.java @@ -0,0 +1,25 @@ +package nautilus.game.arcade.game.games.draw; + +import org.bukkit.Material; + +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; + } +} 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 82939c072..c6874b29e 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 @@ -10,7 +10,6 @@ import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -19,6 +18,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -57,7 +57,6 @@ import nautilus.game.arcade.stats.DrawGuessStatTracker; import nautilus.game.arcade.stats.KeenEyeStatTracker; import nautilus.game.arcade.stats.MrSquiggleStatTracker; import nautilus.game.arcade.stats.PureLuckStatTracker; -import sun.misc.REException; public class Draw extends SoloGame { @@ -83,6 +82,7 @@ public class Draw extends SoloGame private ArrayList _canvas = new ArrayList(); private Location _drawerLocation = null; private Location _textLocation = null; + private UndoRedoData _drawerUndoRedo = null; private Collection _textBlocks = null; @@ -366,6 +366,8 @@ public class Draw extends SoloGame //Create Round _round = new DrawRound(this, drawer); + _drawerUndoRedo = new UndoRedoData(this, drawer); + //Prep Drawer drawer.teleport(_drawerLocation); @@ -383,7 +385,9 @@ public class Draw extends SoloGame drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.IRON_HOE, (byte)0, 1, "Paint Bucket")); drawer.getInventory().addItem(ItemStackFactory.Instance.CreateStack(Material.GOLD_HOE, (byte)0, 1, "Clear Canvas")); - Announce(C.cGold + C.Bold + "Round " + (_roundCount+1) + ": " + C.cYellow + C.Bold + drawer.getName() + " is drawing!"); + drawer.getInventory().setItem(10, ItemStackFactory.Instance.CreateStack(Material.ARROW, (byte)0, 1, "Paint")); + + Announce(C.cGold + C.Bold + "Round " + (_roundCount + 1) + ": " + C.cYellow + C.Bold + drawer.getName() + " is drawing!"); } } @@ -566,6 +570,86 @@ public class Draw extends SoloGame tool.update(); } + @EventHandler + public void sprayCan(UpdateEvent e) + { + if (e.getType() != UpdateType.TICK) + return; + + if (!IsLive()) + return; + + for (Player p : _drawers.GetPlayers(true)) + { + if (!UtilGear.isMat(p.getItemInHand(), Material.BOW)) + continue; + + if (!UtilPlayer.isChargingBow(p)) + { + _brushPrevious = null; + continue; + } + + Block block = p.getTargetBlock((HashSet)null, 200); + if (block == null || !_canvas.contains(block)) + continue; + + // Spray + block.setType(_brushMaterial); + block.setData(_brushColor); + + for (Block surround : UtilBlock.getSurrounding(block, true)) + { + if (!_canvas.contains(surround)) + continue; + + if (Math.random() > 0.1) + { + block.setType(_brushMaterial); + block.setData(_brushColor); + } + } + + for (Player other : UtilServer.getPlayers()) + other.playSound(other.getLocation(), Sound.FIZZ, 0.2f, 2f); + + _lockDrawer = false; + + _brushPrevious = block.getLocation().add(0.5, 0.5, 0.5); + } + } + + @EventHandler + public void undoRedo(PlayerInteractEvent e) + { + if (!IsLive()) + return; + + Player p = e.getPlayer(); + + if (!isDrawer(p)) + return; + + Block block = p.getTargetBlock((HashSet)null, 200); + if (block == null || block.getType() != Material.STAINED_CLAY) + return; + + if (block.getData() == 14) + _drawerUndoRedo.undo(); // Undo + else if (block.getData() == 5) + _drawerUndoRedo.redo(); // Redo + } + + @EventHandler + public void sprayCanArrowCancel(EntityShootBowEvent e) + { + if (e.getEntity() instanceof Player) + { + e.setCancelled(true); + ((Player)e.getEntity()).updateInventory(); + } + } + @EventHandler public void Paint(UpdateEvent event) { @@ -958,10 +1042,8 @@ public class Draw extends SoloGame _lockDrawer = b; } - //fdmsdmfsdfpmsd - /** - * TODO: - * - Spray Can - * - Undo/Redo - */ + public UndoRedoData getDrawerUndoRedo() + { + return _drawerUndoRedo; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/UndoRedoData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/UndoRedoData.java new file mode 100644 index 000000000..99ecbeacd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/UndoRedoData.java @@ -0,0 +1,99 @@ +package nautilus.game.arcade.game.games.draw; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.recharge.Recharge; + +public class UndoRedoData +{ + private Player _player; + private ArrayList> _steps; + private int _stepIndex; + private Draw _host; + + public UndoRedoData(Draw host, Player player) + { + _player = player; + _steps = new ArrayList<>(); + _stepIndex = 0; + _host = host; + + takeSnapshot(); // Grab current white stage. + } + + public void takeSnapshot() + { + if (_stepIndex > 0) + { + // They have drawn on top of an undo. + // Set this to the current stage and + // remove snapshots in front. + for (int i = 0; i < _stepIndex; i++) + _steps.remove(0); // Remove "current" (old) snapshot. + + _stepIndex = 0; + } + + HashMap snapshot = new HashMap<>(); + + for (Block b : _host.getCanvas()) + snapshot.put(b, new BlockInfo(b.getType(), b.getData())); + + _steps.add(0, snapshot); + } + + public void undo() + { + if (_stepIndex == (_steps.size() - 1)) + { + // No snapshots to go back to. + _player.sendMessage(F.main("Game", C.cRed + "Nothing left to undo!")); + return; + } + + if (!Recharge.Instance.use(_player, "Undo", 5000, true, false)) + return; + + _player.sendMessage(F.main("Game", "You used " + C.mSkill + "Undo" + C.mBody + ".")); + + _stepIndex++; // Move back a snapshot. + resetBlocks(); + } + + public void redo() + { + if (_stepIndex == 0) + { + // No steps to go forward to. + _player.sendMessage(F.main("Game", C.cRed + "Nothing left to redo!")); + return; + } + + if (!Recharge.Instance.use(_player, "Redo", 5000, true, false)) + return; + + _player.sendMessage(F.main("Recharge", "You used " + C.mSkill + "Redo" + C.mBody + ".")); + + _stepIndex--; // Move forward a step. + resetBlocks(); + } + + private void resetBlocks() + { + HashMap step = _steps.get(_stepIndex); + for (Block b : step.keySet()) + { + // Reset blocks. + b.setType(step.get(b).getType()); + b.setData(step.get(b).getData()); + //b.getWorld().getBlockAt(b.getLocation()).setType(step.get(b).getType()); + //b.getWorld().getBlockAt(b.getLocation()).setData(step.get(b).getData()); + } + } +} 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 f2c59da59..3dad41646 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 @@ -8,6 +8,7 @@ import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent.ActionType; +import nautilus.game.arcade.game.games.draw.BlockInfo; import nautilus.game.arcade.game.games.draw.Draw; import org.bukkit.Material; @@ -18,28 +19,6 @@ 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; @@ -84,6 +63,8 @@ public abstract class Tool if (!_drawer.isOnline() || !Host.isDrawer(_drawer) || !_drawer.isBlocking()) { + Host.getDrawerUndoRedo().takeSnapshot(); // Save final shape. + _drawer = null; _start = null; _past.clear(); 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 820b1d8b7..5d94d33a2 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 @@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.draw.tools; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.game.games.draw.BlockInfo; import nautilus.game.arcade.game.games.draw.Draw; import org.bukkit.Location; @@ -56,7 +57,7 @@ public class ToolCircle extends Tool } _new.put(block, new BlockInfo(type, color)); - block.setData(Host.getColor()); block.setType(Host.getBrushMaterial()); + block.setData(Host.getColor()); } } 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 2f69b1912..07517383a 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 @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.draw.tools; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilMath; +import nautilus.game.arcade.game.games.draw.BlockInfo; import nautilus.game.arcade.game.games.draw.Draw; import org.bukkit.Location; 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 fc8fac2be..3fddd22ad 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 @@ -1,5 +1,6 @@ package nautilus.game.arcade.game.games.draw.tools; +import nautilus.game.arcade.game.games.draw.BlockInfo; import nautilus.game.arcade.game.games.draw.Draw; import org.bukkit.Location; @@ -81,6 +82,7 @@ public class ToolSquare extends Tool } _new.put(block, new BlockInfo(type, color)); + block.setType(Host.getBrushMaterial()); block.setData(Host.getColor()); } } From 35a853a198da4da63044fd592b1d992e46d1beec Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 24 Feb 2016 08:17:13 +0000 Subject: [PATCH 11/22] Remove redo/undo system as per request of @mightysigils. --- .../game/arcade/game/games/draw/Draw.java | 29 ------ .../arcade/game/games/draw/UndoRedoData.java | 99 ------------------- .../game/games/draw/kits/KitArtist.java | 2 +- .../arcade/game/games/draw/tools/Tool.java | 2 - 4 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/UndoRedoData.java 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 c6874b29e..7ebe19f4a 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 @@ -82,7 +82,6 @@ public class Draw extends SoloGame private ArrayList _canvas = new ArrayList(); private Location _drawerLocation = null; private Location _textLocation = null; - private UndoRedoData _drawerUndoRedo = null; private Collection _textBlocks = null; @@ -366,8 +365,6 @@ public class Draw extends SoloGame //Create Round _round = new DrawRound(this, drawer); - _drawerUndoRedo = new UndoRedoData(this, drawer); - //Prep Drawer drawer.teleport(_drawerLocation); @@ -619,27 +616,6 @@ public class Draw extends SoloGame } } - @EventHandler - public void undoRedo(PlayerInteractEvent e) - { - if (!IsLive()) - return; - - Player p = e.getPlayer(); - - if (!isDrawer(p)) - return; - - Block block = p.getTargetBlock((HashSet)null, 200); - if (block == null || block.getType() != Material.STAINED_CLAY) - return; - - if (block.getData() == 14) - _drawerUndoRedo.undo(); // Undo - else if (block.getData() == 5) - _drawerUndoRedo.redo(); // Redo - } - @EventHandler public void sprayCanArrowCancel(EntityShootBowEvent e) { @@ -1041,9 +1017,4 @@ public class Draw extends SoloGame { _lockDrawer = b; } - - public UndoRedoData getDrawerUndoRedo() - { - return _drawerUndoRedo; - } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/UndoRedoData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/UndoRedoData.java deleted file mode 100644 index 99ecbeacd..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/UndoRedoData.java +++ /dev/null @@ -1,99 +0,0 @@ -package nautilus.game.arcade.game.games.draw; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.recharge.Recharge; - -public class UndoRedoData -{ - private Player _player; - private ArrayList> _steps; - private int _stepIndex; - private Draw _host; - - public UndoRedoData(Draw host, Player player) - { - _player = player; - _steps = new ArrayList<>(); - _stepIndex = 0; - _host = host; - - takeSnapshot(); // Grab current white stage. - } - - public void takeSnapshot() - { - if (_stepIndex > 0) - { - // They have drawn on top of an undo. - // Set this to the current stage and - // remove snapshots in front. - for (int i = 0; i < _stepIndex; i++) - _steps.remove(0); // Remove "current" (old) snapshot. - - _stepIndex = 0; - } - - HashMap snapshot = new HashMap<>(); - - for (Block b : _host.getCanvas()) - snapshot.put(b, new BlockInfo(b.getType(), b.getData())); - - _steps.add(0, snapshot); - } - - public void undo() - { - if (_stepIndex == (_steps.size() - 1)) - { - // No snapshots to go back to. - _player.sendMessage(F.main("Game", C.cRed + "Nothing left to undo!")); - return; - } - - if (!Recharge.Instance.use(_player, "Undo", 5000, true, false)) - return; - - _player.sendMessage(F.main("Game", "You used " + C.mSkill + "Undo" + C.mBody + ".")); - - _stepIndex++; // Move back a snapshot. - resetBlocks(); - } - - public void redo() - { - if (_stepIndex == 0) - { - // No steps to go forward to. - _player.sendMessage(F.main("Game", C.cRed + "Nothing left to redo!")); - return; - } - - if (!Recharge.Instance.use(_player, "Redo", 5000, true, false)) - return; - - _player.sendMessage(F.main("Recharge", "You used " + C.mSkill + "Redo" + C.mBody + ".")); - - _stepIndex--; // Move forward a step. - resetBlocks(); - } - - private void resetBlocks() - { - HashMap step = _steps.get(_stepIndex); - for (Block b : step.keySet()) - { - // Reset blocks. - b.setType(step.get(b).getType()); - b.setData(step.get(b).getData()); - //b.getWorld().getBlockAt(b.getLocation()).setType(step.get(b).getType()); - //b.getWorld().getBlockAt(b.getLocation()).setData(step.get(b).getData()); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java index ad2eb8a45..8777f16ea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/draw/kits/KitArtist.java @@ -21,7 +21,7 @@ public class KitArtist extends Kit super(manager, "Artist", KitAvailability.Free, new String[] { - "The world is but a canvas to our imagination." + "The world is but a canvas to your imagination." }, new Perk[] { 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 3dad41646..b0568ab0d 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 @@ -63,8 +63,6 @@ public abstract class Tool if (!_drawer.isOnline() || !Host.isDrawer(_drawer) || !_drawer.isBlocking()) { - Host.getDrawerUndoRedo().takeSnapshot(); // Save final shape. - _drawer = null; _start = null; _past.clear(); From a5060e014b8df62f2bc839bbbed8cfe929629c8b Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 24 Feb 2016 21:34:41 +0000 Subject: [PATCH 12/22] Replace old paint bucket recursive filling. --- .../game/arcade/game/games/draw/Draw.java | 126 ++++++++++++------ 1 file changed, 84 insertions(+), 42 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 7ebe19f4a..99c04736d 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 @@ -740,53 +740,95 @@ public class Draw extends SoloGame } @EventHandler - public void PaintBucket(PlayerInteractEvent event) - { + public void paintFill(PlayerInteractEvent e) + { if (!IsLive()) return; - - Player player = event.getPlayer(); - if (!UtilGear.isMat(player.getItemInHand(), Material.IRON_HOE)) - return; + Player p = e.getPlayer(); - if (!_drawers.HasPlayer(player)) - return; - - Block block = player.getTargetBlock((HashSet) null, 200); - if (block == null || !_canvas.contains(block)) - return; - - //Fill - byte color = block.getData(); - Material material = block.getType(); - - if (color == _brushColor && material == _brushMaterial) - return; - - FillRecurse(block, color, material); - - for (Player other : UtilServer.getPlayers()) - other.playSound(other.getLocation(), Sound.SPLASH, 0.4f, 1.5f); - } - - public void FillRecurse(Block block, byte color, Material material) - { - if (block.getType() != material) - return; - - if (block.getData() != color) - return; - - if (!_canvas.contains(block)) - return; - - block.setType(_brushMaterial); - block.setData(_brushColor); - - for (Block other : UtilBlock.getSurrounding(block, false)) + if (!UtilGear.isMat(p.getItemInHand(), Material.IRON_HOE)) { - FillRecurse(other, color, material); + // Not the correct tool (iron hoe = paint fill). + return; + } + + if (!_drawers.HasPlayer(p)) + { + // Not drawing. + return; + } + + // Get the target block that the player clicks on. + Block target = p.getTargetBlock((HashSet)null, 200); + + if (target == null || !_canvas.contains(target)) + { + // Target block is non-existent or not in the canvas. + return; + } + + // Play sound to all players. + for (Player player : UtilServer.getPlayers()) + { + player.playSound(player.getLocation(), Sound.SPLASH, 0.4f, 1.5f); + } + + // Save the current block info to check later if it's the same. + BlockInfo originalInfo = new BlockInfo(target.getType(), target.getData()); + + // List of blocks needing to be changed. + ArrayList pending = new ArrayList<>(); + + // Add the current target block to pending changes. + 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. + 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); + } } } From 19b6c3d95fb48c83493eaffca988f8f83576aab1 Mon Sep 17 00:00:00 2001 From: William Burns Date: Wed, 24 Feb 2016 21:37:22 +0000 Subject: [PATCH 13/22] Make sure the blocks are in the canvas. --- .../src/nautilus/game/arcade/game/games/draw/Draw.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 99c04736d..5d978c44d 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 @@ -826,6 +826,12 @@ public class Draw extends SoloGame continue blocks; } + if (!_canvas.contains(other)) + { + // Block isn't in the canvas. + continue blocks; + } + // Add it to the pending list for change later. pending.add(other); } From 7f6517a823e4839d9ec20618d5dc54355e9e19fb Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 25 Feb 2016 14:23:16 +0000 Subject: [PATCH 14/22] Ignore barrier blocks when drawing. --- .../game/arcade/game/games/draw/Draw.java | 17 +++++++---------- .../game/arcade/game/games/draw/tools/Tool.java | 4 ++-- 2 files changed, 9 insertions(+), 12 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 5d978c44d..efc75824e 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 @@ -90,6 +90,9 @@ public class Draw extends SoloGame private String[] _holidayWords; private boolean _useHolidayWords = false; private HashSet _usedWords = new HashSet(); + + // Blocks to be ignored when targeting. (Air, Barrier) + public static final HashSet IGNORED_BLOCKS = new HashSet<>(Arrays.asList((byte)0, (byte)166)); public Draw(ArcadeManager manager) { @@ -587,7 +590,7 @@ public class Draw extends SoloGame continue; } - Block block = p.getTargetBlock((HashSet)null, 200); + Block block = p.getTargetBlock(IGNORED_BLOCKS, 200); if (block == null || !_canvas.contains(block)) continue; @@ -646,7 +649,7 @@ public class Draw extends SoloGame continue; } - Block block = player.getTargetBlock((HashSet) null, 200); + Block block = player.getTargetBlock(IGNORED_BLOCKS, 200); if (block == null || !_canvas.contains(block)) continue; @@ -760,7 +763,7 @@ public class Draw extends SoloGame } // Get the target block that the player clicks on. - Block target = p.getTargetBlock((HashSet)null, 200); + Block target = p.getTargetBlock(IGNORED_BLOCKS, 200); if (target == null || !_canvas.contains(target)) { @@ -826,12 +829,6 @@ public class Draw extends SoloGame continue blocks; } - if (!_canvas.contains(other)) - { - // Block isn't in the canvas. - continue blocks; - } - // Add it to the pending list for change later. pending.add(other); } @@ -849,7 +846,7 @@ public class Draw extends SoloGame if (!_drawers.HasPlayer(player)) return; - Block block = player.getTargetBlock((HashSet) null, 200); + Block block = player.getTargetBlock(IGNORED_BLOCKS, 200); List possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0), WorldData.GetDataLocs("GREEN").get(1)); 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 b0568ab0d..8fc5ad1f2 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 @@ -39,7 +39,7 @@ public abstract class Tool { if (!UtilEvent.isAction(event, ActionType.R)) return; - Block block = event.getPlayer().getTargetBlock((HashSet) null, 60); + Block block = event.getPlayer().getTargetBlock(Draw.IGNORED_BLOCKS, 60); if (block == null) return; @@ -72,7 +72,7 @@ public abstract class Tool _new = new HashMap(); //Calculate New - Block end = _drawer.getTargetBlock((HashSet) null, 64); + Block end = _drawer.getTargetBlock(Draw.IGNORED_BLOCKS, 64); if (end != null && Host.getCanvas().contains(end)) { customDraw(end); From a97409b64ad13ba4683f3a0553349cb96d60f096 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 25 Feb 2016 15:04:19 +0000 Subject: [PATCH 15/22] Adjust max distance for targeting. --- .../src/mineplex/core/common/util/UtilBlock.java | 1 + .../nautilus/game/arcade/game/games/draw/Draw.java | 11 ++++------- .../game/arcade/game/games/draw/tools/Tool.java | 5 +++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java index c632a1f99..8298bd7f1 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilBlock.java @@ -171,6 +171,7 @@ public class UtilBlock blockPassSet.add((byte) Material.STAINED_GLASS_PANE.getId()); blockPassSet.add((byte) Material.IRON_TRAPDOOR.getId()); blockPassSet.add((byte) Material.DAYLIGHT_DETECTOR_INVERTED.getId()); + blockPassSet.add((byte) Material.BARRIER.getId()); blockPassSet.add((byte) Material.BIRCH_FENCE_GATE.getId()); blockPassSet.add((byte) Material.JUNGLE_FENCE_GATE.getId()); 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 efc75824e..c30b0ba1c 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 @@ -91,9 +91,6 @@ public class Draw extends SoloGame private boolean _useHolidayWords = false; private HashSet _usedWords = new HashSet(); - // Blocks to be ignored when targeting. (Air, Barrier) - public static final HashSet IGNORED_BLOCKS = new HashSet<>(Arrays.asList((byte)0, (byte)166)); - public Draw(ArcadeManager manager) { super(manager, GameType.Draw, @@ -590,7 +587,7 @@ public class Draw extends SoloGame continue; } - Block block = p.getTargetBlock(IGNORED_BLOCKS, 200); + Block block = p.getTargetBlock(UtilBlock.blockPassSet, 400); if (block == null || !_canvas.contains(block)) continue; @@ -649,7 +646,7 @@ public class Draw extends SoloGame continue; } - Block block = player.getTargetBlock(IGNORED_BLOCKS, 200); + Block block = player.getTargetBlock(UtilBlock.blockPassSet, 400); if (block == null || !_canvas.contains(block)) continue; @@ -763,7 +760,7 @@ public class Draw extends SoloGame } // Get the target block that the player clicks on. - Block target = p.getTargetBlock(IGNORED_BLOCKS, 200); + Block target = p.getTargetBlock(UtilBlock.blockPassSet, 400); if (target == null || !_canvas.contains(target)) { @@ -846,7 +843,7 @@ public class Draw extends SoloGame if (!_drawers.HasPlayer(player)) return; - Block block = player.getTargetBlock(IGNORED_BLOCKS, 200); + Block block = player.getTargetBlock(UtilBlock.blockPassSet, 400); List possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0), WorldData.GetDataLocs("GREEN").get(1)); 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 8fc5ad1f2..acc0ecceb 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 @@ -4,6 +4,7 @@ package nautilus.game.arcade.game.games.draw.tools; import java.util.HashMap; import java.util.HashSet; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilServer; @@ -39,7 +40,7 @@ public abstract class Tool { if (!UtilEvent.isAction(event, ActionType.R)) return; - Block block = event.getPlayer().getTargetBlock(Draw.IGNORED_BLOCKS, 60); + Block block = event.getPlayer().getTargetBlock(UtilBlock.blockPassSet, 400); if (block == null) return; @@ -72,7 +73,7 @@ public abstract class Tool _new = new HashMap(); //Calculate New - Block end = _drawer.getTargetBlock(Draw.IGNORED_BLOCKS, 64); + Block end = _drawer.getTargetBlock(UtilBlock.blockPassSet, 400); if (end != null && Host.getCanvas().contains(end)) { customDraw(end); From 009d48659b64e7b4b106a339d93ebc7042d560f6 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 25 Feb 2016 15:29:47 +0000 Subject: [PATCH 16/22] Add commands for naming items. --- .../src/mineplex/mapparser/MapParser.java | 24 ++------ .../mapparser/command/AddLoreCommand.java | 58 +++++++++++++++++++ .../mapparser/command/ClearLoreCommand.java | 40 +++++++++++++ .../mapparser/command/ItemNameCommand.java | 52 +++++++++++++++++ 4 files changed, 154 insertions(+), 20 deletions(-) create mode 100644 Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java create mode 100644 Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ClearLoreCommand.java create mode 100644 Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ItemNameCommand.java diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java index 88522f513..86a7e7b6c 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/MapParser.java @@ -22,26 +22,7 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilWorld; -import mineplex.mapparser.command.AdminCommand; -import mineplex.mapparser.command.AuthorCommand; -import mineplex.mapparser.command.BaseCommand; -import mineplex.mapparser.command.CopyCommand; -import mineplex.mapparser.command.CopySchematicsCommand; -import mineplex.mapparser.command.CreateCommand; -import mineplex.mapparser.command.DeleteCommand; -import mineplex.mapparser.command.GameTypeCommand; -import mineplex.mapparser.command.HubCommand; -import mineplex.mapparser.command.ListCommand; -import mineplex.mapparser.command.MapCommand; -import mineplex.mapparser.command.NameCommand; -import mineplex.mapparser.command.ParseCommand200; -import mineplex.mapparser.command.ParseCommand400; -import mineplex.mapparser.command.ParseCommand600; -import mineplex.mapparser.command.RenameCommand; -import mineplex.mapparser.command.SaveCommand; -import mineplex.mapparser.command.SetSpawnCommand; -import mineplex.mapparser.command.SpawnCommand; -import mineplex.mapparser.command.WorldsCommand; +import mineplex.mapparser.command.*; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -120,6 +101,9 @@ public class MapParser extends JavaPlugin implements Listener _commands.add(new CopyCommand(this)); _commands.add(new SpawnCommand(this)); _commands.add(new SetSpawnCommand(this)); + _commands.add(new ItemNameCommand(this)); + _commands.add(new AddLoreCommand(this)); + _commands.add(new ClearLoreCommand(this)); } @Override diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java new file mode 100644 index 000000000..14f5ad669 --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java @@ -0,0 +1,58 @@ +package mineplex.mapparser.command; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.core.common.util.F; +import mineplex.mapparser.MapParser; + +public class AddLoreCommand extends BaseCommand +{ + public AddLoreCommand(MapParser plugin) + { + super(plugin, "addlore", "al"); + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + if (args == null || args.length < 1) + { + message(player, "Invalid Usage: " + F.elem("/" + alias + " ")); + return true; + } + + ItemStack is = player.getItemInHand(); + + if (is == null || is.getType() == Material.AIR) + { + message(player, "You must be holding an item in your hand."); + return true; + } + + ItemMeta im = is.getItemMeta(); + + String line = ""; + for (int i = 0; i < args.length; i++) + { + line += args[i] + " "; + } + line = line.replaceAll("&", "§").trim(); + + List lore = new ArrayList<>(im.getLore()); + lore.add(line); + im.setLore(lore); + is.setItemMeta(im); + + player.setItemInHand(is); + player.updateInventory(); + message(player, "Added lore: " + line); + + return true; + } +} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ClearLoreCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ClearLoreCommand.java new file mode 100644 index 000000000..d6c6a38d6 --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ClearLoreCommand.java @@ -0,0 +1,40 @@ +package mineplex.mapparser.command; + +import java.util.ArrayList; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +import mineplex.mapparser.MapParser; + +public class ClearLoreCommand extends BaseCommand +{ + public ClearLoreCommand(MapParser plugin) + { + super(plugin, "clearlore", "cl"); + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + ItemStack is = player.getItemInHand(); + + if (is == null || is.getType() == Material.AIR) + { + message(player, "You must be holding an item in your hand."); + return true; + } + + ItemMeta im = is.getItemMeta(); + im.setLore(new ArrayList<>()); + is.setItemMeta(im); + + player.setItemInHand(is); + player.updateInventory(); + message(player, "Cleared lore on item!"); + + return true; + } +} diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ItemNameCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ItemNameCommand.java new file mode 100644 index 000000000..95205dd51 --- /dev/null +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/ItemNameCommand.java @@ -0,0 +1,52 @@ +package mineplex.mapparser.command; + +import mineplex.core.common.util.F; +import mineplex.mapparser.MapParser; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class ItemNameCommand extends BaseCommand +{ + public ItemNameCommand(MapParser plugin) + { + super(plugin, "itemname", "in"); + } + + @Override + public boolean execute(Player player, String alias, String[] args) + { + if (args == null || args.length < 1) + { + message(player, "Invalid Usage: " + F.elem("/" + alias + " ")); + return true; + } + + ItemStack is = player.getItemInHand(); + + if (is == null || is.getType() == Material.AIR) + { + message(player, "You must be holding an item in your hand."); + return true; + } + + ItemMeta im = is.getItemMeta(); + + String name = ""; + for (int i = 0; i < args.length; i++) + { + name += args[i] + " "; + } + name = name.replaceAll("&", "§").trim(); + + im.setDisplayName(name); + is.setItemMeta(im); + + player.setItemInHand(is); + player.updateInventory(); + message(player, "Set name: " + name); + + return true; + } +} From 9a8c4104485cc3a47203b6b7dbcf393676df50c6 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 25 Feb 2016 15:39:18 +0000 Subject: [PATCH 17/22] Fix lore being null. --- .../src/mineplex/mapparser/command/AddLoreCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java index 14f5ad669..fb3c6d391 100644 --- a/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java +++ b/Plugins/Mineplex.MapParser/src/mineplex/mapparser/command/AddLoreCommand.java @@ -44,7 +44,7 @@ public class AddLoreCommand extends BaseCommand } line = line.replaceAll("&", "§").trim(); - List lore = new ArrayList<>(im.getLore()); + List lore = (im.getLore() != null ? new ArrayList<>(im.getLore()) : new ArrayList<>()); lore.add(line); im.setLore(lore); is.setItemMeta(im); From dead7a0850da0ea2c2c3b39fc94f2016c6e740f6 Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 25 Feb 2016 16:09:00 +0000 Subject: [PATCH 18/22] Use a different method for targeting blocks. --- .../mineplex/core/common/util/UtilPlayer.java | 45 +++++++++++++++++++ .../game/arcade/game/games/draw/Draw.java | 8 ++-- .../arcade/game/games/draw/tools/Tool.java | 7 ++- 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 268a3cbc8..35664b776 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -15,6 +15,7 @@ import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory; @@ -30,6 +31,8 @@ import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PlayerConnection; +import org.apache.commons.lang3.Validate; + public class UtilPlayer { private static Random RANDOM = new Random(); @@ -755,4 +758,46 @@ public class UtilPlayer looking.multiply(distance); return player.getEyeLocation().clone().add(looking); } + + public static Block getTargetBlock(List ignore, Entity entity, int minDistance, int maxDistance) + { + Location location = offset(entity, minDistance, false); + + Validate.isTrue(maxDistance > minDistance, "Max distance must be larger than min distance."); + + for (int i = 0; i < maxDistance - minDistance; i++) + { + Material type = location.getBlock().getType(); + + if (i + maxDistance >= maxDistance) + { + break; + } + + if (ignore != null && !ignore.contains(type) || ignore == null && !type.equals(Material.AIR)) + { + break; + } + + location = offset(entity, 1, false); + } + + return location.getBlock(); + } + + private static Location offset(Entity entity, double strength, boolean reverse) + { + double x = entity.getLocation().getBlockX(); + double y = entity.getLocation().getBlockY(); + double z = entity.getLocation().getBlockZ(); + + double yaw = Math.toRadians(entity.getLocation().getYaw()); + double pitch = Math.toRadians(entity.getLocation().getPitch()); + + x = reverse ? (x + strength * Math.sin(yaw)) : (x - strength * Math.sin(yaw)); + y = reverse ? (y + strength * Math.sin(pitch)) : (y - strength * Math.sin(pitch)); + z = reverse ? (z - strength * Math.cos(yaw)) : (z + strength * Math.cos(yaw)); + + return new Location(entity.getWorld(), x, y, z); + } } 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 c30b0ba1c..d0be4db71 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 @@ -587,7 +587,7 @@ public class Draw extends SoloGame continue; } - Block block = p.getTargetBlock(UtilBlock.blockPassSet, 400); + Block block = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), p, 50, 400); if (block == null || !_canvas.contains(block)) continue; @@ -646,7 +646,7 @@ public class Draw extends SoloGame continue; } - Block block = player.getTargetBlock(UtilBlock.blockPassSet, 400); + Block block = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), player, 50, 400); if (block == null || !_canvas.contains(block)) continue; @@ -760,7 +760,7 @@ public class Draw extends SoloGame } // Get the target block that the player clicks on. - Block target = p.getTargetBlock(UtilBlock.blockPassSet, 400); + Block target = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), p, 50, 400); if (target == null || !_canvas.contains(target)) { @@ -843,7 +843,7 @@ public class Draw extends SoloGame if (!_drawers.HasPlayer(player)) return; - Block block = player.getTargetBlock(UtilBlock.blockPassSet, 400); + Block block = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), player, 50, 400); List possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0), WorldData.GetDataLocs("GREEN").get(1)); 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 acc0ecceb..042750c22 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 @@ -1,12 +1,14 @@ package nautilus.game.arcade.game.games.draw.tools; +import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilEvent.ActionType; import nautilus.game.arcade.game.games.draw.BlockInfo; @@ -40,7 +42,8 @@ public abstract class Tool { if (!UtilEvent.isAction(event, ActionType.R)) return; - Block block = event.getPlayer().getTargetBlock(UtilBlock.blockPassSet, 400); + + Block block = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), event.getPlayer(), 50, 400); if (block == null) return; @@ -73,7 +76,7 @@ public abstract class Tool _new = new HashMap(); //Calculate New - Block end = _drawer.getTargetBlock(UtilBlock.blockPassSet, 400); + Block end = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), _drawer, 50, 400); if (end != null && Host.getCanvas().contains(end)) { customDraw(end); From e4ba5d9723daee32fb0cd5875281993b8208b72f Mon Sep 17 00:00:00 2001 From: William Burns Date: Thu, 25 Feb 2016 19:48:15 +0000 Subject: [PATCH 19/22] Fix colour targeting FINALLY! --- .../mineplex/core/common/util/UtilPlayer.java | 54 +++++++------------ .../game/arcade/game/games/draw/Draw.java | 29 ++++++++-- .../arcade/game/games/draw/tools/Tool.java | 4 +- 3 files changed, 45 insertions(+), 42 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index 35664b776..e013329cf 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -1,9 +1,9 @@ package mineplex.core.common.util; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -14,7 +14,6 @@ import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; @@ -25,14 +24,13 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.potion.PotionEffect; +import org.bukkit.util.BlockIterator; import org.bukkit.util.Vector; import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.PlayerConnection; -import org.apache.commons.lang3.Validate; - public class UtilPlayer { private static Random RANDOM = new Random(); @@ -759,45 +757,31 @@ public class UtilPlayer return player.getEyeLocation().clone().add(looking); } - public static Block getTargetBlock(List ignore, Entity entity, int minDistance, int maxDistance) + public static Block getTarget(LivingEntity entity, HashSet ignore, int maxDistance) { - Location location = offset(entity, minDistance, false); + Iterator itr = new BlockIterator(entity, maxDistance); - Validate.isTrue(maxDistance > minDistance, "Max distance must be larger than min distance."); - - for (int i = 0; i < maxDistance - minDistance; i++) + while (itr.hasNext()) { - Material type = location.getBlock().getType(); + Block block = itr.next(); + int id = block.getTypeId(); - if (i + maxDistance >= maxDistance) + if (ignore == null) { - break; + if (id != 0) + { + return block; + } } - - if (ignore != null && !ignore.contains(type) || ignore == null && !type.equals(Material.AIR)) + else { - break; + if (!ignore.contains((byte)id)) + { + return block; + } } - - location = offset(entity, 1, false); } - return location.getBlock(); - } - - private static Location offset(Entity entity, double strength, boolean reverse) - { - double x = entity.getLocation().getBlockX(); - double y = entity.getLocation().getBlockY(); - double z = entity.getLocation().getBlockZ(); - - double yaw = Math.toRadians(entity.getLocation().getYaw()); - double pitch = Math.toRadians(entity.getLocation().getPitch()); - - x = reverse ? (x + strength * Math.sin(yaw)) : (x - strength * Math.sin(yaw)); - y = reverse ? (y + strength * Math.sin(pitch)) : (y - strength * Math.sin(pitch)); - z = reverse ? (z - strength * Math.cos(yaw)) : (z + strength * Math.cos(yaw)); - - return new Location(entity.getWorld(), x, y, z); + return null; } } 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 d0be4db71..fb051695c 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 @@ -106,7 +106,7 @@ public class Draw extends SoloGame new String[] { "Take turns to draw something", - "Right-Click with Swords to draw", + "Right-Click with items to draw", "Hints are given at top of screen", }); @@ -587,7 +587,7 @@ public class Draw extends SoloGame continue; } - Block block = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), p, 50, 400); + Block block = UtilPlayer.getTarget(p, UtilBlock.blockPassSet, 400); if (block == null || !_canvas.contains(block)) continue; @@ -646,7 +646,7 @@ public class Draw extends SoloGame continue; } - Block block = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), player, 50, 400); + Block block = UtilPlayer.getTarget(player, UtilBlock.blockPassSet, 400); if (block == null || !_canvas.contains(block)) continue; @@ -760,7 +760,7 @@ public class Draw extends SoloGame } // Get the target block that the player clicks on. - Block target = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), p, 50, 400); + Block target = UtilPlayer.getTarget(p, UtilBlock.blockPassSet, 400); if (target == null || !_canvas.contains(target)) { @@ -843,11 +843,30 @@ public class Draw extends SoloGame if (!_drawers.HasPlayer(player)) return; - Block block = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), player, 50, 400); + Location loc = UtilPlayer.getTarget(player, UtilBlock.blockPassSet, 400).getLocation(); List possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0), WorldData.GetDataLocs("GREEN").get(1)); + Block block = player.getWorld().getBlockAt(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); + + if (block == null) + { + return; + } + + for (Block other : possibleBlocks) + { + if ( + other.getX() == block.getX() + && other.getY() == block.getY() + && other.getZ() == block.getZ() + ) + { + block = other; + } + } + if (block == null || !possibleBlocks.contains(block)) return; 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 042750c22..11893a40e 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 @@ -43,7 +43,7 @@ public abstract class Tool if (!UtilEvent.isAction(event, ActionType.R)) return; - Block block = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), event.getPlayer(), 50, 400); + Block block = UtilPlayer.getTarget(event.getPlayer(), UtilBlock.blockPassSet, 400); if (block == null) return; @@ -76,7 +76,7 @@ public abstract class Tool _new = new HashMap(); //Calculate New - Block end = UtilPlayer.getTargetBlock(Arrays.asList(Material.BARRIER, Material.AIR), _drawer, 50, 400); + Block end = UtilPlayer.getTarget(_drawer, UtilBlock.blockPassSet, 400); if (end != null && Host.getCanvas().contains(end)) { customDraw(end); From 268536ce68d23b36782b47084a454253970369eb Mon Sep 17 00:00:00 2001 From: William Burns Date: Fri, 26 Feb 2016 08:13:28 +0000 Subject: [PATCH 20/22] push 4 shaun --- .../src/nautilus/game/arcade/game/games/draw/Draw.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 fb051695c..8cf73e2d1 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 @@ -221,6 +221,10 @@ public class Draw extends SoloGame _canvas.add(b); } + System.out.println("==="); + System.out.println("Draw loc: " + WorldData.GetDataLocs("RED").size()); + System.out.println("==="); + _drawerLocation = WorldData.GetDataLocs("RED").get(0); _textLocation = WorldData.GetDataLocs("YELLOW").get(0); } @@ -600,10 +604,10 @@ public class Draw extends SoloGame if (!_canvas.contains(surround)) continue; - if (Math.random() > 0.1) + if (Math.random() > 0.5) { - block.setType(_brushMaterial); - block.setData(_brushColor); + surround.setType(_brushMaterial); + surround.setData(_brushColor); } } From 4472c52432fcfab2dacf955cc2b6f77f736dddda Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 26 Feb 2016 04:21:26 -0600 Subject: [PATCH 21/22] Fix bucket --- .../game/arcade/game/games/draw/Draw.java | 100 +++++++----------- 1 file changed, 40 insertions(+), 60 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 8cf73e2d1..aabe8f21d 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 @@ -10,6 +10,7 @@ import java.util.List; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -99,7 +100,7 @@ public class Draw extends SoloGame { //new KitSlowAndSteady(manager), //new KitSelector(manager), - //new KitTools(manager), +// new KitTools(manager), new KitArtist(manager) }, @@ -164,8 +165,8 @@ public class Draw extends SoloGame "Paint", "Guard", "Astronaut" , "Slime" , "Mansion" , "Radar" , "Thorn" , "Tears" , "Tiny" , "Candy" , "Pepsi" , "Flint" , "Draw My Thing" , "Rice" , "Shout" , "Prize" , "Skirt" , "Thief" , "Syrup" , "Kirby" , "Brush" , "Violin", "Car", "Sun", "Eye", "Bow", "Axe", "Face", "Mushroom", "Guitar", - "Book", "Pickle", "Banana", "Crab", "Sugar", "Book", "Soda", "Cookie", "Burger", "Fries", "Speaker", - "Pillow", "Rug", "Purse", "Monitor", "Bow", "Pen", "Cat", "Kitten", "Puppy", "Bed", "Bowl", "Button", + "Pickle", "Banana", "Crab", "Sugar", "Soda", "Cookie", "Burger", "Fries", "Speaker", + "Pillow", "Rug", "Purse", "Monitor", "Bow", "Pen", "Cat", "Kitten", "Puppy", "Bed", "Button", "Computer", "Key", "Spoon", "Lamp", "Bottle", "Card", "Newspaper", "Glasses", "Mountain", "Minecraft", "Shirt", "Truck", "Car", "Phone", "Cork", "iPod", "Paper", "Bag", "USB", "CD", "Wallet", "Cow", "Pig", "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", "Water", "Ocean", "Microsoft", "Twitter", "Godzilla", "Building", "House", "Rainbow", "Barbie", "Girl", "Boy", "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[] @@ -215,14 +216,19 @@ public class Draw extends SoloGame @Override public void ParseData() { + int count = 0; for (Block b : UtilBlock.getInBoundingBox(WorldData.GetDataLocs("PINK").get(0), WorldData.GetDataLocs("PINK").get(1), false)) { if (b.getType() != Material.AIR) + { _canvas.add(b); + count++; + } } System.out.println("==="); System.out.println("Draw loc: " + WorldData.GetDataLocs("RED").size()); + System.out.println("Canvas Count: " + count); System.out.println("==="); _drawerLocation = WorldData.GetDataLocs("RED").get(0); @@ -236,6 +242,9 @@ public class Draw extends SoloGame return; Reset(); + + for (Player player : GetPlayers(true)) + player.setGameMode(GameMode.ADVENTURE); } @EventHandler @@ -772,67 +781,33 @@ public class Draw extends SoloGame return; } - // Play sound to all players. - for (Player player : UtilServer.getPlayers()) + Material material = target.getType(); + 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. - BlockInfo originalInfo = new BlockInfo(target.getType(), target.getData()); + block.setTypeIdAndData(_brushMaterial.getId(), _brushColor, false); - // List of blocks needing to be changed. - ArrayList pending = new ArrayList<>(); + List around = UtilBlock.getSurrounding(block, false); - // Add the current target block to pending changes. - boolean targetBlock = true; - pending.add(target); - - // Cycle through all pending blocks if there are any left. - pendingBlocks: while (!pending.isEmpty()) + for (Block next : around) { - // Find the center block and remove it from the list sequentially. - 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); - } + fillRecursive(next, fillMaterial, fillData); } } @@ -847,7 +822,12 @@ public class Draw extends SoloGame if (!_drawers.HasPlayer(player)) 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 possibleBlocks = UtilBlock.getInBoundingBox(WorldData.GetDataLocs("GREEN").get(0), WorldData.GetDataLocs("GREEN").get(1)); From 923e51483c4db8003a3b0fa1333715e474115756 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 26 Feb 2016 04:29:27 -0600 Subject: [PATCH 22/22] Remove fill line --- .../src/nautilus/game/arcade/game/games/draw/Draw.java | 1 - 1 file changed, 1 deletion(-) 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 aabe8f21d..cc87cc712 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 @@ -787,7 +787,6 @@ public class Draw extends SoloGame if (data == _brushColor && material == _brushMaterial) return; - System.out.println("Fill..."); fillRecursive(target, material, data); for (Player other : UtilServer.getPlayers())