Merge branch 'master' of https://github.com/plexusorg/Plex into cmdblocker

This commit is contained in:
Telesphoreo 2022-04-08 16:57:11 -05:00
commit b939219fc9
6 changed files with 68 additions and 34 deletions

View File

@ -39,7 +39,7 @@ public class PlexCMD extends PlexCommand
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh")); send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
send(sender, mmString("<light_purple>Built by: <gold>" + Plex.build.author + " <light_purple>on <gold>" + Plex.build.date)); send(sender, mmString("<light_purple>Built by: <gold>" + Plex.build.author + " <light_purple>on <gold>" + Plex.build.date));
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules.")); send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, true); plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, 2);
return null; return null;
} }
if (args[0].equalsIgnoreCase("reload")) if (args[0].equalsIgnoreCase("reload"))
@ -99,7 +99,7 @@ public class PlexCMD extends PlexCommand
{ {
return messageComponent("noPermissionRank", "a developer"); return messageComponent("noPermissionRank", "a developer");
} }
if (!plugin.getUpdateChecker().getUpdateStatusMessage(sender, false, false)) if (!plugin.getUpdateChecker().getUpdateStatusMessage(sender, false, 0))
{ {
return mmString("<red>Plex is already up to date!"); return mmString("<red>Plex is already up to date!");
} }

View File

@ -1,6 +1,7 @@
package dev.plex.listener.impl; package dev.plex.listener.impl;
import dev.plex.Plex; import dev.plex.Plex;
import dev.plex.cache.DataUtils;
import dev.plex.cache.player.PlayerCache; import dev.plex.cache.player.PlayerCache;
import dev.plex.listener.PlexListener; import dev.plex.listener.PlexListener;
import dev.plex.player.PlexPlayer; import dev.plex.player.PlexPlayer;
@ -12,6 +13,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; 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.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class WorldListener extends PlexListener public class WorldListener extends PlexListener
{ {
@EventHandler @EventHandler
public void onBlockPlace(BlockPlaceEvent e) public void onBlockPlace(BlockPlaceEvent e)
{ {
@ -118,6 +121,29 @@ public class WorldListener extends PlexListener
e.setCancelled(true); 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");
if (adminworld == null)
{
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);
}
}
}
private boolean checkLevel(PlexPlayer player, String[] requiredList) private boolean checkLevel(PlexPlayer player, String[] requiredList)
{ {
PlexLog.debug("Checking world required levels " + Arrays.toString(requiredList)); PlexLog.debug("Checking world required levels " + Arrays.toString(requiredList));

View File

@ -17,7 +17,7 @@ public class UpdateCheckerService extends AbstractService
{ {
if (!newVersion) if (!newVersion)
{ {
if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender(), false, false)) if (plugin.getUpdateChecker().getUpdateStatusMessage(Bukkit.getConsoleSender(), false, 1))
{ {
newVersion = true; newVersion = true;
} }

View File

@ -51,7 +51,8 @@ public class PlexUtils extends PlexBase
public static List<String> DEVELOPERS = public static List<String> DEVELOPERS =
Arrays.asList("78408086-1991-4c33-a571-d8fa325465b2", // Telesphoreo Arrays.asList("78408086-1991-4c33-a571-d8fa325465b2", // Telesphoreo
"f5cd54c4-3a24-4213-9a56-c06c49594dff", // Taahh "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 static

View File

@ -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) if (branch == null)
{ {
@ -112,30 +115,33 @@ public class UpdateChecker extends PlexBase
switch (distance) switch (distance)
{ {
case -1 -> { case -1 -> {
if (verbose) if (verbosity == 2)
{ {
sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED)); sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED));
} }
return false; return false;
} }
case 0 -> { 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; return false;
} }
case -2 -> { case -2 -> {
if (verbose) if (verbosity == 2)
{ {
sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED)); sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED));
} }
return false; return false;
} }
default -> { default -> {
sender.sendMessage(Component.text("Your version of Plex is not up to date!", 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("Download a new version at: " + DOWNLOAD_PAGE).color(NamedTextColor.RED));
sender.sendMessage(Component.text("Or run: /plex update").color(NamedTextColor.RED)); sender.sendMessage(Component.text("Or run: /plex update").color(NamedTextColor.RED));
}
return true; return true;
} }
} }
@ -156,7 +162,7 @@ public class UpdateChecker extends PlexBase
JSONObject object = new JSONObject(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8)); JSONObject object = new JSONObject(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8));
JSONObject artifact = object.getJSONArray("artifacts").getJSONObject(0); JSONObject artifact = object.getJSONArray("artifacts").getJSONObject(0);
String name = artifact.getString("fileName"); String name = artifact.getString("fileName");
sendMini(sender, "Downloading latest Plex jar file: " + name); sendMini(sender, "<green>Downloading latest Plex jar file: " + name);
CompletableFuture.runAsync(() -> CompletableFuture.runAsync(() ->
{ {
try try
@ -165,7 +171,7 @@ public class UpdateChecker extends PlexBase
new URL(DOWNLOAD_PAGE + "job/" + branch + "/lastSuccessfulBuild/artifact/build/libs/" + name), new URL(DOWNLOAD_PAGE + "job/" + branch + "/lastSuccessfulBuild/artifact/build/libs/" + name),
new File(Bukkit.getUpdateFolderFile(), name) new File(Bukkit.getUpdateFolderFile(), name)
); );
sendMini(sender, "Saved new jar. Please restart your server."); sendMini(sender, "<green>Saved new jar. Please restart your server.");
} }
catch (IOException e) catch (IOException e)
{ {

View File

@ -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 # If you are using permissions, you should turn this off and use Vault to handle prefixes with a different chat plugin
enabled: true enabled: true
# The maximum amount of characters a player can have for their tag # The maximum amount of characters a player can have for their tag
max-tag-length: 16 # This does not include color tags such as <red> or <rainbow>
max-tag-length: 64
# Color code for name color # Color code for name color
name-color: 'f' name-color: 'f'
@ -45,23 +46,6 @@ data:
port: 6379 port: 6379
password: "" 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 # 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. # By default this includes all mobs, as the mobpurge command can be used to purge mobs.
@ -166,6 +150,23 @@ blockedEntities:
- "ENDER_DRAGON" - "ENDER_DRAGON"
- "MINECART_TNT" - "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: worlds:
flatlands: flatlands:
name: "Flatlands" name: "Flatlands"