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>
</properties>
<artifactId>PlotSquared</artifactId>
<version>2.11.8</version>
<version>2.11.9</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

@ -291,7 +291,9 @@ public class PlotSquared {
}
public static boolean removePlot(final String world, final PlotId id, final boolean callEvent) {
EventUtil.manager.callDelete(world, id);
if (callEvent) {
EventUtil.manager.callDelete(world, id);
}
plots.get(world).remove(id);
if (MainUtil.lastPlot.containsKey(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) {
final Player player = event.getPlayer();
BukkitUtil.removePlayer(player.getName());
if (!player.hasPlayedBefore()) {
player.saveData();
}
@ -326,7 +327,12 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (plot.isDenied(pp.getUUID())) {
if (!Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.entry.denied");
player.teleport(event.getFrom());
if (!plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(event.getFrom())))) {
player.teleport(event.getFrom());
}
else {
player.teleport(player.getWorld().getSpawnLocation());
}
event.setCancelled(true);
return;
}
@ -367,7 +373,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final Set<Player> recipients = event.getRecipients();
recipients.clear();
for (final Player p : Bukkit.getOnlinePlayers()) {
if (MainUtil.getPlot(BukkitUtil.getLocation(p)) == plot) {
if (MainUtil.getPlot(BukkitUtil.getLocation(p)).equals(plot)) {
recipients.add(p);
}
}
@ -984,6 +990,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (plot != null) {
final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (plot.isDenied(pp.getUUID())) {
System.out.print(2);
if (Permissions.hasPermission(pp, "plots.admin.enter.denied")) {
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) {
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
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()));
}
}
BukkitUtil.removePlayer(pp.getName());
}
@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 sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)).replaceAll("%greeting%", greeting);
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();
}
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 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 {
@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 {
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.setSubtitleColor(sub_color);
title.send(((BukkitPlayer) player).player);
} catch (final Throwable e) {
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 {
@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 {
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.setSubtitleColor(sub_color);
title.send(((BukkitPlayer) player).player);
} catch (final Throwable e) {
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 {
@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 {
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.setSubtitleColor(sub_color);
title.send(((BukkitPlayer) player).player);

View File

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

View File

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