From 47cb98066dfc1dcb93847abae468b056ae2d46cf Mon Sep 17 00:00:00 2001 From: Mini-Chiss Date: Sat, 8 Aug 2015 08:19:07 +0200 Subject: [PATCH] Hub fixes --- .../core/gadget/gadgets/OutfitTeam.java | 60 +++++++++++++++++-- .../core/gadget/types/OutfitGadget.java | 2 +- .../mineplex/hub/modules/SoccerManager.java | 36 +++++------ .../mineplex/hub/modules/WorldManager.java | 15 +++++ 4 files changed, 89 insertions(+), 24 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java index ce734cd57..ee053c618 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/OutfitTeam.java @@ -2,6 +2,7 @@ package mineplex.core.gadget.gadgets; import java.util.HashMap; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; @@ -18,7 +19,10 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetActivateEvent; import mineplex.core.gadget.types.OutfitGadget; +import mineplex.core.gadget.types.OutfitGadget.ArmorSlot; +import mineplex.core.itemstack.ItemStackFactory; public class OutfitTeam extends OutfitGadget { @@ -29,6 +33,43 @@ public class OutfitTeam extends OutfitGadget { super(manager, name, new String[] {ChatColor.RESET + "Team up with other players!", ChatColor.RESET + "Equip by typing;", ChatColor.RESET + C.cGreen + "/team "}, cost, slot, mat, data); } + + @Override + public void Enable(Player player) + { + GadgetActivateEvent gadgetEvent = new GadgetActivateEvent(player, this); + Bukkit.getServer().getPluginManager().callEvent(gadgetEvent); + + if (gadgetEvent.isCancelled()) + { + return; + } + + EnableCustom(player); + Manager.setActive(player, this); + } + + @Override + public void ApplyArmor(Player player) + { + Manager.RemoveMorph(player); + + Manager.RemoveOutfit(player, _slot); + + _active.add(player); + + if (_slot == ArmorSlot.Helmet) player.getInventory().setHelmet( + ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName())); + + else if (_slot == ArmorSlot.Chest) player.getInventory().setChestplate( + ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName())); + + else if (_slot == ArmorSlot.Legs) player.getInventory().setLeggings( + ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName())); + + else if (_slot == ArmorSlot.Boots) player.getInventory().setBoots( + ItemStackFactory.Instance.CreateStack(GetDisplayMaterial().getId(), GetDisplayData(), 1, GetName())); + } @Override public void EnableCustom(Player player) @@ -44,7 +85,7 @@ public class OutfitTeam extends OutfitGadget } @EventHandler(priority=EventPriority.LOWEST) - public void updateColor(PlayerCommandPreprocessEvent event) + public void setColor(PlayerCommandPreprocessEvent event) { Player player = event.getPlayer(); @@ -62,23 +103,30 @@ public class OutfitTeam extends OutfitGadget if (args[1].equals("red")) { _colorSetting.put(player.getName(), Color.RED); - - UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cRed + "Red Team Outfit") + "!")); + + if (GetSlot() == ArmorSlot.Legs) //Only Display Once + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cRed + "Red Team Outfit") + "!")); } else if (args[1].equals("yellow")) { _colorSetting.put(player.getName(), Color.YELLOW); - UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cRed + "Yellow Team Outfit") + "!")); + + if (GetSlot() == ArmorSlot.Legs) //Only Display Once + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cYellow + "Yellow Team Outfit") + "!")); } else if (args[1].equals("green")) { _colorSetting.put(player.getName(), Color.LIME); - UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cGreen + "Green Team Outfit") + "!")); + + if (GetSlot() == ArmorSlot.Legs) //Only Display Once + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cGreen + "Green Team Outfit") + "!")); } else if (args[1].equals("blue")) { _colorSetting.put(player.getName(), Color.AQUA); - UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cRed + "Blue Team Outfit") + "!")); + + if (GetSlot() == ArmorSlot.Legs) //Only Display Once + UtilPlayer.message(player, F.main("Gadget", "You equipped " + F.elem(C.cAqua + "Blue Team Outfit") + "!")); } colorArmor(player); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java index 1ab3daa45..fabae966d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/OutfitGadget.java @@ -18,7 +18,7 @@ public abstract class OutfitGadget extends Gadget Boots } - private ArmorSlot _slot; + protected ArmorSlot _slot; public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java index 8ab5599c1..55fe110cf 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/SoccerManager.java @@ -2,32 +2,22 @@ package mineplex.hub.modules; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; -import java.util.WeakHashMap; -import org.bukkit.Bukkit; import org.bukkit.FireworkEffect.Type; import org.bukkit.Color; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.Sound; -import org.bukkit.entity.Bat; import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.entity.Skeleton; import org.bukkit.entity.Slime; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import mineplex.core.MiniPlugin; +import mineplex.core.MiniPlugin; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -47,7 +37,6 @@ import mineplex.core.gadget.event.GadgetActivateEvent; import mineplex.core.gadget.gadgets.OutfitTeam; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; -import mineplex.core.gadget.types.MusicGadget; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -87,6 +76,7 @@ public class SoccerManager extends MiniPlugin private long _ballDeadTime = -1; private String _lastKicker = ""; + private Color _lastKick = null; //Item Rebound protected Vector _vel; @@ -178,7 +168,18 @@ public class SoccerManager extends MiniPlugin if (_ball == null) return; - UtilParticle.PlayParticle(ParticleType.HAPPY_VILLAGER, _ball.getLocation().add(0, 0.5, 0), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); + if (_lastKick == Color.AQUA) + { + for (int i = 0 ; i < 3 ; i++) + UtilParticle.PlayParticle(ParticleType.RED_DUST, _ball.getLocation().add(0.0, 0.5, 0.0), -1, 1, 1, 1, 0, + ViewDist.NORMAL, UtilServer.getPlayers()); + } + else + { + for (int i = 0 ; i < 3 ; i++) + UtilParticle.PlayParticle(ParticleType.RED_DUST, _ball.getLocation().add(0.0, 0.5, 0.0), 0, 0, 0, 0, 1, + ViewDist.NORMAL, UtilServer.getPlayers()); + } //Kick for (Player player : _active) @@ -204,11 +205,12 @@ public class SoccerManager extends MiniPlugin UtilAction.zeroVelocity(player); - if (getTeamColor(player) == null) + _lastKick = getTeamColor(player); + if (_lastKick == null) _lastKicker = player.getName(); - else if (getTeamColor(player) == Color.RED) + else if (_lastKick == Color.RED) _lastKicker = C.cRed + player.getName(); - else if (getTeamColor(player) == Color.AQUA) + else if (_lastKick == Color.AQUA) _lastKicker = C.cAqua + player.getName(); } } @@ -274,7 +276,7 @@ public class SoccerManager extends MiniPlugin if (UtilEnt.isGrounded(_ball)) _ballVel = _ballVel.multiply(0.98); - //Rebound Y XXX + //Rebound Y if (UtilEnt.isGrounded(_ball)) { if (_ballVel.getY() < -0.1) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java index 1d2513e02..1506c0311 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/WorldManager.java @@ -37,7 +37,10 @@ import org.bukkit.entity.Snowman; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockSpreadEvent; import org.bukkit.event.block.LeavesDecayEvent; @@ -147,6 +150,18 @@ public class WorldManager extends MiniPlugin event.setCancelled(true); } + + @EventHandler + public void BlockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockIgnite(BlockIgniteEvent event) + { + event.setCancelled(true); + } @EventHandler(priority = EventPriority.LOWEST) public void Explosion(EntityExplodeEvent event)