diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MavericksManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MavericksManager.java index 576122670..2ce181245 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MavericksManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/MavericksManager.java @@ -65,7 +65,7 @@ public class MavericksManager extends MiniPlugin super("Mavericks", plugin); _worldManager = new MavericksWorldManager(plugin); - _portalManager = new MavericksPortalManager(plugin, _worldManager, cosmeticManager); + _portalManager = new MavericksPortalManager(plugin, hub, _worldManager, cosmeticManager); _repoApproved = new MavericksApprovedRepository(); new BasketballManager(plugin, _worldManager, hub); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksPortalManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksPortalManager.java index 597be1b4a..c555fa2f8 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksPortalManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksPortalManager.java @@ -1,6 +1,6 @@ package mineplex.hub.modules.mavericks; -import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -13,13 +13,16 @@ import mineplex.core.MiniPlugin; import mineplex.core.common.util.F; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.gadget.event.GadgetEnableEvent; +import mineplex.core.npc.event.NpcDamageByEntityEvent; +import mineplex.core.npc.event.NpcInteractEntityEvent; +import mineplex.core.recharge.Recharge; +import mineplex.hub.HubManager; + /** * A small teleportation manager to manage the portal from the hub to the mavericks world and back. */ public class MavericksPortalManager extends MiniPlugin -{ - - private Box _portalHubMavericks; +{ private Box _portalMavericksHub; private Location _destHub; @@ -27,17 +30,16 @@ public class MavericksPortalManager extends MiniPlugin private CosmeticManager _cosmeticManager; - public MavericksPortalManager(JavaPlugin plugin, MavericksWorldManager worldManager, CosmeticManager cosmeticManager) + public MavericksPortalManager(JavaPlugin plugin, HubManager hubManager, MavericksWorldManager worldManager, CosmeticManager cosmeticManager) { super("Mavericks Teleporter", plugin); _cosmeticManager = cosmeticManager; - _portalHubMavericks = new Box("world", new Vector(20, 71, -1), new Vector(21, 74, 1)); _destMavericks = worldManager.getSpawn(); _portalMavericksHub = new Box(worldManager.getWorld().getName(), new Vector(3, 20, 316), new Vector(-1, 25, 317)); - _destHub = new Location(Bukkit.getWorld("world"), 0.5, 80, 0.5); + _destHub = hubManager.GetSpawn(); } @EventHandler @@ -49,6 +51,30 @@ public class MavericksPortalManager extends MiniPlugin } } + @EventHandler + public void onUseNPC(NpcInteractEntityEvent event) + { + if (ChatColor.stripColor(event.getNpc().getName()).contains("Mavericks Lobby")) + { + useMavsNpc(event.getPlayer()); + } + } + + @EventHandler + public void onUseNPC(NpcDamageByEntityEvent event) + { + if (!(event.getDamager() instanceof Player)) + { + return; + } + Player player = (Player) event.getDamager(); + + if (ChatColor.stripColor(event.getNpc().getName()).contains("Mavericks Lobby") && Recharge.Instance.use(player, "Go to Mavs Lobby", 1000, false, false)) + { + useMavsNpc(player); + } + } + @EventHandler public void onEnter(EntityPortalEnterEvent event) { @@ -69,12 +95,7 @@ public class MavericksPortalManager extends MiniPlugin _cosmeticManager.getMountManager().DisableAll(p); _cosmeticManager.getGadgetManager().disableAll(p); - if (box == _portalHubMavericks) - { - p.teleport(_destMavericks); - p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Mavericks") + " area.")); - } - else if (box == _portalMavericksHub) + if (box == _portalMavericksHub) { p.teleport(_destHub); p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Hub") + " area.")); @@ -83,10 +104,22 @@ public class MavericksPortalManager extends MiniPlugin p.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1); } + private void useMavsNpc(Player player) + { + _cosmeticManager.getPetManager().disableAll(player); + _cosmeticManager.getMountManager().DisableAll(player); + _cosmeticManager.getGadgetManager().disableAll(player); + player.teleport(_destMavericks); + player.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Mavericks") + " area.")); + player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1); + } + private Box isInside(Player player) { - if(_portalHubMavericks.isInside(player.getLocation())) return _portalHubMavericks; - if(_portalMavericksHub.isInside(player.getLocation())) return _portalMavericksHub; + if (_portalMavericksHub.isInside(player.getLocation())) + { + return _portalMavericksHub; + } return null; } @@ -117,5 +150,4 @@ public class MavericksPortalManager extends MiniPlugin return loc.getWorld().getName().equals(_world) && isInside(loc.toVector()); } } - -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksWorldManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksWorldManager.java index 4306f175d..8db353bca 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksWorldManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/modules/mavericks/MavericksWorldManager.java @@ -22,7 +22,6 @@ import mineplex.core.updater.event.UpdateEvent; */ public class MavericksWorldManager extends MiniPlugin { - private World _world; private Location _spawn; @@ -91,10 +90,4 @@ public class MavericksWorldManager extends MiniPlugin } } } - - - - - - -} +} \ No newline at end of file