Compare commits

..
Author SHA1 Message Date
Andrew Wong a6190504b8 Update cloud to beta.9 2024-07-24 14:43:05 +10:00
Andrew Wong 5dd42e42ad Enforce min version to 1.21 2024-07-24 14:14:27 +10:00
Andrew Wong 7b22f2e40b Compile against 1.21, bump version to 2.9.1-SNAPSHOT 2024-07-24 14:14:22 +10:00
38 changed files with 192 additions and 840 deletions

No files matched your search

+8 -8
View File
@@ -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.10") {
implementation("org.incendo:cloud-paper:2.0.0-beta.9") {
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.21.1-R0.1-SNAPSHOT")
testImplementation("com.github.seeseemelk:MockBukkit-v1.21:3.131.0")
testImplementation("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.86.1")
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.1")
minecraftVersion("1.21")
downloadPlugins {
github("EssentialsX", "essentials", "2.20.1", "EssentialsX-2.20.1.jar")
github("MilkBowl", "Vault", "1.7.3", "Vault.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")
// 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")
}
}
}
@@ -16,10 +16,9 @@ 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.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.Manager;
import me.wiefferink.areashop.managers.SignErrorLogger;
import me.wiefferink.areashop.managers.SignLinkerManager;
@@ -57,7 +56,6 @@ 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;
@@ -83,7 +81,6 @@ 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;
@@ -288,17 +285,11 @@ 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.cacheManager), this);
getServer().getPluginManager().registerEvents(new PlayerLoginLogoutListener(this, messageBridge), this);
setupTasks();
@@ -393,10 +384,6 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
return version;
}
public CacheManager getCacheManager() {
return cacheManager;
}
/**
* Called on shutdown or reload of the server.
*/
@@ -3,17 +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.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;
@@ -30,26 +28,20 @@ import javax.annotation.Nonnull;
@Singleton
public class AddFriendCommand extends AreashopCommandBean {
private static final CloudKey<String> KEY_FRIEND = CloudKey.of("friend", String.class);
private static final CloudKey<OfflinePlayer> KEY_FRIEND = CloudKey.of("friend", OfflinePlayer.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 BukkitSchedulerExecutor executor,
@Nonnull OfflinePlayerHelper offlinePlayerHelper
@Nonnull Plugin plugin
) {
this.messageBridge = messageBridge;
this.plugin = plugin;
this.regionFlag = RegionParseUtil.createDefault(fileManager);
this.executor = executor;
this.offlinePlayerHelper = offlinePlayerHelper;
}
@Override
@@ -69,7 +61,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, OfflinePlayerParser.parser())
.required(KEY_FRIEND, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
.flag(this.regionFlag)
.handler(this::handleCommand);
}
@@ -81,49 +73,31 @@ public class AddFriendCommand extends AreashopCommandBean {
return;
}
GeneralRegion region = RegionParseUtil.getOrParseRegion(context, sender, this.regionFlag);
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
) {
OfflinePlayer friend = context.get(KEY_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,18 +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.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;
@@ -36,23 +34,17 @@ import java.util.concurrent.CompletableFuture;
public class DelFriendCommand extends AreashopCommandBean {
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.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 OfflinePlayerHelper offlinePlayerHelper,
@Nonnull BukkitSchedulerExecutor executor
@Nonnull IFileManager fileManager
) {
this.messageBridge = messageBridge;
this.regionFlag = RegionParseUtil.createDefault(fileManager);
this.offlinePlayerHelper = offlinePlayerHelper;
this.executor = executor;
}
/**
@@ -93,7 +85,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, OfflinePlayerParser.parser(), this::suggestFriends)
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser(), this::suggestFriends)
.flag(this.regionFlag)
.handler(this::handleCommand);
}
@@ -104,24 +96,7 @@ public class DelFriendCommand extends AreashopCommandBean {
throw new AreaShopCommandException("delfriend-noPermission");
}
GeneralRegion region = RegionParseUtil.getOrParseRegion(context, sender, this.regionFlag);
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) {
OfflinePlayer friend = context.get(KEY_PLAYER);
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().sender(), "groupinfo-members", group.getName(), seperatedMembers);
this.messageBridge.message(context.sender(), "groupinfo-members", group.getName(), seperatedMembers);
}
}
@@ -3,13 +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.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 me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.incendo.cloud.Command;
import org.incendo.cloud.bean.CommandProperties;
@@ -21,24 +20,18 @@ import javax.annotation.Nonnull;
@Singleton
public class InfoPlayerCommand extends AreashopCommandBean {
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.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 OfflinePlayerHelper offlinePlayerHelper,
@Nonnull BukkitSchedulerExecutor executor
@Nonnull IFileManager fileManager
) {
this.messageBridge = messageBridge;
this.fileManager = fileManager;
this.offlinePlayerHelper = offlinePlayerHelper;
this.executor = executor;
}
@Override
@@ -54,7 +47,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, OfflinePlayerParser.parser())
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
.handler(this::handleCommand);
}
@@ -69,19 +62,8 @@ public class InfoPlayerCommand extends AreashopCommandBean {
messageBridge.message(sender, "info-noPermission");
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);
OfflinePlayer offlinePlayer = context.get(KEY_PLAYER);
RegionInfoUtil.showRegionInfo(this.messageBridge, this.fileManager, sender, offlinePlayer);
}
}
@@ -3,15 +3,14 @@ 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 me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -26,23 +25,17 @@ import javax.annotation.Nonnull;
@Singleton
public class MeCommand extends AreashopCommandBean {
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.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 OfflinePlayerHelper offlinePlayerHelper,
@Nonnull BukkitSchedulerExecutor executor
@Nonnull IFileManager fileManager
) {
this.messageBridge = messageBridge;
this.fileManager = fileManager;
this.offlinePlayerHelper = offlinePlayerHelper;
this.executor = executor;
}
@Override
@@ -54,7 +47,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, OfflinePlayerParser.parser())
.optional(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
.handler(this::handleCommand);
}
@@ -76,23 +69,8 @@ public class MeCommand extends AreashopCommandBean {
if (!sender.hasPermission("areashop.me")) {
throw new AreaShopCommandException("me-noPermission");
}
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);
OfflinePlayer player = context.getOrDefault(KEY_PLAYER, sender);
RegionInfoUtil.showRegionInfo(this.messageBridge, this.fileManager, sender, player);
}
}
@@ -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,13 +34,12 @@ 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<String> KEY_LANDLORD = CloudKey.of("landlord", String.class);
private static final CloudKey<OfflinePlayer> KEY_LANDLORD = CloudKey.of("landlord", OfflinePlayer.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(
@@ -48,15 +47,13 @@ public class QuickBuyCommand extends AreashopCommandBean {
@Nonnull RegionFactory regionFactory,
@Nonnull IFileManager fileManager,
@Nonnull RegionCreationUtil regionCreationUtil,
@Nonnull BukkitSchedulerExecutor executor,
@Nonnull OfflinePlayerHelper offlinePlayerHelper
@Nonnull BukkitSchedulerExecutor executor
) {
this.messageBridge = messageBridge;
this.regionFactory = regionFactory;
this.fileManager = fileManager;
this.regionCreationUtil = regionCreationUtil;
this.executor = executor;
this.offlinePlayerHelper = offlinePlayerHelper;
}
@Override
@@ -72,7 +69,7 @@ public class QuickBuyCommand extends AreashopCommandBean {
.senderType(PlayerCommandSource.class)
.required(KEY_REGION, StringParser.stringParser())
.required(KEY_PRICE, DoubleParser.doubleParser(0))
.required(KEY_LANDLORD, OfflinePlayerParser.parser())
.required(KEY_LANDLORD, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
.handler(this::handleCommand);
}
@@ -99,26 +96,20 @@ 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();
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);
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);
}, this.executor);
}
@@ -135,4 +126,4 @@ public class QuickBuyCommand extends AreashopCommandBean {
protected @Nonnull CommandProperties properties() {
return CommandProperties.of("quickbuy");
}
}
}
@@ -3,13 +3,12 @@ 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;
@@ -17,6 +16,7 @@ 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,13 +38,12 @@ 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<String> KEY_LANDLORD = CloudKey.of("landlord", String.class);
private static final CloudKey<OfflinePlayer> KEY_LANDLORD = CloudKey.of("landlord", OfflinePlayer.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(
@@ -52,15 +51,13 @@ public class QuickRentCommand extends AreashopCommandBean {
@Nonnull RegionFactory regionFactory,
@Nonnull IFileManager fileManager,
@Nonnull RegionCreationUtil regionCreationUtil,
@Nonnull BukkitSchedulerExecutor executor,
@Nonnull OfflinePlayerHelper offlinePlayerHelper
@Nonnull BukkitSchedulerExecutor executor
) {
this.messageBridge = messageBridge;
this.regionFactory = regionFactory;
this.fileManager = fileManager;
this.regionCreationUtil = regionCreationUtil;
this.executor = executor;
this.offlinePlayerHelper = offlinePlayerHelper;
}
@Override
@@ -77,7 +74,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, OfflinePlayerParser.parser())
.required(KEY_LANDLORD, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
.handler(this::handleCommand);
}
@@ -106,27 +103,20 @@ public class QuickRentCommand extends AreashopCommandBean {
double price = context.get(KEY_PRICE);
DurationInput duration = context.get(KEY_DURATION);
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();
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();
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);
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);
}
@@ -143,4 +133,4 @@ public class QuickRentCommand extends AreashopCommandBean {
protected @Nonnull CommandProperties properties() {
return CommandProperties.of("quickrent");
}
}
}
@@ -3,15 +3,14 @@ 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 me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.incendo.cloud.Command;
@@ -26,24 +25,18 @@ import javax.annotation.Nonnull;
@Singleton
public class SetLandlordCommand extends AreashopCommandBean {
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.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 OfflinePlayerHelper offlinePlayerHelper,
@Nonnull BukkitSchedulerExecutor executor
@Nonnull IFileManager fileManager
) {
this.messageBridge = messageBridge;
this.regionFlag = RegionParseUtil.createDefault(fileManager);
this.offlinePlayerHelper = offlinePlayerHelper;
this.executor = executor;
}
@@ -63,7 +56,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, OfflinePlayerParser.parser())
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
.flag(this.regionFlag)
.handler(this::handleCommand);
}
@@ -79,22 +72,11 @@ public class SetLandlordCommand extends AreashopCommandBean {
throw new AreaShopCommandException("setlandlord-noPermission");
}
GeneralRegion region = RegionParseUtil.getOrParseRegion(context, sender, this.regionFlag);
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);
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);
}
}
@@ -1,88 +0,0 @@
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,16 +3,14 @@ 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;
@@ -30,24 +28,18 @@ import java.util.UUID;
@Singleton
public class SetOwnerCommand extends AreashopCommandBean {
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.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 OfflinePlayerHelper offlinePlayerHelper,
@Nonnull BukkitSchedulerExecutor executor
) {
@Nonnull IFileManager fileManager
) {
this.messageBridge = messageBridge;
this.regionFlag = RegionParseUtil.createDefault(fileManager);
this.offlinePlayerHelper = offlinePlayerHelper;
this.executor = executor;
}
@Override
@@ -66,7 +58,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, OfflinePlayerParser.parser())
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
.flag(this.regionFlag)
.handler(this::handleCommand);
}
@@ -91,22 +83,11 @@ public class SetOwnerCommand extends AreashopCommandBean {
this.messageBridge.message(sender, "setowner-noPermissionBuy", 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) {
OfflinePlayer player = context.get(KEY_PLAYER);
if (!player.hasPlayedBefore()) {
this.messageBridge.message(sender, "setowner-noPlayer", player.getName(), region);
return;
}
final UUID uuid = player.getUniqueId();
if (region instanceof RentRegion rent) {
if (rent.isRenter(uuid)) {
@@ -3,12 +3,11 @@ 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;
@@ -36,17 +35,15 @@ import java.util.concurrent.CompletableFuture;
@Singleton
public class TransferCommand extends AreashopCommandBean {
private static final CloudKey<String> KEY_PLAYER = CloudKey.of("player", String.class);
private static final CloudKey<OfflinePlayer> KEY_PLAYER = CloudKey.of("player", OfflinePlayer.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 OfflinePlayerHelper offlinePlayerHelper
@Nonnull IFileManager fileManager
) {
ParserDescriptor<PlayerCommandSource, GeneralRegion> regionParser =
ParserDescriptor.of(new GeneralRegionParser<>(fileManager, this::suggestRegions), GeneralRegion.class);
@@ -55,7 +52,6 @@ public class TransferCommand extends AreashopCommandBean {
this.regionFlag = CommandFlag.<PlayerCommandSource>builder("region")
.withComponent(regionParser)
.build();
this.offlinePlayerHelper = offlinePlayerHelper;
}
@Override
@@ -75,7 +71,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, OfflinePlayerParser.parser())
.required(KEY_PLAYER, ValidatedOfflinePlayerParser.validatedOfflinePlayerParser())
.flag(this.regionFlag)
.handler(this::handleCommand);
}
@@ -94,32 +90,12 @@ public class TransferCommand extends AreashopCommandBean {
if (!region.isTransferEnabled()) {
throw new AreaShopCommandException("transfer-disabled");
}
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
) {
OfflinePlayer targetPlayer = context.get(KEY_PLAYER);
String targetPlayerName = targetPlayer.getName();
if (Objects.equals(sender, targetPlayer)) {
throw new AreaShopCommandException("transfer-transferSelf");
}
if (!targetPlayer.hasPlayedBefore() && !targetPlayer.isOnline()) {
if (!targetPlayer.hasPlayedBefore()) {
// Unknown player
throw new AreaShopCommandException("transfer-noPlayer", targetPlayerName);
}
@@ -46,7 +46,6 @@ 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;
@@ -110,8 +109,7 @@ public class AreashopCommands {
TeleportCommand.class,
ToggleHomeCommand.class,
TransferCommand.class,
UnrentCommand.class,
SetMaxExtends.class
UnrentCommand.class
);
private final MessageBridge messageBridge;
@@ -149,14 +147,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(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));
exceptionController.registerHandler(InvalidCommandSenderException.class,
new InvalidCommandSenderHandler(this.messageBridge));
exceptionController.registerHandler(AreaShopCommandException.class,
new ArgumentParseExceptionHandler<>(this.messageBridge));
var confirmationConfiguration = ConfirmationConfiguration.<CommandSource<?>>builder()
.cache(GuavaCache.of(CacheBuilder.newBuilder().build()))
.noPendingCommandNotifier(x -> {
@@ -1,38 +0,0 @@
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();
}
}
@@ -0,0 +1,64 @@
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();
}
}
@@ -2,12 +2,10 @@ 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;
@@ -29,20 +27,14 @@ 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,
@Nonnull CacheManager cacheManager
) {
public PlayerLoginLogoutListener(@Nonnull AreaShop plugin, @Nonnull MessageBridge messageBridge) {
this.plugin = plugin;
this.messageBridge = messageBridge;
this.cacheManager = cacheManager;
}
/**
@@ -56,8 +48,6 @@ 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
@@ -1,247 +0,0 @@
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.saveNowAsync();
region.saveNow();
}
}
);
@@ -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() || player.isOnline()) && !noPayBack) {
if(player.hasPlayedBefore() && !noPayBack) {
EconomyResponse response = null;
boolean error = false;
try {
@@ -1,6 +1,5 @@
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;
@@ -30,15 +29,11 @@ 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;
@@ -477,7 +472,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
if(landlordName != null && !landlordName.isEmpty()) {
@SuppressWarnings("deprecation")
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(landlordName);
if(offlinePlayer.hasPlayedBefore() || offlinePlayer.isOnline()) {
if(offlinePlayer.hasPlayedBefore()) {
return offlinePlayer.getUniqueId();
}
}
@@ -963,27 +958,6 @@ 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() || offlinePlayer.isOnline()) {
if(offlinePlayer.hasPlayedBefore()) {
existing.add(offlinePlayer.getUniqueId());
}
}
@@ -190,9 +190,6 @@ public class RentRegion extends GeneralRegion {
}
}
public void setMaxExtends(int times) {
setSetting("rent.maxExtends", times); }
@Override
public Object provideReplacement(String variable) {
return switch (variable) {
@@ -1,67 +0,0 @@
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() || player.isOnline()) {
if (player.hasPlayedBefore()) {
return Optional.of(player.getUniqueId());
}
return Optional.empty();
@@ -31,11 +31,6 @@ 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,7 +6,6 @@ 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;
@@ -806,20 +805,10 @@ public class Utils {
if (uuid == null) {
return "";
}
final CacheManager cacheManager = plugin.getCacheManager();
if (cacheManager.contains(uuid))
return cacheManager.get(uuid).getName();
final String name = Bukkit.getOfflinePlayer(uuid).getName();
String name = Bukkit.getOfflinePlayer(uuid).getName();
if (name != null) {
cacheManager.put(uuid, new CacheWrapper(uuid, name, System.currentTimeMillis()));
return name;
}
return "";
}
-1
View File
@@ -150,7 +150,6 @@ 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,11 +374,6 @@ 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'.
-6
View File
@@ -81,7 +81,6 @@ 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."
@@ -351,11 +350,6 @@ 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 -6
View File
@@ -1,8 +1,3 @@
<h1>
The project is no longer maintained. See this alternative <a href="https://github.com/MCCitiesNetwork/realty">realty</a>
</h1>
<br>
![AreaShop logo](https://cloud.githubusercontent.com/assets/6951068/9471294/f016d8ee-4b4f-11e5-9bda-d61b1c423ebb.png)<br/>
[![](https://jitpack.io/v/md5sha256/AreaShop.svg)](https://jitpack.io/#md5sha256/AreaShop)
<br>
@@ -79,4 +74,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/>
[![Tutorial Video](https://cloud.githubusercontent.com/assets/6951068/9532788/147526cc-4d0e-11e5-9672-1274faae280a.png)](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)
@@ -29,15 +29,6 @@ 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);
@@ -56,7 +56,7 @@ public class RegionAccessSet {
for(String playerName : playerNames) {
@SuppressWarnings("deprecation")
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
if(offlinePlayer.hasPlayedBefore() || offlinePlayer.isOnline()) {
if(offlinePlayer.hasPlayedBefore()) {
result.add(offlinePlayer.getUniqueId());
}
}
+2 -2
View File
@@ -11,7 +11,7 @@ plugins {
}
group = "me.wiefferink"
version = "2.9.2-SNAPSHOT"
version = "2.9.1-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 -1
View File
@@ -1,6 +1,6 @@
[versions]
# Platforms
minecraft = "1.21.1-R0.1-SNAPSHOT"
minecraft = "1.21-R0.1-SNAPSHOT"
# Minecraft Plugins
worldedit = "7.3.3"
Binary file not shown.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+2 -5
View File
@@ -15,8 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
@@ -57,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/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/.
@@ -86,8 +84,7 @@ 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 -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
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
Vendored
-2
View File
@@ -13,8 +13,6 @@
@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 ##########################################################################