mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-02-04 22:41:37 +01:00
Fix bungee portal NPE and dupe code added in 94c02ea
This commit is contained in:
parent
ee4227b919
commit
5bf7b71b65
@ -38,8 +38,6 @@ public class Listeners implements Listener {
|
|||||||
private final AdvancedPortalsPlugin plugin;
|
private final AdvancedPortalsPlugin plugin;
|
||||||
private int PortalMessagesDisplay = 2;
|
private int PortalMessagesDisplay = 2;
|
||||||
|
|
||||||
private boolean teleportDuringMove = false;
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public Listeners(AdvancedPortalsPlugin plugin) {
|
public Listeners(AdvancedPortalsPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@ -79,14 +77,11 @@ public class Listeners implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onMoveEvent(PlayerMoveEvent event) {
|
public void onMoveEvent(PlayerMoveEvent event) {
|
||||||
|
|
||||||
// will check if the player is in the portal or not.
|
// will check if the player is in the portal or not.
|
||||||
if (!Portal.portalsActive) {
|
if (!Portal.portalsActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
teleportDuringMove = false;
|
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
Location fromloc = event.getFrom();
|
Location fromloc = event.getFrom();
|
||||||
@ -121,18 +116,15 @@ public class Listeners implements Listener {
|
|||||||
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ")
|
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(portal.portalName + ".destination").replaceAll("_", " ")
|
||||||
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (warped) {
|
if (warped) {
|
||||||
//event.setFrom(player.getLocation());
|
//event.setFrom(player.getLocation());
|
||||||
//event.setTo(player.getLocation());
|
//event.setTo(player.getLocation());
|
||||||
|
|
||||||
//event.setCancelled(true);
|
//event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
//player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
//plugin.getLogger().info(String.valueOf(teleportDuringMove));
|
event.setCancelled(true);
|
||||||
if(!teleportDuringMove){
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (portal.trigger.equals(Material.PORTAL)) {
|
if (portal.trigger.equals(Material.PORTAL)) {
|
||||||
@ -154,33 +146,6 @@ public class Listeners implements Listener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = false, priority = EventPriority.LOWEST)
|
|
||||||
public void onPlayerTeleport(final PlayerTeleportEvent event){
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
plugin.getLogger().info(String.valueOf(event.getCause()));
|
|
||||||
if(event.getCause() != PlayerTeleportEvent.TeleportCause.NETHER_PORTAL && event.getCause() != PlayerTeleportEvent.TeleportCause.END_PORTAL){
|
|
||||||
teleportDuringMove = true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Location loc = player.getLocation();
|
|
||||||
Object[] portals = Portal.Portals;
|
|
||||||
for (AdvancedPortal portal : Portal.Portals) {
|
|
||||||
if (portal.worldName.equals(player.getWorld().getName())) {
|
|
||||||
|
|
||||||
if ((portal.pos1.getX() + 1D) >= loc.getX() && (portal.pos1.getY() + 1D) >= loc.getY() && (portal.pos1.getZ() + 1D) >= loc.getZ()) {
|
|
||||||
|
|
||||||
if ((portal.pos2.getX()) <= loc.getX() && (portal.pos2.getY()) <= loc.getY() && (portal.pos2.getZ()) <= loc.getZ()) {
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// These are here because java 7 can only take finals straight into a runnable
|
// These are here because java 7 can only take finals straight into a runnable
|
||||||
class RemoveLavaData implements Runnable{
|
class RemoveLavaData implements Runnable{
|
||||||
|
|
||||||
|
@ -419,7 +419,6 @@ public class Portal {
|
|||||||
out.writeUTF(portal.bungee);
|
out.writeUTF(portal.bungee);
|
||||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
// Down to bungee to sort out the teleporting but yea theoretically they should warp.
|
// Down to bungee to sort out the teleporting but yea theoretically they should warp.
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else if (portal.destiation != null) {
|
else if (portal.destiation != null) {
|
||||||
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
|
ConfigAccessor configDesti = new ConfigAccessor(plugin, "destinations.yml");
|
||||||
@ -430,7 +429,6 @@ public class Portal {
|
|||||||
player.sendMessage(plugin.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
|
player.sendMessage(plugin.customPrefix + "\u00A7c The destination you are currently attempting to warp to doesnt exist!");
|
||||||
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
|
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
|
||||||
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
|
+ "attempt and either the data is corrupt or that destination listed doesn't exist!");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (showFailMessage) {
|
if (showFailMessage) {
|
||||||
@ -438,8 +436,8 @@ public class Portal {
|
|||||||
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
|
plugin.getLogger().log(Level.SEVERE, "The portal '" + portal.portalName + "' has just had a warp "
|
||||||
+ "attempt and either the data is corrupt or portal doesn't exist!");
|
+ "attempt and either the data is corrupt or portal doesn't exist!");
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void rename(String oldName, String newName) {
|
public static void rename(String oldName, String newName) {
|
||||||
|
Loading…
Reference in New Issue
Block a user