Fixes + titles

- fixed plot deny
- fixed PlotPlayer caching
- more control over titles
This commit is contained in:
boy0001 2015-05-29 01:42:17 +10:00
parent b8c0b6c4a8
commit 48ccc6552b
11 changed files with 30 additions and 24 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.11.8</version> <version>2.11.9</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -291,7 +291,9 @@ public class PlotSquared {
} }
public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) { public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) {
if (callEvent) {
EventUtil.manager.callDelete(world, id); EventUtil.manager.callDelete(world, id);
}
plots.get(world).remove(id); plots.get(world).remove(id);
if (MainUtil.lastPlot.containsKey(world)) { if (MainUtil.lastPlot.containsKey(world)) {
final PlotId last = MainUtil.lastPlot.get(world); final PlotId last = MainUtil.lastPlot.get(world);

View File

@ -257,9 +257,10 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onJoin(final PlayerJoinEvent event) { public void onJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
BukkitUtil.removePlayer(player.getName());
if (!player.hasPlayedBefore()) { if (!player.hasPlayedBefore()) {
player.saveData(); player.saveData();
} }
@ -326,7 +327,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (plot.isDenied(pp.getUUID())) { if (plot.isDenied(pp.getUUID())) {
if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) { if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied"); MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied");
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(event.getFrom())))) {
player.teleport(event.getFrom()); player.teleport(event.getFrom());
}
else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -367,7 +373,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final Set<Player> recipients = event.getRecipients(); final Set<Player> recipients = event.getRecipients();
recipients.clear(); recipients.clear();
for (final Player p : Bukkit.getOnlinePlayers()) { for (final Player p : Bukkit.getOnlinePlayers()) {
if (MainUtil.getPlot(BukkitUtil.getLocation(p)) == plot) { if (MainUtil.getPlot(BukkitUtil.getLocation(p)).equals(plot)) {
recipients.add(p); recipients.add(p);
} }
} }
@ -984,6 +990,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (plot != null) { if (plot != null) {
final PlotPlayer pp = BukkitUtil.getPlayer(player); final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (plot.isDenied(pp.getUUID())) { if (plot.isDenied(pp.getUUID())) {
System.out.print(2);
if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) { if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) {
return; return;
} }
@ -1059,7 +1066,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
@EventHandler @EventHandler(priority= EventPriority.MONITOR)
public void onLeave(final PlayerQuitEvent event) { public void onLeave(final PlayerQuitEvent event) {
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
EventUtil.unregisterPlayer(pp); EventUtil.unregisterPlayer(pp);
@ -1076,6 +1083,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName())); PlotSquared.log(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), event.getPlayer().getName()));
} }
} }
BukkitUtil.removePlayer(pp.getName());
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)

View File

@ -123,7 +123,7 @@ public class PlotListener extends APlotListener {
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); 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);
final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)).replaceAll("%greeting%", greeting); final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)).replaceAll("%greeting%", greeting);
if (AbstractTitle.TITLE_CLASS != null) { if (AbstractTitle.TITLE_CLASS != null) {
AbstractTitle.TITLE_CLASS.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); AbstractTitle.TITLE_CLASS.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()), 1, 2, 1);
} }
} }
{ {

View File

@ -50,7 +50,7 @@ public class CommentManager {
total = count.get(); total = count.get();
} }
if (size.decrementAndGet() == 0 && total > 0) { if (size.decrementAndGet() == 0 && total > 0) {
AbstractTitle.TITLE_CLASS.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total), ChatColor.GOLD, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); AbstractTitle.TITLE_CLASS.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total), ChatColor.GOLD, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()), 1, 2, 1);
} }
} }
}); });

View File

@ -7,5 +7,5 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
public abstract class AbstractTitle { public abstract class AbstractTitle {
public static AbstractTitle TITLE_CLASS; public static AbstractTitle TITLE_CLASS;
public abstract void sendTitle(PlotPlayer player, String head, String sub, ChatColor head_color, ChatColor sub_color); public abstract void sendTitle(PlotPlayer player, String head, String sub, ChatColor head_color, ChatColor sub_color, int in, int delay, int out);
} }

