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
*/
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"),
CANT_CLAIM_MORE_PLOTS("&cYou can't claim more plots."),
YOU_BE_DENIED("&cYou are not allowed to enter this plot"),
@ -216,7 +216,7 @@ public enum C {
/*
* Claiming
*/
PLOT_NOT_CLAIMED("&cCannot claim plot"),
PLOT_NOT_CLAIMED("&cPlot not claimed"),
PLOT_IS_CLAIMED("&cThis plot is already claimed"),
CLAIMED("&6You successfully claimed the plot"),
/*
@ -270,6 +270,8 @@ public enum C {
/*
* 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_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}"),

View File

@ -6,7 +6,6 @@ public abstract class PlotGenerator extends ChunkGenerator {
public PlotGenerator(String world) {
PlotMain.loadWorld(world, this);
System.out.print("LOADED");
}
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.UUIDFetcher;
import com.intellectualcrafters.plot.uuid.UUIDSaver;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;
/**
@ -35,9 +37,9 @@ public class UUIDHandler {
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;
}
@ -45,42 +47,45 @@ public class UUIDHandler {
return uuidMap.containsValue(uuid);
}
public static boolean nameExists(String name) {
public static boolean nameExists(StringWrapper 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);
}
/**
* @param name
* @return uuid
*/
public static UUID getUUID(String name) {
if (nameExists(name)) {
return uuidMap.get(name);
StringWrapper nameWrap = new StringWrapper(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;
if ((uuid = getUuidOnlinePlayer(name)) != null) {
return uuid;
}
if ((uuid = getUuidOfflinePlayer(name)) != null) {
return uuid;
}
if (online) {
if ((uuid = getUuidOnlinePlayer(nameWrap)) != null) {
return uuid;
}
try {
UUIDFetcher fetcher = new UUIDFetcher(Arrays.asList(name));
uuid = fetcher.call().get(name);
add(name, uuid);
add(nameWrap, uuid);
}
catch (Exception e) {
e.printStackTrace();
}
}
else {
return getUuidOfflineMode(name);
return getUuidOfflineMode(nameWrap);
}
return null;
}
@ -89,7 +94,7 @@ public class UUIDHandler {
* @param uuid
* @return name (cache)
*/
private static String loopSearch(UUID uuid) {
private static StringWrapper loopSearch(UUID uuid) {
return uuidMap.inverse().get(uuid);
}
@ -99,7 +104,7 @@ public class UUIDHandler {
*/
public static String getName(UUID uuid) {
if (uuidExists(uuid)) {
return loopSearch(uuid);
return loopSearch(uuid).value;
}
String name;
if ((name = getNameOnlinePlayer(uuid)) != null) {
@ -112,7 +117,7 @@ public class UUIDHandler {
try {
NameFetcher fetcher = new NameFetcher(Arrays.asList(uuid));
name = fetcher.call().get(uuid);
add(name, uuid);
add(new StringWrapper(name), uuid);
return name;
}
catch (Exception e) {
@ -129,7 +134,7 @@ public class UUIDHandler {
* @param name
* @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));
add(name, uuid);
return uuid;
@ -145,7 +150,7 @@ public class UUIDHandler {
return null;
}
String name = player.getName();
add(name, uuid);
add(new StringWrapper(name), uuid);
return name;
}
@ -159,7 +164,7 @@ public class UUIDHandler {
return null;
}
String name = player.getName();
add(name, uuid);
add(new StringWrapper(name), uuid);
return name;
}
@ -167,9 +172,9 @@ public class UUIDHandler {
* @param name
* @return UUID
*/
private static UUID getUuidOnlinePlayer(String name) {
Player player = Bukkit.getPlayer(name);
if (player == null || !player.isOnline()) {
private static UUID getUuidOnlinePlayer(StringWrapper name) {
Player player = Bukkit.getPlayer(name.value);
if (player == null) {
return null;
}
UUID uuid = player.getUniqueId();
@ -181,8 +186,8 @@ public class UUIDHandler {
* @param name
* @return UUID (username hash)
*/
private static UUID getUuidOfflinePlayer(String name) {
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
private static UUID getUuidOfflinePlayer(StringWrapper name) {
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.value).getBytes(Charsets.UTF_8));
add(name, uuid);
return uuid;
}

View File

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

View File

@ -42,45 +42,49 @@ public class Denied extends SubCommand {
}
Plot plot = PlayerFunctions.getCurrentPlot(plr);
if ((plot.owner == null) || !plot.hasRights(plr)) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true;
}
if (args[0].equalsIgnoreCase("add")) {
UUID uuid;
if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone;
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);
return true;
uuid = DBFunc.everyone;
}
else {
uuid = UUIDHandler.getUUID(args[1]);
}
/*
* 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()) {
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);
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;
}
if (!uuid.equals(DBFunc.everyone) && (Bukkit.getPlayer(uuid) != null) && Bukkit.getPlayer(uuid).isOnline()) {
Plot pl = PlayerFunctions.getCurrentPlot(Bukkit.getPlayer((uuid)));
if (pl.id == plot.id) {
PlayerFunctions.sendMessage(Bukkit.getPlayer(uuid), C.YOU_BE_DENIED);
Bukkit.getPlayer(uuid).teleport(Bukkit.getPlayer(uuid).getWorld().getSpawnLocation());
}
}
PlayerFunctions.sendMessage(plr, C.DENIED_ADDED);
return true;
}
else
if (args[0].equalsIgnoreCase("remove")) {

View File

@ -39,38 +39,41 @@ public class Helpers extends SubCommand {
}
Plot plot = PlayerFunctions.getCurrentPlot(plr);
if ((plot.owner == null) || !plot.hasRights(plr)) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true;
}
if (args[0].equalsIgnoreCase("add")) {
UUID uuid;
if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone;
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);
return true;
uuid = DBFunc.everyone;
}
else {
uuid = UUIDHandler.getUUID(args[1]);
}
/*
* 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);
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);
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;
}
PlayerFunctions.sendMessage(plr, C.HELPER_ADDED);
return true;
}
else
if (args[0].equalsIgnoreCase("remove")) {

View File

@ -38,8 +38,8 @@ public class MainCommand implements CommandExecutor {
}
};
public static boolean no_permission(Player player) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION);
public static boolean no_permission(Player player, String permission) {
PlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission);
return false;
}
@ -53,7 +53,7 @@ public class MainCommand implements CommandExecutor {
player = null;
}
if (!PlotMain.hasPermission(player, "plots.use")) {
return no_permission(player);
return no_permission(player, "plots.use");
}
if ((args.length < 1)
|| ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
@ -109,7 +109,7 @@ public class MainCommand implements CommandExecutor {
}
}
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.events.PlotFlagAddEvent;
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
import com.intellectualcrafters.plot.listeners.PlayerEvents;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -46,7 +48,7 @@ public class Set extends SubCommand {
Plot plot = PlayerFunctions.getCurrentPlot(plr);
if(!plot.hasOwner()) {
sendMessage(plr, C.PLOT_NOT_CLAIMED);
return true;
return false;
}
if (!plot.hasRights(plr) && !plr.hasPermission("plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
@ -69,7 +71,7 @@ public class Set extends SubCommand {
boolean advanced_permissions = true;
if (advanced_permissions) {
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;
}
}
@ -102,7 +104,7 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
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);
return false;
}
@ -133,6 +135,7 @@ public class Set extends SubCommand {
plot.settings.setFlags(newflags.toArray(new Flag[0]));
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
PlayerEvents.plotEntry(plr, plot);
return true;
}
try {
@ -160,6 +163,7 @@ public class Set extends SubCommand {
plot.settings.addFlag(flag);
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
PlayerEvents.plotEntry(plr, plot);
return true;
}
catch (Exception e) {

View File

@ -39,38 +39,42 @@ public class Trusted extends SubCommand {
}
Plot plot = PlayerFunctions.getCurrentPlot(plr);
if ((plot.owner == null) || !plot.hasRights(plr)) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
return true;
}
if (args[0].equalsIgnoreCase("add")) {
UUID uuid;
if (args[1].equalsIgnoreCase("*")) {
UUID uuid = DBFunc.everyone;
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);
return true;
uuid = DBFunc.everyone;
}
else {
uuid = UUIDHandler.getUUID(args[1]);
}
/*
* 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);
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);
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
if (args[0].equalsIgnoreCase("remove")) {

View File

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

View File

@ -2,7 +2,9 @@ package com.intellectualcrafters.plot.uuid;
import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.StringWrapper;
import com.intellectualcrafters.plot.UUIDHandler;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.java.JavaPlugin;
@ -28,7 +30,7 @@ public class PlotUUIDSaver extends UUIDSaver {
uuid = player.getUniqueId();
if (!UUIDHandler.uuidExists(uuid)) {
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;
import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.StringWrapper;
import java.util.UUID;
@ -9,7 +10,7 @@ import java.util.UUID;
*/
public abstract class UUIDSaver {
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 UUIDSet get(String name);
public abstract UUIDSet get(UUID uuid);