NPE fix ;D!
This commit is contained in:
parent
cd68ccf261
commit
a8a96b7822
@ -7,6 +7,7 @@ import nl.Steffion.BlockHunt.Managers.PlayerM;
|
|||||||
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
import nl.Steffion.BlockHunt.Managers.PlayerM.PermsC;
|
||||||
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
import nl.Steffion.BlockHunt.Serializables.LocationSerializable;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -29,47 +30,50 @@ public class PlayerListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (PlayerM.hasPerm(player, PermsC.create, false)) {
|
if (PlayerM.hasPerm(player, PermsC.create, false)) {
|
||||||
ItemStack item = player.getItemInHand();
|
ItemStack item = player.getItemInHand();
|
||||||
|
if (item.getType() != Material.AIR) {
|
||||||
if (item.getItemMeta().hasDisplayName()) {
|
if (item.getItemMeta().hasDisplayName()) {
|
||||||
ItemMeta im = item.getItemMeta();
|
ItemMeta im = item.getItemMeta();
|
||||||
if (im.getDisplayName().equals(
|
if (im.getDisplayName().equals(
|
||||||
MessageM.replaceAll((String) W.config
|
MessageM.replaceAll((String) W.config
|
||||||
.get(ConfigC.wandName)))) {
|
.get(ConfigC.wandName)))) {
|
||||||
Action action = event.getAction();
|
Action action = event.getAction();
|
||||||
if (event.hasBlock()) {
|
if (event.hasBlock()) {
|
||||||
LocationSerializable location = new LocationSerializable(
|
LocationSerializable location = new LocationSerializable(
|
||||||
event.getClickedBlock().getLocation());
|
event.getClickedBlock().getLocation());
|
||||||
if (action.equals(Action.LEFT_CLICK_BLOCK)) {
|
if (action.equals(Action.LEFT_CLICK_BLOCK)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (W.pos1.get(player) == null
|
if (W.pos1.get(player) == null
|
||||||
|| !W.pos1.get(player).equals(location)) {
|
|| !W.pos1.get(player).equals(location)) {
|
||||||
MessageM.sendFMessage(
|
MessageM.sendFMessage(
|
||||||
player,
|
player,
|
||||||
ConfigC.normal_setPosition,
|
ConfigC.normal_setPosition,
|
||||||
true,
|
true,
|
||||||
"number-1",
|
"number-1",
|
||||||
"pos-%N(%A" + location.getBlockX()
|
"pos-%N(%A" + location.getBlockX()
|
||||||
+ "%N, %A"
|
+ "%N, %A"
|
||||||
+ location.getBlockY()
|
+ location.getBlockY()
|
||||||
+ "%N, %A"
|
+ "%N, %A"
|
||||||
+ location.getBlockZ() + "%N)");
|
+ location.getBlockZ()
|
||||||
W.pos1.put(player, location);
|
+ "%N)");
|
||||||
}
|
W.pos1.put(player, location);
|
||||||
} else if (action.equals(Action.RIGHT_CLICK_BLOCK)) {
|
}
|
||||||
event.setCancelled(true);
|
} else if (action.equals(Action.RIGHT_CLICK_BLOCK)) {
|
||||||
if (W.pos2.get(player) == null
|
event.setCancelled(true);
|
||||||
|| !W.pos2.get(player).equals(location)) {
|
if (W.pos2.get(player) == null
|
||||||
MessageM.sendFMessage(
|
|| !W.pos2.get(player).equals(location)) {
|
||||||
player,
|
MessageM.sendFMessage(
|
||||||
ConfigC.normal_setPosition,
|
player,
|
||||||
true,
|
ConfigC.normal_setPosition,
|
||||||
"number-2",
|
true,
|
||||||
"pos-%N(%A" + location.getBlockX()
|
"number-2",
|
||||||
+ "%N, %A"
|
"pos-%N(%A" + location.getBlockX()
|
||||||
+ location.getBlockY()
|
+ "%N, %A"
|
||||||
+ "%N, %A"
|
+ location.getBlockY()
|
||||||
+ location.getBlockZ() + "%N)");
|
+ "%N, %A"
|
||||||
W.pos2.put(player, location);
|
+ location.getBlockZ()
|
||||||
|
+ "%N)");
|
||||||
|
W.pos2.put(player, location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user