From 5dd2610b5e11c91b230095a5d54195c932888d66 Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Fri, 17 May 2019 18:49:09 -0400 Subject: [PATCH] Misc. changes and removal of title manager --- .../plotsquared/bukkit/BukkitMain.java | 5 ---- .../plotsquared/bukkit/chat/Reflection.java | 12 ++-------- .../bukkit/listeners/PlayerEvents.java | 4 ++-- .../bukkit/object/BukkitPlayer.java | 9 +++---- .../entity/ReplicatingEntityWrapper.java | 19 ++++++++------- .../bukkit/titles/DefaultTitle.java | 15 ------------ .../plotsquared/plot/IPlotMain.java | 7 ------ .../plotsquared/plot/PlotSquared.java | 2 -- .../plotsquared/plot/commands/DebugExec.java | 14 ++++++++--- .../plotsquared/plot/commands/FlagCmd.java | 18 ++++++++++---- .../plotsquared/plot/commands/ListCmd.java | 3 +-- .../plotsquared/plot/commands/Merge.java | 24 ++++++++++++------- .../plotsquared/plot/commands/Owner.java | 10 +++++--- .../plotsquared/plot/config/Captions.java | 12 +++++----- .../plotsquared/plot/database/SQLManager.java | 6 +---- .../plot/listener/PlotListener.java | 9 +++++-- .../plot/object/ConsolePlayer.java | 4 ++++ .../plotsquared/plot/object/Plot.java | 4 +--- .../plotsquared/plot/object/PlotPlayer.java | 15 +++++++++++- .../plotsquared/plot/object/Rating.java | 3 +-- .../plotsquared/plot/util/AbstractTitle.java | 20 ---------------- .../plotsquared/plot/util/ChunkManager.java | 2 +- .../plotsquared/plot/util/CommentManager.java | 8 +++++-- .../plotsquared/plot/util/ConsoleColors.java | 3 +-- .../plotsquared/plot/util/EntityUtil.java | 4 +--- .../plot/util/LegacyConverter.java | 6 ++--- 26 files changed, 112 insertions(+), 126 deletions(-) delete mode 100644 Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/titles/DefaultTitle.java delete mode 100644 Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/AbstractTitle.java diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java index e7d67c3ef..68169328d 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java @@ -7,7 +7,6 @@ import com.github.intellectualsites.plotsquared.bukkit.listeners.PlayerEvents; import com.github.intellectualsites.plotsquared.bukkit.listeners.PlotPlusListener; import com.github.intellectualsites.plotsquared.bukkit.listeners.SingleWorldListener; import com.github.intellectualsites.plotsquared.bukkit.listeners.WorldEvents; -import com.github.intellectualsites.plotsquared.bukkit.titles.DefaultTitle; import com.github.intellectualsites.plotsquared.bukkit.util.*; import com.github.intellectualsites.plotsquared.bukkit.util.block.BukkitLocalQueue; import com.github.intellectualsites.plotsquared.bukkit.uuid.DefaultUUIDWrapper; @@ -766,10 +765,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain return new BukkitSchematicHandler(); } - @Override public AbstractTitle initTitleManager() { - return new DefaultTitle(); - } - @Override @Nullable public PlotPlayer wrapPlayer(final Object player) { if (player instanceof Player) { return BukkitUtil.getPlayer((Player) player); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/chat/Reflection.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/chat/Reflection.java index a92515221..f3f004284 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/chat/Reflection.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/chat/Reflection.java @@ -43,10 +43,6 @@ public final class Reflection { */ public synchronized static String getVersion() { if (_versionString == null) { - if (Bukkit.getServer() == null) { - // The server hasn't started, static initializer call? - return null; - } String name = Bukkit.getServer().getClass().getPackage().getName(); _versionString = name.substring(name.lastIndexOf('.') + 1) + "."; } @@ -180,15 +176,11 @@ public final class Reflection { * @return A method object with the specified name declared by the specified class. */ public synchronized static Method getMethod(Class clazz, String name, Class... args) { - if (!_loadedMethods.containsKey(clazz)) { - _loadedMethods.put(clazz, new HashMap<>()); - } + _loadedMethods.computeIfAbsent(clazz, k -> new HashMap<>()); Map>, Method>> loadedMethodNames = _loadedMethods.get(clazz); - if (!loadedMethodNames.containsKey(name)) { - loadedMethodNames.put(name, new HashMap<>()); - } + loadedMethodNames.computeIfAbsent(name, k -> new HashMap<>()); Map>, Method> loadedSignatures = loadedMethodNames.get(name); ArrayWrapper> wrappedArg = new ArrayWrapper<>(args); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index 7a22be0fb..6c85a2265 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -999,7 +999,7 @@ import java.util.regex.Pattern; } else if ( (location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT) && !Permissions - .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) { + .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { event.setCancelled(true); MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.s() .replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT))); @@ -2984,7 +2984,7 @@ import java.util.regex.Pattern; Plot plot = area.getPlot(location); if (plot != null) { if ((location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT) - && !Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) { + && !Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) { event.setCancelled(true); MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.s() .replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT))); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java index 7b1ce2c54..7a8ad2fc5 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java @@ -84,6 +84,11 @@ public class BukkitPlayer extends PlotPlayer { return true; } + @Override + public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) { + player.sendTitle(title, subtitle, fadeIn, stay, fadeOut); + } + private void callEvent(final Event event) { RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners(); for (RegisteredListener listener : listeners) { @@ -219,8 +224,6 @@ public class BukkitPlayer extends PlotPlayer { this.player.setPlayerWeather(WeatherType.DOWNFALL); break; case RESET: - this.player.resetPlayerWeather(); - break; default: this.player.resetPlayerWeather(); break; @@ -254,8 +257,6 @@ public class BukkitPlayer extends PlotPlayer { this.player.setGameMode(GameMode.SPECTATOR); break; case SURVIVAL: - this.player.setGameMode(GameMode.SURVIVAL); - break; default: this.player.setGameMode(GameMode.SURVIVAL); break; diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/entity/ReplicatingEntityWrapper.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/entity/ReplicatingEntityWrapper.java index c7e0e04f6..769fcc9b3 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/entity/ReplicatingEntityWrapper.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/entity/ReplicatingEntityWrapper.java @@ -1,7 +1,12 @@ package com.github.intellectualsites.plotsquared.bukkit.object.entity; import com.github.intellectualsites.plotsquared.plot.PlotSquared; -import org.bukkit.*; +import org.bukkit.Art; +import org.bukkit.DyeColor; +import org.bukkit.Location; +import org.bukkit.Rotation; +import org.bukkit.TreeSpecies; +import org.bukkit.World; import org.bukkit.block.BlockFace; import org.bukkit.entity.*; import org.bukkit.inventory.EntityEquipment; @@ -576,14 +581,6 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { restoreAgeable((Ageable) entity); restoreLiving((LivingEntity) entity); return entity; - case GUARDIAN: - case ELDER_GUARDIAN: - restoreLiving((LivingEntity) entity); - return entity; - case SKELETON: - case WITHER_SKELETON: - restoreLiving((LivingEntity) entity); - return entity; case ARMOR_STAND: // CHECK positions ArmorStand stand = (ArmorStand) entity; @@ -679,6 +676,10 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { case BLAZE: case SNOWMAN: case SHULKER: + case GUARDIAN: + case ELDER_GUARDIAN: + case SKELETON: + case WITHER_SKELETON: restoreLiving((LivingEntity) entity); return entity; case IRON_GOLEM: diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/titles/DefaultTitle.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/titles/DefaultTitle.java deleted file mode 100644 index e91f8bcae..000000000 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/titles/DefaultTitle.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.intellectualsites.plotsquared.bukkit.titles; - -import com.github.intellectualsites.plotsquared.bukkit.object.BukkitPlayer; -import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; -import com.github.intellectualsites.plotsquared.plot.util.AbstractTitle; -import org.bukkit.entity.Player; - -public class DefaultTitle extends AbstractTitle { - - @Override - public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) { - final Player playerObj = ((BukkitPlayer) player).player; - playerObj.sendTitle(head, sub, in, delay, out); - } -} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/IPlotMain.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/IPlotMain.java index 549da8c05..e1eb152b5 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/IPlotMain.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/IPlotMain.java @@ -249,13 +249,6 @@ public interface IPlotMain extends ILogger { */ @NotNull IndependentPlotGenerator getDefaultGenerator(); - /** - * Gets the class that will manage player titles. - * - * @return - */ - AbstractTitle initTitleManager(); - List getPluginIds(); BlockRegistry getBlockRegistry(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java index 892a5bbe8..122822ffa 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PlotSquared.java @@ -188,8 +188,6 @@ import java.util.zip.ZipInputStream; ChunkManager.manager = this.IMP.initChunkManager(); // Schematic handler SchematicHandler.manager = this.IMP.initSchematicHandler(); - // Titles - AbstractTitle.TITLE_CLASS = this.IMP.initTitleManager(); // Chat ChatManager.manager = this.IMP.initChatManager(); // Commands diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java index 4e533fe61..76d060ed3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java @@ -17,12 +17,21 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.google.common.io.Files; -import javax.script.*; +import javax.script.Bindings; +import javax.script.ScriptContext; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; +import javax.script.ScriptException; +import javax.script.SimpleScriptContext; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.sql.Timestamp; -import java.util.*; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.UUID; @CommandDeclaration(command = "debugexec", permission = "plots.admin", description = "Mutli-purpose debug command", aliases = {"exec", "$"}, @@ -107,7 +116,6 @@ import java.util.*; this.scope.put("WEManager", new WEManager()); } this.scope.put("TaskManager", TaskManager.IMP); - this.scope.put("TitleManager", AbstractTitle.TITLE_CLASS); this.scope.put("ConsolePlayer", ConsolePlayer.getConsole()); this.scope.put("SchematicHandler", SchematicHandler.manager); this.scope.put("ChunkManager", ChunkManager.manager); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCmd.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCmd.java index a732df9a7..470d8d605 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCmd.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/FlagCmd.java @@ -5,12 +5,22 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.database.DBFunc; -import com.github.intellectualsites.plotsquared.plot.flag.*; +import com.github.intellectualsites.plotsquared.plot.flag.Flag; +import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; +import com.github.intellectualsites.plotsquared.plot.flag.Flags; +import com.github.intellectualsites.plotsquared.plot.flag.IntegerFlag; +import com.github.intellectualsites.plotsquared.plot.flag.ListFlag; +import com.github.intellectualsites.plotsquared.plot.flag.PlotBlockListFlag; import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; -import com.github.intellectualsites.plotsquared.plot.util.*; +import com.github.intellectualsites.plotsquared.plot.util.MainUtil; +import com.github.intellectualsites.plotsquared.plot.util.MathMan; +import com.github.intellectualsites.plotsquared.plot.util.Permissions; +import com.github.intellectualsites.plotsquared.plot.util.PlotWeather; +import com.github.intellectualsites.plotsquared.plot.util.StringComparison; +import com.github.intellectualsites.plotsquared.plot.util.StringMan; import java.util.*; @@ -284,9 +294,7 @@ import java.util.*; HashMap> flags = new HashMap<>(); for (Flag flag1 : Flags.getFlags()) { String type = flag1.getClass().getSimpleName(); - if (!flags.containsKey(type)) { - flags.put(type, new ArrayList<>()); - } + flags.computeIfAbsent(type, k -> new ArrayList<>()); flags.get(type).add(flag1.getName()); } StringBuilder message = new StringBuilder(); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java index bd4613409..81834c353 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/ListCmd.java @@ -209,8 +209,7 @@ public class ListCmd extends SubCommand { int p1s = p1.getSettings().getRatings().size(); int p2s = p2.getRatings().size(); if (!p1.getSettings().getRatings().isEmpty()) { - v1 = p1.getRatings().entrySet().stream() - .mapToDouble(entry -> entry.getValue().getAverageRating()) + v1 = p1.getRatings().values().stream().mapToDouble(Rating::getAverageRating) .map(av -> av * av).sum(); v1 /= p1s; v1 += p1s; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Merge.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Merge.java index 970a0d35c..2e68b739c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Merge.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Merge.java @@ -3,8 +3,17 @@ package com.github.intellectualsites.plotsquared.plot.commands; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Settings; -import com.github.intellectualsites.plotsquared.plot.object.*; -import com.github.intellectualsites.plotsquared.plot.util.*; +import com.github.intellectualsites.plotsquared.plot.object.Expression; +import com.github.intellectualsites.plotsquared.plot.object.Location; +import com.github.intellectualsites.plotsquared.plot.object.Plot; +import com.github.intellectualsites.plotsquared.plot.object.PlotArea; +import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; +import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm; +import com.github.intellectualsites.plotsquared.plot.util.EconHandler; +import com.github.intellectualsites.plotsquared.plot.util.MainUtil; +import com.github.intellectualsites.plotsquared.plot.util.Permissions; +import com.github.intellectualsites.plotsquared.plot.util.StringMan; +import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import java.util.UUID; @@ -59,8 +68,7 @@ public class Merge extends SubCommand { } } final PlotArea plotArea = plot.getArea(); - Expression priceExr = - plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : null; + Expression priceExr = plotArea.PRICES.getOrDefault("merge", null); final int size = plot.getConnectedPlots().size(); final double price = priceExr == null ? 0d : priceExr.evaluate((double) size); if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d @@ -97,9 +105,9 @@ public class Merge extends SubCommand { terrain = "true".equalsIgnoreCase(args[1]); } if (!terrain && !Permissions - .hasPermission(player, Captions.PERMISSION_MERGE_KEEPROAD)) { + .hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.PERMISSION_MERGE_KEEPROAD.s()); + Captions.PERMISSION_MERGE_KEEP_ROAD.s()); return true; } if (plot.autoMerge(-1, maxSize, uuid, terrain)) { @@ -134,9 +142,9 @@ public class Merge extends SubCommand { } else { terrain = true; } - if (!terrain && !Permissions.hasPermission(player, Captions.PERMISSION_MERGE_KEEPROAD)) { + if (!terrain && !Permissions.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, - Captions.PERMISSION_MERGE_KEEPROAD.s()); + Captions.PERMISSION_MERGE_KEEP_ROAD.s()); return true; } if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java index 89416512f..8247c0e83 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Owner.java @@ -5,7 +5,11 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; -import com.github.intellectualsites.plotsquared.plot.util.*; +import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm; +import com.github.intellectualsites.plotsquared.plot.util.MainUtil; +import com.github.intellectualsites.plotsquared.plot.util.Permissions; +import com.github.intellectualsites.plotsquared.plot.util.TaskManager; +import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import java.util.Set; import java.util.UUID; @@ -34,7 +38,7 @@ import java.util.UUID; if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value .equalsIgnoreCase("-")) { if (!Permissions - .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SETOWNER.s(), true)) { + .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER.s(), true)) { return false; } Set connected = plot.getConnectedPlots(); @@ -54,7 +58,7 @@ import java.util.UUID; Captions.ALREADY_OWNER.send(player, MainUtil.getName(uuid)); return false; } - if (!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SETOWNER)) { + if (!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER)) { if (other == null) { Captions.INVALID_PLAYER_OFFLINE.send(player, value); return false; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index 0c6f501df..a606b5a3a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -60,8 +60,8 @@ public enum Captions { PERMISSION_ADMIN_ENTRY_DENIED("plots.admin.entry.denied", "static.permissions"), PERMISSION_ADMIN_ENTRY_FORCEFIELD("plots.admin.entry.forcefield", "static.permissions"), PERMISSION_COMMANDS_CHAT("plots.admin.command.chat", "static.permissions"), - PERMISSION_MERGE_OTHER("plots.merge.other", "static.permissions"), - PERMISSION_MERGE_KEEPROAD("plots.merge.keeproad", "static.permissions"), + PERMISSION_MERGE_OTHER("plots.merge.other", "static.permissions"), PERMISSION_MERGE_KEEP_ROAD( + "plots.merge.keeproad", "static.permissions"), PERMISSION_ADMIN_DESTROY_UNOWNED("plots.admin.destroy.unowned", "static.permissions"), PERMISSION_ADMIN_DESTROY_GROUNDLEVEL("plots.admin.destroy.groundlevel", "static.permissions"), PERMISSION_ADMIN_DESTROY_OTHER("plots.admin.destroy.other", "static.permissions"), @@ -71,8 +71,8 @@ public enum Captions { PERMISSION_ADMIN_BUILD_OTHER("plots.admin.build.other", "static.permissions"), PERMISSION_ADMIN_INTERACT_ROAD("plots.admin.interact.road", "static.permissions"), PERMISSION_ADMIN_INTERACT_UNOWNED("plots.admin.interact.unowned", "static.permissions"), - PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"), - PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"), + PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"), PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT( + "plots.admin.build.heightlimit", "static.permissions"), PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "static.permissions"), PERMISSION_ADMIN_COMMAND_RATE("plots.admin.command.rate", "static.permissions"), PERMISSION_ADMIN_COMMAND_TRUST("plots.admin.command.trust", "static.permissions"), @@ -141,8 +141,8 @@ public enum Captions { PERMISSION_LIST_FUZZY("plots.list.fuzzy", "static.permissions"), PERMISSION_LIST_AREA("plots.list.area", "static.permissions"), PERMISSION_ADMIN_COMMAND_LOAD("plots.admin.command.load", "static.permissions"), - PERMISSION_ADMIN_COMMAND_MERGE("plots.admin.command.merge", "static.permissions"), - PERMISSION_ADMIN_COMMAND_SETOWNER("plots.admin.command.setowner", "static.permissions"), + PERMISSION_ADMIN_COMMAND_MERGE("plots.admin.command.merge", "static.permissions"), PERMISSION_ADMIN_COMMAND_SET_OWNER( + "plots.admin.command.setowner", "static.permissions"), PERMISSION_COMMENT("plots.comment", "static.permissions"), PERMISSION_ADMIN_COMMAND_REMOVE("plots.admin.command.remove", "static.permissions"), PERMISSION_ADMIN_COMMAND_SAVE("plots.admin.command.save", "static.permissions"), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java index ed0eee71d..4ac78e122 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/database/SQLManager.java @@ -2538,11 +2538,7 @@ import java.util.concurrent.atomic.AtomicInteger; id = resultSet.getInt("id"); String areaid = resultSet.getString("world"); if (!areas.contains(areaid)) { - if (noExist.containsKey(areaid)) { - noExist.put(areaid, noExist.get(areaid) + 1); - } else { - noExist.put(areaid, 1); - } + noExist.merge(areaid, 1, Integer::sum); } owner = resultSet.getString("owner"); user = uuids.get(owner); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java index c56763a76..5f2260922 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/listener/PlotListener.java @@ -5,7 +5,12 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.flag.Flag; import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.Flags; -import com.github.intellectualsites.plotsquared.plot.object.*; +import com.github.intellectualsites.plotsquared.plot.object.Location; +import com.github.intellectualsites.plotsquared.plot.object.Plot; +import com.github.intellectualsites.plotsquared.plot.object.PlotArea; +import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; +import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; +import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; @@ -171,7 +176,7 @@ public class PlotListener { .replaceFromMap(Captions.TITLE_ENTERED_PLOT.s(), replacements); String sub = StringMan .replaceFromMap(Captions.TITLE_ENTERED_PLOT_SUB.s(), replacements); - AbstractTitle.sendTitle(player, main, sub); + player.sendTitle(main, sub); } }, 20); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java index 6f386b3cb..9a2fb193b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/ConsolePlayer.java @@ -38,6 +38,10 @@ public class ConsolePlayer extends PlotPlayer { return true; } + @Override + public void sendTitle(String title, String subtitle, int fadeIn, int stay, int fadeOut) { + } + @Override public Location getLocation() { return this.getMeta("location"); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index 479bfb923..cd29dfe07 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -1360,9 +1360,7 @@ public class Plot { public Map getLikes() { final Map map = new HashMap<>(); final Map ratings = this.getRatings(); - ratings.forEach((uuid, rating) -> { - map.put(uuid, rating.getLike()); - }); + ratings.forEach((uuid, rating) -> map.put(uuid, rating.getLike())); return map; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java index dd2dc28b5..0c7c4a936 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java @@ -16,7 +16,11 @@ import lombok.NonNull; import javax.annotation.Nonnull; import java.nio.ByteBuffer; -import java.util.*; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; @@ -340,6 +344,15 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { return result; } + public void sendTitle(String title, String subtitle) { + sendTitle(title, subtitle, 1, 2, 1); + } + + ; + + public abstract void sendTitle(String title, String subtitle, int fadeIn, int stay, + int fadeOut); + /** * Teleport this player to a location. * diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Rating.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Rating.java index 00fe5bcc2..911b2e6c5 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Rating.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Rating.java @@ -5,7 +5,6 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings; import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import java.util.Map.Entry; import java.util.stream.IntStream; public class Rating { @@ -55,7 +54,7 @@ public class Rating { if (Settings.Ratings.USE_LIKES) { return getLike() ? 10 : 1; } - double total = this.ratingMap.entrySet().stream().mapToDouble(Entry::getValue).sum(); + double total = this.ratingMap.values().stream().mapToDouble(v -> v).sum(); return total / this.ratingMap.size(); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/AbstractTitle.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/AbstractTitle.java deleted file mode 100644 index a5f75c96a..000000000 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/AbstractTitle.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.github.intellectualsites.plotsquared.plot.util; - -import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer; -import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; - -public abstract class AbstractTitle { - public static AbstractTitle TITLE_CLASS; - - public static void sendTitle(PlotPlayer player, String head, String sub) { - if (player instanceof ConsolePlayer) { - return; - } - if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) { - TITLE_CLASS.sendTitle(player, head, sub, 1, 2, 1); - } - } - - public abstract void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, - int out); -} diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ChunkManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ChunkManager.java index 101ec301a..a960bc6db 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ChunkManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ChunkManager.java @@ -136,7 +136,7 @@ public abstract class ChunkManager { } /** - * The int[] will be in the form: [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge] and will represent the bottom and top parts of the chunk + * The int[] will be in the form: [chunkX, chunkZ, pos1x, pos1z, pos2x, pos2z, isEdge] and will represent the bottom and top parts of the chunk * * @param pos1 * @param pos2 diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/CommentManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/CommentManager.java index 416f0aa46..bd5356be1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/CommentManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/CommentManager.java @@ -5,7 +5,11 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; -import com.github.intellectualsites.plotsquared.plot.object.comment.*; +import com.github.intellectualsites.plotsquared.plot.object.comment.CommentInbox; +import com.github.intellectualsites.plotsquared.plot.object.comment.InboxOwner; +import com.github.intellectualsites.plotsquared.plot.object.comment.InboxPublic; +import com.github.intellectualsites.plotsquared.plot.object.comment.InboxReport; +import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment; import java.util.Collection; import java.util.HashMap; @@ -40,7 +44,7 @@ public class CommentManager { total = count.get(); } if ((size.decrementAndGet() == 0) && (total > 0)) { - AbstractTitle.sendTitle(player, "", + player.sendTitle("", Captions.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total)); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ConsoleColors.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ConsoleColors.java index 5e9c87a7a..f8860887f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ConsoleColors.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/ConsoleColors.java @@ -34,8 +34,6 @@ public class ConsoleColors { public static ConsoleColor chatColor(final String color) { switch (color) { - case "&r": - return ConsoleColor.RESET; case "&7": case "&8": return ConsoleColor.WHITE; @@ -65,6 +63,7 @@ public class ConsoleColors { return ConsoleColor.ITALIC; case "&l": return ConsoleColor.BOLD; + case "&r": default: return ConsoleColor.RESET; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EntityUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EntityUtil.java index fa543b21a..51e093d46 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EntityUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/EntityUtil.java @@ -15,9 +15,6 @@ import lombok.experimental.UtilityClass; private static int capNumeral(@NonNull final String flagName) { int i; switch (flagName) { - case "entity-cap": - i = 0; - break; case "mob-cap": i = 3; break; @@ -33,6 +30,7 @@ import lombok.experimental.UtilityClass; case "misc-cap": i = 5; break; + case "entity-cap": default: i = 0; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/LegacyConverter.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/LegacyConverter.java index 55d86ce5a..dfbc0b3eb 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/LegacyConverter.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/LegacyConverter.java @@ -51,9 +51,7 @@ import java.util.Map; private BlockBucket blockListToBucket(@NonNull final PlotBlock[] blocks) { final Map counts = new HashMap<>(); for (final PlotBlock block : blocks) { - if (!counts.containsKey(block)) { - counts.put(block, 0); - } + counts.putIfAbsent(block, 0); counts.put(block, counts.get(block) + 1); } boolean includeRatios = false; @@ -66,7 +64,7 @@ import java.util.Map; final BlockBucket bucket = new BlockBucket(); if (includeRatios) { for (final Map.Entry count : counts.entrySet()) { - bucket.addBlock(count.getKey(), (int) (count.getValue())); + bucket.addBlock(count.getKey(), count.getValue()); } } else { counts.keySet().forEach(bucket::addBlock);