Removes the last of the unprotected variables from Stargate

Makes all classes use getInstance() to get a Stargate instance
Removes the server variable as it's not needed
This commit is contained in:
2021-10-29 18:35:20 +02:00
parent 0237f45046
commit 56ed0495b0
14 changed files with 47 additions and 35 deletions

@ -78,7 +78,7 @@ public final class BungeeHelper {
//Write the actual message
dataOutputStream.writeBytes(message);
//Send the plugin message
player.sendPluginMessage(Stargate.stargate, bungeeChannel, byteArrayOutputStream.toByteArray());
player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
} catch (IOException ex) {
Stargate.logSevere("Error sending BungeeCord teleport packet");
ex.printStackTrace();
@ -104,7 +104,7 @@ public final class BungeeHelper {
dataOutputStream.writeUTF(entrancePortal.getNetwork());
//Send the plugin message
player.sendPluginMessage(Stargate.stargate, bungeeChannel, byteArrayOutputStream.toByteArray());
player.sendPluginMessage(Stargate.getInstance(), bungeeChannel, byteArrayOutputStream.toByteArray());
} catch (IOException ex) {
Stargate.logSevere("Error sending BungeeCord connect packet");
ex.printStackTrace();
@ -155,7 +155,7 @@ public final class BungeeHelper {
String destination = messageParts[1];
//Check if the player is online, if so, teleport, otherwise, queue
Player player = Stargate.server.getPlayer(playerUUID);
Player player = Stargate.getInstance().getServer().getPlayer(playerUUID);
if (player == null) {
bungeeQueue.put(playerUUID, destination);
} else {

@ -53,9 +53,9 @@ public final class EconomyHelper {
PortalOwner owner = entrancePortal.getOwner();
Player portalOwner;
if (owner.getUUID() != null) {
portalOwner = Stargate.server.getPlayer(owner.getUUID());
portalOwner = Stargate.getInstance().getServer().getPlayer(owner.getUUID());
} else {
portalOwner = Stargate.server.getPlayer(owner.getName());
portalOwner = Stargate.getInstance().getServer().getPlayer(owner.getName());
}
//Notify the gate owner of received payment

@ -81,7 +81,7 @@ public final class PermissionHelper {
*/
public static boolean portalAccessDenied(Player player, Portal portal, boolean deny) {
StargateAccessEvent event = new StargateAccessEvent(player, portal, deny);
Stargate.server.getPluginManager().callEvent(event);
Stargate.getInstance().getServer().getPluginManager().callEvent(event);
return event.getDeny();
}