mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2026-01-01 06:38:46 +01:00
Compare commits
3 Commits
7.5.11
...
fix/v7/spe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48a47be17d | ||
|
|
79c7b5275a | ||
|
|
8edc5c15f1 |
@@ -40,6 +40,7 @@ import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@CommandDeclaration(command = "merge",
|
||||
aliases = "m",
|
||||
@@ -116,9 +117,11 @@ public class Merge extends SubCommand {
|
||||
if (direction == null) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("commandconfig.command_syntax"),
|
||||
TagResolver.resolver("value", Tag.inserting(Component.text(
|
||||
"/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]"
|
||||
)))
|
||||
TagResolver.resolver(
|
||||
"value", Tag.inserting(Component.text(
|
||||
"/plot merge <" + StringMan.join(values, " | ") + "> [removeroads]"
|
||||
))
|
||||
)
|
||||
);
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("help.direction"),
|
||||
@@ -154,14 +157,26 @@ public class Merge extends SubCommand {
|
||||
|
||||
UUID uuid = player.getUUID();
|
||||
|
||||
if (!force && !plot.isOwner(uuid)) {
|
||||
if (!player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_MERGE)) {
|
||||
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
|
||||
if (!force) {
|
||||
if (!plot.isOwner(uuid)) {
|
||||
if (!player.hasPermission(Permission.PERMISSION_ADMIN_COMMAND_MERGE)) {
|
||||
player.sendMessage(TranslatableCaption.of("permission.no_plot_perms"));
|
||||
return false;
|
||||
} else {
|
||||
uuid = plot.getOwnerAbs();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d && this.econHandler.getMoney(
|
||||
player) < price) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("economy.cannot_afford_merge"),
|
||||
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price))))
|
||||
);
|
||||
return false;
|
||||
} else {
|
||||
uuid = plot.getOwnerAbs();
|
||||
}
|
||||
}
|
||||
|
||||
if (direction == Direction.ALL) {
|
||||
boolean terrain = true;
|
||||
if (args.length == 2) {
|
||||
@@ -178,17 +193,15 @@ public class Merge extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
if (plot.getPlotModificationManager().autoMerge(Direction.ALL, maxSize, uuid, player, terrain)) {
|
||||
if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
|
||||
this.econHandler.withdrawMoney(player, price);
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("economy.removed_balance"),
|
||||
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price)))),
|
||||
TagResolver.resolver(
|
||||
"balance",
|
||||
Tag.inserting(Component.text(this.econHandler.format(this.econHandler.getMoney(player))))
|
||||
)
|
||||
);
|
||||
}
|
||||
this.econHandler.withdrawMoney(player, price);
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("economy.removed_balance"),
|
||||
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price)))),
|
||||
TagResolver.resolver(
|
||||
"balance",
|
||||
Tag.inserting(Component.text(this.econHandler.format(this.econHandler.getMoney(player))))
|
||||
)
|
||||
);
|
||||
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
||||
eventDispatcher.callPostMerge(player, plot);
|
||||
return true;
|
||||
@@ -196,14 +209,6 @@ public class Merge extends SubCommand {
|
||||
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
|
||||
return false;
|
||||
}
|
||||
if (!force && this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d && this.econHandler.getMoney(
|
||||
player) < price) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("economy.cannot_afford_merge"),
|
||||
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price))))
|
||||
);
|
||||
return false;
|
||||
}
|
||||
final boolean terrain;
|
||||
if (args.length == 2) {
|
||||
terrain = "true".equalsIgnoreCase(args[1]);
|
||||
@@ -244,54 +249,66 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
java.util.Set<UUID> uuids = adjacent.getOwners();
|
||||
boolean isOnline = false;
|
||||
for (final UUID owner : uuids) {
|
||||
final PlotPlayer<?> accepter = PlotSquared.platform().playerManager().getPlayerIfExists(owner);
|
||||
if (!force && accepter == null) {
|
||||
continue;
|
||||
}
|
||||
isOnline = true;
|
||||
final Direction dir = direction;
|
||||
Runnable run = () -> {
|
||||
accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted"));
|
||||
plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, player, terrain);
|
||||
PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(player.getUUID());
|
||||
if (plotPlayer == null) {
|
||||
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid"));
|
||||
return;
|
||||
if (!force) {
|
||||
for (final UUID owner : uuids) {
|
||||
final PlotPlayer<?> accepter = PlotSquared.platform().playerManager().getPlayerIfExists(owner);
|
||||
if (accepter == null) {
|
||||
continue;
|
||||
}
|
||||
if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
|
||||
if (!force && this.econHandler.getMoney(player) < price) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("economy.cannot_afford_merge"),
|
||||
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price))))
|
||||
);
|
||||
return;
|
||||
isOnline = true;
|
||||
final Direction dir = direction;
|
||||
Supplier<Boolean> run = () -> {
|
||||
accepter.sendMessage(TranslatableCaption.of("merge.merge_accepted"));
|
||||
if (plot.getPlotModificationManager().autoMerge(dir, maxSize - size, owner, player, terrain)) {
|
||||
PlotPlayer<?> plotPlayer = PlotSquared.platform().playerManager().getPlayerIfExists(player.getUUID());
|
||||
if (plotPlayer == null) {
|
||||
accepter.sendMessage(TranslatableCaption.of("merge.merge_not_valid"));
|
||||
return false;
|
||||
}
|
||||
if (this.econHandler.isEnabled(plotArea) && !player.hasPermission(Permission.PERMISSION_ADMIN_BYPASS_ECON) && price > 0d) {
|
||||
if (this.econHandler.getMoney(player) < price) {
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("economy.cannot_afford_merge"),
|
||||
TagResolver.resolver(
|
||||
"money",
|
||||
Tag.inserting(Component.text(this.econHandler.format(price)))
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
this.econHandler.withdrawMoney(player, price);
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("economy.removed_balance"),
|
||||
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price))))
|
||||
);
|
||||
}
|
||||
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
||||
eventDispatcher.callPostMerge(player, plot);
|
||||
return true;
|
||||
}
|
||||
this.econHandler.withdrawMoney(player, price);
|
||||
player.sendMessage(
|
||||
TranslatableCaption.of("economy.removed_balance"),
|
||||
TagResolver.resolver("money", Tag.inserting(Component.text(this.econHandler.format(price))))
|
||||
player.sendMessage(TranslatableCaption.of("merge.no_available_automerge"));
|
||||
return false;
|
||||
};
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(
|
||||
accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
|
||||
.deserialize(
|
||||
TranslatableCaption.of("merge.merge_request_confirm").getComponent(player),
|
||||
TagResolver.builder()
|
||||
.tag("player", Tag.inserting(Component.text(player.getName())))
|
||||
.tag(
|
||||
"location",
|
||||
Tag.inserting(Component.text(plot.getWorldName() + " " + plot.getId()))
|
||||
)
|
||||
.build()
|
||||
)),
|
||||
run::get
|
||||
);
|
||||
} else {
|
||||
return run.get();
|
||||
}
|
||||
player.sendMessage(TranslatableCaption.of("merge.success_merge"));
|
||||
eventDispatcher.callPostMerge(player, plot);
|
||||
};
|
||||
if (!force && hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(accepter, MINI_MESSAGE.serialize(MINI_MESSAGE
|
||||
.deserialize(
|
||||
TranslatableCaption.of("merge.merge_request_confirm").getComponent(player),
|
||||
TagResolver.builder()
|
||||
.tag("player", Tag.inserting(Component.text(player.getName())))
|
||||
.tag(
|
||||
"location",
|
||||
Tag.inserting(Component.text(plot.getWorldName() + " " + plot.getId()))
|
||||
)
|
||||
.build()
|
||||
)),
|
||||
run
|
||||
);
|
||||
} else {
|
||||
run.run();
|
||||
// find first
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (force || !isOnline) {
|
||||
|
||||
@@ -20,7 +20,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.intellectualsites.plotsquared"
|
||||
version = "7.5.11"
|
||||
version = "7.5.12-SNAPSHOT"
|
||||
|
||||
if (!File("$rootDir/.git").exists()) {
|
||||
logger.lifecycle("""
|
||||
|
||||
Reference in New Issue
Block a user