Trusted/Helpers changes

This commit is contained in:
boy0001 2014-10-06 20:47:43 +11:00
parent bde2e45e6b
commit 7c643ed535
3 changed files with 32 additions and 17 deletions

View File

@ -29,8 +29,8 @@ public class Helpers extends SubCommand {
}
private boolean hasBeenOnServer(String name) {
Player plr;
if ((plr = Bukkit.getPlayer(name)) == null) {
Player plr = Bukkit.getPlayerExact(name);
if (plr == null) {
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
if (oplr == null) {
return false;
@ -74,11 +74,15 @@ public class Helpers extends SubCommand {
return true;
}
UUID uuid = null;
if ((Bukkit.getPlayer(args[1]) != null) && Bukkit.getPlayer(args[1]).isOnline()) {
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
if ((Bukkit.getPlayerExact(args[1]) != null)) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId();
} else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
}
if (uuid == null) {
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
return true;
}
plot.addHelper(uuid);
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
@ -101,11 +105,15 @@ public class Helpers extends SubCommand {
return true;
}
UUID uuid = null;
if (Bukkit.getPlayer(args[1]).isOnline()) {
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
if (Bukkit.getPlayerExact(args[1]) != null) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId();
} else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
}
if (uuid == null) {
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
return true;
}
if (!plot.helpers.contains(uuid)) {
PlayerFunctions.sendMessage(plr, C.WAS_NOT_ADDED);
return true;

View File

@ -29,8 +29,8 @@ public class Trusted extends SubCommand {
}
private boolean hasBeenOnServer(String name) {
Player plr;
if ((plr = Bukkit.getPlayer(name)) == null) {
Player plr = Bukkit.getPlayerExact(name);
if (plr == null) {
OfflinePlayer oplr = Bukkit.getOfflinePlayer(name);
if (oplr == null) {
return false;
@ -74,11 +74,15 @@ public class Trusted extends SubCommand {
return true;
}
UUID uuid = null;
if ((Bukkit.getPlayer(args[1]) != null) && Bukkit.getPlayer(args[1]).isOnline()) {
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
if ((Bukkit.getPlayerExact(args[1]) != null)) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId();
} else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
}
if (uuid == null) {
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
return true;
}
plot.addTrusted(uuid);
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true);
@ -101,11 +105,15 @@ public class Trusted extends SubCommand {
return true;
}
UUID uuid = null;
if (Bukkit.getPlayer(args[1]).isOnline()) {
uuid = Bukkit.getPlayer(args[1]).getUniqueId();
if (Bukkit.getPlayerExact(args[1]) != null) {
uuid = Bukkit.getPlayerExact(args[1]).getUniqueId();
} else {
uuid = Bukkit.getOfflinePlayer(args[1]).getUniqueId();
}
if (uuid == null) {
PlayerFunctions.sendMessage(plr, C.PLAYER_HAS_NOT_BEEN_ON);
return true;
}
if (!plot.trusted.contains(uuid)) {
PlayerFunctions.sendMessage(plr, C.T_WAS_NOT_ADDED);
return true;

View File

@ -456,13 +456,12 @@ public class PlayerEvents implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onStructureGrow(final StructureGrowEvent e) {
List<BlockState> blocks = e.getBlocks();
boolean f = false;
for (int i = 0; i < blocks.size(); i++) {
if (f || isPlotWorld(blocks.get(i).getLocation())) {
f = true;
boolean remove = false;
for (int i = blocks.size() -1; i >= 0; i--) {
if (remove || isPlotWorld(blocks.get(i).getLocation())) {
remove = true;
if (!isInPlot(blocks.get(i).getLocation())) {
e.getBlocks().remove(i);
i--;
}
}
}