From 898dace3c17c6c9c00be92b39136828700414a98 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Fri, 8 Apr 2022 00:01:02 -0500 Subject: [PATCH 1/6] Set different verbosity levels for the update messages --- .../java/dev/plex/command/impl/PlexCMD.java | 4 ++-- .../services/impl/UpdateCheckerService.java | 2 +- .../java/dev/plex/util/UpdateChecker.java | 22 ++++++++++++------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/dev/plex/command/impl/PlexCMD.java b/src/main/java/dev/plex/command/impl/PlexCMD.java index c6baa8e..bec340b 100644 --- a/src/main/java/dev/plex/command/impl/PlexCMD.java +++ b/src/main/java/dev/plex/command/impl/PlexCMD.java @@ -38,7 +38,7 @@ public class PlexCMD extends PlexCommand send(sender, mmString("Authors: Telesphoreo, Taahh")); send(sender, mmString("Built by: " + Plex.build.author + " on " + Plex.build.date)); send(sender, mmString("Run /plex modules to see a list of modules.")); - plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, true); + plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, 2); return null; } if (args[0].equalsIgnoreCase("reload")) @@ -95,7 +95,7 @@ public class PlexCMD extends PlexCommand { return messageComponent("noPermissionRank", "a developer"); } - if (!plugin.getUpdateChecker().getUpdateStatusMessage(sender, false, false)) + if (!plugin.getUpdateChecker().getUpdateStatusMessage(sender, false, 0)) { return mmString("Plex is already up to date!"); } diff --git a/src/main/java/dev/plex/services/impl/UpdateCheckerService.java b/src/main/java/dev/plex/services/impl/UpdateCheckerService.java index 494a801..418de7e 100644 --- a/src/main/java/dev/plex/services/impl/UpdateCheckerService.java +++ b/src/main/java/dev/plex/services/impl/UpdateCheckerService.java @@ -17,7 +17,7 @@ public class UpdateCheckerService extends AbstractService { if (!newVersion) { - if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender(), false, false)) + if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender(), false, 1)) { newVersion = true; } diff --git a/src/main/java/dev/plex/util/UpdateChecker.java b/src/main/java/dev/plex/util/UpdateChecker.java index 8bca755..2b54520 100644 --- a/src/main/java/dev/plex/util/UpdateChecker.java +++ b/src/main/java/dev/plex/util/UpdateChecker.java @@ -82,7 +82,10 @@ public class UpdateChecker extends PlexBase } } - public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, boolean verbose) + // If verbose is 0, it will display nothing + // If verbose is 1, it will only display a message if there is an update available + // If verbose is 2, it will display all messages + public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, int verbosity) { if (branch == null) { @@ -112,30 +115,33 @@ public class UpdateChecker extends PlexBase switch (distance) { case -1 -> { - if (verbose) + if (verbosity == 2) { sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED)); } return false; } case 0 -> { - if (verbose) + if (verbosity == 2) { - sender.sendMessage(Component.text("Your version of Plex is up to date!").color(NamedTextColor.GREEN)); + sender.sendMessage(Component.text("Plex is up to date!").color(NamedTextColor.GREEN)); } return false; } case -2 -> { - if (verbose) + if (verbosity == 2) { sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED)); } return false; } default -> { - sender.sendMessage(Component.text("Your version of Plex is not up to date!", NamedTextColor.RED)); - sender.sendMessage(Component.text("Download a new version at: " + DOWNLOAD_PAGE).color(NamedTextColor.RED)); - sender.sendMessage(Component.text("Or run: /plex update").color(NamedTextColor.RED)); + if (verbosity >= 1) + { + sender.sendMessage(Component.text("Plex is not up to date!", NamedTextColor.RED)); + sender.sendMessage(Component.text("Download a new version at: " + DOWNLOAD_PAGE).color(NamedTextColor.RED)); + sender.sendMessage(Component.text("Or run: /plex update").color(NamedTextColor.RED)); + } return true; } } From 6071567eb3718d58ff563dad82ee730da19e0674 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Fri, 8 Apr 2022 00:03:59 -0500 Subject: [PATCH 2/6] Add some color --- src/main/java/dev/plex/util/UpdateChecker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/dev/plex/util/UpdateChecker.java b/src/main/java/dev/plex/util/UpdateChecker.java index 2b54520..4a03dd1 100644 --- a/src/main/java/dev/plex/util/UpdateChecker.java +++ b/src/main/java/dev/plex/util/UpdateChecker.java @@ -162,7 +162,7 @@ public class UpdateChecker extends PlexBase JSONObject object = new JSONObject(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8)); JSONObject artifact = object.getJSONArray("artifacts").getJSONObject(0); String name = artifact.getString("fileName"); - sendMini(sender, "Downloading latest Plex jar file: " + name); + sendMini(sender, "Downloading latest Plex jar file: " + name); CompletableFuture.runAsync(() -> { try @@ -171,7 +171,7 @@ public class UpdateChecker extends PlexBase new URL(DOWNLOAD_PAGE + "job/" + branch + "/lastSuccessfulBuild/artifact/build/libs/" + name), new File(Bukkit.getUpdateFolderFile(), name) ); - sendMini(sender, "Saved new jar. Please restart your server."); + sendMini(sender, "Saved new jar. Please restart your server."); } catch (IOException e) { From def099c3a33f4de3e9551fdddc09b2cf5c1f845d Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Fri, 8 Apr 2022 01:06:34 -0500 Subject: [PATCH 3/6] Band aid fix --- .../dev/plex/listener/impl/WorldListener.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/plex/listener/impl/WorldListener.java b/src/main/java/dev/plex/listener/impl/WorldListener.java index a5c223b..83a0930 100644 --- a/src/main/java/dev/plex/listener/impl/WorldListener.java +++ b/src/main/java/dev/plex/listener/impl/WorldListener.java @@ -1,6 +1,7 @@ package dev.plex.listener.impl; import dev.plex.Plex; +import dev.plex.cache.DataUtils; import dev.plex.cache.player.PlayerCache; import dev.plex.listener.PlexListener; import dev.plex.player.PlexPlayer; @@ -12,6 +13,7 @@ import java.util.Arrays; import java.util.List; import java.util.Locale; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -19,11 +21,12 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntitySpawnEvent; +import org.bukkit.event.player.PlayerChangedWorldEvent; +import org.bukkit.event.player.PlayerTeleportEvent; import org.jetbrains.annotations.NotNull; public class WorldListener extends PlexListener { - @EventHandler public void onBlockPlace(BlockPlaceEvent e) { @@ -118,6 +121,18 @@ public class WorldListener extends PlexListener e.setCancelled(true); } + // TODO: Add an entry setting in the config.yml and allow checking for all worlds + @EventHandler + public void onWorldTeleport(PlayerTeleportEvent e) + { + final World adminworld = Bukkit.getWorld("adminworld"); + PlexPlayer plexPlayer = DataUtils.getPlayer(e.getPlayer().getUniqueId()); + if (e.getTo().getWorld().equals(adminworld) && !plexPlayer.isAdminActive()) + { + e.setCancelled(true); + } + } + private boolean checkLevel(PlexPlayer player, String[] requiredList) { PlexLog.debug("Checking world required levels " + Arrays.toString(requiredList)); From e402cd1fe501fe94ff83f1cbbe0c99e0944a715e Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Fri, 8 Apr 2022 01:26:18 -0500 Subject: [PATCH 4/6] Reorganize the config --- src/main/resources/config.yml | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ba5a180..d3c17c0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -22,7 +22,8 @@ chat: # If you are using permissions, you should turn this off and use Vault to handle prefixes with a different chat plugin enabled: true # The maximum amount of characters a player can have for their tag - max-tag-length: 16 + # This does not include color tags such as or + max-tag-length: 64 # Color code for name color name-color: 'f' @@ -45,24 +46,7 @@ data: port: 6379 password: "" -# See https://plex.us.org/docs/customization/config#worlds for documentation -# These gamerules apply to all worlds on the server -global_gamerules: - - "doWeatherCycle;true" - - "doDaylightCycle;true" - - "doMobSpawning;false" - - "keepInventory;true" - - "doFireTick;false" - - "doMobLoot;false" - - "mobGriefing;false" - - "doTileDrops;false" - - "commandBlockOutput;false" - - "naturalRegeneration;true" - - "announceAdvancements;false" - - "showDeathMessages;false" - - "sendCommandFeedback;false" - -# Mob limiter/Entity wiping config +# Mob limiter / Entity wiping config # All entities listed here will NOT be wiped upon wiping entities # By default this includes all mobs, as the mobpurge command can be used to purge mobs. entitywipe_list: @@ -166,6 +150,23 @@ blockedEntities: - "ENDER_DRAGON" - "MINECART_TNT" +# See https://plex.us.org/docs/customization/config#worlds for documentation +# These gamerules apply to all worlds on the server +global_gamerules: + - "doWeatherCycle;true" + - "doDaylightCycle;true" + - "doMobSpawning;false" + - "keepInventory;true" + - "doFireTick;false" + - "doMobLoot;false" + - "mobGriefing;false" + - "doTileDrops;false" + - "commandBlockOutput;false" + - "naturalRegeneration;true" + - "announceAdvancements;false" + - "showDeathMessages;false" + - "sendCommandFeedback;false" + worlds: flatlands: name: "Flatlands" From d33c8df675ac6fc0c379a9af11808949c6c037f8 Mon Sep 17 00:00:00 2001 From: Taah Date: Fri, 8 Apr 2022 00:40:42 -0700 Subject: [PATCH 5/6] add fleek to devs list --- src/main/java/dev/plex/util/PlexUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/dev/plex/util/PlexUtils.java b/src/main/java/dev/plex/util/PlexUtils.java index e36c4d6..37653a4 100644 --- a/src/main/java/dev/plex/util/PlexUtils.java +++ b/src/main/java/dev/plex/util/PlexUtils.java @@ -51,7 +51,8 @@ public class PlexUtils extends PlexBase public static List DEVELOPERS = Arrays.asList("78408086-1991-4c33-a571-d8fa325465b2", // Telesphoreo "f5cd54c4-3a24-4213-9a56-c06c49594dff", // Taahh - "ca83b658-c03b-4106-9edc-72f70a80656d" // ayunami2000 + "ca83b658-c03b-4106-9edc-72f70a80656d", // ayunami2000 + "2e06e049-24c8-42e4-8bcf-d35372af31e6" //Fleek ); static From 3039125b48a7d251888d1c7c9aafb02842b6272e Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Fri, 8 Apr 2022 16:37:13 -0500 Subject: [PATCH 6/6] Improve it more --- .../dev/plex/listener/impl/WorldListener.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/plex/listener/impl/WorldListener.java b/src/main/java/dev/plex/listener/impl/WorldListener.java index 83a0930..b2b319e 100644 --- a/src/main/java/dev/plex/listener/impl/WorldListener.java +++ b/src/main/java/dev/plex/listener/impl/WorldListener.java @@ -126,10 +126,21 @@ public class WorldListener extends PlexListener public void onWorldTeleport(PlayerTeleportEvent e) { final World adminworld = Bukkit.getWorld("adminworld"); - PlexPlayer plexPlayer = DataUtils.getPlayer(e.getPlayer().getUniqueId()); - if (e.getTo().getWorld().equals(adminworld) && !plexPlayer.isAdminActive()) + if (adminworld == null) { - e.setCancelled(true); + return; + } + PlexPlayer plexPlayer = DataUtils.getPlayer(e.getPlayer().getUniqueId()); + if (e.getTo().getWorld().equals(adminworld)) + { + if (plugin.getSystem().equals("ranks") && !plexPlayer.isAdminActive()) + { + e.setCancelled(true); + } + else if (plugin.getSystem().equals("permissions") && !e.getPlayer().hasPermission("plex.enter.adminworld")) + { + e.setCancelled(true); + } } }