Compare commits

..

6 Commits

Author SHA1 Message Date
SirYwell
def2ca7552 make y location of homes always absolute part 2 2022-05-11 19:38:28 +02:00
Jordan
f7d55ce105 Implement restoring tags directly using a supplied block (#3616)
- Reduces overhead when setting blocks via fallback
 - Also means blocks will not be accessed via world when they should be access via chunk (https://github.com/IntellectualSites/PlotSquared/pull/3612)
2022-05-11 13:12:19 +01:00
Bernhard
85911646f3 Add ability to disable random Mojang uuid API calls (#3586)
* feature: ability to disable impromtu Mojang uuid API calls

* refactor: update comment for the new setting
2022-05-11 13:11:57 +01:00
Jordan
8b75dece69 Implement chunkObject into queueing (#3612) 2022-05-11 13:11:38 +01:00
Bernhard
7d6e515ba8 Improvements to /plot list command (#3585)
* refactor: list command shows owner better
added check for:
- unknown owners (UUID not cached/invalid)
- server plots
- plots owner by everyone

* fix: show correct color in list command if plot is owned by everyone

* refactor: improved List command for server plots

(cherry picked from commit fed700f0d8)

* refactor: removed duplicate code

* refactor: renamed placeholders to reflect their use

Co-authored-by: Alexander Brandes <mc.cache@web.de>
2022-05-10 09:50:27 +02:00
dordsor21
13d7357c85 Niceties
- Better ordering of augmented information printed to consol on startup
 - Override
2022-05-10 01:43:01 +01:00
22 changed files with 135 additions and 395 deletions

View File

@@ -513,8 +513,10 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
this.backgroundPipeline.registerService(essentialsUUIDService);
}
final SquirrelIdUUIDService impromptuMojangService = new SquirrelIdUUIDService(Settings.UUID.IMPROMPTU_LIMIT);
this.impromptuPipeline.registerService(impromptuMojangService);
if (Settings.UUID.IMPROMPTU_SERVICE_MOJANG_API) {
final SquirrelIdUUIDService impromptuMojangService = new SquirrelIdUUIDService(Settings.UUID.IMPROMPTU_LIMIT);
this.impromptuPipeline.registerService(impromptuMojangService);
}
final SquirrelIdUUIDService backgroundMojangService = new SquirrelIdUUIDService(Settings.UUID.BACKGROUND_LIMIT);
this.backgroundPipeline.registerService(backgroundMojangService);
} else {

View File

@@ -80,7 +80,8 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
result.setBiome(x, z, BukkitAdapter.adapt(biome));
}
//do not annotate with Override until we discontinue support for 1.4.4
//do not annotate with Override until we discontinue support for 1.4.4 (we no longer support 1.4.4)
@Override
public void setBiome(int x, int y, int z, @NonNull Biome biome) {
result.setBiome(x, z, BukkitAdapter.adapt(biome));

View File

@@ -51,6 +51,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.block.Block;
import org.bukkit.block.Container;
import org.bukkit.block.data.BlockData;
@@ -266,7 +267,13 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
} catch (WorldEditException ignored) {
// Fallback to not so nice method
BlockData blockData = BukkitAdapter.adapt(block);
Block existing = getBukkitWorld().getBlockAt(x, y, z);
Block existing;
// Assume a chunk object has been given only when it should have been.
if (getChunkObject() instanceof Chunk chunkObject) {
existing = chunkObject.getBlock(x & 15, y, z & 15);
} else {
existing = getBukkitWorld().getBlockAt(x, y, z);
}
final BlockState existingBaseBlock = BukkitAdapter.adapt(existing.getBlockData());
if (BukkitBlockUtil.get(existing).equals(existingBaseBlock) && existing.getBlockData().matches(blockData)) {
return;
@@ -282,7 +289,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator {
CompoundTag tag = block.getNbtData();
StateWrapper sw = new StateWrapper(tag);
sw.restoreTag(getWorld().getName(), existing.getX(), existing.getY(), existing.getZ());
sw.restoreTag(existing);
}
}
}

View File

@@ -44,6 +44,7 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
import java.util.HashMap;
@@ -166,14 +167,32 @@ public class StateWrapper {
return str;
}
@SuppressWarnings("deprecation") // #setLine is needed for Spigot compatibility
/**
* Restore the TileEntity data to the given world at the given coordinates.
*
* @param worldName World name
* @param x x position
* @param y y position
* @param z z position
* @return true if successful
*/
public boolean restoreTag(String worldName, int x, int y, int z) {
if (this.tag == null) {
World world = BukkitUtil.getWorld(worldName);
if (world == null) {
return false;
}
World world = BukkitUtil.getWorld(worldName);
Block block = world.getBlockAt(x, y, z);
if (block == null) {
return restoreTag(world.getBlockAt(x, y, z));
}
/**
* Restore the TileEntity data to the given block
*
* @param block Block to restore to
* @return true if successful
*/
@SuppressWarnings("deprecation") // #setLine is needed for Spigot compatibility
public boolean restoreTag(@NonNull Block block) {
if (this.tag == null) {
return false;
}
org.bukkit.block.BlockState state = block.getState();

View File

@@ -37,10 +37,6 @@ dependencies {
// Logging
compileOnlyApi(libs.log4j)
// Records are cool. Builders are cooler
compileOnly(libs.recordBuilderProcessor)
annotationProcessor(libs.recordBuilderProcessor)
// Other libraries
api(libs.prtree)
api(libs.aopalliance)

View File

@@ -889,8 +889,8 @@ public class PlotSquared {
e.printStackTrace();
}
LOGGER.info("| generator: {}>{}", baseGenerator, areaGen);
LOGGER.info("| plot world: {}", pa);
LOGGER.info("| manager: {}", pa);
LOGGER.info("| plot world: {}", pa.getClass().getCanonicalName());
LOGGER.info("| manager: {}", pa.getPlotManager().getClass().getCanonicalName());
LOGGER.info("Note: Area created for cluster '{}' (invalid or old configuration?)", name);
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
@@ -906,6 +906,13 @@ public class PlotSquared {
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
}
PlotArea pa = areaGen.getPlotGenerator().getNewPlotArea(world, null, null, null);
LOGGER.info("- generator: {}>{}", baseGenerator, areaGen);
LOGGER.info("- plot world: {}", pa.getClass().getCanonicalName());
LOGGER.info("- plot area manager: {}", pa.getPlotManager().getClass().getCanonicalName());
if (!this.worldConfiguration.contains(path)) {
this.worldConfiguration.createSection(path);
worldSection = this.worldConfiguration.getConfigurationSection(path);
}
pa.saveConfiguration(worldSection);
pa.loadDefaultConfiguration(worldSection);
try {
@@ -913,9 +920,6 @@ public class PlotSquared {
} catch (IOException e) {
e.printStackTrace();
}
LOGGER.info("- generator: {}>{}", baseGenerator, areaGen);
LOGGER.info("- plot world: {}", pa);
LOGGER.info("- plot area manager: {}", pa.getPlotManager());
areaGen.getPlotGenerator().initialize(pa);
areaGen.augment(pa);
addPlotArea(pa);

View File

@@ -32,6 +32,7 @@ import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.CaptionHolder;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
@@ -39,6 +40,7 @@ import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.expiration.ExpireManager;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.flag.implementations.PriceFlag;
import com.plotsquared.core.plot.flag.implementations.ServerPlotFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.EconHandler;
import com.plotsquared.core.util.MathMan;
@@ -418,7 +420,7 @@ public class ListCmd extends SubCommand {
Caption color;
if (plot.getOwner() == null) {
color = TranslatableCaption.of("info.plot_list_no_owner");
} else if (plot.isOwner(player.getUUID())) {
} else if (plot.isOwner(player.getUUID()) || plot.getOwner().equals(DBFunc.EVERYONE)) {
color = TranslatableCaption.of("info.plot_list_owned_by");
} else if (plot.isAdded(player.getUUID())) {
color = TranslatableCaption.of("info.plot_list_added_to");
@@ -456,37 +458,60 @@ public class ListCmd extends SubCommand {
String prefix = "";
String online = TranslatableCaption.of("info.plot_list_player_online").getComponent(player);
String offline = TranslatableCaption.of("info.plot_list_player_offline").getComponent(player);
String unknown = TranslatableCaption.of("info.plot_list_player_unknown").getComponent(player);
String server = TranslatableCaption.of("info.plot_list_player_server").getComponent(player);
String everyone = TranslatableCaption.of("info.plot_list_player_everyone").getComponent(player);
TextComponent.Builder builder = Component.text();
try {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
for (final UUIDMapping uuidMapping : names) {
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid());
Template prefixTemplate = Template.of("prefix", prefix);
Template playerTemplate = Template.of("player", uuidMapping.getUsername());
if (pp != null) {
builder.append(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate));
} else {
builder.append(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate));
}
prefix = ", ";
}
} catch (InterruptedException | ExecutionException e) {
final StringBuilder playerBuilder = new StringBuilder();
final Iterator<UUID> uuidIterator = plot.getOwners().iterator();
while (uuidIterator.hasNext()) {
final UUID uuid = uuidIterator.next();
playerBuilder.append(uuid);
if (uuidIterator.hasNext()) {
playerBuilder.append(", ");
}
}
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Templates.of("value", playerBuilder.toString())
if (plot.getFlag(ServerPlotFlag.class)) {
Template serverTemplate = Template.of(
"info.server",
TranslatableCaption.of("info.server").getComponent(player)
);
} catch (TimeoutException e) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
builder.append(MINI_MESSAGE.parse(server, serverTemplate));
} else {
try {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
for (final UUIDMapping uuidMapping : names) {
PlotPlayer<?> pp = PlotSquared.platform().playerManager().getPlayerIfExists(uuidMapping.getUuid());
Template prefixTemplate = Template.of("prefix", prefix);
Template playerTemplate = Template.of("player", uuidMapping.getUsername());
if (pp != null) {
builder.append(MINI_MESSAGE.parse(online, prefixTemplate, playerTemplate));
} else if (uuidMapping.getUsername().equalsIgnoreCase("unknown")) {
Template unknownTemplate = Template.of(
"info.unknown",
TranslatableCaption.of("info.unknown").getComponent(player)
);
builder.append(MINI_MESSAGE.parse(unknown, unknownTemplate));
} else if (uuidMapping.getUuid().equals(DBFunc.EVERYONE)) {
Template everyoneTemplate = Template.of(
"info.everyone",
TranslatableCaption.of("info.everyone").getComponent(player)
);
builder.append(MINI_MESSAGE.parse(everyone, everyoneTemplate));
} else {
builder.append(MINI_MESSAGE.parse(offline, prefixTemplate, playerTemplate));
}
prefix = ", ";
}
} catch (InterruptedException | ExecutionException e) {
final StringBuilder playerBuilder = new StringBuilder();
final Iterator<UUID> uuidIterator = plot.getOwners().iterator();
while (uuidIterator.hasNext()) {
final UUID uuid = uuidIterator.next();
playerBuilder.append(uuid);
if (uuidIterator.hasNext()) {
playerBuilder.append(", ");
}
}
player.sendMessage(
TranslatableCaption.of("errors.invalid_player"),
Templates.of("value", playerBuilder.toString())
);
} catch (TimeoutException e) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
}
}
Template players = Template.of("players", builder.asComponent());
caption.set(TranslatableCaption.of("info.plot_list_item"));

View File

@@ -249,6 +249,9 @@ public class Settings extends Config {
public static int UUID_CACHE_SIZE = 100000;
@Comment("Rate limit (per 10 minutes) for background UUID fetching from the Mojang API")
public static int BACKGROUND_LIMIT = 200;
@Comment("Whether the Mojang API service is enabled for impromptu api calls. If false only the Background task will use" +
" http requests to fill the UUID cache (requires restart)")
public static boolean IMPROMPTU_SERVICE_MOJANG_API = true;
@Comment("Rate limit (per 10 minutes) for random UUID fetching from the Mojang API")
public static int IMPROMPTU_LIMIT = 300;
@Comment("Timeout (in milliseconds) for non-blocking UUID requests (mostly commands)")
@@ -691,6 +694,7 @@ public class Settings extends Config {
@Comment({"If blocks at the edges of queued operations should be set causing updates",
" - Slightly slower, but prevents issues such as fences left connected to nothing"})
public static boolean UPDATE_EDGES = true;
}
@Comment("Settings related to tab completion")

View File

@@ -1,8 +0,0 @@
package com.plotsquared.core.player;
public enum PlotRole {
OWNER,
HELPER,
TRUSTED,
DENIED,
}

View File

@@ -290,14 +290,14 @@ public class Plot {
* @param area the plot's PlotArea
* @param merged an array giving merged plots
* @param timestamp when the plot was created
* @param temp value representing whatever DBManager needs it to. Do not touch tbh.
* @param temp value representing whatever DBManager needs to to. Do not touch tbh.
*/
public Plot(
@NonNull PlotId id,
UUID owner,
Set<UUID> trusted,
Set<UUID> members,
Set<UUID> denied,
HashSet<UUID> trusted,
HashSet<UUID> members,
HashSet<UUID> denied,
String alias,
BlockLoc position,
Collection<PlotFlag<?, ?>> flags,
@@ -310,9 +310,9 @@ public class Plot {
this.area = area;
this.owner = owner;
this.settings = new PlotSettings();
this.members = new HashSet<>(members);
this.trusted = new HashSet<>(trusted);
this.denied = new HashSet<>(denied);
this.members = members;
this.trusted = trusted;
this.denied = denied;
this.settings.setAlias(alias);
this.settings.setPosition(position);
this.settings.setMerged(merged);
@@ -321,7 +321,9 @@ public class Plot {
if (area != null) {
this.flagContainer.setParentContainer(area.getFlagContainer());
if (flags != null) {
flags.forEach(this.flagContainer::addFlag);
for (PlotFlag<?, ?> flag : flags) {
this.flagContainer.addFlag(flag);
}
}
}
PlotSquared.platform().injector().injectMembers(this);
@@ -1418,15 +1420,7 @@ public class Plot {
0
);
}
Location location = Location
.at(
bottom.getWorldName(),
bottom.getX() + home.getX(),
bottom.getY() + home.getY(),
bottom.getZ() + home.getZ(),
home.getYaw(),
home.getPitch()
);
Location location = toHomeLocation(bottom, home);
if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
location = location.withY(
Math.max(1 + this.worldUtil.getHighestBlockSynchronous(
@@ -1459,15 +1453,7 @@ public class Plot {
return;
}
Location bottom = this.getBottomAbs();
Location location = Location
.at(
bottom.getWorldName(),
bottom.getX() + home.getX(),
home.getY(), // y is absolute
bottom.getZ() + home.getZ(),
home.getYaw(),
home.getPitch()
);
Location location = toHomeLocation(bottom, home);
this.worldUtil.getBlock(location, block -> {
if (!block.getBlockType().getMaterial().isAir()) {
this.worldUtil.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
@@ -1480,6 +1466,17 @@ public class Plot {
}
}
private Location toHomeLocation(Location bottom, BlockLoc relativeHome) {
return Location.at(
bottom.getWorldName(),
bottom.getX() + relativeHome.getX(),
relativeHome.getY(), // y is absolute
bottom.getZ() + relativeHome.getZ(),
relativeHome.getYaw(),
relativeHome.getPitch()
);
}
/**
* Sets the home location
*

View File

@@ -1,56 +0,0 @@
package com.plotsquared.core.plot;
import com.plotsquared.core.repository.PlotRepository;
import com.plotsquared.core.repository.PlotRoleRepository;
import com.plotsquared.core.repository.PlotSettingsRepository;
import com.plotsquared.core.repository.dbo.PlotSettingsDBOBuilder;
import org.checkerframework.checker.nullness.qual.NonNull;
import javax.inject.Inject;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
public final class PlotService {
private static final String PLOT_SETTINGS_DEFAULT_POSITION = "default";
private final PlotRepository plotRepository;
private final PlotSettingsRepository plotSettingsRepository;
private final PlotRoleRepository plotRoleRepository;
@Inject
public PlotService(
final @NonNull PlotRepository plotRepository,
final @NonNull PlotSettingsRepository plotSettingsRepository,
final @NonNull PlotRoleRepository plotRoleRepository
) {
this.plotRepository = plotRepository;
this.plotSettingsRepository = plotSettingsRepository;
this.plotRoleRepository = plotRoleRepository;
}
/**
* Returns a list containing all the plots in the given {@code plotArea}.
*
* @param plotArea the area
* @return all plots in the area
*/
public @NonNull Collection<Plot> getPlotsInArea(final @NonNull PlotArea plotArea) {
return this.plotRepository.getPlotsInArea(plotArea.getId())
.map(plotDBO -> {
final var settings = this.plotSettingsRepository.findById(plotDBO)
.orElseGet(() -> PlotSettingsDBOBuilder.builder()
.plot(plotDBO)
.position(PLOT_SETTINGS_DEFAULT_POSITION)
.build()
);
return plotDBO.toPlot(
plotArea,
settings,
this.plotRoleRepository.findAllFor(plotDBO),
List.of()
);
}).collect(Collectors.toList());
}
}

View File

@@ -143,7 +143,8 @@ public abstract class QueueCoordinator {
}
/**
* Set a chunk object (e.g. the Bukkit Chunk object) to the queue
* Set a chunk object (e.g. the Bukkit Chunk object) to the queue. This will be used as fallback in case of WNA failure.
* Should ONLY be used in specific cases (i.e. generation, where a chunk is being populated)
*
* @param chunkObject chunk object. Usually the implementation-specific chunk (e.g. bukkit Chunk)
*/

View File

@@ -1,21 +0,0 @@
package com.plotsquared.core.repository;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.repository.dbo.PlotDBO;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.stream.Stream;
/**
* {@link Repository} storing {@link PlotDBO plots} identified by their respective {@link PlotId}.
*/
public interface PlotRepository extends Repository<PlotDBO, Integer> {
/**
* Returns all plots in the given {@code area}.
*
* @param area the plot area
* @return a stream with all plots in the given area.
*/
@NonNull Stream<PlotDBO> getPlotsInArea(@NonNull String area);
}

View File

@@ -1,12 +0,0 @@
package com.plotsquared.core.repository;
import com.plotsquared.core.repository.dbo.PlotDBO;
import com.plotsquared.core.repository.dbo.PlotRoleDBO;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.List;
public interface PlotRoleRepository extends Repository<PlotRoleDBO, PlotRoleDBO.Key> {
List<PlotRoleDBO> findAllFor(@NonNull PlotDBO plotDBO);
}

View File

@@ -1,8 +0,0 @@
package com.plotsquared.core.repository;
import com.plotsquared.core.repository.dbo.PlotDBO;
import com.plotsquared.core.repository.dbo.PlotSettingsDBO;
public interface PlotSettingsRepository extends Repository<PlotSettingsDBO, PlotDBO> {
}

View File

@@ -1,28 +0,0 @@
package com.plotsquared.core.repository;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Optional;
/**
* Generic object repository.
*
* @param <T> the type of object stored in the repository.
* @param <U> the type used to identify objects stored in the repository.
*/
public interface Repository<@NonNull T, @NonNull U> {
/**
* Saves the given object.
*
* @param object {@code the object}.
*/
void save(T object);
/**
* Finds the object by its {@code id}.
*
* @param id the id
*/
@NonNull Optional<T> findById(U id);
}

View File

@@ -1,65 +0,0 @@
package com.plotsquared.core.repository.dbo;
import com.plotsquared.core.location.BlockLoc;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.PlotId;
import com.plotsquared.core.plot.flag.PlotFlag;
import io.soabase.recordbuilder.core.RecordBuilder;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.time.Instant;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
@RecordBuilder
public record PlotDBO(
@Nullable Integer id,
int plotIdX,
int plotIdZ,
@NonNull String world,
@NonNull UUID owner,
@NonNull Instant timestamp
) {
public @NonNull Plot toPlot(
final @NonNull PlotArea plotArea,
final @NonNull PlotSettingsDBO plotSettingsDBO,
final @NonNull Collection<PlotRoleDBO> plotRoles,
final @NonNull Collection<PlotFlag<?, ?>> flags
) {
final PlotId plotId = PlotId.of(this.plotIdX(), this.plotIdZ());
final int id = Objects.requireNonNull(id(), "id may not be null");
final Set<UUID> trusted = new HashSet<>();
final Set<UUID> members = new HashSet<>();
final Set<UUID> denied = new HashSet<>();
for (final PlotRoleDBO plotRole : plotRoles) {
switch (plotRole.plotRole()) {
case TRUSTED -> trusted.add(plotRole.userId());
case HELPER -> members.add(plotRole.userId());
case DENIED -> denied.add(plotRole.userId());
}
}
return new Plot(
plotId,
this.owner(),
Collections.unmodifiableSet(trusted),
Collections.unmodifiableSet(members),
Collections.unmodifiableSet(denied),
plotSettingsDBO.alias(),
BlockLoc.fromString(plotSettingsDBO.position()),
flags,
plotArea,
plotSettingsDBO.unwrapMerged(),
this.timestamp().toEpochMilli(),
id
);
}
}

View File

@@ -1,22 +0,0 @@
package com.plotsquared.core.repository.dbo;
import com.plotsquared.core.player.PlotRole;
import io.soabase.recordbuilder.core.RecordBuilder;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.UUID;
@RecordBuilder
public record PlotRoleDBO(
@NonNull PlotDBO plot,
@NonNull UUID userId,
@NonNull PlotRole plotRole
) {
public @NonNull Key key() {
return new Key(this.plot(), this.userId());
}
public record Key(@NonNull PlotDBO plot, @NonNull UUID userId) {
}
}

View File

@@ -1,29 +0,0 @@
package com.plotsquared.core.repository.dbo;
import io.soabase.recordbuilder.core.RecordBuilder;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
@RecordBuilder
public record PlotSettingsDBO(
@NonNull PlotDBO plot,
@Nullable String alias,
Integer merged,
@NonNull String position
) {
/**
* Unwraps {@link #merged()} into an array indicating whether the plot is merged in
* any given cardinal direction. The indices of the array correspond to the ordinals of
* {@link com.plotsquared.core.location.Direction}.
*
* @return unwrapped merged status
*/
public boolean@NonNull [] unwrapMerged() {
final boolean[] merged = new boolean[4];
for (int i = 0; i < 4; i++) {
merged[3 - i] = (this.merged() & 1 << i) != 0;
}
return merged;
}
}

View File

@@ -381,6 +381,9 @@
"info.plot_list_default": "<gold><plot></gold>",
"info.plot_list_player_online": "<dark_aqua><prefix></dark_aqua><hover:show_text:\"<dark_aqua>Online</dark_aqua>\"><gold><player></gold></hover>",
"info.plot_list_player_offline": "<dark_aqua><prefix></dark_aqua><hover:show_text:\"<dark_gray>Offline</dark_gray>\"><gold><player></gold></hover>",
"info.plot_list_player_unknown": "<hover:show_text:\"<red>The owner of this plot is unknown</red>\"><white><info.unknown></white></hover>",
"info.plot_list_player_server": "<hover:show_text:\"<red>The plot is owned by the server</red>\"><white><info.server></white></hover>",
"info.plot_list_player_everyone": "<hover:show_text:\"<blue>The plot is owned by everyone</blue>\"><white><info.everyone></white></hover>",
"info.area_info_format": "<header>\n<reset><gold>Name: </gold><gray><name></gray>\n<gold>Type: </gold><gray><type></gray>\n<gold>Terrain: </gold><gray><terrain></gray>\n<gold>Usage: </gold><gray><usage>%</gray>\n<gold>Claimed: </gold><gray><claimed></gray>\n<gold>Clusters: </gold><gray><clusters></gray>\n<gold>Region: </gold><gray><region></gray>\n<gold>Generator: </gold><gray><generator></gray>\n<footer>",
"info.area_list_tooltip": "<gold>Claimed=</gold><gray><claimed></gray>\n<gold>Usage=</gold><gray><usage></gray>\n<gold>Clusters=</gold><gray><clusters></gray>\n<gold>Region=</gold><gray><region></gray>\n<gold>Generator=</gold><gray><generator></gray>",
"info.area_list_item": "<click:run_command:<command_tp>><hover:show_text:\"<command_tp>\"><dark_gray>[</dark_gray><gold><number></gold><dark_gray>]</dark_gray></hover></click> <click:run_command:<command_info>><hover:show_text:\"<hover_info>\"><gold><area_name></gold></hover></click><gray> - </gray><gray><area_type>:<area_terrain></gray>",

View File

@@ -1,68 +0,0 @@
create table if not exists ${prefix}plot(
id int(11) not null auto_increment,
plot_id_x int(11) not null,
plot_id_z int(11) not null,
world varchar(45) not null,
owner varchar(40) not null,
timestamp timestamp not null default current_timestamp,
primary key (id)
) engine=InnoDB default charset=utf8 auto_increment=0;
-- TODO: Migrating existing data to this table.
create table if not exists ${prefix}plot_role(
plot_id int(11) not null,
user_id varchar(45) not null,
role enum('helper', 'trusted', 'denied') not null,
foreign key (plot_id) references ${prefix}plot(id) on delete cascade,
primary key (plot_id, user_id)
) engine=InnoDB default charset=utf8 auto_increment=0;
create table if not exists ${prefix}plot_comments(
world varchar(45) not null,
comment varchar(45) not null,
inbox varchar(45) not null,
timestamp int(11) not null,
sender varchar(45) not null
) engine=InnoDB default charset=utf8 auto_increment=0;
-- TODO: Look into what to do with this one...
-- Most data is now found in flags.
create table if not exists ${prefix}plot_settings(
plot_plot_id int(11) not null,
biome varchar(45) default 'FOREST', -- Unused. Moved to flags.
rain int(1) default 0, -- Unused. Moved to flags.
custom_time tinyint(1) default 0, -- Unused. Moved to flags.
time int(11) default 8000, -- Unused. Moved to flags.
deny_entry tinyint(1) default 0, -- Unused. Moved to flags.
alias varchar(50) default null,
merged int(11) default null,
position varchar(50) not null default 'default',
foreign key (plot_plot_id) references ${prefix}plot(id) on delete cascade,
primary key (plot_plot_id)
) engine=InnoDB default charset=utf8;
-- TODO: Look into adding foreign keys to this.
create table if not exists ${prefix}plot_rating(
plot_plot_id int(11) not null,
rating int(2) not null,
player varchar(45) not null
) engine=InnoDB default charset=utf8;
-- TODO: Drop the key and make the player ID the key instead.
create table if not exists ${prefix}player_meta(
meta_id int(11) not null auto_increment,
uuid varchar(45) not null,
key varchar(32) not null,
value blob not null,
primary key (meta_id)
) engine=InnoDB default charset=utf8 auto_increment=0;
-- TODO: Drop the ID and make (plot_id, flag) the new primary key.
create table if not exists ${prefix}plot_flags(
id int(11) not null auto_increment primary key,
plot_id int(11) not null,
flag varchar(64),
value varchar(512),
foreign key (plot_id) references ${prefix}plot(id) on delete cascade,
unique (plot_id, flag)
) engine=InnoDB default charset=utf8 auto_increment=0;

View File

@@ -36,7 +36,6 @@ paperlib = "1.0.7"
squirrelid = "0.3.1"
serverlib = "2.3.1"
http4j = "1.3"
record-builder-processor = "33"
# Gradle plugins
shadow = "7.1.2"
@@ -87,7 +86,6 @@ arkitektonika = { group = "com.intellectualsites.arkitektonika", name = "Arkitek
http4j = { group = "com.intellectualsites.http", name = "HTTP4J", version.ref = "http4j" }
paster = { group = "com.intellectualsites.paster", name = "Paster", version.ref = "paster" }
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
recordBuilderProcessor = { group = "io.soabase.record-builder", name = "record-builder-processor", version.ref = "record-builder-processor" }
[plugins]
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }