Merge remote-tracking branch 'origin/master'

Conflicts:
	PlotSquared/src/com/intellectualcrafters/plot/listeners/PlayerEvents.java
This commit is contained in:
Sauilitired 2014-10-21 18:59:24 +02:00
commit a80c044b3e
13 changed files with 257 additions and 171 deletions

View File

@ -110,7 +110,7 @@ public enum C {
* Permission * Permission
*/ */
NO_SCHEMATIC_PERMISSION("&cYou don't have the permission required to use schematic &6%s"), NO_SCHEMATIC_PERMISSION("&cYou don't have the permission required to use schematic &6%s"),
NO_PERMISSION("&cYou don't have the permissions required to use this command."), NO_PERMISSION("&cYou are lacking the permission node: &6%s"),
NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"), NO_PLOT_PERMS("&cYou don't have the permissions to do that in this plot"),
CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."), CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."),
YOU_BE_DENIED("&cYou are not allowed to enter this plot"), YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
@ -216,7 +216,7 @@ public enum C {
/* /*
* Claiming * Claiming
*/ */
PLOT_NOT_CLAIMED("&cCannot claim plot"), PLOT_NOT_CLAIMED("&cPlot not claimed"),
PLOT_IS_CLAIMED("&cThis plot is already claimed"), PLOT_IS_CLAIMED("&cThis plot is already claimed"),
CLAIMED("&6You successfully claimed the plot"), CLAIMED("&6You successfully claimed the plot"),
/* /*
@ -270,6 +270,8 @@ public enum C {
/* /*
* Trusted * Trusted
*/ */
ALREADY_OWNER("&cThat user is already the plot owner."),
ALREADY_ADDED("&cThat user is already added to that category."),
TRUSTED_ADDED("&6You successfully added a trusted user to the plot"), TRUSTED_ADDED("&6You successfully added a trusted user to the plot"),
TRUSTED_REMOVED("&6You successfully removed a trusted user from the plot"), TRUSTED_REMOVED("&6You successfully removed a trusted user from the plot"),
TRUSTED_NEED_ARGUMENT("&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"), TRUSTED_NEED_ARGUMENT("&cArguments are missing. &6/plot trusted add {name} &cor &6/plot trusted remove {name}"),

View File

@ -6,7 +6,6 @@ public abstract class PlotGenerator extends ChunkGenerator {
public PlotGenerator(String world) { public PlotGenerator(String world) {
PlotMain.loadWorld(world, this); PlotMain.loadWorld(world, this);
System.out.print("LOADED");
} }
public abstract PlotWorld getNewPlotWorld(String world); public abstract PlotWorld getNewPlotWorld(String world);

View File

@ -0,0 +1,34 @@
package com.intellectualcrafters.plot;
public class StringWrapper {
public String value;
public StringWrapper(String value) {
this.value = value;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
StringWrapper other = (StringWrapper) obj;
return other.value.toLowerCase().equals(this.value.toLowerCase());
}
@Override
public String toString() {
return this.value;
}
@Override
public int hashCode() {
return this.value.toLowerCase().hashCode();
}
}

View File

@ -6,11 +6,13 @@ import com.google.common.collect.HashBiMap;
import com.intellectualcrafters.plot.uuid.NameFetcher; import com.intellectualcrafters.plot.uuid.NameFetcher;
import com.intellectualcrafters.plot.uuid.UUIDFetcher; import com.intellectualcrafters.plot.uuid.UUIDFetcher;
import com.intellectualcrafters.plot.uuid.UUIDSaver; import com.intellectualcrafters.plot.uuid.UUIDSaver;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID; import java.util.UUID;
/** /**
@ -35,9 +37,9 @@ public class UUIDHandler {
private static boolean online = Bukkit.getServer().getOnlineMode(); private static boolean online = Bukkit.getServer().getOnlineMode();
private static BiMap<String, UUID> uuidMap = HashBiMap.create(); private static BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
public static BiMap<String, UUID> getUuidMap() { public static BiMap<StringWrapper, UUID> getUuidMap() {
return uuidMap; return uuidMap;
} }
@ -45,42 +47,45 @@ public class UUIDHandler {
return uuidMap.containsValue(uuid); return uuidMap.containsValue(uuid);
} }
public static boolean nameExists(String name) { public static boolean nameExists(StringWrapper name) {
return uuidMap.containsKey(name); return uuidMap.containsKey(name);
} }
public static void add(String name, UUID uuid) { public static void add(StringWrapper name, UUID uuid) {
uuidMap.put(name, uuid); uuidMap.put(name, uuid);
} }
/** /**
* @param name * @param name
* @return uuid * @return uuid
*/ */
public static UUID getUUID(String name) { public static UUID getUUID(String name) {
if (nameExists(name)) { StringWrapper nameWrap = new StringWrapper(name);
return uuidMap.get(name); if (uuidMap.containsKey(nameWrap)) {
return uuidMap.get(nameWrap);
}
Player player = Bukkit.getPlayer(name);
if (player!=null) {
UUID uuid = player.getUniqueId();
uuidMap.put(nameWrap, uuid);
return uuid;
} }
UUID uuid; UUID uuid;
if ((uuid = getUuidOnlinePlayer(name)) != null) {
return uuid;
}
if ((uuid = getUuidOfflinePlayer(name)) != null) {
return uuid;
}
if (online) { if (online) {
if ((uuid = getUuidOnlinePlayer(nameWrap)) != null) {
return uuid;
}
try { try {
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name)); UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name); uuid = fetcher.call().get(name);
add(name, uuid); add(nameWrap, uuid);
} }
catch (Exception e) { catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
else { else {
return getUuidOfflineMode(name); return getUuidOfflineMode(nameWrap);
} }
return null; return null;
} }
@ -89,7 +94,7 @@ public class UUIDHandler {
* @param uuid * @param uuid
* @return name (cache) * @return name (cache)
*/ */
private static String loopSearch(UUID uuid) { private static StringWrapper loopSearch(UUID uuid) {
return uuidMap.inverse().get(uuid); return uuidMap.inverse().get(uuid);
} }
@ -99,7 +104,7 @@ public class UUIDHandler {
*/ */
public static String getName(UUID uuid) { public static String getName(UUID uuid) {
if (uuidExists(uuid)) { if (uuidExists(uuid)) {
return loopSearch(uuid); return loopSearch(uuid).value;
} }
String name; String name;
if ((name = getNameOnlinePlayer(uuid)) != null) { if ((name = getNameOnlinePlayer(uuid)) != null) {
@ -112,7 +117,7 @@ public class UUIDHandler {
try { try {
NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid)); NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
name = fetcher.call().get(uuid); name = fetcher.call().get(uuid);
add(name, uuid); add(new StringWrapper(name), uuid);
return name; return name;
} }
catch (Exception e) { catch (Exception e) {
@ -129,7 +134,7 @@ public class UUIDHandler {
* @param name * @param name
* @return UUID (name hash) * @return UUID (name hash)
*/ */
private static UUID getUuidOfflineMode(String name) { private static UUID getUuidOfflineMode(StringWrapper name) {
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
add(name, uuid); add(name, uuid);
return uuid; return uuid;
@ -145,7 +150,7 @@ public class UUIDHandler {
return null; return null;
} }
String name = player.getName(); String name = player.getName();
add(name, uuid); add(new StringWrapper(name), uuid);
return name; return name;
} }
@ -159,7 +164,7 @@ public class UUIDHandler {
return null; return null;
} }
String name = player.getName(); String name = player.getName();
add(name, uuid); add(new StringWrapper(name), uuid);
return name; return name;
} }
@ -167,9 +172,9 @@ public class UUIDHandler {
* @param name * @param name
* @return UUID * @return UUID
*/ */
private static UUID getUuidOnlinePlayer(String name) { private static UUID getUuidOnlinePlayer(StringWrapper name) {
Player player = Bukkit.getPlayer(name); Player player = Bukkit.getPlayer(name.value);
if (player == null || !player.isOnline()) { if (player == null) {
return null; return null;
} }
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
@ -181,8 +186,8 @@ public class UUIDHandler {
* @param name * @param name
* @return UUID (username hash) * @return UUID (username hash)
*/ */
private static UUID getUuidOfflinePlayer(String name) { private static UUID getUuidOfflinePlayer(StringWrapper name) {
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)); UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.value).getBytes(Charsets.UTF_8));
add(name, uuid); add(name, uuid);
return uuid; return uuid;
} }

View File

@ -23,7 +23,7 @@ public class CommandPermission {
/** /**
* *
*/ */
private String permission; public String permission;
/** /**
* @param permission * @param permission

View File

@ -42,45 +42,49 @@ public class Denied extends SubCommand {
} }
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if ((plot.owner == null) || !plot.hasRights(plr)) { if ((plot.owner == null) || !plot.hasRights(plr)) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true; return true;
} }
if (args[0].equalsIgnoreCase("add")) { if (args[0].equalsIgnoreCase("add")) {
UUID uuid;
if (args[1].equalsIgnoreCase("*")) { if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone; uuid = DBFunc.everyone;
}
else {
uuid = UUIDHandler.getUUID(args[1]);
}
if (!plot.denied.contains(uuid)) { if (!plot.denied.contains(uuid)) {
if (plot.owner == uuid) {
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
return false;
}
if (plot.trusted.contains(uuid)) {
plot.trusted.remove(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
}
if (plot.helpers.contains(uuid)) {
plot.helpers.remove(uuid);
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
}
plot.addDenied(uuid); plot.addDenied(uuid);
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true); PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
} }
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED); else {
return true; PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false;
} }
/* if (!uuid.equals(DBFunc.everyone) && (Bukkit.getPlayer(uuid) != null) && Bukkit.getPlayer(uuid).isOnline()) {
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
* ((Bukkit.getPlayer(args[1]) != null)) { uuid =
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
* null) { PlayerFunctions.sendMessage(plr,
* C.PLAYER_HAS_NOT_BEEN_ON); return true; }
*/
UUID uuid = UUIDHandler.getUUID(args[1]);
if (!plot.denied.contains(uuid)) {
plot.addDenied(uuid);
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
}
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
if ((Bukkit.getPlayer(uuid) != null) && Bukkit.getPlayer(uuid).isOnline()) {
Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid))); Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid)));
if (pl.id == plot.id) { if (pl.id == plot.id) {
PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED); PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED);
Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation()); Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation());
} }
} }
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
return true;
} }
else else
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {

View File

@ -39,39 +39,42 @@ public class Helpers extends SubCommand {
} }
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if ((plot.owner == null) || !plot.hasRights(plr)) { if ((plot.owner == null) || !plot.hasRights(plr)) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true; return true;
} }
if (args[0].equalsIgnoreCase("add")) { if (args[0].equalsIgnoreCase("add")) {
UUID uuid;
if (args[1].equalsIgnoreCase("*")) { if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone; uuid = DBFunc.everyone;
}
else {
uuid = UUIDHandler.getUUID(args[1]);
}
if (!plot.helpers.contains(uuid)) { if (!plot.helpers.contains(uuid)) {
if (plot.owner == uuid) {
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
return false;
}
if (plot.trusted.contains(uuid)) {
plot.trusted.remove(uuid);
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
}
if (plot.denied.contains(uuid)) {
plot.denied.remove(uuid);
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
}
plot.addHelper(uuid); plot.addHelper(uuid);
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true); PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
} }
else {
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false;
}
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED); PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
return true; return true;
} }
/*
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
* ((Bukkit.getPlayer(args[1]) != null)) { uuid =
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
* null) { PlayerFunctions.sendMessage(plr,
* C.PLAYER_HAS_NOT_BEEN_ON); return true; }
*/
UUID uuid = UUIDHandler.getUUID(args[1]);
if (!plot.helpers.contains(uuid)) {
plot.addHelper(uuid);
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
}
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
}
else else
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {
if (args[1].equalsIgnoreCase("*")) { if (args[1].equalsIgnoreCase("*")) {

View File

@ -38,8 +38,8 @@ public class MainCommand implements CommandExecutor {
} }
}; };
public static boolean no_permission(Player player) { public static boolean no_permission(Player player, String permission) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION); PlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission);
return false; return false;
} }
@ -53,7 +53,7 @@ public class MainCommand implements CommandExecutor {
player = null; player = null;
} }
if (!PlotMain.hasPermission(player, "plots.use")) { if (!PlotMain.hasPermission(player, "plots.use")) {
return no_permission(player); return no_permission(player, "plots.use");
} }
if ((args.length < 1) if ((args.length < 1)
|| ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) { || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
@ -109,7 +109,7 @@ public class MainCommand implements CommandExecutor {
} }
} }
else { else {
return no_permission(player); return no_permission(player, command.permission.permission.toLowerCase());
} }
} }
} }

