mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Merge branch 'v5' into v6
# Conflicts: # .github/CODEOWNERS # Bukkit/pom.xml # Bukkit/src/main/java/com/plotsquared/bukkit/BukkitPlatform.java # Bukkit/src/main/java/com/plotsquared/bukkit/player/BukkitPlayer.java # Core/src/main/java/com/plotsquared/core/command/Alias.java # Core/src/main/java/com/plotsquared/core/command/HomeCommand.java # Core/src/main/java/com/plotsquared/core/command/Music.java # Core/src/main/java/com/plotsquared/core/listener/PlotListener.java # Core/src/main/java/com/plotsquared/core/player/ConsolePlayer.java # Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java # Core/src/main/java/com/plotsquared/core/plot/flag/types/BlockTypeWrapper.java # build.gradle
This commit is contained in:
commit
554efbb057
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@ -1 +1 @@
|
||||
* @IntellectualSites/plotsquared-team
|
||||
@IntellectualSites/plotsquared-team
|
||||
|
@ -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,8 +317,12 @@ 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) {
|
||||
if (getServerVersion()[1] == 13) {
|
||||
getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener113.class), this);
|
||||
} else {
|
||||
getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener.class), this);
|
||||
}
|
||||
}
|
||||
this.plotListener.startRunnable();
|
||||
}
|
||||
|
||||
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<Player> {
|
||||
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) {
|
||||
|
@ -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"));
|
||||
|
@ -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
|
||||
|
@ -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()),
|
||||
|
@ -218,4 +218,8 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
||||
return PlotSquared.platform().getConsoleAudience();
|
||||
}
|
||||
|
||||
@Override public boolean canSee(final PlotPlayer<?> other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -859,6 +859,16 @@ public abstract class PlotPlayer<P> 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() {
|
||||
|
@ -50,6 +50,7 @@ public class BlockTypeWrapper {
|
||||
private static final Map<BlockType, BlockTypeWrapper> blockTypes = new HashMap<>();
|
||||
private static final Map<String, BlockTypeWrapper> 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() {
|
||||
|
Loading…
Reference in New Issue
Block a user