View File

@ -7,15 +7,15 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
public class DefaultTitle extends AbstractTitle { public class DefaultTitle extends AbstractTitle {
@Override @Override
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color) { public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
try { try {
final DefaultTitleManager title = new DefaultTitleManager(head, sub, 1, 2, 1); final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
title.setTitleColor(head_color); title.setTitleColor(head_color);
title.setSubtitleColor(sub_color); title.setSubtitleColor(sub_color);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);
} catch (final Throwable e) { } catch (final Throwable e) {
AbstractTitle.TITLE_CLASS = new DefaultTitle_183(); AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, in, delay, out);
} }
} }
} }

View File

@ -7,15 +7,15 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
public class DefaultTitle_183 extends AbstractTitle { public class DefaultTitle_183 extends AbstractTitle {
@Override @Override
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color) { public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
try { try {
final DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, 1, 2, 1); final DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
title.setTitleColor(head_color); title.setTitleColor(head_color);
title.setSubtitleColor(sub_color); title.setSubtitleColor(sub_color);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);
} catch (final Throwable e) { } catch (final Throwable e) {
AbstractTitle.TITLE_CLASS = new HackTitle(); AbstractTitle.TITLE_CLASS = new HackTitle();
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, in, delay, out);
} }
} }
} }

View File

@ -9,9 +9,9 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
public class HackTitle extends AbstractTitle { public class HackTitle extends AbstractTitle {
@Override @Override
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color) { public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
try { try {
final HackTitleManager title = new HackTitleManager(head, sub, 1, 2, 1); final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
title.setTitleColor(head_color); title.setTitleColor(head_color);
title.setSubtitleColor(sub_color); title.setSubtitleColor(sub_color);
title.send(((BukkitPlayer) player).player); title.send(((BukkitPlayer) player).player);

View File

@ -92,8 +92,6 @@ public class ExpireManager {
expiredPlots.get(world).remove(plot); expiredPlots.get(world).remove(plot);
return; return;
} }
final PlotDeleteEvent event = new PlotDeleteEvent(world, plot.id);
Bukkit.getServer().getPluginManager().callEvent(event);
for (final UUID helper : plot.trusted) { for (final UUID helper : plot.trusted) {
final PlotPlayer player = UUIDHandler.getPlayer(helper); final PlotPlayer player = UUIDHandler.getPlayer(helper);
if (player != null) { if (player != null) {
@ -119,7 +117,7 @@ public class ExpireManager {
manager.clearPlot(plotworld, plot, false, null); manager.clearPlot(plotworld, plot, false, null);
MainUtil.removeSign(plot); MainUtil.removeSign(plot);
DBFunc.delete(world, plot); DBFunc.delete(world, plot);
PlotSquared.removePlot(world, plot.id, true); PlotSquared.removePlot(world, plot.id, false);
expiredPlots.get(world).remove(plot); expiredPlots.get(world).remove(plot);
PlotSquared.log("&cDeleted expired plot: " + plot.id); PlotSquared.log("&cDeleted expired plot: " + plot.id);
PlotSquared.log("&3 - World: " + plot.world); PlotSquared.log("&3 - World: " + plot.world);

View File

@ -34,10 +34,8 @@ public class BukkitUtil extends BlockManager {
private static PlotPlayer lastPlotPlayer = null; private static PlotPlayer lastPlotPlayer = null;
public static void removePlayer(final String plr) { public static void removePlayer(final String plr) {
if ((lastPlayer != null) && lastPlayer.getName().equals(plr)) {
lastPlayer = null; lastPlayer = null;
lastPlotPlayer = null; lastPlotPlayer = null;
}
UUIDHandler.players.remove(plr); UUIDHandler.players.remove(plr);
} }