mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-04 14:44:43 +02:00
Compare commits
9 Commits
fix/missin
...
perf/v6/uu
Author | SHA1 | Date | |
---|---|---|---|
704148e47f | |||
aeb4350ccb | |||
9609990832 | |||
0e4319b757 | |||
c8f4907f77 | |||
dcf98c2298 | |||
ae59c7442f | |||
98708118d8 | |||
276d8f8e1e |
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -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:
|
||||||
|
@ -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");
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
@ -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(
|
||||||
|
@ -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(
|
||||||
|
@ -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.
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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>",
|
||||||
|
@ -19,7 +19,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = "com.plotsquared"
|
group = "com.plotsquared"
|
||||||
version = "6.9.3-SNAPSHOT"
|
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.11"))
|
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") {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
{
|
{
|
||||||
"extends": [
|
"extends": [
|
||||||
"config:base",
|
"config:base"
|
||||||
":disableDependencyDashboard"
|
|
||||||
],
|
],
|
||||||
"labels": ["Renovate"],
|
"labels": ["Renovate"],
|
||||||
"commitMessagePrefix": "build: ",
|
|
||||||
"rebaseWhen": "conflicted"
|
"rebaseWhen": "conflicted"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user