diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index ee32d3854..a38435696 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -811,9 +811,43 @@ public enum Achievement new String[]{"Gladiators.SwiftKill"}, new String[]{"Earn 15 first bloods", "in Gladiators"}, new int[]{15}, - AchievementCategory.GLADIATORS) + AchievementCategory.GLADIATORS), - ; + TYPE_WARS_SPEED_DEMON("Speed Demon", 1000, + new String[]{"Type Wars.Demon"}, + new String[]{"Kill 5 Mobs in 8 seconds", "by typing"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_PERFECTIONIST("Perfectionist", 1200, + new String[]{"Type Wars.Perfectionist"}, + new String[]{"Go an entire game", "without mistyping"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_WAIT_FOR_IT("Wait for it", 1200, + new String[]{"Type Wars.Nuke"}, + new String[]{"Kill 30 or more Mobs", "with a Nuke Spell"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_HOARDER("Hoarder", 1000, + new String[]{"Type Wars.Hoarder"}, + new String[]{"Summon 50 Mobs in one game"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_DUMBLEDONT("Dumbledont", 800, + new String[]{"Type Wars.Dumbledont"}, + new String[]{"Win without using any spells"}, + new int[]{1}, + AchievementCategory.TYPE_WARS), + + TYPE_WARS_WINNS("The True Typewriter", 2000, + new String[]{"Type Wars.Wins"}, + new String[]{"Win 30 Games"}, + new int[]{30}, + AchievementCategory.TYPE_WARS); private String _name; private String[] _desc; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 7813b1e09..9202f38b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -150,13 +150,14 @@ public enum AchievementCategory MONSTER_MAZE("Monster Maze", null, new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED}, Material.ROTTEN_FLESH, 0, GameCategory.ARCADE, "SoonTM"), - + GLADIATORS("Gladiators", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, - Material.IRON_SWORD, 0, GameCategory.ARCADE, null) - - ; - + Material.IRON_SWORD, 0, GameCategory.ARCADE, null), + + TYPE_WARS("Type Wars", null, + new StatDisplay[] {StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Minions killed", "MinionKills"), new StatDisplay("Words Per Minute", false, true, "MinionKills", "TimeInGame"), StatDisplay.GEMS_EARNED}, + Material.FEATHER, 0, GameCategory.ARCADE, null); private String _name; private String[] _statsToPull; private StatDisplay[] _statDisplays; @@ -243,7 +244,7 @@ public enum AchievementCategory if (!clientManager.Get(player).GetRank().has(Rank.MODERATOR) && !player.equals(target) && (displayName.contains("Losses") || displayName.contains("Kills") || displayName.contains("Deaths") || displayName.equals("Time In Game") || displayName.equals("Games Played"))) continue; - int statNumber = 0; + double statNumber = 0; // This is so we could load stats from other games @@ -256,15 +257,49 @@ public enum AchievementCategory else { for (String statToPull : _statsToPull) + { for (String statName : _statDisplays[i].getStats()) - statNumber += stats.getStat(statToPull + "." + statName); + { + if(_statDisplays[i].isDivideStats()) + { + if(statNumber == 0) + { + statNumber = stats.getStat(statToPull + "." + statName); + continue; + } + double stat = stats.getStat(statToPull + "." + statName); + if(stat == 0) + statNumber = statNumber / 1; + else + statNumber = (double) statNumber / stat; + } + else + statNumber += stats.getStat(statToPull + "." + statName); + } + } } - String statString = C.cWhite + statNumber; + String statString = C.cWhite + Math.round(statNumber); + + // doubles + // Special display for Words per Minute + if (displayName.equalsIgnoreCase("Words Per Minute")) + { + statString = C.cWhite + (double) statNumber; + if(statString.length() > 7) + statString = statString.substring(0, 7); + + lore.add(C.cYellow + displayName + ": " + statString); + continue; + } + + + // ints // Need to display special for time if (displayName.equalsIgnoreCase("Time In Game")) - statString = C.cWhite + UtilTime.convertString(statNumber * 1000L, 0, UtilTime.TimeUnit.FIT); + statString = C.cWhite + UtilTime.convertString(Math.round(statNumber) * 1000L, 0, UtilTime.TimeUnit.FIT); + lore.add(C.cYellow + displayName + ": " + statString); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java index ea7515827..0d6badd6e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java @@ -14,6 +14,7 @@ public class StatDisplay private String[] _stats; private boolean _fullStat; private boolean _justDisplayName; + private boolean _divideStats; public StatDisplay(String stat) { @@ -25,19 +26,26 @@ public class StatDisplay _displayName = stat; _stats = new String[] { stat }; _fullStat = false; + _divideStats = false; _justDisplayName = justDisplayName; } + + public StatDisplay(String displayName, boolean divideStats, String... stats) + { + this(displayName, false, divideStats, stats); + } public StatDisplay(String displayName, String... stats) { - this(displayName, false, stats); + this(displayName, false, false, stats); } - public StatDisplay(String displayName, boolean fullStat, String... stats) + public StatDisplay(String displayName, boolean fullStat, boolean divideStats, String... stats) { _displayName = displayName; _stats = stats; _fullStat = fullStat; + _divideStats = divideStats; } public String getDisplayName() @@ -59,6 +67,11 @@ public class StatDisplay { return _fullStat; } + + public boolean isDivideStats() + { + return _divideStats; + } public static StatDisplay fromGame(String name, GameDisplay gameDisplay, String... stats) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index ebdc89a02..ba6beef4b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -67,12 +67,9 @@ public enum GameDisplay MonsterLeague("Monster League", Material.MINECART, (byte)0, GameCategory.ARCADE, 56), Lobbers("Bomb Lobbers", Material.FIREBALL, (byte) 0, GameCategory.ARCADE, 54), - ChampionsCTF("Champions CTF", "Champions", Material.BANNER, DyeColor.RED.getDyeData(), GameCategory.CHAMPIONS, 56), - - BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57), - - Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58), + BouncyBalls("Bouncy Balls", Material.SLIME_BALL, (byte)0, GameCategory.ARCADE, 57), Gladiators("Gladiators", Material.IRON_SWORD, (byte)0, GameCategory.ARCADE, 58), +TypeWars("Type Wars", Material.BOOK_AND_QUILL, (byte) 0, GameCategory.ARCADE, 59), Event("Mineplex Event", Material.CAKE, (byte)0, GameCategory.EVENT, 999); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java index 11887cd53..6c2f331f6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/message/MessageManager.java @@ -219,7 +219,7 @@ public class MessageManager extends MiniClientPlugin Get(from).LastToTime = System.currentTimeMillis(); // Chiss or defek7 - if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("fooify") || to.getName().equals("sampepere")) + if (to.getName().equals("Chiss") || to.getName().equals("defek7") || to.getName().equals("Phinary") || to.getName().equals("xXVevzZXx") || to.getName().equals("fooify") || to.getName().equals("sampepere")) { UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development."); UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly."); diff --git a/Plugins/Mineplex.Queuer/.gitignore b/Plugins/Mineplex.Queuer/.gitignore index 5e56e040e..167fb2c02 100644 --- a/Plugins/Mineplex.Queuer/.gitignore +++ b/Plugins/Mineplex.Queuer/.gitignore @@ -1 +1,2 @@ /bin +/bin 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 5ff9e576c..5f647dcd9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -62,6 +62,7 @@ import nautilus.game.arcade.game.games.survivalgames.SoloSurvivalGames; import nautilus.game.arcade.game.games.survivalgames.TeamSurvivalGames; import nautilus.game.arcade.game.games.tug.Tug; import nautilus.game.arcade.game.games.turfforts.TurfForts; +import nautilus.game.arcade.game.games.typewars.TypeWars; import nautilus.game.arcade.game.games.uhc.UHC; import nautilus.game.arcade.game.games.wither.WitherGame; import nautilus.game.arcade.game.games.wizards.Wizards; @@ -104,6 +105,7 @@ public enum GameType Runner(Runner.class, GameDisplay.Runner), SearchAndDestroy(SearchAndDestroy.class, GameDisplay.SearchAndDestroy), Sheep(SheepGame.class, GameDisplay.Sheep), + TypeWars(TypeWars.class, GameDisplay.TypeWars), Smash(SoloSuperSmash.class, GameDisplay.Smash), SmashDomination(SuperSmashDominate.class, GameDisplay.SmashDomination), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java index 07e2ab006..8943458b7 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/cards/Cards.java @@ -2,17 +2,9 @@ package nautilus.game.arcade.game.games.cards; import java.util.ArrayList; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.inventory.ItemStack; - import mineplex.core.common.util.C; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilTime; -import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.ArcadeManager; @@ -23,6 +15,13 @@ import nautilus.game.arcade.game.games.GameScore; import nautilus.game.arcade.game.games.cards.kits.KitPlayer; import nautilus.game.arcade.kit.Kit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.inventory.ItemStack; + public class Cards extends SoloGame { private CardFactory _cardFactory; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateNukeSpellEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateNukeSpellEvent.java new file mode 100644 index 000000000..8b27a426e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateNukeSpellEvent.java @@ -0,0 +1,42 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class ActivateNukeSpellEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private ArrayList _minions; + + public ActivateNukeSpellEvent(Player player, ArrayList minions) + { + _player = player; + _minions = minions; + } + + public Player getPlayer() + { + return _player; + } + + public ArrayList getMinions() + { + return _minions; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateSpellEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateSpellEvent.java new file mode 100644 index 000000000..21148e56d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/ActivateSpellEvent.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.typewars; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class ActivateSpellEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private Spell _spell; + + public ActivateSpellEvent(Player player, Spell spell) + { + _player = player; + _spell = spell; + } + + public Player getPlayer() + { + return _player; + } + + public Spell getSpell() + { + return _spell; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java new file mode 100644 index 000000000..45494c974 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Minion.java @@ -0,0 +1,632 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; +import java.util.Collections; + +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.disguise.disguises.DisguiseZombie; +import mineplex.core.hologram.Hologram; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.Game.GameState; + +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Zombie; +import org.bukkit.inventory.ItemStack; + +public class Minion +{ + + private static String[] NAMES = new String[]{"Fishing", "Cookie", "Sleeping", "Diamond", "Banana", "Tree", "Egg", "Cat", + "Quadrilateral", "Rollercoaster", "Hallucinating", "Advertisement", "Entertainment", "Administrator", "Intergalactic", "International", "Understanding", "Investigation", + "Veterinarian", "Photographer", "Cheeseburger", "Civilization", "Tranquilizer", "Conversation", "EnderDragon", "Engineering", "Philippines", "Countryside", + "Electricity", "Caterpillar", "Keyboarding", "Agriculture", "Mathematics", "Millimeters", "Centimeters", "Screwdriver", "Achievement", "Necromancer", + "Grasshopper", "Quadrillion", "Horseradish", "Aboveground", "Belowground", "Mississippi", "Computerize", "Hibernation", "Radioactive", "Unfortunate", + "Demonstrate", "Gymnastics", "Toothpaste", "Paraphrase", "Limitless", "Breakfast", "Graveyard", "Philippines", "Countryside", + "Competition", "Management", "Peppermint", "Pyromaniac", "Sandstone", "Vengeance", "Passwords", "Chew", "Philippines", "Countryside", + "Competitive", "Accounting", "Generation", "Mechanized", "Minecraft", "Sprinting", "Beautiful", "Container", "Mayonaise", "Generator", + "Bombardment", "Laboratory", "BlackBerry", "Calculator", "Mushrooms", "Heartbeat", "Authority", "Apartment", "Deception", "Recommend", + "Highlighter", "Incomplete", "Javascript", "Compressor", "Dentistry", "Rectangle", "Exhausted", "Slimeball", "Commander", "Associate", + "Complicated", "Government", "Ceptillion", "Deflection", "Cosmetics", "Trapezoid", "Hamburger", "Raspberry", "Developer", "Accompany", + "Basketball", "Milkshakes", "Antibiotic", "Vocabulary", "Australia", "Dodecagon", "Miniature", "Blueberry", "Historian", "Machinery", + "Volleyball", "Earthquake", "Girlfriend", "Definition", "Christmas", "Cardboard", "Dimension", "Overreact", "Character", + "Television", "Motorcycle", "Despicable", "Contradict", "Chocolate", "Screaming", "Microsoft", "Barbarian", "Backspace", "Knowledge", + "Microphone", "Buccaneers", "Affordable", "Attendance", "Halloween", "Demanding", "Wrestling", "Lightbulb", "Wisconsin", "Secondary", + "Rhinoceros", "Applesauce", "Disconnect", "Protection", "Vacations", "Hopscotch", "Moderator", "Invisible", "Tennessee", "Adjective", + "Chestpiece", "Headphones", "Watermelon", "Reasonless", "Traveling", "Spectator", "Paintball", "Carnivore", "Awareness", "Direction", + "Complicated", "Controller", "Chimpanzee", "Deportment", "Saxophone", "Quadruple", "Champions", "Herbivore", "Unexcused", "Different", + "Antarctica", "Paintbrush", "Newsletter", "Appearance", "Hurricane", "Autopilot", "Architect", "Automatic", "Diplomacy", "Construct", + "Snowflakes", "Typewriter", "Sunglasses", "Occupation", "Piercings", "Principle", "Sharpness", "Performer", "Valentine", "Alternate", + "Strawberry", "Smartwatch", "Horrendous", "Antarctica", "Necklaces", "September", "Trademark", "Miniscule", "Copyright", "Opposable", + "Blackholes", "Minestrike", "California", "Wristwatch", "Evolution", "Microwave", "Dangerous", "Humongous", "Practical", "Imaginary", + "Rocketship", "Deathmatch", "Transplant", "Confusion", "Spaceship", "Eyeshadow", "Afternoon", "Judgement", "Imperfect", "Bonemeal", + "Aquamarine", "Playground", "Inevitable", "Surprised", "Lightning", "Butterfly", "Beekeeper", "Gladiator", "Excessive", "Courages", + "Levitation", "Resistance", "Inflatable", "Newspaper", "Sketching", "Centipede", "Parachute", "Treachery", "Crocodile", "Baseball", + "Vegetables", "Lighthouse", "Relentless", "Dinosaurs", "Teenagers", "Cartwheel", "Barricade", "Blowtorch", "Alligator", "Presents", + "Whispering", "Helicopter", "Mistakable", "Tarantula", "Grassland", "President", "Raincloud", "Incentive", "Balloons", + "Announcing", "Mechanical", "Expectance", "Mountains", "Fingertip", "Millenium", "Structure", "Keyboard", + "Meditation", "Toothbrush", "Tumbleweed", "Sandstone", "Dumplings", "Scientist", "Pineapple", "Boyfriend", "Spotlight", "Computer", + "Clothing", "Elephant", "Reptiles", "Scorpion", "Redstone", "Diamonds", "Porkchop", "Endermen", "Obsidian", "Planting", + "Potatoes", "Vampires", "Bracelet", "Coloring", "Thousand", "Hologram", "Lipstick", "Cruising", "Delivery", "Dreaming", + "Minecart", "Werewolf", "Highways", "Painting", "Infinity", "Ancestor", "Eyeliner", "Complete", "Packages", "Thinking", + "Unicorns", "Pumpkins", "Internet", "Toddlers", "Swimming", "Wreckage", "Siblings", "Branches", "Criminal", "Engineer", + "Military", "Costumes", "Earrings", "Children", "Triangle", "Defender", "Baguette", "Politics", "Handsome", "Reindeer", + "Portland", "Chipotle", "Dolphins", "Pre-teen", "Pentagon", "Homework", "Princess", "Citizens", "Gorgeous", "Necklace", + "Penguins", "Sapphire", "Galaxies", "Campfire", "Heptagon", "February", "Alphabet", "Username", "Panthers", "Mineplex", + "Barbecue", "Amethyst", "Cartoons", "Tropical", "Lollipop", "November", "Scissors", "Medicine", "Warriors", "Pallette", + "Mermaids", "Clarinet", "Basement", "Broccoli", "Shouting", "December", "Eternity", "Behavior", "Chatting", "Dominate", + "Assassin", "Elevator", "Weakness", "Blizzard", "Entrance", "Universe", "Teleport", "Director", "Stuffing", "Eruption", + "Godzilla", "Electron", "Strength", "Powerful", "Dynamite", "Backyard", "Gradient", "Producer", "Festival", "Mattress", + "Empoleon", "Building", "Dinosaur", "Illusion", "Mustache", "Ceremony", "Shipment", "Cosmetic", "Applause", "Research", + "Chimchar", "Aquarium", "Sidewalk", "Calendar", "Treasure", "Airplane", "Envelope", "Kangaroo", "Goldfish", "Starfish", + "Nickname", "Slowness", "Official", "Accident", "Cinnamon", "Collapse", "Geometry", "Barnacle", "Football", "Creative", + "Hypnotic", "Antidote", "Emulator", "Foothold", "Friction", "Tungsten", "Tablets", "Torches", "Fairies", "Windows", + "Conquest", "Province", "Overflow", "Graceful", "Negative", "Doctrine", "Charger", "Carrots", "Spirits", "Robbers", + "Karambit", "Solution", "Sandwich", "Catapult", "Positive", "Firework", "Ukulele", "Dragons", "Cobwebs", "Drawing", + "Internal", "Japanese", "Atronomy", "Villager", "Tranquil", "Compress", "Glasses", "Nursing", "College", "Magenta", + "Trillion", "Standard", "Astrology", "Infringe", "Fortress", "Prisoner", "Daisies", "Soldier", "Courses", "Serpent", + "Carnival", "Parasite", "Porridge", "Variable", "Charcoal", "Decision", "Hazards", "Jupiter", "Buttons", "Camping", + "Concrete", "Carriage", "Pressure", "Practice", "Commerce", "Windmill", "Cheetah", "Mercury", "Octopus", "Canyons", + "Pavement", "Auxilary", "Demolish", "Maintain", "Barbeque", "Parmesan", "Vulture", "America", "Printer", "Seventy", + "Joystick", "Marshall", "Franklin", "Umbrella", "Contract", "Warthog", "Turtles", "Ireland", "Titanic", "Hundred", + "Speaker", "Suitcase", "Michigan", "Darkness", "Separate", "Puzzled", "Ocelots", "Germany", "Vanilla", "Million", + "Figurine", "Mandarin", "Arkansas", "Ethernet", "Eligible", "Shocked", "Creeper", "Chillie", "Tornado", "Billion", + "Boundary", "Anteater", "Colorado", "Everyday", "Fraction", "Figures", "Zombies", "Jamaica", "Seaweed", "Twitter", + "Birthday", "Sunshine", "Virginia", "Surprise", "Compound", "Pillows", "Leather", "Bermuda", "Craters", "Waiting", + "Hogwarts", "Particle", "American", "Together", "Precious", "Erasers", "Chicken", "Bahamas", "Meteors", "Passion", + "Walking", "Decagon", "Spatula", "Science", "Bicycle", "Animate", "Cereal", "Graphic", "Message", "Episode", + "Running", "Talking", "Cooking", "Biology", "Sweater", "Cabinet", "Pokemon", "Kingdom", "Funeral", "Destroy", + "Jogging", "Yelling", "Fashion", "Pajamas", "Lettuce", "Furnace", "Chariot", "Package", "Grinder", "Defrost", + "Breathe", "Ladybug", "Brother", "Reflect", "Cheddar", "Bridges", "Spawner", "Exhibit", "Nuclear", "Avocado", + "Muscles", "Invader", "Grandpa", "Confirm", "Speaker", "Wizards", "Stacker", "Feather", "Channel", "Thunder", + "Marbles", "Contest", "Grandma", "History", "Minigun", "Skywars", "Turtwig", "Morning", "Explode", "Factory", + "Polygon", "Teacher", "Royalty", "Balcony", "Android", "Monster", "Emerald", "Primate", "Village", "Company", + "Degrees", "Glacier", "Cricket", "Partner", "Medieval", "Gravity", "Surgeon", "Volcano", "Forward", "Console", + "Hexagon", "Cyclops", "Kung-fu", "Bonjour", "Painter", "Snowman", "Caramel", "Lullaby", "Sparrow", "Blowgun", + "Octagon", "January", "Century", "Bowling", "Plumber", "Explore", "Healing", "Circuit", "Vampire", "Distort", + "Nonagon", "October", "Lockers", "Justice", "England", "Pancake", "Whisper", "Voltage", "Ceramic", "Avenger", + "Bazooka", "Actress", "Highway", "Fighter", "Notepad", "Knuckle", "YouTube", "Fishing", "Florida", "Capsule", + "Missile", "Haircut", "Apricot", "Deathly", "Cracker", "Western", "Colonel", "Balance", "Georgia", "Boolean", + "Pyramid", "Stomach", "Dracula", "Fractal", "Network", "Eastern", "Creator", "Monitor", "Glowing", "Integer", + "Mailbox", "Phantom", "Harpoon", "Endless", "Ketchup", "English", "Sunrise", "Examine", "Blowing", "Perfect", + "Algebra", "Pattern", "Cottage", "Crystal", "Mustard", "Spanish", "Unlucky", "Tragedy", "Deviate", "Builder", + "Penguin", "Emperor", "Amplify", "Hamster", "Paprika", "Chinese", "Shackle", "Kitchen", "Liberty", "Cupcake", + "Robotic", "Fortune", "Gazelle", "Scratch", "Revenge", "Honesty", "Hideout", "Compass", "Italian", "Demoman", + "Machine", "Gymnast", "Balloon", "Country", "Poision", "Brendan", "Connect", "Fireman", "Mexican", "Neptune", + "Aquatic", "Hostage", "Program", "Witness", "Villain", "Virtual", "Supreme", "Platter", "Ukraine", "Profile", + "Hatchet", "Hangers", "Bayonet", "Gamepad", "Bandage", "Blister", "Archive", "Implode", "Hilbert", "Offline", + "Shelter", "Primary", "Organic", "Healthy", "Makeup", "Blazes", "Brazil", "Horror", "Subway", "Babies", + "Capture", "Various", "Gradual", "Rapture", "Pollen", "String", "Warren", "Moving", "Shorts", "Elders", + "Elegant", "Violate", "Heroic", "Violent", "Leaves", "Soccer", "Europe", "School", "Scarves", "Orange", + "Dentist", "Neglect", "Strong", "Solvent", "Monkey", "Closet", "Africa", "Hotels", "Sharks", "Yellow", + "Combine", "Fulfill", "Barbie", "Engrave", "Rabbit", "Carpet", "Winter", "Zipper", "Whales", "Purple", + "Surface", "Sailing", "Pencil", "Passage", "Kitten", "Saturn", "Spring", "Acorns", "Comets", + "Gelatin", "Klarin", "Phones", "Quality", "Ingots", "Uranus", "Summer", "Pariot", "Comedy", "Poison", + "Similar", "Flutter", "Shield", "Psychic", "Spider", "Mexico", "Autumn", "Cruise", "Sports", "Forest", + "Oxidize", "Disease", "Guitar", "Opossum", "Ghasts", "France", "Ghosts", "Lucius", "Cement", "Desert", + "Purpose", "Symptom", "Sticks", "Measure", "Slimes", "Greece", "Spooky", "Coffee", "Aliens", "Cities", + "Bikini", "Mortal", "Serena", "Future", "Bottle", "Helmet", "Crunch", "Afraid", "Threat", "Static", + "Happy", "Knife", "Scary", "Lapis", "Skirt", "Waves", "Calem", "Clock", "Taste", "Lucas", + "Anger", "Spork", "Maike", "Candy", "Shirt", "Tides", "Ocean", "Crawl", "Smell", "React", + "Dolls", "Roses", "Trips", "Flute", "Pants", "Brick", "Three", "Ethan", "Uncle", "Lunch", + "Legos", "Tulip", "Beach", "Wipes", "Heels", "Straw", "Seven", "Hands", "Queen", "Books", + "Couch", "Grass", "Clans", "Frame", "Nails", "Cream", "Eight", "Belly", "Crown", "Polls", + "Vases", "Tiger", "Wagon", "Sleet", "Rings", "Attic", "Forty", "Chest", "Staff", "Hello", + "Sword", "Panda", "Sleep", "Roads", "Money", "Green", "Fifty", "Brush", "Tools", "Howdy", + "Banjo", "Sloth", "X-ray", "Truck", "Coral", "Speed", "Sixty", "Peace", "Music", "Court", + "Drums", "Snake", "Socks", "Plane", "Reefs", "Hilda", "Brown", "Heart", "Lucia", "Raven", + "Spoon", "Boots", "Pearl", "Train", "Horse", "Woods", "Silly", "Lotta", "Month", "Games", + "Love", "Cats", "Lava", "Ship", "Moon", "Five", "Head", "July", "Mask", "Hola", + "Rosa", "Wolf", "Soda", "Ruby", "News", "Nine", "Hair", "Feel", "Jazz", "Soft", + "Toys", "Duck", "Mars", "Mint", "Ufos", "Grey", "Ears", "Hear", "Hour", "Hard", + "Soap", "Ores", "Cuba", "Snow", "Cops", "Derp", "Eyes", "Oven", "Week", "Clay", + "Wigs", "Gold", "Asia", "Rain", "Lime", "Time", "Star", "King", "Year", "Gold", + "Fork", "Iron", "Elfs", "Suit", "Blue", "Tony", "Salt", "Ants", "Nate", "Mind", + "Weed", "Pigs", "Bricks", "Blue", "Pink", "Hide", "Kris", "File", "Yard", "Comb", + "Wood", "Lyra", "Frog", "Hats", "Heal", "Feet", "Yoga", "Edit", "Mile", "Paws", + "Bird", "Wool", "Fish", "Eels", "Jump", "Arms", "Boom", "View", "Girl", "Tree", + "Lion", "Dirt", "Yarn", "Dawn", "Four", "Neck", "June", "Help", "Mail", "Lamp", + "Sad", "Sun", "Pan", "Yes", "Dad", "Bat", "Wig", "KFC", "War", "Fan", + "Red", "Jam", "Ivy", "Map", "Fur", "Yen", "Hum", "May", "Dog", + "One", "Day", "Sky", "Add", "Orb", "Hip", "Sew", "Act", "Ice", + "Two", "Gum", "Cow", "Moo", "Bee", "Ape", "Zoo", "Pit", "Hat", + "Six", "Gym", "Rat", "Mow", "Pot", "Dot", "Paw", "Hen", "Bed", + "Ten", "Art", "Bag", "Mob", "End", "Egg", "Saw", "Law", "Fog", + "Fly", "Boy", "Rag", "New", "Jet", "Pet", "Tin", "Pen", "Car", + "Old", "Age", "TNT", "Leg", "Axe", "UFO", "Rap", "Wet", "Tie", + "May", "Gas", "Hue", "Wax", "Toy", "Lay", "Pop", "Dry", "Sea", + "See", "Ash", "Mom", "Box", "Key", "Fat", "Spy"}; + + private ArcadeManager _manager; + + private MinionType _type; + private Entity _entity; + private String _name; + private Location _location; + private Location _target; + private GameTeam _team; + private Player _player; + private Player _killer; + private Location _lastNameChanged; + private Hologram _hologram; + private int _money; + private float _walkSpeed; + private boolean _spawned; + private double _tagHight; + private boolean _moving; + + private int _size; + + private int _spawnID; + + private boolean _die; + private boolean _killed; + private int _frame; + private int _lives; + + public Minion(ArcadeManager manager, Location location, Location target, GameTeam team, int spawnID) + { + this(manager, location, target, team, null, true, null, spawnID); + } + + public Minion(ArcadeManager manager, Location location, Location target, GameTeam team, Player player, boolean spawn, MinionType type, int spawnID) + { + _manager = manager; + + _type = type; + _moving = true; + if(_type == null) + _type = randomType(); + + _walkSpeed = _type.getWalkSpeed(); + _tagHight = _type.getTagHight(); + _die = false; + _killed = false; + _frame = 0; + _entity = null; + _team = team; + _player = player; + _killer = null; + _money = _type.getMoney(); + _spawnID = spawnID; + _size = 10; + if(_type == MinionType.WITHER) + _size = 0; + + changeRandomName(_type.getMinName(), _type.getMaxName(), true); + + _location = location; + _target = target; + _spawned = false; + _lives = _type.getSize().getLives(); + if(spawn) + spawnMinion(); + } + + public void spawnMinion() + { + _entity = _location.getWorld().spawn(_location, Zombie.class); + Zombie zombie = (Zombie) _entity; + zombie.setRemoveWhenFarAway(false); + zombie.setMaxHealth(200); + zombie.setHealth(200); + zombie.getEquipment().setHelmet(new ItemStack(Material.LEATHER_HELMET)); + disguiseCreeper(); + path(); + _spawned = true; + } + + private Material[] _items = new Material[]{Material.DIAMOND_AXE, Material.IRON_SWORD, Material.CARROT, Material.STONE_SPADE, Material.GOLD_PICKAXE, Material.AIR}; + + private void disguiseCreeper() + { + if (_hologram != null) + { + _hologram.setText(_team.GetColor() + _name); + } + else + { + if(_manager.GetGame().GetState() == GameState.Live) + { + _hologram = new Hologram(_manager.getHologramManager(), _entity.getLocation().add(0, 2.3, 0), _team.GetColor() + _name); + } + else + { + _hologram = new Hologram(_manager.getHologramManager(), _entity.getLocation().add(0, 2.3, 0), ChatColor.WHITE + _name); + } + _hologram.setHologramTarget(Hologram.HologramTarget.WHITELIST); + //_hologram.setFollowEntity(_entity); + + for (Player player : _manager.GetGame().GetPlayers(false)) + { + if (_manager.GetGame().GetTeam(player) == _team && _manager.GetGame().GetState() != GameState.Prepare) + { + continue; + } + + _hologram.addPlayer(player); + } + + _hologram.start(); + } + + try + { + int i = 0; + for(Class clazz : _type.getDisguiseClasses()) + { + Object disguise = null; + Entity ent = null; + if(i == 0) + { + disguise = clazz.getConstructors()[0].newInstance(_entity); + } + else + { + ent = _location.getWorld().spawn(_location, Creeper.class); + disguise = clazz.getConstructors()[0].newInstance(ent); + } + try + { + clazz.getMethod("setHelmet", ItemStack.class).invoke(disguise, new ItemStack(Material.LEATHER_HELMET)); + clazz.getMethod("setHeldItem", ItemStack.class).invoke(disguise, new ItemStack(_items[UtilMath.r(_items.length)])); + } + catch (Exception e) {} + if(disguise instanceof DisguiseZombie && i > 0) + { + DisguiseZombie zombie = (DisguiseZombie) disguise; + zombie.SetBaby(true); + } + if(disguise instanceof DisguiseSlime) + { + DisguiseSlime slime = (DisguiseSlime) disguise; + slime.SetSize(_size); + } + if(disguise instanceof DisguiseWither) + { + DisguiseWither wither = (DisguiseWither) disguise; + wither.setInvulTime(_size); + } + _entity.setPassenger(ent); + _manager.GetDisguise().disguise((DisguiseBase)disguise); + _manager.GetDisguise().updateDisguise((DisguiseBase)disguise); + i++; + } + } + catch (Exception e) {} + _hologram.start(); + } + + private void path() + { + UtilEnt.Vegetate(_entity); + UtilEnt.silence(_entity, true); + UtilEnt.ghost(_entity, true, false); + } + + private MinionType randomType() + { + if(System.currentTimeMillis() - _manager.GetGame().GetStateTime() <= 30000) + { + return MinionSize.EASY.getRandomType(); + } + if(System.currentTimeMillis() - _manager.GetGame().GetStateTime() <= 60000) + { + int rdm = UtilMath.r(2); + if(rdm == 0) + return MinionSize.MEDIUM.getRandomType(); + else + return MinionSize.EASY.getRandomType(); + } + int rdm = UtilMath.r(MinionType.values().length); + int freak = UtilMath.r(1000); + if(freak <= 10) + { + ArrayList minions = new ArrayList<>(); + for(MinionType type : MinionType.values()) + { + if(type.getSize() == MinionSize.FREAK) + minions.add(type); + } + return minions.get(UtilMath.r(minions.size())); + } + for(MinionType type : MinionType.values()) + { + if(type.ordinal() == rdm) + { + if(type.getSize() != MinionSize.FREAK && type.getSize() != MinionSize.BOSS) + { + return type; + } + else + { + return randomType(); + } + } + } + return null; + } + + public boolean hasLives() + { + return _lives > 1; + } + + public void despawn(Player player, boolean killed, boolean clean) + { + _money = _money + 1; + if(_lives > 1) + { + _lives = _lives - 1; + changeRandomName(_name.length()+1, _name.length()+1, false); + if(_type == MinionType.WITHER) + { + _size = _size + 100; + _tagHight = _tagHight - 0.15; + } + else + { + _size = _size -1; + _tagHight = _tagHight - 0.1; + } + return; + } + _killed = killed; + _killer = player; + _die = true; + _hologram.stop(); + try + { + if(_entity.getPassenger() != null) + { + if(!clean) + ((Zombie) _entity.getPassenger()).damage(10000); + else + _entity.getPassenger().remove(); + } + if(!clean) + ((Zombie) _entity).damage(10000); + else + _entity.remove(); + + if(!_entity.isDead()) + _entity.remove(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void despawn(Player player, boolean killed) + { + despawn(player, killed, false); + } + + public void animation() + { + if(!_die) + return; + + if(_killed) + { + if(_frame <= 30) + { + if(_team.GetColor() == ChatColor.RED) + { + double radius = _frame / 20D; + int particleAmount = _frame / 2; + for (int e = 0; e < particleAmount; e++) + { + double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = _entity.getLocation().clone().add(0.5, 0, 0.5).add(xDiff, particleAmount/10, zDiff); + try + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.RED_DUST, location, 0, 0, 0, 0, 1, ViewDist.NORMAL, _player); + } + catch (Exception ex) + { + + } + + } + } + else + { + double radius = _frame / 20D; + int particleAmount = _frame / 2; + for (int e = 0; e < particleAmount; e++) + { + double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = _entity.getLocation().clone().add(0.5, 0, 0.5).add(xDiff, particleAmount/10, zDiff); + try + { + UtilParticle.PlayParticle(ParticleType.RED_DUST, location, -1, 1, 1, 1, 0,ViewDist.NORMAL, _player); + } + catch (Exception ex) + { + + } + + } + + } + } + } + else + { + if(_frame <= 1) + { + UtilFirework.playFirework(_entity.getLocation().add(0.5, 0.5, 0.5), Type.BALL_LARGE, Color.GREEN, true, true); + } + } + + if(_frame == 31) + { + _die = false; + } + + _frame++; + } + + public void changeName(String name) + { + _name = name; + Location loc = _entity.getLocation(); + _lastNameChanged = loc; + disguiseCreeper(); + } + + public void changeRandomName(int min, int max, boolean spawned) + { + ArrayList tempList = new ArrayList<>(); + for(String names : NAMES) + tempList.add(names); + + Collections.shuffle(tempList); + for(String str : tempList) + { + if(str.length() >= min && str.length() <= max) + { + if(!spawned) + changeName(str); + else + _name = str; + + return; + } + } + } + + public boolean isNameChangeable() + { + if(_lastNameChanged == null) + return true; + + if(_entity.getLocation().getBlockX() != _lastNameChanged.getBlockX()) + return true; + + if(_entity.getLocation().getBlockZ() != _lastNameChanged.getBlockZ()) + return true; + + return false; + } + + public void setWalkSpeed(float speed) + { + _walkSpeed = speed; + } + + public void increaseWalkSpeed(float speed) + { + float oldSpeed = _walkSpeed; + _walkSpeed = oldSpeed + speed; + if(_walkSpeed <= 0.5) + _walkSpeed = 0.6F; + } + + public Location getTarget() + { + return _target; + } + + public boolean isSpawned() + { + return _spawned; + } + + public Entity getEntity() + { + return _entity; + } + + public MinionType getType() + { + return _type; + } + + public int getMoney() + { + return _money; + } + + public Player getKiller() + { + return _player; + } + + public Player getPlayer() + { + return _player; + } + + public GameTeam getTeam() + { + return _team; + } + + public String getName() + { + return _name; + } + + public float getWalkSpeed() + { + return _walkSpeed; + } + + public Location getLastNameChanged() + { + return _lastNameChanged; + } + + public Hologram getHologram() + { + return _hologram; + } + + public int getSpawnID() + { + return _spawnID; + } + + public double getTagHight() + { + return _tagHight; + } + + public void setTarget(Location location) + { + _target = location; + } + + public void setMoving(boolean moving) + { + _moving = moving; + } + + public boolean isMoving() + { + return _moving; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionKillEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionKillEvent.java new file mode 100644 index 000000000..2198d4aca --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionKillEvent.java @@ -0,0 +1,66 @@ +package nautilus.game.arcade.game.games.typewars; + +import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; + +import org.bukkit.entity.Player; +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class MinionKillEvent extends Event implements Cancellable +{ + + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private Minion _minion; + private KillType _type; + + private boolean _canceled; + + public MinionKillEvent(Player player, Minion minion, KillType type) + { + _player = player; + _minion = minion; + _type = type; + _canceled = false; + } + + public Player getPlayer() + { + return _player; + } + + public Minion getMinion() + { + return _minion; + } + + public KillType getType() + { + return _type; + } + + @Override + public void setCancelled(boolean cancel) + { + _canceled = cancel; + } + + public boolean isCancelled() + { + return _canceled; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionSize.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionSize.java new file mode 100644 index 000000000..af5f91434 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionSize.java @@ -0,0 +1,73 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.itemstack.ItemStackFactory; + +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; + +public enum MinionSize +{ + EASY("Easy", 2, ItemStackFactory.Instance.CreateStack(Material.MONSTER_EGG, (byte) 0, 1, (short) 55, "", new String[]{}), 1, 1), + MEDIUM("Medium", 4, ItemStackFactory.Instance.CreateStack(Material.MONSTER_EGG, (byte) 0, 1, (short) 61, "", new String[]{}), 1, 2), + HARD("Hard", 6, ItemStackFactory.Instance.CreateStack(Material.MONSTER_EGG, (byte) 0, 1, (short) 52, "", new String[]{}), 1, 4), + FREAK("Freak", 10000, new ItemStack(Material.MONSTER_EGG), 1, 999999), + BOSS("Boss", 10000, new ItemStack(Material.MONSTER_EGG), 7, 999999999); + + private int _cost; + private ItemStack _displayItem; + private int _lives; + private int _gemReward; + + private String _displayName; + + private MinionSize(String name, int cost, ItemStack displayItem, int lives, int gemReward) + { + _displayName = name; + _cost = cost; + _displayItem = displayItem; + _lives = lives; + _gemReward = gemReward; + } + + public int getCost() + { + return _cost; + } + + public ItemStack getDisplayItem() + { + return _displayItem; + } + + public String getDisplayName() + { + return _displayName; + } + + public int getGemReward() + { + return _gemReward; + } + + public MinionType getRandomType() + { + ArrayList minionList = new ArrayList<>(); + for(MinionType type : MinionType.values()) + { + if(type.getSize() == this) + { + minionList.add(type); + } + } + return minionList.get(UtilMath.r(minionList.size())); + } + + public int getLives() + { + return _lives; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionType.java new file mode 100644 index 000000000..a80d1fc5f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/MinionType.java @@ -0,0 +1,123 @@ +package nautilus.game.arcade.game.games.typewars; + +import mineplex.core.disguise.disguises.DisguiseBase; +import mineplex.core.disguise.disguises.DisguiseChicken; +import mineplex.core.disguise.disguises.DisguiseCow; +import mineplex.core.disguise.disguises.DisguiseCreeper; +import mineplex.core.disguise.disguises.DisguiseEnderman; +import mineplex.core.disguise.disguises.DisguiseHorse; +import mineplex.core.disguise.disguises.DisguiseIronGolem; +import mineplex.core.disguise.disguises.DisguiseMagmaCube; +import mineplex.core.disguise.disguises.DisguisePig; +import mineplex.core.disguise.disguises.DisguiseSkeleton; +import mineplex.core.disguise.disguises.DisguiseSlime; +import mineplex.core.disguise.disguises.DisguiseSpider; +import mineplex.core.disguise.disguises.DisguiseWither; +import mineplex.core.disguise.disguises.DisguiseWolf; +import mineplex.core.disguise.disguises.DisguiseZombie; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; + +@SuppressWarnings("unchecked") +public enum MinionType +{ + + CHICKEN(10, MinionSize.EASY, EntityType.CHICKEN, 3, 3, (float) (0.7 + (0.1*7)), 1, -0.5D, Material.EGG, DisguiseChicken.class), + PIG(10, MinionSize.EASY, EntityType.PIG, 3, 6, (float) (0.7 + (0.1*7)), 1, -0.5D, Material.PORK, DisguisePig.class), + COW(10, MinionSize.EASY, EntityType.COW, 6, 9, (float) (0.7 + (0.1*7)), 1, -0.5D, Material.COOKED_BEEF, DisguiseCow.class), + + ZOMBIE(10, MinionSize.MEDIUM, EntityType.ZOMBIE, 9, 12, (float) (0.7 + (0.1*2)), 2, 0D, Material.ROTTEN_FLESH, DisguiseZombie.class), + SPIDER(10, MinionSize.MEDIUM, EntityType.SPIDER, 6, 9, (float) (0.7 + (0.1*5)), 2, 0D, Material.SPIDER_EYE, DisguiseSpider.class), + WOLF(10, MinionSize.MEDIUM, EntityType.WOLF, 3, 6, (float) (0.7 + (0.1*8)), 2, -1D, Material.COOKED_BEEF, DisguiseWolf.class), + + IRON_GOLEM(10, MinionSize.HARD, EntityType.IRON_GOLEM, 10, 13,(float) (0.7 + (0.1*3)), 3, 0.5D, Material.IRON_INGOT, DisguiseIronGolem.class), + HORSE(10, MinionSize.HARD, EntityType.HORSE, 6, 9, (float) (0.7 + (0.1*10)), 3, 0D, Material.APPLE, DisguiseHorse.class), + ENDERMAN(10, MinionSize.HARD, EntityType.ENDERMAN, 9, 12, (float) (0.7 + (0.1*4)), 3, 1D, Material.ENDER_STONE, DisguiseEnderman.class), + + WITHER(1, MinionSize.BOSS, EntityType.WITHER, 5, 5, (float) (0.7 + (0.1*2)), 1, 2D, Material.NETHER_STAR, DisguiseWither.class), + SLIME(1, MinionSize.BOSS, EntityType.SLIME, 5, 5, (float) (0.7 + (0.1*2)), 1, 3D, Material.SLIME_BALL, DisguiseSlime.class), + + SPIDER_JOKEY(1, MinionSize.FREAK, EntityType.SPIDER, 10, 13, (float) (0.7 + (0.1*7)), 10, 1D, Material.APPLE, DisguiseSpider.class, DisguiseSkeleton.class), + CHICKEN_JOKEY(1, MinionSize.FREAK, EntityType.CHICKEN, 10, 13, (float) (0.7 + (0.1*7)), 10, 1D, Material.APPLE, DisguiseChicken.class, DisguiseZombie.class); + + private Class[] _disguiseClasses; + + private EntityType _type; + private int _minName; + private int _maxName; + private float _walkSpeed; + private int _money; + + private MinionSize _size; + + private double _tagHight; + private Material _displayItem; + + private int _chance; + + private MinionType(int chance, MinionSize size, EntityType type, int minName, int maxName, float walkSpeed, int money, double tagHight, Material displayItem,Class... disguiseClasses) + { + _disguiseClasses = disguiseClasses; + _type = type; + _minName = minName; + _maxName = maxName; + _walkSpeed = walkSpeed; + _money = money; + _displayItem = displayItem; + _tagHight = tagHight; + _chance = chance; + _size = size; + } + + public EntityType getType() + { + return _type; + } + + public int getMinName() + { + return _minName; + } + + public int getMaxName() + { + return _maxName; + } + + public float getWalkSpeed() + { + return _walkSpeed; + } + + public int getMoney() + { + return _money; + } + + public Material getDisplayItem() + { + return _displayItem; + } + + public Class[] getDisguiseClasses() + { + return _disguiseClasses; + } + + public double getTagHight() + { + return _tagHight; + } + + public int getChance() + { + return _chance; + } + + public MinionSize getSize() + { + return _size; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Spell.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Spell.java new file mode 100644 index 000000000..532de8dd0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/Spell.java @@ -0,0 +1,212 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; +import java.util.HashMap; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.recharge.Recharge; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +public abstract class Spell +{ + + private ArrayList _playerUses; + + private ArcadeManager _manager; + private TypeWars _typeWars; + private String _name; + private int _cost; + private Material _material; + private Long _recharge; + private boolean _singleUse; + private long _updateDelay; + + private HashMap _lastUsed; + private long _useDelay; + + public Spell(ArcadeManager manager, String name, int cost, Material material, Long recharge, int updateDelay, long useDelay, boolean singleUse) + { + _manager = manager; + _name = name; + _cost = cost; + _material = material; + _recharge = recharge; + _singleUse = singleUse; + _updateDelay = updateDelay; + _playerUses = new ArrayList<>(); + _lastUsed = new HashMap<>(); + _updateDelay = useDelay; + } + + public void prepareExecution(final Player player) + { + if(isSingleUse()) + { + if(_playerUses.contains(player)) + { + UtilTextMiddle.display("", ChatColor.GRAY + "You can't use this spell anymore.", player); + return; + } + } + GameTeam team = getManager().GetGame().GetTeam(player); + if(_lastUsed.containsKey(team)) + { + if(!UtilTime.elapsed(_lastUsed.get(team), _useDelay)) + { + UtilTextMiddle.display("", ChatColor.GRAY + "This Spell cant be used at the moment.", player); + return; + } + } + _lastUsed.put(team, System.currentTimeMillis()); + + _typeWars = (TypeWars) _manager.GetGame(); + if(_typeWars.getMoneyMap().get(player) < getCost()) + { + UtilTextMiddle.display("", ChatColor.GRAY + "You dont have enough Money to use that spell.", player); + return; + } + if(!Recharge.Instance.usable(player, getName(), true)) + return; + + UtilTextMiddle.display(ChatColor.GREEN + "-$" + getCost(), ChatColor.GRAY + "You used " + F.game(getName()), player); + final Spell spell = this; + + new Thread(new Runnable() + { + + @Override + public void run() + { + Location loc = player.getLastTwoTargetBlocks(UtilBlock.blockAirFoliageSet, 80).get(0).getLocation().add(0.5, 0.5, 0.5); + if(trail() != null) + { + int i = 0; + for (Location location : UtilShapes.getLinesDistancedPoints(player.getEyeLocation().subtract(0, 0.1, 0), loc, 0.6)) + { + if(getManager().GetGame().GetTeam(player).GetColor() == ChatColor.RED) + { + UtilParticle.PlayParticle(trail(), location, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + } + else + { + UtilParticle.PlayParticle(trail(), location, -1, 1, 1, 1, 0, ViewDist.NORMAL, UtilServer.getPlayers()); + } + trailAnimation(location, i); + location.getWorld().playSound(location, sound(), 1, 1); + i++; + if(i > 30) + i = 0; + try + { + Thread.sleep(_updateDelay); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + } + } + if(hit() != null) + UtilParticle.PlayParticle(hit(), loc, 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + + if(execute(player, loc)) + { + Recharge.Instance.use(player, getName(), getRecharge(), false, true); + int money = ((TypeWars) _manager.GetGame()).getMoneyMap().get(player); + ((TypeWars) _manager.GetGame()).getMoneyMap().put(player, money - getCost()); + if(!_playerUses.contains(player)) + _playerUses.add(player); + + Bukkit.getPluginManager().callEvent(new ActivateSpellEvent(player, spell)); + return; + } + else + { + UtilPlayer.message(player, F.main("Game", "Error while using spell.")); + return; + } + } + + }).start(); + + } + + public ParticleType trail() + { + return ParticleType.RED_DUST; + } + + public ParticleType hit() + { + return ParticleType.EXPLODE; + } + + public Sound sound() + { + return Sound.CLICK; + } + + public boolean hasUsed(Player player) + { + return _playerUses.contains(player); + } + + public void trailAnimation(Location location, int frame) {} + + public abstract boolean execute(Player player, Location location); + + public ArcadeManager getManager() + { + return _manager; + } + + public TypeWars getTypeWars() + { + return _typeWars; + } + + public String getName() + { + return _name; + } + + public int getCost() + { + return _cost; + } + + public Material getMaterial() + { + return _material; + } + + public Long getRecharge() + { + return _recharge; + } + + public boolean isSingleUse() + { + return _singleUse; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/SummonMinionEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/SummonMinionEvent.java new file mode 100644 index 000000000..49ed46c56 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/SummonMinionEvent.java @@ -0,0 +1,40 @@ +package nautilus.game.arcade.game.games.typewars; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class SummonMinionEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private Minion _minion; + + public SummonMinionEvent(Player player, Minion minion) + { + _player = player; + _minion = minion; + } + + public Player getPlayer() + { + return _player; + } + + public Minion getMinion() + { + return _minion; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeAttemptEvent.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeAttemptEvent.java new file mode 100644 index 000000000..c03828fdf --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeAttemptEvent.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; + +import org.bukkit.entity.Player; +import org.bukkit.event.Event; +import org.bukkit.event.HandlerList; + +public class TypeAttemptEvent extends Event +{ + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private Player _player; + private String _attempt; + private boolean _success; + + public TypeAttemptEvent(Player player, String attempt, boolean sucess) + { + _player = player; + _attempt = attempt; + _success = sucess; + } + + public Player getPlayer() + { + return _player; + } + + public String getAttempt() + { + return _attempt; + } + + public boolean isSuccessful() + { + return _success; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java new file mode 100644 index 000000000..d1379f1b5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/TypeWars.java @@ -0,0 +1,1365 @@ +package nautilus.game.arcade.game.games.typewars; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTextMiddle; +import mineplex.core.common.util.UtilTime; +import mineplex.core.hologram.Hologram; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.typewars.kits.KitTypeWarsBase; +import nautilus.game.arcade.game.games.typewars.kits.KitTyper; +import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything; +import nautilus.game.arcade.game.games.typewars.stats.DemonStatsTracker; +import nautilus.game.arcade.game.games.typewars.stats.DumbledontStatTracker; +import nautilus.game.arcade.game.games.typewars.stats.HoarderStatTracker; +import nautilus.game.arcade.game.games.typewars.stats.KillsStatTracker; +import nautilus.game.arcade.game.games.typewars.stats.PerfectionistStatTracker; +import nautilus.game.arcade.game.games.typewars.stats.TimeInGameTracker; +import nautilus.game.arcade.game.games.typewars.stats.WaitForItStatTracker; +import nautilus.game.arcade.game.games.typewars.tutorial.TutorialTypeWars; +import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; +import nautilus.game.arcade.gametutorial.events.GameTutorialStartEvent; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.stats.TimeInGameStatTracker; +import nautilus.game.arcade.world.WorldData; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Giant; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDeathEvent; +import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.AsyncPlayerChatEvent; +import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.util.Vector; + +public class TypeWars extends TeamGame +{ + + private ArrayList _activeMinions; + private ArrayList _deadMinions; + private ArrayList _finishedMinions; + + private HashMap _moneyMap; + + private long _lastSpawnedRed; + private long _timeToSpawnRed; + + private long _lastSpawnedBlue; + private long _timeToSpawnBlue; + + private ArrayList _pendingNukes; + + private HashMap> _lineGrowth; + private HashMap> _lineShorten; + private HashMap> _minionSpawns; + + private HashMap> _giantAttackZones; + private HashMap _giants; + private HashMap _giantLocs; + private HashMap _minionsSpawned; + private HashMap _giantsAttacked; + + private HashSet _playerTitles; + + public TypeWars(ArcadeManager manager) + { + super(manager, GameType.TypeWars, + new Kit[] + { + new KitTyper(manager), + }, + new String[] + { + "Protect your Giant from enemy minions.", + "Type minions names to kill them and get money.", + "Spend money on Spells and Minion Spawns.", + "You get ONE free Giant Smash per game.", + "Kill your enemies Giant before they kill yours!" + }); + + this.DeathOut = false; + this.DamageTeamSelf = false; + this.DamageSelf = false; + this.DamageTeamOther = false; + this.DeathSpectateSecs = 0; + this.HungerSet = 20; + this.WorldBoundaryKill = true; + this.CompassEnabled = false; + this.TeamArmor = true; + this.TeamArmorHotbar = false; + this.WorldTimeSet = 6000; + this.DamageEvP = false; + this.DamagePvE = false; + this.DamagePvP = false; + this.TeamArmorHotbar = true; + this.Damage = false; + this.CreatureAllow = false; + this.PrepareTime = 50000; + this.PrepareFreeze = false; + this.PlaySoundGameStart = false; + this.EnableTutorials = true; + this.PrepareFreeze = true; + this.AllowParticles = false; + + _activeMinions = new ArrayList<>(); + _deadMinions = new ArrayList<>(); + _finishedMinions = new ArrayList<>(); + _minionSpawns = new HashMap<>(); + _moneyMap = new HashMap<>(); + _timeToSpawnRed = 30000; + _timeToSpawnBlue = 30000; + _lineGrowth = new HashMap<>(); + _lineShorten = new HashMap<>(); + _pendingNukes = new ArrayList<>(); + _giantAttackZones = new HashMap<>(); + _giants = new HashMap<>(); + _minionsSpawned = new HashMap<>(); + _giantsAttacked = new HashMap<>(); + _playerTitles = new HashSet<>(); + _giantLocs = new HashMap<>(); + + _animationTicks = 0; + _nukeFrame = 0; + + registerStatTrackers( + new DemonStatsTracker(this), + new DumbledontStatTracker(this), + new HoarderStatTracker(this), + new PerfectionistStatTracker(this), + new WaitForItStatTracker(this), + new KillsStatTracker(this), + new TimeInGameTracker(this) + ); + + manager.GetCreature().SetDisableCustomDrops(true); + manager.GetChat().setThreeSecondDelay(false); + } + + @EventHandler + public void stateChange(GameStateChangeEvent event) + { + for (Player player : GetPlayers(true)) + { + UtilAction.velocity(player, 0.1, 0.1, 0.1, false); + _moneyMap.put(player, 0); + _playerTitles.add(player); + } + + if(event.GetState() == GameState.Prepare) + { + initSpawns(); + prepareGiants(); + } + if(event.GetState() != GameState.Live) + return; + + for(GameTeam team : GetTeamList()) + { + _lineGrowth.put(team, new ArrayList()); + _lineShorten.put(team, new ArrayList()); + _minionsSpawned.put(team, 0); + } + + _timeToSpawnRed = 6000 / GetTeamList().get(0).GetPlayers(true).size(); + _timeToSpawnBlue = 6000 / GetTeamList().get(1).GetPlayers(true).size(); + + _lastSpawnedRed = System.currentTimeMillis(); + _lastSpawnedBlue = System.currentTimeMillis(); + } + + public void prepareGiants() + { + Location blue = WorldData.GetDataLocs("PURPLE").get(0).clone(); + Location red = WorldData.GetDataLocs("LIME").get(0).clone(); + + red.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(red, blue))); + blue.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(blue, red))); + + red.getBlock().setType(Material.STONE); + blue.getBlock().setType(Material.STONE); + + red.add(0, 2, 0); + blue.add(0, 2, 0); + + int i = 0; + for(GameTeam team : GetTeamList()) + { + Location loc = red; + if(i == 1) + loc = blue; + + this.CreatureAllowOverride = true; + Giant giant = loc.getWorld().spawn(loc, Giant.class); + _giantLocs.put(giant, loc.clone()); + this.CreatureAllowOverride = false; + giant.setRemoveWhenFarAway(false); + UtilEnt.Vegetate(giant, true); + UtilEnt.ghost(giant, true, false); + + ItemStack helmet = new ItemStack(Material.LEATHER_HELMET); + LeatherArmorMeta helmetmeta = (LeatherArmorMeta) helmet.getItemMeta(); + helmetmeta.setColor(team.GetColorBase()); + helmet.setItemMeta(helmetmeta); + + ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE); + LeatherArmorMeta chestmeta = (LeatherArmorMeta) chest.getItemMeta(); + chestmeta.setColor(team.GetColorBase()); + chest.setItemMeta(chestmeta); + + ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS); + LeatherArmorMeta leggingsmeta = (LeatherArmorMeta) leggings.getItemMeta(); + leggingsmeta.setColor(team.GetColorBase()); + leggings.setItemMeta(leggingsmeta); + + ItemStack stack = new ItemStack(Material.LEATHER_BOOTS); + LeatherArmorMeta meta = (LeatherArmorMeta) stack.getItemMeta(); + meta.setColor(team.GetColorBase()); + stack.setItemMeta(meta); + + giant.getEquipment().setHelmet(helmet); + giant.getEquipment().setChestplate(chest); + giant.getEquipment().setLeggings(leggings); + giant.getEquipment().setBoots(stack); + + giant.setMaxHealth(100); + giant.setHealth(100); + _giants.put(team, giant); + i++; + } + for(GameTeam team : GetTeamList()) + { + for(GameTeam otherTeam : GetTeamList()) + { + if(team != otherTeam) + { + for(Location location : _giantAttackZones.get(team)) + { + Location giantLoc = _giants.get(otherTeam).getLocation(); + location.setYaw(UtilAlg.GetYaw(new Vector(giantLoc.getBlockX() - location.getBlockX(), giantLoc.getBlockY() - location.getBlockY(), giantLoc.getBlockZ() - location.getBlockZ()))); + } + } + } + } + } + + @EventHandler + public void fixGiants(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if(GetState() != GameState.Prepare) + return; + + for(Giant giant : _giantLocs.keySet()) + { + giant.teleport(_giantLocs.get(giant)); + } + } + + @EventHandler + public void Players(UpdateEvent event) + { + if(GetState() != GameState.Live && GetState() != GameState.End) + return; + + if(event.getType() != UpdateType.TICK) + return; + + for(Player player : GetPlayers(true)) + { + Recharge.Instance.Reset(player, "Chat Message"); + + player.setAllowFlight(true); + player.setFlying(true); + UtilTextBottom.display(C.cGreen + "You have $" + _moneyMap.get(player), player); + + for(Minion minion : _activeMinions) + { + if(UtilMath.offset(minion.getEntity().getLocation(), player.getLocation()) < 1) + { + UtilAction.velocity(player, UtilAlg.getTrajectory(minion.getEntity().getLocation(), player.getLocation()), 1, true, 1, 1, 1, true); + } + } + } + } + + @EventHandler + public void ForcefieldUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + for (Minion minion : _activeMinions) + { + for (Player other : UtilServer.getPlayers()) + { + if (UtilMath.offset(other, minion.getEntity()) > 3) + continue; + + if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) + { + UtilAction.velocity(other, UtilAlg.getTrajectory2d(minion.getEntity(), other), 1.6, true, 0.8, 0, 10, true); + other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + } + } + } + for (Giant giant : _giants.values()) + { + for (Player other : UtilServer.getPlayers()) + { + if (UtilMath.offset(other, giant) > 10) + continue; + + if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) + { + UtilAction.velocity(other, UtilAlg.getTrajectory2d(giant, other), 1.6, true, 0.8, 0, 10, true); + other.getWorld().playSound(other.getLocation(), Sound.CHICKEN_EGG_POP, 2f, 0.5f); + } + } + } + } + + private Location _tutorialLocationRed, _tutorialLocationBlue; + + private void initSpawns() + { + WorldData data = WorldData; + + ((CraftWorld) data.World).getHandle().spigotConfig.animalActivationRange = 200; + ((CraftWorld) data.World).getHandle().spigotConfig.monsterActivationRange = 200; + + ((CraftWorld) data.World).getHandle().spigotConfig.animalTrackingRange = 200; + ((CraftWorld) data.World).getHandle().spigotConfig.monsterTrackingRange = 200; + + _minionSpawns.put(GetTeamList().get(0), (ArrayList)data.GetDataLocs("RED").clone()); + _minionSpawns.put(GetTeamList().get(1), (ArrayList)data.GetDataLocs("LIGHT_BLUE").clone()); + + _giantAttackZones.put(GetTeamList().get(0), (ArrayList) data.GetDataLocs("MAGENTA").clone()); + _giantAttackZones.put(GetTeamList().get(1), (ArrayList) data.GetDataLocs("ORANGE").clone()); + + Location blue = WorldData.GetDataLocs("LIME").get(0); + Location red = WorldData.GetDataLocs("PURPLE").get(0); + + ArrayList tutorialLocations = UtilShapes.getLinesDistancedPoints(red, blue, 1); + _tutorialLocationRed = tutorialLocations.get(20).clone().add(0, 15, 0); + _tutorialLocationBlue = tutorialLocations.get(tutorialLocations.size() - 20).clone().add(0, 15, 0); + } + + @EventHandler + public void tutorialStart(GameTutorialStartEvent event) + { + Location targetRed, targetBlue; + ArrayList locations = UtilShapes.getLinesDistancedPoints(_minionSpawns.get(GetTeamList().get(0)).get(4), _minionSpawns.get(GetTeamList().get(1)).get(4), 1); + + targetRed = locations.get(locations.size() - 3); + targetBlue = locations.get(3); + if(event.getTutorial().getTeam() == GetTeamList().get(1)) + { + event.getTutorial().getPhase(1).setLocation(_tutorialLocationRed); + event.getTutorial().getPhase(1).setTarget(targetRed); + } + else + { + event.getTutorial().getPhase(1).setLocation(_tutorialLocationBlue); + event.getTutorial().getPhase(1).setTarget(targetBlue); + } + } + + @EventHandler + public void tutorialEnd(final GameTutorialEndEvent event) + { + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + for(Player player : event.getTutorial().getPlayers().keySet()) + { + Location location = player.getLocation().clone(); + for(GameTeam team : GetTeamList()) + { + if(team != event.getTutorial().getTeam()) + { + location.setPitch(UtilAlg.GetPitch(UtilAlg.getTrajectory(location, _giants.get(team).getLocation()))); + location.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory(location, _giants.get(team).getLocation()))); + } + } + player.teleport(location); + } + } + }, 7); + } + + @Override + public void addTutorials() + { + GetTeamList().get(0).setTutorial(new TutorialTypeWars(Manager)); + GetTeamList().get(1).setTutorial(new TutorialTypeWars(Manager)); + } + + @EventHandler + public void tutorialFrames(GameStateChangeEvent event) + { + if(event.GetState() != GameState.Live) + return; + + for(Giant giant : _giants.values()) + { + giant.setHealth(100); + } + + _activeMinions.clear(); + _deadMinions.clear(); + _finishedMinions.clear(); + } + + @EventHandler + public void testCommands(PlayerCommandPreprocessEvent event) + { + if(GetState() != GameState.Live) + return; + + if(event.getMessage().contains("/Money")) + { + + if(!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.DEVELOPER, true)) + return; + + _moneyMap.put(event.getPlayer(), 1000); + UtilPlayer.message(event.getPlayer(), F.main("Money", "You got some Money")); + event.setCancelled(true); + return; + } + + if(event.getMessage().contains("/Boss")) + { + if(!Manager.GetClients().Get(event.getPlayer()).GetRank().has(event.getPlayer(), Rank.DEVELOPER, true)) + return; + + if(!IsPlaying(event.getPlayer())) + return; + + + event.setCancelled(true); + GameTeam teams = GetTeam(event.getPlayer()); + for(GameTeam team : GetTeamList()) + { + if(team == teams) + continue; + + int rdm = UtilMath.r(_minionSpawns.get(teams).size()); + this.CreatureAllowOverride = true; + Minion minion = new Minion(Manager, _minionSpawns.get(teams).get(rdm), _minionSpawns.get(team).get(rdm), teams, event.getPlayer(), true, MinionSize.BOSS.getRandomType(), rdm); + _activeMinions.add(minion); + this.CreatureAllowOverride = false; + UtilPlayer.message(event.getPlayer(), F.main("Boss", "You have spawned a Boss")); + } + } + + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if(event.getItem() == null) + return; + + if(GetState() != GameState.Live) + return; + + for(MinionSize type : MinionSize.values()) + { + if(type.getDisplayItem().getType() == event.getItem().getType() && type.getDisplayItem().getDurability() == event.getItem().getDurability()) + { + if(type.getCost() > _moneyMap.get(event.getPlayer())) + { + UtilTextMiddle.display("", ChatColor.GRAY + "You dont have enough money to spawn this Minion.", event.getPlayer()); + return; + } + GameTeam teams = GetTeam(event.getPlayer()); + for(GameTeam team : GetTeamList()) + { + if(teams != team) + { + if(getMinions(teams).size() >= 60) + { + UtilTextMiddle.display("", ChatColor.GRAY + "Your Team can't have more than 60 Minions", 5, 30, 5, event.getPlayer()); + return; + } + + this.CreatureAllowOverride = true; + _moneyMap.put(event.getPlayer(), _moneyMap.get(event.getPlayer()) - type.getCost()); + UtilTextMiddle.display("", ChatColor.GRAY + "You bought a Minion.", event.getPlayer()); + int rdm = UtilMath.r(_minionSpawns.get(teams).size()); + Minion minion = new Minion(Manager, _minionSpawns.get(teams).get(rdm), _minionSpawns.get(team).get(rdm), teams, event.getPlayer(), true, type.getRandomType(), rdm); + Bukkit.getPluginManager().callEvent(new SummonMinionEvent(event.getPlayer(), minion)); + _activeMinions.add(minion); + this.CreatureAllowOverride = false; + } + } + return; + } + } + } + + @EventHandler + public void mobSpawn(EntitySpawnEvent event) + { + if(event.getEntityType() == EntityType.CREEPER) + { + event.setCancelled(true); + } + } + + @EventHandler(priority=EventPriority.LOWEST) + public void noItems(EntityDeathEvent event) + { + event.getDrops().clear(); + } + + @EventHandler + public void spawnMinions(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if(!IsLive()) + return; + + if(UtilTime.elapsed(_lastSpawnedRed, _timeToSpawnRed)) + { + if(getMinions(GetTeamList().get(0)).size() < 60) + { + _lastSpawnedRed = System.currentTimeMillis(); + + this.CreatureAllowOverride = true; + int rdm = UtilMath.r(_minionSpawns.get(GetTeamList().get(0)).size()); + Minion minion = null; + + if(_minionsSpawned.get(GetTeamList().get(0)) >= 100) + { + _minionsSpawned.put(GetTeamList().get(0), 0); + minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(0)).get(rdm), _minionSpawns.get(GetTeamList().get(1)).get(rdm), GetTeamList().get(0), null, true, MinionSize.BOSS.getRandomType(), rdm); + UtilTextMiddle.display("", minion.getTeam().GetColor() + "A Boss monster has spawned!"); + } + else + { + minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(0)).get(rdm), _minionSpawns.get(GetTeamList().get(1)).get(rdm), GetTeamList().get(0), rdm); + } + _activeMinions.add(minion); + + this.CreatureAllowOverride = false; + + if(_timeToSpawnRed > 5000 / (GetTeamList().get(1).GetPlayers(true).size() > 0 ? GetTeamList().get(1).GetPlayers(true).size() : 1)) + _timeToSpawnRed = _timeToSpawnRed - 75; + + } + } + if(UtilTime.elapsed(_lastSpawnedBlue, _timeToSpawnBlue)) + { + if(getMinions(GetTeamList().get(1)).size() < 60) + { + _lastSpawnedBlue = System.currentTimeMillis(); + + this.CreatureAllowOverride = true; + int rdm = UtilMath.r(_minionSpawns.get(GetTeamList().get(1)).size()); + Minion minion = null; + if(_minionsSpawned.get(GetTeamList().get(1)) >= 100) + { + _minionsSpawned.put(GetTeamList().get(1), 0); + minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(1)).get(rdm), _minionSpawns.get(GetTeamList().get(0)).get(rdm), GetTeamList().get(1), null, true, MinionSize.BOSS.getRandomType(), rdm); + UtilTextMiddle.display("", minion.getTeam().GetColor() + "A Boss monster has spawned!"); + } + else + { + minion = new Minion(Manager, _minionSpawns.get(GetTeamList().get(1)).get(rdm), _minionSpawns.get(GetTeamList().get(0)).get(rdm), GetTeamList().get(1), rdm); + } + _activeMinions.add(minion); + this.CreatureAllowOverride = false; + + if(_timeToSpawnBlue > 5000 / (GetTeamList().get(0).GetPlayers(true).size() > 0 ? GetTeamList().get(0).GetPlayers(true).size() : 1)) + _timeToSpawnBlue = _timeToSpawnRed - 75; + + } + } + } + + @EventHandler + public void updateMinions(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if(GetState() != GameState.Live && GetState() != GameState.Prepare) + return; + + Iterator minionIterator = _activeMinions.iterator(); + + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + + if(minion.isSpawned()) + { + if(minion.isMoving()) + { + if(!UtilEnt.CreatureMoveFast(minion.getEntity(), minion.getTarget(), minion.getWalkSpeed())) + { + GameTeam enemy = null; + for(GameTeam teams : GetTeamList()) + { + if(teams != minion.getTeam()) + enemy = teams; + } + Location nextTarget = _giantAttackZones.get(enemy).get(minion.getSpawnID()); + if(!nextTarget.equals(minion.getTarget())) + { + minion.setTarget(nextTarget); + } + else + { + if(!_finishedMinions.contains(minion)) + _finishedMinions.add(minion); + } + } + } + } + Hologram hologram = minion.getHologram(); + hologram.setLocation(minion.getEntity().getLocation().add(0, minion.getTagHight() + 2.3, 0)); + } + } + + @EventHandler + public void checkDeadMinions(UpdateEvent event) + { + if(GetState() != GameState.Live && GetState() != GameState.End) + return; + + if(event.getType() != UpdateType.FASTER) + return; + + for(Minion minion : _deadMinions) + { + if(!minion.getEntity().isDead()) + minion.despawn(null, false); + } + } + + @EventHandler + public void giants(UpdateEvent event) + { + if(GetState() != GameState.Live) + return; + + if(event.getType() != UpdateType.SLOW) + return; + + for(GameTeam team : _giants.keySet()) + { + ArrayList minions = new ArrayList<>(); + for(Minion minion : _finishedMinions) + { + if(!minion.getEntity().isDead()) + { + if(minion.getTeam() != team) + minions.add(minion); + } + } + if(minions.isEmpty()) + continue; + + Giant giant = _giants.get(team); + Minion minion = minions.get(UtilMath.r(minions.size())); + Location loc = giant.getLocation().clone(); + loc.setYaw(UtilAlg.GetYaw(new Vector(minion.getEntity().getLocation().getBlockX() - loc.getBlockX(), minion.getEntity().getLocation().getBlockY() - loc.getBlockY(), minion.getEntity().getLocation().getBlockZ() - loc.getBlockZ()))); + giant.teleport(loc); + for(Player player : team.GetPlayers(false)) + { + player.playSound(giant.getLocation(), Sound.ZOMBIE_WOODBREAK, 100, 1); + player.playSound(giant.getLocation(), Sound.ZOMBIE_IDLE, 1, 1); + } + + UtilParticle.PlayParticle(ParticleType.LARGE_EXPLODE, minion.getEntity().getLocation(), 0, 0, 0, 1, 1, ViewDist.LONG, UtilServer.getPlayers()); + + minion.despawn(null, true); + if(!minion.hasLives()) + _deadMinions.add(minion); + } + } + + @EventHandler + public void minionAttack(UpdateEvent event) + { + if(GetState() != GameState.Live && GetState() != GameState.Prepare) + return; + + if(event.getType() != UpdateType.SEC) + return; + + for(GameTeam team : _giants.keySet()) + { + int damage = 0; + for(Minion minion : _finishedMinions) + { + if(minion.getTeam() == team) + continue; + + if(minion.getEntity().isDead()) + continue; + + damage++; + } + if(damage == 0) + continue; + + for(GameTeam otherTeam : GetTeamList()) + { + if(team != otherTeam) + { + _giants.get(team).getWorld().playSound(_giants.get(team).getEyeLocation(), Sound.ZOMBIE_HURT, 100, 1); + _giants.get(team).damage(damage); + } + } + if(!_giantsAttacked.containsKey(team) || UtilTime.elapsed(_giantsAttacked.get(team), 10000)) + { + _giantsAttacked.put(team, System.currentTimeMillis()); + for(Player player : GetPlayers(true)) + { + if(GetTeam(player) == team) + { + if(IsLive()) + { + UtilTextMiddle.display("", "Your giant is under Attack!", 0, 30, 9, player); + } + } + } + } + } + } + + @EventHandler + public void minionAnimation(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + Iterator minionIterator = _activeMinions.iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + minion.animation(); + } + } + + public double getScore(GameTeam team) + { + if(_giants.get(team).isDead()) + { + return 0; + } + return _giants.get(team).getHealth(); + } + + @EventHandler + public void chatCheck(AsyncPlayerChatEvent event) + { + if(!IsLive()) + return; + + if(!GetPlayers(true).contains(event.getPlayer())) + return; + + if(event.getMessage().split(" ").length == 1) + event.setCancelled(true); + } + + @EventHandler + public void chatCheck(PlayerChatEvent event) + { + if(!IsLive()) + return; + + if(!GetPlayers(true).contains(event.getPlayer())) + return; + + try + { + Minion minion = getFarestMininion(event.getPlayer(), event.getMessage()); + + Bukkit.getPluginManager().callEvent(new TypeAttemptEvent(event.getPlayer(), event.getMessage(), minion != null)); + + if(minion == null) + return; + + MinionKillEvent minionEvent = new MinionKillEvent(event.getPlayer(), minion, KillType.TYPED); + Bukkit.getPluginManager().callEvent(minionEvent); + + if(minionEvent.isCancelled()) + return; + + killMinion(minion, event.getPlayer()); + + int spawned = _minionsSpawned.get(GetTeam(event.getPlayer())); + _minionsSpawned.put(GetTeam(event.getPlayer()), spawned + 1); + + if(_playerTitles.contains(event.getPlayer())) + { + _playerTitles.remove(event.getPlayer()); + UtilTextMiddle.clear(event.getPlayer()); + } + UtilTextMiddle.display("", C.cGreen + "+$" + minion.getMoney(), event.getPlayer()); + _moneyMap.put(event.getPlayer(), _moneyMap.get(event.getPlayer()) + minion.getMoney()); + return; + } + catch (Exception ex) {} + } + + public enum KillType + { + TYPED, SPELL; + } + + public void killMinion(Minion minion, Player player) + { + if(!minion.hasLives()) + { + _activeMinions.remove(minion); + _deadMinions.add(minion); + } + minion.despawn(player, true); + } + + private Minion getFarestMininion(Player player, String msg) + { + for(Minion minion : _activeMinions) + { + if(msg != null && !minion.getName().equalsIgnoreCase(msg)) + continue; + + if(GetTeam(player) == minion.getTeam()) + continue; + + boolean found = true; + + for(Minion otherMinion : _activeMinions) + { + if(minion == otherMinion) + continue; + + if(msg != null && !otherMinion.getName().equalsIgnoreCase(msg)) + continue; + + if(GetTeam(player) == otherMinion.getTeam()) + continue; + + if(UtilMath.offset(minion.getEntity().getLocation(), minion.getTarget()) > UtilMath.offset(otherMinion.getEntity().getLocation(), otherMinion.getTarget())) + found = false; + } + + if(found) + return minion; + else + continue; + } + return null; + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + ArrayList winners = new ArrayList<>(); + + for(GameTeam team : GetTeamList()) + { + for(GameTeam otherTeam : GetTeamList()) + { + if(team == otherTeam) + continue; + + if(getScore(team) <= 0) + { + _giants.get(team).damage(1); + winners.add(otherTeam); + } + } + } + + if(winners.isEmpty()) + return; + + GameTeam winner = winners.get(UtilMath.r(winners.size())); + AnnounceEnd(winner); + + Iterator minionIterator = _activeMinions.iterator(); + + while (minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + minion.despawn(null, false); + minionIterator.remove(); + } + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + AddGems(player, 10, "Winning Team", false, false); + } + + for (Player player : team.GetPlayers(false)) + { + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + AddGems(player, getPlayerKills(player), getPlayerKills(player) + " Minions killed", false, true); + + for(MinionSize size : MinionSize.values()) + { + if(size == MinionSize.BOSS || size == MinionSize.FREAK) + continue; + + AddGems(player, getSpawnedMinions(player, size) * size.getGemReward(), getSpawnedMinions(player, size) + " " + size.getDisplayName() + " Minions spawned", false, true); + } + } + } + } + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + for(GameTeam team : GetTeamList()) + { + Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team"); + Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team))); + Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); + String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); + if(wpm.length() > 4) + wpm = wpm.substring(0, 4); + + Scoreboard.Write(team.GetColor() + "WPM: " + wpm); + Scoreboard.WriteBlank(); + } + + Scoreboard.Draw(); + + //End + Manager.GetCreature().SetDisableCustomDrops(false); + Manager.GetChat().setThreeSecondDelay(true); + SetState(GameState.End); + } + + @EventHandler + public void preventFire(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + Iterator minionIterator = _activeMinions.iterator(); + while(minionIterator.hasNext()) + { + minionIterator.next().getEntity().setFireTicks(0); + } + } + + @EventHandler + public void updateHotbarItems(UpdateEvent event) + { + if(!IsLive()) + return; + + if (event.getType() != UpdateType.FASTEST) + return; + + for(Player player : GetPlayers(true)) + { + int e = 0; + for(Spell spell : ((KitTypeWarsBase) GetKit(player)).getSpells()) + { + if(spell instanceof SpellKillEverything) + { + if(spell.hasUsed(player)) + { + player.getInventory().setItem(e, new ItemStack(Material.AIR)); + continue; + } + } + if(_moneyMap.get(player) >= spell.getCost()) + { + if(spell.getCost() > 0) + player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, Math.round(_moneyMap.get(player)/spell.getCost()), C.cGreen + "Activate " + spell.getName() + " Cost: " + spell.getCost())); + else + player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, 1, C.cGreen + "Activate " + spell.getName() + " Cost: " + spell.getCost())); + } + else + { + player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, 0, C.cRed + "Activate " + spell.getName() + " Cost: " + spell.getCost())); + } + e++; + } + + int i = 4; + for(MinionSize type : MinionSize.values()) + { + if(type == MinionSize.BOSS || type == MinionSize.FREAK) + continue; + + if(_moneyMap.get(player) >= type.getCost()) + { + player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(type.getDisplayItem().getType(), (byte) 0, Math.round(_moneyMap.get(player)/type.getCost()), (short) type.getDisplayItem().getDurability(), C.cGreen + "Spawn " + type.getDisplayName() + " Minion Cost: " + type.getCost(), new String[]{})); + } + else + { + player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(type.getDisplayItem().getType(), (byte) 0, 0, (short) type.getDisplayItem().getDurability(), C.cRed + "Spawn " + type.getDisplayName() + " Minion Cost: " + type.getCost(), new String[]{})); + } + i++; + } + } + } + + private int _animationTicks; + + @EventHandler + public void lines(UpdateEvent event) + { + if(event.getType() != UpdateType.FASTEST) + return; + + for(ArrayList locs : _lineGrowth.values()) + { + for(Location loc : locs) + { + double radius = _animationTicks / 20D; + int particleAmount = _animationTicks / 2; + for (int e = 0; e < particleAmount; e++) + { + double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = loc.clone().add(0.5, 0, 0.5).clone().add(xDiff, particleAmount/10, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.RED_DUST, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + for(ArrayList locs : _lineShorten.values()) + { + for(Location loc : locs) + { + double radius = _animationTicks / 20D; + int particleAmount = _animationTicks / 2; + for (int e = 0; e < particleAmount; e++) + { + double xDiff = Math.sin(e/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(e/(double)particleAmount * 2 * Math.PI) * radius; + + Location location = loc.clone().add(0.5, 0, 0.5).add(xDiff, particleAmount/10, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, location, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + } + } + + _animationTicks++; + if(_animationTicks > 15) + _animationTicks = 0; + + Iterator minionIterator = _activeMinions.iterator(); + + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + for(GameTeam team : _lineGrowth.keySet()) + { + for(Location loc : _lineGrowth.get(team)) + { + if(minion.getEntity().getLocation().getBlockX() != loc.getBlockX()) + continue; + + if(minion.getEntity().getLocation().getBlockZ() != loc.getBlockZ()) + continue; + + if(!minion.isNameChangeable()) + continue; + + if(team != minion.getTeam()) + continue; + + int oldname = minion.getName().length() + 2; + minion.changeRandomName(oldname, oldname, false); + } + } + for(GameTeam team : _lineShorten.keySet()) + { + for(Location loc : _lineShorten.get(team)) + { + if(minion.getEntity().getLocation().getBlockX() != loc.getBlockX()) + continue; + + if(minion.getEntity().getLocation().getBlockZ() != loc.getBlockZ()) + continue; + + if(!minion.isNameChangeable()) + continue; + + if(team == minion.getTeam()) + continue; + + int oldname = minion.getName().length() - 2; + minion.changeRandomName(oldname, oldname, false); + } + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + if (GetTeamList().isEmpty()) + return; + + if(!IsLive()) + return; + + Scoreboard.Reset(); + + Scoreboard.WriteBlank(); + + for(GameTeam team : GetTeamList()) + { + Scoreboard.Write(team.GetColor() + C.Bold + team.GetName() + " Team"); + Scoreboard.Write(team.GetColor() + "Health: " + Math.round(getScore(team))); + Scoreboard.Write(team.GetColor() + "Minions: " + getMinions(team).size() + "/60"); + String wpm = String.valueOf((double) getTeamKills(team) / ((double) (System.currentTimeMillis() - GetStateTime())/60000)); + if(wpm.length() > 4) + wpm = wpm.substring(0, 4); + + Scoreboard.Write(team.GetColor() + "WPM: " + wpm); + Scoreboard.WriteBlank(); + } + + Scoreboard.Draw(); + } + + public ArrayList getMinions(GameTeam team) + { + ArrayList minionList = new ArrayList<>(); + Iterator minionIterator = _activeMinions.iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + if(minion.getTeam() == team) + minionList.add(minion); + } + return minionList; + } + + private int _nukeFrame; + + @EventHandler + public void nuke(UpdateEvent event) + { + if(event.getType() != UpdateType.TICK) + return; + + if(_pendingNukes.isEmpty()) + return; + + Player player = _pendingNukes.get(0); + GameTeam team = GetTeam(player); + + GameTeam otherTeam = null; + for(GameTeam teams : GetTeamList()) + { + if(teams != team) + { + otherTeam = teams; + } + } + ArrayList testLocs = UtilShapes.getLinesDistancedPoints(_minionSpawns.get(team).get(0), _minionSpawns.get(otherTeam).get(0), 1); + + if(_nukeFrame >= testLocs.size()) + { + _nukeFrame = 0; + _pendingNukes.remove(0); + return; + } + if(_nukeFrame < 25) + { + _giants.get(team).getWorld().playSound(_giants.get(team).getLocation(), Sound.ZOMBIE_IDLE, 1, 1); + } + boolean cansee = true; + int i = 0; + for(Location loc : _minionSpawns.get(team)) + { + cansee = !cansee; + ArrayList locations = UtilShapes.getLinesDistancedPoints(loc, _minionSpawns.get(otherTeam).get(i), 1); + Location location = locations.get(_nukeFrame); + + if(cansee) + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, location, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + for(Player players : GetPlayers(false)) + players.playSound(location, Sound.EXPLODE, 1, 1); + } + + Iterator minionIterator = _activeMinions.iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + if(minion.getTeam() == team) + continue; + + if(UtilMath.offset(location, minion.getEntity().getLocation()) > 1) + continue; + + minion.despawn(player, true); + if(!minion.hasLives()) + { + minionIterator.remove(); + _deadMinions.add(minion); + } + } + Iterator finishedMinionIterator = _finishedMinions.iterator(); + while(finishedMinionIterator.hasNext()) + { + Minion minion = finishedMinionIterator.next(); + if(minion.getTeam() == team) + continue; + + if(UtilMath.offset(location, minion.getEntity().getLocation()) > 3) + continue; + + minion.despawn(player, true); + if(!minion.hasLives()) + { + minionIterator.remove(); + _deadMinions.add(minion); + } + } + i++; + } + _nukeFrame++; + } + + public int getPlayerKills(Player player) + { + int kills = 0; + for(Minion minion : _deadMinions) + { + if(minion.getKiller() != null) + { + if(minion.getKiller().getName().contentEquals(player.getName())) + { + kills++; + } + } + } + return kills; + } + + public int getTeamKills(GameTeam team) + { + int kills = 0; + for(Player player : team.GetPlayers(true)) + { + kills = kills + getPlayerKills(player); + } + return kills; + } + + public int getSpawnedMinions(Player player, MinionSize size) + { + int spawns = 0; + for(Minion minion : _deadMinions) + { + if(minion.getPlayer() == null) + continue; + + if(minion.getPlayer().getName().contentEquals(player.getName())) + spawns++; + } + return spawns; + } + + public HashMap getMoneyMap() + { + return _moneyMap; + } + + public ArrayList getActiveMinions() + { + return _activeMinions; + } + + public ArrayList getDeadMinions() + { + return _deadMinions; + } + + public HashMap> getMinionSpawns() + { + return _minionSpawns; + } + + public HashMap> getLineGrowth() + { + return _lineGrowth; + } + + public HashMap> getLineShorten() + { + return _lineShorten; + } + + public void addNuke(Player player) + { + _pendingNukes.add(player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTactician.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTactician.java new file mode 100644 index 000000000..62ed1d88e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTactician.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.typewars.kits; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; +import nautilus.game.arcade.game.games.typewars.spells.SpellGrowthLiner; +import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything; +import nautilus.game.arcade.game.games.typewars.spells.SpellMassSlow; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public class KitTactician extends KitTypeWarsBase +{ + + public KitTactician(ArcadeManager manager) + { + super(manager, "Alpha. Tactician", KitAvailability.Achievement, + new String[] + { + "The ahlpabet Tactician", + "is known for using deffensive spells" + }, + new Perk[] + { + new Perk("Growth Line", new String[]{"Creates a line that grows your minions names"}){}, + new Perk("Mass Slow", new String[]{"Slows down all enemy Minions"}){}, + new Perk("Nuke Spell", new String[]{"Kill all enemy minions. One use."}){} + }, + EntityType.SKELETON, new ItemStack(Material.PAPER), + new Spell[]{new SpellGrowthLiner(manager), new SpellMassSlow(manager), new SpellKillEverything(manager)}); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTypeWarsBase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTypeWarsBase.java new file mode 100644 index 000000000..f71c2cf8f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTypeWarsBase.java @@ -0,0 +1,94 @@ +package nautilus.game.arcade.game.games.typewars.kits; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.ItemStackFactory; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.MinionSize; +import nautilus.game.arcade.game.games.typewars.Spell; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +public abstract class KitTypeWarsBase extends Kit +{ + + private Spell[] _spells; + + public KitTypeWarsBase(ArcadeManager manager, String name, KitAvailability kitAvailability, int cost, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand, Spell[] spells) + { + super(manager, name, kitAvailability, cost, kitDesc, kitPerks, entityType, itemInHand); + _spells = spells; + } + + public KitTypeWarsBase(ArcadeManager manager, String name, KitAvailability kitAvailability, String[] kitDesc, Perk[] kitPerks, EntityType entityType, ItemStack itemInHand, Spell[] spells) + { + super(manager, name, kitAvailability, kitDesc, kitPerks, entityType, itemInHand); + _spells = spells; + } + + @Override + public void GiveItems(Player player) + { + int e = 0; + for(Spell spell : getSpells()) + { + player.getInventory().setItem(e, ItemStackFactory.Instance.CreateStack(spell.getMaterial(), (byte) 0, 1, C.cYellow + "Activate " + spell.getName() + " Cost: " + spell.getCost())); + e++; + } + + int i = 4; + for(MinionSize type : MinionSize.values()) + { + if(type != MinionSize.BOSS && type != MinionSize.FREAK) + { + player.getInventory().setItem(i, ItemStackFactory.Instance.CreateStack(type.getDisplayItem().getType(), (byte) 0, 1, (short) type.getDisplayItem().getDurability(), C.cYellow + "Spawn " + type.getDisplayName() + " Minion Cost: " + type.getCost(), new String[]{})); + i++; + } + } + } + + public Spell[] getSpells() + { + return _spells; + } + + @EventHandler + public void activateSpell(PlayerInteractEvent event) + { + if(!Manager.GetGame().IsLive()) + return; + + if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) + return; + + if(event.getPlayer().getItemInHand() == null) + return; + + if(!Manager.GetGame().GetKit(event.getPlayer()).GetName().equalsIgnoreCase(GetName())) + return; + + executeSpell(event.getPlayer(), event.getPlayer().getItemInHand().getType()); + } + + public boolean executeSpell(Player player, Material mat) + { + for(Spell spell : getSpells()) + { + if(spell.getMaterial() == mat) + { + spell.prepareExecution(player); + return true; + } + } + return false; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTyper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTyper.java new file mode 100644 index 000000000..4eb64ad90 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitTyper.java @@ -0,0 +1,38 @@ +package nautilus.game.arcade.game.games.typewars.kits; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; +import nautilus.game.arcade.game.games.typewars.spells.SpellFirebomb; +import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything; +import nautilus.game.arcade.game.games.typewars.spells.SpellSniper; +import nautilus.game.arcade.game.games.typewars.spells.SpellSpeedUp; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public class KitTyper extends KitTypeWarsBase +{ + + public KitTyper(ArcadeManager manager) + { + super(manager, "Typer", KitAvailability.Free, + + new String[] + { + "This is the fastest typer ", + "in the land of Mineplex" + }, + new Perk[] + { + new Perk("Fire Bomb", new String[]{"Kills small and medium sized enemies."}){}, + new Perk("Sniper spell", new String[]{"Shoot a minion and kill it"}){}, + new Perk("Zombie Smash", new String[]{"Kill all enemy minions. One use."}){} + }, + EntityType.ZOMBIE, new ItemStack(Material.FEATHER), + new Spell[]{new SpellFirebomb(manager), new SpellSniper(manager), new SpellKillEverything(manager)}); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitWarrior.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitWarrior.java new file mode 100644 index 000000000..de293df7d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/kits/KitWarrior.java @@ -0,0 +1,36 @@ +package nautilus.game.arcade.game.games.typewars.kits; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; +import nautilus.game.arcade.game.games.typewars.spells.SpellKillEverything; +import nautilus.game.arcade.game.games.typewars.spells.SpellShrinkLiner; +import nautilus.game.arcade.game.games.typewars.spells.SpellSniper; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.inventory.ItemStack; + +public class KitWarrior extends KitTypeWarsBase +{ + + public KitWarrior(ArcadeManager manager) + { + super(manager, "Letter Warrior", KitAvailability.Gem, 2000, + new String[] + { + "This Legendary Warrior", + "has many Offensive spells" + }, + new Perk[] + { + new Perk("Shrinking Line", new String[]{"Creates a line that shortens enemy names"}){}, + new Perk("Sniper spell", new String[]{"Shoot a minion and kill it"}){}, + new Perk("Nuke Spell", new String[]{"Kill all enemy minions. One use."}){} + }, + EntityType.SKELETON, new ItemStack(Material.STONE_SWORD), + new Spell[]{new SpellShrinkLiner(manager), new SpellSniper(manager), new SpellKillEverything(manager)}); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellFirebomb.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellFirebomb.java new file mode 100644 index 000000000..2da5791b2 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellFirebomb.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.Iterator; + +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.MinionSize; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +public class SpellFirebomb extends Spell +{ + + public SpellFirebomb(ArcadeManager manager) + { + super(manager, "Firebomb", 4, Material.BLAZE_POWDER, 2000L, 5, 0, false); + } + + @Override + public boolean execute(Player player, Location location) + { + Iterator minionIterator = getTypeWars().getActiveMinions().iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + + if(UtilMath.offset2d(minion.getEntity().getLocation(), location) > 3) + continue; + + if(getTypeWars().GetTeam(player) == minion.getTeam()) + continue; + + if(minion.getType().getSize() != MinionSize.EASY) + { + UtilPlayer.message(player, F.main("Game", F.game(minion.getName()) + " is to strong to be killed with that.")); + continue; + } + + minion.despawn(player, true); + if(!minion.hasLives()) + { + minionIterator.remove(); + getTypeWars().getDeadMinions().add(minion); + } + } + return true; + } + + @Override + public ParticleType hit() + { + return ParticleType.HUGE_EXPLOSION; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java new file mode 100644 index 000000000..1ba8efa83 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellGrowthLiner.java @@ -0,0 +1,135 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class SpellGrowthLiner extends Spell +{ + + public SpellGrowthLiner(ArcadeManager manager) + { + super(manager, "Growth Line", 7, Material.STICK, 2000L, 10, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.FLAME; + } + + @Override + public boolean execute(final Player player, Location location) + { + final ArrayList line = getLine(player, location); + for(Location loc : line) + { + getTypeWars().getLineGrowth().get(getManager().GetGame().GetTeam(player)).add(loc); + } + + getManager().runSyncLater(new Runnable() + { + @Override + public void run() + { + for(Location loc : line) + { + getTypeWars().getLineGrowth().get(getManager().GetGame().GetTeam(player)).remove(loc); + } + } + }, 180); + return true; + } + + private ArrayList getLine(Player player, Location location) + { + ArrayList line = new ArrayList<>(); + ArrayList spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)); + for(Location loc : spawns) + { + if(loc.getBlockX() == location.getBlockX() || loc.getBlockX() == location.getBlockX() - 1 || loc.getBlockX() == location.getBlockX() + 1) + { + for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player))) + { + Location newLoc = locs.clone(); + newLoc.setZ(location.getBlockZ()); + line.add(newLoc); + Location pos1 = newLoc.clone().add(1, 0, 0); + Location pos2 = newLoc.clone().add(-1, 0, 0); + boolean addLoc1 = true; + boolean addLoc2 = true; + for(Location otherLoc : line) + { + if(otherLoc.equals(pos1)) + addLoc1 = false; + } + for(Location otherLoc : line) + { + if(otherLoc.equals(pos2)) + addLoc2 = false; + } + if(addLoc1) + line.add(pos1); + + if(addLoc2) + line.add(pos2); + } + break; + } + if(loc.getBlockZ() == location.getBlockZ() || loc.getBlockZ() == location.getBlockZ() - 1 || loc.getBlockZ() == location.getBlockZ() + 1) + { + for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player))) + { + Location newLoc = locs.clone(); + newLoc.setX(location.getBlockX()); + line.add(newLoc); + Location pos1 = newLoc.clone().add(0, 0, 1); + Location pos2 = newLoc.clone().add(0, 0, -1); + boolean addLoc1 = true; + boolean addLoc2 = true; + for(Location otherLoc : line) + { + if(otherLoc.equals(pos1)) + addLoc1 = false; + } + for(Location otherLoc : line) + { + if(otherLoc.equals(pos2)) + addLoc2 = false; + } + if(addLoc1) + line.add(pos1); + + if(addLoc2) + line.add(pos2); + } + break; + } + } + for(Location loc : spawns) + { + Iterator locIterator = line.iterator(); + while(locIterator.hasNext()) + { + Location locs = locIterator.next(); + if(locs.equals(loc)) + { + locIterator.remove(); + } + if(locs.getBlock().getType() != Material.AIR) + locIterator.remove(); + + } + } + return line; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellKillEverything.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellKillEverything.java new file mode 100644 index 000000000..26bae0d4b --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellKillEverything.java @@ -0,0 +1,60 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextMiddle; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.ActivateNukeSpellEvent; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class SpellKillEverything extends Spell +{ + + public SpellKillEverything(ArcadeManager manager) + { + super(manager, "Zombie Smash", 0, Material.TNT, 1000L, 0, 20000, true); + } + + @Override + public ParticleType trail() + { + return null; + } + + @Override + public ParticleType hit() + { + return null; + } + + @Override + public boolean execute(Player player, Location location) + { + + UtilTextMiddle.display("", getManager().GetGame().GetTeam(player).GetColor() + player.getName() + " used a Zombie Smash", 0, 40, 0); + ArrayList minionList = new ArrayList<>(); + Iterator minionIterator = getTypeWars().getActiveMinions().iterator(); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + + if(getTypeWars().GetTeam(player) == minion.getTeam()) + continue; + + minionList.add(minion); + } + getTypeWars().addNuke(player); + Bukkit.getPluginManager().callEvent(new ActivateNukeSpellEvent(player, minionList)); + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellMassSlow.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellMassSlow.java new file mode 100644 index 000000000..26068b303 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellMassSlow.java @@ -0,0 +1,79 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.Spell; + +public class SpellMassSlow extends Spell +{ + + public SpellMassSlow(ArcadeManager manager) + { + super(manager, "Mass Slow spell", 8, Material.ANVIL, 2000L, 0, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.WITCH_MAGIC; + } + + @Override + public boolean execute(Player player, Location location) + { + location.getWorld().playSound(location.clone().add(0.5, 0.5, 0.5), Sound.ENDERDRAGON_DEATH, 10F, 2.0F); + + for(int c = -1; c <= 1; c++) + { + for(int i = -10; i <= 10; i = i + 2) + { + for(double x = 0.2; x <= 2; x = x + 0.2) + { + Location loc = location.clone().add(i + x, 2*(x-1)*(x-1)*(x-1) -2*(x-1), c); + loc.add(0, 0.3, 0); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, loc, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + + Location otherLocation = location.clone().add(c, 2*(x-1)*(x-1)*(x-1) -2*(x-1), i + x); + otherLocation.add(0, 0.3, 0); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HAPPY_VILLAGER, otherLocation, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + } + } + } + + for(Minion minion : getTypeWars().getActiveMinions()) + { + if(getTypeWars().GetTeam(player) == minion.getTeam()) + continue; + + minion.increaseWalkSpeed(-0.3F); + } + return true; + } + + /*@Override + public void trailAnimation(Location location, int frame) + { + double radius = 0.6; + int particleAmount = frame / 2; + for (int i = 0; i < particleAmount; i++) + { + double xDiff = Math.sin(i/(double)particleAmount * 2 * Math.PI) * radius; + double zDiff = Math.cos(i/(double)particleAmount * 2 * Math.PI) * radius; + + Location loc = location.clone().add(xDiff, 0, zDiff); + UtilParticle.PlayParticle(UtilParticle.ParticleType.ENCHANTMENT_TABLE, loc, 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + }*/ + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java new file mode 100644 index 000000000..4bf3471e8 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellShrinkLiner.java @@ -0,0 +1,134 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class SpellShrinkLiner extends Spell +{ + + public SpellShrinkLiner(ArcadeManager manager) + { + super(manager, "Shrinking Line", 7, Material.BLAZE_ROD, 2000L, 10, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.FLAME; + } + + @Override + public boolean execute(final Player player, Location location) + { + final ArrayList line = getLine(player, location); + for(Location loc : line) + { + getTypeWars().getLineShorten().get(getManager().GetGame().GetTeam(player)).add(loc); + } + + getManager().runSyncLater(new Runnable() + { + @Override + public void run() + { + for(Location loc : line) + { + getTypeWars().getLineShorten().get(getManager().GetGame().GetTeam(player)).remove(loc); + } + } + }, 180); + return true; + } + + private ArrayList getLine(Player player, Location location) + { + ArrayList line = new ArrayList<>(); + ArrayList spawns = getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player)); + for(Location loc : spawns) + { + if(loc.getBlockX() == location.getBlockX() || loc.getBlockX() == location.getBlockX() - 1 || loc.getBlockX() == location.getBlockX() + 1) + { + for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player))) + { + Location newLoc = locs.clone(); + newLoc.setZ(location.getBlockZ()); + line.add(newLoc); + Location pos1 = newLoc.clone().add(1, 0, 0); + Location pos2 = newLoc.clone().add(-1, 0, 0); + boolean addLoc1 = true; + boolean addLoc2 = true; + for(Location otherLoc : line) + { + if(otherLoc.equals(pos1)) + addLoc1 = false; + } + for(Location otherLoc : line) + { + if(otherLoc.equals(pos2)) + addLoc2 = false; + } + if(addLoc1) + line.add(pos1); + + if(addLoc2) + line.add(pos2); + } + break; + } + if(loc.getBlockZ() == location.getBlockZ() || loc.getBlockZ() == location.getBlockZ() - 1 || loc.getBlockZ() == location.getBlockZ() + 1) + { + for(Location locs : getTypeWars().getMinionSpawns().get(getManager().GetGame().GetTeam(player))) + { + Location newLoc = locs.clone(); + newLoc.setX(location.getBlockX()); + line.add(newLoc); + Location pos1 = newLoc.clone().add(0, 0, 1); + Location pos2 = newLoc.clone().add(0, 0, -1); + boolean addLoc1 = true; + boolean addLoc2 = true; + for(Location otherLoc : line) + { + if(otherLoc.equals(pos1)) + addLoc1 = false; + } + for(Location otherLoc : line) + { + if(otherLoc.equals(pos2)) + addLoc2 = false; + } + if(addLoc1) + line.add(pos1); + + if(addLoc2) + line.add(pos2); + } + break; + } + } + for(Location loc : spawns) + { + Iterator locIterator = line.iterator(); + while(locIterator.hasNext()) + { + Location locs = locIterator.next(); + if(locs.equals(loc)) + { + locIterator.remove(); + } + if(locs.getBlock().getType() != Material.AIR) + locIterator.remove(); + + } + } + return line; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSniper.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSniper.java new file mode 100644 index 000000000..ddc9db8e5 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSniper.java @@ -0,0 +1,63 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import java.util.ArrayList; +import java.util.Iterator; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilShapes; +import mineplex.core.common.util.UtilParticle.ParticleType; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.MinionSize; +import nautilus.game.arcade.game.games.typewars.Spell; + +public class SpellSniper extends Spell +{ + + public SpellSniper(ArcadeManager manager) + { + super(manager, "Sniper spell", 4, Material.ARROW, 2000L, 0, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.EXPLODE; + } + + @Override + public boolean execute(Player player, Location location) + { + Iterator minionIterator = getTypeWars().getActiveMinions().iterator(); + + ArrayList locs = UtilShapes.getLinesDistancedPoints(player.getEyeLocation(), location, 0.5); + while(minionIterator.hasNext()) + { + Minion minion = minionIterator.next(); + + for(Location loc : locs) + { + if(UtilMath.offset2d(minion.getEntity().getLocation(), loc) > 1) + continue; + + if(getTypeWars().GetTeam(player) == minion.getTeam()) + continue; + + minion.despawn(player, true); + if(!minion.hasLives()) + { + minionIterator.remove(); + getTypeWars().getDeadMinions().add(minion); + } + break; + } + } + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSpeedUp.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSpeedUp.java new file mode 100644 index 000000000..e38733319 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/spells/SpellSpeedUp.java @@ -0,0 +1,67 @@ +package nautilus.game.arcade.game.games.typewars.spells; + +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.Spell; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; + +public class SpellSpeedUp extends Spell +{ + + public SpellSpeedUp(ArcadeManager manager) + { + super(manager, "Speed Boost", 6, Material.FEATHER, 5000L, 0, 0, false); + } + + @Override + public ParticleType trail() + { + return ParticleType.HAPPY_VILLAGER; + } + + @Override + public boolean execute(Player player, Location location) + { + + location.getWorld().playSound(location.clone().add(0.5, 0.5, 0.5), Sound.FIREWORK_BLAST, 10F, 2.0F); + + for(int c = -1; c <= 1; c++) + { + for(int i = -10; i <= 10; i = i + 2) + { + for(double x = 0.2; x <= 2; x = x + 0.2) + { + Location loc = location.clone().add(i + x, 2*(x-1)*(x-1)*(x-1) -2*(x-1), c); + loc.add(0, 0.3, 0); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, loc, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + + Location otherLocation = location.clone().add(c, 2*(x-1)*(x-1)*(x-1) -2*(x-1), i + x); + otherLocation.add(0, 0.3, 0); + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, otherLocation, 0, 0, 0, 0, 1, ViewDist.LONG, UtilServer.getPlayers()); + } + } + } + + for(Minion minion : getTypeWars().getActiveMinions()) + { + if(UtilMath.offset2d(minion.getEntity().getLocation(), location) > 3) + continue; + + if(getTypeWars().GetTeam(player) != minion.getTeam()) + continue; + + minion.increaseWalkSpeed((float) 0.5); + } + return true; + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DemonStatsTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DemonStatsTracker.java new file mode 100644 index 000000000..480443f76 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DemonStatsTracker.java @@ -0,0 +1,54 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import java.util.HashMap; + +import nautilus.game.arcade.game.games.typewars.MinionKillEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.game.games.typewars.TypeWars.KillType; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class DemonStatsTracker extends StatTracker +{ + + private HashMap _players; + private HashMap _kills; + + public DemonStatsTracker(TypeWars game) + { + super(game); + _players = new HashMap<>(); + _kills = new HashMap<>(); + } + + @EventHandler + public void minonKill(MinionKillEvent event) + { + if(event.getType() != KillType.TYPED) + return; + + if(!_players.containsKey(event.getPlayer())) + { + _players.put(event.getPlayer(), System.currentTimeMillis()); + _kills.put(event.getPlayer(), 1); + return; + } + if(_players.get(event.getPlayer()) + 8000 > System.currentTimeMillis()) + { + int kills = _kills.get(event.getPlayer()); + _kills.put(event.getPlayer(), kills + 1); + } + else + { + _players.put(event.getPlayer(), System.currentTimeMillis()); + _kills.put(event.getPlayer(), 1); + } + if(_kills.get(event.getPlayer()) >= 5) + { + addStat(event.getPlayer(), "Demon", 1, true, false); + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DumbledontStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DumbledontStatTracker.java new file mode 100644 index 000000000..2549690a6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/DumbledontStatTracker.java @@ -0,0 +1,52 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import java.util.ArrayList; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.ActivateSpellEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class DumbledontStatTracker extends StatTracker +{ + + private ArrayList _players; + + public DumbledontStatTracker(TypeWars game) + { + super(game); + _players = new ArrayList<>(); + } + + @EventHandler + public void spell(ActivateSpellEvent event) + { + _players.remove(event.getPlayer()); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if(event.GetState() == GameState.Live) + { + for(Player player : event.GetGame().GetPlayers(true)) + _players.add(player); + } + if(event.GetState() == GameState.End) + { + for(Player player : _players) + { + if(player.isOnline()) + { + if(event.GetGame().GetTeam(player) == event.GetGame().WinnerTeam) + addStat(player, "Dumbledont", 1, true, false); + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/HoarderStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/HoarderStatTracker.java new file mode 100644 index 000000000..588520211 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/HoarderStatTracker.java @@ -0,0 +1,37 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import java.util.HashMap; + +import nautilus.game.arcade.game.games.typewars.SummonMinionEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class HoarderStatTracker extends StatTracker +{ + + private HashMap _players; + + public HoarderStatTracker(TypeWars game) + { + super(game); + _players = new HashMap<>(); + } + + @EventHandler + public void summonMinion(SummonMinionEvent event) + { + if(!_players.containsKey(event.getPlayer())) + { + _players.put(event.getPlayer(), 1); + return; + } + int summons = _players.get(event.getPlayer()); + _players.put(event.getPlayer(), summons + 1); + if(_players.get(event.getPlayer()) >= 50) + addStat(event.getPlayer(), "Hoarder", 1, true, false); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/KillsStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/KillsStatTracker.java new file mode 100644 index 000000000..1aa151b31 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/KillsStatTracker.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +public class KillsStatTracker extends StatTracker +{ + + private TypeWars _typeWars; + + public KillsStatTracker(TypeWars game) + { + super(game); + _typeWars = game; + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if(event.GetState() != GameState.End) + return; + + for(Player player : _typeWars.GetPlayers(true)) + { + addStat(player, "MinionKills", _typeWars.getPlayerKills(player), false, false); + } + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/PerfectionistStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/PerfectionistStatTracker.java new file mode 100644 index 000000000..f84200bd0 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/PerfectionistStatTracker.java @@ -0,0 +1,82 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import java.util.ArrayList; +import java.util.HashMap; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.games.typewars.TypeAttemptEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class PerfectionistStatTracker extends StatTracker +{ + + private HashMap _wordsRecently; + private ArrayList _players; + private HashMap _playerWords; + + public PerfectionistStatTracker(TypeWars game) + { + super(game); + _wordsRecently = new HashMap<>(); + _players = new ArrayList<>(); + _playerWords = new HashMap<>(); + } + + @EventHandler + public void attempt(TypeAttemptEvent event) + { + if(event.isSuccessful()) + { + _wordsRecently.put(event.getAttempt().toUpperCase(), System.currentTimeMillis()); + + if(!_playerWords.containsKey(event.getPlayer())) + _playerWords.put(event.getPlayer(), 1); + + int words = _playerWords.get(event.getPlayer()); + _playerWords.put(event.getPlayer(), words + 1); + } + else + { + if(_wordsRecently.containsKey(event.getAttempt().toUpperCase())) + { + if(_wordsRecently.get(event.getAttempt().toUpperCase()) + 2000 > System.currentTimeMillis()) + { + return; + } + } + _players.remove(event.getPlayer()); + } + } + + @EventHandler + public void gameState(GameStateChangeEvent event) + { + if(event.GetState() == GameState.Live) + { + for(Player player : event.GetGame().GetPlayers(true)) + { + _players.add(player); + } + } + if(event.GetState() == GameState.End) + { + for(Player player : _players) + { + if(player.isOnline()) + { + if(_playerWords.containsKey(player)) + { + if(_playerWords.get(player) >= 5) + addStat(player, "Perfectionist", 1, true, false); + } + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/TimeInGameTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/TimeInGameTracker.java new file mode 100644 index 000000000..b92316dae --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/TimeInGameTracker.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; + +public class TimeInGameTracker extends StatTracker +{ + + public TimeInGameTracker(Game game) + { + super(game); + } + + @EventHandler + public void end(GameStateChangeEvent event) + { + if(event.GetState() != GameState.End) + return; + + for(Player player : getGame().GetPlayers(true)) + { + addStat(player, "TimeInGame", (int) (((System.currentTimeMillis() - getGame().getGameLiveTime())/1000)/60), false, false); + } + + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/WaitForItStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/WaitForItStatTracker.java new file mode 100644 index 000000000..14ec0a44c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/stats/WaitForItStatTracker.java @@ -0,0 +1,24 @@ +package nautilus.game.arcade.game.games.typewars.stats; + +import nautilus.game.arcade.game.games.typewars.ActivateNukeSpellEvent; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.stats.StatTracker; + +import org.bukkit.event.EventHandler; + +public class WaitForItStatTracker extends StatTracker +{ + + public WaitForItStatTracker(TypeWars game) + { + super(game); + } + + @EventHandler + public void nuke(ActivateNukeSpellEvent event) + { + if(event.getMinions().size() >= 30) + addStat(event.getPlayer(), "Nuke", 1, true, false); + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialPhaseTypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialPhaseTypeWars.java new file mode 100644 index 000000000..0c6c64898 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialPhaseTypeWars.java @@ -0,0 +1,62 @@ +package nautilus.game.arcade.game.games.typewars.tutorial; + +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.gametutorial.TutorialPhase; +import nautilus.game.arcade.gametutorial.TutorialText; + +public class TutorialPhaseTypeWars extends TutorialPhase +{ + + public TutorialPhaseTypeWars() + { + super(new TutorialText[] + { + new TutorialText("This is your giant!", 1), + new TutorialText("Protect him from evil minions!", 2), + new TutorialText("Type the name above their head to kill them", 3), + new TutorialText("F_", 7, 4), + new TutorialText("Fi_", 7, 5), + new TutorialText("Fis_", 7, 6), + new TutorialText("Fish_", 7, 7), + new TutorialText("Fishi_", 7, 8), + new TutorialText("Fishin_", 7, 9), + new TutorialText("Fishing_", 30, 10), + new TutorialText("Kill your enemy's giant before they kill yours.", 11) + }); + } + + @Override + public int ID() + { + return 1; + } + + @Override + public void onStart() + { + + } + + @Override + public void onEnd() + { + + } + + @Override + public void onMessageDisplay(TutorialText text) + { + if(text.ID() == 10) + { + for(Minion minion : ((TypeWars) getTutorial().Manager.GetGame()).getActiveMinions()) + { + if(minion.getTeam() == getTutorial().getTeam()) + { + minion.despawn(null, false); + } + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialTypeWars.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialTypeWars.java new file mode 100644 index 000000000..6c4cd2600 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/typewars/tutorial/TutorialTypeWars.java @@ -0,0 +1,49 @@ +package nautilus.game.arcade.game.games.typewars.tutorial; + +import java.util.ArrayList; + +import mineplex.core.common.util.UtilShapes; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.typewars.Minion; +import nautilus.game.arcade.game.games.typewars.TypeWars; +import nautilus.game.arcade.gametutorial.GameTutorial; +import nautilus.game.arcade.gametutorial.TutorialPhase; + +import org.bukkit.Location; + +public class TutorialTypeWars extends GameTutorial +{ + + private ArcadeManager _manager; + private TypeWars _typeWars; + + public TutorialTypeWars(ArcadeManager manager) + { + super(manager, new TutorialPhase[]{new TutorialPhaseTypeWars()}); + + TutorialNotification = true; + } + + @Override + public void onStart() + { + _manager = Manager; + _typeWars = (TypeWars) Manager.GetGame(); + for(GameTeam team : Manager.GetGame().GetTeamList()) + { + if(team != getTeam()) + { + ArrayList locations = UtilShapes.getLinesDistancedPoints(_typeWars.getMinionSpawns().get(getTeam()).get(4), _typeWars.getMinionSpawns().get(team).get(4), 1); + _manager.GetCreature().SetForce(true); + _manager.GetGame().CreatureAllowOverride = true; + Minion minion = new Minion(_manager, locations.get(locations.size() - 35), _typeWars.getMinionSpawns().get(team).get(4), getTeam(), 4); + minion.changeName("Fishing"); + ((TypeWars) _manager.GetGame()).getActiveMinions().add(minion); + _manager.GetGame().CreatureAllowOverride = false; + _manager.GetCreature().SetForce(false); + } + } + } + +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java index fc4457377..96ac7ad5a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/GameTutorial.java @@ -3,7 +3,6 @@ package nautilus.game.arcade.gametutorial; import java.util.HashMap; import mineplex.core.common.util.UtilServer; -import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.gametutorial.events.GameTutorialEndEvent; @@ -36,9 +35,12 @@ public abstract class GameTutorial public boolean RunTasksSync = true; public boolean PlayTutorialSounds = false; public boolean ShowPrepareTimer = false; + public boolean CustomEnding = false; + public boolean TutorialNotification = false; public long TimeBetweenPhase = 0; public long StartAfterTutorial = 5000; + public long CustomEndingTime = 5000; public GameTutorial(ArcadeManager manager, TutorialPhase[] phases) { @@ -47,6 +49,9 @@ public abstract class GameTutorial _players = new HashMap<>(); } + /** + * start the Tutorial (never use this) + */ final public void start() { _hasStarted = true; @@ -54,7 +59,30 @@ public abstract class GameTutorial for(TutorialPhase phase : _phases) phase.setTutorial(this); - //Manager.GetGame().PrepareTime = 60000; + if(TutorialNotification) + { + TutorialPhase phase = getPhase(1); + for(TutorialText text : phase.getText()) + { + int index = text.ID(); + text.setID(index + 1); + } + TutorialText[] newText = new TutorialText[phase.getText().length + 1]; + for(int i = 0; i < newText.length; i++) + { + if(i == 0) + { + newText[i] = new TutorialText("Please notice that this is a Tutorial", 20, 1); + continue; + } + else + { + newText[i] = phase.getText()[i - 1]; + } + } + phase.setText(newText); + } + Manager.GetChat().Silence(60000, false); _started = System.currentTimeMillis(); Manager.getPluginManager().callEvent(new GameTutorialStartEvent(this)); @@ -72,6 +100,9 @@ public abstract class GameTutorial _currentPhase.teleport(); } + /** + * Stting next Phase/ending Tutorial + */ protected void nextPhase(boolean phaseOne) { TutorialPhase from = _currentPhase; @@ -80,25 +111,33 @@ public abstract class GameTutorial if(_currentPhase == null) { - onEnd(); - _hasEnded = true; - endTutorial(); - final GameTutorial tutorial = this; - Manager.runSyncLater(new Runnable() + // has ended + if(!CustomEnding) { - @Override - public void run() + onEnd(); + _hasEnded = true; + endTutorial(); + final GameTutorial tutorial = this; + Manager.runSyncLater(new Runnable() { - Manager.getPluginManager().callEvent(new GameTutorialEndEvent(tutorial)); - } - }, 5); + @Override + public void run() + { + Manager.getPluginManager().callEvent(new GameTutorialEndEvent(tutorial)); + } + }, 5); + } } else { - Manager.GetChat().Silence(70000, false); - onPhaseChange(_currentPhase); - Manager.getPluginManager().callEvent(new GameTutorialPhaseEvent(this, from, _currentPhase)); - _currentPhase.start(phaseOne); + // setting another Phase, if Tutorial hasn't stopped yet + if(!_hasEnded) + { + Manager.GetChat().Silence(70000, false); + onPhaseChange(_currentPhase); + Manager.getPluginManager().callEvent(new GameTutorialPhaseEvent(this, from, _currentPhase)); + _currentPhase.start(phaseOne); + } } } @@ -111,19 +150,19 @@ public abstract class GameTutorial { for(final Player player : _players.keySet()) { - //VisibilityManager.Instance.setVisibility(player, true, UtilServer.getPlayers()); Manager.runSyncLater(new Runnable() { @Override public void run() { - for(Player player : Manager.GetGame().GetPlayers(true)) + // Player visibility/fly mode + for(Player other : Manager.GetGame().GetPlayers(false)) { - for(Player other : Manager.GetGame().GetPlayers(true)) - { - player.showPlayer(other); - } - } + if(player == other) + continue; + + other.showPlayer(player); + } player.setAllowFlight(false); player.setFlying(false); } @@ -135,17 +174,20 @@ public abstract class GameTutorial @Override public void run() { + // Spawn teleporting _team.SpawnTeleport(); } }, 5); } } + // setting the right prepare Time after the Tutorial ends Manager.GetChat().Silence(StartAfterTutorial, false); Manager.GetGame().PrepareTime = (System.currentTimeMillis() - Manager.GetGame().GetStateTime()) + StartAfterTutorial; } protected TutorialPhase getNextPhase() { + // getting next TutorialPhase for(TutorialPhase phase : _phases) { if(_currentPhase == null && phase.ID() == 1) @@ -164,13 +206,13 @@ public abstract class GameTutorial { for(Player player : UtilServer.getPlayers()) { + // setting Players into fly mode and save their Locations int i = 0; if(Manager.GetGame().GetTeam(player) == _team) { _players.put(player, Manager.GetGame().GetTeam(player).GetSpawns().get(i)); player.setAllowFlight(true); player.setFlying(true); - // VisibilityManager.Instance.setVisibility(player, false, UtilServer.getPlayers()); i++; } } @@ -206,16 +248,42 @@ public abstract class GameTutorial return _team; } - public void onTick(int tick){} - - public void onStart(){} - - public void onPhaseChange(TutorialPhase phase){} - - public void onEnd(){} + /** + * only available if CustomEnding is enabled + * You can end the tutorial with this method + * if you set CutomEnding to true, you have to run this method! + */ + public void end() + { + if(CustomEnding) + { + // Ending + onEnd(); + _hasEnded = true; + Thread thread = _currentPhase.getThread(); + if(thread.isAlive()) + thread.destroy(); + + endTutorial(); + final GameTutorial tutorial = this; + Manager.runSyncLater(new Runnable() + { + @Override + public void run() + { + Manager.getPluginManager().callEvent(new GameTutorialEndEvent(tutorial)); + } + }, 5); + } + else + { + System.out.println("Only allowed while Custom Ending is enabled"); + } + } public int tick() { + // Fix for Visibility Manager not really working if(!_hasEnded && hasStarted()) { for(Player player : UtilServer.getPlayers()) @@ -249,4 +317,17 @@ public abstract class GameTutorial { return _currentPhase.getPhaseTime(); } + + /* + * some overrideable methods that can be used to synchronize the tutorial events + */ + + public void onTick(int tick){} + + public void onStart(){} + + public void onPhaseChange(TutorialPhase phase){} + + public void onEnd(){} + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java index b140b79bc..57c4baad5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialPhase.java @@ -18,6 +18,8 @@ public abstract class TutorialPhase private Location _target; private boolean _hasEnded; + private Thread _thread; + private long _started; private TutorialText _currentText; @@ -27,6 +29,9 @@ public abstract class TutorialPhase _text = text; } + /** + * start the Phase (never use this as well) + */ final public void start(boolean phaseOne) { _hasEnded = false; @@ -39,6 +44,9 @@ public abstract class TutorialPhase displayText(); } + /** + * Teleporting Players and keeping them if SetTutorialPositions == true + */ final public void teleport() { if(!getTutorial().SetTutorialPositions) @@ -51,6 +59,9 @@ public abstract class TutorialPhase } } + /** + * preparing Pitch/Yaw of the location + */ private void prepareLocations() { Vector vector = new Vector(_target.getBlockX() - _location.getBlockX(), _target.getBlockY() - _location.getBlockY(), _target.getBlockZ() - _location.getBlockZ()); @@ -60,6 +71,9 @@ public abstract class TutorialPhase _location.setYaw(yaw); } + /** + * teleporting players until Phase ends + */ private void updatePlayers() { new Thread(new Runnable() @@ -74,6 +88,7 @@ public abstract class TutorialPhase @Override public void run() { + // teleport Players Sync if(!_hasEnded && !getTutorial().hasEnded()) { for(Player player : _tutorial.getPlayers().keySet()) @@ -87,6 +102,7 @@ public abstract class TutorialPhase }); try { + // sleep for 1 tick Thread.sleep(50); } catch (InterruptedException e) { @@ -97,9 +113,13 @@ public abstract class TutorialPhase }).start(); } + /** + * displays all messages set in the constructor + * will end Phase if no more messages are available or Tutorial has already ended + */ public void displayText() { - new Thread(new Runnable() + _thread = new Thread(new Runnable() { @Override public void run() @@ -109,6 +129,7 @@ public abstract class TutorialPhase TutorialText text = getNextMessage(); if(text == null) { + // ending Phase _tutorial.Manager.runSyncLater(new Runnable() { @Override @@ -123,6 +144,7 @@ public abstract class TutorialPhase } else { + // displaying next message Player[] players = new Player[_tutorial.getPlayers().keySet().size()]; int i = 0; for(Player player : _tutorial.getPlayers().keySet()) @@ -137,7 +159,7 @@ public abstract class TutorialPhase } displayMessage(text); UtilTextMiddle.display("", text.getText(), 0, text.getStayTime(), 0, players); - try + try { Thread.sleep(text.getStayTime() * 50); } catch (InterruptedException e) @@ -148,14 +170,18 @@ public abstract class TutorialPhase } } - }).start(); + }); + _thread.start(); } + /** + * firing abstract method Sync/Async depending on the RunTasksSync Flag + */ private void displayMessage(final TutorialText text) { if(_tutorial.RunTasksSync) { - _tutorial.Manager.runSync(new Runnable() + _tutorial.Manager.runSync(new Runnable() { @Override public void run() @@ -170,6 +196,9 @@ public abstract class TutorialPhase } } + /** + * getting next message + */ protected TutorialText getNextMessage() { for(TutorialText text : _text) @@ -193,6 +222,11 @@ public abstract class TutorialPhase return _text; } + public void setText(TutorialText[] text) + { + _text = text; + } + public Location getLocation() { return _location; @@ -228,6 +262,15 @@ public abstract class TutorialPhase return _started; } + public Thread getThread() + { + return _thread; + } + + /* + * some overrideable methods that can be used to synchronize the tutorial events + */ + public void onStart(){} public void onMessageDisplay(TutorialText text){} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java index dba1d39a6..2711b10fa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/gametutorial/TutorialText.java @@ -59,4 +59,9 @@ public class TutorialText _text = text; } + public void setID(int id) + { + _id = id; + } + } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java index ca7bb2df2..c3fd7777d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameManager.java @@ -19,34 +19,31 @@ import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.gadget.gadgets.morph.MorphWither; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; -import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.core.mount.Mount; import mineplex.core.mount.types.MountDragon; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.RestartServerEvent; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.condition.Condition.ConditionType; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.events.GamePrepareCountdownCommence; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.games.uhc.UHC; -import nautilus.game.arcade.gametutorial.GameTutorial; import nautilus.game.arcade.gametutorial.TutorialPhase; import nautilus.game.arcade.gametutorial.TutorialText; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Sound; -import org.bukkit.FireworkEffect.Type; import org.bukkit.entity.Creature; import org.bukkit.entity.Player; -import org.bukkit.entity.Wither; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -220,9 +217,12 @@ public class GameManager implements Listener if(!team.getTutorial().hasStarted()) { team.getTutorial().setTeam(team); - team.getTutorial().start(); + team.getTutorial().start(); timeUsage = team.getTutorial().StartAfterTutorial; timeUsage = timeUsage + (team.getTutorial().TimeBetweenPhase * team.getTutorial().getPhases().length); + if(team.getTutorial().CustomEnding) + timeUsage = timeUsage + team.getTutorial().CustomEndingTime; + for(TutorialPhase phase : team.getTutorial().getPhases()) { for(TutorialText text : phase.getText()) @@ -237,9 +237,9 @@ public class GameManager implements Listener if(checkForTimer) { if(team.getTutorial().ShowPrepareTimer) - finished = false; - else finished = true; + else + finished = false; } } } @@ -251,7 +251,7 @@ public class GameManager implements Listener if(!finished) return true; - } + } return false; } @@ -290,6 +290,7 @@ public class GameManager implements Listener if(game.GetState() != GameState.Prepare) return; + if(game.EnableTutorials) { for(GameTeam team : game.GetTeamList()) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java index 74242f538..798c40179 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/world/WorldData.java @@ -544,6 +544,11 @@ public class WorldData { return CustomLocs; } + + public HashMap> GetAllDataLocs() + { + return DataLocs; + } public Location GetRandomXZ() {