Compare commits

..

1 Commits

Author SHA1 Message Date
fbf07bbf1a Use correct field for unsaved in 1.18 2022-03-12 15:04:31 +00:00
14 changed files with 86 additions and 97 deletions

View File

@ -8,11 +8,11 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v3 uses: actions/checkout@v3.0.0
- name: Validate Gradle Wrapper" - name: Validate Gradle Wrapper"
uses: gradle/wrapper-validation-action@v1 uses: gradle/wrapper-validation-action@v1.0.4
- name: Setup Java - name: Setup Java
uses: actions/setup-java@v3 uses: actions/setup-java@v3.0.0
with: with:
distribution: temurin distribution: temurin
java-version: 17 java-version: 17

View File

@ -76,6 +76,7 @@ import com.plotsquared.core.util.EventDispatcher;
import com.plotsquared.core.util.MathMan; import com.plotsquared.core.util.MathMan;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.PremiumVerification; import com.plotsquared.core.util.PremiumVerification;
import com.plotsquared.core.util.RegExUtil;
import com.plotsquared.core.util.entity.EntityCategories; import com.plotsquared.core.util.entity.EntityCategories;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import com.plotsquared.core.util.task.TaskTime; import com.plotsquared.core.util.task.TaskTime;
@ -222,9 +223,10 @@ public class PlayerEventListener extends PlotListener implements Listener {
} }
} }
@SuppressWarnings("StringSplitter")
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void playerCommand(PlayerCommandPreprocessEvent event) { public void playerCommand(PlayerCommandPreprocessEvent event) {
String msg = event.getMessage().replace("/", "").toLowerCase(Locale.ROOT).trim(); String msg = event.getMessage().toLowerCase().replaceAll("/", "").trim();
if (msg.isEmpty()) { if (msg.isEmpty()) {
return; return;
} }
@ -238,9 +240,11 @@ public class PlayerEventListener extends PlotListener implements Listener {
String[] parts = msg.split(" "); String[] parts = msg.split(" ");
Plot plot = plotPlayer.getCurrentPlot(); Plot plot = plotPlayer.getCurrentPlot();
// Check WorldEdit // Check WorldEdit
switch (parts[0]) { switch (parts[0].toLowerCase()) {
case "up": case "up":
case "/up":
case "worldedit:up": case "worldedit:up":
case "worldedit:/up":
if (plot == null || (!plot.isAdded(plotPlayer.getUUID()) && !Permissions if (plot == null || (!plot.isAdded(plotPlayer.getUUID()) && !Permissions
.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER, true))) { .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER, true))) {
event.setCancelled(true); event.setCancelled(true);
@ -254,67 +258,63 @@ public class PlayerEventListener extends PlotListener implements Listener {
List<String> blockedCommands = plot != null ? List<String> blockedCommands = plot != null ?
plot.getFlag(BlockedCmdsFlag.class) : plot.getFlag(BlockedCmdsFlag.class) :
area.getFlag(BlockedCmdsFlag.class); area.getFlag(BlockedCmdsFlag.class);
if (blockedCommands.isEmpty()) { if (!blockedCommands.isEmpty() && !Permissions
return; .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
} String part = parts[0];
if (Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) { if (parts[0].contains(":")) {
return; part = parts[0].split(":")[1];
} msg = msg.replace(parts[0].split(":")[0] + ':', "");
// When using namespaced commands, we're not interested in the namespace }
String part = parts[0]; String s1 = part;
if (part.contains(":")) { List<String> aliases = new ArrayList<>();
String[] namespaced = part.split(":"); for (HelpTopic cmdLabel : Bukkit.getServer().getHelpMap().getHelpTopics()) {
part = namespaced[1]; if (part.equals(cmdLabel.getName())) {
msg = msg.substring(namespaced[0].length() + 1); break;
} }
msg = replaceAliases(msg, part); String label = cmdLabel.getName().replaceFirst("/", "");
for (String blocked : blockedCommands) { if (aliases.contains(label)) {
if (blocked.equalsIgnoreCase(msg)) { continue;
String perm; }
if (plot != null && plot.isAdded(plotPlayer.getUUID())) { PluginCommand p;
perm = "plots.admin.command.blocked-cmds.shared"; if ((p = Bukkit.getPluginCommand(label)) != null) {
for (String a : p.getAliases()) {
if (aliases.contains(a)) {
continue;
}
aliases.add(a);
a = a.replaceFirst("/", "");
if (!a.equals(label) && a.equals(part)) {
part = label;
break;
}
}
}
}
if (!s1.equals(part)) {
msg = msg.replace(s1, part);
}
for (String s : blockedCommands) {
Pattern pattern;
if (!RegExUtil.compiledPatterns.containsKey(s)) {
RegExUtil.compiledPatterns.put(s, pattern = Pattern.compile(s));
} else { } else {
perm = "plots.admin.command.blocked-cmds.road"; pattern = RegExUtil.compiledPatterns.get(s);
} }
if (!Permissions.hasPermission(plotPlayer, perm)) { if (pattern.matcher(msg).matches()) {
plotPlayer.sendMessage(TranslatableCaption.of("blockedcmds.command_blocked")); String perm;
event.setCancelled(true); if (plot != null && plot.isAdded(plotPlayer.getUUID())) {
} perm = "plots.admin.command.blocked-cmds.shared";
return; } else {
} perm = "plots.admin.command.blocked-cmds.road";
}
}
private String replaceAliases(String msg, String part) {
String s1 = part;
Set<String> aliases = new HashSet<>();
for (HelpTopic cmdLabel : Bukkit.getServer().getHelpMap().getHelpTopics()) {
if (part.equals(cmdLabel.getName())) {
break;
}
String label = cmdLabel.getName().replaceFirst("/", "");
if (aliases.contains(label)) {
continue;
}
PluginCommand p = Bukkit.getPluginCommand(label);
if (p != null) {
for (String a : p.getAliases()) {
if (aliases.contains(a)) {
continue;
} }
aliases.add(a); if (!Permissions.hasPermission(plotPlayer, perm)) {
a = a.replaceFirst("/", ""); plotPlayer.sendMessage(TranslatableCaption.of("blockedcmds.command_blocked"));
if (!a.equals(label) && a.equals(part)) { event.setCancelled(true);
part = label;
break;
} }
return;
} }
} }
} }
if (!s1.equals(part)) {
msg = msg.replace(s1, part);
}
return msg;
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -347,15 +347,13 @@ public class BukkitUtil extends WorldUtil {
final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ()); final Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
final Material type = block.getType(); final Material type = block.getType();
if (type != Material.LEGACY_SIGN && type != Material.LEGACY_WALL_SIGN) { if (type != Material.LEGACY_SIGN && type != Material.LEGACY_WALL_SIGN) {
BlockFace facing = BlockFace.NORTH; BlockFace facing = BlockFace.EAST;
if (!world.getBlockAt(location.getX(), location.getY(), location.getZ() + 1).getType().isSolid()) { if (world.getBlockAt(location.getX(), location.getY(), location.getZ() + 1).getType().isSolid()) {
if (world.getBlockAt(location.getX() - 1, location.getY(), location.getZ()).getType().isSolid()) { facing = BlockFace.NORTH;
facing = BlockFace.EAST; } else if (world.getBlockAt(location.getX() + 1, location.getY(), location.getZ()).getType().isSolid()) {
} else if (world.getBlockAt(location.getX() + 1, location.getY(), location.getZ()).getType().isSolid()) { facing = BlockFace.WEST;
facing = BlockFace.WEST; } else if (world.getBlockAt(location.getX(), location.getY(), location.getZ() - 1).getType().isSolid()) {
} else if (world.getBlockAt(location.getX(), location.getY(), location.getZ() - 1).getType().isSolid()) { facing = BlockFace.SOUTH;
facing = BlockFace.SOUTH;
}
} }
if (PlotSquared.platform().serverVersion()[1] == 13) { if (PlotSquared.platform().serverVersion()[1] == 13) {
block.setType(Material.valueOf(area.legacySignMaterial()), false); block.setType(Material.valueOf(area.legacySignMaterial()), false);

View File

@ -48,7 +48,7 @@ public class Confirm extends SubCommand {
player.sendMessage(TranslatableCaption.of("confirm.expired_confirm")); player.sendMessage(TranslatableCaption.of("confirm.expired_confirm"));
return false; return false;
} }
TaskManager.runTask(command.command); TaskManager.runTaskAsync(command.command);
return true; return true;
} }

View File

@ -40,7 +40,6 @@ import com.plotsquared.core.plot.schematic.Schematic;
import com.plotsquared.core.plot.world.PlotAreaManager; import com.plotsquared.core.plot.world.PlotAreaManager;
import com.plotsquared.core.util.Permissions; import com.plotsquared.core.util.Permissions;
import com.plotsquared.core.util.SchematicHandler; import com.plotsquared.core.util.SchematicHandler;
import com.plotsquared.core.util.TimeUtil;
import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.RunnableVal;
import com.plotsquared.core.util.task.TaskManager; import com.plotsquared.core.util.task.TaskManager;
import net.kyori.adventure.text.minimessage.Template; import net.kyori.adventure.text.minimessage.Template;
@ -206,7 +205,7 @@ public class Load extends SubCommand {
if (split.length < 5) { if (split.length < 5) {
continue; continue;
} }
String time = TimeUtil.secToTime((System.currentTimeMillis() / 1000) - Long.parseLong(split[0])); String time = secToTime((System.currentTimeMillis() / 1000) - Long.parseLong(split[0]));
String world = split[1]; String world = split[1];
PlotId id = PlotId.fromString(split[2] + ';' + split[3]); PlotId id = PlotId.fromString(split[2] + ';' + split[3]);
String size = split[4]; String size = split[4];
@ -224,10 +223,6 @@ public class Load extends SubCommand {
} }
} }
/**
* @deprecated Use {@link TimeUtil#secToTime(long)}
*/
@Deprecated(forRemoval = true, since = "6.6.2")
public String secToTime(long time) { public String secToTime(long time) {
StringBuilder toreturn = new StringBuilder(); StringBuilder toreturn = new StringBuilder();
if (time >= 33868800) { if (time >= 33868800) {

View File

@ -389,7 +389,7 @@ public class ClassicPlotManager extends SquarePlotManager {
if (!plot.isMerged(Direction.NORTH)) { if (!plot.isMerged(Direction.NORTH)) {
int z = bot.getZ(); int z = bot.getZ();
for (int x = bot.getX(); x < top.getX(); x++) { for (int x = bot.getX(); x < top.getX(); x++) {
for (int y = classicPlotWorld.getMinBuildHeight(); y <= classicPlotWorld.WALL_HEIGHT; y++) { for (int y = classicPlotWorld.getMaxBuildHeight(); y <= classicPlotWorld.WALL_HEIGHT; y++) {
queue.setBlock(x, y, z, blocks); queue.setBlock(x, y, z, blocks);
} }
} }

View File

@ -309,7 +309,7 @@ public class PlotListener {
} }
if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) { if ((lastPlot != null) && plot.getId().equals(lastPlot.getId()) && plot.hasOwner()) {
final UUID plotOwner = plot.getOwnerAbs(); final UUID plotOwner = plot.getOwnerAbs();
String owner = PlayerManager.resolveName(plotOwner, true).getComponent(player); String owner = PlayerManager.resolveName(plotOwner, false).getComponent(player);
Caption header = fromFlag ? StaticCaption.of(title) : TranslatableCaption.of("titles" + Caption header = fromFlag ? StaticCaption.of(title) : TranslatableCaption.of("titles" +
".title_entered_plot"); ".title_entered_plot");
Caption subHeader = fromFlag ? StaticCaption.of(subtitle) : TranslatableCaption.of("titles" + Caption subHeader = fromFlag ? StaticCaption.of(subtitle) : TranslatableCaption.of("titles" +

View File

@ -333,9 +333,10 @@ public final class PlotModificationManager {
ids.add(current.getId()); ids.add(current.getId());
} }
this.plot.clearRatings(); this.plot.clearRatings();
QueueCoordinator queue = this.plot.getArea().getQueue(); QueueCoordinator queue = null;
if (createSign) { if (createSign) {
this.removeSign(); this.removeSign();
queue = this.plot.getArea().getQueue();
} }
PlotManager manager = this.plot.getArea().getPlotManager(); PlotManager manager = this.plot.getArea().getPlotManager();
if (createRoad) { if (createRoad) {

View File

@ -29,7 +29,6 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@Deprecated(since = "6.6.2", forRemoval = true)
public class RegExUtil { public class RegExUtil {
public static Map<String, Pattern> compiledPatterns; public static Map<String, Pattern> compiledPatterns;

View File

@ -44,27 +44,27 @@ public final class TimeUtil {
StringBuilder toReturn = new StringBuilder(); StringBuilder toReturn = new StringBuilder();
if (time >= 33868800) { if (time >= 33868800) {
int years = (int) (time / 33868800); int years = (int) (time / 33868800);
time -= years * 33868800L; time -= years * 33868800;
toReturn.append(years).append("y "); toReturn.append(years).append("y ");
} }
if (time >= 604800) { if (time >= 604800) {
int weeks = (int) (time / 604800); int weeks = (int) (time / 604800);
time -= weeks * 604800L; time -= weeks * 604800;
toReturn.append(weeks).append("w "); toReturn.append(weeks).append("w ");
} }
if (time >= 86400) { if (time >= 86400) {
int days = (int) (time / 86400); int days = (int) (time / 86400);
time -= days * 86400L; time -= days * 86400;
toReturn.append(days).append("d "); toReturn.append(days).append("d ");
} }
if (time >= 3600) { if (time >= 3600) {
int hours = (int) (time / 3600); int hours = (int) (time / 3600);
time -= hours * 3600L; time -= hours * 3600;
toReturn.append(hours).append("h "); toReturn.append(hours).append("h ");
} }
if (time >= 60) { if (time >= 60) {
int minutes = (int) (time / 60); int minutes = (int) (time / 60);
time -= minutes * 60L; time -= minutes * 60;
toReturn.append(minutes).append("m "); toReturn.append(minutes).append("m ");
} }
if (toReturn.length() == 0 || time > 0) { if (toReturn.length() == 0 || time > 0) {

View File

@ -18,7 +18,7 @@ plugins {
idea idea
} }
version = "6.6.3-SNAPSHOT" version = "6.6.2-SNAPSHOT"
allprojects { allprojects {
group = "com.plotsquared" group = "com.plotsquared"
@ -40,9 +40,6 @@ allprojects {
maven { maven {
name = "Jitpack" name = "Jitpack"
url = uri("https://jitpack.io") url = uri("https://jitpack.io")
content {
includeModule("com.github.MilkBowl", "VaultAPI")
}
} }
maven { maven {

View File

@ -6,7 +6,7 @@ guava = "31.0.1-jre" # Version set by Minecraft
# Platform expectations # Platform expectations
paper = "1.18.1-R0.1-SNAPSHOT" paper = "1.18.1-R0.1-SNAPSHOT"
checker-qual = "3.21.4" checker-qual = "3.21.3"
guice = "5.1.0" guice = "5.1.0"
findbugs = "3.0.1" findbugs = "3.0.1"
snakeyaml = "1.30" # Version set by Bukkit snakeyaml = "1.30" # Version set by Bukkit
@ -17,12 +17,12 @@ adventure-text-minimessage = "4.1.0-SNAPSHOT"
adventure-platform-bukkit = "4.0.1" adventure-platform-bukkit = "4.0.1"
# Plugins # Plugins
worldedit = "7.2.10" worldedit = "7.2.9"
fawe = "2.1.1" fawe = "2.0.2-SNAPSHOT"
vault = "1.7.1" vault = "1.7.1"
placeholderapi = "2.11.1" placeholderapi = "2.11.1"
luckperms = "5.4" luckperms = "5.4"
essentialsx = "2.19.4" essentialsx = "2.19.3"
mvdwapi = "3.1.1" mvdwapi = "3.1.1"
# Third party # Third party
@ -33,7 +33,7 @@ arkitektonika = "2.1.1"
paster = "1.1.4" paster = "1.1.4"
bstats = "3.0.0" bstats = "3.0.0"
paperlib = "1.0.7" paperlib = "1.0.7"
squirrelid = "0.3.1" squirrelid = "0.3.0"
serverlib = "2.3.1" serverlib = "2.3.1"
http4j = "1.3" http4j = "1.3"
@ -78,7 +78,7 @@ prtree = { group = "com.intellectualsites.prtree", name = "PRTree", version.ref
aopalliance = { group = "aopalliance", name = "aopalliance", version.ref = "aopalliance" } aopalliance = { group = "aopalliance", name = "aopalliance", version.ref = "aopalliance" }
cloudServices = { group = "cloud.commandframework", name = "cloud-services", version.ref = "cloud-services" } cloudServices = { group = "cloud.commandframework", name = "cloud-services", version.ref = "cloud-services" }
mvdwapi = { group = "com.intellectualsites.mvdwplaceholderapi", name = "MVdWPlaceholderAPI", version.ref = "mvdwapi" } mvdwapi = { group = "com.intellectualsites.mvdwplaceholderapi", name = "MVdWPlaceholderAPI", version.ref = "mvdwapi" }
squirrelid = { group = "org.enginehub", name = "squirrelid", version.ref = "squirrelid" } squirrelid = { group = "com.github.EngineHub", name = "SquirrelID", version.ref = "squirrelid" }
serverlib = { group = "dev.notmyfault.serverlib", name = "ServerLib", version.ref = "serverlib" } serverlib = { group = "dev.notmyfault.serverlib", name = "ServerLib", version.ref = "serverlib" }
bstats = { group = "org.bstats", name = "bstats-bukkit", version.ref = "bstats" } bstats = { group = "org.bstats", name = "bstats-bukkit", version.ref = "bstats" }
paperlib = { group = "io.papermc", name = "paperlib", version.ref = "paperlib" } paperlib = { group = "io.papermc", name = "paperlib", version.ref = "paperlib" }

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.4.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -8,8 +8,7 @@
"com.google.guava:guava", "com.google.guava:guava",
"com.google.code.gson:gson", "com.google.code.gson:gson",
"gson", "gson",
"snakeyaml", "snakeyaml"
"net.kyori"
], ],
"timezone": "Europe/Berlin", "timezone": "Europe/Berlin",
"schedule": [ "schedule": [