mirror of
https://github.com/md5sha256/AreaShop.git
synced 2026-11-07 01:42:34 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61828d3cfd | ||
|
|
54241d5ce3 | ||
|
|
d048665530 | ||
|
|
23de68431c | ||
|
|
95b4543f19 | ||
|
|
d058bb7271 | ||
|
|
63d26be369 | ||
|
|
1020388aae |
No files matched your search
@@ -48,10 +48,7 @@ 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)
|
||||
|
||||
runtimeOnly(projects.adapters.platform.bukkitModern)
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.9.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+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();
|
||||
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "me.wiefferink"
|
||||
version = "2.7.14-SNAPSHOT"
|
||||
version = "2.7.15"
|
||||
|
||||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
|
||||
|
||||
+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