View File

@ -12,6 +12,8 @@ import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.events.PlotFlagAddEvent; import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent; import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
import com.intellectualcrafters.plot.listeners.PlayerEvents;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -46,7 +48,7 @@ public class Set extends SubCommand {
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if(!plot.hasOwner()) { if(!plot.hasOwner()) {
sendMessage(plr, C.PLOT_NOT_CLAIMED); sendMessage(plr, C.PLOT_NOT_CLAIMED);
return true; return false;
} }
if (!plot.hasRights(plr) && !plr.hasPermission("plots.admin")) { if (!plot.hasRights(plr) && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
@ -69,7 +71,7 @@ public class Set extends SubCommand {
boolean advanced_permissions = true; boolean advanced_permissions = true;
if (advanced_permissions) { if (advanced_permissions) {
if (!plr.hasPermission("plots.set." + args[0].toLowerCase())) { if (!plr.hasPermission("plots.set." + args[0].toLowerCase())) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set."+args[0].toLowerCase());
return false; return false;
} }
} }
@ -102,7 +104,7 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
return false; return false;
} }
if (!plr.hasPermission("plots.set.flag." + args[1].toLowerCase())) { if (!PlotMain.hasPermission(plr, "plots.set.flag." + args[1].toLowerCase())) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
return false; return false;
} }
@ -133,6 +135,7 @@ public class Set extends SubCommand {
plot.settings.setFlags(newflags.toArray(new Flag[0])); plot.settings.setFlags(newflags.toArray(new Flag[0]));
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0])); DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED); PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
PlayerEvents.plotEntry(plr, plot);
return true; return true;
} }
try { try {
@ -160,6 +163,7 @@ public class Set extends SubCommand {
plot.settings.addFlag(flag); plot.settings.addFlag(flag);
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0])); DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED); PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
PlayerEvents.plotEntry(plr, plot);
return true; return true;
} }
catch (Exception e) { catch (Exception e) {

View File

@ -39,39 +39,43 @@ public class Trusted extends SubCommand {
} }
Plot plot = PlayerFunctions.getCurrentPlot(plr); Plot plot = PlayerFunctions.getCurrentPlot(plr);
if ((plot.owner == null) || !plot.hasRights(plr)) { if ((plot.owner == null) || !plot.hasRights(plr)) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION); PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true; return true;
} }
if (args[0].equalsIgnoreCase("add")) { if (args[0].equalsIgnoreCase("add")) {
UUID uuid;
if (args[1].equalsIgnoreCase("*")) { if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone; uuid = DBFunc.everyone;
}
else {
uuid = UUIDHandler.getUUID(args[1]);
}
if (!plot.trusted.contains(uuid)) { if (!plot.trusted.contains(uuid)) {
if (plot.owner == uuid) {
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
return false;
}
if (plot.helpers.contains(uuid)) {
plot.helpers.remove(uuid);
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
}
if (plot.denied.contains(uuid)) {
plot.denied.remove(uuid);
DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
}
plot.addTrusted(uuid); plot.addTrusted(uuid);
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true); PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
} }
else {
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false;
}
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED);
return true; return true;
} }
/*
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr,
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if
* ((Bukkit.getPlayer(args[1]) != null)) { uuid =
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid =
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid ==
* null) { PlayerFunctions.sendMessage(plr,
* C.PLAYER_HAS_NOT_BEEN_ON); return true; }
*/
UUID uuid = UUIDHandler.getUUID(args[1]);
if (!plot.trusted.contains(uuid)) {
plot.addTrusted(uuid);
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
}
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED);
}
else else
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {
if (args[1].equalsIgnoreCase("*")) { if (args[1].equalsIgnoreCase("*")) {

View File

@ -44,12 +44,12 @@ import java.util.Set;
public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener { public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotListener implements Listener {
@EventHandler @EventHandler
public void onWorldLoad(WorldLoadEvent event) { public static void onWorldLoad(WorldLoadEvent event) {
PlotMain.loadWorld(event.getWorld()); PlotMain.loadWorld(event.getWorld());
} }
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent event) { public static void onJoin(PlayerJoinEvent event) {
if (!event.getPlayer().hasPlayedBefore()) { if (!event.getPlayer().hasPlayedBefore()) {
event.getPlayer().saveData(); event.getPlayer().saveData();
} }
@ -61,7 +61,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler @EventHandler
public void onChangeWorld(PlayerChangedWorldEvent event) { public void onChangeWorld(PlayerChangedWorldEvent event) {
/*if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) { if (isPlotWorld(event.getFrom()) && (Settings.PLOT_SPECIFIC_RESOURCE_PACK.length() > 1)) {
event.getPlayer().setResourcePack(""); event.getPlayer().setResourcePack("");
} }
else { else {
@ -71,7 +71,35 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGHEST, ignoreCancelled = true) priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PlayerMove(PlayerMoveEvent event) { public static void PlayerMove(PlayerMoveEvent event) {
try {
Player player = event.getPlayer();
Location from = event.getFrom();
Location to = event.getTo();
if ((from.getBlockX() != to.getBlockX()) || (from.getBlockZ() != to.getBlockZ())) {
if (!isPlotWorld(player.getWorld())) {
return;
}
if (enteredPlot(from, to)) {
Plot plot = getCurrentPlot(event.getTo());
boolean admin = player.hasPermission("plots.admin");
if (plot.deny_entry(player) && !admin) {
event.setCancelled(true);
return;
}
plotEntry(player, plot);
}
else
if (leftPlot(event.getFrom(), event.getTo())) {
Plot plot = getCurrentPlot(event.getFrom());
plotExit(player, plot);
}
}
}
catch (Exception e) {
// Gotta catch 'em all.
}
public static void PlayerMove(PlayerMoveEvent event) {
try { try {
Player player = event.getPlayer(); Player player = event.getPlayer();
Location from = event.getFrom(); Location from = event.getFrom();
@ -103,7 +131,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGHEST) priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent event) { public static void onChat(AsyncPlayerChatEvent event) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
@ -135,7 +163,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH) priority = EventPriority.HIGH)
public void BlockDestroy(BlockBreakEvent event) { public static void BlockDestroy(BlockBreakEvent event) {
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
@ -176,7 +204,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
@EventHandler @EventHandler
public void onBigBoom(EntityExplodeEvent event) { public static void onBigBoom(EntityExplodeEvent event) {
World world = event.getLocation().getWorld(); World world = event.getLocation().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
@ -186,7 +214,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPeskyMobsChangeTheWorldLikeWTFEvent( // LOL! public static void onPeskyMobsChangeTheWorldLikeWTFEvent( // LOL!
EntityChangeBlockEvent event) { EntityChangeBlockEvent event) {
World world = event.getBlock().getWorld(); World world = event.getBlock().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
@ -225,7 +253,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEntityBlockForm(final EntityBlockFormEvent event) { public static void onEntityBlockForm(final EntityBlockFormEvent event) {
World world = event.getBlock().getWorld(); World world = event.getBlock().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
@ -237,7 +265,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBS(final BlockSpreadEvent e) { public static void onBS(final BlockSpreadEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
@ -248,7 +276,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBF(final BlockFormEvent e) { public static void onBF(final BlockFormEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
@ -259,7 +287,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBD(final BlockDamageEvent e) { public static void onBD(final BlockDamageEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
@ -270,7 +298,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onFade(final BlockFadeEvent e) { public static void onFade(final BlockFadeEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
@ -281,7 +309,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onChange(final BlockFromToEvent e) { public static void onChange(final BlockFromToEvent e) {
Block b = e.getToBlock(); Block b = e.getToBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
@ -292,7 +320,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onGrow(final BlockGrowEvent e) { public static void onGrow(final BlockGrowEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
@ -303,7 +331,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPistonExtend(final BlockPistonExtendEvent e) { public static void onBlockPistonExtend(final BlockPistonExtendEvent e) {
if (isInPlot(e.getBlock().getLocation())) { if (isInPlot(e.getBlock().getLocation())) {
e.getDirection(); e.getDirection();
@ -366,7 +394,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPistonRetract(final BlockPistonRetractEvent e) { public static void onBlockPistonRetract(final BlockPistonRetractEvent e) {
Block b = e.getRetractLocation().getBlock(); Block b = e.getRetractLocation().getBlock();
if (isPlotWorld(b.getLocation()) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) { if (isPlotWorld(b.getLocation()) && (e.getBlock().getType() == Material.PISTON_STICKY_BASE)) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
@ -377,7 +405,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onStructureGrow(final StructureGrowEvent e) { public static void onStructureGrow(final StructureGrowEvent e) {
List<BlockState> blocks = e.getBlocks(); List<BlockState> blocks = e.getBlocks();
boolean remove = false; boolean remove = false;
for (int i = blocks.size() - 1; i >= 0; i--) { for (int i = blocks.size() - 1; i >= 0; i--) {
@ -391,7 +419,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
@EventHandler @EventHandler
public void onInteract(PlayerInteractEvent event) { public static void onInteract(PlayerInteractEvent event) {
if (event.getClickedBlock() == null) { if (event.getClickedBlock() == null) {
return; return;
} }
@ -434,7 +462,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void MobSpawn(CreatureSpawnEvent event) { public static void MobSpawn(CreatureSpawnEvent event) {
World world = event.getLocation().getWorld(); World world = event.getLocation().getWorld();
if (!isPlotWorld(world)) { if (!isPlotWorld(world)) {
return; return;
@ -459,7 +487,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockIgnite(final BlockIgniteEvent e) { public static void onBlockIgnite(final BlockIgniteEvent e) {
if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) { if (e.getCause() == BlockIgniteEvent.IgniteCause.LIGHTNING) {
e.setCancelled(true); e.setCancelled(true);
return; return;
@ -495,7 +523,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void onTeleport(PlayerTeleportEvent event) { public static void onTeleport(PlayerTeleportEvent event) {
Location f = event.getFrom(); Location f = event.getFrom();
Location t = event.getTo(); Location t = event.getTo();
Location q = new Location(t.getWorld(),t.getBlockX(), 64, t.getZ()); Location q = new Location(t.getWorld(),t.getBlockX(), 64, t.getZ());
@ -529,24 +557,24 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBucketEmpty(PlayerBucketEmptyEvent e) { public static void onBucketEmpty(PlayerBucketEmptyEvent e) {
if (!e.getPlayer().hasPermission("plots.admin")) { if (!e.getPlayer().hasPermission("plots.admin")) {
BlockFace bf = e.getBlockFace(); BlockFace bf = e.getBlockFace();
Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock(); Block b = e.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
else { else {
Plot plot = getCurrentPlot(b.getLocation()); Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) { if (plot == null) {
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
else else
if (!plot.hasRights(e.getPlayer())) { if (!plot.hasRights(e.getPlayer())) {
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -556,14 +584,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGHEST) priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent event) { public static void onInventoryClick(InventoryClickEvent event) {
if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) { if (event.getInventory().getName().equalsIgnoreCase("PlotSquared Commands")) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@EventHandler @EventHandler
public void onLeave(PlayerQuitEvent event) { public static void onLeave(PlayerQuitEvent event) {
if(PlotSelection.currentSelection.containsKey(event.getPlayer().getName())) { if(PlotSelection.currentSelection.containsKey(event.getPlayer().getName())) {
PlotSelection.currentSelection.remove(event.getPlayer().getName()); PlotSelection.currentSelection.remove(event.getPlayer().getName());
} }
@ -583,23 +611,23 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBucketFill(PlayerBucketFillEvent e) { public static void onBucketFill(PlayerBucketFillEvent e) {
if (!e.getPlayer().hasPermission("plots.admin")) { if (!e.getPlayer().hasPermission("plots.admin")) {
Block b = e.getBlockClicked(); Block b = e.getBlockClicked();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
else { else {
Plot plot = getCurrentPlot(b.getLocation()); Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) { if (plot == null) {
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
else else
if (!plot.hasRights(e.getPlayer())) { if (!plot.hasRights(e.getPlayer())) {
PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PERMISSION); PlayerFunctions.sendMessage(e.getPlayer(), C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -609,13 +637,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onHangingPlace(final HangingPlaceEvent e) { public static void onHangingPlace(final HangingPlaceEvent e) {
Block b = e.getBlock(); Block b = e.getBlock();
if (isPlotWorld(b.getLocation())) { if (isPlotWorld(b.getLocation())) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (!isInPlot(b.getLocation())) { if (!isInPlot(b.getLocation())) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -623,14 +651,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
Plot plot = getCurrentPlot(b.getLocation()); Plot plot = getCurrentPlot(b.getLocation());
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
else else
if (!plot.hasRights(p)) { if (!plot.hasRights(p)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -640,7 +668,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onHangingBreakByEntity(final HangingBreakByEntityEvent e) { public static void onHangingBreakByEntity(final HangingBreakByEntityEvent e) {
Entity r = e.getRemover(); Entity r = e.getRemover();
if (r instanceof Player) { if (r instanceof Player) {
Player p = (Player) r; Player p = (Player) r;
@ -648,7 +676,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (isPlotWorld(l)) { if (isPlotWorld(l)) {
if (!isInPlot(l)) { if (!isInPlot(l)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -656,14 +684,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
Plot plot = getCurrentPlot(l); Plot plot = getCurrentPlot(l);
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
else else
if (!plot.hasRights(p)) { if (!plot.hasRights(p)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -674,13 +702,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerInteractEntity(final PlayerInteractEntityEvent e) { public static void onPlayerInteractEntity(final PlayerInteractEntityEvent e) {
Location l = e.getRightClicked().getLocation(); Location l = e.getRightClicked().getLocation();
if (isPlotWorld(l)) { if (isPlotWorld(l)) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (!isInPlot(l)) { if (!isInPlot(l)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -688,14 +716,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
Plot plot = getCurrentPlot(l); Plot plot = getCurrentPlot(l);
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
else else
if (!plot.hasRights(p)) { if (!plot.hasRights(p)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -705,7 +733,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) { public static void onEntityDamageByEntityEvent(final EntityDamageByEntityEvent e) {
Location l = e.getEntity().getLocation(); Location l = e.getEntity().getLocation();
Entity d = e.getDamager(); Entity d = e.getDamager();
Entity a = e.getEntity(); Entity a = e.getEntity();
@ -721,7 +749,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
if (!isInPlot(l)) { if (!isInPlot(l)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -729,14 +757,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
Plot plot = getCurrentPlot(l); Plot plot = getCurrentPlot(l);
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
else else
if (!plot.hasRights(p)) { if (!plot.hasRights(p)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setCancelled(true); e.setCancelled(true);
} }
} }
@ -747,13 +775,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
@EventHandler( @EventHandler(
priority = EventPriority.HIGH, ignoreCancelled = true) priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerEggThrow(final PlayerEggThrowEvent e) { public static void onPlayerEggThrow(final PlayerEggThrowEvent e) {
Location l = e.getEgg().getLocation(); Location l = e.getEgg().getLocation();
if (isPlotWorld(l)) { if (isPlotWorld(l)) {
Player p = e.getPlayer(); Player p = e.getPlayer();
if (!isInPlot(l)) { if (!isInPlot(l)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setHatching(false); e.setHatching(false);
} }
} }
@ -761,14 +789,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
Plot plot = getCurrentPlot(l); Plot plot = getCurrentPlot(l);
if (plot == null) { if (plot == null) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setHatching(false); e.setHatching(false);
} }
} }
else else
if (!plot.hasRights(p)) { if (!plot.hasRights(p)) {
if (!p.hasPermission("plots.admin")) { if (!p.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(p, C.NO_PERMISSION); PlayerFunctions.sendMessage(p, C.NO_PLOT_PERMS);
e.setHatching(false); e.setHatching(false);
} }
} }

View File

@ -2,7 +2,9 @@ package com.intellectualcrafters.plot.uuid;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.StringWrapper;
import com.intellectualcrafters.plot.UUIDHandler; import com.intellectualcrafters.plot.UUIDHandler;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -28,7 +30,7 @@ public class PlotUUIDSaver extends UUIDSaver {
uuid = player.getUniqueId(); uuid = player.getUniqueId();
if (!UUIDHandler.uuidExists(uuid)) { if (!UUIDHandler.uuidExists(uuid)) {
name = player.getName(); name = player.getName();
UUIDHandler.add(name, uuid); UUIDHandler.add(new StringWrapper(name), uuid);
} }
} }
@ -49,7 +51,7 @@ public class PlotUUIDSaver extends UUIDSaver {
}); });
} }
public void globalSave(BiMap<String, UUID> map) { public void globalSave(BiMap<StringWrapper, UUID> map) {
} }

View File

@ -1,6 +1,7 @@
package com.intellectualcrafters.plot.uuid; package com.intellectualcrafters.plot.uuid;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.StringWrapper;
import java.util.UUID; import java.util.UUID;
@ -9,7 +10,7 @@ import java.util.UUID;
*/ */
public abstract class UUIDSaver { public abstract class UUIDSaver {
public abstract void globalPopulate(); public abstract void globalPopulate();
public abstract void globalSave(BiMap<String, UUID> map); public abstract void globalSave(BiMap<StringWrapper, UUID> biMap);
public abstract void save(UUIDSet set); public abstract void save(UUIDSet set);
public abstract UUIDSet get(String name); public abstract UUIDSet get(String name);
public abstract UUIDSet get(UUID uuid); public abstract UUIDSet get(UUID uuid);