Compare commits

..
17 Commits
Author SHA1 Message Date
md5sha256 88f55bb6a9 Release 2.7.16 2023-12-06 20:13:28 +08:00
md5sha256 4ba8326314 Update dependencies and minor buildscript changes 2023-12-06 20:01:08 +08:00
md5sha256 de81d92da0 Update the SDK before installing 2023-12-06 19:50:50 +08:00
md5sha256 f636a98314 Use temurin jdk in jitpack.yml 2023-12-06 19:45:08 +08:00
md5sha256 e4df5a8cc9 Update gradle wrapper to 8.5 2023-12-06 19:33:54 +08:00
Andrew Wong 56818bebdb Add transfer feature
Adds /as transfer
2023-11-24 21:50:07 +11:00
Andrew Wong 7e1d7168f1 Refactor transfer to transfer both buyers and renters. Update lang files and fix data keys in GeneralRegion 2023-11-24 21:47:40 +11:00
Andrew Wong ff1ea3ae51 Add default config for transfers 2023-11-24 21:47:38 +11:00
Andrew Wong c9dc8dd840 Add SetTransferCommand 2023-11-24 21:47:36 +11:00
Andrew Wong c0794daeeb Actually respect transfers being disabled 2023-11-24 21:47:34 +11:00
Andrew Wong d40b9c660b Fix transfer missing region arg replacement and incorrect ownership checks in TransferCommand 2023-11-24 21:47:32 +11:00
Andrew Wong f7b010b3f3 Fix lang issue with region not being replaced, fix landlord/owner not being changed 2023-11-24 21:47:30 +11:00
Andrew Wong a06d9271c4 Make sure tab complete list is mutable in transfer command 2023-11-24 21:47:27 +11:00
Andrew Wong dd343aa587 Add messages for when regions are transferred 2023-11-24 21:47:25 +11:00
Andrew Wong e09d4ebd83 Fix lang and incorrect argument access 2023-11-24 21:47:23 +11:00
Andrew Wong 5f435941e4 Add transfer region command 2023-11-24 21:47:19 +11:00
Andrew Wong 86316cdd5b Prepare for snapshot 2.7.16 2023-11-24 21:43:33 +11:00
14 changed files with 306 additions and 23 deletions

No files matched your search

