More work

This commit is contained in:
N0tMyFaultOG
2020-08-07 18:52:45 +02:00
parent 7f29b5d1e8
commit c31c4b4286
7 changed files with 37 additions and 29 deletions

View File

@ -65,7 +65,6 @@ 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.Captions;
import com.plotsquared.core.configuration.caption.ChatFormatter;
import com.plotsquared.core.configuration.ConfigurationNode;
import com.plotsquared.core.configuration.ConfigurationSection;
@ -276,7 +275,7 @@ import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
if (!plotSquared.getConfigurationVersion().equalsIgnoreCase("v5")) {
// Perform upgrade
if (DBFunc.dbManager.convertFlags()) {
log(Captions.PREFIX.getTranslated() + "Flags were converted successfully!");
logger.info("[P2] Flags were converted successfully!");
// Update the config version
try {
plotSquared.setConfigurationVersion("v5");

View File

@ -36,14 +36,15 @@ import com.google.inject.Inject;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.command.Command;
import com.plotsquared.core.command.MainCommand;
import com.plotsquared.core.configuration.Captions;
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.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.plot.flag.implementations.DoneFlag;
import com.plotsquared.core.plot.world.PlotAreaManager;
import net.kyori.adventure.text.minimessage.Template;
import org.bukkit.Chunk;
import org.bukkit.block.Block;
import org.bukkit.block.TileState;
@ -287,7 +288,10 @@ public class PaperListener implements Listener {
final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length;
if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) {
final PlotPlayer<?> plotPlayer = BukkitUtil.adapt(event.getPlayer());
Captions.TILE_ENTITY_CAP_REACHED.send(plotPlayer, Settings.Chunk_Processor.MAX_TILES);
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);
}

View File

@ -32,6 +32,7 @@ import com.plotsquared.bukkit.player.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.UpdateUtility;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.permissions.Permission;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.configuration.caption.TranslatableCaption;
@ -706,19 +707,17 @@ import java.util.regex.Pattern;
this.eventDispatcher.doJoinTask(pp);
}, TaskTime.seconds(1L));
if (pp.hasPermission(Permission.PERMISSION_ADMIN_UPDATE_NOTIFICATION.getTranslated())
&& Settings.Enabled_Components.UPDATE_NOTIFICATIONS && PremiumVerification.isPremium()
if (pp.hasPermission(Permission.PERMISSION_ADMIN_UPDATE_NOTIFICATION.toString())
&& Settings.Enabled_Components.UPDATE_NOTIFICATIONS
&& PremiumVerification.isPremium()
&& UpdateUtility.hasUpdate) {
new PlotMessage("-----------------------------------").send(pp);
new PlotMessage(Captions.PREFIX + "There appears to be a PlotSquared update available!")
.color("$1").send(pp);
new PlotMessage(
Captions.PREFIX + "&6You are running version " + UpdateUtility.internalVersion
.versionString() + ", &6latest version is " + UpdateUtility.spigotVersion)
.color("$1").send(pp);
new PlotMessage(Captions.PREFIX + "Download at:").color("$1").send(pp);
player.sendMessage(" https://www.spigotmc.org/resources/77506/updates");
new PlotMessage("-----------------------------------").send(pp);
Caption upperBoundary = TranslatableCaption.of("update.update_boundary");
Caption updateNotification = TranslatableCaption.of("update.update_notification");
Template internalVersion = Template.of("p2version", String.valueOf(UpdateUtility.internalVersion.versionString()));
Template spigotVersion = Template.of("spigotversion", UpdateUtility.spigotVersion);
Template downloadUrl = Template.of("downloadurl", "https://www.spigotmc.org/resources/77506/updates");
Caption lowerBoundary = TranslatableCaption.of("update.update_boundary");
pp.sendMessage(upperBoundary, updateNotification, internalVersion, spigotVersion, downloadUrl, lowerBoundary);
}
}
@ -1025,10 +1024,11 @@ import java.util.regex.Pattern;
return;
}
event.setCancelled(true);
String message = event.getMessage();
String format = Captions.PLOT_CHAT_FORMAT.getTranslated();
String sender = event.getPlayer().getDisplayName();
PlotId id = plot.getId();
Caption msg = TranslatableCaption.of("chat.plot_chat_format");
Template msgTemplate = Template.of("msg", event.getMessage());
Template plotTemplate = Template.of("plot_id", String.valueOf(plot.getId()));
Template senderTemplate = Template.of("sender", event.getPlayer().getDisplayName());
plotPlayer.sendMessage(msg, msgTemplate, plotTemplate, senderTemplate);
Set<Player> recipients = event.getRecipients();
recipients.clear();
Set<Player> spies = new HashSet<>();
@ -1052,11 +1052,12 @@ import java.util.regex.Pattern;
receiver.sendMessage(full);
}
if (!spies.isEmpty()) {
String spyMessage = Captions.PLOT_CHAT_SPY_FORMAT.getTranslated()
.replace("%plot_id%", id.getX() + ";" + id.getY()).replace("%sender%", sender)
.replace("%msg%", message);
Caption spymsg = TranslatableCaption.of("chat.plot_chat_spy_format");
Template plotidTemplate = Template.of("plot_id", id.getX() + ";" + id.getY());
Template spysenderTemplate = Template.of("sender", sender);
Template spymessageTemplate = Template.of("msg", message);
for (Player player : spies) {
player.sendMessage(spyMessage);
plotPlayer.sendMessage(spymsg, plotidTemplate, spysenderTemplate, spymessageTemplate);
}
}
// TODO: Re-implement

View File

@ -162,15 +162,15 @@ public class BukkitPlayer extends PlotPlayer<Player> {
@Override @Nonnegative public int hasPermissionRange(@Nonnull final String stub,
@Nonnegative final int range) {
if (hasPermission(Permission.PERMISSION_ADMIN.getTranslated())) {
if (hasPermission(Permission.PERMISSION_ADMIN.toString())) {
return Integer.MAX_VALUE;
}
final String[] nodes = stub.split("\\.");
final StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) {
n.append(nodes[i]).append(".");
if (!stub.equals(n + Permission.PERMISSION_STAR.getTranslated())) {
if (hasPermission(n + Permission.PERMISSION_STAR.getTranslated())) {
if (!stub.equals(n + Permission.PERMISSION_STAR.toString())) {
if (hasPermission(n + Permission.PERMISSION_STAR.toString())) {
return Integer.MAX_VALUE;
}
}

View File

@ -26,7 +26,6 @@
package com.plotsquared.bukkit.schematic;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.core.configuration.Captions;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.ListTag;