- Anonymize meta data keys
This commit is contained in:
NotMyFault 2021-05-20 21:04:07 +02:00
parent aae350c1b3
commit a05dd19986
No known key found for this signature in database
GPG Key ID: 158F5701A6AAD00C
3 changed files with 24 additions and 25 deletions

View File

@ -27,8 +27,8 @@ package com.plotsquared.core.listener;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.configuration.caption.StaticCaption;
import com.plotsquared.core.configuration.caption.Templates;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
import com.plotsquared.core.database.DBFunc;
import com.plotsquared.core.events.PlotFlagRemoveEvent;
@ -63,6 +63,7 @@ import com.plotsquared.core.plot.flag.implementations.WeatherFlag;
import com.plotsquared.core.plot.flag.types.TimedFlag;
import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PlayerManager;
import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime;
import com.sk89q.worldedit.world.gamemode.GameMode;
@ -76,7 +77,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import java.util.function.Consumer;
@ -296,16 +296,15 @@ public class PlotListener {
lastPlot = lastPlotAccess.get().orElse(null);
}
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) {
final UUID plotOwner = plot.getOwnerAbs();
String owner = PlayerManager.getName(plotOwner, false);
Caption header = TranslatableCaption.of("titles.title_entered_plot");
Caption subHeader = TranslatableCaption.of("titles.title_entered_plot_sub");
Template plotTemplate = Template.of("plot", lastPlot.getId().toString());
Template worldTemplate = Template.of("world", player.getLocation().getWorldName());
Template ownerTemplate = Template.of("owner", owner);
final Consumer<String> userConsumer = user -> player
.sendTitle(TranslatableCaption.of("titles.title_entered_plot"),
TranslatableCaption.of("titles.title_entered_plot_sub"),
Templates.of("x", lastPlot.getId().getX()),
Templates.of("z", lastPlot.getId().getY()),
Templates.of("world", Objects.requireNonNull(plot.getArea().getId(), "Unknown")),
Templates.of("greeting", greeting),
Templates.of("alias", plot.getAlias()),
Templates.of("owner", user)
);
.sendTitle(header, subHeader, plotTemplate, worldTemplate, ownerTemplate);
UUID uuid = plot.getOwner();
if (uuid == null) {
userConsumer.accept("Unknown");

View File

@ -38,20 +38,20 @@ import java.util.List;
public final class PlayerMetaDataKeys {
//@formatter:off
public static final MetaDataKey<Boolean> PERSISTENT_FLIGHT = MetaDataKey.of("flight", new TypeLiteral<Boolean>() {});
public static final MetaDataKey<Integer> PERSISTENT_GRANTED_PLOTS = MetaDataKey.of("grantedPlots", new TypeLiteral<Integer>() {});
public static final MetaDataKey<Boolean> PERSISTENT_FLIGHT = MetaDataKey.of("flight", new TypeLiteral<>() {});
public static final MetaDataKey<Integer> PERSISTENT_GRANTED_PLOTS = MetaDataKey.of("grantedPlots", new TypeLiteral<>() {});
public static final MetaDataKey<Plot> TEMPORARY_LAST_PLOT = MetaDataKey.of("lastplot", new TypeLiteral<Plot>() {});
public static final MetaDataKey<Location> TEMPORARY_MUSIC = MetaDataKey.of("music", new TypeLiteral<Location>() {});
public static final MetaDataKey<Boolean> TEMPORARY_KICK = MetaDataKey.of("kick", new TypeLiteral<Boolean>() {});
public static final MetaDataKey<SetupProcess> TEMPORARY_SETUP = MetaDataKey.of("setup", new TypeLiteral<SetupProcess>() {});
public static final MetaDataKey<PlotInventory> TEMPORARY_INVENTORY = MetaDataKey.of("inventory", new TypeLiteral<PlotInventory>() {});
public static final MetaDataKey<Boolean> TEMPORARY_IGNORE_EXPIRE_TASK = MetaDataKey.of("ignoreExpireTask", new TypeLiteral<Boolean>() {});
public static final MetaDataKey<Plot> TEMPORARY_WORLD_EDIT_REGION_PLOT = MetaDataKey.of("WorldEditRegionPlot", new TypeLiteral<Plot>() {});
public static final MetaDataKey<Boolean> TEMPORARY_AUTO = MetaDataKey.of(Auto.class.getName(), new TypeLiteral<Boolean>() {});
public static final MetaDataKey<List<String>> TEMPORARY_SCHEMATICS = MetaDataKey.of("plot_schematics", new TypeLiteral<List<String>>() {});
public static final MetaDataKey<Location> TEMPORARY_LOCATION = MetaDataKey.of("location", new TypeLiteral<Location>() {});
public static final MetaDataKey<CmdInstance> TEMPORARY_CONFIRM = MetaDataKey.of("cmdConfirm", new TypeLiteral<CmdInstance>() {});
public static final MetaDataKey<Plot> TEMPORARY_LAST_PLOT = MetaDataKey.of("lastplot", new TypeLiteral<>() {});
public static final MetaDataKey<Location> TEMPORARY_MUSIC = MetaDataKey.of("music", new TypeLiteral<>() {});
public static final MetaDataKey<Boolean> TEMPORARY_KICK = MetaDataKey.of("kick", new TypeLiteral<>() {});
public static final MetaDataKey<SetupProcess> TEMPORARY_SETUP = MetaDataKey.of("setup", new TypeLiteral<>() {});
public static final MetaDataKey<PlotInventory> TEMPORARY_INVENTORY = MetaDataKey.of("inventory", new TypeLiteral<>() {});
public static final MetaDataKey<Boolean> TEMPORARY_IGNORE_EXPIRE_TASK = MetaDataKey.of("ignoreExpireTask", new TypeLiteral<>() {});
public static final MetaDataKey<Plot> TEMPORARY_WORLD_EDIT_REGION_PLOT = MetaDataKey.of("WorldEditRegionPlot", new TypeLiteral<>() {});
public static final MetaDataKey<Boolean> TEMPORARY_AUTO = MetaDataKey.of(Auto.class.getName(), new TypeLiteral<>() {});
public static final MetaDataKey<List<String>> TEMPORARY_SCHEMATICS = MetaDataKey.of("plot_schematics", new TypeLiteral<>() {});
public static final MetaDataKey<Location> TEMPORARY_LOCATION = MetaDataKey.of("location", new TypeLiteral<>() {});
public static final MetaDataKey<CmdInstance> TEMPORARY_CONFIRM = MetaDataKey.of("cmdConfirm", new TypeLiteral<>() {});
//@formatter:on
private PlayerMetaDataKeys() {

View File

@ -157,7 +157,7 @@
"schematic.schematic_exportall_world": "<prefix><red>Invalid world.</red>",
"schematics.plot_to_schem": "<dark_aqua>Plot</dark_aqua><dark_gray>-></dark_gray><dark_aqua>Schematic</dark_aqua><dark_gray>: </dark_gray><gray>Found </gray><gold><amount></gold><gray> plots...</gray>",
"error.task_in_process": "<prefix><gold>Task is already running.</gold>",
"titles.title_entered_plot": "<gold>Plot: <world>;<x>;<z></gold>",
"titles.title_entered_plot": "<gold>Plot: <world>;<plot></gold>",
"titles.title_entered_plot_sub": "<dark_aqua>Owned by <owner></dark_aqua>",
"titles.prefix_greeting": "<gold><id></gold><gray>></gray>",
"titles.prefix_farewell": "<gold><id></gold><gray>></gray>",