Fixes some bugs regarding bungee teleportation

Fixes the server being teleported normally after it's teleported to another server
Fixes a nullpointerexception
This commit is contained in:
Kristian Knarvik 2021-09-12 01:23:16 +02:00
parent ec4ed1e086
commit 19018e46b8
2 changed files with 25 additions and 15 deletions

View File

@ -217,21 +217,27 @@ public class Stargate extends JavaPlugin {
return player.hasPermission(perm); return player.hasPermission(perm);
} }
/* /**
* Check a deep permission, this will check to see if the permissions is defined for this use * Check a deep permission, this will check to see if the permissions is defined for this use
* If using Permissions it will return the same as hasPerm *
* If using SuperPerms will return true if the node isn't defined * <p>If using Permissions it will return the same as hasPerm. If using SuperPerms will return true if the node
* Or the value of the node if it is * isn't defined, or the value of the node if it is</p>
*
* @param player <p>The player to check</p>
* @param permission <p>The permission to check</p>
* @return <p>True if the player has the permission or it is not set</p>
*/ */
public static boolean hasPermDeep(Player player, String perm) { public static boolean hasPermDeep(Player player, String permission) {
if (!player.isPermissionSet(perm)) { if (!player.isPermissionSet(permission)) {
if (permDebug) if (permDebug) {
Stargate.debug("hasPermDeep::SuperPerm", perm + " => true"); Stargate.debug("hasPermDeep::SuperPerm", permission + " => true");
}
return true; return true;
} }
if (permDebug) if (permDebug) {
Stargate.debug("hasPermDeep::SuperPerms", perm + " => " + player.hasPermission(perm)); Stargate.debug("hasPermDeep::SuperPerms", permission + " => " + player.hasPermission(permission));
return player.hasPermission(perm); }
return player.hasPermission(permission);
} }
/* /*
@ -309,10 +315,13 @@ public class Stargate extends JavaPlugin {
boolean deny = false; boolean deny = false;
// Check if player has access to this server for Bungee gates // Check if player has access to this server for Bungee gates
if (entrancePortal.isBungee() && !Stargate.canAccessServer(player, entrancePortal.getNetwork())) { if (entrancePortal.isBungee() && !Stargate.canAccessServer(player, entrancePortal.getNetwork())) {
Stargate.debug("cannotAccessPortal", "Cannot access server");
deny = true; deny = true;
} else if (!Stargate.canAccessNetwork(player, entrancePortal.getNetwork())) { } else if (!Stargate.canAccessNetwork(player, entrancePortal.getNetwork())) {
Stargate.debug("cannotAccessPortal", "Cannot access network");
deny = true; deny = true;
} else if (!Stargate.canAccessWorld(player, destination.getWorld().getName())) { } else if (!entrancePortal.isBungee() && !Stargate.canAccessWorld(player, destination.getWorld().getName())) {
Stargate.debug("cannotAccessPortal", "Cannot access world");
deny = true; deny = true;
} }
return Stargate.cannotAccessPortal(player, entrancePortal, deny); return Stargate.cannotAccessPortal(player, entrancePortal, deny);

View File

@ -155,10 +155,8 @@ public class PlayerEventListener implements Listener {
if (entrancePortal.isBungee()) { if (entrancePortal.isBungee()) {
if (bungeeTeleport(player, entrancePortal, event)) { if (bungeeTeleport(player, entrancePortal, event)) {
Stargate.sendMessage(player, Stargate.getString("teleportMsg"), false); Stargate.sendMessage(player, Stargate.getString("teleportMsg"), false);
return true;
} else {
return false;
} }
return false;
} }
return true; return true;
} }
@ -328,15 +326,18 @@ public class PlayerEventListener implements Listener {
//Send the SGBungee packet first, it will be queued by BC if required //Send the SGBungee packet first, it will be queued by BC if required
if (!BungeeHelper.sendTeleportationMessage(player, entrancePortal)) { if (!BungeeHelper.sendTeleportationMessage(player, entrancePortal)) {
Stargate.debug("bungeeTeleport", "Unable to send teleportation message");
return false; return false;
} }
// Connect player to new server // Connect player to new server
if (!BungeeHelper.changeServer(player, entrancePortal)) { if (!BungeeHelper.changeServer(player, entrancePortal)) {
Stargate.debug("bungeeTeleport", "Unable to change server");
return false; return false;
} }
// Close portal if required (Should never be) // Close portal if required (Should never be)
Stargate.debug("bungeeTeleport", "Teleported player to another server");
entrancePortal.close(false); entrancePortal.close(false);
return true; return true;
} }