diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c1962a7..7f93135 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 744c64d..3fa8f86 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -2,5 +2,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index aeb74cb..1aa94a4 100755 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -130,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -198,11 +202,11 @@ fi # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/server/src/main/java/dev/plex/command/impl/EntityWipeCMD.java b/server/src/main/java/dev/plex/command/impl/EntityWipeCMD.java index f5115da..b940437 100644 --- a/server/src/main/java/dev/plex/command/impl/EntityWipeCMD.java +++ b/server/src/main/java/dev/plex/command/impl/EntityWipeCMD.java @@ -4,7 +4,7 @@ import dev.plex.command.PlexCommand; import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandPermissions; import dev.plex.command.source.RequiredCommandSource; - +import dev.plex.util.PlexLog; import dev.plex.util.PlexUtils; import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; @@ -19,7 +19,7 @@ import org.jetbrains.annotations.Nullable; import java.util.*; @CommandPermissions(permission = "plex.entitywipe", source = RequiredCommandSource.ANY) -@CommandParameters(name = "entitywipe", description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/ [name]", aliases = "ew,rd") +@CommandParameters(name = "entitywipe", description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/ [entity] [radius]", aliases = "ew,rd") public class EntityWipeCMD extends PlexCommand { @Override @@ -29,6 +29,21 @@ public class EntityWipeCMD extends PlexCommand List entityWhitelist = new LinkedList<>(Arrays.asList(args)); + boolean radiusSpecified = !entityWhitelist.isEmpty() && isNumeric(entityWhitelist.get(entityWhitelist.size() - 1)); // try and detect if the last argument of the command is a number + boolean useBlacklist = args.length == 0 || (args.length == 1 && radiusSpecified); // if there are no arguments or the one argument is a number + int radius = 0; + + PlexLog.log("using blacklist: " + useBlacklist); + PlexLog.log("radius specified: " + radiusSpecified); + + if (radiusSpecified) + { + radius = parseInt(sender, args[entityWhitelist.size() - 1]); // get the args length as the size of the list + entityWhitelist.remove(entityWhitelist.size() - 1); // remove the radius from the list + } + + PlexLog.log("radius: " + radius); + EntityType[] entityTypes = EntityType.values(); entityWhitelist.removeIf(name -> { @@ -40,8 +55,6 @@ public class EntityWipeCMD extends PlexCommand return res; }); - boolean useBlacklist = args.length == 0; - HashMap entityCounts = new HashMap<>(); for (World world : Bukkit.getWorlds()) @@ -54,6 +67,16 @@ public class EntityWipeCMD extends PlexCommand if (useBlacklist ? entityBlacklist.stream().noneMatch(entityName -> entityName.equalsIgnoreCase(type)) : entityWhitelist.stream().anyMatch(entityName -> entityName.equalsIgnoreCase(type))) { + if (radius > 0) + { + PlexLog.log("we got here, radius is > 0"); + if (playerSender != null && entity.getWorld() == playerSender.getWorld() && playerSender.getLocation().distance(entity.getLocation()) > radius) + { + PlexLog.log("continuing"); + continue; + } + } + PlexLog.log("removed entity: " + entity.getType().name()); entity.remove(); entityCounts.put(type, entityCounts.getOrDefault(type, 0) + 1); @@ -97,4 +120,34 @@ public class EntityWipeCMD extends PlexCommand } return entities.stream().toList(); } + + private Integer parseInt(CommandSender sender, String string) + { + try + { + return Integer.parseInt(string); + } + catch (NumberFormatException ex) + { + sender.sendMessage(mmString("" + string + " is not a valid number!")); + } + return null; + } + + private boolean isNumeric(String string) + { + if (string == null) + { + return false; + } + try + { + int num = Integer.parseInt(string); + } + catch (NumberFormatException nfe) + { + return false; + } + return true; + } } \ No newline at end of file diff --git a/server/src/main/java/dev/plex/command/impl/ListCMD.java b/server/src/main/java/dev/plex/command/impl/ListCMD.java index c10bba5..b5acc13 100644 --- a/server/src/main/java/dev/plex/command/impl/ListCMD.java +++ b/server/src/main/java/dev/plex/command/impl/ListCMD.java @@ -5,7 +5,6 @@ import dev.plex.command.PlexCommand; import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandPermissions; import dev.plex.hook.VaultHook; - import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; @@ -14,9 +13,10 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Collections; import java.util.List; -@CommandParameters(name = "list", description = "Show a list of all online players", aliases = "lsit,who,playerlist,online") +@CommandParameters(name = "list", description = "Show a list of all online players", usage = "/ [-d]", aliases = "lsit,who,playerlist,online") @CommandPermissions(permission = "plex.list") public class ListCMD extends PlexCommand { @@ -37,7 +37,7 @@ public class ListCMD extends PlexCommand .append(Component.space()) .append(Component.text(Bukkit.getMaxPlayers() == 1 ? "player." : "players.").color(NamedTextColor.GRAY)); send(sender, header); - if (players.size() == 0) + if (players.isEmpty()) { return null; } @@ -45,10 +45,18 @@ public class ListCMD extends PlexCommand { Player player = players.get(i); Component prefix = VaultHook.getPrefix(getPlexPlayer(player)); - if (prefix != null && !prefix.equals(Component.empty()) && !prefix.equals(Component.space())) { + if (prefix != null && !prefix.equals(Component.empty()) && !prefix.equals(Component.space())) + { list = list.append(prefix).append(Component.space()); } list = list.append(Component.text(player.getName()).color(NamedTextColor.WHITE)); + if (args.length > 0 && args[0].equalsIgnoreCase("-d")) + { + list = list.append(Component.space()); + list = list.append(Component.text("(").color(NamedTextColor.WHITE)); + list = list.append(player.displayName()); + list = list.append(Component.text(")").color(NamedTextColor.WHITE)); + } if (i != players.size() - 1) { list = list.append(Component.text(",")).append(Component.space()); @@ -56,4 +64,13 @@ public class ListCMD extends PlexCommand } return list; } + + public @NotNull List tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException + { + if (args.length == 1) + { + return Collections.singletonList("-d"); + } + return Collections.emptyList(); + } } diff --git a/server/src/main/resources/messages.yml b/server/src/main/resources/messages.yml index abbcd94..99f9736 100644 --- a/server/src/main/resources/messages.yml +++ b/server/src/main/resources/messages.yml @@ -29,16 +29,6 @@ specifyPlayer: "You must specify a player!" worldNotFound: "World not found!" # 0 - The world you have been teleported to playerWorldTeleport: "You have been teleported to {0}." -# 0 - The sender who opped everyone -oppedAllPlayers: "{0} - Opped all players on the server" -# 0 - The sender who de-opped everyone -deoppedAllPlayers: "{0} - De-opped all players on the server" -# 0 - The person who is opping -# 1 - The person who has been opped -oppedPlayer: "{0} - Opped {1}" -# 0 - The person who is deopped -# 1 - The person who has been deopped -deoppedPlayer: "{0} - Deopped {1}" # 0 - The person who is freezing # 1 - The person who has been frozen frozePlayer: "{0} - Froze {1}" @@ -57,8 +47,6 @@ lockedUpPlayer: "{0} - Locking up {1}" # 0 - The person who is unlocking # 1 - The person who has been unlocked unlockedPlayer: "{0} - Unlocking {1}" -# 0 - The rank required to use the command -noPermissionRank: "You must be at least {0} to use this command!" # 0 - The permission node required to use the command noPermissionNode: "You must have the permission: {0} to use this command!" noPermissionInGame: "You must be in console to use this command!"