Compare commits

..

1 Commits

Author SHA1 Message Date
704148e47f avoid quadratic overhead for UUID collection 2022-07-29 20:05:40 +02:00
9 changed files with 26 additions and 44 deletions

View File

@ -27,7 +27,6 @@ body:
description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first. description: Which server version version you using? If your server version is not listed, it is not supported. Update to a supported version first.
multiple: false multiple: false
options: options:
- '1.19.2'
- '1.19.1' - '1.19.1'
- '1.19' - '1.19'
- '1.18.2' - '1.18.2'

View File

@ -121,23 +121,6 @@ public class BlockEventListener implements Listener {
Material.TURTLE_EGG, Material.TURTLE_EGG,
Material.TURTLE_SPAWN_EGG Material.TURTLE_SPAWN_EGG
); );
private static final Set<Material> SNOW; // needed as Tag.SNOW isn't present in 1.16.5
static {
if (PlotSquared.platform().serverVersion()[1] < 17) {
SNOW = Set.of(
Material.SNOW,
Material.SNOW_BLOCK
);
} else {
SNOW = Set.of(
Material.SNOW,
Material.SNOW_BLOCK,
Material.POWDER_SNOW // only since 1.17
);
}
}
private final PlotAreaManager plotAreaManager; private final PlotAreaManager plotAreaManager;
private final WorldEdit worldEdit; private final WorldEdit worldEdit;
@ -546,7 +529,7 @@ public class BlockEventListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
if (SNOW.contains(event.getNewState().getType())) { if (Tag.SNOW.isTagged(event.getNewState().getType())) {
if (!plot.getFlag(SnowFormFlag.class)) { if (!plot.getFlag(SnowFormFlag.class)) {
plot.debug("Snow could not form because snow-form = false"); plot.debug("Snow could not form because snow-form = false");
event.setCancelled(true); event.setCancelled(true);
@ -578,7 +561,7 @@ public class BlockEventListener implements Listener {
return; return;
} }
Class<? extends BooleanFlag<?>> flag; Class<? extends BooleanFlag<?>> flag;
if (SNOW.contains(event.getNewState().getType())) { if (Tag.SNOW.isTagged(event.getNewState().getType())) {
flag = SnowFormFlag.class; flag = SnowFormFlag.class;
} else if (Tag.ICE.isTagged(event.getNewState().getType())) { } else if (Tag.ICE.isTagged(event.getNewState().getType())) {
flag = IceFormFlag.class; flag = IceFormFlag.class;
@ -695,7 +678,7 @@ public class BlockEventListener implements Listener {
} }
return; return;
} }
if (SNOW.contains(blockType)) { if (Tag.SNOW.isTagged(blockType)) {
if (!plot.getFlag(SnowMeltFlag.class)) { if (!plot.getFlag(SnowMeltFlag.class)) {
plot.debug("Snow could not melt because snow-melt = false"); plot.debug("Snow could not melt because snow-melt = false");
event.setCancelled(true); event.setCancelled(true);
@ -709,7 +692,7 @@ public class BlockEventListener implements Listener {
} }
return; return;
} }
if (Tag.CORAL_BLOCKS.isTagged(blockType) || Tag.CORALS.isTagged(blockType) || Tag.WALL_CORALS.isTagged(blockType)) { if (Tag.CORAL_BLOCKS.isTagged(blockType) || Tag.CORALS.isTagged(blockType)) {
if (!plot.getFlag(CoralDryFlag.class)) { if (!plot.getFlag(CoralDryFlag.class)) {
plot.debug("Coral could not dry because coral-dry = false"); plot.debug("Coral could not dry because coral-dry = false");
event.setCancelled(true); event.setCancelled(true);

View File

@ -126,16 +126,16 @@ public class EntitySpawnListener implements Listener {
Plot plot = location.getOwnedPlotAbs(); Plot plot = location.getOwnedPlotAbs();
EntityType type = entity.getType(); EntityType type = entity.getType();
if (plot == null) { if (plot == null) {
if (type == EntityType.DROPPED_ITEM) {
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
event.setCancelled(true);
}
return;
}
if (!area.isMobSpawning()) { if (!area.isMobSpawning()) {
if (type == EntityType.PLAYER) { if (type == EntityType.PLAYER) {
return; return;
} }
if (type == EntityType.DROPPED_ITEM) {
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
event.setCancelled(true);
}
return;
}
if (type.isAlive()) { if (type.isAlive()) {
event.setCancelled(true); event.setCancelled(true);
} }

View File

@ -229,17 +229,17 @@ public class PaperListener implements Listener {
Plot plot = location.getOwnedPlotAbs(); Plot plot = location.getOwnedPlotAbs();
if (plot == null) { if (plot == null) {
EntityType type = event.getType(); EntityType type = event.getType();
// PreCreatureSpawnEvent **should** not be called for DROPPED_ITEM, just for the sake of consistency
if (type == EntityType.DROPPED_ITEM) {
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
event.setCancelled(true);
}
return;
}
if (!area.isMobSpawning()) { if (!area.isMobSpawning()) {
if (type == EntityType.PLAYER) { if (type == EntityType.PLAYER) {
return; return;
} }
if (type == EntityType.DROPPED_ITEM) {
if (Settings.Enabled_Components.KILL_ROAD_ITEMS) {
event.setShouldAbortSpawn(true);
event.setCancelled(true);
}
return;
}
if (type.isAlive()) { if (type.isAlive()) {
event.setShouldAbortSpawn(true); event.setShouldAbortSpawn(true);
event.setCancelled(true); event.setCancelled(true);

View File

@ -32,6 +32,7 @@ import com.plotsquared.core.util.TabCompletions;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.RunnableVal2; import com.plotsquared.core.util.task.RunnableVal2;
import com.plotsquared.core.util.task.RunnableVal3; import com.plotsquared.core.util.task.RunnableVal3;
import com.plotsquared.core.uuid.UUIDMapping;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
import java.util.Collection; import java.util.Collection;
@ -39,7 +40,6 @@ import java.util.Collections;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -88,8 +88,8 @@ public class Grant extends Command {
Template.of("value", String.valueOf(uuids)) Template.of("value", String.valueOf(uuids))
); );
} else { } else {
final UUID uuid = uuids.iterator().next(); final UUIDMapping uuid = uuids.toArray(new UUIDMapping[0])[0];
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuid); PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuid.getUuid());
if (pp != null) { if (pp != null) {
try (final MetaDataAccess<Integer> access = pp.accessPersistentMetaData( try (final MetaDataAccess<Integer> access = pp.accessPersistentMetaData(
PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) { PlayerMetaDataKeys.PERSISTENT_GRANTED_PLOTS)) {
@ -103,7 +103,7 @@ public class Grant extends Command {
} }
} }
} else { } else {
DBFunc.getPersistentMeta(uuid, new RunnableVal<>() { DBFunc.getPersistentMeta(uuid.getUuid(), new RunnableVal<>() {
@Override @Override
public void run(Map<String, byte[]> value) { public void run(Map<String, byte[]> value) {
final byte[] array = value.get("grantedPlots"); final byte[] array = value.get("grantedPlots");
@ -128,7 +128,7 @@ public class Grant extends Command {
boolean replace = array != null; boolean replace = array != null;
String key = "grantedPlots"; String key = "grantedPlots";
byte[] rawData = Ints.toByteArray(amount); byte[] rawData = Ints.toByteArray(amount);
DBFunc.addPersistentMeta(uuid, key, rawData, replace); DBFunc.addPersistentMeta(uuid.getUuid(), key, rawData, replace);
player.sendMessage( player.sendMessage(
TranslatableCaption.of("grants.added"), TranslatableCaption.of("grants.added"),
Template.of("grants", String.valueOf(amount)) Template.of("grants", String.valueOf(amount))

View File

@ -164,7 +164,7 @@ public final class PlaceholderRegistry {
PlayerManager.getPlayerList(plot.getDenied(), player)); PlayerManager.getPlayerList(plot.getDenied(), player));
}); });
this.createPlaceholder("currentplot_creationdate", (player, plot) -> { this.createPlaceholder("currentplot_creationdate", (player, plot) -> {
if (plot.getTimestamp() == 0 || !plot.hasOwner()) { if (plot.getTimestamp() == 0) {
return legacyComponent(TranslatableCaption.of("info.unknown"), player); return legacyComponent(TranslatableCaption.of("info.unknown"), player);
} }
long creationDate = plot.getTimestamp(); long creationDate = plot.getTimestamp();

View File

@ -19,7 +19,7 @@ plugins {
} }
group = "com.plotsquared" group = "com.plotsquared"
version = "6.9.4" version = "6.9.4-SNAPSHOT"
subprojects { subprojects {
group = rootProject.group group = rootProject.group

View File

@ -5,7 +5,7 @@ guice = "5.1.0"
spotbugs = "4.7.1" spotbugs = "4.7.1"
# Plugins # Plugins
worldedit = "7.2.12" worldedit = "7.2.10"
placeholderapi = "2.11.2" placeholderapi = "2.11.2"
luckperms = "5.4" luckperms = "5.4"
essentialsx = "2.19.4" essentialsx = "2.19.4"

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists