This commit is contained in:
boy0001 2014-10-21 20:58:52 +11:00
parent 3bbd0a2293
commit c55faaec8d
13 changed files with 192 additions and 188 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"),
/* /*

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,61 +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;
if (!plot.denied.contains(uuid)) {
if (plot.owner == uuid) { }
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); else {
return false; uuid = UUIDHandler.getUUID(args[1]);
} }
if (plot.trusted.contains(uuid)) { if (!plot.denied.contains(uuid)) {
plot.trusted.remove(uuid); if (plot.owner == uuid) {
DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid)); PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
}
if (plot.helpers.contains(uuid)) {
plot.helpers.remove(uuid);
DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(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);
}
else {
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false; return false;
} }
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED); if (plot.trusted.contains(uuid)) {
return true; plot.trusted.remove(uuid);
} DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
/* }
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr, if (plot.helpers.contains(uuid)) {
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if plot.helpers.remove(uuid);
* ((Bukkit.getPlayer(args[1]) != null)) { uuid = DBFunc.removeHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = }
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid == plot.addDenied(uuid);
* null) { PlayerFunctions.sendMessage(plr, DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true);
*/ Bukkit.getPluginManager().callEvent(event);
UUID uuid = UUIDHandler.getUUID(args[1]); }
if (!plot.denied.contains(uuid)) { else {
plot.addDenied(uuid); PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
DBFunc.setDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); return false;
PlayerPlotDeniedEvent event = new PlayerPlotDeniedEvent(plr, plot, uuid, true); }
Bukkit.getPluginManager().callEvent(event); if (!uuid.equals(DBFunc.everyone) && (Bukkit.getPlayer(uuid) != null) && Bukkit.getPlayer(uuid).isOnline()) {
}
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,54 +39,41 @@ 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;
if (!plot.helpers.contains(uuid)) { }
if (plot.owner == uuid) { else {
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); uuid = UUIDHandler.getUUID(args[1]);
return false; }
} if (!plot.helpers.contains(uuid)) {
if (plot.trusted.contains(uuid)) { if (plot.owner == uuid) {
plot.trusted.remove(uuid); PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
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);
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
}
else {
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false; return false;
} }
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED); if (plot.trusted.contains(uuid)) {
return true; plot.trusted.remove(uuid);
} DBFunc.removeTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
/* }
* if (!hasBeenOnServer(args[1])) { PlayerFunctions.sendMessage(plr, if (plot.denied.contains(uuid)) {
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } UUID uuid = null; if plot.denied.remove(uuid);
* ((Bukkit.getPlayer(args[1]) != null)) { uuid = DBFunc.removeDenied(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(uuid));
* Bukkit.getPlayer(args[1]).getUniqueId(); } else { uuid = }
* Bukkit.getOfflinePlayer(args[1]).getUniqueId(); } if (uuid == plot.addHelper(uuid);
* null) { PlayerFunctions.sendMessage(plr, DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
* C.PLAYER_HAS_NOT_BEEN_ON); return true; } PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true);
*/ Bukkit.getPluginManager().callEvent(event);
UUID uuid = UUIDHandler.getUUID(args[1]); }
if (!plot.helpers.contains(uuid)) { else {
plot.addHelper(uuid); PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
DBFunc.setHelper(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); return false;
PlayerPlotHelperEvent event = new PlayerPlotHelperEvent(plr, plot, uuid, true); }
Bukkit.getPluginManager().callEvent(event); PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
} return true;
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
} }
else else
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {

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

@ -48,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);
@ -71,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;
} }
} }
@ -104,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;
} }

View File

@ -39,54 +39,42 @@ 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;
if (!plot.trusted.contains(uuid)) {
if (plot.owner == uuid) { }
PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER); else {
return false; uuid = UUIDHandler.getUUID(args[1]);
}
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);
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
}
else {
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false;
}
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED);
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)) { if (!plot.trusted.contains(uuid)) {
plot.addTrusted(uuid); if (plot.owner == uuid) {
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1])); PlayerFunctions.sendMessage(plr, C.ALREADY_OWNER);
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true); return false;
Bukkit.getPluginManager().callEvent(event); }
} if (plot.helpers.contains(uuid)) {
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED); 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);
DBFunc.setTrusted(plr.getWorld().getName(), plot, Bukkit.getOfflinePlayer(args[1]));
PlayerPlotTrustedEvent event = new PlayerPlotTrustedEvent(plr, plot, uuid, true);
Bukkit.getPluginManager().callEvent(event);
}
else {
PlayerFunctions.sendMessage(plr, C.ALREADY_ADDED);
return false;
}
PlayerFunctions.sendMessage(plr, C.TRUSTED_ADDED);
return true;
} }
else else
if (args[0].equalsIgnoreCase("remove")) { if (args[0].equalsIgnoreCase("remove")) {

View File

@ -676,18 +676,18 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -720,18 +720,18 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -747,7 +747,7 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -755,14 +755,14 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -780,7 +780,7 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -788,14 +788,14 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -812,7 +812,7 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -820,14 +820,14 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -853,7 +853,7 @@ public class PlayerEvents implements Listener {
} }
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);
} }
} }
@ -861,14 +861,14 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -885,7 +885,7 @@ public class PlayerEvents implements Listener {
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);
} }
} }
@ -893,14 +893,14 @@ public class PlayerEvents implements Listener {
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);