diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5a99a2678..f0809ab2a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @IntellectualSites/plotsquared-team \ No newline at end of file +@IntellectualSites/plotsquared-team diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index 77f82647c..0b8bf2714 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -42,7 +42,7 @@ dependencies { } implementation("net.alpenblock:BungeePerms:4.0-dev-106") implementation("net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT") - implementation('net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT') + implementation('net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT') compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false } compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false } compile('be.maximvdw:MVdWPlaceholderAPI:3.1.1-SNAPSHOT'){ transitive = false } diff --git a/Bukkit/pom.xml b/Bukkit/pom.xml index 3fe1f3b6f..291bb536c 100644 --- a/Bukkit/pom.xml +++ b/Bukkit/pom.xml @@ -179,7 +179,7 @@ net.kyori adventure-text-minimessage - 3.0.0-SNAPSHOT + 4.0.0-SNAPSHOT runtime diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java index ab3b2074f..bca3318cf 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java @@ -42,20 +42,21 @@ import com.plotsquared.bukkit.listener.ChunkListener; import com.plotsquared.bukkit.listener.EntityEventListener; import com.plotsquared.bukkit.listener.EntitySpawnListener; import com.plotsquared.bukkit.listener.PaperListener; +import com.plotsquared.bukkit.listener.PaperListener113; import com.plotsquared.bukkit.listener.PlayerEventListener; import com.plotsquared.bukkit.listener.ProjectileEventListener; import com.plotsquared.bukkit.listener.ServerListener; import com.plotsquared.bukkit.listener.SingleWorldListener; import com.plotsquared.bukkit.listener.WorldEvents; +import com.plotsquared.bukkit.placeholder.PAPIPlaceholders; import com.plotsquared.bukkit.placeholder.PlaceholderFormatter; import com.plotsquared.bukkit.player.BukkitPlayer; -import com.plotsquared.bukkit.placeholder.PAPIPlaceholders; import com.plotsquared.bukkit.player.BukkitPlayerManager; -import com.plotsquared.bukkit.util.task.BukkitTaskManager; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitWorld; import com.plotsquared.bukkit.util.SetGenCB; import com.plotsquared.bukkit.util.UpdateUtility; +import com.plotsquared.bukkit.util.task.BukkitTaskManager; import com.plotsquared.bukkit.util.task.PaperTimeConverter; import com.plotsquared.bukkit.util.task.SpigotTimeConverter; import com.plotsquared.bukkit.uuid.BungeePermsUUIDService; @@ -70,11 +71,11 @@ import com.plotsquared.core.PlotSquared; import com.plotsquared.core.backup.BackupManager; import com.plotsquared.core.command.WE_Anywhere; import com.plotsquared.core.components.ComponentPresetManager; -import com.plotsquared.core.configuration.caption.ChatFormatter; import com.plotsquared.core.configuration.ConfigurationNode; import com.plotsquared.core.configuration.ConfigurationSection; import com.plotsquared.core.configuration.ConfigurationUtil; import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.ChatFormatter; import com.plotsquared.core.configuration.file.YamlConfiguration; import com.plotsquared.core.database.DBFunc; import com.plotsquared.core.generator.GeneratorWrapper; @@ -316,7 +317,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl getServer().getPluginManager().registerEvents(getInjector().getInstance(ServerListener.class), this); getServer().getPluginManager().registerEvents(getInjector().getInstance(EntitySpawnListener.class), this); if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) { - getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener.class), this); + if (getServerVersion()[1] == 13) { + getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener113.class), this); + } else { + getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener.class), this); + } } this.plotListener.startRunnable(); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java new file mode 100644 index 000000000..4a92ae36b --- /dev/null +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener113.java @@ -0,0 +1,90 @@ +/* + * _____ _ _ _____ _ + * | __ \| | | | / ____| | | + * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | + * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | + * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | + * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| + * | | + * |_| + * PlotSquared plot management system for Minecraft + * Copyright (C) 2020 IntellectualSites + * + * 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 . + */ +package com.plotsquared.bukkit.listener; + +import com.google.inject.Inject; +import com.plotsquared.bukkit.util.BukkitUtil; +import com.plotsquared.core.configuration.Settings; +import com.plotsquared.core.configuration.caption.TranslatableCaption; +import com.plotsquared.core.location.Location; +import com.plotsquared.core.player.PlotPlayer; +import com.plotsquared.core.plot.PlotArea; +import com.plotsquared.core.plot.world.PlotAreaManager; +import net.kyori.adventure.text.minimessage.Template; +import org.bukkit.block.Banner; +import org.bukkit.block.Beacon; +import org.bukkit.block.Bed; +import org.bukkit.block.BlockState; +import org.bukkit.block.CommandBlock; +import org.bukkit.block.Comparator; +import org.bukkit.block.Conduit; +import org.bukkit.block.Container; +import org.bukkit.block.CreatureSpawner; +import org.bukkit.block.DaylightDetector; +import org.bukkit.block.EnchantingTable; +import org.bukkit.block.EndGateway; +import org.bukkit.block.EnderChest; +import org.bukkit.block.Jukebox; +import org.bukkit.block.Sign; +import org.bukkit.block.Skull; +import org.bukkit.block.Structure; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.BlockPlaceEvent; + +import javax.annotation.Nonnull; + +public class PaperListener113 extends PaperListener { + + @Inject public PaperListener113(@Nonnull PlotAreaManager plotAreaManager) { + super(plotAreaManager); + } + + @EventHandler public void onBlockPlace(BlockPlaceEvent event) { + if (!Settings.Paper_Components.TILE_ENTITY_CHECK || !Settings.Enabled_Components.CHUNK_PROCESSOR) { + return; + } + BlockState state = event.getBlock().getState(false); + if (!(state instanceof Banner || state instanceof Beacon || state instanceof Bed || state instanceof CommandBlock + || state instanceof Comparator || state instanceof Conduit || state instanceof Container || state instanceof CreatureSpawner + || state instanceof DaylightDetector || state instanceof EnchantingTable || state instanceof EnderChest || state instanceof EndGateway + || state instanceof Jukebox || state instanceof Sign || state instanceof Skull || state instanceof Structure)) { + return; + } + final Location location = BukkitUtil.adapt(event.getBlock().getLocation()); + final PlotArea plotArea = location.getPlotArea(); + if (plotArea == null) { + return; + } + final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length; + if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) { + final PlotPlayer plotPlayer = BukkitUtil.adapt(event.getPlayer()); + plotPlayer.sendMessage(TranslatableCaption.of("errors.tile_entity_cap_reached"), + Template.of("amount", String.valueOf(Settings.Chunk_Processor.MAX_TILES))); + event.setCancelled(true); + event.setBuild(false); + } + } +} diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java index 82b245631..6fad843db 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java @@ -33,6 +33,7 @@ import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.events.TeleportCause; import com.plotsquared.core.location.Location; import com.plotsquared.core.permissions.PermissionHandler; +import com.plotsquared.core.player.ConsolePlayer; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.PlotWeather; import com.plotsquared.core.plot.world.PlotAreaManager; @@ -330,6 +331,13 @@ public class BukkitPlayer extends PlotPlayer { return BukkitUtil.BUKKIT_AUDIENCES.player(this.player); } + @Override public boolean canSee(final PlotPlayer other) { + if (other instanceof ConsolePlayer) { + return true; + } else { + return this.player.canSee(((BukkitPlayer) other).getPlatformPlayer()); + } + } public PlayerTeleportEvent.TeleportCause getTeleportCause(@Nonnull final TeleportCause cause) { switch (cause) { diff --git a/Core/build.gradle b/Core/build.gradle index b47d359d0..167600f33 100644 --- a/Core/build.gradle +++ b/Core/build.gradle @@ -16,7 +16,7 @@ dependencies { implementation("org.khelekore:prtree:1.7.0-SNAPSHOT") // Adventure related stuff implementation('net.kyori:adventure-api:4.0.0-SNAPSHOT') - implementation('net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT') + implementation('net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT') compile("com.google.inject:guice:4.2.3") compile("com.google.inject.extensions:guice-assistedinject:4.2.3") compile group: 'com.google.code.findbugs', name: 'annotations', version: '3.0.1' @@ -82,7 +82,7 @@ shadowJar { include(dependency('net.kyori:adventure-gson:4.0.0-SNAPSHOT')) include(dependency('net.kyori:adventure-legacy:4.0.0-SNAPSHOT')) include(dependency('net.kyori:adventure-plain:4.0.0-SNAPSHOT')) - include(dependency('net.kyori:adventure-text-minimessage:3.0.0-SNAPSHOT')) + include(dependency('net.kyori:adventure-text-minimessage:4.0.0-SNAPSHOT')) include(dependency('org.khelekore:prtree:1.7.0-SNAPSHOT')) } relocate('net.kyori.text', 'com.plotsquared.formatting.text') diff --git a/Core/pom.xml b/Core/pom.xml index e1d8a8107..50a5c1be6 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -113,7 +113,7 @@ net.kyori adventure-text-minimessage - 3.0.0-SNAPSHOT + 4.0.0-SNAPSHOT runtime diff --git a/Core/src/main/java/com/plotsquared/core/command/Alias.java b/Core/src/main/java/com/plotsquared/core/command/Alias.java index ce12ed780..ec5e35bab 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Alias.java +++ b/Core/src/main/java/com/plotsquared/core/command/Alias.java @@ -28,6 +28,7 @@ package com.plotsquared.core.command; import com.plotsquared.core.PlotSquared; import com.plotsquared.core.permissions.Permission; import com.plotsquared.core.configuration.caption.TranslatableCaption; +import com.plotsquared.core.configuration.Settings; import com.plotsquared.core.location.Location; import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.plot.Plot; @@ -149,6 +150,11 @@ public class Alias extends SubCommand { player.sendMessage(TranslatableCaption.of("alias.alias_is_taken")); return; } + if (Settings.UUID.OFFLINE) { + plot.setAlias(alias); + player.sendMessage(TranslatableCaption.of("alias.alias_set_to"), Template.of("alias", alias)); + return; + } PlotSquared.get().getImpromptuUUIDPipeline().getSingle(alias, ((uuid, throwable) -> { if (throwable instanceof TimeoutException) { player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); diff --git a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java index 4c30a4ef3..70058cf09 100644 --- a/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java +++ b/Core/src/main/java/com/plotsquared/core/command/HomeCommand.java @@ -118,6 +118,7 @@ public class HomeCommand extends Command { PlotQuery query = query(player); int page = 1; // page = index + 1 String identifier; + PlotArea plotArea; boolean basePlotOnly = true; switch (args.length) { case 1: @@ -143,12 +144,18 @@ public class HomeCommand extends Command { query.withPlot(fromId); break; } + // allow for plot home within a plot area + plotArea = this.plotAreaManager.getPlotAreaByString(args[0]); + if (plotArea != null) { + query.inArea(plotArea); + break; + } // it wasn't a valid plot id, trying to find plot by alias query.withAlias(identifier); break; case 2: // we assume args[0] is a plot area and args[1] an identifier - final PlotArea plotArea = this.plotAreaManager.getPlotAreaByString(args[0]); + plotArea = this.plotAreaManager.getPlotAreaByString(args[0]); identifier = args[1]; if (plotArea == null) { // invalid command, therefore no plots diff --git a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java index 8fabb2f06..71fe1e28b 100644 --- a/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/core/listener/PlotListener.java @@ -168,7 +168,7 @@ public class PlotListener { if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) { for (UUID uuid : plot.getOwners()) { final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid); - if (owner != null && !owner.getUUID().equals(player.getUUID())) { + if (owner != null && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { player.sendMessage( TranslatableCaption.of("notification.notify_enter"), Template.of("player", player.getName()), @@ -355,7 +355,7 @@ public class PlotListener { if (!Permissions.hasPermission(player, "plots.flag.notify-enter.bypass")) { for (UUID uuid : plot.getOwners()) { final PlotPlayer owner = PlotSquared.platform().getPlayerManager().getPlayerIfExists(uuid); - if ((owner != null) && !owner.getUUID().equals(player.getUUID())) { + if ((owner != null) && !owner.getUUID().equals(player.getUUID()) && owner.canSee(player)) { player.sendMessage( TranslatableCaption.of("notification.notify_leave"), Template.of("player", player.getName()), diff --git a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java index 730127060..e45566bd4 100644 --- a/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java @@ -218,4 +218,8 @@ public class ConsolePlayer extends PlotPlayer { return PlotSquared.platform().getConsoleAudience(); } + @Override public boolean canSee(final PlotPlayer other) { + return true; + } + } diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index 2b3fdf764..593afdc3e 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -859,6 +859,16 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer, return this.metaMap.containsKey(key); } + /** + * Check if the player is able to see the other player. + * This does not mean that the other player is in line of sight of the player, + * but rather that the player is permitted to see the other player. + * + * @param other Other player + * @return {@code true} if the player is able to see the other player, {@code false} if not + */ + public abstract boolean canSee(PlotPlayer other); + public abstract void stopSpectating(); public boolean hasDebugMode() { diff --git a/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java b/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java index 23a141263..837c38668 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java +++ b/Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java @@ -50,6 +50,7 @@ public class BlockTypeWrapper { private static final Map blockTypes = new HashMap<>(); private static final Map blockCategories = new HashMap<>(); @Nullable private final BlockType blockType; + private static final String minecraftNamespace = "minecraft"; @Nullable private final String blockCategoryId; @Nullable private BlockCategory blockCategory; @@ -81,7 +82,14 @@ public class BlockTypeWrapper { } public static BlockTypeWrapper get(final String blockCategoryId) { - return blockCategories.computeIfAbsent(blockCategoryId, BlockTypeWrapper::new); + // use minecraft as default namespace + String id; + if (blockCategoryId.indexOf(':') == -1) { + id = minecraftNamespace + ":" + blockCategoryId; + } else { + id = blockCategoryId; + } + return blockCategories.computeIfAbsent(id, BlockTypeWrapper::new); } @Override public String toString() {