diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 5c4cd4dcb..1451bb314 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1329,10 +1329,6 @@ public class PlayerEvents extends PlotListener implements Listener { return; } if (checkEntity(entity, plot)) { - PlotPlayer owner = UUIDHandler.getPlayer(plot.owner); - if (owner != null) { - C.ENTITY_CAP.send(owner); - } event.setCancelled(true); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 5e3695e3f..2ab3ecbe1 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -8,6 +8,7 @@ import com.intellectualcrafters.plot.object.PlotItemStack; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.expiry.ExpireManager; import com.plotsquared.general.commands.CommandDeclaration; import java.util.UUID; @@ -35,6 +36,7 @@ public class Info extends SubCommand { case "id": case "size": case "members": + case "seen": case "owner": case "rating": plot = MainUtil.getPlotFromString(player, null, false); @@ -82,7 +84,7 @@ public class Info extends SubCommand { "&cAlias: &6" + plot.getAlias(), "&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + plot.isAdded(uuid), - "&cExpires: &6" + plot.isAdded(uuid), + "&cSeen: &6" + MainUtil.secToTime((int) (ExpireManager.IMP.getAge(plot) / 1000)), "&cIs Denied: &6" + plot.isDenied(uuid))); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users")); @@ -110,7 +112,7 @@ public class Info extends SubCommand { info = getCaption(arg); if (info == null) { MainUtil.sendMessage(player, - "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aexpires&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " + "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, " + "&aowner&7, &arating"); return false; } @@ -149,8 +151,8 @@ public class Info extends SubCommand { return C.PLOT_INFO_OWNER.s(); case "rating": return C.PLOT_INFO_RATING.s(); - case "expires": - return C.PLOT_INFO_EXPIRES.s(); + case "seen": + return C.PLOT_INFO_SEEN.s(); default: return null; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java index 1cd08afe4..d60bb951a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -466,7 +466,7 @@ public enum C { + "$1Biome: $2%biome%$1&-" + "$1Can Build: $2%build%$1&-" + "$1Rating: $2%rating%&-" - + "$1Expires: $2%expires%&-" + + "$1Seen: $2%seen%&-" + "$1Trusted: $2%trusted%$1&-" + "$1Members: $2%members%$1&-" + "$1Denied: $2%denied%$1&-" @@ -482,7 +482,7 @@ public enum C { PLOT_INFO_ID("$1ID:$2 %id%", "Info"), PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"), PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"), - PLOT_INFO_EXPIRES("$1Expires:$2 %expires%", "Info"), + PLOT_INFO_SEEN("$1Seen:$2 %seen%", "Info"), PLOT_USER_LIST(" $1%user%$2,", "Info"), PLOT_FLAG_LIST("$1%s0:%s1$2", "Info"), INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"), @@ -682,7 +682,7 @@ public enum C { } public static String format(C caption, Object... args) { - if (caption.usePrefix()) { + if (caption.usePrefix() && caption.s.length() > 0) { return C.PREFIX.s() + format(caption.s, args); } else { return format(caption.s, args); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index aaa9676d2..342c04d2e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -16,7 +16,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; - +import com.intellectualcrafters.plot.util.expiry.ExpireManager; import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -38,7 +38,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.UUID; -import java.util.concurrent.TimeUnit; /** * plot functions @@ -207,6 +206,39 @@ public class MainUtil { return false; } + public static String secToTime(long time) { + StringBuilder toreturn = new StringBuilder(); + if (time>=33868800) { + int years = (int) (time/33868800); + time-=years*33868800; + toreturn.append(years+"y "); + } + if (time>=604800) { + int weeks = (int) (time/604800); + time-=weeks*604800; + toreturn.append(weeks+"w "); + } + if (time>=86400) { + int days = (int) (time/86400); + time-=days*86400; + toreturn.append(days+"d "); + } + if (time>=3600) { + int hours = (int) (time/3600); + time-=hours*3600; + toreturn.append(hours+"h "); + } + if (time>=60) { + int minutes = (int) (time/60); + time-=minutes*60; + toreturn.append(minutes+"m "); + } + if (toreturn.equals("")||time>0){ + toreturn.append((time)+"s "); + } + return toreturn.toString().trim(); + } + public static long timeToSec(String string) { if (MathMan.isInteger(string)) { return Long.parseLong(string); @@ -687,31 +719,12 @@ public class MainUtil { String trusted = getPlayerList(plot.getTrusted()); String members = getPlayerList(plot.getMembers()); String denied = getPlayerList(plot.getDenied()); - String expires = C.UNKNOWN.s(); + String seen = C.UNKNOWN.s(); if (Settings.Enabled_Components.PLOT_EXPIRY) { - if (plot.hasOwner()) { - Optional keep = plot.getFlag(Flags.KEEP); - if (keep.isPresent()) { - Object value = keep.get(); - if (value instanceof Boolean) { - if (Boolean.TRUE.equals(value)) { - expires = C.NONE.s(); - } - } else if (value instanceof Long) { - if ((Long) value > System.currentTimeMillis()) { - long l = System.currentTimeMillis() - (long) value; - expires = String.format("%d days", TimeUnit.MILLISECONDS.toDays(l)); - } - } - //} else if (ExpireManager.IMP != null) { - //long timestamp = ExpireManager.IMP.getTimestamp(plot.owner); - //long compared = System.currentTimeMillis() - timestamp; - //long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared); - //expires = String.format("%d days", l); - } - } + int time = (int) (ExpireManager.IMP.getAge(plot) / 1000); + seen = MainUtil.secToTime(time); } else { - expires = C.NEVER.s(); + seen = C.NEVER.s(); } Optional descriptionFlag = plot.getFlag(Flags.DESCRIPTION); String description = !descriptionFlag.isPresent() ? C.NONE.s() : Flags.DESCRIPTION.valueToString(descriptionFlag.get()); @@ -742,7 +755,7 @@ public class MainUtil { info = info.replace("%trusted%", trusted); info = info.replace("%helpers%", members); info = info.replace("%denied%", denied); - info = info.replace("%expires%", expires); + info = info.replace("%seen%", seen); info = info.replace("%flags%", flags); info = info.replace("%build%", String.valueOf(build)); info = info.replace("%desc%", "No description set.");