mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Optimized player move event
This commit is contained in:
parent
35fa448252
commit
d2bd642929
@ -200,7 +200,7 @@ public class Info extends SubCommand {
|
|||||||
final String members = getPlayerList(plot.members);
|
final String members = getPlayerList(plot.members);
|
||||||
final String denied = getPlayerList(plot.denied);
|
final String denied = getPlayerList(plot.denied);
|
||||||
|
|
||||||
final String flags = StringMan.replaceFromMap("$2" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "$1, $2") : C.NONE.s()), C.replacements);
|
final String flags = StringMan.replaceFromMap("$2" + (StringUtils.join(FlagManager.getPlotFlags(plot).values(), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot).values(), "$1, $2") : C.NONE.s()), C.replacements);
|
||||||
final boolean build = (player == null) || plot.isAdded(player.getUUID());
|
final boolean build = (player == null) || plot.isAdded(player.getUUID());
|
||||||
|
|
||||||
String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
|
String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
|
||||||
|
@ -237,21 +237,20 @@ public class FlagManager {
|
|||||||
* @param plot
|
* @param plot
|
||||||
* @return set of flags
|
* @return set of flags
|
||||||
*/
|
*/
|
||||||
public static Collection<Flag> getPlotFlags(final Plot plot) {
|
public static HashMap<String, Flag> getPlotFlags(final Plot plot) {
|
||||||
return getSettingFlags(plot.world, plot.settings);
|
return getSettingFlags(plot.world, plot.settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Collection<Flag> getSettingFlags(final String world, final PlotSettings settings) {
|
public static HashMap<String, Flag> getSettingFlags(final String world, final PlotSettings settings) {
|
||||||
PlotWorld plotworld = PS.get().getPlotWorld(world);
|
PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||||
HashMap<String, Flag> map;
|
if (plotworld == null || plotworld.DEFAULT_FLAGS.size() == 0) {
|
||||||
if (plotworld == null) {
|
return settings.flags;
|
||||||
map = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
map = (HashMap<String, Flag>) plotworld.DEFAULT_FLAGS.clone();
|
HashMap<String, Flag> map = (HashMap<String, Flag>) plotworld.DEFAULT_FLAGS.clone();
|
||||||
|
map.putAll(settings.flags);
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
map.putAll(settings.flags);
|
|
||||||
return map.values();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean removePlotFlag(final Plot plot, final String id) {
|
public static boolean removePlotFlag(final Plot plot, final String id) {
|
||||||
|
@ -7,7 +7,7 @@ public abstract class APlotListener {
|
|||||||
|
|
||||||
public static APlotListener manager;
|
public static APlotListener manager;
|
||||||
|
|
||||||
public abstract void plotExit(final PlotPlayer player, final Plot plot);
|
public abstract boolean plotEntry(final PlotPlayer player, final Plot plot);
|
||||||
|
|
||||||
public abstract void plotEntry(final PlotPlayer player, final Plot plot);
|
public abstract boolean plotExit(final PlotPlayer player, final Plot plot);
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
import com.intellectualcrafters.plot.object.PlotHandler;
|
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotInventory;
|
import com.intellectualcrafters.plot.object.PlotInventory;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
@ -352,67 +353,136 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
}
|
}
|
||||||
plotEntry(pp, plot);
|
plotEntry(pp, plot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void PlayerMove(final PlayerMoveEvent event) {
|
public void PlayerMove(final PlayerMoveEvent event) {
|
||||||
final Location f = BukkitUtil.getLocation(event.getFrom());
|
org.bukkit.Location from = event.getFrom();
|
||||||
final Location t = BukkitUtil.getLocation(event.getTo());
|
org.bukkit.Location to = event.getTo();
|
||||||
if ((f.getX() != t.getX()) || (f.getZ() != t.getZ())) {
|
int x1, x2;
|
||||||
final Player player = event.getPlayer();
|
if ((x1 = (int) from.getX()) != (x2 = (int) to.getX()) ) {
|
||||||
if (Settings.TELEPORT_DELAY != 0) {
|
String worldname = to.getWorld().getName();
|
||||||
TaskManager.TELEPORT_QUEUE.remove(player.getName());
|
PlotWorld plotworld = PS.get().getPlotWorld(worldname);
|
||||||
}
|
if (plotworld == null) {
|
||||||
final String worldname = t.getWorld();
|
|
||||||
if (!PS.get().isPlotWorld(worldname)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MainUtil.worldBorder.containsKey(worldname)) {
|
PlotManager plotManager = PS.get().getPlotManager(worldname);
|
||||||
final int border = MainUtil.getBorder(worldname);
|
PlotId id = plotManager.getPlotId(plotworld, x2, 0, (int) to.getZ());
|
||||||
boolean passed = true;
|
Player player = event.getPlayer();
|
||||||
if (t.getX() > border) {
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
event.getTo().setX(border);
|
PlotId lastId = (PlotId) pp.getMeta("lastplotid");
|
||||||
} else if (t.getX() < -border) {
|
if (id == null) {
|
||||||
event.getTo().setX(-border);
|
if (lastId == null) {
|
||||||
} else if (t.getZ() > border) {
|
return;
|
||||||
event.getTo().setZ(border);
|
|
||||||
} else if (t.getZ() < -border) {
|
|
||||||
event.getTo().setZ(-border);
|
|
||||||
} else {
|
|
||||||
passed = false;
|
|
||||||
}
|
}
|
||||||
if (passed) {
|
Plot plot = MainUtil.getPlot(worldname, lastId);
|
||||||
|
if (!plotExit(pp, plot)) {
|
||||||
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.exit.denied");
|
||||||
|
if (plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||||
|
player.teleport(from);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (id.equals(lastId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Plot plot = MainUtil.getPlot(worldname, id);
|
||||||
|
if (!plotEntry(pp, plot)) {
|
||||||
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied");
|
||||||
|
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||||
|
player.teleport(from);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Integer border = MainUtil.worldBorder.get(worldname);
|
||||||
|
if (border != null) {
|
||||||
|
if (x2 > border) {
|
||||||
|
to.setX(border - 4);
|
||||||
|
player.teleport(event.getTo());
|
||||||
|
MainUtil.sendMessage(pp, C.BORDER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (x2 < -border) {
|
||||||
|
to.setX(-border + 4);
|
||||||
player.teleport(event.getTo());
|
player.teleport(event.getTo());
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
|
||||||
MainUtil.sendMessage(pp, C.BORDER);
|
MainUtil.sendMessage(pp, C.BORDER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Plot plot = MainUtil.getPlot(t);
|
return;
|
||||||
if (plot != null) {
|
}
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
int z1, z2;
|
||||||
if (plot.denied.size() > 0) {
|
if ((z1 = (int) from.getZ()) != (z2 = (int) to.getZ()) ) {
|
||||||
if (plot.isDenied(pp.getUUID())) {
|
String worldname = to.getWorld().getName();
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
|
PlotWorld plotworld = PS.get().getPlotWorld(worldname);
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied");
|
if (plotworld == null) {
|
||||||
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(event.getFrom())))) {
|
return;
|
||||||
player.teleport(event.getFrom());
|
}
|
||||||
}
|
PlotManager plotManager = PS.get().getPlotManager(worldname);
|
||||||
else {
|
PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
Player player = event.getPlayer();
|
||||||
}
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
event.setCancelled(true);
|
PlotId lastId = (PlotId) pp.getMeta("lastplotid");
|
||||||
return;
|
if (id == null) {
|
||||||
}
|
if (lastId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Plot plot = MainUtil.getPlot(worldname, lastId);
|
||||||
|
if (!plotExit(pp, plot)) {
|
||||||
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.exit.denied");
|
||||||
|
if (plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||||
|
player.teleport(from);
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
if (!plot.equals(MainUtil.getPlot(f))) {
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
plotEntry(pp, plot);
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (MainUtil.leftPlot(f, t)) {
|
else if (id.equals(lastId)) {
|
||||||
plot = MainUtil.getPlot(f);
|
return;
|
||||||
plotExit(BukkitUtil.getPlayer(player), plot);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Plot plot = MainUtil.getPlot(worldname, id);
|
||||||
|
if (!plotEntry(pp, plot)) {
|
||||||
|
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied");
|
||||||
|
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||||
|
player.teleport(from);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Integer border = MainUtil.worldBorder.get(worldname);
|
||||||
|
if (border != null) {
|
||||||
|
if (z2 > border) {
|
||||||
|
to.setZ(border - 4);
|
||||||
|
player.teleport(event.getTo());
|
||||||
|
MainUtil.sendMessage(pp, C.BORDER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (z2 < -border) {
|
||||||
|
to.setZ(-border + 4);
|
||||||
|
player.teleport(event.getTo());
|
||||||
|
MainUtil.sendMessage(pp, C.BORDER);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1221,7 +1291,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
|||||||
} else {
|
} else {
|
||||||
if (MainUtil.leftPlot(f, t)) {
|
if (MainUtil.leftPlot(f, t)) {
|
||||||
final Plot plot2 = MainUtil.getPlot(f);
|
final Plot plot2 = MainUtil.getPlot(f);
|
||||||
APlotListener.manager.plotExit(BukkitUtil.getPlayer(player), plot2);
|
plotExit(BukkitUtil.getPlayer(player), plot2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) {
|
if ((q.getX() >= 29999999) || (q.getX() <= -29999999) || (q.getZ() >= 29999999) || (q.getZ() <= -29999999)) {
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
package com.intellectualcrafters.plot.listeners;
|
package com.intellectualcrafters.plot.listeners;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -41,9 +44,15 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
|||||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||||
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
import com.intellectualcrafters.plot.object.BukkitPlayer;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.comment.CommentManager;
|
import com.intellectualcrafters.plot.object.comment.CommentManager;
|
||||||
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,83 +103,118 @@ public class PlotListener extends APlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void plotEntry(final PlotPlayer pp, final Plot plot) {
|
public boolean plotEntry(final PlotPlayer pp, final Plot plot) {
|
||||||
|
if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
pp.setMeta("lastplotid", plot.id);
|
||||||
final Player player = ((BukkitPlayer) pp).player;
|
final Player player = ((BukkitPlayer) pp).player;
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
final Flag gamemodeFlag = FlagManager.getPlotFlag(plot, "gamemode");
|
final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
|
||||||
if (gamemodeFlag != null) {
|
Bukkit.getPluginManager().callEvent(callEvent);
|
||||||
player.setGameMode(getGameMode(gamemodeFlag.getValueString()));
|
|
||||||
}
|
HashMap<String, Flag> flags = FlagManager.getPlotFlags(plot);
|
||||||
final Flag flyFlag = FlagManager.getPlotFlag(plot, "fly");
|
int size = flags.size();
|
||||||
if (flyFlag != null) {
|
boolean titles = Settings.TITLES;
|
||||||
player.setAllowFlight((boolean) flyFlag.getValue());
|
final String greeting;
|
||||||
}
|
|
||||||
final Flag timeFlag = FlagManager.getPlotFlag(plot, "time");
|
if (size != 0) {
|
||||||
if (timeFlag != null) {
|
Flag titleFlag = flags.get("titles");
|
||||||
try {
|
titles = (Boolean) titleFlag.getValue();
|
||||||
final long time = (long) timeFlag.getValue();
|
Flag greetingFlag = flags.get("greeting");
|
||||||
player.setPlayerTime(time, false);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
FlagManager.removePlotFlag(plot, "time");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final Flag weatherFlag = FlagManager.getPlotFlag(plot, "weather");
|
|
||||||
if (weatherFlag != null) {
|
|
||||||
setWeather(player, weatherFlag.getValueString());
|
|
||||||
}
|
|
||||||
if ((FlagManager.isBooleanFlag(plot, "titles", Settings.TITLES)) && (C.TITLE_ENTERED_PLOT.s().length() > 2)) {
|
|
||||||
Flag greetingFlag = FlagManager.getPlotFlag(plot, "greeting");
|
|
||||||
String greeting;
|
|
||||||
if (greetingFlag != null) {
|
if (greetingFlag != null) {
|
||||||
greeting = greetingFlag.getValue() + "";
|
greeting = (String) greetingFlag.getValue();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
greeting = "";
|
greeting = "";
|
||||||
}
|
}
|
||||||
String alias = plot.settings.getAlias();
|
|
||||||
if (alias.length() == 0) {
|
final Flag gamemodeFlag = flags.get("gamemode");
|
||||||
alias = plot.toString();
|
if (gamemodeFlag != null) {
|
||||||
|
player.setGameMode(getGameMode(gamemodeFlag.getValueString()));
|
||||||
}
|
}
|
||||||
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceAll("%s", getName(plot.owner)).replaceAll("%alias%", alias);
|
final Flag flyFlag = flags.get("fly");
|
||||||
final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceAll("%s", getName(plot.owner)).replaceAll("%alias%", alias);
|
if (flyFlag != null) {
|
||||||
AbstractTitle.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()));
|
player.setAllowFlight((boolean) flyFlag.getValue());
|
||||||
}
|
}
|
||||||
{
|
final Flag timeFlag = flags.get("time");
|
||||||
final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
|
if (timeFlag != null) {
|
||||||
Bukkit.getPluginManager().callEvent(callEvent);
|
try {
|
||||||
}
|
final long time = (long) timeFlag.getValue();
|
||||||
Flag musicFlag = FlagManager.getPlotFlag(plot, "music");
|
player.setPlayerTime(time, false);
|
||||||
if (musicFlag != null) {
|
} catch (final Exception e) {
|
||||||
final Integer id = (Integer) musicFlag.getValue();
|
FlagManager.removePlotFlag(plot, "time");
|
||||||
if ((id >= 2256 && id <= 2267) || id == 0) {
|
}
|
||||||
final org.bukkit.Location loc = player.getLocation();
|
}
|
||||||
|
final Flag weatherFlag = flags.get("weather");
|
||||||
|
if (weatherFlag != null) {
|
||||||
|
setWeather(player, weatherFlag.getValueString());
|
||||||
|
}
|
||||||
|
|
||||||
|
Flag musicFlag = flags.get("music");
|
||||||
|
if (musicFlag != null) {
|
||||||
|
final Integer id = (Integer) musicFlag.getValue();
|
||||||
|
if ((id >= 2256 && id <= 2267) || id == 0) {
|
||||||
|
final org.bukkit.Location loc = player.getLocation();
|
||||||
|
org.bukkit.Location lastLoc = (org.bukkit.Location) pp.getMeta("music");
|
||||||
|
if (lastLoc != null) {
|
||||||
|
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
|
||||||
|
if (id == 0) {
|
||||||
|
pp.deleteMeta("music");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
pp.setMeta("music", loc);
|
||||||
|
player.playEffect(loc, Effect.RECORD_PLAY, Material.getMaterial(id));
|
||||||
|
}
|
||||||
|
catch (Exception e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
org.bukkit.Location lastLoc = (org.bukkit.Location) pp.getMeta("music");
|
org.bukkit.Location lastLoc = (org.bukkit.Location) pp.getMeta("music");
|
||||||
if (lastLoc != null) {
|
if (lastLoc != null) {
|
||||||
|
pp.deleteMeta("music");
|
||||||
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
|
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
|
||||||
if (id == 0) {
|
|
||||||
pp.deleteMeta("music");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
pp.setMeta("music", loc);
|
|
||||||
player.playEffect(loc, Effect.RECORD_PLAY, Material.getMaterial(id));
|
|
||||||
}
|
|
||||||
catch (Exception e) {}
|
|
||||||
}
|
}
|
||||||
|
CommentManager.sendTitle(pp, plot);
|
||||||
|
}
|
||||||
|
else if (titles) {
|
||||||
|
greeting = "";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
org.bukkit.Location lastLoc = (org.bukkit.Location) pp.getMeta("music");
|
return true;
|
||||||
if (lastLoc != null) {
|
}
|
||||||
pp.deleteMeta("music");
|
if (titles) {
|
||||||
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
|
if (C.TITLE_ENTERED_PLOT.s().length() != 0 || C.TITLE_ENTERED_PLOT_SUB.s().length() != 0) {
|
||||||
|
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
PlotId id = (PlotId) pp.getMeta("lastplotid");
|
||||||
|
if (plot.id.equals(id)) {
|
||||||
|
Map<String, String> replacements = new HashMap<>();
|
||||||
|
replacements.put("%x%", id.x + "");
|
||||||
|
replacements.put("%z%", id.y + "");
|
||||||
|
replacements.put("%world%", plot.world);
|
||||||
|
replacements.put("%greeting%", greeting);
|
||||||
|
replacements.put("%alias", plot.toString());
|
||||||
|
replacements.put("%s", 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, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CommentManager.sendTitle(pp, plot);
|
return true;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void plotExit(final PlotPlayer pp, final Plot plot) {
|
public boolean plotExit(final PlotPlayer pp, final Plot plot) {
|
||||||
|
pp.deleteMeta("lastplotid");
|
||||||
Player player = ((BukkitPlayer) pp).player;
|
Player player = ((BukkitPlayer) pp).player;
|
||||||
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
||||||
Bukkit.getPluginManager().callEvent(callEvent);
|
Bukkit.getPluginManager().callEvent(callEvent);
|
||||||
@ -191,6 +235,7 @@ public class PlotListener extends APlotListener {
|
|||||||
pp.deleteMeta("music");
|
pp.deleteMeta("music");
|
||||||
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
|
player.playEffect(lastLoc, Effect.RECORD_PLAY, 0);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getFlagValue(final String value) {
|
public boolean getFlagValue(final String value) {
|
||||||
|
@ -879,7 +879,6 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
final Player player = (Player) entity;
|
final Player player = (Player) entity;
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
pp.teleport(MainUtil.getDefaultHome(plot));
|
pp.teleport(MainUtil.getDefaultHome(plot));
|
||||||
APlotListener.manager.plotExit(pp, plot);
|
|
||||||
} else {
|
} else {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user