mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 12:06:15 +01:00
finished refactor
This commit is contained in:
parent
7155af3188
commit
791ce39ecc
@ -174,7 +174,7 @@ import java.util.UUID;
|
|||||||
final String trusted = getPlayerList(plot.trusted);
|
final String trusted = getPlayerList(plot.trusted);
|
||||||
final String denied = getPlayerList(plot.denied);
|
final String denied = getPlayerList(plot.denied);
|
||||||
final String rating = String.format("%.1f", DBFunc.getRatings(plot));
|
final String rating = String.format("%.1f", DBFunc.getRatings(plot));
|
||||||
final String flags = "&6" + (StringUtils.join(plot.settings.getFlags(), "").length() > 0 ? StringUtils.join(plot.settings.getFlags(), "&7, &6") : "none");
|
final String flags = "&6" + (StringUtils.join(plot.settings.flags, "").length() > 0 ? StringUtils.join(plot.settings.flags, "&7, &6") : "none");
|
||||||
final boolean build = (player == null) || plot.hasRights(player);
|
final boolean build = (player == null) || plot.hasRights(player);
|
||||||
|
|
||||||
String owner = "none";
|
String owner = "none";
|
||||||
|
@ -124,7 +124,7 @@ public class Set extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (plot.settings.getFlag(args[1].toLowerCase()) == null) {
|
if (FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()) == null) {
|
||||||
if (PlotMain.worldGuardListener != null) {
|
if (PlotMain.worldGuardListener != null) {
|
||||||
if (PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) {
|
if (PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) {
|
||||||
PlotMain.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]);
|
PlotMain.worldGuardListener.removeFlag(plr, plr.getWorld(), plot, args[1]);
|
||||||
@ -134,17 +134,13 @@ public class Set extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_IN_PLOT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final Flag flag = plot.settings.getFlag(args[1].toLowerCase());
|
|
||||||
final PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flag, plot);
|
boolean result = FlagManager.removePlotFlag(plot, args[1].toLowerCase());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
|
||||||
if (event.isCancelled()) {
|
if (!result) {
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_REMOVED);
|
||||||
event.setCancelled(true);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final java.util.Set<Flag> newflags = FlagManager.removeFlag(plot.settings.getFlags(), args[1].toLowerCase());
|
|
||||||
plot.settings.setFlags(newflags);
|
|
||||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags);
|
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
||||||
PlotListener.plotEntry(plr, plot);
|
PlotListener.plotEntry(plr, plot);
|
||||||
return true;
|
return true;
|
||||||
@ -163,15 +159,11 @@ public class Set extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), value);
|
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), value);
|
||||||
final PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot);
|
boolean result = FlagManager.addPlotFlag(plot, flag);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
if (!result) {
|
||||||
if (event.isCancelled()) {
|
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_NOT_ADDED);
|
||||||
event.setCancelled(true);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
plot.settings.addFlag(flag);
|
|
||||||
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags());
|
|
||||||
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
||||||
PlotListener.plotEntry(plr, plot);
|
PlotListener.plotEntry(plr, plot);
|
||||||
return true;
|
return true;
|
||||||
|
@ -678,7 +678,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
PlotMain.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted.");
|
PlotMain.sendConsoleSenderMessage("&cPlot " + id + " had an invalid flag. A fix has been attempted.");
|
||||||
setFlags(id, flags.toArray(new Flag[0]));
|
setFlags(id, flags.toArray(new Flag[0]));
|
||||||
}
|
}
|
||||||
plot.settings.setFlags(flags);
|
FlagManager.setPlotFlags(plot, flags);
|
||||||
} else {
|
} else {
|
||||||
PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry.");
|
PlotMain.sendConsoleSenderMessage("&cPLOT " + id + " in plot_settings does not exist. Please create the plot or remove this entry.");
|
||||||
}
|
}
|
||||||
@ -732,7 +732,6 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFlags(final String world, final Plot plot, final Set<Flag> flags) {
|
public void setFlags(final String world, final Plot plot, final Set<Flag> flags) {
|
||||||
plot.settings.setFlags(flags);
|
|
||||||
final StringBuilder flag_string = new StringBuilder();
|
final StringBuilder flag_string = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (final Flag flag : flags) {
|
for (final Flag flag : flags) {
|
||||||
|
@ -21,11 +21,19 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.flag;
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.events.PlotFlagAddEvent;
|
||||||
|
import com.intellectualcrafters.plot.events.PlotFlagRemoveEvent;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.sun.istack.internal.NotNull;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -56,6 +64,100 @@ import java.util.Set;
|
|||||||
return (getFlag(flag.getKey()) == null) && flags.add(flag);
|
return (getFlag(flag.getKey()) == null) && flags.add(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a flag for a plot (respects flag defaults)
|
||||||
|
* @param plot
|
||||||
|
* @param flag
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Flag getPlotFlag(Plot plot, String flag) {
|
||||||
|
ArrayList<Flag> flags = new ArrayList<>();
|
||||||
|
flags.addAll(plot.settings.flags);
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings(plot.world);
|
||||||
|
flags.addAll(Arrays.asList(plotworld.DEFAULT_FLAGS));
|
||||||
|
for (final Flag myflag : flags) {
|
||||||
|
if (myflag.getKey().equals(flag)) {
|
||||||
|
return myflag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the value of a flag for a plot (ignores flag defaults)
|
||||||
|
* @param plot
|
||||||
|
* @param flag
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Flag getPlotFlagAbs(Plot plot, String flag) {
|
||||||
|
for (final Flag myflag : plot.settings.flags) {
|
||||||
|
if (myflag.getKey().equals(flag)) {
|
||||||
|
return myflag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a flag to a plot
|
||||||
|
* @param plot
|
||||||
|
* @param flag
|
||||||
|
*/
|
||||||
|
public static boolean addPlotFlag(Plot plot, final Flag flag) {
|
||||||
|
final PlotFlagAddEvent event = new PlotFlagAddEvent(flag, plot);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Flag hasFlag = getPlotFlag(plot, flag.getKey());
|
||||||
|
if (hasFlag != null) {
|
||||||
|
plot.settings.flags.remove(hasFlag);
|
||||||
|
}
|
||||||
|
plot.settings.flags.add(flag);
|
||||||
|
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param plot
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Set<Flag> getPlotFlags(Plot plot) {
|
||||||
|
Set<Flag> plotflags = plot.settings.flags;
|
||||||
|
PlotWorld plotworld = PlotMain.getWorldSettings(plot.world);
|
||||||
|
plotflags.addAll(Arrays.asList(plotworld.DEFAULT_FLAGS));
|
||||||
|
return plotflags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean removePlotFlag(Plot plot, String flag) {
|
||||||
|
final Flag hasFlag = getPlotFlag(plot, flag);
|
||||||
|
if (hasFlag != null) {
|
||||||
|
Flag flagObj = FlagManager.getPlotFlagAbs(plot, flag);
|
||||||
|
if (flagObj != null) {
|
||||||
|
final PlotFlagRemoveEvent event = new PlotFlagRemoveEvent(flagObj, plot);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
plot.settings.flags.remove(hasFlag);
|
||||||
|
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setPlotFlags(Plot plot, Set<Flag> flags) {
|
||||||
|
if (flags == null) {
|
||||||
|
plot.settings.flags = new HashSet<>();
|
||||||
|
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
plot.settings.flags = flags;
|
||||||
|
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||||
|
}
|
||||||
|
|
||||||
public static Flag[] removeFlag(final Flag[] flags, final String r) {
|
public static Flag[] removeFlag(final Flag[] flags, final String r) {
|
||||||
final Flag[] f = new Flag[flags.length - 1];
|
final Flag[] f = new Flag[flags.length - 1];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -174,8 +276,8 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @return List (AbstractFlag)
|
* @return List (AbstractFlag)
|
||||||
*/
|
*/
|
||||||
public static List<AbstractFlag> getPlotFlags(final Plot plot) {
|
public static List<AbstractFlag> getPlotAbstractFlags(final Plot plot) {
|
||||||
final Set<Flag> plotFlags = plot.settings.getFlags();
|
final Set<Flag> plotFlags = getPlotFlags(plot);
|
||||||
final List<AbstractFlag> flags = new ArrayList<>();
|
final List<AbstractFlag> flags = new ArrayList<>();
|
||||||
for (final Flag flag : plotFlags) {
|
for (final Flag flag : plotFlags) {
|
||||||
flags.add(flag.getAbstractFlag());
|
flags.add(flag.getAbstractFlag());
|
||||||
|
@ -21,8 +21,10 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.listeners;
|
package com.intellectualcrafters.plot.listeners;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -102,7 +104,7 @@ public class ForceFieldListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Plot plot = PlayerFunctions.getCurrentPlot(player);
|
final Plot plot = PlayerFunctions.getCurrentPlot(player);
|
||||||
if ((plot.settings.getFlag("forcefield") != null) && plot.settings.getFlag("forcefield").getValue().equals("true")) {
|
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
|
||||||
if (!PlotListener.booleanFlag(plot, "forcefield")) {
|
if (!PlotListener.booleanFlag(plot, "forcefield")) {
|
||||||
if (plot.hasRights(player)) {
|
if (plot.hasRights(player)) {
|
||||||
final Set<Player> players = getNearbyPlayers(player, plot);
|
final Set<Player> players = getNearbyPlayers(player, plot);
|
||||||
|
@ -26,6 +26,7 @@ import com.intellectualcrafters.plot.commands.Setup;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
import com.intellectualcrafters.plot.util.PlotHelper;
|
||||||
@ -403,7 +404,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
if (PlotMain.booleanFlags.containsKey(event.getClickedBlock().getType())) {
|
if (PlotMain.booleanFlags.containsKey(event.getClickedBlock().getType())) {
|
||||||
final String flag = PlotMain.booleanFlags.get(event.getClickedBlock().getType());
|
final String flag = PlotMain.booleanFlags.get(event.getClickedBlock().getType());
|
||||||
if ((plot.settings.getFlag(flag) != null) && getFlagValue(plot.settings.getFlag(flag).getValue())) {
|
if ((FlagManager.getPlotFlag(plot, flag) != null) && getFlagValue(FlagManager.getPlotFlag(plot, flag).getValue())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ package com.intellectualcrafters.plot.listeners;
|
|||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
|
||||||
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
@ -142,7 +141,7 @@ import java.util.UUID;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean booleanFlag(final Plot plot, final String flag) {
|
public static boolean booleanFlag(final Plot plot, final String flag) {
|
||||||
return (plot.settings.getFlag(flag) != null) && getBooleanFlag(plot.settings.getFlag(flag).getValue()).equals("true");
|
return (FlagManager.getPlotFlag(plot, flag) != null) && getBooleanFlag(FlagManager.getPlotFlag(plot, flag).getValue()).equals("true");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getBooleanFlag(final String value) {
|
private static String getBooleanFlag(final String value) {
|
||||||
@ -177,23 +176,22 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public static void plotEntry(final Player player, final Plot plot) {
|
public static void plotEntry(final Player player, final Plot plot) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (plot.settings.getFlag("gamemode") != null) {
|
if (FlagManager.getPlotFlag(plot, "gamemode") != null) {
|
||||||
player.setGameMode(getGameMode(plot.settings.getFlag("gamemode").getValue()));
|
player.setGameMode(getGameMode(FlagManager.getPlotFlag(plot, "gamemode").getValue()));
|
||||||
}
|
}
|
||||||
if (plot.settings.getFlag("fly") != null) {
|
if (FlagManager.getPlotFlag(plot, "fly") != null) {
|
||||||
player.setAllowFlight(getFlagValue(plot.settings.getFlag("fly").getValue()));
|
player.setAllowFlight(getFlagValue(FlagManager.getPlotFlag(plot, "fly").getValue()));
|
||||||
}
|
}
|
||||||
if (plot.settings.getFlag("time") != null) {
|
if (FlagManager.getPlotFlag(plot, "time") != null) {
|
||||||
try {
|
try {
|
||||||
final Long time = Long.parseLong(plot.settings.getFlag("time").getValue());
|
final Long time = Long.parseLong(FlagManager.getPlotFlag(plot, "time").getValue());
|
||||||
player.setPlayerTime(time, true);
|
player.setPlayerTime(time, true);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
plot.settings.setFlags(FlagManager.removeFlag(plot.settings.getFlags(), "time"));
|
FlagManager.removePlotFlag(plot, "time");
|
||||||
DBFunc.setFlags(plot.world, plot, plot.settings.getFlags());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plot.settings.getFlag("weather") != null) {
|
if (FlagManager.getPlotFlag(plot, "weather") != null) {
|
||||||
player.setPlayerWeather(getWeatherType(plot.settings.getFlag("weather").getValue()));
|
player.setPlayerWeather(getWeatherType(FlagManager.getPlotFlag(plot, "weather").getValue()));
|
||||||
}
|
}
|
||||||
if ((booleanFlag(plot, "titles") || Settings.TITLES) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) {
|
if ((booleanFlag(plot, "titles") || Settings.TITLES) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) {
|
||||||
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%y%", plot.id.y + "").replaceAll("%world%", plot.world + "");
|
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%y%", plot.id.y + "").replaceAll("%world%", plot.world + "");
|
||||||
@ -218,16 +216,16 @@ import java.util.UUID;
|
|||||||
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
||||||
Bukkit.getPluginManager().callEvent(callEvent);
|
Bukkit.getPluginManager().callEvent(callEvent);
|
||||||
}
|
}
|
||||||
if (plot.settings.getFlag("fly") != null) {
|
if (FlagManager.getPlotFlag(plot, "fly") != null) {
|
||||||
player.setAllowFlight(Bukkit.getAllowFlight());
|
player.setAllowFlight(Bukkit.getAllowFlight());
|
||||||
}
|
}
|
||||||
if (plot.settings.getFlag("gamemode") != null) {
|
if (FlagManager.getPlotFlag(plot, "gamemode") != null) {
|
||||||
player.setGameMode(Bukkit.getDefaultGameMode());
|
player.setGameMode(Bukkit.getDefaultGameMode());
|
||||||
}
|
}
|
||||||
if (plot.settings.getFlag("time") != null) {
|
if (FlagManager.getPlotFlag(plot, "time") != null) {
|
||||||
player.resetPlayerTime();
|
player.resetPlayerTime();
|
||||||
}
|
}
|
||||||
if (plot.settings.getFlag("weather") != null) {
|
if (FlagManager.getPlotFlag(plot, "weather") != null) {
|
||||||
player.resetPlayerWeather();
|
player.resetPlayerWeather();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,11 @@ package com.intellectualcrafters.plot.listeners;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
|
||||||
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
|
||||||
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -170,8 +172,8 @@ import java.util.*;
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
public void onPlotEnter(final PlayerEnterPlotEvent event) {
|
||||||
final Plot plot = event.getPlot();
|
final Plot plot = event.getPlot();
|
||||||
if (plot.settings.getFlag("greeting") != null) {
|
if (FlagManager.getPlotFlag(plot, "greeting") != null) {
|
||||||
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', plot.settings.getFlag("greeting").getValue()));
|
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', FlagManager.getPlotFlag(plot, "greeting").getValue()));
|
||||||
}
|
}
|
||||||
if (booleanFlag(plot, "notify-enter")) {
|
if (booleanFlag(plot, "notify-enter")) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
@ -204,8 +206,8 @@ import java.util.*;
|
|||||||
public void onPlotLeave(final PlayerLeavePlotEvent event) {
|
public void onPlotLeave(final PlayerLeavePlotEvent event) {
|
||||||
event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.RECORD_PLAY, 0);
|
event.getPlayer().playEffect(event.getPlayer().getLocation(), Effect.RECORD_PLAY, 0);
|
||||||
final Plot plot = event.getPlot();
|
final Plot plot = event.getPlot();
|
||||||
if (plot.settings.getFlag("farewell") != null) {
|
if (FlagManager.getPlotFlag(plot, "farewell") != null) {
|
||||||
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', plot.settings.getFlag("farewell").getValue()));
|
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', FlagManager.getPlotFlag(plot, "farewell").getValue()));
|
||||||
}
|
}
|
||||||
if (feedRunnable.containsKey(event.getPlayer().getName())) {
|
if (feedRunnable.containsKey(event.getPlayer().getName())) {
|
||||||
feedRunnable.remove(event.getPlayer().getName());
|
feedRunnable.remove(event.getPlayer().getName());
|
||||||
|
@ -55,7 +55,7 @@ public class InfoInventory implements InventoryHolder {
|
|||||||
final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers");
|
final ItemStack helpers = getItem(Material.EMERALD, "&cHelpers", "&cAmount: &6" + this.plot.helpers.size(), "&8Click to view a list of the plot helpers");
|
||||||
final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players");
|
final ItemStack trusted = getItem(Material.EMERALD, "&cTrusted", "&cAmount: &6" + this.plot.trusted.size(), "&8Click to view a list of trusted players");
|
||||||
final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.size(), "&8Click to view a list of denied players");
|
final ItemStack denied = getItem(Material.EMERALD, "&cDenied", "&cAmount: &6" + this.plot.denied.size(), "&8Click to view a list of denied players");
|
||||||
final ItemStack flags = getItem(Material.EMERALD, "&cFlags", "&cAmount: &6" + this.plot.settings.getFlags().size(), "&8Click to view a list of plot flags");
|
final ItemStack flags = getItem(Material.EMERALD, "&cFlags", "&cAmount: &6" + this.plot.settings.flags.size(), "&8Click to view a list of plot flags");
|
||||||
this.inventory.setItem(2, generalInfo);
|
this.inventory.setItem(2, generalInfo);
|
||||||
this.inventory.setItem(3, helpers);
|
this.inventory.setItem(3, helpers);
|
||||||
this.inventory.setItem(4, trusted);
|
this.inventory.setItem(4, trusted);
|
||||||
|
@ -111,7 +111,7 @@ import java.util.UUID;
|
|||||||
this.settings.setAlias("");
|
this.settings.setAlias("");
|
||||||
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
||||||
this.delete = false;
|
this.delete = false;
|
||||||
this.settings.setFlags(new HashSet<Flag>());
|
this.settings.flags = new HashSet<Flag>();
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ import java.util.UUID;
|
|||||||
this.settings.setAlias("");
|
this.settings.setAlias("");
|
||||||
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
this.settings.setPosition(PlotHomePosition.DEFAULT);
|
||||||
this.delete = false;
|
this.delete = false;
|
||||||
this.settings.setFlags(new HashSet<Flag>());
|
this.settings.flags = new HashSet<Flag>();
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,9 +165,9 @@ import java.util.UUID;
|
|||||||
this.settings.setMerged(merged);
|
this.settings.setMerged(merged);
|
||||||
this.delete = false;
|
this.delete = false;
|
||||||
if (flags != null) {
|
if (flags != null) {
|
||||||
this.settings.setFlags(flags);
|
this.settings.flags = flags;
|
||||||
} else {
|
} else {
|
||||||
this.settings.setFlags(new HashSet<Flag>());
|
this.settings.flags = new HashSet<Flag>();
|
||||||
}
|
}
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
@ -194,9 +194,9 @@ import java.util.UUID;
|
|||||||
this.settings.setMerged(merged);
|
this.settings.setMerged(merged);
|
||||||
this.delete = false;
|
this.delete = false;
|
||||||
if (flags != null) {
|
if (flags != null) {
|
||||||
this.settings.setFlags(flags);
|
this.settings.flags = flags;
|
||||||
} else {
|
} else {
|
||||||
this.settings.setFlags(new HashSet<Flag>());
|
this.settings.flags = new HashSet<Flag>();
|
||||||
}
|
}
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
@ -271,7 +271,7 @@ import java.util.UUID;
|
|||||||
public Object clone() throws CloneNotSupportedException {
|
public Object clone() throws CloneNotSupportedException {
|
||||||
final Plot p = (Plot) super.clone();
|
final Plot p = (Plot) super.clone();
|
||||||
if (!p.equals(this) || (p != this)) {
|
if (!p.equals(this) || (p != this)) {
|
||||||
return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.getFlags(), getWorld().getName(), this.settings.getMerged());
|
return new Plot(this.id, this.owner, this.helpers, this.trusted, this.denied, this.settings.getAlias(), this.settings.getPosition(), this.settings.flags, getWorld().getName(), this.settings.getMerged());
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user