From b3e2d671522d1f4440f269302d14e0a98ee6df19 Mon Sep 17 00:00:00 2001 From: Thanos paravantis Date: Sat, 2 Jan 2016 15:27:44 +0200 Subject: [PATCH] Change death effect skull and item spawn height, add /restrict command. --- .../identified-project-coordinates.json | 2 +- .../arcade/game/games/mineware/MineWare.java | 67 +++++++++++++++++-- .../challenges/ChallengeMinecartDance.java | 2 +- .../games/mineware/effect/DeathEffect.java | 5 +- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/.recommenders/caches/identified-project-coordinates.json b/.recommenders/caches/identified-project-coordinates.json index ccebebf7f..c2c806782 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\\Libraries\\craftbukkit.jar","type":"JAR","hints":{}},"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 +[[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Mineplex.Core.Common","type":"PROJECT","hints":{"PROJECT_NAME":"Mineplex.Core.Common"}},"ABSENT"],[{"location":"C:\\@Thanos\\Documents\\Minecraft\\Mineplex\\projects\\Mineplex\\Plugins\\Nautilus.Game.Arcade","type":"PROJECT","hints":{"PROJECT_NAME":"Nautilus.Game.Arcade"}},"ABSENT"],[{"location":"C:\\Program Files\\Java\\jre1.8.0_51","type":"JRE","hints":{}},"jre:jre:1.8.0"]] \ No newline at end of file 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 24d2daae7..c3d81e484 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 @@ -31,15 +31,19 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitRunnable; +import com.google.common.base.Joiner; + import mineplex.core.account.CoreClient; import mineplex.core.blood.BloodEvent; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlockText; import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextTop; import mineplex.core.common.util.UtilTime; @@ -162,6 +166,57 @@ public class MineWare extends SoloGame implements IThrown ); } + // Debug Only + @SuppressWarnings("unchecked") + @EventHandler + public void restrictChallengeCommand(PlayerCommandPreprocessEvent event) + { + Player player = event.getPlayer(); + String command = "restrict"; + String message = event.getMessage(); + + if (player.isOp()) + { + if (message.startsWith("/" + command)) + { + String[] pieces = message.split(" "); + + if (pieces.length > 1) + { + String rawClass = pieces[1].replace("Challenge", ""); + + try + { + Class result = (Class) Class.forName("nautilus.game.arcade.game.games.mineware.challenges.Challenge" + rawClass); + + String name = rawClass.replaceAll("(?!^)([A-Z])", " $1"); + + Announce(C.cAqua + C.Bold + GetType().GetName() + " restricted to " + name + " challenge."); + + _challenges.clear(); + _challenges.add(result); + } + catch (ClassNotFoundException e) + { + UtilPlayer.message(player, F.main("Debug", "Could not match " + F.elem(rawClass) + " with any challenges.")); + } + catch (ClassCastException e) + { + UtilPlayer.message(player, F.main("Debug", "Could not match " + F.elem(rawClass) + " with any challenges.")); + } + } + else + { + Announce(C.cAqua + C.Bold + GetType().GetName() + " challenge restrictions were cleared."); + _challenges.clear(); + PopulateOrders(); + } + + event.setCancelled(true); + } + } + } + public void PopulateOrders() { _challenges.add(ChallengeAnvilDance.class); @@ -494,9 +549,11 @@ public class MineWare extends SoloGame implements IThrown return; Player player = event.getEntity(); + Location death = player.getLocation().clone(); _challenge.getLost().add(player); LoseLife(event.getEntity(), true); + _deathEffect.playDeath(player, death); } @EventHandler @@ -885,11 +942,9 @@ public class MineWare extends SoloGame implements IThrown public void LoseLife(Player player, boolean isDeath) { - Location death = player.getLocation().clone(); - if (!isDeath) { - Manager.addSpectator(player, false); + Manager.addSpectator(player, true); } if (_challenge == null || _challenge.IsCompleted(player)) @@ -897,7 +952,7 @@ public class MineWare extends SoloGame implements IThrown int lives = GetLives(player); int playersAlive = 0; - + for(Player players: _lives.keySet()) { if(_lives.get(players) > 0) @@ -926,11 +981,9 @@ public class MineWare extends SoloGame implements IThrown if (isDeath) { - Manager.addSpectator(player, false); + Manager.addSpectator(player, true); } } - - _deathEffect.playDeath(player, death); } public void endCurrentChallenge() // TODO diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMinecartDance.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMinecartDance.java index 04c19f318..4e8a0a694 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMinecartDance.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/challenges/ChallengeMinecartDance.java @@ -368,7 +368,7 @@ public class ChallengeMinecartDance extends Challenge } } - }.runTaskLater(Host.Manager.getPlugin(), ticks); + }.runTaskLater(Host.Manager.getPlugin(), ticks * 20); } public void spawnFireworkAtCorners(Color color) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/DeathEffect.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/DeathEffect.java index fcf149207..f5a37dcd1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/DeathEffect.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/mineware/effect/DeathEffect.java @@ -110,8 +110,7 @@ public class DeathEffect @SuppressWarnings("deprecation") private void spawnChickenHead(DeathEffectData data) { - Location loc = data.getLocation(); - Location dropsite = loc.clone().subtract(0, 0.7, 0); + Location dropsite = data.getLocation(); ArmorStand chickenHead = _host.WorldData.World.spawn(dropsite, ArmorStand.class); chickenHead.setVisible(false); @@ -128,7 +127,7 @@ public class DeathEffect data.setChickenHead(chickenHead); playHeadRotation(data); - Hologram hologram = getRandomHologram(loc); + Hologram hologram = getRandomHologram(dropsite); hologram.start(); data.setHologram(hologram); }