mirror of
				https://github.com/IntellectualSites/PlotSquared.git
				synced 2025-10-31 17:43:44 +01:00 
			
		
		
		
	Compare commits
	
		
			7 Commits
		
	
	
		
			6.3.0
			...
			fix/v6/nul
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 4c166d057e | ||
|   | 827f46566c | ||
|   | 6f4d2f6d5a | ||
|   | 6073b96317 | ||
| ![renovate[bot]](/assets/img/avatar_default.png)  | 74a490f9f0 | ||
|   | 3a752db698 | ||
|   | 7cdde5a822 | 
							
								
								
									
										2
									
								
								.github/workflows/release-drafter.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/release-drafter.yml
									
									
									
									
										vendored
									
									
								
							| @@ -13,6 +13,6 @@ jobs: | |||||||
|   update_release_draft: |   update_release_draft: | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|     steps: |     steps: | ||||||
|       - uses: release-drafter/release-drafter@v5.15.0 |       - uses: release-drafter/release-drafter@v5.17.5 | ||||||
|         env: |         env: | ||||||
|           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								.lift.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								.lift.toml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,4 @@ | |||||||
|  | jdkVersion = "17" | ||||||
|  | build = "gradle clean build -x test" | ||||||
|  | tools = ["findsecbugs", "ErrorProne", "Semgrep", "Detekt", "Infer"] | ||||||
|  | ignoreRules = ["CatchAndPrintStackTrace", "ReferenceEquality", "FallThrough", "FutureReturnValueIgnored", "MixedMutabilityReturnType", "EmptyCatch", "MissingCasesInEnumSwitch", "OperatorPrecedence", "StaticAssignmentInConstructor", "ReferenceEquality", "EqualsHashCode", "EqualsGetClass", "TypeParameterUnusedInFormals"] | ||||||
| @@ -218,6 +218,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | |||||||
|     private PlatformWorldManager<World> worldManager; |     private PlatformWorldManager<World> worldManager; | ||||||
|     private Locale serverLocale; |     private Locale serverLocale; | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("StringSplitter") | ||||||
|     @Override |     @Override | ||||||
|     public int @NonNull [] serverVersion() { |     public int @NonNull [] serverVersion() { | ||||||
|         if (this.version == null) { |         if (this.version == null) { | ||||||
| @@ -970,7 +971,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | |||||||
|                                                 } |                                                 } | ||||||
|                                                 iterator.remove(); |                                                 iterator.remove(); | ||||||
|                                                 entity.remove(); |                                                 entity.remove(); | ||||||
|                                                 continue; |  | ||||||
|                                             } |                                             } | ||||||
|                                         } |                                         } | ||||||
|                                     } else { |                                     } else { | ||||||
| @@ -982,7 +982,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | |||||||
|                                             } |                                             } | ||||||
|                                             iterator.remove(); |                                             iterator.remove(); | ||||||
|                                             entity.remove(); |                                             entity.remove(); | ||||||
|                                             continue; |  | ||||||
|                                         } |                                         } | ||||||
|                                     } |                                     } | ||||||
|                                 } |                                 } | ||||||
| @@ -1223,7 +1222,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl | |||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     @NonNull |     @NonNull | ||||||
|     @SuppressWarnings("ALL") |     @SuppressWarnings("unchecked") | ||||||
|     public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> playerManager() { |     public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> playerManager() { | ||||||
|         return (PlayerManager<BukkitPlayer, Player>) injector().getInstance(PlayerManager.class); |         return (PlayerManager<BukkitPlayer, Player>) injector().getInstance(PlayerManager.class); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -461,6 +461,7 @@ public final class ReplicatingEntityWrapper extends EntityWrapper { | |||||||
|         this.tamed.tamed = tamed.isTamed(); |         this.tamed.tamed = tamed.isTamed(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("deprecation") // Paper deprecation | ||||||
|     @Override |     @Override | ||||||
|     public Entity spawn(World world, int xOffset, int zOffset) { |     public Entity spawn(World world, int xOffset, int zOffset) { | ||||||
|         Location location = new Location(world, this.getX() + xOffset, this.getY(), this.z + zOffset); |         Location location = new Location(world, this.getX() + xOffset, this.getY(), this.z + zOffset); | ||||||
|   | |||||||
| @@ -36,6 +36,7 @@ import org.bukkit.World; | |||||||
|  |  | ||||||
| public class WorldManagerModule extends AbstractModule { | public class WorldManagerModule extends AbstractModule { | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("removal") // Internal use only | ||||||
|     @Provides |     @Provides | ||||||
|     @Singleton |     @Singleton | ||||||
|     PlatformWorldManager<World> provideWorldManager() { |     PlatformWorldManager<World> provideWorldManager() { | ||||||
|   | |||||||
| @@ -36,7 +36,6 @@ import com.plotsquared.core.plot.world.PlotAreaManager; | |||||||
| import net.kyori.adventure.text.minimessage.Template; | import net.kyori.adventure.text.minimessage.Template; | ||||||
| import org.bukkit.block.Banner; | import org.bukkit.block.Banner; | ||||||
| import org.bukkit.block.Beacon; | import org.bukkit.block.Beacon; | ||||||
| import org.bukkit.block.Bed; |  | ||||||
| import org.bukkit.block.BlockState; | import org.bukkit.block.BlockState; | ||||||
| import org.bukkit.block.CommandBlock; | import org.bukkit.block.CommandBlock; | ||||||
| import org.bukkit.block.Comparator; | import org.bukkit.block.Comparator; | ||||||
| @@ -51,6 +50,7 @@ import org.bukkit.block.Jukebox; | |||||||
| import org.bukkit.block.Sign; | import org.bukkit.block.Sign; | ||||||
| import org.bukkit.block.Skull; | import org.bukkit.block.Skull; | ||||||
| import org.bukkit.block.Structure; | import org.bukkit.block.Structure; | ||||||
|  | import org.bukkit.block.data.type.Bed; | ||||||
| import org.bukkit.event.EventHandler; | import org.bukkit.event.EventHandler; | ||||||
| import org.bukkit.event.block.BlockPlaceEvent; | import org.bukkit.event.block.BlockPlaceEvent; | ||||||
| import org.checkerframework.checker.nullness.qual.NonNull; | import org.checkerframework.checker.nullness.qual.NonNull; | ||||||
|   | |||||||
| @@ -154,7 +154,6 @@ import org.checkerframework.checker.nullness.qual.NonNull; | |||||||
|  |  | ||||||
| import java.lang.reflect.Field; | import java.lang.reflect.Field; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.Arrays; |  | ||||||
| import java.util.HashSet; | import java.util.HashSet; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Locale; | import java.util.Locale; | ||||||
| @@ -224,6 +223,7 @@ public class PlayerEventListener extends PlotListener implements Listener { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("StringSplitter") | ||||||
|     @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) |     @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) | ||||||
|     public void playerCommand(PlayerCommandPreprocessEvent event) { |     public void playerCommand(PlayerCommandPreprocessEvent event) { | ||||||
|         String msg = event.getMessage().toLowerCase().replaceAll("/", "").trim(); |         String msg = event.getMessage().toLowerCase().replaceAll("/", "").trim(); | ||||||
| @@ -379,6 +379,7 @@ public class PlayerEventListener extends PlotListener implements Listener { | |||||||
|         this.eventDispatcher.doRespawnTask(pp); |         this.eventDispatcher.doRespawnTask(pp); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("deprecation") // We explicitly want #getHomeSynchronous here | ||||||
|     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |     @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||||||
|     public void onTeleport(PlayerTeleportEvent event) { |     public void onTeleport(PlayerTeleportEvent event) { | ||||||
|         Player player = event.getPlayer(); |         Player player = event.getPlayer(); | ||||||
| @@ -1063,9 +1064,13 @@ public class PlayerEventListener extends PlotListener implements Listener { | |||||||
|         if (area == null) { |         if (area == null) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         PlayerBlockEventType eventType = null; |         PlayerBlockEventType eventType; | ||||||
|         BlockType blocktype1; |         BlockType blocktype1; | ||||||
|         Block block = event.getClickedBlock(); |         Block block = event.getClickedBlock(); | ||||||
|  |         if (block == null) { | ||||||
|  |             // We do not care in this case, the player is likely interacting with air ("nothing"). | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|         Location location = BukkitUtil.adapt(block.getLocation()); |         Location location = BukkitUtil.adapt(block.getLocation()); | ||||||
|         Action action = event.getAction(); |         Action action = event.getAction(); | ||||||
|         switch (action) { |         switch (action) { | ||||||
| @@ -1667,6 +1672,7 @@ public class PlayerEventListener extends PlotListener implements Listener { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("deprecation") // #getLocate is needed for Spigot compatibility | ||||||
|     @EventHandler |     @EventHandler | ||||||
|     public void onLocaleChange(final PlayerLocaleChangeEvent event) { |     public void onLocaleChange(final PlayerLocaleChangeEvent event) { | ||||||
|         // The event is fired before the player is deemed online upon login |         // The event is fired before the player is deemed online upon login | ||||||
|   | |||||||
| @@ -43,7 +43,6 @@ import java.lang.reflect.Method; | |||||||
|  |  | ||||||
| import static com.plotsquared.core.util.ReflectionUtils.getRefClass; | import static com.plotsquared.core.util.ReflectionUtils.getRefClass; | ||||||
|  |  | ||||||
| @SuppressWarnings("unused") |  | ||||||
| public class SingleWorldListener implements Listener { | public class SingleWorldListener implements Listener { | ||||||
|  |  | ||||||
|     private final Method methodGetHandleChunk; |     private final Method methodGetHandleChunk; | ||||||
|   | |||||||
| @@ -162,6 +162,7 @@ public class BukkitPlayer extends PlotPlayer<Player> { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("StringSplitter") | ||||||
|     @Override |     @Override | ||||||
|     @NonNegative |     @NonNegative | ||||||
|     public int hasPermissionRange( |     public int hasPermissionRange( | ||||||
| @@ -319,7 +320,7 @@ public class BukkitPlayer extends PlotPlayer<Player> { | |||||||
|         if (id == ItemTypes.AIR) { |         if (id == ItemTypes.AIR) { | ||||||
|             // Let's just stop all the discs because why not? |             // Let's just stop all the discs because why not? | ||||||
|             for (final Sound sound : Arrays.stream(Sound.values()) |             for (final Sound sound : Arrays.stream(Sound.values()) | ||||||
|                     .filter(sound -> sound.name().contains("DISC")).collect(Collectors.toList())) { |                     .filter(sound -> sound.name().contains("DISC")).toList()) { | ||||||
|                 player.stopSound(sound); |                 player.stopSound(sound); | ||||||
|             } |             } | ||||||
|             // this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, Material.AIR); |             // this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, Material.AIR); | ||||||
| @@ -331,6 +332,7 @@ public class BukkitPlayer extends PlotPlayer<Player> { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("deprecation") // Needed for Spigot compatibility | ||||||
|     @Override |     @Override | ||||||
|     public void kick(final String message) { |     public void kick(final String message) { | ||||||
|         this.player.kickPlayer(message); |         this.player.kickPlayer(message); | ||||||
|   | |||||||
| @@ -199,7 +199,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|                 if (localChunk.getTiles().size() > 0) { |                 if (localChunk.getTiles().size() > 0) { | ||||||
|                     localChunk.getTiles().forEach(((blockVector3, tag) -> { |                     localChunk.getTiles().forEach((blockVector3, tag) -> { | ||||||
|                         try { |                         try { | ||||||
|                             BaseBlock block = getWorld().getBlock(blockVector3).toBaseBlock(tag); |                             BaseBlock block = getWorld().getBlock(blockVector3).toBaseBlock(tag); | ||||||
|                             getWorld().setBlock(blockVector3, block, noSideEffectSet); |                             getWorld().setBlock(blockVector3, block, noSideEffectSet); | ||||||
| @@ -207,7 +207,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { | |||||||
|                             StateWrapper sw = new StateWrapper(tag); |                             StateWrapper sw = new StateWrapper(tag); | ||||||
|                             sw.restoreTag(getWorld().getName(), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()); |                             sw.restoreTag(getWorld().getName(), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()); | ||||||
|                         } |                         } | ||||||
|                     })); |                     }); | ||||||
|                 } |                 } | ||||||
|                 if (localChunk.getEntities().size() > 0) { |                 if (localChunk.getEntities().size() > 0) { | ||||||
|                     localChunk.getEntities().forEach((location, entity) -> getWorld().createEntity(location, entity)); |                     localChunk.getEntities().forEach((location, entity) -> getWorld().createEntity(location, entity)); | ||||||
|   | |||||||
| @@ -166,6 +166,7 @@ public class StateWrapper { | |||||||
|         return str; |         return str; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("deprecation") // #setLine is needed for Spigot compatibility | ||||||
|     public boolean restoreTag(String worldName, int x, int y, int z) { |     public boolean restoreTag(String worldName, int x, int y, int z) { | ||||||
|         if (this.tag == null) { |         if (this.tag == null) { | ||||||
|             return false; |             return false; | ||||||
|   | |||||||
| @@ -77,6 +77,7 @@ public class BukkitInventoryUtil extends InventoryUtil { | |||||||
|         return stack; |         return stack; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("deprecation") // Paper deprecation | ||||||
|     @Override |     @Override | ||||||
|     public void open(PlotInventory inv) { |     public void open(PlotInventory inv) { | ||||||
|         BukkitPlayer bp = (BukkitPlayer) inv.getPlayer(); |         BukkitPlayer bp = (BukkitPlayer) inv.getPlayer(); | ||||||
| @@ -113,6 +114,7 @@ public class BukkitInventoryUtil extends InventoryUtil { | |||||||
|         bp.player.updateInventory(); |         bp.player.updateInventory(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("deprecation") // Paper deprecation | ||||||
|     public PlotItemStack getItem(ItemStack item) { |     public PlotItemStack getItem(ItemStack item) { | ||||||
|         if (item == null) { |         if (item == null) { | ||||||
|             return null; |             return null; | ||||||
| @@ -145,6 +147,7 @@ public class BukkitInventoryUtil extends InventoryUtil { | |||||||
|                 .toArray(PlotItemStack[]::new); |                 .toArray(PlotItemStack[]::new); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("deprecation") // #getTitle is needed for Spigot compatibility | ||||||
|     @Override |     @Override | ||||||
|     public boolean isOpen(PlotInventory plotInventory) { |     public boolean isOpen(PlotInventory plotInventory) { | ||||||
|         if (!plotInventory.isOpen()) { |         if (!plotInventory.isOpen()) { | ||||||
|   | |||||||
| @@ -61,6 +61,7 @@ public class UpdateUtility implements Listener { | |||||||
|         internalVersion = PlotSquared.get().getVersion(); |         internalVersion = PlotSquared.get().getVersion(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings({"deprecation", "DefaultCharset"}) // Suppress Json deprecation, we can't use features from gson 2.8.1 and newer yet | ||||||
|     public void updateChecker() { |     public void updateChecker() { | ||||||
|         task = Bukkit.getScheduler().runTaskTimerAsynchronously(this.javaPlugin, () -> { |         task = Bukkit.getScheduler().runTaskTimerAsynchronously(this.javaPlugin, () -> { | ||||||
|             try { |             try { | ||||||
| @@ -68,7 +69,7 @@ public class UpdateUtility implements Listener { | |||||||
|                         "https://api.spigotmc.org/simple/0.1/index.php?action=getResource&id=77506") |                         "https://api.spigotmc.org/simple/0.1/index.php?action=getResource&id=77506") | ||||||
|                         .openConnection(); |                         .openConnection(); | ||||||
|                 connection.setRequestMethod("GET"); |                 connection.setRequestMethod("GET"); | ||||||
|                 JsonObject result = (new JsonParser()) |                 JsonObject result = new JsonParser() | ||||||
|                         .parse(new JsonReader(new InputStreamReader(connection.getInputStream()))) |                         .parse(new JsonReader(new InputStreamReader(connection.getInputStream()))) | ||||||
|                         .getAsJsonObject(); |                         .getAsJsonObject(); | ||||||
|                 spigotVersion = result.get("current_version").getAsString(); |                 spigotVersion = result.get("current_version").getAsString(); | ||||||
| @@ -91,7 +92,7 @@ public class UpdateUtility implements Listener { | |||||||
|                 notify = false; |                 notify = false; | ||||||
|                 LOGGER.info("Congratulations! You are running the latest PlotSquared version"); |                 LOGGER.info("Congratulations! You are running the latest PlotSquared version"); | ||||||
|             } |             } | ||||||
|         }, 0L, Settings.UpdateChecker.POLL_RATE * 60 * 20); |         }, 0L, (long) Settings.UpdateChecker.POLL_RATE * 60 * 20); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void cancelTask() { |     private void cancelTask() { | ||||||
|   | |||||||
| @@ -75,6 +75,7 @@ public class FaweSchematicHandler extends SchematicHandler { | |||||||
|         return delegate.save(tag, path); |         return delegate.save(tag, path); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("removal") // Just the override | ||||||
|     @Override |     @Override | ||||||
|     public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) { |     public void upload(final CompoundTag tag, final UUID uuid, final String file, final RunnableVal<URL> whenDone) { | ||||||
|         delegate.upload(tag, uuid, file, whenDone); |         delegate.upload(tag, uuid, file, whenDone); | ||||||
|   | |||||||
| @@ -106,7 +106,7 @@ public class Add extends Command { | |||||||
|                                         .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { |                                         .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { | ||||||
|                             player.sendMessage( |                             player.sendMessage( | ||||||
|                                     TranslatableCaption.of("errors.invalid_player"), |                                     TranslatableCaption.of("errors.invalid_player"), | ||||||
|                                     Template.of("value", PlayerManager.getName(uuid)) |                                     Template.of("value", PlayerManager.resolveName(uuid).getComponent(player)) | ||||||
|                             ); |                             ); | ||||||
|                             iterator.remove(); |                             iterator.remove(); | ||||||
|                             continue; |                             continue; | ||||||
| @@ -114,7 +114,7 @@ public class Add extends Command { | |||||||
|                         if (plot.isOwner(uuid)) { |                         if (plot.isOwner(uuid)) { | ||||||
|                             player.sendMessage( |                             player.sendMessage( | ||||||
|                                     TranslatableCaption.of("member.already_added"), |                                     TranslatableCaption.of("member.already_added"), | ||||||
|                                     Template.of("player", PlayerManager.getName(uuid)) |                                     Template.of("player", PlayerManager.resolveName(uuid).getComponent(player)) | ||||||
|                             ); |                             ); | ||||||
|                             iterator.remove(); |                             iterator.remove(); | ||||||
|                             continue; |                             continue; | ||||||
| @@ -122,7 +122,7 @@ public class Add extends Command { | |||||||
|                         if (plot.getMembers().contains(uuid)) { |                         if (plot.getMembers().contains(uuid)) { | ||||||
|                             player.sendMessage( |                             player.sendMessage( | ||||||
|                                     TranslatableCaption.of("member.already_added"), |                                     TranslatableCaption.of("member.already_added"), | ||||||
|                                     Template.of("player", PlayerManager.getName(uuid)) |                                     Template.of("player", PlayerManager.resolveName(uuid).getComponent(player)) | ||||||
|                             ); |                             ); | ||||||
|                             iterator.remove(); |                             iterator.remove(); | ||||||
|                             continue; |                             continue; | ||||||
|   | |||||||
| @@ -125,7 +125,7 @@ public class Deny extends SubCommand { | |||||||
|                     } else if (plot.getDenied().contains(uuid)) { |                     } else if (plot.getDenied().contains(uuid)) { | ||||||
|                         player.sendMessage( |                         player.sendMessage( | ||||||
|                                 TranslatableCaption.of("member.already_added"), |                                 TranslatableCaption.of("member.already_added"), | ||||||
|                                 Template.of("player", PlayerManager.getName(uuid)) |                                 Template.of("player", PlayerManager.resolveName(uuid).getComponent(player)) | ||||||
|                         ); |                         ); | ||||||
|                         return; |                         return; | ||||||
|                     } else { |                     } else { | ||||||
|   | |||||||
| @@ -142,7 +142,7 @@ public class Owner extends SetCommand { | |||||||
|             if (plot.isOwner(uuid)) { |             if (plot.isOwner(uuid)) { | ||||||
|                 player.sendMessage( |                 player.sendMessage( | ||||||
|                         TranslatableCaption.of("member.already_owner"), |                         TranslatableCaption.of("member.already_owner"), | ||||||
|                         Template.of("player", PlayerManager.getName(uuid, false)) |                         Template.of("player", PlayerManager.resolveName(uuid, false).getComponent(player)) | ||||||
|                 ); |                 ); | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
| @@ -151,7 +151,7 @@ public class Owner extends SetCommand { | |||||||
|                 if (other == null) { |                 if (other == null) { | ||||||
|                     player.sendMessage( |                     player.sendMessage( | ||||||
|                             TranslatableCaption.of("errors.invalid_player_offline"), |                             TranslatableCaption.of("errors.invalid_player_offline"), | ||||||
|                             Template.of("player", PlayerManager.getName(uuid)) |                             Template.of("player", PlayerManager.resolveName(uuid).getComponent(player)) | ||||||
|                     ); |                     ); | ||||||
|                     return; |                     return; | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -112,7 +112,7 @@ public class Trust extends Command { | |||||||
|                                     .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { |                                     .hasPermission(player, Permission.PERMISSION_ADMIN_COMMAND_TRUST))) { | ||||||
|                         player.sendMessage( |                         player.sendMessage( | ||||||
|                                 TranslatableCaption.of("errors.invalid_player"), |                                 TranslatableCaption.of("errors.invalid_player"), | ||||||
|                                 Template.of("value", PlayerManager.getName(uuid)) |                                 Template.of("value", PlayerManager.resolveName(uuid).getComponent(player)) | ||||||
|                         ); |                         ); | ||||||
|                         iterator.remove(); |                         iterator.remove(); | ||||||
|                         continue; |                         continue; | ||||||
| @@ -120,7 +120,7 @@ public class Trust extends Command { | |||||||
|                     if (currentPlot.isOwner(uuid)) { |                     if (currentPlot.isOwner(uuid)) { | ||||||
|                         player.sendMessage( |                         player.sendMessage( | ||||||
|                                 TranslatableCaption.of("member.already_added"), |                                 TranslatableCaption.of("member.already_added"), | ||||||
|                                 Template.of("value", PlayerManager.getName(uuid)) |                                 Template.of("value", PlayerManager.resolveName(uuid).getComponent(player)) | ||||||
|                         ); |                         ); | ||||||
|                         iterator.remove(); |                         iterator.remove(); | ||||||
|                         continue; |                         continue; | ||||||
| @@ -128,7 +128,7 @@ public class Trust extends Command { | |||||||
|                     if (currentPlot.getTrusted().contains(uuid)) { |                     if (currentPlot.getTrusted().contains(uuid)) { | ||||||
|                         player.sendMessage( |                         player.sendMessage( | ||||||
|                                 TranslatableCaption.of("member.already_added"), |                                 TranslatableCaption.of("member.already_added"), | ||||||
|                                 Template.of("value", PlayerManager.getName(uuid)) |                                 Template.of("value", PlayerManager.resolveName(uuid).getComponent(player)) | ||||||
|                         ); |                         ); | ||||||
|                         iterator.remove(); |                         iterator.remove(); | ||||||
|                         continue; |                         continue; | ||||||
|   | |||||||
| @@ -70,7 +70,7 @@ public final class Templates { | |||||||
|      * @return Generated template |      * @return Generated template | ||||||
|      */ |      */ | ||||||
|     public static @NonNull Template of(final @NonNull String key, final @NonNull UUID uuid) { |     public static @NonNull Template of(final @NonNull String key, final @NonNull UUID uuid) { | ||||||
|         final String username = PlayerManager.getName(uuid); |         final String username = PlayerManager.resolveName(uuid).getComponent(LocaleHolder.console()); | ||||||
|         return Template.of(key, username); |         return Template.of(key, username); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -198,13 +198,7 @@ public class PlotListener { | |||||||
|                         final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid); |                         final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid); | ||||||
|                         if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { |                         if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { | ||||||
|                             Caption caption = TranslatableCaption.of("notification.notify_enter"); |                             Caption caption = TranslatableCaption.of("notification.notify_enter"); | ||||||
|                             Template playerTemplate = Template.of("player", player.getName()); |                             notifyPlotOwner(player, plot, owner, caption); | ||||||
|                             Template plotTemplate = Template.of("plot", plot.getId().toString()); |  | ||||||
|                             if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) { |  | ||||||
|                                 owner.sendMessage(caption, playerTemplate, plotTemplate); |  | ||||||
|                             } else { |  | ||||||
|                                 owner.sendActionBar(caption, playerTemplate, plotTemplate); |  | ||||||
|                             } |  | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
| @@ -327,7 +321,7 @@ public class PlotListener { | |||||||
|                         } |                         } | ||||||
|                         if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) { |                         if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) { | ||||||
|                             final UUID plotOwner = plot.getOwnerAbs(); |                             final UUID plotOwner = plot.getOwnerAbs(); | ||||||
|                             String owner = PlayerManager.getName(plotOwner, false); |                             String owner = PlayerManager.resolveName(plotOwner, false).getComponent(player); | ||||||
|                             Caption header = fromFlag ? StaticCaption.of(title) : TranslatableCaption.of("titles" + |                             Caption header = fromFlag ? StaticCaption.of(title) : TranslatableCaption.of("titles" + | ||||||
|                                     ".title_entered_plot"); |                                     ".title_entered_plot"); | ||||||
|                             Caption subHeader = fromFlag ? StaticCaption.of(subtitle) : TranslatableCaption.of("titles" + |                             Caption subHeader = fromFlag ? StaticCaption.of(subtitle) : TranslatableCaption.of("titles" + | ||||||
| @@ -443,13 +437,7 @@ public class PlotListener { | |||||||
|                             final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid); |                             final PlotPlayer<?> owner = PlotSquared.platform().playerManager().getPlayerIfExists(uuid); | ||||||
|                             if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { |                             if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { | ||||||
|                                 Caption caption = TranslatableCaption.of("notification.notify_leave"); |                                 Caption caption = TranslatableCaption.of("notification.notify_leave"); | ||||||
|                                 Template playerTemplate = Template.of("player", player.getName()); |                                 notifyPlotOwner(player, plot, owner, caption); | ||||||
|                                 Template plotTemplate = Template.of("plot", plot.getId().toString()); |  | ||||||
|                                 if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) { |  | ||||||
|                                     owner.sendMessage(caption, playerTemplate, plotTemplate); |  | ||||||
|                                 } else { |  | ||||||
|                                     owner.sendActionBar(caption, playerTemplate, plotTemplate); |  | ||||||
|                                 } |  | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
| @@ -497,6 +485,17 @@ public class PlotListener { | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private void notifyPlotOwner(final PlotPlayer<?> player, final Plot plot, final PlotPlayer<?> owner, final Caption caption) { | ||||||
|  |         Template playerTemplate = Template.of("player", player.getName()); | ||||||
|  |         Template plotTemplate = Template.of("plot", plot.getId().toString()); | ||||||
|  |         Template areaTemplate = Template.of("area", plot.getArea().toString()); | ||||||
|  |         if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) { | ||||||
|  |             owner.sendMessage(caption, playerTemplate, plotTemplate, areaTemplate); | ||||||
|  |         } else { | ||||||
|  |             owner.sendActionBar(caption, playerTemplate, plotTemplate, areaTemplate); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     public void logout(UUID uuid) { |     public void logout(UUID uuid) { | ||||||
|         feedRunnable.remove(uuid); |         feedRunnable.remove(uuid); | ||||||
|         healRunnable.remove(uuid); |         healRunnable.remove(uuid); | ||||||
|   | |||||||
| @@ -53,7 +53,7 @@ public abstract class MetaDataAccess<T> implements AutoCloseable { | |||||||
|         this.lockAccess = lockAccess; |         this.lockAccess = lockAccess; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @SuppressWarnings("ALL") |     @SuppressWarnings("unchecked") | ||||||
|     private static <E extends Throwable> void sneakyThrow(final Throwable e) throws E { |     private static <E extends Throwable> void sneakyThrow(final Throwable e) throws E { | ||||||
|         throw (E) e; |         throw (E) e; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -2838,7 +2838,7 @@ public class Plot { | |||||||
|                             if (time != 0) { |                             if (time != 0) { | ||||||
|                                 seen = TimeUtil.secToTime(time); |                                 seen = TimeUtil.secToTime(time); | ||||||
|                             } else { |                             } else { | ||||||
|                                 seen = TranslatableCaption.of("info.known").getComponent(player); |                                 seen = TranslatableCaption.of("info.unknown").getComponent(player); | ||||||
|                             } |                             } | ||||||
|                         } |                         } | ||||||
|                     } else { |                     } else { | ||||||
|   | |||||||
| @@ -30,6 +30,7 @@ import com.plotsquared.core.PlotSquared; | |||||||
| import com.plotsquared.core.configuration.ConfigurationUtil; | import com.plotsquared.core.configuration.ConfigurationUtil; | ||||||
| import com.plotsquared.core.configuration.Settings; | import com.plotsquared.core.configuration.Settings; | ||||||
| import com.plotsquared.core.configuration.caption.Caption; | import com.plotsquared.core.configuration.caption.Caption; | ||||||
|  | import com.plotsquared.core.configuration.caption.LocaleHolder; | ||||||
| import com.plotsquared.core.configuration.caption.TranslatableCaption; | import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||||
| import com.plotsquared.core.database.DBFunc; | import com.plotsquared.core.database.DBFunc; | ||||||
| import com.plotsquared.core.events.PlotComponentSetEvent; | import com.plotsquared.core.events.PlotComponentSetEvent; | ||||||
| @@ -358,7 +359,8 @@ public final class PlotModificationManager { | |||||||
|         if (createSign) { |         if (createSign) { | ||||||
|             queue.setCompleteTask(() -> TaskManager.runTaskAsync(() -> { |             queue.setCompleteTask(() -> TaskManager.runTaskAsync(() -> { | ||||||
|                 for (Plot current : plots) { |                 for (Plot current : plots) { | ||||||
|                     current.getPlotModificationManager().setSign(PlayerManager.getName(current.getOwnerAbs())); |                     current.getPlotModificationManager().setSign(PlayerManager.resolveName(current.getOwnerAbs()).getComponent( | ||||||
|  |                             LocaleHolder.console())); | ||||||
|                 } |                 } | ||||||
|             })); |             })); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -96,7 +96,7 @@ public class FlagContainer { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Cast a plot flag with wildcard parameters into a parametrisized |      * Cast a plot flag with wildcard parameters into a parametrized | ||||||
|      * PlotFlag. This is an unsafe operation, and should only be performed |      * PlotFlag. This is an unsafe operation, and should only be performed | ||||||
|      * if the generic parameters are known beforehand. |      * if the generic parameters are known beforehand. | ||||||
|      * |      * | ||||||
| @@ -105,7 +105,7 @@ public class FlagContainer { | |||||||
|      * @param <T>  Flag type |      * @param <T>  Flag type | ||||||
|      * @return Casted flag |      * @return Casted flag | ||||||
|      */ |      */ | ||||||
|     @SuppressWarnings("ALL") |     @SuppressWarnings("unchecked") | ||||||
|     public static <V, T extends PlotFlag<V, ?>> T castUnsafe( |     public static <V, T extends PlotFlag<V, ?>> T castUnsafe( | ||||||
|             final PlotFlag<?, ?> flag |             final PlotFlag<?, ?> flag | ||||||
|     ) { |     ) { | ||||||
| @@ -181,6 +181,7 @@ public class FlagContainer { | |||||||
|      * @param <V>  flag value type |      * @param <V>  flag value type | ||||||
|      * @return value of flag removed |      * @return value of flag removed | ||||||
|      */ |      */ | ||||||
|  |     @SuppressWarnings("unchecked") | ||||||
|     public <V, T extends PlotFlag<V, ?>> V removeFlag(final T flag) { |     public <V, T extends PlotFlag<V, ?>> V removeFlag(final T flag) { | ||||||
|         final Object value = this.flagMap.remove(flag.getClass()); |         final Object value = this.flagMap.remove(flag.getClass()); | ||||||
|         if (this.plotFlagUpdateHandler != null) { |         if (this.plotFlagUpdateHandler != null) { | ||||||
|   | |||||||
| @@ -73,6 +73,7 @@ public class EntityUtil { | |||||||
|         return i; |         return i; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @SuppressWarnings("unchecked") | ||||||
|     public static boolean checkEntity(Plot plot, PlotFlag<Integer, ?>... flags) { |     public static boolean checkEntity(Plot plot, PlotFlag<Integer, ?>... flags) { | ||||||
|         if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { |         if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { | ||||||
|             return true; |             return true; | ||||||
|   | |||||||
| @@ -27,7 +27,9 @@ package com.plotsquared.core.util; | |||||||
|  |  | ||||||
| import com.plotsquared.core.PlotSquared; | import com.plotsquared.core.PlotSquared; | ||||||
| import com.plotsquared.core.configuration.Settings; | import com.plotsquared.core.configuration.Settings; | ||||||
|  | import com.plotsquared.core.configuration.caption.Caption; | ||||||
| import com.plotsquared.core.configuration.caption.LocaleHolder; | import com.plotsquared.core.configuration.caption.LocaleHolder; | ||||||
|  | import com.plotsquared.core.configuration.caption.StaticCaption; | ||||||
| import com.plotsquared.core.configuration.caption.TranslatableCaption; | import com.plotsquared.core.configuration.caption.TranslatableCaption; | ||||||
| import com.plotsquared.core.database.DBFunc; | import com.plotsquared.core.database.DBFunc; | ||||||
| import com.plotsquared.core.player.ConsolePlayer; | import com.plotsquared.core.player.ConsolePlayer; | ||||||
| @@ -162,7 +164,9 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> { | |||||||
|      * |      * | ||||||
|      * @param owner Owner UUID |      * @param owner Owner UUID | ||||||
|      * @return The player's name, None, Everyone or Unknown |      * @return The player's name, None, Everyone or Unknown | ||||||
|  |      * @deprecated Use {@link #resolveName(UUID)} | ||||||
|      */ |      */ | ||||||
|  |     @Deprecated(forRemoval = true, since = "TODO") | ||||||
|     public static @NonNull String getName(final @Nullable UUID owner) { |     public static @NonNull String getName(final @Nullable UUID owner) { | ||||||
|         return getName(owner, true); |         return getName(owner, true); | ||||||
|     } |     } | ||||||
| @@ -173,7 +177,9 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> { | |||||||
|      * @param owner    Owner UUID |      * @param owner    Owner UUID | ||||||
|      * @param blocking Whether or not the operation can be blocking |      * @param blocking Whether or not the operation can be blocking | ||||||
|      * @return The player's name, None, Everyone or Unknown |      * @return The player's name, None, Everyone or Unknown | ||||||
|  |      * @deprecated Use {@link #resolveName(UUID, boolean)} | ||||||
|      */ |      */ | ||||||
|  |     @Deprecated(forRemoval = true, since = "TODO") | ||||||
|     public static @NonNull String getName(final @Nullable UUID owner, final boolean blocking) { |     public static @NonNull String getName(final @Nullable UUID owner, final boolean blocking) { | ||||||
|         if (owner == null) { |         if (owner == null) { | ||||||
|             TranslatableCaption.of("info.none"); |             TranslatableCaption.of("info.none"); | ||||||
| @@ -203,6 +209,57 @@ public abstract class PlayerManager<P extends PlotPlayer<? extends T>, T> { | |||||||
|         return name; |         return name; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Attempts to resolve the username by an uuid | ||||||
|  |      * <p> | ||||||
|  |      * <b>Note:</b> blocks the thread until the name was resolved or failed | ||||||
|  |      * | ||||||
|  |      * @param owner The UUID of the owner | ||||||
|  |      * @return A caption containing either the name, {@code None}, {@code Everyone} or {@code Unknown} | ||||||
|  |      * @see #resolveName(UUID, boolean) | ||||||
|  |      * @since TODO | ||||||
|  |      */ | ||||||
|  |     public static @NonNull Caption resolveName(final @Nullable UUID owner) { | ||||||
|  |         return resolveName(owner, true); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Attempts to resolve the username by an uuid | ||||||
|  |      * | ||||||
|  |      * @param owner    The UUID of the owner | ||||||
|  |      * @param blocking If the operation should block the current thread for {@link Settings.UUID#BLOCKING_TIMEOUT} milliseconds | ||||||
|  |      * @return A caption containing either the name, {@code None}, {@code Everyone} or {@code Unknown} | ||||||
|  |      * @since TODO | ||||||
|  |      */ | ||||||
|  |     public static @NonNull Caption resolveName(final @Nullable UUID owner, final boolean blocking) { | ||||||
|  |         if (owner == null) { | ||||||
|  |             return TranslatableCaption.of("info.none"); | ||||||
|  |         } | ||||||
|  |         if (owner.equals(DBFunc.EVERYONE)) { | ||||||
|  |             return TranslatableCaption.of("info.everyone"); | ||||||
|  |         } | ||||||
|  |         if (owner.equals(DBFunc.SERVER)) { | ||||||
|  |             return TranslatableCaption.of("info.server"); | ||||||
|  |         } | ||||||
|  |         final String name; | ||||||
|  |         if (blocking) { | ||||||
|  |             name = PlotSquared.get().getImpromptuUUIDPipeline() | ||||||
|  |                     .getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT); | ||||||
|  |         } else { | ||||||
|  |             final UUIDMapping uuidMapping = | ||||||
|  |                     PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner); | ||||||
|  |             if (uuidMapping != null) { | ||||||
|  |                 name = uuidMapping.getUsername(); | ||||||
|  |             } else { | ||||||
|  |                 name = null; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         if (name == null) { | ||||||
|  |             return TranslatableCaption.of("info.unknown"); | ||||||
|  |         } | ||||||
|  |         return StaticCaption.of(name); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Remove a player from the player map |      * Remove a player from the player map | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -116,7 +116,7 @@ public final class PlaceholderRegistry { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             try { |             try { | ||||||
|                 return PlayerManager.getName(plotOwner, false); |                 return PlayerManager.resolveName(plotOwner, false).getComponent(player); | ||||||
|             } catch (final Exception ignored) { |             } catch (final Exception ignored) { | ||||||
|             } |             } | ||||||
|             return legacyComponent(TranslatableCaption.of("info.unknown"), player); |             return legacyComponent(TranslatableCaption.of("info.unknown"), player); | ||||||
|   | |||||||
| @@ -60,8 +60,8 @@ | |||||||
|   "worldedit.worldedit_bypassed": "<prefix><gray>Currently bypassing WorldEdit restriction.</gray>", |   "worldedit.worldedit_bypassed": "<prefix><gray>Currently bypassing WorldEdit restriction.</gray>", | ||||||
|   "gamemode.gamemode_was_bypassed": "<prefix><gold>You bypassed the gamemode (</gold><gray><gamemode></gray><gold>) <gold>set for </gold><gray><plot>.</gray>", |   "gamemode.gamemode_was_bypassed": "<prefix><gold>You bypassed the gamemode (</gold><gray><gamemode></gray><gold>) <gold>set for </gold><gray><plot>.</gray>", | ||||||
|   "height.height_limit": "<prefix><gold>This plot area has building height limits: Min height: </gold><gray><minHeight></gray><gold>, Max height: </gold><gray><maxHeight></gray>", |   "height.height_limit": "<prefix><gold>This plot area has building height limits: Min height: </gold><gray><minHeight></gray><gold>, Max height: </gold><gray><maxHeight></gray>", | ||||||
|   "notification.notify_enter": "<prefix><gray><player> entered your plot (</gray><gold><plot></gold><gray>).</gray>", |   "notification.notify_enter": "<prefix><gray><player> entered your plot (</gray><gold><area>;<plot></gold><gray>).</gray>", | ||||||
|   "notification.notify_leave": "<prefix><gray><player> left your plot (</gray><gold><plot></gold><gray>).</gray>", |   "notification.notify_leave": "<prefix><gray><player> left your plot (</gray><gold><area>;<plot></gold><gray>).</gray>", | ||||||
|   "swap.swap_overlap": "<prefix><red>The proposed areas are not allowed to overlap.</red>", |   "swap.swap_overlap": "<prefix><red>The proposed areas are not allowed to overlap.</red>", | ||||||
|   "swap.swap_success": "<prefix><dark_aqua>Successfully swapped plots</dark_aqua> <gold><origin></gold><dark_aqua> -> </dark_aqua><gold><target></gold>", |   "swap.swap_success": "<prefix><dark_aqua>Successfully swapped plots</dark_aqua> <gold><origin></gold><dark_aqua> -> </dark_aqua><gold><target></gold>", | ||||||
|   "swap.swap_merged": "<prefix><red>Merged plots may not be swapped. Please unmerge the plots before performing the swap.</red>", |   "swap.swap_merged": "<prefix><red>Merged plots may not be swapped. Please unmerge the plots before performing the swap.</red>", | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ plugins { | |||||||
|     idea |     idea | ||||||
| } | } | ||||||
|  |  | ||||||
| version = "6.3.0" | version = "6.3.1-SNAPSHOT" | ||||||
|  |  | ||||||
| allprojects { | allprojects { | ||||||
|     group = "com.plotsquared" |     group = "com.plotsquared" | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ adventure-platform-bukkit = "4.0.1" | |||||||
|  |  | ||||||
| # Plugins | # Plugins | ||||||
| worldedit = "7.2.8" | worldedit = "7.2.8" | ||||||
| fawe = "2.0.0-SNAPSHOT" | fawe = "2.0.0" | ||||||
| vault = "1.7.1" | vault = "1.7.1" | ||||||
| placeholderapi = "2.11.1" | placeholderapi = "2.11.1" | ||||||
| luckperms = "5.3" | luckperms = "5.3" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user