+3 -3
View File
@@ -49,9 +49,9 @@ dependencies {
runtimeOnly(project(":adapters:platform:bukkit-1-17", "reobf"))
}
runtimeOnly(projects.adapters.platform.bukkitModern)
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.57.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
}
@@ -0,0 +1,77 @@
package me.wiefferink.areashop.commands;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.List;
@Singleton
public class SetTransferCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private IFileManager fileManager;
@Inject
private Plugin plugin;
@Override
public String getCommandStart() {
return "areashop settransfer";
}
@Override
public String getHelp(CommandSender target) {
if (target.hasPermission("areashop.settransfer")) {
return "help-settransfer";
}
return null;
}
@Override
public void execute(CommandSender sender, String[] args) {
if (!sender.hasPermission("areashop.settransfer")) {
messageBridge.message(sender, "settransfer-noPermission");
return;
}
if (args.length <= 2 || args[1] == null || args[2] == null) {
messageBridge.message(sender, "settransfer-help");
return;
}
GeneralRegion region = fileManager.getRegion(args[1]);
if (region == null) {
messageBridge.message(sender, "settransfer-notRegistered", args[1]);
return;
}
boolean value;
if (args[2].equalsIgnoreCase("true")) {
value = true;
} else if (args[2].equalsIgnoreCase("false")) {
value = false;
} else {
messageBridge.message(sender, "settransfer-invalidSetting", args[2]);
return;
}
region.setTransferEnabled(value);
messageBridge.message(sender, "settransfer-success", args[2], region);
region.update();
}
@Override
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
List<String> result = new ArrayList<>();
if (toComplete == 2) {
result = fileManager.getRegionNames();
} else if (toComplete == 3) {
result.add("true");
result.add("false");
}
return result;
}
}
@@ -0,0 +1,150 @@
package me.wiefferink.areashop.commands;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Singleton
public class TransferCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private IFileManager fileManager;
@Inject
private Plugin plugin;
@Inject
private Server server;
@Override
public String getCommandStart() {
return "areashop transfer";
}
@Override
public String getHelp(CommandSender target) {
if (!target.hasPermission("areashop.transfer")) {
return null;
}
return "help-transfer";
}
@Override
public void execute(CommandSender sender, String[] args) {
if (!sender.hasPermission("areashop.transfer")) {
this.messageBridge.message(sender, "transfer-noPermission");
return;
}
if (sender instanceof Player player) {
handlePlayer(player, args);
} else {
this.messageBridge.message(sender, "cmd-onlyByPlayer");
}
}
private void handlePlayer(Player player, String[] args) {
if (args.length < 2) {
this.messageBridge.message(player, "transfer-help");
return;
}
String targetPlayerName = args[1];
if (targetPlayerName.equals(player.getName())) {
this.messageBridge.message(player, "transfer-transferSelf");
return;
}
GeneralRegion region;
if (args.length > 2) {
String targetRegionName = args[2];
region = this.fileManager.getRegion(targetRegionName);
if (region == null) {
messageBridge.message(player, "cmd-noRegion");
return;
}
} else {
List<GeneralRegion> regions = Utils.getImportantRegions(player.getLocation());
if (regions.isEmpty()) {
messageBridge.message(player, "cmd-noRegionsAtLocation");
return;
} else if (regions.size() > 1) {
messageBridge.message(player, "cmd-moreRegionsAtLocation");
return;
}
region = regions.get(0);
}
if (!region.isTransferEnabled()) {
this.messageBridge.message(player, "transfer-disabled");
return;
}
@SuppressWarnings("deprecation")
OfflinePlayer targetPlayer = this.server.getOfflinePlayer(targetPlayerName);
if (!targetPlayer.hasPlayedBefore()) {
// Unknown player
this.messageBridge.message(player, "transfer-noPlayer", targetPlayerName);
return;
}
if (region.isLandlord(player.getUniqueId())) {
// Transfer ownership if same as landlord
region.setOwner(targetPlayer.getUniqueId());
region.setLandlord(targetPlayer.getUniqueId(), targetPlayerName);
this.messageBridge.message(player, "transfer-transferred-owner", targetPlayerName, region);
if (targetPlayer.isOnline()) {
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-owner", targetPlayerName, region);
}
return;
}
if (!region.isOwner(player.getUniqueId())) {
// Cannot transfer tenant if we aren't the current tenant
this.messageBridge.message(player, "transfer-notCurrentTenant");
return;
}
// Swap the owner/occupant (renter or buyer)
region.setOwner(targetPlayer.getUniqueId());
this.messageBridge.message(player, "transfer-transferred-tenant", targetPlayerName, region);
if (targetPlayer.isOnline()) {
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-tenant", targetPlayerName, region);
}
}
@Override
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
if (toComplete == 2) {
Collection<? extends Player> players = this.server.getOnlinePlayers();
List<String> ret = new ArrayList<>(players.stream()
.map(Player::getName)
.toList());
if (sender instanceof Player player) {
ret.remove(player.getName());
}
return ret;
} else if (toComplete == 3) {
if (!(sender instanceof Player player)) {
return this.fileManager.getRegionNames();
}
UUID uuid = player.getUniqueId();
return new ArrayList<>(this.fileManager.getRegions()
.stream()
.filter(region -> region.isOwner(uuid) || region.isLandlord(uuid))
.map(GeneralRegion::getName)
.toList());
}
return Collections.emptyList();
}
}
@@ -29,6 +29,7 @@ import me.wiefferink.areashop.commands.RentCommand;
import me.wiefferink.areashop.commands.ResellCommand;
import me.wiefferink.areashop.commands.SchematiceventCommand;
import me.wiefferink.areashop.commands.SellCommand;
import me.wiefferink.areashop.commands.SetTransferCommand;
import me.wiefferink.areashop.commands.SetdurationCommand;
import me.wiefferink.areashop.commands.SetlandlordCommand;
import me.wiefferink.areashop.commands.SetownerCommand;
@@ -38,6 +39,7 @@ import me.wiefferink.areashop.commands.SetteleportCommand;
import me.wiefferink.areashop.commands.StackCommand;
import me.wiefferink.areashop.commands.StopresellCommand;
import me.wiefferink.areashop.commands.TeleportCommand;
import me.wiefferink.areashop.commands.TransferCommand;
import me.wiefferink.areashop.commands.UnrentCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -70,6 +72,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
commands.add(injector.getInstance(UnrentCommand.class));
commands.add(injector.getInstance(BuyCommand.class));
commands.add(injector.getInstance(SellCommand.class));
commands.add(injector.getInstance(TransferCommand.class));
commands.add(injector.getInstance(MeCommand.class));
commands.add(injector.getInstance(InfoCommand.class));
commands.add(injector.getInstance(TeleportCommand.class));
@@ -83,6 +86,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
commands.add(injector.getInstance(SetpriceCommand.class));
commands.add(injector.getInstance(SetownerCommand.class));
commands.add(injector.getInstance(SetdurationCommand.class));
commands.add(injector.getInstance(SetTransferCommand.class));
commands.add(injector.getInstance(ReloadCommand.class));
commands.add(injector.getInstance(GroupaddCommand.class));
commands.add(injector.getInstance(GroupdelCommand.class));
@@ -1589,6 +1589,22 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
return volume;
}
/**
* Whether region transfers are enabled
* @return Returns true if region transfers are enabled, false otherwise
*/
public boolean isTransferEnabled() {
return getBooleanSetting("general.transferMode");
}
/**
* Se whether region transfers are enabled
* @param enabled Whether region transfers should be enabled, false otherwise
*/
public void setTransferEnabled(boolean enabled) {
setSetting("general.transferMode", enabled);
}
/**
* Calculate the volume of the region (could be expensive for polygon regions).
* @return Number of blocks in the region
+2
View File
@@ -34,6 +34,8 @@ general:
landlordName: ''
# Disable to prevent counting this region towards limits set by 'limitGroups' in config.yml.
countForLimits: true
# Whether transferring tenant <--> tenant and landlord <--> landlord should be enabled
transferMode: false
##### Set the layout and functions of the signs.
# The following sections can be added for performing certain commands when the sign is clicked:
+17
View File
@@ -80,6 +80,7 @@ help-reload: "%lang:helpCommand|/as reload|% Reload all files and update the reg
help-setrestore: "%lang:helpCommand|/as setrestore|% Set restoring on/off and choose profile."
help-setprice: "%lang:helpCommand|/as setprice|% Change the price of a region."
help-setduration: "%lang:helpCommand|/as setduration|% Change the duration of a rent region."
help-settransfer: "%lang:helpCommand|/as settransfer|% Set transfer on/off."
help-teleport: "%lang:helpCommand|/as tp|% Teleport to a rent/buy region."
help-setteleport: "%lang:helpCommand|/as settp|% Set teleport position for a region."
help-find: "%lang:helpCommand|/as find|% Find an empty buy or rent."
@@ -102,6 +103,7 @@ help-linksigns: "%lang:helpCommand|/as linksigns|% Use bulk sign linking mode."
help-stack: "%lang:helpCommand|/as stack|% Create multiple regions and add them."
help-setlandlord: "%lang:helpCommand|/as setlandlord|% Set the landlord of a region."
help-import: "%lang:helpCommand|/as import|% Import region from RegionForSale."
help-transfer: "%lang:helpCommand|/as transfer|% Transfer a region to another player."
rent-help: "/as rent [region], the region you stand in will be used if not specified."
rent-noPermission: "You don't have permission to rent a region."
@@ -156,6 +158,15 @@ sell-noPermission: "You don't have permission to sell a region."
sell-noPermissionOther: "You don't have permission to sell another region."
sell-disabled: "Selling has been disabled for this region."
transfer-help: "/as transfer <player> [region], the region you stand in will be used if not specified."
transfer-noPermission: "You don't have permission to transfer a region."
transfer-disabled: "Transferring has been disabled for this region."
transfer-transferred-owner: "%lang:region% has been transferred and is now owned by %0%."
transfer-transferred-tenant: "%lang:region% has been transferred and is now occupied by %0%."
transfer-noPlayer: "Unknown player: %0%"
transfer-notCurrentTenant: "You are not the current tenant of this region."
transfer-transferSelf: "You cannot transfer a region to yourself."
reload-reloading: "Reloaded all configuration and region files."
reload-updateStart: ""
reload-updateComplete: ""
@@ -303,6 +314,12 @@ setrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or
setrestore-success: "Successfully set the restore setting of %lang:region% to '%0%'."
setrestore-successProfile: "Successfully set the restore setting of %lang:region% to '%0%' and the profile to '%1%'."
settransfer-help: "/as settransfer <region> <true|false>."
settransfer-noPermission: "You don't have permission to change the transfer settings."
settransfer-notRegistered: "The specified region is not registered: %0%."
settransfer-invalidSetting: "'%0%' is not a valid state, should be true, false or general."
settransfer-success: "Successfully set the transfer setting of %lang:region% to '%0%'."
setprice-noPermission: "You don't have permission to change the price of a region."
setprice-help: "/as setprice <price> [region], the region you stand in will be used if not specified."
setprice-notRegistered: "The specified region is not registered: %0%."
+11 -7
View File
@@ -5,16 +5,20 @@ plugins {
java
`java-library`
`maven-publish`
id("io.papermc.paperweight.userdev") version "1.5.5" apply false
id("io.papermc.paperweight.userdev") version "1.5.10" apply false
id("com.github.spotbugs") version "5.1.3"
idea
eclipse
}
group = "me.wiefferink"
version = "2.7.15"
version = "2.7.16"
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
val targetJavaVersion = 17
val encoding = Charsets.UTF_8
val encodingName: String = encoding.name()
java.toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
subprojects {
@@ -52,18 +56,18 @@ subprojects {
tasks {
withType(JavaCompile::class) {
options.release.set(17)
options.encoding = Charsets.UTF_8.name()
options.release.set(targetJavaVersion)
options.encoding = encodingName
options.isFork = true
options.isDeprecation = true
}
withType(Javadoc::class) {
options.encoding = Charsets.UTF_8.name()
options.encoding = encodingName
}
withType(ProcessResources::class) {
filteringCharset = Charsets.UTF_8.name()
filteringCharset = encodingName
}
}
+2 -2
View File
@@ -3,9 +3,9 @@
minecraft = "1.17.1-R0.1-SNAPSHOT"
# Minecraft Plugins
worldedit = "7.2.15"
worldedit = "7.2.17"
worldguard = "7.0.9"
fawe = "2.7.1"
fawe = "2.8.1"
[libraries]
# Platform
Binary file not shown.
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+17 -8
View File
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
esac
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -193,6 +198,10 @@ if "$cygwin" || "$msys" ; then
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Vendored
+1
View File
@@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+3 -2
View File
@@ -1,5 +1,6 @@
before_install:
- sdk install java 17.0.8-amzn
- sdk use java 17.0.8-amzn
- sdk update
- sdk install java 17.0.9-tem
- sdk use java 17.0.9-tem
install:
- ./gradlew build publishToMavenLocal