Convert to npc for entering mavericks lobby
This commit is contained in:
parent
d7d8ef021e
commit
5108a6f08d
@ -65,7 +65,7 @@ public class MavericksManager extends MiniPlugin
|
|||||||
super("Mavericks", plugin);
|
super("Mavericks", plugin);
|
||||||
|
|
||||||
_worldManager = new MavericksWorldManager(plugin);
|
_worldManager = new MavericksWorldManager(plugin);
|
||||||
_portalManager = new MavericksPortalManager(plugin, _worldManager, cosmeticManager);
|
_portalManager = new MavericksPortalManager(plugin, hub, _worldManager, cosmeticManager);
|
||||||
_repoApproved = new MavericksApprovedRepository();
|
_repoApproved = new MavericksApprovedRepository();
|
||||||
|
|
||||||
new BasketballManager(plugin, _worldManager, hub);
|
new BasketballManager(plugin, _worldManager, hub);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package mineplex.hub.modules.mavericks;
|
package mineplex.hub.modules.mavericks;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -13,13 +13,16 @@ import mineplex.core.MiniPlugin;
|
|||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.cosmetic.CosmeticManager;
|
import mineplex.core.cosmetic.CosmeticManager;
|
||||||
import mineplex.core.gadget.event.GadgetEnableEvent;
|
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.
|
* A small teleportation manager to manage the portal from the hub to the mavericks world and back.
|
||||||
*/
|
*/
|
||||||
public class MavericksPortalManager extends MiniPlugin
|
public class MavericksPortalManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
private Box _portalHubMavericks;
|
|
||||||
private Box _portalMavericksHub;
|
private Box _portalMavericksHub;
|
||||||
|
|
||||||
private Location _destHub;
|
private Location _destHub;
|
||||||
@ -27,17 +30,16 @@ public class MavericksPortalManager extends MiniPlugin
|
|||||||
|
|
||||||
private CosmeticManager _cosmeticManager;
|
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);
|
super("Mavericks Teleporter", plugin);
|
||||||
|
|
||||||
_cosmeticManager = cosmeticManager;
|
_cosmeticManager = cosmeticManager;
|
||||||
|
|
||||||
_portalHubMavericks = new Box("world", new Vector(20, 71, -1), new Vector(21, 74, 1));
|
|
||||||
_destMavericks = worldManager.getSpawn();
|
_destMavericks = worldManager.getSpawn();
|
||||||
|
|
||||||
_portalMavericksHub = new Box(worldManager.getWorld().getName(), new Vector(3, 20, 316), new Vector(-1, 25, 317));
|
_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
|
@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
|
@EventHandler
|
||||||
public void onEnter(EntityPortalEnterEvent event)
|
public void onEnter(EntityPortalEnterEvent event)
|
||||||
{
|
{
|
||||||
@ -69,12 +95,7 @@ public class MavericksPortalManager extends MiniPlugin
|
|||||||
_cosmeticManager.getMountManager().DisableAll(p);
|
_cosmeticManager.getMountManager().DisableAll(p);
|
||||||
_cosmeticManager.getGadgetManager().disableAll(p);
|
_cosmeticManager.getGadgetManager().disableAll(p);
|
||||||
|
|
||||||
if (box == _portalHubMavericks)
|
if (box == _portalMavericksHub)
|
||||||
{
|
|
||||||
p.teleport(_destMavericks);
|
|
||||||
p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Mavericks") + " area."));
|
|
||||||
}
|
|
||||||
else if (box == _portalMavericksHub)
|
|
||||||
{
|
{
|
||||||
p.teleport(_destHub);
|
p.teleport(_destHub);
|
||||||
p.sendMessage(F.main("Teleporter", "Teleported to " + F.item("Hub") + " area."));
|
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);
|
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)
|
private Box isInside(Player player)
|
||||||
{
|
{
|
||||||
if(_portalHubMavericks.isInside(player.getLocation())) return _portalHubMavericks;
|
if (_portalMavericksHub.isInside(player.getLocation()))
|
||||||
if(_portalMavericksHub.isInside(player.getLocation())) return _portalMavericksHub;
|
{
|
||||||
|
return _portalMavericksHub;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,5 +150,4 @@ public class MavericksPortalManager extends MiniPlugin
|
|||||||
return loc.getWorld().getName().equals(_world) && isInside(loc.toVector());
|
return loc.getWorld().getName().equals(_world) && isInside(loc.toVector());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -22,7 +22,6 @@ import mineplex.core.updater.event.UpdateEvent;
|
|||||||
*/
|
*/
|
||||||
public class MavericksWorldManager extends MiniPlugin
|
public class MavericksWorldManager extends MiniPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
private World _world;
|
private World _world;
|
||||||
private Location _spawn;
|
private Location _spawn;
|
||||||
|
|
||||||
@ -91,10 +90,4 @@ public class MavericksWorldManager extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user