mirror of
https://github.com/md5sha256/AreaShop.git
synced 2026-11-07 01:42:34 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88f55bb6a9 | ||
|
|
4ba8326314 | ||
|
|
de81d92da0 | ||
|
|
f636a98314 | ||
|
|
e4df5a8cc9 | ||
|
|
56818bebdb | ||
|
|
7e1d7168f1 | ||
|
|
ff1ea3ae51 | ||
|
|
c9dc8dd840 | ||
|
|
c0794daeeb | ||
|
|
d40b9c660b | ||
|
|
f7b010b3f3 | ||
|
|
a06d9271c4 | ||
|
|
dd343aa587 | ||
|
|
e09d4ebd83 | ||
|
|
5f435941e4 | ||
|
|
86316cdd5b | ||
|
|
61828d3cfd | ||
|
|
54241d5ce3 | ||
|
|
d048665530 | ||
|
|
23de68431c | ||
|
|
95b4543f19 | ||
|
|
d058bb7271 | ||
|
|
63d26be369 | ||
|
|
1020388aae |
No files matched your search
@@ -48,13 +48,10 @@ dependencies {
|
||||
if (!providers.environmentVariable("JITPACK").isPresent) {
|
||||
runtimeOnly(project(":adapters:platform:bukkit-1-17", "reobf"))
|
||||
}
|
||||
runtimeOnly(projects.adapters.platform.bukkit118)
|
||||
runtimeOnly(projects.adapters.platform.bukkit119)
|
||||
runtimeOnly(projects.adapters.platform.bukkit120)
|
||||
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||
runtimeOnly(projects.adapters.platform.bukkitModern)
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.57.1")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,11 +25,14 @@ import me.wiefferink.areashop.modules.AreaShopModule;
|
||||
import me.wiefferink.areashop.modules.BukkitModule;
|
||||
import me.wiefferink.areashop.modules.DependencyModule;
|
||||
import me.wiefferink.areashop.modules.PlatformModule;
|
||||
import me.wiefferink.areashop.nms.NMS;
|
||||
import me.wiefferink.areashop.platform.adapter.PlatformAdapter;
|
||||
import me.wiefferink.areashop.tools.GithubUpdateCheck;
|
||||
import me.wiefferink.areashop.tools.SimpleMessageBridge;
|
||||
import me.wiefferink.areashop.tools.SpigotPlatform;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import me.wiefferink.areashop.tools.version.Version;
|
||||
import me.wiefferink.areashop.tools.version.VersionData;
|
||||
import me.wiefferink.areashop.tools.version.VersionUtil;
|
||||
import me.wiefferink.bukkitdo.Do;
|
||||
import me.wiefferink.interactivemessenger.source.LanguageManager;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
@@ -70,7 +73,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
private WorldGuardInterface worldGuardInterface = null;
|
||||
private WorldEditPlugin worldEdit = null;
|
||||
private WorldEditInterface worldEditInterface = null;
|
||||
private NMS nms;
|
||||
private PlatformAdapter platformAdapter;
|
||||
private MessageBridge messageBridge;
|
||||
private IFileManager fileManager = null;
|
||||
private LanguageManager languageManager = null;
|
||||
@@ -172,18 +175,34 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
signErrorLogger = new SignErrorLogger(new File(getDataFolder(), signLogFile));
|
||||
|
||||
// Setup NMS Impl
|
||||
String rawServerVersion = Bukkit.getServer().getClass().getPackageName();
|
||||
String[] split = rawServerVersion.split("\\.");
|
||||
String serverVersion = split[3];
|
||||
try {
|
||||
Class<?> nmsImpl = Class.forName("me.wiefferink.areashop.adapters.platform." + serverVersion + ".NMSImpl");
|
||||
this.nms = nmsImpl.asSubclass(NMS.class).getConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
ex.printStackTrace();
|
||||
error("Failed to initialize NMS implementation!");
|
||||
Version currentServerVersion = VersionUtil.parseMinecraftVersion(Bukkit.getBukkitVersion());
|
||||
if (currentServerVersion.versionData().isOlderThan(VersionUtil.MC_1_17_1)) {
|
||||
error("Unsupported minecraft version: " + currentServerVersion + "! Minimum is 1.17.1");
|
||||
shutdownOnError();
|
||||
return;
|
||||
}
|
||||
if (currentServerVersion.versionData().equals(VersionUtil.MC_1_17_1)) {
|
||||
try {
|
||||
Class<?> adapterImpl = Class.forName("me.wiefferink.areashop.adapters.platform.legacy.LegacyPlatformAdapter");
|
||||
this.platformAdapter = adapterImpl.asSubclass(PlatformAdapter.class).getConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
ex.printStackTrace();
|
||||
error("Failed to initialize legacy PlatformAdapter implementation!");
|
||||
shutdownOnError();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Class<?> adapterImpl = Class.forName("me.wiefferink.areashop.adapters.platform.modern.ModernPlatformAdapter");
|
||||
this.platformAdapter = adapterImpl.asSubclass(PlatformAdapter.class).getConstructor().newInstance();
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
ex.printStackTrace();
|
||||
error("Failed to initialize modern PlatformAdapter implementation!");
|
||||
shutdownOnError();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final MinecraftPlatform platform;
|
||||
if (PaperLib.isPaper()) {
|
||||
platform = new PaperPlatform(this);
|
||||
@@ -192,7 +211,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
platform = new SpigotPlatform(this);
|
||||
info("Detected Spigot; using the SpigotPlatform impl");
|
||||
}
|
||||
final PlatformModule platformModule = new PlatformModule(platform, this.nms);
|
||||
final PlatformModule platformModule = new PlatformModule(platform, this.platformAdapter);
|
||||
|
||||
// Check if Vault is present
|
||||
if(getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
@@ -254,7 +273,8 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
return;
|
||||
}
|
||||
|
||||
AreaShopModule asModule = new AreaShopModule(this, messageBridge, nms, worldEditInterface, worldGuardInterface, signErrorLogger, platformModule, dependencyModule);
|
||||
AreaShopModule asModule = new AreaShopModule(this, messageBridge,
|
||||
platformAdapter, worldEditInterface, worldGuardInterface, signErrorLogger, platformModule, dependencyModule);
|
||||
injector = Guice.createInjector(Stage.PRODUCTION, new BukkitModule(getServer()), asModule);
|
||||
|
||||
// Load all data from files and check versions
|
||||
@@ -296,8 +316,11 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
this,
|
||||
"md5sha256",
|
||||
"AreaShop"
|
||||
).withVersionComparator((latestVersion, currentVersion) ->
|
||||
!cleanVersion(latestVersion).equals(cleanVersion(currentVersion))
|
||||
).withVersionComparator((latestVersion, currentVersion) -> {
|
||||
Version latest = Version.parse(cleanVersion(latestVersion));
|
||||
Version current = Version.parse(cleanVersion(currentVersion));
|
||||
return latest.versionData().isNewerThan(current.versionData());
|
||||
}
|
||||
).checkUpdate(result -> {
|
||||
AreaShop.debug("Update check result:", result);
|
||||
if(!result.hasUpdate()) {
|
||||
@@ -409,8 +432,8 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
this.chatprefix = chatprefix;
|
||||
}
|
||||
|
||||
public NMS getNms() {
|
||||
return nms;
|
||||
public PlatformAdapter getPlatformAdapter() {
|
||||
return platformAdapter;
|
||||
}
|
||||
|
||||
public SignErrorLogger getSignErrorLogger() {
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@Singleton
|
||||
public class FindCommand extends CommandAreaShop {
|
||||
@@ -96,7 +97,7 @@ public class FindCommand extends CommandAreaShop {
|
||||
}
|
||||
if(!results.isEmpty()) {
|
||||
// Draw a random one
|
||||
BuyRegion region = results.get(new Random().nextInt(results.size()));
|
||||
BuyRegion region = results.get(ThreadLocalRandom.current().nextInt(results.size()));
|
||||
Message onlyInGroup = Message.empty();
|
||||
if(group != null) {
|
||||
onlyInGroup = Message.fromKey("find-onlyInGroup").replacements(args[3]);
|
||||
@@ -136,7 +137,7 @@ public class FindCommand extends CommandAreaShop {
|
||||
}
|
||||
if(!results.isEmpty()) {
|
||||
// Draw a random one
|
||||
RentRegion region = results.get(new Random().nextInt(results.size()));
|
||||
RentRegion region = results.get(ThreadLocalRandom.current().nextInt(results.size()));
|
||||
Message onlyInGroup = Message.empty();
|
||||
if(group != null) {
|
||||
onlyInGroup = Message.fromKey("find-onlyInGroup").replacements(args[3]);
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SetTransferCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop settransfer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (target.hasPermission("areashop.settransfer")) {
|
||||
return "help-settransfer";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.settransfer")) {
|
||||
messageBridge.message(sender, "settransfer-noPermission");
|
||||
return;
|
||||
}
|
||||
if (args.length <= 2 || args[1] == null || args[2] == null) {
|
||||
messageBridge.message(sender, "settransfer-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = fileManager.getRegion(args[1]);
|
||||
if (region == null) {
|
||||
messageBridge.message(sender, "settransfer-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
boolean value;
|
||||
if (args[2].equalsIgnoreCase("true")) {
|
||||
value = true;
|
||||
} else if (args[2].equalsIgnoreCase("false")) {
|
||||
value = false;
|
||||
} else {
|
||||
messageBridge.message(sender, "settransfer-invalidSetting", args[2]);
|
||||
return;
|
||||
}
|
||||
region.setTransferEnabled(value);
|
||||
messageBridge.message(sender, "settransfer-success", args[2], region);
|
||||
region.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if (toComplete == 2) {
|
||||
result = fileManager.getRegionNames();
|
||||
} else if (toComplete == 3) {
|
||||
result.add("true");
|
||||
result.add("false");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Singleton
|
||||
public class TransferCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
@Inject
|
||||
private Server server;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop transfer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (!target.hasPermission("areashop.transfer")) {
|
||||
return null;
|
||||
}
|
||||
return "help-transfer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.transfer")) {
|
||||
this.messageBridge.message(sender, "transfer-noPermission");
|
||||
return;
|
||||
}
|
||||
if (sender instanceof Player player) {
|
||||
handlePlayer(player, args);
|
||||
} else {
|
||||
this.messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePlayer(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
this.messageBridge.message(player, "transfer-help");
|
||||
return;
|
||||
}
|
||||
String targetPlayerName = args[1];
|
||||
if (targetPlayerName.equals(player.getName())) {
|
||||
this.messageBridge.message(player, "transfer-transferSelf");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if (args.length > 2) {
|
||||
String targetRegionName = args[2];
|
||||
region = this.fileManager.getRegion(targetRegionName);
|
||||
if (region == null) {
|
||||
messageBridge.message(player, "cmd-noRegion");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(player.getLocation());
|
||||
if (regions.isEmpty()) {
|
||||
messageBridge.message(player, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if (regions.size() > 1) {
|
||||
messageBridge.message(player, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
}
|
||||
region = regions.get(0);
|
||||
}
|
||||
if (!region.isTransferEnabled()) {
|
||||
this.messageBridge.message(player, "transfer-disabled");
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer targetPlayer = this.server.getOfflinePlayer(targetPlayerName);
|
||||
if (!targetPlayer.hasPlayedBefore()) {
|
||||
// Unknown player
|
||||
this.messageBridge.message(player, "transfer-noPlayer", targetPlayerName);
|
||||
return;
|
||||
}
|
||||
if (region.isLandlord(player.getUniqueId())) {
|
||||
// Transfer ownership if same as landlord
|
||||
region.setOwner(targetPlayer.getUniqueId());
|
||||
region.setLandlord(targetPlayer.getUniqueId(), targetPlayerName);
|
||||
this.messageBridge.message(player, "transfer-transferred-owner", targetPlayerName, region);
|
||||
if (targetPlayer.isOnline()) {
|
||||
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-owner", targetPlayerName, region);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!region.isOwner(player.getUniqueId())) {
|
||||
// Cannot transfer tenant if we aren't the current tenant
|
||||
this.messageBridge.message(player, "transfer-notCurrentTenant");
|
||||
return;
|
||||
}
|
||||
// Swap the owner/occupant (renter or buyer)
|
||||
region.setOwner(targetPlayer.getUniqueId());
|
||||
this.messageBridge.message(player, "transfer-transferred-tenant", targetPlayerName, region);
|
||||
if (targetPlayer.isOnline()) {
|
||||
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-tenant", targetPlayerName, region);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
if (toComplete == 2) {
|
||||
Collection<? extends Player> players = this.server.getOnlinePlayers();
|
||||
List<String> ret = new ArrayList<>(players.stream()
|
||||
.map(Player::getName)
|
||||
.toList());
|
||||
if (sender instanceof Player player) {
|
||||
ret.remove(player.getName());
|
||||
}
|
||||
return ret;
|
||||
} else if (toComplete == 3) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
return this.fileManager.getRegionNames();
|
||||
}
|
||||
UUID uuid = player.getUniqueId();
|
||||
return new ArrayList<>(this.fileManager.getRegions()
|
||||
.stream()
|
||||
.filter(region -> region.isOwner(uuid) || region.isLandlord(uuid))
|
||||
.map(GeneralRegion::getName)
|
||||
.toList());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.managers.SignErrorLogger;
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.tools.Materials;
|
||||
import me.wiefferink.areashop.tools.SignUtils;
|
||||
|
||||
@@ -10,7 +10,7 @@ import me.wiefferink.areashop.events.notify.UpdateRegionEvent;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
@@ -36,7 +36,6 @@ import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -9,7 +9,7 @@ import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@@ -29,6 +29,7 @@ import me.wiefferink.areashop.commands.RentCommand;
|
||||
import me.wiefferink.areashop.commands.ResellCommand;
|
||||
import me.wiefferink.areashop.commands.SchematiceventCommand;
|
||||
import me.wiefferink.areashop.commands.SellCommand;
|
||||
import me.wiefferink.areashop.commands.SetTransferCommand;
|
||||
import me.wiefferink.areashop.commands.SetdurationCommand;
|
||||
import me.wiefferink.areashop.commands.SetlandlordCommand;
|
||||
import me.wiefferink.areashop.commands.SetownerCommand;
|
||||
@@ -38,6 +39,7 @@ import me.wiefferink.areashop.commands.SetteleportCommand;
|
||||
import me.wiefferink.areashop.commands.StackCommand;
|
||||
import me.wiefferink.areashop.commands.StopresellCommand;
|
||||
import me.wiefferink.areashop.commands.TeleportCommand;
|
||||
import me.wiefferink.areashop.commands.TransferCommand;
|
||||
import me.wiefferink.areashop.commands.UnrentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -70,6 +72,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
||||
commands.add(injector.getInstance(UnrentCommand.class));
|
||||
commands.add(injector.getInstance(BuyCommand.class));
|
||||
commands.add(injector.getInstance(SellCommand.class));
|
||||
commands.add(injector.getInstance(TransferCommand.class));
|
||||
commands.add(injector.getInstance(MeCommand.class));
|
||||
commands.add(injector.getInstance(InfoCommand.class));
|
||||
commands.add(injector.getInstance(TeleportCommand.class));
|
||||
@@ -83,6 +86,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
||||
commands.add(injector.getInstance(SetpriceCommand.class));
|
||||
commands.add(injector.getInstance(SetownerCommand.class));
|
||||
commands.add(injector.getInstance(SetdurationCommand.class));
|
||||
commands.add(injector.getInstance(SetTransferCommand.class));
|
||||
commands.add(injector.getInstance(ReloadCommand.class));
|
||||
commands.add(injector.getInstance(GroupaddCommand.class));
|
||||
commands.add(injector.getInstance(GroupdelCommand.class));
|
||||
|
||||
@@ -54,6 +54,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -123,11 +124,11 @@ public class FileManager extends Manager implements IFileManager {
|
||||
public void shutdown() {
|
||||
// Update lastactive time for players that are online now
|
||||
for(GeneralRegion region : this.regions.values()) {
|
||||
if (region.getOwner() == null) {
|
||||
AreaShop.warn(String.format("%s has no owner", region.getName()));
|
||||
UUID ownerUuid = region.getOwner();
|
||||
if (ownerUuid == null) {
|
||||
continue;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(region.getOwner());
|
||||
Player player = Bukkit.getPlayer(ownerUuid);
|
||||
if(player != null) {
|
||||
region.updateLastActiveTime();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import me.wiefferink.areashop.managers.FileManager;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.managers.SignErrorLogger;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
import me.wiefferink.areashop.nms.NMS;
|
||||
import me.wiefferink.areashop.platform.adapter.PlatformAdapter;
|
||||
import me.wiefferink.areashop.regions.ImportJobFactory;
|
||||
import me.wiefferink.areashop.regions.RegionModule;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
@@ -30,14 +30,14 @@ public class AreaShopModule extends AbstractModule {
|
||||
private final AreaShop instance;
|
||||
private final WorldGuardInterface worldGuardInterface;
|
||||
private final WorldEditInterface worldEditInterface;
|
||||
private final NMS nms;
|
||||
private final PlatformAdapter platformAdapter;
|
||||
private final MessageBridge messageBridge;
|
||||
private final SignErrorLogger signErrorLogger;
|
||||
private final AbstractModule[] extras;
|
||||
|
||||
public AreaShopModule(@Nonnull AreaShop instance,
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull NMS nms,
|
||||
@Nonnull PlatformAdapter platformAdapter,
|
||||
@Nonnull WorldEditInterface worldEditInterface,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nonnull SignErrorLogger signErrorLogger,
|
||||
@@ -45,7 +45,7 @@ public class AreaShopModule extends AbstractModule {
|
||||
) {
|
||||
this.instance = instance;
|
||||
this.messageBridge = messageBridge;
|
||||
this.nms = nms;
|
||||
this.platformAdapter = platformAdapter;
|
||||
this.signErrorLogger = signErrorLogger;
|
||||
this.worldEditInterface = worldEditInterface;
|
||||
this.worldGuardInterface = worldGuardInterface;
|
||||
|
||||
@@ -3,27 +3,27 @@ package me.wiefferink.areashop.modules;
|
||||
import com.google.inject.AbstractModule;
|
||||
import me.wiefferink.areashop.adapters.platform.MinecraftPlatform;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.nms.NMS;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.PlatformAdapter;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlatformModule extends AbstractModule {
|
||||
|
||||
private final MinecraftPlatform minecraftPlatform;
|
||||
private final NMS nms;
|
||||
private final PlatformAdapter platformAdapter;
|
||||
|
||||
public PlatformModule(@NotNull MinecraftPlatform platform,
|
||||
@NotNull NMS nms) {
|
||||
@NotNull PlatformAdapter platformAdapter) {
|
||||
this.minecraftPlatform = platform;
|
||||
this.nms = nms;
|
||||
this.platformAdapter = platformAdapter;
|
||||
}
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(MinecraftPlatform.class).toInstance(this.minecraftPlatform);
|
||||
bind(OfflinePlayerHelper.class).toInstance(this.minecraftPlatform.offlinePlayerHelper());
|
||||
bind(NMS.class).toInstance(this.nms);
|
||||
bind(BlockBehaviourHelper.class).toInstance(this.nms.blockBehaviourHelper());
|
||||
bind(PlatformAdapter.class).toInstance(this.platformAdapter);
|
||||
bind(BlockBehaviourHelper.class).toInstance(this.platformAdapter.blockBehaviourHelper());
|
||||
bind(BukkitSchedulerExecutor.class).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@@ -517,7 +518,8 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
* @return true if the player is the landlord, otherwise false
|
||||
*/
|
||||
public boolean isLandlord(UUID landlord) {
|
||||
return landlord != null && getLandlord() != null && getLandlord().equals(landlord);
|
||||
UUID ourLandlord = getLandlord();
|
||||
return Objects.equals(landlord, ourLandlord);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1587,6 +1589,22 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
return volume;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether region transfers are enabled
|
||||
* @return Returns true if region transfers are enabled, false otherwise
|
||||
*/
|
||||
public boolean isTransferEnabled() {
|
||||
return getBooleanSetting("general.transferMode");
|
||||
}
|
||||
|
||||
/**
|
||||
* Se whether region transfers are enabled
|
||||
* @param enabled Whether region transfers should be enabled, false otherwise
|
||||
*/
|
||||
public void setTransferEnabled(boolean enabled) {
|
||||
setSetting("general.transferMode", enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the volume of the region (could be expensive for polygon regions).
|
||||
* @return Number of blocks in the region
|
||||
|
||||
@@ -20,7 +20,7 @@ public class GithubUpdateCheck {
|
||||
|
||||
public static final String API_HOST = "https://api.github.com/repos";
|
||||
public static final String API_LATEST_RELEASE = "releases/latest";
|
||||
public static final String USER_AGENT = "GithubUpdateCheck by NLThijs48";
|
||||
public static final String USER_AGENT = "md5sha256 AreaShop GithubUpdateCheck";
|
||||
public static final boolean DEBUG = false;
|
||||
|
||||
private final String author;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package me.wiefferink.areashop.tools.version;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
|
||||
public enum PreReleaseType {
|
||||
|
||||
UNKNOWN("unknown"),
|
||||
|
||||
ALPHA("alpha"),
|
||||
BETA("beta"),
|
||||
SNAPSHOT("snapshot"),
|
||||
RELEASE_CANDIDATE("rc");
|
||||
|
||||
private static final PreReleaseType[] VALUES = values();
|
||||
|
||||
private final String asString;
|
||||
|
||||
PreReleaseType(String asString) {
|
||||
this.asString = asString;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PreReleaseType parse(String release) {
|
||||
if (release.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String sanitized = release.toLowerCase(Locale.ENGLISH);
|
||||
for (PreReleaseType preReleaseType : VALUES) {
|
||||
if (preReleaseType.asString.equals(sanitized)) {
|
||||
return preReleaseType;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
return this.asString;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package me.wiefferink.areashop.tools.version;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public record Version(String original, VersionData versionData) {
|
||||
|
||||
/**
|
||||
* Semver pattern, cg1 = major, cg2 = minor, cg3 = patch, cg4 = prerelease and cg5 = buildmetadata
|
||||
* Taken from https://semver.org/ and https://regex101.com/r/vkijKf/1/
|
||||
*/
|
||||
public static final Pattern SEMVER_PATTERN = Pattern.compile(
|
||||
"^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
|
||||
|
||||
|
||||
public static Version parse(String version) {
|
||||
Matcher matcher = SEMVER_PATTERN.matcher(version);
|
||||
if (!matcher.find()) {
|
||||
throw new IllegalArgumentException("Invalid version: " + version);
|
||||
}
|
||||
String majorRaw = matcher.group(1);
|
||||
String minorRaw = matcher.group(2);
|
||||
String patchRaw = matcher.group(3);
|
||||
String preReleaseRaw = matcher.group(4);
|
||||
int major;
|
||||
int minor;
|
||||
try {
|
||||
major = Integer.parseInt(majorRaw);
|
||||
minor = Integer.parseInt(minorRaw);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException("Invalid version: " + version);
|
||||
}
|
||||
if (patchRaw == null || patchRaw.isEmpty()) {
|
||||
return new Version(version, new VersionData(major, minor, 0, null));
|
||||
}
|
||||
int patch;
|
||||
try {
|
||||
patch = Integer.parseInt(patchRaw);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException("Invalid version: " + version);
|
||||
}
|
||||
if (preReleaseRaw == null || preReleaseRaw.isEmpty()) {
|
||||
return new Version(version, new VersionData(major, minor, patch, null));
|
||||
}
|
||||
PreReleaseType releaseType = PreReleaseType.parse(preReleaseRaw);
|
||||
return new Version(version, new VersionData(major, minor, patch, releaseType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.original;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package me.wiefferink.areashop.tools.version;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record VersionData(int major, int minor, int patch, PreReleaseType preReleaseType)
|
||||
implements Comparable<VersionData> {
|
||||
|
||||
|
||||
public VersionData(int major, int minor, int patch) {
|
||||
this(major, minor, patch, null);
|
||||
}
|
||||
|
||||
public VersionData(int major, int minor) {
|
||||
this(major, minor, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%d.%d.%d", major, minor, patch);
|
||||
}
|
||||
|
||||
public boolean isNewerThan(VersionData other) {
|
||||
return compareTo(other) > 0;
|
||||
}
|
||||
|
||||
public boolean isOlderThan(VersionData other) {
|
||||
return compareTo(other) < 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull VersionData o) {
|
||||
int majorComp = Integer.compare(this.major, o.major);
|
||||
if (majorComp != 0) {
|
||||
return majorComp;
|
||||
}
|
||||
int minorComp = Integer.compare(this.minor, o.minor);
|
||||
if (minorComp != 0) {
|
||||
return minorComp;
|
||||
}
|
||||
int patchComp = Integer.compare(this.patch, o.patch);
|
||||
if (patchComp != 0) {
|
||||
return patchComp;
|
||||
}
|
||||
if (this.preReleaseType == null && o.preReleaseType == null) {
|
||||
return 0;
|
||||
}
|
||||
if (this.preReleaseType == null) {
|
||||
return 1;
|
||||
}
|
||||
return this.preReleaseType.compareTo(o.preReleaseType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.wiefferink.areashop.tools.version;
|
||||
|
||||
public class VersionUtil {
|
||||
|
||||
public static VersionData MC_1_17_1 = new VersionData(1, 17, 1);
|
||||
|
||||
public static Version parseMinecraftVersion(String minecraftVersion) {
|
||||
// Expecting 1.X.X-R0.1-SNAPSHOT
|
||||
int stripLength = "-R0.1-SNAPSHOT".length();
|
||||
int length = minecraftVersion.length();
|
||||
if (length <= stripLength) {
|
||||
throw new IllegalArgumentException("Invalid minecraft version: " + minecraftVersion);
|
||||
}
|
||||
String strippedVersion = minecraftVersion.substring(0, length - stripLength);
|
||||
try {
|
||||
return Version.parse(strippedVersion);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new IllegalArgumentException("Invalid minecraft version: " + minecraftVersion, ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,8 @@ general:
|
||||
landlordName: ''
|
||||
# Disable to prevent counting this region towards limits set by 'limitGroups' in config.yml.
|
||||
countForLimits: true
|
||||
# Whether transferring tenant <--> tenant and landlord <--> landlord should be enabled
|
||||
transferMode: false
|
||||
|
||||
##### Set the layout and functions of the signs.
|
||||
# The following sections can be added for performing certain commands when the sign is clicked:
|
||||
|
||||
@@ -80,6 +80,7 @@ help-reload: "%lang:helpCommand|/as reload|% Reload all files and update the reg
|
||||
help-setrestore: "%lang:helpCommand|/as setrestore|% Set restoring on/off and choose profile."
|
||||
help-setprice: "%lang:helpCommand|/as setprice|% Change the price of a region."
|
||||
help-setduration: "%lang:helpCommand|/as setduration|% Change the duration of a rent region."
|
||||
help-settransfer: "%lang:helpCommand|/as settransfer|% Set transfer on/off."
|
||||
help-teleport: "%lang:helpCommand|/as tp|% Teleport to a rent/buy region."
|
||||
help-setteleport: "%lang:helpCommand|/as settp|% Set teleport position for a region."
|
||||
help-find: "%lang:helpCommand|/as find|% Find an empty buy or rent."
|
||||
@@ -102,6 +103,7 @@ help-linksigns: "%lang:helpCommand|/as linksigns|% Use bulk sign linking mode."
|
||||
help-stack: "%lang:helpCommand|/as stack|% Create multiple regions and add them."
|
||||
help-setlandlord: "%lang:helpCommand|/as setlandlord|% Set the landlord of a region."
|
||||
help-import: "%lang:helpCommand|/as import|% Import region from RegionForSale."
|
||||
help-transfer: "%lang:helpCommand|/as transfer|% Transfer a region to another player."
|
||||
|
||||
rent-help: "/as rent [region], the region you stand in will be used if not specified."
|
||||
rent-noPermission: "You don't have permission to rent a region."
|
||||
@@ -156,6 +158,15 @@ sell-noPermission: "You don't have permission to sell a region."
|
||||
sell-noPermissionOther: "You don't have permission to sell another region."
|
||||
sell-disabled: "Selling has been disabled for this region."
|
||||
|
||||
transfer-help: "/as transfer <player> [region], the region you stand in will be used if not specified."
|
||||
transfer-noPermission: "You don't have permission to transfer a region."
|
||||
transfer-disabled: "Transferring has been disabled for this region."
|
||||
transfer-transferred-owner: "%lang:region% has been transferred and is now owned by %0%."
|
||||
transfer-transferred-tenant: "%lang:region% has been transferred and is now occupied by %0%."
|
||||
transfer-noPlayer: "Unknown player: %0%"
|
||||
transfer-notCurrentTenant: "You are not the current tenant of this region."
|
||||
transfer-transferSelf: "You cannot transfer a region to yourself."
|
||||
|
||||
reload-reloading: "Reloaded all configuration and region files."
|
||||
reload-updateStart: ""
|
||||
reload-updateComplete: ""
|
||||
@@ -303,6 +314,12 @@ setrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or
|
||||
setrestore-success: "Successfully set the restore setting of %lang:region% to '%0%'."
|
||||
setrestore-successProfile: "Successfully set the restore setting of %lang:region% to '%0%' and the profile to '%1%'."
|
||||
|
||||
settransfer-help: "/as settransfer <region> <true|false>."
|
||||
settransfer-noPermission: "You don't have permission to change the transfer settings."
|
||||
settransfer-notRegistered: "The specified region is not registered: %0%."
|
||||
settransfer-invalidSetting: "'%0%' is not a valid state, should be true, false or general."
|
||||
settransfer-success: "Successfully set the transfer setting of %lang:region% to '%0%'."
|
||||
|
||||
setprice-noPermission: "You don't have permission to change the price of a region."
|
||||
setprice-help: "/as setprice <price> [region], the region you stand in will be used if not specified."
|
||||
setprice-notRegistered: "The specified region is not registered: %0%."
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_17_R1;
|
||||
package me.wiefferink.areashop.adapters.platform.legacy;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package me.wiefferink.areashop.adapters.platform.legacy;
|
||||
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.PlatformAdapter;
|
||||
|
||||
public class LegacyPlatformAdapter implements PlatformAdapter {
|
||||
|
||||
private final BlockBehaviourImpl blockBehaviourHelper = new BlockBehaviourImpl();
|
||||
|
||||
@Override
|
||||
public BlockBehaviourHelper blockBehaviourHelper() {
|
||||
return this.blockBehaviourHelper;
|
||||
}
|
||||
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_17_R1;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.nms.NMS;
|
||||
|
||||
public class NMSImpl implements NMS {
|
||||
|
||||
private final BlockBehaviourImpl blockBehaviourHelper = new BlockBehaviourImpl();
|
||||
|
||||
@Override
|
||||
public BlockBehaviourHelper blockBehaviourHelper() {
|
||||
return this.blockBehaviourHelper;
|
||||
}
|
||||
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_18_R2;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockBehaviourImpl implements BlockBehaviourHelper {
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, BlockData blockData) {
|
||||
Objects.requireNonNull(location.getWorld(), "Null World!");
|
||||
return location.getBlock().canPlace(blockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockValid(Block block) {
|
||||
return block.canPlace(block.getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockStateValid(BlockState blockState) {
|
||||
return blockState.getBlock().canPlace(blockState.getBlockData());
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_18_R2;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.nms.NMS;
|
||||
|
||||
public class NMSImpl implements NMS {
|
||||
|
||||
private final BlockBehaviourImpl blockBehaviourHelper = new BlockBehaviourImpl();
|
||||
|
||||
@Override
|
||||
public BlockBehaviourHelper blockBehaviourHelper() {
|
||||
return this.blockBehaviourHelper;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
|
||||
compileOnly(projects.areashopInterface)
|
||||
compileOnly(projects.areashopNms)
|
||||
}
|
||||
|
||||
description = "AreaShop NMS Helper 1-19"
|
||||
|
||||
tasks {
|
||||
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_19_R3;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.nms.NMS;
|
||||
|
||||
public class NMSImpl implements NMS {
|
||||
|
||||
private final BlockBehaviourImpl blockBehaviourHelper = new BlockBehaviourImpl();
|
||||
|
||||
@Override
|
||||
public BlockBehaviourHelper blockBehaviourHelper() {
|
||||
return this.blockBehaviourHelper;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.2-R0.1-SNAPSHOT")
|
||||
compileOnly(projects.areashopInterface)
|
||||
compileOnly(projects.areashopNms)
|
||||
}
|
||||
|
||||
description = "AreaShop NMS Helper 1-20"
|
||||
|
||||
tasks {
|
||||
|
||||
}
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_20_R2;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class BlockBehaviourImpl implements BlockBehaviourHelper {
|
||||
|
||||
@Override
|
||||
public boolean canPlace(Location location, BlockData blockData) {
|
||||
Objects.requireNonNull(location.getWorld(), "Null World!");
|
||||
return location.getBlock().canPlace(blockData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockValid(Block block) {
|
||||
return block.canPlace(block.getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlockStateValid(BlockState blockState) {
|
||||
return blockState.getBlock().canPlace(blockState.getBlockData());
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_20_R2;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.nms.NMS;
|
||||
|
||||
public class NMSImpl implements NMS {
|
||||
|
||||
private final BlockBehaviourImpl blockBehaviourHelper = new BlockBehaviourImpl();
|
||||
|
||||
@Override
|
||||
public BlockBehaviourHelper blockBehaviourHelper() {
|
||||
return this.blockBehaviourHelper;
|
||||
}
|
||||
|
||||
}
|
||||
File renamed without changes.
+2
-2
@@ -1,6 +1,6 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_19_R3;
|
||||
package me.wiefferink.areashop.adapters.platform.modern;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package me.wiefferink.areashop.adapters.platform.modern;
|
||||
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.PlatformAdapter;
|
||||
|
||||
public class ModernPlatformAdapter implements PlatformAdapter {
|
||||
|
||||
private final BlockBehaviourImpl blockBehaviourHelper = new BlockBehaviourImpl();
|
||||
|
||||
@Override
|
||||
public BlockBehaviourHelper blockBehaviourHelper() {
|
||||
return this.blockBehaviourHelper;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package me.wiefferink.areashop.nms;
|
||||
|
||||
public interface NMS {
|
||||
|
||||
BlockBehaviourHelper blockBehaviourHelper();
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package me.wiefferink.areashop.nms;
|
||||
package me.wiefferink.areashop.platform.adapter;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package me.wiefferink.areashop.platform.adapter;
|
||||
|
||||
public interface PlatformAdapter {
|
||||
|
||||
BlockBehaviourHelper blockBehaviourHelper();
|
||||
|
||||
}
|
||||
+11
-7
@@ -5,16 +5,20 @@ plugins {
|
||||
java
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("io.papermc.paperweight.userdev") version "1.5.5" apply false
|
||||
id("io.papermc.paperweight.userdev") version "1.5.10" apply false
|
||||
id("com.github.spotbugs") version "5.1.3"
|
||||
idea
|
||||
eclipse
|
||||
}
|
||||
|
||||
group = "me.wiefferink"
|
||||
version = "2.7.14-SNAPSHOT"
|
||||
version = "2.7.16"
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
val targetJavaVersion = 17
|
||||
val encoding = Charsets.UTF_8
|
||||
val encodingName: String = encoding.name()
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
|
||||
|
||||
subprojects {
|
||||
|
||||
@@ -52,18 +56,18 @@ subprojects {
|
||||
|
||||
tasks {
|
||||
withType(JavaCompile::class) {
|
||||
options.release.set(17)
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.release.set(targetJavaVersion)
|
||||
options.encoding = encodingName
|
||||
options.isFork = true
|
||||
options.isDeprecation = true
|
||||
}
|
||||
|
||||
withType(Javadoc::class) {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
options.encoding = encodingName
|
||||
}
|
||||
|
||||
withType(ProcessResources::class) {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
filteringCharset = encodingName
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
minecraft = "1.17.1-R0.1-SNAPSHOT"
|
||||
|
||||
# Minecraft Plugins
|
||||
worldedit = "7.2.15"
|
||||
worldedit = "7.2.17"
|
||||
worldguard = "7.0.9"
|
||||
fawe = "2.7.1"
|
||||
fawe = "2.8.1"
|
||||
|
||||
[libraries]
|
||||
# Platform
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,5 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -80,13 +80,11 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -133,22 +131,29 @@ location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -193,6 +198,10 @@ if "$cygwin" || "$msys" ; then
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
|
||||
Vendored
+1
@@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
before_install:
|
||||
- sdk install java 17.0.8-amzn
|
||||
- sdk use java 17.0.8-amzn
|
||||
- sdk update
|
||||
- sdk install java 17.0.9-tem
|
||||
- sdk use java 17.0.9-tem
|
||||
install:
|
||||
- ./gradlew build publishToMavenLocal
|
||||
+1
-3
@@ -29,9 +29,7 @@ if (!providers.environmentVariable("JITPACK").isPresent) {
|
||||
include(":adapters:platform:bukkit-1-17")
|
||||
}
|
||||
|
||||
include(":adapters:platform:bukkit-1-18")
|
||||
include(":adapters:platform:bukkit-1-19")
|
||||
include(":adapters:platform:bukkit-1-20")
|
||||
include(":adapters:platform:bukkit-modern")
|
||||
|
||||
|
||||
// Main project
|
||||
|
||||
Reference in new issue
Block a user