mirror of
https://github.com/TotalFreedomMC/TF-PlotSquared.git
synced 2024-12-23 00:15:06 +00:00
Tweaks and doc updates.
This commit is contained in:
parent
83f664129f
commit
465f7f4504
7 changed files with 144 additions and 143 deletions
|
@ -1271,9 +1271,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void MobSpawn(CreatureSpawnEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity instanceof Player) {
|
||||
return;
|
||||
}
|
||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
|
@ -2128,7 +2125,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||
plot = null;
|
||||
stub = "road";
|
||||
} else {
|
||||
// Priorize plots for close to seamless pvp zones
|
||||
// Prioritize plots for close to seamless pvp zones
|
||||
if (victim.getTicksLived() > damager.getTicksLived()) {
|
||||
if (dplot == null || !(victim instanceof Player)) {
|
||||
if (vplot == null) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -251,8 +250,8 @@ public interface AbstractDB {
|
|||
void removeDenied(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* @param plot Plot Object
|
||||
* @param uuid Player uuid that should be added
|
||||
* @param plot the plot
|
||||
* @param uuid the uuid of the player to deny
|
||||
*/
|
||||
void setDenied(Plot plot, UUID uuid);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.intellectualcrafters.plot.flag;
|
|||
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
|
||||
public class Flag<V> {
|
||||
public abstract class Flag<V> {
|
||||
|
||||
private final String name;
|
||||
|
||||
|
@ -11,28 +11,22 @@ public class Flag<V> {
|
|||
* key/value pair. For a flag to be usable by a player, you need to
|
||||
* register it with PlotSquared.
|
||||
*
|
||||
* @param name Flag name
|
||||
* @param name the flag name
|
||||
*/
|
||||
public Flag(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String valueToString(Object value) {
|
||||
return null;
|
||||
}
|
||||
public abstract String valueToString(Object value);
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public final String toString() {
|
||||
return "Flag { name='" + getName() + "'}";
|
||||
}
|
||||
|
||||
public V parseValue(String value) {
|
||||
return null;
|
||||
}
|
||||
public abstract V parseValue(String value);
|
||||
|
||||
public String getValueDescription() {
|
||||
return "";
|
||||
}
|
||||
public abstract String getValueDescription();
|
||||
|
||||
public final String getName() {
|
||||
return this.name;
|
||||
|
|
|
@ -62,36 +62,38 @@ public class FlagManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Reserve a flag so that it cannot be set by players
|
||||
* @param flag
|
||||
* Reserve a flag so that it cannot be set by players.
|
||||
* @param flag the flag to reserve
|
||||
* @return false if the flag was already reserved, otherwise true
|
||||
*/
|
||||
public static void reserveFlag(Flag<?> flag) {
|
||||
reserved.add(flag);
|
||||
public static boolean reserveFlag(Flag<?> flag) {
|
||||
return reserved.add(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if a flag is reserved
|
||||
* @param flag
|
||||
* @return
|
||||
* Check if a flag is reserved.
|
||||
* @param flag the flag to check
|
||||
* @return true if the flag is reserved, false otherwise
|
||||
*/
|
||||
public static boolean isReserved(Flag<?> flag) {
|
||||
return reserved.contains(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reserved flags
|
||||
* @return
|
||||
* Get an immutable set of reserved flags.
|
||||
* @return a set of reserved flags
|
||||
*/
|
||||
public static Set<Flag<?>> getReservedFlags() {
|
||||
return Collections.unmodifiableSet(reserved);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unreserve a flag
|
||||
* @param flag
|
||||
* Unreserve a flag.
|
||||
* @param flag the flag to unreserve
|
||||
* @return true if the flag was unreserved
|
||||
*/
|
||||
public static void unreserveFlag(Flag<?> flag) {
|
||||
reserved.remove(flag);
|
||||
public static boolean unreserveFlag(Flag<?> flag) {
|
||||
return reserved.remove(flag);
|
||||
}
|
||||
|
||||
public static String toString(HashMap<Flag<?>, Object> flags) {
|
||||
|
@ -162,12 +164,12 @@ public class FlagManager {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
* @return set of flags
|
||||
* @param plot the plot
|
||||
* @return a map of flags and their values
|
||||
*/
|
||||
public static Map<Flag<?>, Object> getPlotFlags(Plot plot) {
|
||||
if (!plot.hasOwner()) {
|
||||
return null;
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return getSettingFlags(plot.getArea(), plot.getSettings());
|
||||
}
|
||||
|
@ -195,6 +197,12 @@ public class FlagManager {
|
|||
return getPlotFlags(area, settings, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a flag from a certain plot.
|
||||
* @param plot the plot to remove the flag from
|
||||
* @param id the flag to remove
|
||||
* @return true if the plot contained the flag and was removed successfully
|
||||
*/
|
||||
public static boolean removePlotFlag(Plot plot, Flag<?> id) {
|
||||
Object value = plot.getFlags().remove(id);
|
||||
if (value == null) {
|
||||
|
@ -273,11 +281,11 @@ public class FlagManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get an Flag by a String
|
||||
* Get a {@link Flag} specified by a {@code String}.
|
||||
*
|
||||
* @param string the flag name
|
||||
*
|
||||
* @return the flag or null if the flag the provided name does not exist
|
||||
* @return the {@code Flag} object defined by {@code string}
|
||||
*/
|
||||
public static Flag<?> getFlag(String string) {
|
||||
for (Flag flag : Flags.getFlags()) {
|
||||
|
@ -306,10 +314,10 @@ public class FlagManager {
|
|||
}
|
||||
|
||||
|
||||
public static Map<Flag<?>, Object> parseFlags(List<String> flagstrings) {
|
||||
public static Map<Flag<?>, Object> parseFlags(List<String> flagStrings) {
|
||||
HashMap<Flag<?>, Object> map = new HashMap<>();
|
||||
|
||||
for (String key : flagstrings) {
|
||||
for (String key : flagStrings) {
|
||||
String[] split;
|
||||
if (key.contains(";")) {
|
||||
split = key.split(";");
|
||||
|
|
|
@ -113,6 +113,8 @@ public class Flags {
|
|||
return "Flag value must a timestamp or a boolean";
|
||||
}
|
||||
};
|
||||
public static final BooleanFlag SLEEP = new BooleanFlag("sleep");
|
||||
|
||||
private static final HashSet<Flag<?>> flags = Sets.newHashSet(MUSIC, DESCRIPTION, ANALYSIS, GREETING, FAREWELL, FEED, HEAL,
|
||||
GAMEMODE,
|
||||
DONE,
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.Area;
|
||||
import java.awt.geom.PathIterator;
|
||||
|
@ -126,9 +127,9 @@ public class Plot {
|
|||
*
|
||||
* @see Plot#getPlot(Location) for existing plots
|
||||
*
|
||||
* @param area
|
||||
* @param id
|
||||
* @param owner
|
||||
* @param area the PlotArea where the plot is located
|
||||
* @param id the plot id
|
||||
* @param owner the plot owner
|
||||
*/
|
||||
public Plot(PlotArea area, PlotId id, UUID owner) {
|
||||
this.area = area;
|
||||
|
@ -142,8 +143,8 @@ public class Plot {
|
|||
*
|
||||
* @see Plot#getPlot(Location) for existing plots
|
||||
*
|
||||
* @param area
|
||||
* @param id
|
||||
* @param area the PlotArea where the plot is located
|
||||
* @param id the plot id
|
||||
*/
|
||||
public Plot(PlotArea area, PlotId id) {
|
||||
this.area = area;
|
||||
|
@ -157,9 +158,9 @@ public class Plot {
|
|||
*
|
||||
* @see Plot#getPlot(Location) for existing plots
|
||||
*
|
||||
* @param area
|
||||
* @param id
|
||||
* @param owner
|
||||
* @param area the PlotArea where the plot is located
|
||||
* @param id the plot id
|
||||
* @param owner the owner of the plot
|
||||
* @param temp
|
||||
*/
|
||||
public Plot(PlotArea area, PlotId id, UUID owner, int temp) {
|
||||
|
@ -174,8 +175,8 @@ public class Plot {
|
|||
*
|
||||
* @see Plot#getPlot(Location) for existing plots
|
||||
*
|
||||
* @param id
|
||||
* @param owner
|
||||
* @param id the plot id
|
||||
* @param owner the plot owner
|
||||
* @param trusted
|
||||
* @param denied
|
||||
* @param merged
|
||||
|
@ -236,7 +237,7 @@ public class Plot {
|
|||
*
|
||||
* @see PlotPlayer#getCurrentPlot() if a player is expected here.
|
||||
*
|
||||
* @param location
|
||||
* @param location the location of the plot
|
||||
* @return
|
||||
*/
|
||||
public static Plot getPlot(Location location) {
|
||||
|
@ -314,7 +315,7 @@ public class Plot {
|
|||
}
|
||||
|
||||
/**
|
||||
* Check if the plot has a set owner
|
||||
* Check if the plot has an owner.
|
||||
*
|
||||
* @return false if there is no owner
|
||||
*/
|
||||
|
@ -324,8 +325,8 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Check if a UUID is a plot owner (merged plots may have multiple owners)
|
||||
* @param uuid
|
||||
* @return
|
||||
* @param uuid the player uuid
|
||||
* @return if the provided uuid is the owner of the plot
|
||||
*/
|
||||
public boolean isOwner(UUID uuid) {
|
||||
if (uuid.equals(this.owner)) {
|
||||
|
@ -349,11 +350,11 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Get a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
|
||||
* @return the Plot owners
|
||||
* @return the plot owners
|
||||
*/
|
||||
public Set<UUID> getOwners() {
|
||||
if (this.owner == null) {
|
||||
return Collections.emptySet();
|
||||
return ImmutableSet.of();
|
||||
}
|
||||
if (isMerged()) {
|
||||
Set<Plot> plots = getConnectedPlots();
|
||||
|
@ -508,7 +509,7 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Check if the plot is merged in any direction.
|
||||
* @return
|
||||
* @return is the plot merged or not
|
||||
*/
|
||||
public boolean isMerged() {
|
||||
return getSettings().getMerged(0) || getSettings().getMerged(2) || getSettings().getMerged(1) || getSettings().getMerged(3);
|
||||
|
@ -518,7 +519,7 @@ public class Plot {
|
|||
* Get the timestamp of when the plot was created (unreliable)<br>
|
||||
* - not accurate if the plot was created before this was implemented<br>
|
||||
* - Milliseconds since the epoch<br>
|
||||
* @return
|
||||
* @return the creation date of the plot
|
||||
*/
|
||||
public long getTimestamp() {
|
||||
if (this.timestamp == 0) {
|
||||
|
@ -583,7 +584,7 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Get the denied users.
|
||||
* @return
|
||||
* @return a set of denied users
|
||||
*/
|
||||
public HashSet<UUID> getDenied() {
|
||||
if (this.denied == null) {
|
||||
|
@ -613,7 +614,7 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Get the trusted users.
|
||||
* @return
|
||||
* @return a set of trusted users
|
||||
*/
|
||||
public HashSet<UUID> getTrusted() {
|
||||
if (this.trusted == null) {
|
||||
|
@ -643,7 +644,7 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Get the members
|
||||
* @return
|
||||
* @return a set of members
|
||||
*/
|
||||
public HashSet<UUID> getMembers() {
|
||||
if (this.members == null) {
|
||||
|
@ -673,7 +674,7 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Deny someone (updates database as well)
|
||||
* @param uuid
|
||||
* @param uuid the uuid of the player to deny.
|
||||
*/
|
||||
public void addDenied(UUID uuid) {
|
||||
for (Plot current : getConnectedPlots()) {
|
||||
|
@ -686,7 +687,7 @@ public class Plot {
|
|||
/**
|
||||
* Add someone as a helper (updates database as well)
|
||||
*
|
||||
* @param uuid
|
||||
* @param uuid the uuid of the player to trust
|
||||
*/
|
||||
public void addTrusted(UUID uuid) {
|
||||
for (Plot current : getConnectedPlots()) {
|
||||
|
@ -699,7 +700,7 @@ public class Plot {
|
|||
/**
|
||||
* Add someone as a trusted user (updates database as well)
|
||||
*
|
||||
* @param uuid
|
||||
* @param uuid the uuid of the player to add as a member
|
||||
*/
|
||||
public void addMember(UUID uuid) {
|
||||
for (Plot current : getConnectedPlots()) {
|
||||
|
@ -942,7 +943,8 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Remove a flag from this plot
|
||||
* @param flag
|
||||
* @param flag the flag to remove
|
||||
* @return
|
||||
*/
|
||||
public boolean removeFlag(Flag<?> flag) {
|
||||
return FlagManager.removePlotFlag(this, flag);
|
||||
|
@ -958,7 +960,8 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Get the flag for a given key
|
||||
* @param key
|
||||
* @param key the flag
|
||||
* @param def if the key is null, the value to return
|
||||
*/
|
||||
public <V> V getFlag(Flag<V> key, V def) {
|
||||
V value = FlagManager.getPlotFlagRaw(this, key);
|
||||
|
@ -1289,18 +1292,18 @@ public class Plot {
|
|||
return this.create(this.owner, true);
|
||||
}
|
||||
|
||||
public boolean claim(final PlotPlayer pp, boolean teleport, String schematic) {
|
||||
if (!canClaim(pp)) {
|
||||
public boolean claim(final PlotPlayer player, boolean teleport, String schematic) {
|
||||
if (!canClaim(player)) {
|
||||
return false;
|
||||
}
|
||||
boolean result = EventUtil.manager.callClaim(pp, this, false);
|
||||
if (!result || !create(pp.getUUID(), true)) {
|
||||
boolean result = EventUtil.manager.callClaim(player, this, false);
|
||||
if (!result || !create(player.getUUID(), true)) {
|
||||
return false;
|
||||
}
|
||||
setSign(pp.getName());
|
||||
MainUtil.sendMessage(pp, C.CLAIMED);
|
||||
setSign(player.getName());
|
||||
MainUtil.sendMessage(player, C.CLAIMED);
|
||||
if (teleport) {
|
||||
teleportPlayer(pp);
|
||||
teleportPlayer(player);
|
||||
}
|
||||
PlotArea plotworld = getArea();
|
||||
if (plotworld.SCHEMATIC_ON_CLAIM) {
|
||||
|
@ -1317,9 +1320,9 @@ public class Plot {
|
|||
@Override
|
||||
public void run(Boolean value) {
|
||||
if (value) {
|
||||
MainUtil.sendMessage(pp, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
} else {
|
||||
MainUtil.sendMessage(pp, C.SCHEMATIC_PASTE_FAILED);
|
||||
MainUtil.sendMessage(player, C.SCHEMATIC_PASTE_FAILED);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1333,7 +1336,7 @@ public class Plot {
|
|||
* - The plot will not be created if the owner is null<br>
|
||||
* - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot
|
||||
* creation.
|
||||
* @param uuid
|
||||
* @param uuid the uuid of the plot owner
|
||||
* @param notify
|
||||
* @return true if plot was created successfully
|
||||
*/
|
||||
|
@ -1384,6 +1387,7 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Get the biome.
|
||||
* @return the name of the biome
|
||||
*/
|
||||
public String getBiome() {
|
||||
Location loc = this.getBottomAbs();
|
||||
|
@ -1408,8 +1412,8 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Swap the settings for two plots.
|
||||
* @param plot
|
||||
* @param whenDone
|
||||
* @param plot the plot to swap data with
|
||||
* @param whenDone the task to run at the end of this method.
|
||||
* @return
|
||||
*/
|
||||
public boolean swapData(Plot plot, Runnable whenDone) {
|
||||
|
@ -1444,27 +1448,27 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Move the settings for a plot.
|
||||
* @param pos2
|
||||
* @param plot the plot to move
|
||||
* @param whenDone
|
||||
* @return
|
||||
*/
|
||||
public boolean moveData(Plot pos2, Runnable whenDone) {
|
||||
public boolean moveData(Plot plot, Runnable whenDone) {
|
||||
if (this.owner == null) {
|
||||
PS.debug(pos2 + " is unowned (single)");
|
||||
PS.debug(plot + " is unowned (single)");
|
||||
TaskManager.runTask(whenDone);
|
||||
return false;
|
||||
}
|
||||
if (pos2.hasOwner()) {
|
||||
PS.debug(pos2 + " is unowned (multi)");
|
||||
if (plot.hasOwner()) {
|
||||
PS.debug(plot + " is unowned (multi)");
|
||||
TaskManager.runTask(whenDone);
|
||||
return false;
|
||||
}
|
||||
this.area.removePlot(this.id);
|
||||
this.getId().x = pos2.getId().x;
|
||||
this.getId().y = pos2.getId().y;
|
||||
this.getId().x = plot.getId().x;
|
||||
this.getId().y = plot.getId().y;
|
||||
this.getId().recalculateHash();
|
||||
this.area.addPlotAbs(this);
|
||||
DBFunc.movePlot(this, pos2);
|
||||
DBFunc.movePlot(this, plot);
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return true;
|
||||
}
|
||||
|
@ -1585,7 +1589,7 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* @deprecated in favor of getCorners()[1];
|
||||
* @return
|
||||
* @return the top corner of the plot
|
||||
*/
|
||||
@Deprecated
|
||||
public Location getTop() {
|
||||
|
@ -2532,8 +2536,8 @@ public class Plot {
|
|||
|
||||
/**
|
||||
* Teleport a player to a plot and send them the teleport message.
|
||||
* @param player The player
|
||||
* @return If the teleportation is allowed.
|
||||
* @param player the player
|
||||
* @return if the teleport succeeded
|
||||
*/
|
||||
public boolean teleportPlayer(final PlotPlayer player) {
|
||||
Plot plot = this.getBasePlot(false);
|
||||
|
@ -2623,7 +2627,7 @@ public class Plot {
|
|||
}
|
||||
|
||||
/**
|
||||
* Merges 2 plots Removes the road inbetween <br>- Assumes plots are directly next to each other <br> - saves to DB
|
||||
* Merges 2 plots Removes the road in-between <br>- Assumes plots are directly next to each other <br> - saves to DB
|
||||
*
|
||||
* @param lesserPlot
|
||||
* @param removeRoads
|
||||
|
|
|
@ -29,19 +29,19 @@ import java.util.UUID;
|
|||
|
||||
public class PlotListener {
|
||||
|
||||
public static boolean plotEntry(final PlotPlayer pp, final Plot plot) {
|
||||
if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
|
||||
public static boolean plotEntry(final PlotPlayer player, final Plot plot) {
|
||||
if (plot.isDenied(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.entry.denied")) {
|
||||
return false;
|
||||
}
|
||||
Plot last = pp.getMeta("lastplot");
|
||||
Plot last = player.getMeta("lastplot");
|
||||
if ((last != null) && !last.getId().equals(plot.getId())) {
|
||||
plotExit(pp, last);
|
||||
plotExit(player, last);
|
||||
}
|
||||
if (ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.handleEntry(pp, plot);
|
||||
ExpireManager.IMP.handleEntry(player, plot);
|
||||
}
|
||||
pp.setMeta("lastplot", plot);
|
||||
EventUtil.manager.callEntry(pp, plot);
|
||||
player.setMeta("lastplot", plot);
|
||||
EventUtil.manager.callEntry(player, plot);
|
||||
if (plot.hasOwner()) {
|
||||
Map<Flag<?>, Object> flags = FlagManager.getPlotFlags(plot);
|
||||
boolean titles = Settings.TITLES;
|
||||
|
@ -54,17 +54,14 @@ public class PlotListener {
|
|||
return true;
|
||||
}
|
||||
} else {
|
||||
Optional<Boolean> titleFlag = plot.getFlag(Flags.TITLES);
|
||||
if (titleFlag.isPresent()) {
|
||||
titles = titleFlag.get();
|
||||
}
|
||||
titles = plot.getFlag(Flags.TITLES, true);
|
||||
Optional<String> greetingFlag = plot.getFlag(Flags.GREETING);
|
||||
if (greetingFlag.isPresent()) {
|
||||
greeting = greetingFlag.get();
|
||||
MainUtil.format(C.PREFIX_GREETING.s() + greeting, plot, pp, false, new RunnableVal<String>() {
|
||||
MainUtil.format(C.PREFIX_GREETING.s() + greeting, plot, player, false, new RunnableVal<String>() {
|
||||
@Override
|
||||
public void run(String value) {
|
||||
MainUtil.sendMessage(pp, value);
|
||||
MainUtil.sendMessage(player, value);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -72,79 +69,79 @@ public class PlotListener {
|
|||
}
|
||||
Optional<Boolean> enter = plot.getFlag(Flags.NOTIFY_ENTER);
|
||||
if (enter.isPresent() && enter.get()) {
|
||||
if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
|
||||
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
|
||||
for (UUID uuid : plot.getOwners()) {
|
||||
PlotPlayer owner = UUIDHandler.getPlayer(uuid);
|
||||
if (owner != null && !owner.getUUID().equals(pp.getUUID())) {
|
||||
if (owner != null && !owner.getUUID().equals(player.getUUID())) {
|
||||
MainUtil.sendMessage(owner,
|
||||
C.NOTIFY_ENTER.s().replace("%player", pp.getName()).replace("%plot", plot.getId().toString()));
|
||||
C.NOTIFY_ENTER.s().replace("%player", player.getName()).replace("%plot", plot.getId().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Optional<PlotGameMode> gamemodeFlag = plot.getFlag(Flags.GAMEMODE);
|
||||
if (gamemodeFlag.isPresent()) {
|
||||
if (pp.getGameMode() != gamemodeFlag.get()) {
|
||||
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
|
||||
pp.setGameMode(gamemodeFlag.get());
|
||||
if (player.getGameMode() != gamemodeFlag.get()) {
|
||||
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
|
||||
player.setGameMode(gamemodeFlag.get());
|
||||
} else {
|
||||
MainUtil.sendMessage(pp,
|
||||
MainUtil.sendMessage(player,
|
||||
StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
||||
if (flyFlag.isPresent()) {
|
||||
pp.setFlight(flyFlag.get());
|
||||
player.setFlight(flyFlag.get());
|
||||
}
|
||||
Optional<Long> timeFlag = plot.getFlag(Flags.TIME);
|
||||
if (timeFlag.isPresent()) {
|
||||
try {
|
||||
long time = timeFlag.get();
|
||||
pp.setTime(time);
|
||||
player.setTime(time);
|
||||
} catch (Exception ignored) {
|
||||
FlagManager.removePlotFlag(plot, Flags.TIME);
|
||||
}
|
||||
}
|
||||
Optional<PlotWeather> weatherFlag = plot.getFlag(Flags.WEATHER);
|
||||
if (weatherFlag.isPresent()) {
|
||||
pp.setWeather(weatherFlag.get());
|
||||
player.setWeather(weatherFlag.get());
|
||||
}
|
||||
|
||||
Optional<Integer> musicFlag = plot.getFlag(Flags.MUSIC);
|
||||
if (musicFlag.isPresent()) {
|
||||
Integer id = musicFlag.get();
|
||||
if ((id >= 2256 && id <= 2267) || (id == 0)) {
|
||||
Location loc = pp.getLocation();
|
||||
Location lastLoc = pp.getMeta("music");
|
||||
Location loc = player.getLocation();
|
||||
Location lastLoc = player.getMeta("music");
|
||||
if (lastLoc != null) {
|
||||
pp.playMusic(lastLoc, 0);
|
||||
player.playMusic(lastLoc, 0);
|
||||
if (id == 0) {
|
||||
pp.deleteMeta("music");
|
||||
player.deleteMeta("music");
|
||||
}
|
||||
}
|
||||
if (id != 0) {
|
||||
try {
|
||||
pp.setMeta("music", loc);
|
||||
pp.playMusic(loc, id);
|
||||
player.setMeta("music", loc);
|
||||
player.playMusic(loc, id);
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Location lastLoc = pp.getMeta("music");
|
||||
Location lastLoc = player.getMeta("music");
|
||||
if (lastLoc != null) {
|
||||
pp.deleteMeta("music");
|
||||
pp.playMusic(lastLoc, 0);
|
||||
player.deleteMeta("music");
|
||||
player.playMusic(lastLoc, 0);
|
||||
}
|
||||
}
|
||||
CommentManager.sendTitle(pp, plot);
|
||||
CommentManager.sendTitle(player, plot);
|
||||
}
|
||||
if (titles) {
|
||||
if (!C.TITLE_ENTERED_PLOT.s().isEmpty() || !C.TITLE_ENTERED_PLOT_SUB.s().isEmpty()) {
|
||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Plot lastPlot = pp.getMeta("lastplot");
|
||||
Plot lastPlot = player.getMeta("lastplot");
|
||||
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId())) {
|
||||
Map<String, String> replacements = new HashMap<>();
|
||||
replacements.put("%x%", String.valueOf(lastPlot.getId().x));
|
||||
|
@ -155,7 +152,7 @@ public class PlotListener {
|
|||
replacements.put("%s", MainUtil.getName(plot.owner));
|
||||
String main = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT.s(), replacements);
|
||||
String sub = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT_SUB.s(), replacements);
|
||||
AbstractTitle.sendTitle(pp, main, sub);
|
||||
AbstractTitle.sendTitle(player, main, sub);
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
|
@ -166,60 +163,60 @@ public class PlotListener {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean plotExit(final PlotPlayer pp, Plot plot) {
|
||||
pp.deleteMeta("lastplot");
|
||||
EventUtil.manager.callLeave(pp, plot);
|
||||
public static boolean plotExit(final PlotPlayer player, Plot plot) {
|
||||
player.deleteMeta("lastplot");
|
||||
EventUtil.manager.callLeave(player, plot);
|
||||
if (plot.hasOwner()) {
|
||||
PlotArea pw = plot.getArea();
|
||||
if (pw == null) {
|
||||
return true;
|
||||
}
|
||||
if (plot.getFlag(Flags.GAMEMODE).isPresent()) {
|
||||
if (pp.getGameMode() != pw.GAMEMODE) {
|
||||
if (!Permissions.hasPermission(pp, "plots.gamemode.bypass")) {
|
||||
pp.setGameMode(pw.GAMEMODE);
|
||||
if (player.getGameMode() != pw.GAMEMODE) {
|
||||
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
|
||||
player.setGameMode(pw.GAMEMODE);
|
||||
} else {
|
||||
MainUtil.sendMessage(pp, StringMan
|
||||
MainUtil.sendMessage(player, StringMan
|
||||
.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.toString(), "{gamemode}", pw.GAMEMODE.name().toLowerCase()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Optional<String> farewell = plot.getFlag(Flags.FAREWELL);
|
||||
if (farewell.isPresent()) {
|
||||
MainUtil.format(C.PREFIX_FAREWELL.s() + farewell.get(), plot, pp, false, new RunnableVal<String>() {
|
||||
MainUtil.format(C.PREFIX_FAREWELL.s() + farewell.get(), plot, player, false, new RunnableVal<String>() {
|
||||
@Override
|
||||
public void run(String value) {
|
||||
MainUtil.sendMessage(pp, value);
|
||||
MainUtil.sendMessage(player, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
Optional<Boolean> leave = plot.getFlag(Flags.NOTIFY_LEAVE);
|
||||
if (leave.isPresent() && leave.get()) {
|
||||
if (!Permissions.hasPermission(pp, "plots.flag.notify-enter.bypass")) {
|
||||
if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) {
|
||||
for (UUID uuid : plot.getOwners()) {
|
||||
PlotPlayer owner = UUIDHandler.getPlayer(uuid);
|
||||
if ((owner != null) && !owner.getUUID().equals(pp.getUUID())) {
|
||||
MainUtil.sendMessage(pp, C.NOTIFY_LEAVE.s().replace("%player", pp.getName()).replace("%plot", plot.getId().toString()));
|
||||
if ((owner != null) && !owner.getUUID().equals(player.getUUID())) {
|
||||
MainUtil.sendMessage(player, C.NOTIFY_LEAVE.s().replace("%player", player.getName()).replace("%plot", plot.getId().toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plot.getFlag(Flags.FLY).isPresent()) {
|
||||
PlotGameMode gamemode = pp.getGameMode();
|
||||
PlotGameMode gamemode = player.getGameMode();
|
||||
if (gamemode == PlotGameMode.SURVIVAL || (gamemode == PlotGameMode.ADVENTURE)) {
|
||||
pp.setFlight(false);
|
||||
player.setFlight(false);
|
||||
}
|
||||
}
|
||||
if (plot.getFlag(Flags.TIME).isPresent()) {
|
||||
pp.setTime(Long.MAX_VALUE);
|
||||
player.setTime(Long.MAX_VALUE);
|
||||
}
|
||||
if (plot.getFlag(Flags.WEATHER).isPresent()) {
|
||||
pp.setWeather(PlotWeather.RESET);
|
||||
player.setWeather(PlotWeather.RESET);
|
||||
}
|
||||
Location lastLoc = pp.getMeta("music");
|
||||
Location lastLoc = player.getMeta("music");
|
||||
if (lastLoc != null) {
|
||||
pp.deleteMeta("music");
|
||||
pp.playMusic(lastLoc, 0);
|
||||
player.deleteMeta("music");
|
||||
player.playMusic(lastLoc, 0);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue