From e3a9f4f2f7e40b5cae2cd7347382fda74f44d4c6 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sat, 30 Jan 2016 14:14:55 +0200 Subject: [PATCH] Chicken attack changes, refactoring, update map crumble variable access. --- .../identified-project-coordinates.json | 2 +- .../arcade/game/games/mineware/Challenge.java | 16 +--- .../arcade/game/games/mineware/MineWare.java | 85 ++++++++++++++----- .../challenges/ChallengeRushPush.java | 4 +- .../games/mineware/effect/ChickenAttack.java | 9 +- 5 files changed, 74 insertions(+), 42 deletions(-) diff --git a/.recommenders/caches/identified-project-coordinates.json b/.recommenders/caches/identified-project-coordinates.json index c1462f66f..148788ee0 100644 --- a/.recommenders/caches/identified-project-coordinates.json +++ b/.recommenders/caches/identified-project-coordinates.json @@ -1 +1 @@ -[[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core"}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"]] \ No newline at end of file +[[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Libraries\\craftbukkit.jar","type":"JAR","hints":{}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_51","type":"JRE","hints":{}},"jre:jre:1.8.0"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core.Common","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core.Common"}},"ABSENT"]] \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java index c4ee604b5..4693f1577 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/Challenge.java @@ -248,7 +248,7 @@ public abstract class Challenge implements Listener { return; } - if(!Host._currentCrumble) + if(!Host.isCrumbling()) { return; } @@ -257,7 +257,7 @@ public abstract class Challenge implements Listener if(_modifiedBlocks.isEmpty()) { - Host._currentCrumble = false; + Host.setCrumbling(false); return; } for(Block currentBlock: _modifiedBlocks) @@ -334,7 +334,7 @@ public abstract class Challenge implements Listener { return; } - if(Host._currentCrumble == false) + if(!Host.isCrumbling()) { Lost.add(player); } @@ -499,16 +499,6 @@ public abstract class Challenge implements Listener { return _center.clone(); } - - /** - * Only set this to true if you put
- * The "Crumble" in the challenge constructor to True! - * @param condition - */ - public void setMapCrumble(boolean condition) - { - Host._currentCrumble = condition; - } public boolean hasWinner() { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java index 3b851aa2c..c44232120 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/MineWare.java @@ -16,12 +16,14 @@ import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Chicken; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; @@ -113,15 +115,19 @@ public class MineWare extends TeamGame implements IThrown // Used for testing. private int _livesAmount = 1; + // Testing related commands. + private String _restrictCommand = "restrict"; + private String _skipCommand = "skip"; + // All players that will participate on challenges. private GameTeam _playersTeam; - + // All players that have lost their lives and are spectating with a baby chicken morph. private GameTeam _chickenTeam; private HashMap _lives = new HashMap(); - public boolean _currentCrumble = false; + private boolean _currentCrumble = false; private boolean _waitingChallenge = true; private boolean _allMessageSent = false; private boolean _sendingMessages = false; @@ -151,20 +157,21 @@ public class MineWare extends TeamGame implements IThrown } ); + DamageSelf = false; DamageTeamSelf = true; DamagePvP = false; DamagePvE = false; DamageEvP = false; DamageFall = false; - InventoryClick = true; - DamageSelf = false; + DeathOut = false; DeathTeleport = false; AutomaticRespawn = false; DeathMessages = false; - GiveClock = false; CreatureAllow = true; + TeleportsDisqualify = false; + GiveClock = false; Manager.GetCreature().SetDisableCustomDrops(true); @@ -187,8 +194,6 @@ public class MineWare extends TeamGame implements IThrown if (event.GetState() == GameState.Recruit) { _playersTeam = GetTeamList().get(0); - _playersTeam.SetColor(ChatColor.YELLOW); - _playersTeam.SetName("Players"); } else if (event.GetState() == GameState.Live) { @@ -198,19 +203,34 @@ public class MineWare extends TeamGame implements IThrown } } + @EventHandler + public void onChickenAttackMemberDamage(EntityDamageEvent event) + { + if (!IsLive()) + return; + + if (event.getEntity() instanceof Chicken) + { + Chicken chicken = (Chicken) event.getEntity(); + + if (_chickenAttack.isGroupMember(chicken)) + { + event.setCancelled(true); + } + } + } + // Debug Only @SuppressWarnings("unchecked") @EventHandler public void onDebugCommand(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); - String restrictCommand = "restrict"; - String skipCommand = "skip"; String message = event.getMessage(); if (player.isOp()) { - if (message.startsWith("/" + restrictCommand)) + if (message.startsWith("/" + _restrictCommand)) { String[] pieces = message.split(" "); @@ -229,11 +249,11 @@ public class MineWare extends TeamGame implements IThrown } catch (ClassNotFoundException e) { - UtilPlayer.message(player, F.main("Debug", "Could not match " + F.elem(rawClass) + " with any challenges.")); + UtilPlayer.message(player, F.main(GetType().GetName(), "Could not match " + F.elem(rawClass) + " with any challenges.")); } catch (ClassCastException e) { - UtilPlayer.message(player, F.main("Debug", F.elem(rawClass) + "is not a challenge!")); + UtilPlayer.message(player, F.main(GetType().GetName(), F.elem(rawClass) + "is not a challenge!")); } } else @@ -245,18 +265,18 @@ public class MineWare extends TeamGame implements IThrown event.setCancelled(true); } - else if (message.startsWith("/" + skipCommand)) + else if (message.startsWith("/" + _skipCommand)) { if (IsLive()) { endCurrentChallenge(); _currentCrumble = false; - + Announce(C.cAqua + C.Bold + player.getName() + " skipped this challenge."); } else { - UtilPlayer.message(player, F.main("Debug", "You cannot skip a challenge if the game is not started.")); + UtilPlayer.message(player, F.main(GetType().GetName(), "You cannot skip a challenge if the game is not started.")); } event.setCancelled(true); @@ -270,7 +290,7 @@ public class MineWare extends TeamGame implements IThrown if (event.getEntity() instanceof ArmorStand) { ArmorStand armorStand = (ArmorStand) event.getEntity(); - + for (DeathEffectData data : _deathEffect.getData()) { if (data.getChickenHead().equals(armorStand)) @@ -339,7 +359,7 @@ public class MineWare extends TeamGame implements IThrown if (GetState() == GameState.Recruit && GetCountdown() >= 0 && GetPlayers(false).size() < 2) { - UtilServer.broadcast(F.main("MineWare", C.cRed + "This game requires at least 2 players to start.")); + UtilServer.broadcast(F.main(GetType().GetName(), C.cRed + "This game requires at least 2 players to start.")); SetCountdown(-1); Manager.GetLobby().DisplayWaiting(); } @@ -369,11 +389,12 @@ public class MineWare extends TeamGame implements IThrown if (living <= 1) { + SetCustomWinLine("You have defeated Bawk Bawk!"); Collections.reverse(_places); if (!_places.contains(GetPlayers(true).get(0))) _places.add(0, GetPlayers(true).get(0)); - + if (_places.size() >= 1) { AddGems(_places.get(0), 40, "First Place", false, false); @@ -396,7 +417,7 @@ public class MineWare extends TeamGame implements IThrown AnnounceEnd(_places); SetState(GameState.End); } - + // if (living <= 1) // { // SetState(GameState.End); @@ -1262,23 +1283,43 @@ public class MineWare extends TeamGame implements IThrown { return _isChallengeStarted; } - + public GameTeam getPlayersTeam() { return _playersTeam; } - + public GameTeam getChickenTeam() { return _chickenTeam; } - + @Override public ArrayList getWinners() { return _places; } + public DeathEffect getDeathEffect() + { + return _deathEffect; + } + + public ChickenAttack getChickenAttack() + { + return _chickenAttack; + } + + public void setCrumbling(boolean crumbling) + { + _currentCrumble = crumbling; + } + + public boolean isCrumbling() + { + return _currentCrumble; + } + @Override public void Idle(ProjectileUser data) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeRushPush.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeRushPush.java index a0dd02f2a..f5cb3e647 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeRushPush.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeRushPush.java @@ -129,7 +129,7 @@ public class ChallengeRushPush extends Challenge onRed++; } } - if((onBlue == 0 || onRed == 0) && Host._currentCrumble == false) + if((onBlue == 0 || onRed == 0) && Host.isCrumbling() == false) { UtilTextMiddle.display(onBlue == 0 ? C.cBlue + "Blue Team won!" : C.cRed + "Red Team won!", "Friendly fire enabled!", 20, 60, 20); } @@ -151,7 +151,7 @@ public class ChallengeRushPush extends Challenge event.SetCancelled("Player out of the game"); return; } - if (!Host._currentCrumble) + if (!Host.isCrumbling()) { if (_teams.containsKey(event.GetDamagerPlayer(false).getName())) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java index 56a47f30f..a7559248d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/ChickenAttack.java @@ -20,7 +20,6 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.disguise.disguises.DisguiseChicken; -import mineplex.core.visibility.VisibilityManager; import nautilus.game.arcade.game.games.mineware.MineWare; public class ChickenAttack @@ -29,8 +28,6 @@ public class ChickenAttack private JavaPlugin _plugin; private Location _center; - private World _world; - private Location _corner1; private Location _corner2; @@ -44,7 +41,6 @@ public class ChickenAttack _plugin = host.getArcadeManager().getPlugin(); _center = center.clone().add(0, 1.0, 0); - _world = center.getWorld(); _corner1 = corner1; _corner2 = corner2; @@ -142,6 +138,11 @@ public class ChickenAttack // TODO: Make chickens attack player. } + + public boolean isGroupMember(Chicken chicken) + { + return _chickens.contains(chicken); + } public void reset() {