Compare commits

...

13 Commits

Author SHA1 Message Date
704148e47f avoid quadratic overhead for UUID collection 2022-07-29 20:05:40 +02:00
aeb4350ccb Update bug_report.yml 2022-07-29 19:01:35 +02:00
9609990832 build: Update dependency com.intellectualsites.bom:bom-1.18.x to v1.12 (#3739)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-26 22:47:51 +02:00
0e4319b757 build: Update dependency org.junit.jupiter:junit-jupiter to v5.9.0 (#3741)
* build: Update dependency org.junit.jupiter:junit-jupiter to v5.9.0

* Update renovate.json

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Alexander Brandes <mc.cache@web.de>
2022-07-26 22:47:25 +02:00
c8f4907f77 build: Back to snapshot for development 2022-07-25 21:11:35 +02:00
dcf98c2298 build: Release 6.9.3 2022-07-25 21:10:39 +02:00
ae59c7442f fix: improve handling of missing message files (#3718)
* improve handling of missing message files

* fix javadoc

Co-authored-by: Alexander Brandes <mc.cache@web.de>
2022-07-25 21:02:54 +02:00
98708118d8 Deprecate the static Permissions "util" class that is almost entirely superseded by methods in PermissionHolder instances themselves (#3695)
Co-authored-by: Alexander Brandes <mc.cache@web.de>
2022-07-24 15:55:43 +02:00
276d8f8e1e change message of /p remove <player> if player does not need to be removed (#3734)
refactor: change message of `/p remove <player>` if unnecessary
2022-07-24 10:32:29 +02:00
87f89541b5 build: Update dependency com.intellectualsites.bom:bom-1.18.x to v1.11 (#3726)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-15 10:04:01 +02:00
93f6de7029 build: Update dependency gradle to v7.5 (#3727)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-15 10:03:27 +02:00
73d2686b17 build: Update dependency com.intellectualsites.bom:bom-1.18.x to v1.10 (#3723)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2022-07-06 00:14:20 +02:00
c446a95b07 build: Back to snapshot for development 2022-07-05 22:26:52 +02:00
14 changed files with 113 additions and 39 deletions

View File

@ -27,10 +27,10 @@ body:
description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first. description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first.
multiple: false multiple: false
options: options:
- '1.19.1'
- '1.19' - '1.19'
- '1.18.2' - '1.18.2'
- '1.18.1' - '1.18.1'
- '1.18'
- '1.17.1' - '1.17.1'
- '1.16.5' - '1.16.5'
validations: validations:

View File

@ -656,20 +656,15 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
final @NonNull SQLiteUUIDService sqLiteUUIDService, final @NonNull SQLiteUUIDService sqLiteUUIDService,
final @NonNull CacheUUIDService cacheUUIDService final @NonNull CacheUUIDService cacheUUIDService
) { ) {
// Load all uuids into a big chunky boi queue // Record all unique UUID's and put them into a queue
final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>(); final Set<UUID> uuidSet = new HashSet<>();
PlotSquared.get().forEachPlotRaw(plot -> { PlotSquared.get().forEachPlotRaw(plot -> {
final Set<UUID> uuids = new HashSet<>(); uuidSet.add(plot.getOwnerAbs());
uuids.add(plot.getOwnerAbs()); uuidSet.addAll(plot.getMembers());
uuids.addAll(plot.getMembers()); uuidSet.addAll(plot.getTrusted());
uuids.addAll(plot.getTrusted()); uuidSet.addAll(plot.getDenied());
uuids.addAll(plot.getDenied());
for (final UUID uuid : uuids) {
if (!uuidQueue.contains(uuid)) {
uuidQueue.add(uuid);
}
}
}); });
final Queue<UUID> uuidQueue = new LinkedBlockingQueue<>(uuidSet);
LOGGER.info("(UUID) {} UUIDs will be cached", uuidQueue.size()); LOGGER.info("(UUID) {} UUIDs will be cached", uuidQueue.size());
@ -732,6 +727,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
this.getServer().getPluginManager().disablePlugin(this); this.getServer().getPluginManager().disablePlugin(this);
} }
@Override
public void shutdownServer() {
getServer().shutdown();
}
private void registerCommands() { private void registerCommands() {
final BukkitCommand bukkitCommand = new BukkitCommand(); final BukkitCommand bukkitCommand = new BukkitCommand();
final PluginCommand plotCommand = getCommand("plots"); final PluginCommand plotCommand = getCommand("plots");

View File

@ -75,6 +75,11 @@ public interface PlotPlatform<P> extends LocaleHolder {
*/ */
void shutdown(); void shutdown();
/**
* Completely shuts down the server.
*/
void shutdownServer();
/** /**
* Get the name of the plugin * Get the name of the plugin
* *

View File

@ -197,6 +197,9 @@ public class PlotSquared {
this.loadCaptionMap(); this.loadCaptionMap();
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.error("Failed to load caption map", e); LOGGER.error("Failed to load caption map", e);
LOGGER.error("Shutting down server to prevent further issues");
this.platform.shutdownServer();
throw new RuntimeException("Abort loading PlotSquared");
} }
// Setup the global flag container // Setup the global flag container
@ -267,7 +270,7 @@ public class PlotSquared {
captionMap = this.captionLoader.loadAll(this.platform.getDirectory().toPath().resolve("lang")); captionMap = this.captionLoader.loadAll(this.platform.getDirectory().toPath().resolve("lang"));
} else { } else {
String fileName = "messages_" + Settings.Enabled_Components.DEFAULT_LOCALE + ".json"; String fileName = "messages_" + Settings.Enabled_Components.DEFAULT_LOCALE + ".json";
captionMap = this.captionLoader.loadSingle(this.platform.getDirectory().toPath().resolve("lang").resolve(fileName)); captionMap = this.captionLoader.loadOrCreateSingle(this.platform.getDirectory().toPath().resolve("lang").resolve(fileName));
} }
this.captionMaps.put(TranslatableCaption.DEFAULT_NAMESPACE, captionMap); this.captionMaps.put(TranslatableCaption.DEFAULT_NAMESPACE, captionMap);
LOGGER.info( LOGGER.info(

View File

@ -115,8 +115,8 @@ public class Remove extends SubCommand {
} }
if (count == 0) { if (count == 0) {
player.sendMessage( player.sendMessage(
TranslatableCaption.of("errors.invalid_player"), TranslatableCaption.of("member.player_not_removed"),
Template.of("value", args[0]) Template.of("player", args[0])
); );
} else { } else {
player.sendMessage( player.sendMessage(

View File

@ -174,7 +174,7 @@ public final class CaptionLoader {
public @NonNull CaptionMap loadAll(final @NonNull Path directory) throws IOException { public @NonNull CaptionMap loadAll(final @NonNull Path directory) throws IOException {
final Map<Locale, CaptionMap> localeMaps = new HashMap<>(); final Map<Locale, CaptionMap> localeMaps = new HashMap<>();
try (final Stream<Path> files = Files.list(directory)) { try (final Stream<Path> files = Files.list(directory)) {
final List<Path> captionFiles = files.filter(Files::isRegularFile).collect(Collectors.toList()); final List<Path> captionFiles = files.filter(Files::isRegularFile).toList();
for (Path file : captionFiles) { for (Path file : captionFiles) {
try { try {
final CaptionMap localeMap = loadSingle(file); final CaptionMap localeMap = loadSingle(file);
@ -190,13 +190,14 @@ public final class CaptionLoader {
/** /**
* Load a message file into a new CaptionMap. The file name must match * Load a message file into a new CaptionMap. The file name must match
* the pattern {@code messages_<locale>.json} where {@code <locale>} * the pattern expected by the {@link #localeExtractor}.
* is a valid {@link Locale} string. * Note that this method does not attempt to create a new file.
* *
* @param file The file to load * @param file The file to load
* @return A new CaptionMap containing the loaded messages * @return A new CaptionMap containing the loaded messages
* @throws IOException if the file couldn't be accessed or read successfully. * @throws IOException if the file couldn't be accessed or read successfully.
* @throws IllegalArgumentException if the file name doesn't match the specified format. * @throws IllegalArgumentException if the file name doesn't match the specified format.
* @see #loadOrCreateSingle(Path)
*/ */
public @NonNull CaptionMap loadSingle(final @NonNull Path file) throws IOException { public @NonNull CaptionMap loadSingle(final @NonNull Path file) throws IOException {
final Locale locale = this.localeExtractor.apply(file); final Locale locale = this.localeExtractor.apply(file);
@ -205,14 +206,42 @@ public final class CaptionLoader {
if (patch(map, locale)) { if (patch(map, locale)) {
save(file, map); // update the file using the modified map save(file, map); // update the file using the modified map
} }
return new LocalizedCaptionMap(locale, map.entrySet().stream() return new LocalizedCaptionMap(locale, mapToCaptions(map));
.collect(Collectors.toMap( }
}
/**
* Load a message file into a new CaptionMap. The file name must match
* the pattern expected by the {@link #localeExtractor}.
* If no file exists at the given path, this method will
* attempt to create one and fill it with default values.
*
* @param file The file to load
* @return A new CaptionMap containing the loaded messages
* @throws IOException if the file couldn't be accessed or read successfully.
* @throws IllegalArgumentException if the file name doesn't match the specified format.
* @see #loadSingle(Path)
* @since 6.9.3
*/
public @NonNull CaptionMap loadOrCreateSingle(final @NonNull Path file) throws IOException {
final Locale locale = this.localeExtractor.apply(file);
if (!Files.exists(file) ) {
Map<String, String> map = new LinkedHashMap<>();
patch(map, locale);
save(file, map);
return new LocalizedCaptionMap(locale, mapToCaptions(map));
} else {
return loadSingle(file);
}
}
private @NonNull Map<TranslatableCaption, String> mapToCaptions(Map<String, String> map) {
return map.entrySet().stream().collect(
Collectors.toMap(
entry -> TranslatableCaption.of(this.namespace, entry.getKey()), entry -> TranslatableCaption.of(this.namespace, entry.getKey()),
Map.Entry::getValue Map.Entry::getValue
)
)); ));
} }
}
/** /**
* Add missing entries to the given map. * Add missing entries to the given map.

View File

@ -30,9 +30,18 @@ import org.checkerframework.checker.nullness.qual.NonNull;
* The Permissions class handles checking user permissions.<br> * The Permissions class handles checking user permissions.<br>
* - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)<br> * - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)<br>
* - Checking the PlotPlayer class directly will not take the above into account<br> * - Checking the PlotPlayer class directly will not take the above into account<br>
*
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/ */
@Deprecated(forRemoval = true, since = "6.9.3")
public class Permissions { public class Permissions {
/**
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(PlotPlayer<?> player, Permission permission, boolean notify) { public static boolean hasPermission(PlotPlayer<?> player, Permission permission, boolean notify) {
return hasPermission(player, permission.toString(), notify); return hasPermission(player, permission.toString(), notify);
} }
@ -43,18 +52,25 @@ public class Permissions {
* @param caller permission holder * @param caller permission holder
* @param permission Permission * @param permission Permission
* @return {@code true} if the owner has the given permission, else {@code false} * @return {@code true} if the owner has the given permission, else {@code false}
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/ */
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull Permission permission) { public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull Permission permission) {
return caller.hasPermission(permission.toString()); return caller.hasPermission(permission.toString());
} }
/** /**
* Check if the owner of the profile has a given (global) permission * Check if the owner of the profile has a given (global) permission. There is no guarantee that per-world permissions will
* be checked because unmaintained crap plugins like PEX exist.
* *
* @param caller permission holder * @param caller permission holder
* @param permission Permission * @param permission Permission
* @return {@code true} if the owner has the given permission, else {@code false} * @return {@code true} if the owner has the given permission, else {@code false}
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/ */
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull String permission) { public static boolean hasPermission(final @NonNull PermissionHolder caller, final @NonNull String permission) {
return caller.hasPermission(permission); return caller.hasPermission(permission);
} }
@ -68,7 +84,10 @@ public class Permissions {
* @param key Permission "key" * @param key Permission "key"
* @return {@code true} if the owner has the given permission, else {@code false} * @return {@code true} if the owner has the given permission, else {@code false}
* @since 6.0.10 * @since 6.0.10
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/ */
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasKeyedPermission( public static boolean hasKeyedPermission(
final @NonNull PermissionHolder caller, final @NonNull String permission, final @NonNull PermissionHolder caller, final @NonNull String permission,
final @NonNull String key final @NonNull String key
@ -83,7 +102,10 @@ public class Permissions {
* @param permission permission * @param permission permission
* @param notify if to notify the permission holder * @param notify if to notify the permission holder
* @return if permission is had * @return if permission is had
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/ */
@Deprecated(forRemoval = true, since = "6.9.3")
public static boolean hasPermission(PlotPlayer<?> player, String permission, boolean notify) { public static boolean hasPermission(PlotPlayer<?> player, String permission, boolean notify) {
if (!hasPermission(player, permission)) { if (!hasPermission(player, permission)) {
if (notify) { if (notify) {
@ -97,6 +119,11 @@ public class Permissions {
return true; return true;
} }
/**
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/
@Deprecated(forRemoval = true, since = "6.9.3")
public static int hasPermissionRange(PlotPlayer<?> player, Permission Permission, int range) { public static int hasPermissionRange(PlotPlayer<?> player, Permission Permission, int range) {
return hasPermissionRange(player, Permission.toString(), range); return hasPermissionRange(player, Permission.toString(), range);
} }
@ -110,7 +137,10 @@ public class Permissions {
* @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot` * @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot`
* @param range The range to check * @param range The range to check
* @return The highest permission they have within that range * @return The highest permission they have within that range
* @deprecated all logic that may once have been in the class lives elsewhere. We also want to do away with statically-accessed
* classes
*/ */
@Deprecated(forRemoval = true, since = "6.9.3")
public static int hasPermissionRange(PlotPlayer<?> player, String stub, int range) { public static int hasPermissionRange(PlotPlayer<?> player, String stub, int range) {
return player.hasPermissionRange(stub, range); return player.hasPermissionRange(stub, range);
} }

View File

@ -414,6 +414,7 @@
"kick.you_got_kicked": "<prefix><dark_aqua>You got kicked from the plot!</dark_aqua>", "kick.you_got_kicked": "<prefix><dark_aqua>You got kicked from the plot!</dark_aqua>",
"trusted.trusted_added": "<prefix><dark_aqua>You successfully trusted a user to the plot.</dark_aqua>", "trusted.trusted_added": "<prefix><dark_aqua>You successfully trusted a user to the plot.</dark_aqua>",
"trusted.plot_removed_user": "<prefix><red>Plot <plot> of which you were added to has been deleted due to owner inactivity.</red>", "trusted.plot_removed_user": "<prefix><red>Plot <plot> of which you were added to has been deleted due to owner inactivity.</red>",
"member.player_not_removed": "<prefix><gray><player></gray><red> is neither added, trusted or denied on the plot, thus doesn't need to be removed.</red>",
"member.removed_players": "<prefix><gray>Removed <amount> player(s) from this plot.</gray>", "member.removed_players": "<prefix><gray>Removed <amount> player(s) from this plot.</gray>",
"member.plot_left": "<prefix><gray><player> left the plot.</gray>", "member.plot_left": "<prefix><gray><player> left the plot.</gray>",
"member.plot_cant_leave_owner": "<prefix><red>You are the plot owner. You cannot leave this plot.</red>", "member.plot_cant_leave_owner": "<prefix><red>You are the plot owner. You cannot leave this plot.</red>",

View File

@ -19,7 +19,7 @@ plugins {
} }
group = "com.plotsquared" group = "com.plotsquared"
version = "6.9.2" version = "6.9.4-SNAPSHOT"
subprojects { subprojects {
group = rootProject.group group = rootProject.group
@ -65,12 +65,12 @@ subprojects {
} }
dependencies { dependencies {
implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.9")) implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.12"))
} }
dependencies { dependencies {
// Tests // Tests
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2") testImplementation("org.junit.jupiter:junit-jupiter:5.9.0")
} }
plugins.withId("java") { plugins.withId("java") {

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

6
gradlew vendored
View File

@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \ org.gradle.wrapper.GradleWrapperMain \
"$@" "$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args. # Use "xargs" to parse quoted args.
# #
# With -n1 it outputs one arg per line, with the quotes and backslashes removed. # With -n1 it outputs one arg per line, with the quotes and backslashes removed.

14
gradlew.bat vendored
View File

@ -14,7 +14,7 @@
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%"=="" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if %ERRORLEVEL% equ 0 goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if %ERRORLEVEL% equ 0 goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 set EXIT_CODE=%ERRORLEVEL%
exit /b 1 if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal

View File

@ -1,9 +1,7 @@
{ {
"extends": [ "extends": [
"config:base", "config:base"
":disableDependencyDashboard"
], ],
"labels": ["Renovate"], "labels": ["Renovate"],
"commitMessagePrefix": "build: ",
"rebaseWhen": "conflicted" "rebaseWhen": "conflicted"
} }