Fixed NPE with a SHIT TON OF STATIC
This commit is contained in:
parent
850169533a
commit
e01e9d3f3e
3 changed files with 50 additions and 62 deletions
|
@ -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<Player> playersToBeFlaired = new ArrayList<Player>();
|
||||
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<Player> playersToBeFlaired = new ArrayList<Player>();
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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!");
|
||||
|
|
Loading…
Reference in a new issue