mirror of
https://github.com/md5sha256/AreaShop.git
synced 2026-11-06 17:32:43 -05:00
Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7907498c9 | ||
|
|
afbdc6c009 | ||
|
|
cc3a0b32a4 | ||
|
|
aca6103b1c | ||
|
|
02c02dad8d | ||
|
|
822f300e65 | ||
|
|
1671dc8c26 | ||
|
|
72c4a76c6c | ||
|
|
c9e7e3cdbb | ||
|
|
4ceff1b80e | ||
|
|
8e88dc7b6b | ||
|
|
2762ebae1d | ||
|
|
5742dd623e | ||
|
|
e5d190d81e | ||
|
|
b631cfc89d | ||
|
|
399b166339 | ||
|
|
b556cb1bce | ||
|
|
105274b633 | ||
|
|
9b036dad93 | ||
|
|
628aa83089 | ||
|
|
11da15454d | ||
|
|
ff2e4e235d |
No files matched your search
@@ -31,7 +31,7 @@ dependencies {
|
||||
api("com.google.inject.extensions:guice-assistedinject:7.0.0") {
|
||||
exclude("com.google.guava")
|
||||
}
|
||||
implementation("org.incendo:cloud-paper:2.0.0-beta.9") {
|
||||
implementation("org.incendo:cloud-paper:2.0.0-beta.10") {
|
||||
exclude("com.google.guava")
|
||||
}
|
||||
implementation("org.incendo:cloud-processors-confirmation:1.0.0-beta.3") {
|
||||
@@ -53,8 +53,8 @@ dependencies {
|
||||
runtimeOnly(projects.adapters.plugins.fastasyncworldedit)
|
||||
runtimeOnly(projects.adapters.plugins.essentials)
|
||||
}
|
||||
testImplementation("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.86.1")
|
||||
testImplementation("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.21:3.131.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
|
||||
}
|
||||
@@ -130,15 +130,15 @@ tasks {
|
||||
// Configure the Minecraft version for our task.
|
||||
// This is the only required configuration besides applying the plugin.
|
||||
// Your plugin's jar (or shadowJar if present) will be used automatically.
|
||||
minecraftVersion("1.21")
|
||||
minecraftVersion("1.21.1")
|
||||
|
||||
downloadPlugins {
|
||||
github("EssentialsX", "essentials", "2.20.1", "EssentialsX-2.20.1.jar")
|
||||
github("MilkBowl", "Vault", "1.7.3", "Vault.jar")
|
||||
// WorldEdit 7.3.3
|
||||
url("https://mediafilez.forgecdn.net/files/5400/331/worldedit-bukkit-7.3.3.jar")
|
||||
// WorldGuard 7.0.10
|
||||
url("https://mediafilez.forgecdn.net/files/5344/377/worldguard-bukkit-7.0.10-dist.jar")
|
||||
// WorldEdit 7.3.9
|
||||
url("https://mediafilez.forgecdn.net/files/5935/693/worldedit-bukkit-7.3.9.jar")
|
||||
// WorldGuard 7.0.12
|
||||
url("https://mediafilez.forgecdn.net/files/5719/698/worldguard-bukkit-7.0.12-dist.jar")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,10 @@ import me.wiefferink.areashop.interfaces.AreaShopInterface;
|
||||
import me.wiefferink.areashop.interfaces.WorldEditInterface;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.listeners.PlayerLoginLogoutListener;
|
||||
import me.wiefferink.areashop.managers.CacheManager;
|
||||
import me.wiefferink.areashop.managers.FeatureManager;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.managers.FileManager;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.managers.Manager;
|
||||
import me.wiefferink.areashop.managers.SignErrorLogger;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
@@ -56,6 +57,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@@ -81,6 +83,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
private MessageBridge messageBridge;
|
||||
private IFileManager fileManager = null;
|
||||
private LanguageManager languageManager = null;
|
||||
private CacheManager cacheManager = null;
|
||||
private SignLinkerManager signLinkerManager = null;
|
||||
private FeatureManager featureManager = null;
|
||||
private SignManager signManager;
|
||||
@@ -285,11 +288,17 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
managers.add(featureManager);
|
||||
signManager = injector.getInstance(SignManager.class);
|
||||
managers.add(signManager);
|
||||
cacheManager = injector.getInstance(CacheManager.class);
|
||||
String rawExpiryDuration = fileManager.getConfig().getString("cacheExpiryDuration", "7d");
|
||||
long millis = Utils.durationStringToLong(rawExpiryDuration);
|
||||
cacheManager.initialize(new File(getDataFolder(), "uuid-cache.bin"), Duration.ofMillis(millis));
|
||||
cacheManager.loadCache();
|
||||
managers.add(cacheManager);
|
||||
|
||||
loadExtensions();
|
||||
|
||||
// Register the event listeners
|
||||
getServer().getPluginManager().registerEvents(new PlayerLoginLogoutListener(this, messageBridge), this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerLoginLogoutListener(this, messageBridge, this.cacheManager), this);
|
||||
|
||||
setupTasks();
|
||||
|
||||
@@ -384,6 +393,10 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
return version;
|
||||
}
|
||||
|
||||
public CacheManager getCacheManager() {
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on shutdown or reload of the server.
|
||||
*/
|
||||
|
||||
@@ -3,15 +3,17 @@ package me.wiefferink.areashop.commands;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionParseUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.PlayerCommandSource;
|
||||
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.BukkitSchedulerExecutor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -28,20 +30,26 @@ import javax.annotation.Nonnull;
|
||||
@Singleton
|
||||
public class AddFriendCommand extends AreashopCommandBean {
|
||||
|
||||
private static final CloudKey<OfflinePlayer> KEY_FRIEND = CloudKey.of("friend", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_FRIEND = CloudKey.of("friend", String.class);
|
||||
private final CommandFlag<GeneralRegion> regionFlag;
|
||||
private final MessageBridge messageBridge;
|
||||
private final Plugin plugin;
|
||||
private final BukkitSchedulerExecutor executor;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
|
||||
@Inject
|
||||
public AddFriendCommand(
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull Plugin plugin
|
||||
@Nonnull Plugin plugin,
|
||||
@Nonnull BukkitSchedulerExecutor executor,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.plugin = plugin;
|
||||
this.regionFlag = RegionParseUtil.createDefault(fileManager);
|
||||
this.executor = executor;
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,7 +69,7 @@ public class AddFriendCommand extends AreashopCommandBean {
|
||||
protected @Nonnull Command.Builder<? extends CommandSource<?>> configureCommand(@Nonnull Command.Builder<CommandSource<?>> builder) {
|
||||
return builder.literal("addfriend")
|
||||
.senderType(PlayerCommandSource.class)
|
||||
.required(KEY_FRIEND, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
|
||||
.required(KEY_FRIEND, OfflinePlayerParser.parser())
|
||||
.flag(this.regionFlag)
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
@@ -73,31 +81,49 @@ public class AddFriendCommand extends AreashopCommandBean {
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = RegionParseUtil.getOrParseRegion(context, sender, this.regionFlag);
|
||||
OfflinePlayer friend = context.get(KEY_FRIEND);
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_FRIEND))
|
||||
.whenCompleteAsync((offlinePlayer, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) {
|
||||
this.messageBridge.message(sender, "cmd-invalidPlayer", offlinePlayer.getName());
|
||||
return;
|
||||
}
|
||||
processWithFriend(sender, region, offlinePlayer);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
private void processWithFriend(@Nonnull Player sender,
|
||||
@Nonnull GeneralRegion region,
|
||||
@Nonnull OfflinePlayer friend
|
||||
) {
|
||||
if (sender.hasPermission("areashop.addfriendall") && ((region instanceof RentRegion rentRegion && !rentRegion.isRented())
|
||||
|| (region instanceof BuyRegion buyRegion && !buyRegion.isSold()))) {
|
||||
this.messageBridge.message(sender, "addfriend-noOwner", region);
|
||||
this.messageBridge.message(sender, "addfriend-noOwner", region);
|
||||
return;
|
||||
|
||||
}
|
||||
if (!sender.hasPermission("areashop.addfriend")) {
|
||||
this.messageBridge.message(sender, "addfriend-noPermission", region);
|
||||
this.messageBridge.message(sender, "addfriend-noPermission", region);
|
||||
return;
|
||||
}
|
||||
if (!region.isOwner(sender)) {
|
||||
this.messageBridge.message(sender, "addfriend-noPermissionOther", region);
|
||||
this.messageBridge.message(sender, "addfriend-noPermissionOther", region);
|
||||
return;
|
||||
}
|
||||
if (!friend.hasPlayedBefore() && !friend.isOnline() && !plugin.getConfig()
|
||||
.getBoolean("addFriendNotExistingPlayers")) {
|
||||
this.messageBridge.message(sender, "addfriend-notVisited", friend.getName(), region);
|
||||
this.messageBridge.message(sender, "addfriend-notVisited", friend.getName(), region);
|
||||
} else if (region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
this.messageBridge.message(sender, "addfriend-alreadyAdded", friend.getName(), region);
|
||||
this.messageBridge.message(sender, "addfriend-alreadyAdded", friend.getName(), region);
|
||||
} else if (region.isOwner(friend.getUniqueId())) {
|
||||
this.messageBridge.message(sender, "addfriend-self", friend.getName(), region);
|
||||
this.messageBridge.message(sender, "addfriend-self", friend.getName(), region);
|
||||
} else if (region.getFriendsFeature().addFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
this.messageBridge.message(sender, "addfriend-success", friend.getName(), region);
|
||||
this.messageBridge.message(sender, "addfriend-success", friend.getName(), region);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,18 @@ package me.wiefferink.areashop.commands;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreaShopCommandException;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionParseUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.features.FriendsFeature;
|
||||
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.BukkitSchedulerExecutor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -34,17 +36,23 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class DelFriendCommand extends AreashopCommandBean {
|
||||
|
||||
|
||||
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
|
||||
private final MessageBridge messageBridge;
|
||||
private final CommandFlag<GeneralRegion> regionFlag;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
private final BukkitSchedulerExecutor executor;
|
||||
|
||||
@Inject
|
||||
public DelFriendCommand(
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull IFileManager fileManager
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper,
|
||||
@Nonnull BukkitSchedulerExecutor executor
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.regionFlag = RegionParseUtil.createDefault(fileManager);
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +93,7 @@ public class DelFriendCommand extends AreashopCommandBean {
|
||||
@Override
|
||||
protected @Nonnull Command.Builder<? extends CommandSource<?>> configureCommand(@Nonnull Command.Builder<CommandSource<?>> builder) {
|
||||
return builder.literal("delfriend", "deletefriend")
|
||||
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser(), this::suggestFriends)
|
||||
.required(KEY_PLAYER, OfflinePlayerParser.parser(), this::suggestFriends)
|
||||
.flag(this.regionFlag)
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
@@ -96,7 +104,24 @@ public class DelFriendCommand extends AreashopCommandBean {
|
||||
throw new AreaShopCommandException("delfriend-noPermission");
|
||||
}
|
||||
GeneralRegion region = RegionParseUtil.getOrParseRegion(context, sender, this.regionFlag);
|
||||
OfflinePlayer friend = context.get(KEY_PLAYER);
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_PLAYER))
|
||||
.whenCompleteAsync((offlinePlayer, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) {
|
||||
this.messageBridge.message(sender, "cmd-invalidPlayer", offlinePlayer.getName());
|
||||
return;
|
||||
}
|
||||
processWithSender(sender, region, offlinePlayer);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
private void processWithSender(@Nonnull CommandSender sender,
|
||||
@Nonnull GeneralRegion region,
|
||||
@Nonnull OfflinePlayer friend) {
|
||||
FriendsFeature friendsFeature = region.getFriendsFeature();
|
||||
if (sender.hasPermission("areashop.delfriendall")) {
|
||||
if ((region instanceof RentRegion rentRegion && !rentRegion.isRented())
|
||||
|
||||
@@ -75,7 +75,7 @@ public class GroupInfoCommand extends AreashopCommandBean {
|
||||
throw new AreaShopCommandException("groupinfo-noMembers", group.getName());
|
||||
}
|
||||
String seperatedMembers = Utils.createCommaSeparatedList(members);
|
||||
this.messageBridge.message(context.sender(), "groupinfo-members", group.getName(), seperatedMembers);
|
||||
this.messageBridge.message(context.sender().sender(), "groupinfo-members", group.getName(), seperatedMembers);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,13 @@ package me.wiefferink.areashop.commands;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionInfoUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.bean.CommandProperties;
|
||||
@@ -20,18 +21,24 @@ import javax.annotation.Nonnull;
|
||||
@Singleton
|
||||
public class InfoPlayerCommand extends AreashopCommandBean {
|
||||
|
||||
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
|
||||
|
||||
private final MessageBridge messageBridge;
|
||||
private final IFileManager fileManager;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
private final BukkitSchedulerExecutor executor;
|
||||
|
||||
@Inject
|
||||
public InfoPlayerCommand(
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull IFileManager fileManager
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper,
|
||||
@Nonnull BukkitSchedulerExecutor executor
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.fileManager = fileManager;
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,7 +54,7 @@ public class InfoPlayerCommand extends AreashopCommandBean {
|
||||
@Override
|
||||
protected @Nonnull Command.Builder<? extends CommandSource<?>> configureCommand(@Nonnull Command.Builder<CommandSource<?>> builder) {
|
||||
return builder.literal("info").literal("player")
|
||||
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
|
||||
.required(KEY_PLAYER, OfflinePlayerParser.parser())
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
|
||||
@@ -62,8 +69,19 @@ public class InfoPlayerCommand extends AreashopCommandBean {
|
||||
messageBridge.message(sender, "info-noPermission");
|
||||
return;
|
||||
}
|
||||
OfflinePlayer offlinePlayer = context.get(KEY_PLAYER);
|
||||
RegionInfoUtil.showRegionInfo(this.messageBridge, this.fileManager, sender, offlinePlayer);
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_PLAYER))
|
||||
.whenCompleteAsync((offlinePlayer, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) {
|
||||
this.messageBridge.message(sender, "cmd-invalidPlayer", offlinePlayer.getName());
|
||||
return;
|
||||
}
|
||||
RegionInfoUtil.showRegionInfo(this.messageBridge, this.fileManager, sender, offlinePlayer);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,15 @@ package me.wiefferink.areashop.commands;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreaShopCommandException;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionInfoUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.PlayerCommandSource;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -25,17 +26,23 @@ import javax.annotation.Nonnull;
|
||||
@Singleton
|
||||
public class MeCommand extends AreashopCommandBean {
|
||||
|
||||
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
|
||||
private final IFileManager fileManager;
|
||||
private final MessageBridge messageBridge;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
private final BukkitSchedulerExecutor executor;
|
||||
|
||||
@Inject
|
||||
public MeCommand(
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull IFileManager fileManager
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper,
|
||||
@Nonnull BukkitSchedulerExecutor executor
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.fileManager = fileManager;
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,7 +54,7 @@ public class MeCommand extends AreashopCommandBean {
|
||||
protected Command.Builder<? extends CommandSource<?>> configureCommand(Command.@NotNull Builder<CommandSource<?>> builder) {
|
||||
return builder.literal("me")
|
||||
.senderType(PlayerCommandSource.class)
|
||||
.optional(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
|
||||
.optional(KEY_PLAYER, OfflinePlayerParser.parser())
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
|
||||
@@ -69,8 +76,23 @@ public class MeCommand extends AreashopCommandBean {
|
||||
if (!sender.hasPermission("areashop.me")) {
|
||||
throw new AreaShopCommandException("me-noPermission");
|
||||
}
|
||||
OfflinePlayer player = context.getOrDefault(KEY_PLAYER, sender);
|
||||
RegionInfoUtil.showRegionInfo(this.messageBridge, this.fileManager, sender, player);
|
||||
if (!context.contains(KEY_PLAYER)) {
|
||||
RegionInfoUtil.showRegionInfo(this.messageBridge, this.fileManager, sender, sender);
|
||||
return;
|
||||
}
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_PLAYER))
|
||||
.whenCompleteAsync((offlinePlayer, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) {
|
||||
this.messageBridge.message(sender, "cmd-invalidPlayer", offlinePlayer.getName());
|
||||
return;
|
||||
}
|
||||
RegionInfoUtil.showRegionInfo(this.messageBridge, this.fileManager, sender, offlinePlayer);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,18 +3,18 @@ package me.wiefferink.areashop.commands;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreaShopCommandException;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.ArgumentParseExceptionHandler;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionCreationUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.PlayerCommandSource;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -34,12 +34,13 @@ public class QuickBuyCommand extends AreashopCommandBean {
|
||||
|
||||
private static final CloudKey<String> KEY_REGION = CloudKey.of("region", String.class);
|
||||
private static final CloudKey<Double> KEY_PRICE = CloudKey.of("price", Double.class);
|
||||
private static final CloudKey<OfflinePlayer> KEY_LANDLORD = CloudKey.of("landlord", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_LANDLORD = CloudKey.of("landlord", String.class);
|
||||
private final RegionFactory regionFactory;
|
||||
private final IFileManager fileManager;
|
||||
private final MessageBridge messageBridge;
|
||||
private final RegionCreationUtil regionCreationUtil;
|
||||
private final BukkitSchedulerExecutor executor;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
|
||||
@Inject
|
||||
public QuickBuyCommand(
|
||||
@@ -47,13 +48,15 @@ public class QuickBuyCommand extends AreashopCommandBean {
|
||||
@Nonnull RegionFactory regionFactory,
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull RegionCreationUtil regionCreationUtil,
|
||||
@Nonnull BukkitSchedulerExecutor executor
|
||||
@Nonnull BukkitSchedulerExecutor executor,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.regionFactory = regionFactory;
|
||||
this.fileManager = fileManager;
|
||||
this.regionCreationUtil = regionCreationUtil;
|
||||
this.executor = executor;
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,7 +72,7 @@ public class QuickBuyCommand extends AreashopCommandBean {
|
||||
.senderType(PlayerCommandSource.class)
|
||||
.required(KEY_REGION, StringParser.stringParser())
|
||||
.required(KEY_PRICE, DoubleParser.doubleParser(0))
|
||||
.required(KEY_LANDLORD, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
|
||||
.required(KEY_LANDLORD, OfflinePlayerParser.parser())
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
|
||||
@@ -96,20 +99,26 @@ public class QuickBuyCommand extends AreashopCommandBean {
|
||||
return;
|
||||
}
|
||||
double price = context.get(KEY_PRICE);
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_LANDLORD))
|
||||
.whenCompleteAsync((landlord, exception) -> {
|
||||
if (exception != null) {
|
||||
player.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!landlord.isOnline() && !landlord.hasPlayedBefore()) {
|
||||
this.messageBridge.message(player, "me-noPlayer", landlord.getName());
|
||||
return;
|
||||
}
|
||||
String regionName = region.getId();
|
||||
World world = player.getWorld();
|
||||
|
||||
OfflinePlayer landlord = context.get(KEY_LANDLORD);
|
||||
if (!landlord.isOnline() && !landlord.hasPlayedBefore()) {
|
||||
this.messageBridge.message(player, "me-noPlayer", landlord.getName());
|
||||
return;
|
||||
}
|
||||
String regionName = region.getId();
|
||||
World world = player.getWorld();
|
||||
|
||||
BuyRegion buyRegion = this.regionFactory.createBuyRegion(regionName, world);
|
||||
buyRegion.setPrice(price);
|
||||
buyRegion.setLandlord(landlord.getUniqueId(), landlord.getName());
|
||||
this.fileManager.addRegion(buyRegion);
|
||||
this.messageBridge.message(player, "add-success", "buy", regionName);
|
||||
BuyRegion buyRegion = this.regionFactory.createBuyRegion(regionName, world);
|
||||
buyRegion.setPrice(price);
|
||||
buyRegion.setLandlord(landlord.getUniqueId(), landlord.getName());
|
||||
this.fileManager.addRegion(buyRegion);
|
||||
this.messageBridge.message(player, "add-success", "buy", regionName);
|
||||
}, this.executor);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
@@ -126,4 +135,4 @@ public class QuickBuyCommand extends AreashopCommandBean {
|
||||
protected @Nonnull CommandProperties properties() {
|
||||
return CommandProperties.of("quickbuy");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,13 @@ package me.wiefferink.areashop.commands;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreaShopCommandException;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.ArgumentParseExceptionHandler;
|
||||
import me.wiefferink.areashop.commands.util.DurationInputParser;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionCreationUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.PlayerCommandSource;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
@@ -16,7 +17,6 @@ import me.wiefferink.areashop.regions.RegionFactory;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import me.wiefferink.areashop.tools.DurationInput;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -38,12 +38,13 @@ public class QuickRentCommand extends AreashopCommandBean {
|
||||
private static final CloudKey<Double> KEY_PRICE = CloudKey.of("price", Double.class);
|
||||
|
||||
private static final CloudKey<DurationInput> KEY_DURATION = CloudKey.of("duration", DurationInput.class);
|
||||
private static final CloudKey<OfflinePlayer> KEY_LANDLORD = CloudKey.of("landlord", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_LANDLORD = CloudKey.of("landlord", String.class);
|
||||
private final RegionFactory regionFactory;
|
||||
private final IFileManager fileManager;
|
||||
private final MessageBridge messageBridge;
|
||||
private final RegionCreationUtil regionCreationUtil;
|
||||
private final BukkitSchedulerExecutor executor;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
|
||||
@Inject
|
||||
public QuickRentCommand(
|
||||
@@ -51,13 +52,15 @@ public class QuickRentCommand extends AreashopCommandBean {
|
||||
@Nonnull RegionFactory regionFactory,
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull RegionCreationUtil regionCreationUtil,
|
||||
@Nonnull BukkitSchedulerExecutor executor
|
||||
@Nonnull BukkitSchedulerExecutor executor,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.regionFactory = regionFactory;
|
||||
this.fileManager = fileManager;
|
||||
this.regionCreationUtil = regionCreationUtil;
|
||||
this.executor = executor;
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -74,7 +77,7 @@ public class QuickRentCommand extends AreashopCommandBean {
|
||||
.required(KEY_REGION, StringParser.stringParser())
|
||||
.required(KEY_PRICE, DoubleParser.doubleParser(0))
|
||||
.required(KEY_DURATION, DurationInputParser.durationInputParser())
|
||||
.required(KEY_LANDLORD, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
|
||||
.required(KEY_LANDLORD, OfflinePlayerParser.parser())
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
|
||||
@@ -103,20 +106,27 @@ public class QuickRentCommand extends AreashopCommandBean {
|
||||
double price = context.get(KEY_PRICE);
|
||||
DurationInput duration = context.get(KEY_DURATION);
|
||||
|
||||
OfflinePlayer landlord = context.get(KEY_LANDLORD);
|
||||
if (!landlord.isOnline() && !landlord.hasPlayedBefore()) {
|
||||
this.messageBridge.message(player, "me-noPlayer");
|
||||
return;
|
||||
}
|
||||
String regionName = region.getId();
|
||||
World world = player.getWorld();
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_LANDLORD))
|
||||
.whenCompleteAsync((landlord, exception) -> {
|
||||
if (exception != null) {
|
||||
player.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!landlord.hasPlayedBefore() && !landlord.isOnline()) {
|
||||
this.messageBridge.message(player, "cmd-invalidPlayer", landlord.getName());
|
||||
return;
|
||||
}
|
||||
String regionName = region.getId();
|
||||
World world = player.getWorld();
|
||||
|
||||
RentRegion rentRegion = this.regionFactory.createRentRegion(regionName, world);
|
||||
rentRegion.setPrice(price);
|
||||
rentRegion.setLandlord(landlord.getUniqueId(), landlord.getName());
|
||||
rentRegion.setDuration(duration.toTinySpacedString());
|
||||
this.fileManager.addRegion(rentRegion);
|
||||
this.messageBridge.message(player, "add-success", "rent", regionName);
|
||||
RentRegion rentRegion = this.regionFactory.createRentRegion(regionName, world);
|
||||
rentRegion.setPrice(price);
|
||||
rentRegion.setLandlord(landlord.getUniqueId(), landlord.getName());
|
||||
rentRegion.setDuration(duration.toTinySpacedString());
|
||||
this.fileManager.addRegion(rentRegion);
|
||||
this.messageBridge.message(player, "add-success", "rent", regionName);
|
||||
}, this.executor);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
@@ -133,4 +143,4 @@ public class QuickRentCommand extends AreashopCommandBean {
|
||||
protected @Nonnull CommandProperties properties() {
|
||||
return CommandProperties.of("quickrent");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,15 @@ package me.wiefferink.areashop.commands;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreaShopCommandException;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionParseUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.incendo.cloud.Command;
|
||||
@@ -25,18 +26,24 @@ import javax.annotation.Nonnull;
|
||||
@Singleton
|
||||
public class SetLandlordCommand extends AreashopCommandBean {
|
||||
|
||||
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
|
||||
|
||||
private final MessageBridge messageBridge;
|
||||
private final CommandFlag<GeneralRegion> regionFlag;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
private final BukkitSchedulerExecutor executor;
|
||||
|
||||
@Inject
|
||||
public SetLandlordCommand(
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull IFileManager fileManager
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper,
|
||||
@Nonnull BukkitSchedulerExecutor executor
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.regionFlag = RegionParseUtil.createDefault(fileManager);
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +63,7 @@ public class SetLandlordCommand extends AreashopCommandBean {
|
||||
@Override
|
||||
protected Command.Builder<? extends CommandSource<?>> configureCommand(Command.@NotNull Builder<CommandSource<?>> builder) {
|
||||
return builder.literal("setlandlord")
|
||||
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
|
||||
.required(KEY_PLAYER, OfflinePlayerParser.parser())
|
||||
.flag(this.regionFlag)
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
@@ -72,11 +79,22 @@ public class SetLandlordCommand extends AreashopCommandBean {
|
||||
throw new AreaShopCommandException("setlandlord-noPermission");
|
||||
}
|
||||
GeneralRegion region = RegionParseUtil.getOrParseRegion(context, sender, this.regionFlag);
|
||||
OfflinePlayer player = context.get(KEY_PLAYER);
|
||||
String playerName = player.getName();
|
||||
region.setLandlord(player.getUniqueId(), playerName);
|
||||
region.update();
|
||||
this.messageBridge.message(sender, "setlandlord-success", playerName, region);
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_PLAYER))
|
||||
.whenCompleteAsync((landlord, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!landlord.hasPlayedBefore() && !landlord.isOnline()) {
|
||||
this.messageBridge.message(sender, "cmd-invalidPlayer", landlord.getName());
|
||||
return;
|
||||
}
|
||||
String playerName = landlord.getName();
|
||||
region.setLandlord(landlord.getUniqueId(), playerName);
|
||||
region.update();
|
||||
this.messageBridge.message(sender, "setlandlord-success", playerName, region);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.RegionParseUtil;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.incendo.cloud.Command;
|
||||
import org.incendo.cloud.bean.CommandProperties;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.key.CloudKey;
|
||||
import org.incendo.cloud.parser.flag.CommandFlag;
|
||||
import org.incendo.cloud.parser.standard.IntegerParser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@Singleton
|
||||
public class SetMaxExtends extends AreashopCommandBean {
|
||||
|
||||
private static final CloudKey<Integer> KEY_EXTENDS = CloudKey.of("extends", Integer.class);
|
||||
private final MessageBridge messageBridge;
|
||||
private final CommandFlag<RentRegion> regionFlag;
|
||||
|
||||
@Inject
|
||||
public SetMaxExtends(
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull IFileManager fileManager
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.regionFlag = RegionParseUtil.createDefaultRent(fileManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpKey(@NotNull CommandSender target) {
|
||||
if (target.hasPermission("areashop.setmaxextends")) {
|
||||
return "help-setmaxextends";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stringDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Command.Builder<? extends CommandSource<?>> configureCommand(Command.@NotNull Builder<CommandSource<?>> builder) {
|
||||
return builder.literal("setmaxextends")
|
||||
.required(KEY_EXTENDS, IntegerParser.integerParser(0))
|
||||
.flag(this.regionFlag)
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @NonNull CommandProperties properties() {
|
||||
return CommandProperties.of("setmaxextends");
|
||||
}
|
||||
|
||||
private void handleCommand(@Nonnull CommandContext<CommandSource<?>> context) {
|
||||
CommandSender sender = context.sender().sender();
|
||||
if (!sender.hasPermission("areashop.setmaxextends") && (!sender.hasPermission("areashop.setmaxextends.landlord") && sender instanceof Player)) {
|
||||
this.messageBridge.message(sender, "setmaxextends-noPermission");
|
||||
return;
|
||||
}
|
||||
RentRegion rent = RegionParseUtil.getOrParseRentRegion(context, sender, this.regionFlag);
|
||||
if (!sender.hasPermission("areashop.setmaxextends")
|
||||
&& !(sender instanceof Player player
|
||||
&& rent.isLandlord(player.getUniqueId()))
|
||||
) {
|
||||
this.messageBridge.message(sender, "setmaxextends-noLandlord", rent);
|
||||
return;
|
||||
}
|
||||
int extend = context.get(KEY_EXTENDS);
|
||||
|
||||
sender.sendMessage();
|
||||
rent.setMaxExtends(extend);
|
||||
rent.update();
|
||||
this.messageBridge.message(sender, "setmaxextends-success", rent);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,14 +3,16 @@ package me.wiefferink.areashop.commands;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionParseUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
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.BukkitSchedulerExecutor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -28,18 +30,24 @@ import java.util.UUID;
|
||||
@Singleton
|
||||
public class SetOwnerCommand extends AreashopCommandBean {
|
||||
|
||||
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
|
||||
private final CommandFlag<GeneralRegion> regionFlag;
|
||||
|
||||
private final MessageBridge messageBridge;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
private final BukkitSchedulerExecutor executor;
|
||||
|
||||
@Inject
|
||||
public SetOwnerCommand(
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull IFileManager fileManager
|
||||
) {
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper,
|
||||
@Nonnull BukkitSchedulerExecutor executor
|
||||
) {
|
||||
this.messageBridge = messageBridge;
|
||||
this.regionFlag = RegionParseUtil.createDefault(fileManager);
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
this.executor = executor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,7 +66,7 @@ public class SetOwnerCommand extends AreashopCommandBean {
|
||||
@Override
|
||||
protected Command.Builder<? extends CommandSource<?>> configureCommand(Command.@NotNull Builder<CommandSource<?>> builder) {
|
||||
return builder.literal("setowner")
|
||||
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
|
||||
.required(KEY_PLAYER, OfflinePlayerParser.parser())
|
||||
.flag(this.regionFlag)
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
@@ -83,11 +91,22 @@ public class SetOwnerCommand extends AreashopCommandBean {
|
||||
this.messageBridge.message(sender, "setowner-noPermissionBuy", region);
|
||||
return;
|
||||
}
|
||||
OfflinePlayer player = context.get(KEY_PLAYER);
|
||||
if (!player.hasPlayedBefore()) {
|
||||
this.messageBridge.message(sender, "setowner-noPlayer", player.getName(), region);
|
||||
return;
|
||||
}
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_PLAYER))
|
||||
.whenCompleteAsync((offlinePlayer, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!offlinePlayer.hasPlayedBefore() && !offlinePlayer.isOnline()) {
|
||||
this.messageBridge.message(sender, "cmd-invalidPlayer", offlinePlayer.getName());
|
||||
return;
|
||||
}
|
||||
setOwner(sender, offlinePlayer, region);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
private void setOwner(@Nonnull CommandSender sender, @Nonnull OfflinePlayer player, GeneralRegion region) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
if (region instanceof RentRegion rent) {
|
||||
if (rent.isRenter(uuid)) {
|
||||
|
||||
@@ -3,11 +3,12 @@ package me.wiefferink.areashop.commands;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.commands.util.AreaShopCommandException;
|
||||
import me.wiefferink.areashop.commands.util.AreashopCommandBean;
|
||||
import me.wiefferink.areashop.commands.util.GeneralRegionParser;
|
||||
import me.wiefferink.areashop.commands.util.OfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.RegionParseUtil;
|
||||
import me.wiefferink.areashop.commands.util.ValidatedOfflinePlayerParser;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.PlayerCommandSource;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
@@ -35,15 +36,17 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Singleton
|
||||
public class TransferCommand extends AreashopCommandBean {
|
||||
|
||||
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.class);
|
||||
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
|
||||
private final MessageBridge messageBridge;
|
||||
private final IFileManager fileManager;
|
||||
private final CommandFlag<GeneralRegion> regionFlag;
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
|
||||
@Inject
|
||||
public TransferCommand(
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull IFileManager fileManager
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull OfflinePlayerHelper offlinePlayerHelper
|
||||
) {
|
||||
ParserDescriptor<PlayerCommandSource, GeneralRegion> regionParser =
|
||||
ParserDescriptor.of(new GeneralRegionParser<>(fileManager, this::suggestRegions), GeneralRegion.class);
|
||||
@@ -52,6 +55,7 @@ public class TransferCommand extends AreashopCommandBean {
|
||||
this.regionFlag = CommandFlag.<PlayerCommandSource>builder("region")
|
||||
.withComponent(regionParser)
|
||||
.build();
|
||||
this.offlinePlayerHelper = offlinePlayerHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,7 +75,7 @@ public class TransferCommand extends AreashopCommandBean {
|
||||
protected Command.Builder<? extends CommandSource<?>> configureCommand(Command.@NotNull Builder<CommandSource<?>> builder) {
|
||||
return builder.literal("transfer")
|
||||
.senderType(PlayerCommandSource.class)
|
||||
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
|
||||
.required(KEY_PLAYER, OfflinePlayerParser.parser())
|
||||
.flag(this.regionFlag)
|
||||
.handler(this::handleCommand);
|
||||
}
|
||||
@@ -90,12 +94,32 @@ public class TransferCommand extends AreashopCommandBean {
|
||||
if (!region.isTransferEnabled()) {
|
||||
throw new AreaShopCommandException("transfer-disabled");
|
||||
}
|
||||
OfflinePlayer targetPlayer = context.get(KEY_PLAYER);
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(context.get(KEY_PLAYER))
|
||||
.whenComplete((offlinePlayer, exception) -> {
|
||||
if (exception != null) {
|
||||
sender.sendMessage("failed to lookup offline player!");
|
||||
exception.printStackTrace();
|
||||
return;
|
||||
}
|
||||
if (!offlinePlayer.hasPlayedBefore() &&!offlinePlayer.isOnline()) {
|
||||
this.messageBridge.message(sender, "cmd-invalidPlayer", offlinePlayer.getName());
|
||||
return;
|
||||
}
|
||||
performTransfer(sender, offlinePlayer, region);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void performTransfer(
|
||||
@Nonnull Player sender,
|
||||
@Nonnull OfflinePlayer targetPlayer,
|
||||
@Nonnull GeneralRegion region
|
||||
) {
|
||||
String targetPlayerName = targetPlayer.getName();
|
||||
if (Objects.equals(sender, targetPlayer)) {
|
||||
throw new AreaShopCommandException("transfer-transferSelf");
|
||||
}
|
||||
if (!targetPlayer.hasPlayedBefore()) {
|
||||
if (!targetPlayer.hasPlayedBefore() && !targetPlayer.isOnline()) {
|
||||
// Unknown player
|
||||
throw new AreaShopCommandException("transfer-noPlayer", targetPlayerName);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ import me.wiefferink.areashop.commands.TeleportCommand;
|
||||
import me.wiefferink.areashop.commands.ToggleHomeCommand;
|
||||
import me.wiefferink.areashop.commands.TransferCommand;
|
||||
import me.wiefferink.areashop.commands.UnrentCommand;
|
||||
import me.wiefferink.areashop.commands.SetMaxExtends;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSource;
|
||||
import me.wiefferink.areashop.commands.util.commandsource.CommandSourceMapper;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -109,7 +110,8 @@ public class AreashopCommands {
|
||||
TeleportCommand.class,
|
||||
ToggleHomeCommand.class,
|
||||
TransferCommand.class,
|
||||
UnrentCommand.class
|
||||
UnrentCommand.class,
|
||||
SetMaxExtends.class
|
||||
);
|
||||
|
||||
private final MessageBridge messageBridge;
|
||||
@@ -147,14 +149,14 @@ public class AreashopCommands {
|
||||
private void initCommandManager() {
|
||||
ExceptionController<CommandSource<?>> exceptionController = this.commandManager.exceptionController();
|
||||
// We need to unwrap ArgumentParseException because they wrap the custom exception messages
|
||||
exceptionController.registerHandler(ArgumentParseException.class,
|
||||
ExceptionHandler.unwrappingHandler(AreaShopCommandException.class));
|
||||
exceptionController.registerHandler(CommandExecutionException.class,
|
||||
ExceptionHandler.unwrappingHandler(AreaShopCommandException.class));
|
||||
exceptionController.registerHandler(InvalidCommandSenderException.class,
|
||||
new InvalidCommandSenderHandler(this.messageBridge));
|
||||
exceptionController.registerHandler(AreaShopCommandException.class,
|
||||
new ArgumentParseExceptionHandler<>(this.messageBridge));
|
||||
exceptionController.registerHandler(ArgumentParseException.class,
|
||||
ExceptionHandler.unwrappingHandler(AreaShopCommandException.class));
|
||||
exceptionController.registerHandler(CommandExecutionException.class,
|
||||
ExceptionHandler.unwrappingHandler(AreaShopCommandException.class));
|
||||
var confirmationConfiguration = ConfirmationConfiguration.<CommandSource<?>>builder()
|
||||
.cache(GuavaCache.of(CacheBuilder.newBuilder().build()))
|
||||
.noPendingCommandNotifier(x -> {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package me.wiefferink.areashop.commands.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.context.CommandInput;
|
||||
import org.incendo.cloud.parser.ArgumentParseResult;
|
||||
import org.incendo.cloud.parser.ArgumentParser;
|
||||
import org.incendo.cloud.parser.ParserDescriptor;
|
||||
import org.incendo.cloud.suggestion.BlockingSuggestionProvider;
|
||||
|
||||
public class OfflinePlayerParser<C> implements ArgumentParser<C, String>, BlockingSuggestionProvider.Strings<C> {
|
||||
|
||||
|
||||
public static <C> ParserDescriptor<C, String> parser() {
|
||||
return ParserDescriptor.of(new OfflinePlayerParser<>(), String.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ArgumentParseResult<@NonNull String> parse(@NonNull CommandContext<@NonNull C> commandContext,
|
||||
@NonNull CommandInput commandInput) {
|
||||
final String input = commandInput.readString();
|
||||
if (input.length() > 16) {
|
||||
return ArgumentParseResult.failure(new AreaShopCommandException("cmd-invalidPlayer", input));
|
||||
}
|
||||
return ArgumentParseResult.success(input);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<@NonNull String> stringSuggestions(@NonNull CommandContext<C> commandContext,
|
||||
@NonNull CommandInput input) {
|
||||
return Bukkit.getServer().getOnlinePlayers().stream()
|
||||
.map(Player::getName)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
-64
@@ -1,64 +0,0 @@
|
||||
package me.wiefferink.areashop.commands.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.incendo.cloud.bukkit.BukkitCommandContextKeys;
|
||||
import org.incendo.cloud.context.CommandContext;
|
||||
import org.incendo.cloud.context.CommandInput;
|
||||
import org.incendo.cloud.parser.ArgumentParseResult;
|
||||
import org.incendo.cloud.parser.ArgumentParser;
|
||||
import org.incendo.cloud.parser.ParserDescriptor;
|
||||
import org.incendo.cloud.suggestion.BlockingSuggestionProvider;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class ValidatedOfflinePlayerParser<C> implements ArgumentParser<C, OfflinePlayer>, BlockingSuggestionProvider.Strings<C> {
|
||||
|
||||
public static <C> ParserDescriptor<C, OfflinePlayer> validatedOfflinePlayerParser() {
|
||||
return ParserDescriptor.of(new ValidatedOfflinePlayerParser<>(), OfflinePlayer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public @NonNull ArgumentParseResult<OfflinePlayer> parse(
|
||||
final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull CommandInput commandInput
|
||||
) {
|
||||
final String input = commandInput.readString();
|
||||
if (input.length() > 16) {
|
||||
return ArgumentParseResult.failure(new AreaShopCommandException("cmd-invalidPlayer", input));
|
||||
}
|
||||
final Player onlinePlayer = Bukkit.getPlayerExact(input);
|
||||
if (onlinePlayer != null) {
|
||||
return ArgumentParseResult.success(onlinePlayer);
|
||||
}
|
||||
final OfflinePlayer player;
|
||||
try {
|
||||
player = Bukkit.getOfflinePlayer(input);
|
||||
} catch (final Exception e) {
|
||||
return ArgumentParseResult.failure(new AreaShopCommandException("cmd-invalidPlayer", input));
|
||||
}
|
||||
if (!player.hasPlayedBefore()) {
|
||||
return ArgumentParseResult.failure(new AreaShopCommandException("cmd-invalidPlayer", input));
|
||||
}
|
||||
return ArgumentParseResult.success(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<@NonNull String> stringSuggestions(
|
||||
final @NonNull CommandContext<C> commandContext,
|
||||
final @NonNull CommandInput input
|
||||
) {
|
||||
if (!commandContext.contains(BukkitCommandContextKeys.BUKKIT_COMMAND_SENDER)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final CommandSender sender = commandContext.get(BukkitCommandContextKeys.BUKKIT_COMMAND_SENDER);
|
||||
return Bukkit.getOnlinePlayers().stream()
|
||||
.filter(onlinePlayer -> !(sender instanceof Player player && !((Player) sender).canSee(player)))
|
||||
.map(Player::getName)
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
+11
-1
@@ -2,10 +2,12 @@ package me.wiefferink.areashop.listeners;
|
||||
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.CacheManager;
|
||||
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 me.wiefferink.areashop.tools.CacheWrapper;
|
||||
import me.wiefferink.bukkitdo.Do;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -27,14 +29,20 @@ public final class PlayerLoginLogoutListener implements Listener {
|
||||
|
||||
private final AreaShop plugin;
|
||||
private final MessageBridge messageBridge;
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param plugin The AreaShop plugin
|
||||
*/
|
||||
public PlayerLoginLogoutListener(@Nonnull AreaShop plugin, @Nonnull MessageBridge messageBridge) {
|
||||
public PlayerLoginLogoutListener(
|
||||
@Nonnull AreaShop plugin,
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull CacheManager cacheManager
|
||||
) {
|
||||
this.plugin = plugin;
|
||||
this.messageBridge = messageBridge;
|
||||
this.cacheManager = cacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,6 +56,8 @@ public final class PlayerLoginLogoutListener implements Listener {
|
||||
}
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
this.cacheManager.computeIfAbsent(player.getUniqueId(), uuid -> new CacheWrapper(uuid, player.getName()));
|
||||
|
||||
// Schedule task to check for notifications, prevents a lag spike at login
|
||||
Do.syncTimerLater(25, 25, () -> {
|
||||
// Delay until all regions are loaded
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
package me.wiefferink.areashop.managers;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import me.wiefferink.areashop.tools.CacheWrapper;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CacheManager extends Manager {
|
||||
|
||||
private final Plugin plugin;
|
||||
private final Map<UUID, CacheWrapper> cache;
|
||||
|
||||
private File cacheFile;
|
||||
private Duration expiryDuration;
|
||||
|
||||
@Inject
|
||||
CacheManager(@Nonnull Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.cache = new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (this.expiryDuration != null) {
|
||||
trimCache(expiryDuration);
|
||||
}
|
||||
if (this.cacheFile != null) {
|
||||
saveCache(cacheFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void initialize(@Nonnull File cacheFile, @Nonnull Duration expiryDuration) {
|
||||
this.cacheFile = cacheFile;
|
||||
this.expiryDuration = expiryDuration;
|
||||
}
|
||||
|
||||
public void loadCache() {
|
||||
if (this.cacheFile != null) {
|
||||
loadCache(this.cacheFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the cache from the file
|
||||
*/
|
||||
public void loadCache(@Nonnull File cacheFile) {
|
||||
if (Files.notExists(cacheFile.toPath())) {
|
||||
this.plugin.getLogger().info("uuid cache file does not exist, loaded 0 entries");
|
||||
return;
|
||||
}
|
||||
this.cache.clear();
|
||||
|
||||
try (FileInputStream input = new FileInputStream(cacheFile)) {
|
||||
byte[] bytes = input.readAllBytes();
|
||||
ByteBuffer buffer = ByteBuffer.wrap(bytes).asReadOnlyBuffer();
|
||||
while (buffer.hasRemaining()) {
|
||||
long lastUsed = buffer.getLong();
|
||||
long lsb = buffer.getLong();
|
||||
long msb = buffer.getLong();
|
||||
int stringLen = buffer.getInt();
|
||||
byte[] stringBytes = new byte[stringLen];
|
||||
buffer.get(stringBytes);
|
||||
String name = new String(stringBytes, StandardCharsets.UTF_8);
|
||||
UUID uuid = new UUID(msb, lsb);
|
||||
CacheWrapper wrapper = new CacheWrapper(uuid, name, lastUsed);
|
||||
this.cache.put(wrapper.getUuid(), wrapper);
|
||||
}
|
||||
this.plugin.getLogger()
|
||||
.info(String.format("Loaded %d cached uuid name entries", this.cache.size()));
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
this.plugin.getLogger().warning("Failed to load the uuid cache!");
|
||||
}
|
||||
}
|
||||
|
||||
public void saveCache() {
|
||||
if (this.cacheFile != null) {
|
||||
saveCache(this.cacheFile);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveCacheAsync() {
|
||||
if (this.cacheFile != null) {
|
||||
saveCacheAsync(this.cacheFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save the cache to the file
|
||||
*/
|
||||
public void saveCache(@Nonnull File cacheFile) {
|
||||
List<CacheWrapper> copy = this.cache.values().stream().map(CacheWrapper::new).toList();
|
||||
try {
|
||||
// Ensure parent directory exists
|
||||
Path parentDir = cacheFile.toPath().getParent();
|
||||
if (parentDir != null) { // parent might be null if cacheFile is relative with no parent
|
||||
Files.createDirectories(parentDir);
|
||||
}
|
||||
byte[] bytes = serialize(copy);
|
||||
try (FileOutputStream fos = new FileOutputStream(cacheFile)) {
|
||||
fos.write(bytes);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Failed to save cache.json", e);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveCacheAsync(@Nonnull File cacheFile) {
|
||||
List<CacheWrapper> copy = this.cache.values().stream().map(CacheWrapper::new).toList();
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
// Ensure parent directory exists
|
||||
Path parentDir = cacheFile.toPath().getParent();
|
||||
if (parentDir != null) { // parent might be null if cacheFile is relative with no parent
|
||||
Files.createDirectories(parentDir);
|
||||
}
|
||||
byte[] bytes = serialize(copy);
|
||||
try (FileOutputStream fos = new FileOutputStream(cacheFile)) {
|
||||
fos.write(bytes);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().log(Level.SEVERE, "Failed to save cache.json", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private byte[] serialize(List<CacheWrapper> wrappers) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(256 * wrappers.size());
|
||||
for (CacheWrapper wrapper : wrappers) {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(256);
|
||||
byte[] stringBytes = wrapper.getName().getBytes(StandardCharsets.UTF_8);
|
||||
int stringLen = stringBytes.length;
|
||||
long lsb = wrapper.getUuid().getLeastSignificantBits();
|
||||
long msb = wrapper.getUuid().getMostSignificantBits();
|
||||
long lastUsed = wrapper.getLastUsed();
|
||||
buffer.putLong(lastUsed);
|
||||
buffer.putLong(lsb);
|
||||
buffer.putLong(msb);
|
||||
buffer.putInt(stringLen);
|
||||
buffer.put(stringBytes);
|
||||
|
||||
buffer.flip();
|
||||
|
||||
bos.write(buffer.array(), buffer.position(), buffer.remaining());
|
||||
}
|
||||
return bos.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a cache entry
|
||||
*/
|
||||
public CacheWrapper get(UUID uuid) {
|
||||
return cache.get(uuid);
|
||||
}
|
||||
|
||||
public CacheWrapper computeIfAbsent(@Nonnull UUID uuid, Function<UUID, CacheWrapper> function) {
|
||||
return this.cache.computeIfAbsent(uuid, function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a cache entry
|
||||
*/
|
||||
public void put(UUID uuid, CacheWrapper wrapper) {
|
||||
cache.put(uuid, wrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a cache entry
|
||||
*/
|
||||
public CacheWrapper remove(UUID uuid) {
|
||||
return cache.remove(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if cache contains a UUID
|
||||
*/
|
||||
public boolean contains(UUID uuid) {
|
||||
return cache.containsKey(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all cache entries
|
||||
*/
|
||||
public Map<UUID, CacheWrapper> getAllEntries() {
|
||||
return new HashMap<>(cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all cache entries
|
||||
*/
|
||||
public void clear() {
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the cache
|
||||
*/
|
||||
public int size() {
|
||||
return cache.size();
|
||||
}
|
||||
|
||||
public void trimCache() {
|
||||
if (this.expiryDuration != null) {
|
||||
trimCache(this.expiryDuration);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim the cache by removing entries older than 1 week
|
||||
*/
|
||||
public void trimCache(@Nonnull Duration expiryDuration) {
|
||||
long expiryMillis = expiryDuration.toMillis();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
|
||||
Iterator<Map.Entry<UUID, CacheWrapper>> iterator = cache.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<UUID, CacheWrapper> entry = iterator.next();
|
||||
CacheWrapper wrapper = entry.getValue();
|
||||
|
||||
if (wrapper.getLastUsed() != -1 && (currentTime - wrapper.getLastUsed()) >= expiryMillis) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -651,7 +651,7 @@ public class FileManager extends Manager implements IFileManager {
|
||||
getRegionsRef(),
|
||||
region -> {
|
||||
if(region.isSaveRequired()) {
|
||||
region.saveNow();
|
||||
region.saveNowAsync();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.UUID;
|
||||
public class BuyRegion extends GeneralRegion {
|
||||
|
||||
private final Economy economy;
|
||||
|
||||
|
||||
@AssistedInject
|
||||
BuyRegion(
|
||||
@Nonnull AreaShop plugin,
|
||||
@@ -424,7 +424,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
|
||||
// Resell is done, disable that now
|
||||
disableReselling();
|
||||
|
||||
|
||||
// Send message to the player
|
||||
message(offlinePlayer, "buy-successResale", oldOwnerName);
|
||||
Player seller = Bukkit.getPlayer(oldOwner);
|
||||
@@ -542,7 +542,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
|
||||
// Give back the money
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(getBuyer());
|
||||
if(player.hasPlayedBefore() && !noPayBack) {
|
||||
if((player.hasPlayedBefore() || player.isOnline()) && !noPayBack) {
|
||||
EconomyResponse response = null;
|
||||
boolean error = false;
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.wiefferink.areashop.regions;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
@@ -29,11 +30,15 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Writer;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -472,7 +477,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
if(landlordName != null && !landlordName.isEmpty()) {
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(landlordName);
|
||||
if(offlinePlayer.hasPlayedBefore()) {
|
||||
if(offlinePlayer.hasPlayedBefore() || offlinePlayer.isOnline()) {
|
||||
return offlinePlayer.getUniqueId();
|
||||
}
|
||||
}
|
||||
@@ -958,6 +963,27 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public CompletableFuture<Boolean> saveNowAsync() {
|
||||
if(isDeleted()) {
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
String data = config.saveToString();
|
||||
saveRequired = false;
|
||||
File file = new File(plugin.getFileManager().getRegionFolder() + File.separator + getName().toLowerCase() + ".yml");
|
||||
BukkitScheduler scheduler = this.plugin.getServer().getScheduler();
|
||||
CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||
scheduler.runTaskAsynchronously(this.plugin, () -> {
|
||||
try(Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8);){
|
||||
writer.write(data);
|
||||
future.complete(true);
|
||||
} catch (IOException ex) {
|
||||
future.complete(false);
|
||||
}
|
||||
});
|
||||
return future;
|
||||
}
|
||||
|
||||
|
||||
// CONFIG
|
||||
|
||||
|
||||
@@ -279,7 +279,7 @@ public class ImportJob {
|
||||
if(owner != null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(owner);
|
||||
if(offlinePlayer.hasPlayedBefore()) {
|
||||
if(offlinePlayer.hasPlayedBefore() || offlinePlayer.isOnline()) {
|
||||
existing.add(offlinePlayer.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +190,9 @@ public class RentRegion extends GeneralRegion {
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaxExtends(int times) {
|
||||
setSetting("rent.maxExtends", times); }
|
||||
|
||||
@Override
|
||||
public Object provideReplacement(String variable) {
|
||||
return switch (variable) {
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CacheWrapper {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CacheWrapper.class);
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
private long lastUsed;
|
||||
|
||||
public CacheWrapper(CacheWrapper other) {
|
||||
this.uuid = other.uuid;
|
||||
this.name = other.name;
|
||||
this.lastUsed = other.lastUsed;
|
||||
}
|
||||
|
||||
public CacheWrapper(@Nonnull UUID uuid, @Nonnull String name) {
|
||||
this(uuid, name, -1);
|
||||
}
|
||||
|
||||
public CacheWrapper(@Nonnull UUID uuid, @Nonnull String name, long lastUsed) {
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.lastUsed = lastUsed;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
this.lastUsed = System.currentTimeMillis();
|
||||
return name;
|
||||
}
|
||||
|
||||
public long getLastUsed() {
|
||||
return lastUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
CacheWrapper that = (CacheWrapper) o;
|
||||
return lastUsed == that.lastUsed && Objects.equals(uuid,
|
||||
that.uuid) && Objects.equals(name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(uuid, name, lastUsed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CacheWrapper{" +
|
||||
"uuid=" + uuid +
|
||||
", name='" + name + '\'' +
|
||||
", lastUsed=" + lastUsed +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ public class SpigotOfflinePlayerHelper implements OfflinePlayerHelper {
|
||||
@Override
|
||||
public CompletableFuture<Optional<UUID>> lookupUuidAsync(String username) {
|
||||
return lookupOfflinePlayerAsync(username).thenApply(player -> {
|
||||
if (player.hasPlayedBefore()) {
|
||||
if (player.hasPlayedBefore() || player.isOnline()) {
|
||||
return Optional.of(player.getUniqueId());
|
||||
}
|
||||
return Optional.empty();
|
||||
@@ -31,6 +31,11 @@ public class SpigotOfflinePlayerHelper implements OfflinePlayerHelper {
|
||||
@Override
|
||||
public CompletableFuture<OfflinePlayer> lookupOfflinePlayerAsync(String username) {
|
||||
final CompletableFuture<OfflinePlayer> future = new CompletableFuture<>();
|
||||
OfflinePlayer onlinePlayer = this.plugin.getServer().getPlayerExact(username);
|
||||
if (onlinePlayer != null) {
|
||||
future.complete(onlinePlayer);
|
||||
return future;
|
||||
}
|
||||
final Server server = this.plugin.getServer();
|
||||
server.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -6,6 +6,7 @@ import jakarta.inject.Inject;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.interfaces.WorldEditSelection;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.managers.CacheManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
@@ -805,10 +806,20 @@ public class Utils {
|
||||
if (uuid == null) {
|
||||
return "";
|
||||
}
|
||||
String name = Bukkit.getOfflinePlayer(uuid).getName();
|
||||
|
||||
final CacheManager cacheManager = plugin.getCacheManager();
|
||||
|
||||
if (cacheManager.contains(uuid))
|
||||
return cacheManager.get(uuid).getName();
|
||||
|
||||
|
||||
final String name = Bukkit.getOfflinePlayer(uuid).getName();
|
||||
|
||||
if (name != null) {
|
||||
cacheManager.put(uuid, new CacheWrapper(uuid, name, System.currentTimeMillis()));
|
||||
return name;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ forceClearEntities: false
|
||||
# Maximum number of locations the teleport function should check to find a safe spot.
|
||||
maximumTries: 50000
|
||||
|
||||
cacheExpiryDuration: '7d'
|
||||
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ VARIABLES: Variables that can be used in messages and settings where a region is available. │
|
||||
|
||||
@@ -374,6 +374,11 @@ setduration-noLandlord: You don't have permission to change the duration because
|
||||
setduration-successRemoved: 'Duration of %lang:region% has been removed, it will now
|
||||
use the duration from a group or the default.yml file, new duration: %duration%.'
|
||||
|
||||
setmaxextends-noPermission: You don't have permission to change the amount of times a region can have rent extended.
|
||||
setmaxextends-help: /as setmaxextends \<amount> [region], the region you stand in will be used if not specified.
|
||||
setmaxextends-noLandlord: You don't have permission to change the duration because you are not the landlord of %lang:region%.
|
||||
setmaxextends-success: Max extensions of %lang:region% changed to %maxextends%
|
||||
|
||||
setup-noRegion: You did not specify a region on the second line.
|
||||
setup-alreadyRentSign: The region you specified is already added to AreaShop as a
|
||||
rent region, add signs with [as] on the first line or '/as addsign'.
|
||||
|
||||
@@ -81,6 +81,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-setmaxextends: "%lang:helpCommand|/as setmaxextends|% Change the amount of times a renter can extend their rent by."
|
||||
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."
|
||||
@@ -350,6 +351,11 @@ setduration-success: "Duration of region %lang:region% changed to '%duration%'."
|
||||
setduration-noLandlord: "You don't have permission to change the duration because you are not the landlord of %lang:region%."
|
||||
setduration-successRemoved: "Duration of %lang:region% has been removed, it will now use the duration from a group or the default.yml file, new duration: %duration%."
|
||||
|
||||
setmaxextends-noPermission: "You don't have permission to change the amount of times a region can have rent extended."
|
||||
setmaxextends-help: "/as setmaxextends <amount> [region], the region you stand in will be used if not specified."
|
||||
setmaxextends-noLandlord: "You don't have permission to change the duration because you are not the landlord of %lang:region%."
|
||||
setmaxextends-success: "Max extensions of %lang:region% changed to %maxextends%"
|
||||
|
||||
setup-noRegion: "You did not specify a region on the second line."
|
||||
setup-alreadyRentSign: "The region you specified is already added to AreaShop as a rent region, add signs with [as] on the first line or '/as addsign'."
|
||||
setup-alreadyOtherWorld: "The region you specified is already added to AreaShop in another world, regions from different worlds still need different names."
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
<h1>
|
||||
The project is no longer maintained. See this alternative <a href="https://github.com/MCCitiesNetwork/realty">realty</a>
|
||||
</h1>
|
||||
<br>
|
||||
|
||||
<br/>
|
||||
[](https://jitpack.io/#md5sha256/AreaShop)
|
||||
<br>
|
||||
@@ -74,4 +79,4 @@ For a preview join 'mc.go-craft.com' and go to the Survival server, the shops ar
|
||||
**Made by [PerkulatorTime](https://www.youtube.com/user/PerkulatorTime)**<br/>
|
||||
[](https://www.youtube.com/watch?v=OQOsOG-EdNc)
|
||||
|
||||
Old video for AreaShop v1.0: [Tutorial by VariationVault](https://www.youtube.com/watch?v=k2HMCxCCOYo)
|
||||
Old video for AreaShop v1.0: [Tutorial by VariationVault](https://www.youtube.com/watch?v=k2HMCxCCOYo)
|
||||
+9
@@ -29,6 +29,15 @@ public class PaperOfflinePlayerHelper implements OfflinePlayerHelper {
|
||||
@Override
|
||||
public CompletableFuture<OfflinePlayer> lookupOfflinePlayerAsync(String username) {
|
||||
final CompletableFuture<OfflinePlayer> future = new CompletableFuture<>();
|
||||
OfflinePlayer onlinePlayer = this.server.getPlayerExact(username);
|
||||
if (onlinePlayer != null) {
|
||||
future.complete(onlinePlayer);
|
||||
return future;
|
||||
}
|
||||
OfflinePlayer cachedPlayer = this.server.getOfflinePlayerIfCached(username);
|
||||
if (cachedPlayer != null) {
|
||||
return CompletableFuture.completedFuture(cachedPlayer);
|
||||
}
|
||||
this.server.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(username);
|
||||
future.complete(offlinePlayer);
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class RegionAccessSet {
|
||||
for(String playerName : playerNames) {
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
|
||||
if(offlinePlayer.hasPlayedBefore()) {
|
||||
if(offlinePlayer.hasPlayedBefore() || offlinePlayer.isOnline()) {
|
||||
result.add(offlinePlayer.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "me.wiefferink"
|
||||
version = "2.9.1-SNAPSHOT"
|
||||
version = "2.9.2-SNAPSHOT"
|
||||
|
||||
val targetJavaVersion = 21
|
||||
val encoding = Charsets.UTF_8
|
||||
@@ -32,7 +32,7 @@ subprojects {
|
||||
plugin<MavenPublishPlugin>()
|
||||
// plugin<SpotBugsPlugin>()
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://oss.sonatype.org/content/groups/public/")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[versions]
|
||||
# Platforms
|
||||
minecraft = "1.21-R0.1-SNAPSHOT"
|
||||
minecraft = "1.21.1-R0.1-SNAPSHOT"
|
||||
|
||||
# Minecraft Plugins
|
||||
worldedit = "7.3.3"
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -84,7 +86,8 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# 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
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
Vendored
+2
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
|
||||
Reference in new issue
Block a user