mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 01:23:44 +01:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			7.0.0
			...
			recordiniz
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | e06bf2cd6b | ||
|   | 0484915233 | 
| @@ -52,7 +52,7 @@ public class MVdWPlaceholders { | ||||
|  | ||||
|     @Subscribe | ||||
|     public void onNewPlaceholder(final PlaceholderRegistry.@NonNull PlaceholderAddedEvent event) { | ||||
|         this.addPlaceholder(event.getPlaceholder()); | ||||
|         this.addPlaceholder(event.placeholder()); | ||||
|     } | ||||
|  | ||||
|     private void addPlaceholder(final @NonNull Placeholder placeholder) { | ||||
|   | ||||
| @@ -110,9 +110,9 @@ public class GenChunk extends ZeroedDelegateScopedQueueCoordinator { | ||||
|      */ | ||||
|     public void setChunk(@NonNull ChunkWrapper wrap) { | ||||
|         chunk = null; | ||||
|         world = wrap.world; | ||||
|         chunkX = wrap.x; | ||||
|         chunkZ = wrap.z; | ||||
|         world = wrap.world(); | ||||
|         chunkX = wrap.x(); | ||||
|         chunkZ = wrap.z(); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -124,7 +124,7 @@ public class BukkitSetupUtils extends SetupUtils { | ||||
|     public String setupWorld(PlotAreaBuilder builder) { | ||||
|         this.updateGenerators(false); | ||||
|         ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ? | ||||
|                 new ConfigurationNode[0] : builder.settingsNodesWrapper().getSettingsNodes(); | ||||
|                 new ConfigurationNode[0] : builder.settingsNodesWrapper().settingsNodes(); | ||||
|         String world = builder.worldName(); | ||||
|         PlotAreaType type = builder.plotAreaType(); | ||||
|         String worldPath = "worlds." + builder.worldName(); | ||||
|   | ||||
| @@ -111,8 +111,8 @@ public class SQLiteUUIDService implements UUIDService, Consumer<List<UUIDMapping | ||||
|         try (final PreparedStatement statement = getConnection() | ||||
|                 .prepareStatement("INSERT OR REPLACE INTO `usercache` (`uuid`, `username`) VALUES(?, ?)")) { | ||||
|             for (final UUIDMapping mapping : uuidWrappers) { | ||||
|                 statement.setString(1, mapping.getUuid().toString()); | ||||
|                 statement.setString(2, mapping.getUsername()); | ||||
|                 statement.setString(1, mapping.uuid().toString()); | ||||
|                 statement.setString(2, mapping.username()); | ||||
|                 statement.executeUpdate(); | ||||
|             } | ||||
|         } catch (SQLException e) { | ||||
|   | ||||
| @@ -136,33 +136,29 @@ public class SimpleBackupManager implements BackupManager { | ||||
|         return this.backupLimit; | ||||
|     } | ||||
|  | ||||
|     private static final class PlotCacheKey { | ||||
|  | ||||
|         private final Plot plot; | ||||
|  | ||||
|         private PlotCacheKey(Plot plot) { | ||||
|             this.plot = plot; | ||||
|         } | ||||
|     private record PlotCacheKey( | ||||
|             Plot plot | ||||
|     ) { | ||||
|  | ||||
|         @Override | ||||
|         public boolean equals(final Object o) { | ||||
|             if (this == o) { | ||||
|                 return true; | ||||
|             public boolean equals(final Object o) { | ||||
|                 if (this == o) { | ||||
|                     return true; | ||||
|                 } | ||||
|                 if (o == null || getClass() != o.getClass()) { | ||||
|                     return false; | ||||
|                 } | ||||
|                 final PlotCacheKey that = (PlotCacheKey) o; | ||||
|                 return Objects.equals(plot.getArea(), that.plot.getArea()) | ||||
|                         && Objects.equals(plot.getId(), that.plot.getId()) | ||||
|                         && Objects.equals(plot.getOwnerAbs(), that.plot.getOwnerAbs()); | ||||
|             } | ||||
|             if (o == null || getClass() != o.getClass()) { | ||||
|                 return false; | ||||
|  | ||||
|             @Override | ||||
|             public int hashCode() { | ||||
|                 return Objects.hash(plot.getArea(), plot.getId(), plot.getOwnerAbs()); | ||||
|             } | ||||
|             final PlotCacheKey that = (PlotCacheKey) o; | ||||
|             return Objects.equals(plot.getArea(), that.plot.getArea()) | ||||
|                     && Objects.equals(plot.getId(), that.plot.getId()) | ||||
|                     && Objects.equals(plot.getOwnerAbs(), that.plot.getOwnerAbs()); | ||||
|         } | ||||
|  | ||||
|         @Override | ||||
|         public int hashCode() { | ||||
|             return Objects.hash(plot.getArea(), plot.getId(), plot.getOwnerAbs()); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -35,6 +35,7 @@ import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.PlotArea; | ||||
| import com.plotsquared.core.plot.world.PlotAreaManager; | ||||
| import com.plotsquared.core.services.plots.AutoQuery; | ||||
| import com.plotsquared.core.services.plots.AutoService; | ||||
| import com.plotsquared.core.util.EconHandler; | ||||
| import com.plotsquared.core.util.EventDispatcher; | ||||
| @@ -326,7 +327,7 @@ public class Auto extends SubCommand { | ||||
|         } | ||||
|  | ||||
|         List<Plot> plots = this.servicePipeline | ||||
|                 .pump(new AutoService.AutoQuery(player, null, sizeX, sizeZ, plotarea)) | ||||
|                 .pump(new AutoQuery(player, null, sizeX, sizeZ, plotarea)) | ||||
|                 .through(AutoService.class) | ||||
|                 .getResult(); | ||||
|  | ||||
|   | ||||
| @@ -85,24 +85,24 @@ public class Inbox extends SubCommand { | ||||
|         for (int x = page * 12; x < max; x++) { | ||||
|             PlotComment comment = comments[x]; | ||||
|             Component commentColored; | ||||
|             if (player.getName().equals(comment.senderName)) { | ||||
|             if (player.getName().equals(comment.senderName())) { | ||||
|                 commentColored = MINI_MESSAGE | ||||
|                         .deserialize( | ||||
|                                 TranslatableCaption.of("list.comment_list_by_lister").getComponent(player), | ||||
|                                 TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment))) | ||||
|                                 TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment()))) | ||||
|                         ); | ||||
|             } else { | ||||
|                 commentColored = MINI_MESSAGE | ||||
|                         .deserialize( | ||||
|                                 TranslatableCaption.of("list.comment_list_by_other").getComponent(player), | ||||
|                                 TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment))) | ||||
|                                 TagResolver.resolver("comment", Tag.inserting(Component.text(comment.comment()))) | ||||
|                         ); | ||||
|             } | ||||
|             TagResolver resolver = TagResolver.builder() | ||||
|                     .tag("number", Tag.inserting(Component.text(x))) | ||||
|                     .tag("world", Tag.inserting(Component.text(comment.world))) | ||||
|                     .tag("plot_id", Tag.inserting(Component.text(comment.id.getX() + ";" + comment.id.getY()))) | ||||
|                     .tag("commenter", Tag.inserting(Component.text(comment.senderName))) | ||||
|                     .tag("world", Tag.inserting(Component.text(comment.world()))) | ||||
|                     .tag("plot_id", Tag.inserting(Component.text(comment.id().getX() + ";" + comment.id().getY()))) | ||||
|                     .tag("commenter", Tag.inserting(Component.text(comment.senderName()))) | ||||
|                     .tag("comment", Tag.inserting(commentColored)) | ||||
|                     .build(); | ||||
|             builder.append(MINI_MESSAGE | ||||
| @@ -137,7 +137,7 @@ public class Inbox extends SubCommand { | ||||
|                                 int unread = 0; | ||||
|                                 for (PlotComment comment : value) { | ||||
|                                     total++; | ||||
|                                     if (comment.timestamp > CommentManager | ||||
|                                     if (comment.timestamp() > CommentManager | ||||
|                                             .getTimestamp(player, inbox.toString())) { | ||||
|                                         unread++; | ||||
|                                     } | ||||
| @@ -242,7 +242,7 @@ public class Inbox extends SubCommand { | ||||
|                             if (success) { | ||||
|                                 player.sendMessage( | ||||
|                                         TranslatableCaption.of("comment.comment_removed_success"), | ||||
|                                         TagResolver.resolver("value", Tag.inserting(Component.text(comment.comment))) | ||||
|                                         TagResolver.resolver("value", Tag.inserting(Component.text(comment.comment()))) | ||||
|                                 ); | ||||
|                             } else { | ||||
|                                 player.sendMessage( | ||||
|   | ||||
| @@ -474,20 +474,20 @@ public class ListCmd extends SubCommand { | ||||
|                         final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners()) | ||||
|                                 .get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS); | ||||
|                         for (final UUIDMapping uuidMapping : names) { | ||||
|                             PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid()); | ||||
|                             PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.uuid()); | ||||
|                             TagResolver resolver = TagResolver.builder() | ||||
|                                 .tag("prefix", Tag.inserting(Component.text(prefix))) | ||||
|                                 .tag("player", Tag.inserting(Component.text(uuidMapping.getUsername()))) | ||||
|                                 .tag("player", Tag.inserting(Component.text(uuidMapping.username()))) | ||||
|                                 .build(); | ||||
|                         if (pp != null) { | ||||
|                             builder.append(MINI_MESSAGE.deserialize(online, resolver)); | ||||
|                             } else if (uuidMapping.getUsername().equalsIgnoreCase("unknown")) { | ||||
|                             } else if (uuidMapping.username().equalsIgnoreCase("unknown")) { | ||||
|                                 TagResolver unknownResolver = TagResolver.resolver( | ||||
|                                         "info.unknown", | ||||
|                                         Tag.inserting(TranslatableCaption.of("info.unknown").toComponent(player)) | ||||
|                                 ); | ||||
|                                 builder.append(MINI_MESSAGE.deserialize(unknown, unknownResolver)); | ||||
|                             } else if (uuidMapping.getUuid().equals(DBFunc.EVERYONE)) { | ||||
|                             } else if (uuidMapping.uuid().equals(DBFunc.EVERYONE)) { | ||||
|                                 TagResolver everyoneResolver = TagResolver.resolver( | ||||
|                                         "info.everyone", | ||||
|                                         Tag.inserting(TranslatableCaption.of("info.everyone").toComponent(player)) | ||||
|   | ||||
| @@ -127,7 +127,7 @@ public class Purge extends SubCommand { | ||||
|                         ); | ||||
|                         return false; | ||||
|                     } | ||||
|                     owner = ownerMapping.getUuid(); | ||||
|                     owner = ownerMapping.uuid(); | ||||
|                     break; | ||||
|                 case "shared": | ||||
|                 case "s": | ||||
| @@ -139,7 +139,7 @@ public class Purge extends SubCommand { | ||||
|                         ); | ||||
|                         return false; | ||||
|                     } | ||||
|                     added = addedMapping.getUuid(); | ||||
|                     added = addedMapping.uuid(); | ||||
|                     break; | ||||
|                 case "clear": | ||||
|                 case "c": | ||||
|   | ||||
| @@ -156,9 +156,9 @@ public class Template extends SubCommand { | ||||
|              ZipOutputStream zos = new ZipOutputStream(fos)) { | ||||
|  | ||||
|             for (FileBytes file : files) { | ||||
|                 ZipEntry ze = new ZipEntry(file.path); | ||||
|                 ZipEntry ze = new ZipEntry(file.path()); | ||||
|                 zos.putNextEntry(ze); | ||||
|                 zos.write(file.data); | ||||
|                 zos.write(file.data()); | ||||
|             } | ||||
|             zos.closeEntry(); | ||||
|         } | ||||
|   | ||||
| @@ -35,28 +35,15 @@ import java.util.Map; | ||||
|  * the component GUI | ||||
|  */ | ||||
| @SerializableAs("preset") | ||||
| public class ComponentPreset implements ConfigurationSerializable { | ||||
|  | ||||
|     private final ClassicPlotManagerComponent component; | ||||
|     private final String pattern; | ||||
|     private final double cost; | ||||
|     private final String permission; | ||||
|     private final String displayName; | ||||
|     private final List<String> description; | ||||
|     private final ItemType icon; | ||||
|  | ||||
|     public ComponentPreset( | ||||
|             ClassicPlotManagerComponent component, String pattern, double cost, | ||||
|             String permission, String displayName, List<String> description, final ItemType icon | ||||
|     ) { | ||||
|         this.component = component; | ||||
|         this.pattern = pattern; | ||||
|         this.cost = cost; | ||||
|         this.permission = permission; | ||||
|         this.displayName = displayName; | ||||
|         this.description = description; | ||||
|         this.icon = icon; | ||||
|     } | ||||
| public record ComponentPreset( | ||||
|         ClassicPlotManagerComponent component, | ||||
|         String pattern, | ||||
|         double cost, | ||||
|         String permission, | ||||
|         String displayName, | ||||
|         List<String> description, | ||||
|         ItemType icon | ||||
| ) implements ConfigurationSerializable { | ||||
|  | ||||
|     @SuppressWarnings("unchecked") | ||||
|     public static ComponentPreset deserialize(final @NonNull Map<String, Object> map) { | ||||
| @@ -74,34 +61,6 @@ public class ComponentPreset implements ConfigurationSerializable { | ||||
|         ); | ||||
|     } | ||||
|  | ||||
|     public ClassicPlotManagerComponent getComponent() { | ||||
|         return this.component; | ||||
|     } | ||||
|  | ||||
|     public String getPattern() { | ||||
|         return this.pattern; | ||||
|     } | ||||
|  | ||||
|     public double getCost() { | ||||
|         return this.cost; | ||||
|     } | ||||
|  | ||||
|     public String getPermission() { | ||||
|         return this.permission; | ||||
|     } | ||||
|  | ||||
|     public String getDisplayName() { | ||||
|         return this.displayName; | ||||
|     } | ||||
|  | ||||
|     public List<String> getDescription() { | ||||
|         return this.description; | ||||
|     } | ||||
|  | ||||
|     public ItemType getIcon() { | ||||
|         return this.icon; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Map<String, Object> serialize() { | ||||
|         final Map<String, Object> map = new HashMap<>(); | ||||
|   | ||||
| @@ -165,8 +165,8 @@ public class ComponentPresetManager { | ||||
|  | ||||
|         final List<ComponentPreset> allowedPresets = new ArrayList<>(this.presets.size()); | ||||
|         for (final ComponentPreset componentPreset : this.presets) { | ||||
|             if (!componentPreset.getPermission().isEmpty() && !player.hasPermission( | ||||
|                     componentPreset.getPermission() | ||||
|             if (!componentPreset.permission().isEmpty() && !player.hasPermission( | ||||
|                     componentPreset.permission() | ||||
|             )) { | ||||
|                 continue; | ||||
|             } | ||||
| @@ -200,30 +200,30 @@ public class ComponentPresetManager { | ||||
|                     return false; | ||||
|                 } | ||||
|  | ||||
|                 final Pattern pattern = PatternUtil.parse(null, componentPreset.getPattern(), false); | ||||
|                 final Pattern pattern = PatternUtil.parse(null, componentPreset.pattern(), false); | ||||
|                 if (pattern == null) { | ||||
|                     getPlayer().sendMessage(TranslatableCaption.of("preset.preset_invalid")); | ||||
|                     return false; | ||||
|                 } | ||||
|  | ||||
|                 if (componentPreset.getCost() > 0.0D) { | ||||
|                 if (componentPreset.cost() > 0.0D) { | ||||
|                     if (!econHandler.isEnabled(plot.getArea())) { | ||||
|                         getPlayer().sendMessage( | ||||
|                                 TranslatableCaption.of("preset.economy_disabled"), | ||||
|                                 TagResolver.resolver("preset", Tag.inserting(Component.text(componentPreset.getDisplayName()))) | ||||
|                                 TagResolver.resolver("preset", Tag.inserting(Component.text(componentPreset.displayName()))) | ||||
|                         ); | ||||
|                         return false; | ||||
|                     } | ||||
|                     if (econHandler.getMoney(getPlayer()) < componentPreset.getCost()) { | ||||
|                     if (econHandler.getMoney(getPlayer()) < componentPreset.cost()) { | ||||
|                         getPlayer().sendMessage(TranslatableCaption.of("preset.preset_cannot_afford")); | ||||
|                         return false; | ||||
|                     } else { | ||||
|                         econHandler.withdrawMoney(getPlayer(), componentPreset.getCost()); | ||||
|                         econHandler.withdrawMoney(getPlayer(), componentPreset.cost()); | ||||
|                         getPlayer().sendMessage( | ||||
|                                 TranslatableCaption.of("economy.removed_balance"), | ||||
|                                 TagResolver.resolver( | ||||
|                                         "money", | ||||
|                                         Tag.inserting(Component.text(econHandler.format(componentPreset.getCost()))) | ||||
|                                         Tag.inserting(Component.text(econHandler.format(componentPreset.cost()))) | ||||
|                                 ) | ||||
|                         ); | ||||
|                     } | ||||
| @@ -235,7 +235,7 @@ public class ComponentPresetManager { | ||||
|                     queue.setCompleteTask(plot::removeRunning); | ||||
|                     for (Plot current : plot.getConnectedPlots()) { | ||||
|                         current.getPlotModificationManager().setComponent( | ||||
|                                 componentPreset.getComponent().name(), | ||||
|                                 componentPreset.component().name(), | ||||
|                                 pattern, | ||||
|                                 player, | ||||
|                                 queue | ||||
| @@ -252,32 +252,32 @@ public class ComponentPresetManager { | ||||
|         for (int i = 0; i < allowedPresets.size(); i++) { | ||||
|             final ComponentPreset preset = allowedPresets.get(i); | ||||
|             final List<String> lore = new ArrayList<>(); | ||||
|             if (preset.getCost() > 0) { | ||||
|             if (preset.cost() > 0) { | ||||
|                 if (!this.econHandler.isEnabled(plot.getArea())) { | ||||
|                     lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize( | ||||
|                             TranslatableCaption.of("preset.preset_lore_economy_disabled").getComponent(player)))); | ||||
|                 } else { | ||||
|                     lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize( | ||||
|                             TranslatableCaption.of("preset.preset_lore_cost").getComponent(player), | ||||
|                             TagResolver.resolver("cost", Tag.inserting(Component.text(String.format("%.2f", preset.getCost())))) | ||||
|                             TagResolver.resolver("cost", Tag.inserting(Component.text(String.format("%.2f", preset.cost())))) | ||||
|                     ))); | ||||
|                 } | ||||
|             } | ||||
|             lore.add(MINI_MESSAGE.serialize(MINI_MESSAGE.deserialize( | ||||
|                     TranslatableCaption.of("preset.preset_lore_component").getComponent(player), | ||||
|                     TagResolver.builder() | ||||
|                             .tag("component", Tag.inserting(Component.text(preset.getComponent().name().toLowerCase()))) | ||||
|                             .tag("component", Tag.inserting(Component.text(preset.component().name().toLowerCase()))) | ||||
|                             .tag("prefix", Tag.inserting(TranslatableCaption.of("core.prefix").toComponent(player))) | ||||
|                             .build() | ||||
|             ))); | ||||
|             lore.removeIf(String::isEmpty); | ||||
|             lore.addAll(preset.getDescription()); | ||||
|             lore.addAll(preset.description()); | ||||
|             plotInventory.setItem( | ||||
|                     i, | ||||
|                     new PlotItemStack( | ||||
|                             preset.getIcon().getId().replace("minecraft:", ""), | ||||
|                             preset.icon().getId().replace("minecraft:", ""), | ||||
|                             1, | ||||
|                             preset.getDisplayName(), | ||||
|                             preset.displayName(), | ||||
|                             lore.toArray(new String[0]) | ||||
|                     ) | ||||
|             ); | ||||
|   | ||||
| @@ -2400,13 +2400,13 @@ public class SQLManager implements AbstractDB { | ||||
|                 if (plot != null) { | ||||
|                     statement.setString(1, plot.getArea().toString()); | ||||
|                     statement.setInt(2, plot.getId().hashCode()); | ||||
|                     statement.setString(3, comment.comment); | ||||
|                     statement.setString(4, comment.inbox); | ||||
|                     statement.setString(5, comment.senderName); | ||||
|                     statement.setString(3, comment.comment()); | ||||
|                     statement.setString(4, comment.inbox()); | ||||
|                     statement.setString(5, comment.senderName()); | ||||
|                 } else { | ||||
|                     statement.setString(1, comment.comment); | ||||
|                     statement.setString(2, comment.inbox); | ||||
|                     statement.setString(3, comment.senderName); | ||||
|                     statement.setString(1, comment.comment()); | ||||
|                     statement.setString(2, comment.inbox()); | ||||
|                     statement.setString(3, comment.senderName()); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @@ -2518,10 +2518,10 @@ public class SQLManager implements AbstractDB { | ||||
|             public void set(PreparedStatement statement) throws SQLException { | ||||
|                 statement.setString(1, plot.getArea().toString()); | ||||
|                 statement.setInt(2, plot.getId().hashCode()); | ||||
|                 statement.setString(3, comment.comment); | ||||
|                 statement.setString(4, comment.inbox); | ||||
|                 statement.setInt(5, (int) (comment.timestamp / 1000)); | ||||
|                 statement.setString(6, comment.senderName); | ||||
|                 statement.setString(3, comment.comment()); | ||||
|                 statement.setString(4, comment.inbox()); | ||||
|                 statement.setInt(5, (int) (comment.timestamp() / 1000)); | ||||
|                 statement.setString(6, comment.senderName()); | ||||
|             } | ||||
|  | ||||
|             @Override | ||||
| @@ -3414,15 +3414,10 @@ public class SQLManager implements AbstractDB { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private static class LegacySettings { | ||||
|  | ||||
|         public final int id; | ||||
|         public final PlotSettings settings; | ||||
|  | ||||
|         public LegacySettings(int id, PlotSettings settings) { | ||||
|             this.id = id; | ||||
|             this.settings = settings; | ||||
|         } | ||||
|     private record LegacySettings( | ||||
|             int id, | ||||
|             PlotSettings settings | ||||
|     ) { | ||||
|  | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -341,14 +341,14 @@ public class PlotListener { | ||||
|             } | ||||
|  | ||||
|             TimedFlag.Timed<Integer> feed = plot.getFlag(FeedFlag.class); | ||||
|             if (feed.getInterval() != 0 && feed.getValue() != 0) { | ||||
|             if (feed.interval() != 0 && feed.value() != 0) { | ||||
|                 feedRunnable | ||||
|                         .put(player.getUUID(), new Interval(feed.getInterval(), feed.getValue(), 20)); | ||||
|                         .put(player.getUUID(), new Interval(feed.interval(), feed.value(), 20)); | ||||
|             } | ||||
|             TimedFlag.Timed<Integer> heal = plot.getFlag(HealFlag.class); | ||||
|             if (heal.getInterval() != 0 && heal.getValue() != 0) { | ||||
|             if (heal.interval() != 0 && heal.value() != 0) { | ||||
|                 healRunnable | ||||
|                         .put(player.getUUID(), new Interval(heal.getInterval(), heal.getValue(), 20)); | ||||
|                         .put(player.getUUID(), new Interval(heal.interval(), heal.value(), 20)); | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|   | ||||
| @@ -21,17 +21,11 @@ package com.plotsquared.core.location; | ||||
| import com.plotsquared.core.util.MathMan; | ||||
| import com.plotsquared.core.util.StringMan; | ||||
|  | ||||
| public class ChunkWrapper { | ||||
|  | ||||
|     public final int x; | ||||
|     public final int z; | ||||
|     public final String world; | ||||
|  | ||||
|     public ChunkWrapper(String world, int x, int z) { | ||||
|         this.world = world; | ||||
|         this.x = x; | ||||
|         this.z = z; | ||||
|     } | ||||
| public record ChunkWrapper( | ||||
|         String world, | ||||
|         int x, | ||||
|         int z | ||||
| ) { | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() { | ||||
|   | ||||
| @@ -215,66 +215,48 @@ public final class BlockBucket implements ConfigurationSerializable { | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     private static final class Range { | ||||
|  | ||||
|         private final int min; | ||||
|         private final int max; | ||||
|         private final boolean automatic; | ||||
|  | ||||
|         public Range(int min, int max, boolean automatic) { | ||||
|             this.min = min; | ||||
|             this.max = max; | ||||
|             this.automatic = automatic; | ||||
|         } | ||||
|     private record Range( | ||||
|             int min, | ||||
|             int max, | ||||
|             boolean automatic | ||||
|     ) { | ||||
|  | ||||
|         public int getWeight() { | ||||
|             return max - min; | ||||
|         } | ||||
|                 return max - min; | ||||
|             } | ||||
|  | ||||
|         public boolean isInRange(final int num) { | ||||
|             return num <= max && num >= min; | ||||
|         } | ||||
|             public boolean isInRange(final int num) { | ||||
|                 return num <= max && num >= min; | ||||
|             } | ||||
|  | ||||
|         public int getMin() { | ||||
|             return this.min; | ||||
|         } | ||||
|  | ||||
|         public int getMax() { | ||||
|             return this.max; | ||||
|         } | ||||
|  | ||||
|         public boolean equals(final Object o) { | ||||
|             if (o == this) { | ||||
|             public boolean equals(final Object o) { | ||||
|                 if (o == this) { | ||||
|                     return true; | ||||
|                 } | ||||
|                 if (!(o instanceof final Range other)) { | ||||
|                     return false; | ||||
|                 } | ||||
|                 if (this.min() != other.min()) { | ||||
|                     return false; | ||||
|                 } | ||||
|                 if (this.max() != other.max()) { | ||||
|                     return false; | ||||
|                 } | ||||
|                 if (this.automatic() != other.automatic()) { | ||||
|                     return false; | ||||
|                 } | ||||
|                 return true; | ||||
|             } | ||||
|             if (!(o instanceof final Range other)) { | ||||
|                 return false; | ||||
|             } | ||||
|             if (this.getMin() != other.getMin()) { | ||||
|                 return false; | ||||
|             } | ||||
|             if (this.getMax() != other.getMax()) { | ||||
|                 return false; | ||||
|             } | ||||
|             if (this.isAutomatic() != other.isAutomatic()) { | ||||
|                 return false; | ||||
|             } | ||||
|             return true; | ||||
|         } | ||||
|  | ||||
|         public int hashCode() { | ||||
|             final int PRIME = 59; | ||||
|             int result = 1; | ||||
|             result = result * PRIME + this.getMin(); | ||||
|             result = result * PRIME + this.getMax(); | ||||
|             result = result * PRIME + (this.isAutomatic() ? 79 : 97); | ||||
|             return result; | ||||
|         } | ||||
|             public int hashCode() { | ||||
|                 final int PRIME = 59; | ||||
|                 int result = 1; | ||||
|                 result = result * PRIME + this.min(); | ||||
|                 result = result * PRIME + this.max(); | ||||
|                 result = result * PRIME + (this.automatic() ? 79 : 97); | ||||
|                 return result; | ||||
|             } | ||||
|  | ||||
|         public boolean isAutomatic() { | ||||
|             return this.automatic; | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -113,13 +113,12 @@ public class PlotSettings { | ||||
|         this.position = position; | ||||
|     } | ||||
|  | ||||
|     @SuppressWarnings({"UnstableApiUsage"}) | ||||
|     public List<PlotComment> getComments(String inbox) { | ||||
|         if (this.comments == null) { | ||||
|             return Collections.emptyList(); | ||||
|         } | ||||
|  | ||||
|         return this.comments.stream().filter(comment -> comment.inbox.equals(inbox)) | ||||
|         return this.comments.stream().filter(comment -> comment.inbox().equals(inbox)) | ||||
|                 .collect(ImmutableList.toImmutableList()); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -58,7 +58,7 @@ public class CommentManager { | ||||
|                         if (value != null) { | ||||
|                             int num = 0; | ||||
|                             for (PlotComment comment : value) { | ||||
|                                 if (comment.timestamp > getTimestamp(player, inbox.toString())) { | ||||
|                                 if (comment.timestamp() > getTimestamp(player, inbox.toString())) { | ||||
|                                     num++; | ||||
|                                 } | ||||
|                             } | ||||
|   | ||||
| @@ -20,25 +20,13 @@ package com.plotsquared.core.plot.comment; | ||||
|  | ||||
| import com.plotsquared.core.plot.PlotId; | ||||
|  | ||||
| public class PlotComment { | ||||
|  | ||||
|     public final String comment; | ||||
|     public final String inbox; | ||||
|     public final String senderName; | ||||
|     public final PlotId id; | ||||
|     public final String world; | ||||
|     public final long timestamp; | ||||
|  | ||||
|     public PlotComment( | ||||
|             String world, PlotId id, String comment, String senderName, String inbox, | ||||
|             long timestamp | ||||
|     ) { | ||||
|         this.world = world; | ||||
|         this.id = id; | ||||
|         this.comment = comment; | ||||
|         this.senderName = senderName; | ||||
|         this.inbox = inbox; | ||||
|         this.timestamp = timestamp; | ||||
|     } | ||||
| public record PlotComment( | ||||
|         String world, | ||||
|         PlotId id, | ||||
|         String comment, | ||||
|         String senderName, | ||||
|         String inbox, | ||||
|         long timestamp | ||||
| ) { | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -60,7 +60,7 @@ public class FeedFlag extends TimedFlag<Integer, FeedFlag> { | ||||
|  | ||||
|     @Override | ||||
|     protected Integer mergeValue(Integer other) { | ||||
|         return this.getValue().getValue() + other; | ||||
|         return this.getValue().value() + other; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -60,7 +60,7 @@ public class HealFlag extends TimedFlag<Integer, HealFlag> { | ||||
|  | ||||
|     @Override | ||||
|     protected Integer mergeValue(Integer other) { | ||||
|         return this.getValue().getValue() + other; | ||||
|         return this.getValue().value() + other; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -76,29 +76,16 @@ public abstract class TimedFlag<T, F extends PlotFlag<TimedFlag.Timed<T>, F>> | ||||
|         return getValue().toString(); | ||||
|     } | ||||
|  | ||||
|     public static final class Timed<T> { | ||||
|  | ||||
|         private final int interval; | ||||
|         private final T value; | ||||
|  | ||||
|         public Timed(int interval, T value) { | ||||
|             this.interval = interval; | ||||
|             this.value = value; | ||||
|         } | ||||
|  | ||||
|         public int getInterval() { | ||||
|             return interval; | ||||
|         } | ||||
|  | ||||
|         public T getValue() { | ||||
|             return value; | ||||
|         } | ||||
|     public record Timed<T>( | ||||
|             int interval, | ||||
|             T value | ||||
|     ) { | ||||
|  | ||||
|         @Override | ||||
|         public String toString() { | ||||
|             return String.format("%d %s", interval, value); | ||||
|             public String toString() { | ||||
|                 return String.format("%d %s", interval, value); | ||||
|             } | ||||
|  | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,105 @@ | ||||
| /* | ||||
|  * PlotSquared, a land and world management plugin for Minecraft. | ||||
|  * Copyright (C) IntellectualSites <https://intellectualsites.com> | ||||
|  * Copyright (C) IntellectualSites team and contributors | ||||
|  * | ||||
|  * This program is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or | ||||
|  * (at your option) any later version. | ||||
|  * | ||||
|  * This program is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU General Public License for more details. | ||||
|  * | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with this program.  If not, see <https://www.gnu.org/licenses/>. | ||||
|  */ | ||||
| package com.plotsquared.core.services.plots; | ||||
|  | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.PlotArea; | ||||
| import com.plotsquared.core.plot.PlotId; | ||||
| import org.checkerframework.checker.nullness.qual.NonNull; | ||||
| import org.checkerframework.checker.nullness.qual.Nullable; | ||||
|  | ||||
| public record AutoQuery( | ||||
|         PlotPlayer<?> player, | ||||
|         PlotId startId, | ||||
|         int sizeX, | ||||
|         int sizeZ, | ||||
|         PlotArea plotArea | ||||
| ) { | ||||
|  | ||||
|     /** | ||||
|      * Crate a new auto query | ||||
|      * | ||||
|      * @param player   Player to claim for | ||||
|      * @param startId  Plot ID to start searching from | ||||
|      * @param sizeX    Number of plots along the X axis | ||||
|      * @param sizeZ    Number of plots along the Z axis | ||||
|      * @param plotArea Plot area to search in | ||||
|      */ | ||||
|     public AutoQuery( | ||||
|             final @NonNull PlotPlayer<?> player, final @Nullable PlotId startId, | ||||
|             final int sizeX, final int sizeZ, final @NonNull PlotArea plotArea | ||||
|     ) { | ||||
|         this.player = player; | ||||
|         this.startId = startId; | ||||
|         this.sizeX = sizeX; | ||||
|         this.sizeZ = sizeZ; | ||||
|         this.plotArea = plotArea; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the player that the plots are meant for | ||||
|      * | ||||
|      * @return Player | ||||
|      */ | ||||
|     @Override | ||||
|     public @NonNull PlotPlayer<?> player() { | ||||
|         return this.player; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the plot ID to start searching from | ||||
|      * | ||||
|      * @return Start ID | ||||
|      */ | ||||
|     @Override | ||||
|     public @Nullable PlotId startId() { | ||||
|         return this.startId; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the number of plots along the X axis | ||||
|      * | ||||
|      * @return Number of plots along the X axis | ||||
|      */ | ||||
|     @Override | ||||
|     public int sizeX() { | ||||
|         return this.sizeX; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the number of plots along the Z axis | ||||
|      * | ||||
|      * @return Number of plots along the Z axis | ||||
|      */ | ||||
|     @Override | ||||
|     public int sizeZ() { | ||||
|         return this.sizeZ; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Get the plot area to search in | ||||
|      * | ||||
|      * @return Plot area | ||||
|      */ | ||||
|     @Override | ||||
|     public @NonNull PlotArea plotArea() { | ||||
|         return this.plotArea; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -21,9 +21,7 @@ package com.plotsquared.core.services.plots; | ||||
| import cloud.commandframework.services.types.Service; | ||||
| import com.google.common.cache.Cache; | ||||
| import com.google.common.cache.CacheBuilder; | ||||
| import com.plotsquared.core.player.PlotPlayer; | ||||
| import com.plotsquared.core.plot.Plot; | ||||
| import com.plotsquared.core.plot.PlotArea; | ||||
| import com.plotsquared.core.plot.PlotAreaType; | ||||
| import com.plotsquared.core.plot.PlotId; | ||||
| import org.checkerframework.checker.nullness.qual.NonNull; | ||||
| @@ -34,88 +32,12 @@ import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.function.Predicate; | ||||
|  | ||||
| public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>> { | ||||
| public interface AutoService extends Service<AutoQuery, List<Plot>> { | ||||
|  | ||||
|     Cache<PlotId, Plot> plotCandidateCache = CacheBuilder.newBuilder() | ||||
|             .expireAfterWrite(20, TimeUnit.SECONDS).build(); | ||||
|     Object plotLock = new Object(); | ||||
|  | ||||
|     final class AutoQuery { | ||||
|  | ||||
|         private final PlotPlayer<?> player; | ||||
|         private final PlotId startId; | ||||
|         private final int sizeX; | ||||
|         private final int sizeZ; | ||||
|         private final PlotArea plotArea; | ||||
|  | ||||
|         /** | ||||
|          * Crate a new auto query | ||||
|          * | ||||
|          * @param player   Player to claim for | ||||
|          * @param startId  Plot ID to start searching from | ||||
|          * @param sizeX    Number of plots along the X axis | ||||
|          * @param sizeZ    Number of plots along the Z axis | ||||
|          * @param plotArea Plot area to search in | ||||
|          */ | ||||
|         public AutoQuery( | ||||
|                 final @NonNull PlotPlayer<?> player, final @Nullable PlotId startId, | ||||
|                 final int sizeX, final int sizeZ, final @NonNull PlotArea plotArea | ||||
|         ) { | ||||
|             this.player = player; | ||||
|             this.startId = startId; | ||||
|             this.sizeX = sizeX; | ||||
|             this.sizeZ = sizeZ; | ||||
|             this.plotArea = plotArea; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Get the player that the plots are meant for | ||||
|          * | ||||
|          * @return Player | ||||
|          */ | ||||
|         public @NonNull PlotPlayer<?> getPlayer() { | ||||
|             return this.player; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Get the plot ID to start searching from | ||||
|          * | ||||
|          * @return Start ID | ||||
|          */ | ||||
|         public @Nullable PlotId getStartId() { | ||||
|             return this.startId; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Get the number of plots along the X axis | ||||
|          * | ||||
|          * @return Number of plots along the X axis | ||||
|          */ | ||||
|         public int getSizeX() { | ||||
|             return this.sizeX; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Get the number of plots along the Z axis | ||||
|          * | ||||
|          * @return Number of plots along the Z axis | ||||
|          */ | ||||
|         public int getSizeZ() { | ||||
|             return this.sizeZ; | ||||
|         } | ||||
|  | ||||
|         /** | ||||
|          * Get the plot area to search in | ||||
|          * | ||||
|          * @return Plot area | ||||
|          */ | ||||
|         public @NonNull PlotArea getPlotArea() { | ||||
|             return this.plotArea; | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
|     final class DefaultAutoService implements AutoService { | ||||
|  | ||||
|         @Override | ||||
| @@ -125,17 +47,16 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>> | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
|     final class SinglePlotService implements AutoService, Predicate<AutoQuery> { | ||||
|  | ||||
|         @Nullable | ||||
|         @Override | ||||
|         public List<Plot> handle(@NonNull AutoQuery autoQuery) { | ||||
|             Plot plot; | ||||
|             PlotId nextId = autoQuery.getStartId(); | ||||
|             PlotId nextId = autoQuery.startId(); | ||||
|             do { | ||||
|                 synchronized (plotLock) { | ||||
|                     plot = autoQuery.getPlotArea().getNextFreePlot(autoQuery.getPlayer(), nextId); | ||||
|                     plot = autoQuery.plotArea().getNextFreePlot(autoQuery.player(), nextId); | ||||
|                     if (plot != null && plotCandidateCache.getIfPresent(plot.getId()) == null) { | ||||
|                         plotCandidateCache.put(plot.getId(), plot); | ||||
|                         return Collections.singletonList(plot); | ||||
| @@ -151,12 +72,11 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>> | ||||
|  | ||||
|         @Override | ||||
|         public boolean test(final @NonNull AutoQuery autoQuery) { | ||||
|             return autoQuery.sizeX == 1 && autoQuery.sizeZ == 1; | ||||
|             return autoQuery.sizeX() == 1 && autoQuery.sizeZ() == 1; | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
|     final class MultiPlotService implements AutoService, Predicate<AutoQuery> { | ||||
|  | ||||
|         @Override | ||||
| @@ -166,14 +86,14 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>> | ||||
|             while (true) { | ||||
|                 synchronized (plotLock) { | ||||
|                     final PlotId start = | ||||
|                             autoQuery.getPlotArea().getMeta("lastPlot", PlotId.of(0, 0)).getNextId(); | ||||
|                             autoQuery.plotArea().getMeta("lastPlot", PlotId.of(0, 0)).getNextId(); | ||||
|                     final PlotId end = PlotId.of( | ||||
|                             start.getX() + autoQuery.getSizeX() - 1, | ||||
|                             start.getY() + autoQuery.getSizeZ() - 1 | ||||
|                             start.getX() + autoQuery.sizeX() - 1, | ||||
|                             start.getY() + autoQuery.sizeZ() - 1 | ||||
|                     ); | ||||
|                     final List<Plot> plots = | ||||
|                             autoQuery.getPlotArea().canClaim(autoQuery.getPlayer(), start, end); | ||||
|                     autoQuery.getPlotArea().setMeta("lastPlot", start); // set entry point for next try | ||||
|                             autoQuery.plotArea().canClaim(autoQuery.player(), start, end); | ||||
|                     autoQuery.plotArea().setMeta("lastPlot", start); // set entry point for next try | ||||
|                     if (plots != null && !plots.isEmpty()) { | ||||
|                         for (final Plot plot : plots) { | ||||
|                             if (plotCandidateCache.getIfPresent(plot.getId()) != null) { | ||||
| @@ -189,7 +109,7 @@ public interface AutoService extends Service<AutoService.AutoQuery, List<Plot>> | ||||
|  | ||||
|         @Override | ||||
|         public boolean test(final @NonNull AutoQuery autoQuery) { | ||||
|             return autoQuery.getPlotArea().getType() != PlotAreaType.PARTIAL; | ||||
|             return autoQuery.plotArea().getType() != PlotAreaType.PARTIAL; | ||||
|         } | ||||
|  | ||||
|     } | ||||
|   | ||||
| @@ -48,10 +48,10 @@ public class SettingsNodeStep implements SetupStep { | ||||
|     ) { | ||||
|         this.configurationNode = configurationNode; | ||||
|         this.id = id; | ||||
|         if (wrapper.getSettingsNodes().length > id + 1) { | ||||
|             this.next = new SettingsNodeStep(wrapper.getSettingsNodes()[id + 1], id + 1, wrapper); | ||||
|         if (wrapper.settingsNodes().length > id + 1) { | ||||
|             this.next = new SettingsNodeStep(wrapper.settingsNodes()[id + 1], id + 1, wrapper); | ||||
|         } else { | ||||
|             this.next = wrapper.getAfterwards(); | ||||
|             this.next = wrapper.afterwards(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -23,15 +23,10 @@ import com.plotsquared.core.configuration.ConfigurationNode; | ||||
| /** | ||||
|  * This class wraps an array of {@link ConfigurationNode}s. | ||||
|  */ | ||||
| public class SettingsNodesWrapper { | ||||
|  | ||||
|     private final ConfigurationNode[] settingsNodes; | ||||
|     private final SetupStep afterwards; | ||||
|  | ||||
|     public SettingsNodesWrapper(final ConfigurationNode[] settingsNodes, final SetupStep afterwards) { | ||||
|         this.settingsNodes = settingsNodes; | ||||
|         this.afterwards = afterwards; | ||||
|     } | ||||
| public record SettingsNodesWrapper( | ||||
|         ConfigurationNode[] settingsNodes, | ||||
|         SetupStep afterwards | ||||
| ) { | ||||
|  | ||||
|     /** | ||||
|      * Returns the first step of this wrapper or the step or the | ||||
| @@ -43,12 +38,4 @@ public class SettingsNodesWrapper { | ||||
|         return this.settingsNodes.length == 0 ? this.afterwards : new SettingsNodeStep(this.settingsNodes[0], 0, this); | ||||
|     } | ||||
|  | ||||
|     public ConfigurationNode[] getSettingsNodes() { | ||||
|         return this.settingsNodes; | ||||
|     } | ||||
|  | ||||
|     public SetupStep getAfterwards() { | ||||
|         return this.afterwards; | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -18,14 +18,9 @@ | ||||
|  */ | ||||
| package com.plotsquared.core.util; | ||||
|  | ||||
| public class FileBytes { | ||||
|  | ||||
|     public final String path; | ||||
|     public final byte[] data; | ||||
|  | ||||
|     public FileBytes(String path, byte[] data) { | ||||
|         this.path = path; | ||||
|         this.data = data; | ||||
|     } | ||||
| public record FileBytes( | ||||
|         String path, | ||||
|         byte[] data | ||||
| ) { | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -98,7 +98,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> { | ||||
|                             consumer.accept(null, throwable); | ||||
|                         } else { | ||||
|                             for (final UUIDMapping uuid : uuids) { | ||||
|                                 result.add(uuid.getUuid()); | ||||
|                                 result.add(uuid.uuid()); | ||||
|                             } | ||||
|                             consumer.accept(result, null); | ||||
|                         } | ||||
| @@ -136,7 +136,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> { | ||||
|         try { | ||||
|             for (final UUIDMapping mapping : PlotSquared.get().getImpromptuUUIDPipeline() | ||||
|                     .getNames(players).get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS)) { | ||||
|                 users.add(Component.text(mapping.getUsername())); | ||||
|                 users.add(Component.text(mapping.username())); | ||||
|             } | ||||
|         } catch (final Exception e) { | ||||
|             e.printStackTrace(); | ||||
| @@ -200,7 +200,7 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> { | ||||
|             final UUIDMapping uuidMapping = | ||||
|                     PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner); | ||||
|             if (uuidMapping != null) { | ||||
|                 name = uuidMapping.getUsername(); | ||||
|                 name = uuidMapping.username(); | ||||
|             } else { | ||||
|                 name = null; | ||||
|             } | ||||
|   | ||||
| @@ -238,8 +238,8 @@ public final class TabCompletions { | ||||
|                         PlotSquared.get().getImpromptuUUIDPipeline().getAllImmediately(); | ||||
|                 players = new ArrayList<>(mappings.size()); | ||||
|                 for (final UUIDMapping mapping : mappings) { | ||||
|                     if (uuidFilter.test(mapping.getUuid())) { | ||||
|                         players.add(mapping.getUsername()); | ||||
|                     if (uuidFilter.test(mapping.uuid())) { | ||||
|                         players.add(mapping.username()); | ||||
|                     } | ||||
|                 } | ||||
|                 cachedCompletionValues.put(cacheIdentifier, players); | ||||
|   | ||||
| @@ -298,19 +298,11 @@ public final class PlaceholderRegistry { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Event called when a new {@link Placeholder} has been added | ||||
|      */ | ||||
|     public static class PlaceholderAddedEvent { | ||||
|  | ||||
|         private final Placeholder placeholder; | ||||
|  | ||||
|         public PlaceholderAddedEvent(Placeholder placeholder) { | ||||
|             this.placeholder = placeholder; | ||||
|         } | ||||
|  | ||||
|         public Placeholder getPlaceholder() { | ||||
|             return this.placeholder; | ||||
|         } | ||||
|     * Event called when a new {@link Placeholder} has been added | ||||
|     */ | ||||
|     public record PlaceholderAddedEvent( | ||||
|             Placeholder placeholder | ||||
|     ) { | ||||
|  | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -67,8 +67,8 @@ public class CacheUUIDService implements UUIDService, Consumer<List<UUIDMapping> | ||||
|     @Override | ||||
|     public void accept(final @NonNull List<@NonNull UUIDMapping> uuidMappings) { | ||||
|         for (final UUIDMapping mapping : uuidMappings) { | ||||
|             this.uuidCache.put(mapping.getUuid(), mapping); | ||||
|             this.usernameCache.put(mapping.getUsername(), mapping); | ||||
|             this.uuidCache.put(mapping.uuid(), mapping); | ||||
|             this.usernameCache.put(mapping.username(), mapping); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -20,29 +20,15 @@ package com.plotsquared.core.uuid; | ||||
|  | ||||
| import org.checkerframework.checker.nullness.qual.NonNull; | ||||
|  | ||||
| import java.util.Objects; | ||||
| import java.util.UUID; | ||||
|  | ||||
| /** | ||||
|  * A pair consisting of a UUID and a username | ||||
|  */ | ||||
| public class UUIDMapping { | ||||
|  | ||||
|     private final UUID uuid; | ||||
|     private final String username; | ||||
|  | ||||
|     public UUIDMapping(final @NonNull UUID uuid, final @NonNull String username) { | ||||
|         this.uuid = uuid; | ||||
|         this.username = username; | ||||
|     } | ||||
|  | ||||
|     public @NonNull String getUsername() { | ||||
|         return this.username; | ||||
|     } | ||||
|  | ||||
|     public @NonNull UUID getUuid() { | ||||
|         return this.uuid; | ||||
|     } | ||||
| public record UUIDMapping( | ||||
|         @NonNull UUID uuid, | ||||
|         @NonNull String username | ||||
| ) { | ||||
|  | ||||
|     @Override | ||||
|     public boolean equals(final Object o) { | ||||
| @@ -56,9 +42,4 @@ public class UUIDMapping { | ||||
|         return uuid.equals(that.uuid) && username.equals(that.username); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public int hashCode() { | ||||
|         return Objects.hash(uuid, username); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -157,7 +157,7 @@ public class UUIDPipeline { | ||||
|                     TimeUnit.MILLISECONDS | ||||
|             ); | ||||
|             if (mappings.size() == 1) { | ||||
|                 return mappings.get(0).getUuid(); | ||||
|                 return mappings.get(0).uuid(); | ||||
|             } | ||||
|         } catch (InterruptedException | ExecutionException e) { | ||||
|             e.printStackTrace(); | ||||
| @@ -182,7 +182,7 @@ public class UUIDPipeline { | ||||
|         try { | ||||
|             final List<UUIDMapping> mappings = this.getNames(Collections.singletonList(uuid)).get(timeout, TimeUnit.MILLISECONDS); | ||||
|             if (mappings.size() == 1) { | ||||
|                 return mappings.get(0).getUsername(); | ||||
|                 return mappings.get(0).username(); | ||||
|             } | ||||
|         } catch (InterruptedException | ExecutionException e) { | ||||
|             e.printStackTrace(); | ||||
| @@ -209,7 +209,7 @@ public class UUIDPipeline { | ||||
|                         uuid.accept(null, throwable); | ||||
|                     } else { | ||||
|                         if (!uuids.isEmpty()) { | ||||
|                             uuid.accept(uuids.get(0).getUuid(), null); | ||||
|                             uuid.accept(uuids.get(0).uuid(), null); | ||||
|                         } else { | ||||
|                             uuid.accept(null, null); | ||||
|                         } | ||||
| @@ -231,7 +231,7 @@ public class UUIDPipeline { | ||||
|                         username.accept(null, throwable); | ||||
|                     } else { | ||||
|                         if (!uuids.isEmpty()) { | ||||
|                             username.accept(uuids.get(0).getUsername(), null); | ||||
|                             username.accept(uuids.get(0).username(), null); | ||||
|                         } else { | ||||
|                             username.accept(null, null); | ||||
|                         } | ||||
| @@ -296,7 +296,7 @@ public class UUIDPipeline { | ||||
|             if (service.canBeSynchronous()) { | ||||
|                 final List<UUIDMapping> completedRequests = service.getNames(remainingRequests); | ||||
|                 for (final UUIDMapping mapping : completedRequests) { | ||||
|                     remainingRequests.remove(mapping.getUuid()); | ||||
|                     remainingRequests.remove(mapping.uuid()); | ||||
|                 } | ||||
|                 mappings.addAll(completedRequests); | ||||
|             } else { | ||||
| @@ -311,7 +311,7 @@ public class UUIDPipeline { | ||||
|             for (final UUIDService service : serviceList) { | ||||
|                 final List<UUIDMapping> completedRequests = service.getNames(remainingRequests); | ||||
|                 for (final UUIDMapping mapping : completedRequests) { | ||||
|                     remainingRequests.remove(mapping.getUuid()); | ||||
|                     remainingRequests.remove(mapping.uuid()); | ||||
|                 } | ||||
|                 mappings.addAll(completedRequests); | ||||
|                 if (remainingRequests.isEmpty()) { | ||||
| @@ -365,7 +365,7 @@ public class UUIDPipeline { | ||||
|             if (service.canBeSynchronous()) { | ||||
|                 final List<UUIDMapping> completedRequests = service.getUUIDs(remainingRequests); | ||||
|                 for (final UUIDMapping mapping : completedRequests) { | ||||
|                     remainingRequests.remove(mapping.getUsername()); | ||||
|                     remainingRequests.remove(mapping.username()); | ||||
|                 } | ||||
|                 mappings.addAll(completedRequests); | ||||
|             } else { | ||||
| @@ -380,7 +380,7 @@ public class UUIDPipeline { | ||||
|             for (final UUIDService service : serviceList) { | ||||
|                 final List<UUIDMapping> completedRequests = service.getUUIDs(remainingRequests); | ||||
|                 for (final UUIDMapping mapping : completedRequests) { | ||||
|                     remainingRequests.remove(mapping.getUsername()); | ||||
|                     remainingRequests.remove(mapping.username()); | ||||
|                 } | ||||
|                 mappings.addAll(completedRequests); | ||||
|                 if (remainingRequests.isEmpty()) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user