From e01e9d3f3e5cd315da4437c07e79a6a5677206ba Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 1 Dec 2016 16:46:42 -0500 Subject: [PATCH] Fixed NPE with a SHIT TON OF STATIC --- .../flairdoor/FlairDoorComponent.java | 51 +++++++++---------- .../PlayerProximityLoop.java | 50 +++++++++--------- .../SetProximityLocation.java | 11 +--- 3 files changed, 50 insertions(+), 62 deletions(-) diff --git a/src/alisolarflare/components/flairdoor/FlairDoorComponent.java b/src/alisolarflare/components/flairdoor/FlairDoorComponent.java index b7886f6..e43389d 100644 --- a/src/alisolarflare/components/flairdoor/FlairDoorComponent.java +++ b/src/alisolarflare/components/flairdoor/FlairDoorComponent.java @@ -1,27 +1,24 @@ -package alisolarflare.components.flairdoor; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import alisolarflare.architecture.Component; -import alisolarflare.components.flairdoor.flairme.FlairMe; -import alisolarflare.components.flairdoor.listeners.PortalListener; -import alisolarflare.components.flairdoor.proximitydetector.PlayerProximityLoop; -import alisolarflare.components.flairdoor.proximitydetector.SetProximityLocation; - -public class FlairDoorComponent extends Component { - public List playersToBeFlaired = new ArrayList(); - public Location startLocation = null; - public Location endLocation = null; - @Override - public void register(JavaPlugin plugin) { - registerCommand(plugin, new FlairMe(this)); - registerCommand(plugin, new SetProximityLocation(this)); - registerListener(plugin, new PortalListener(plugin, this)); - registerListener(plugin, new PlayerProximityLoop(plugin, this)); - } -} +package alisolarflare.components.flairdoor; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.architecture.Component; +import alisolarflare.components.flairdoor.flairme.FlairMe; +import alisolarflare.components.flairdoor.listeners.PortalListener; +import alisolarflare.components.flairdoor.proximitydetector.PlayerProximityLoop; +import alisolarflare.components.flairdoor.proximitydetector.SetProximityLocation; + +public class FlairDoorComponent extends Component { + public List playersToBeFlaired = new ArrayList(); + @Override + public void register(JavaPlugin plugin) { + registerCommand(plugin, new FlairMe(this)); + registerCommand(plugin, new SetProximityLocation()); + registerListener(plugin, new PortalListener(plugin, this)); + registerListener(plugin, new PlayerProximityLoop(plugin, this)); + } +} diff --git a/src/alisolarflare/components/flairdoor/proximitydetector/PlayerProximityLoop.java b/src/alisolarflare/components/flairdoor/proximitydetector/PlayerProximityLoop.java index a1727a6..e65eff7 100644 --- a/src/alisolarflare/components/flairdoor/proximitydetector/PlayerProximityLoop.java +++ b/src/alisolarflare/components/flairdoor/proximitydetector/PlayerProximityLoop.java @@ -9,38 +9,36 @@ import org.bukkit.scheduler.BukkitRunnable; import alisolarflare.components.flairdoor.FlairDoorComponent; public class PlayerProximityLoop extends BukkitRunnable implements Listener{ - private JavaPlugin plugin; - private FlairDoorComponent component; - private Location startLocation; - private Location endLocation; + private static JavaPlugin plugin; + private static FlairDoorComponent component; + private static Location startLocation; + private static Location endLocation; - private int sX; - private int sY; - private int sZ; - private int eX; - private int eY; - private int eZ; + private static int sX; + private static int sY; + private static int sZ; + private static int eX; + private static int eY; + private static int eZ; public PlayerProximityLoop(JavaPlugin plugin, FlairDoorComponent component) { - this.plugin = plugin; - this.component = component; - setStartLocation(component.startLocation); - setEndLocation(component.endLocation); + PlayerProximityLoop.plugin = plugin; + PlayerProximityLoop.component = component; this.runTaskTimer(plugin, 0, 20); } - public void setStartLocation(Location location){ - this.sX = startLocation.getBlockX(); - this.sY = startLocation.getBlockY(); - this.sZ = startLocation.getBlockZ(); - this.startLocation = location; - this.endLocation.setWorld(location.getWorld()); + public static void setStartLocation(Location location){ + PlayerProximityLoop.sX = location.getBlockX(); + PlayerProximityLoop.sY = location.getBlockY(); + PlayerProximityLoop.sZ = location.getBlockZ(); + PlayerProximityLoop.startLocation = location; + PlayerProximityLoop.endLocation.setWorld(location.getWorld()); } - public void setEndLocation(Location location){ - this.eX = startLocation.getBlockX(); - this.eY = startLocation.getBlockY(); - this.eZ = startLocation.getBlockZ(); - this.endLocation = location; - this.startLocation.setWorld(location.getWorld()); + public static void setEndLocation(Location location){ + PlayerProximityLoop.eX = location.getBlockX(); + PlayerProximityLoop.eY = location.getBlockY(); + PlayerProximityLoop.eZ = location.getBlockZ(); + PlayerProximityLoop.startLocation.setWorld(location.getWorld()); + PlayerProximityLoop.endLocation = location; } @Override diff --git a/src/alisolarflare/components/flairdoor/proximitydetector/SetProximityLocation.java b/src/alisolarflare/components/flairdoor/proximitydetector/SetProximityLocation.java index f19ce48..372d158 100644 --- a/src/alisolarflare/components/flairdoor/proximitydetector/SetProximityLocation.java +++ b/src/alisolarflare/components/flairdoor/proximitydetector/SetProximityLocation.java @@ -3,16 +3,9 @@ package alisolarflare.components.flairdoor.proximitydetector; import org.bukkit.entity.Player; import alisolarflare.architecture.commands.ModCommand; -import alisolarflare.components.flairdoor.FlairDoorComponent; public class SetProximityLocation extends ModCommand{ - private FlairDoorComponent component; - - public SetProximityLocation(FlairDoorComponent flairDoorComponent) { - this.component = flairDoorComponent; - } - @Override public boolean OnCommand(Player player, String alias, String[] args) { if (args.length < 1){ @@ -24,11 +17,11 @@ public class SetProximityLocation extends ModCommand{ switch(firstChar){ case "s": case "0": - component.startLocation = player.getLocation(); + PlayerProximityLoop.setStartLocation(player.getLocation()); return true; case "e": case "1": - component.endLocation = player.getLocation(); + PlayerProximityLoop.setEndLocation(player.getLocation()); return true; default: player.sendMessage("You must provide a vaild argument!");