Compare commits

..
24 Commits
Author SHA1 Message Date
md5sha256 088471aa3c more project restructuring 2022-01-16 21:28:28 +08:00
md5sha256 5a95c95670 Fix gitignore and restructure project 2022-01-16 20:58:44 +08:00
md5sha256 5a5d627d51 Fix publishing 2022-01-16 15:26:54 +08:00
md5sha256 9b5434a4b2 Add type safe project acessors and version catalog 2022-01-16 14:40:19 +08:00
md5sha256 e13717950b Kotlin dsl 2022-01-16 12:05:39 +08:00
md5sha256 03ed2803bd Bump version to 2.7.3 2022-01-15 07:38:40 +08:00
md5sha256 b3f1225934 Deprecate the FAWE WG handler and fix fawe version parsing 2022-01-15 07:36:43 +08:00
md5sha256 68651899b7 Update the fawe module 2022-01-10 22:59:03 +08:00
md5sha256 4a7a4ca4ee Fix reobf 2022-01-10 22:34:35 +08:00
md5sha256 0d272c8fe9 Publish nms provider poms 2021-12-05 23:07:05 +08:00
md5sha256 6b2c905939 Parallel builds 2021-12-05 22:57:17 +08:00
md5sha256 7ab782799b Fix maven publish tasks 2021-12-05 22:57:03 +08:00
md5sha256 bea82eae88 Fix maven publish tasks 2021-12-05 22:56:37 +08:00
md5sha256 4ac0e045bd Add maven publish task 2021-12-05 18:22:41 +08:00
md5sha256 e5061b218e Java 17 and 1.18 2021-12-01 17:59:17 +08:00
md5sha256 40fdfba47d Fix silly typo in the buildscript 2021-11-18 22:16:36 +08:00
md5sha256 e9260cede6 Bump gradle wrapper version to 7.3 2021-11-18 22:14:56 +08:00
md5sha256 bb297c9ff1 Bump version 2021-11-16 15:28:14 +08:00
Andrew Wong 666742ad56 Merge pull request #2 from md5sha256/feature/purge 2021-11-16 15:25:54 +08:00
md5sha256 36eb8c3a5e Fix imports 2021-11-16 15:25:01 +08:00
Olzie-12 06a9f7b28e file management 2021-11-14 14:41:41 +00:00
md5sha256 e101780420 Fix compat for file manager 2021-11-11 13:31:09 +08:00
md5sha256 6abe99e807 Log sign warnings to the sign error logger 2021-11-09 19:06:02 +08:00
md5sha256 a1d18521ee Introduce interface for FileManager 2021-10-11 00:00:57 +08:00
80 changed files with 1049 additions and 757 deletions

No files matched your search

+20 -37
View File
@@ -1,13 +1,11 @@
# Created by https://www.toptal.com/developers/gitignore/api/macos,windows,intellij,maven,gradle
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,intellij,maven,gradle
# Created by https://www.toptal.com/developers/gitignore/api/macos,windows,intellij+all,gradle,maven
# Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,intellij+all,gradle,maven
### Intellij ###
### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
.idea/**
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
@@ -68,6 +66,9 @@ atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
@@ -80,35 +81,21 @@ fabric.properties
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
.idea/*
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/
# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/
# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$
# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml
.idea/sonarlint
### macOS ###
# General
@@ -152,7 +139,6 @@ buildNumber.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
### Maven Patch ###
# Eclipse m2e generated files
# Eclipse Core
.project
@@ -188,6 +174,7 @@ $RECYCLE.BIN/
### Gradle ###
.gradle
build/
build-cache/
# Ignore Gradle GUI config
gradle-app.setting
@@ -204,8 +191,4 @@ gradle-app.setting
### Gradle Patch ###
**/build/
# Eclipse Gradle plugin generated files
# Eclipse Core
# JDT-specific (Eclipse Java Development Tools)
# End of https://www.toptal.com/developers/gitignore/api/macos,windows,intellij,maven,gradle
# End of https://www.toptal.com/developers/gitignore/api/macos,windows,intellij+all,gradle,maven
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>
-76
View File
@@ -1,76 +0,0 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'com.github.johnrengelman.shadow' version '7.1.0'
}
version = "2.7.0-SNAPSHOT"
dependencies {
implementation 'com.github.NLthijs48:InteractiveMessenger:e7749258ca'
implementation 'com.github.NLthijs48:BukkitDo:819d51ec2b'
implementation 'io.papermc:paperlib:1.0.6'
implementation 'io.github.baked-libs:dough-data:1.0.3'
implementation ('com.google.inject:guice:5.0.1') {
exclude group: 'com.google.guava'
}
implementation ('com.google.inject.extensions:guice-assistedinject:5.0.1') {
exclude group: 'com.google.guava'
}
implementation project(':areashop-interface')
implementation project(':areashop-bukkit-1_13')
implementation project(':areashop-nms')
implementation project(':areashop-nms-1-17')
implementation project(':areashop-worldedit-7')
implementation project(':areashop-worldguard-7')
implementation project(':areashop-fastasyncworldedit')
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly ('com.sk89q.worldedit:worldedit-bukkit:7.2.5') {
exclude group: 'com.google.guava'
}
compileOnly ('com.sk89q.worldguard:worldguard-bukkit:7.0.5') {
exclude group: 'com.google.guava'
}
compileOnly ('com.github.MilkBowl:VaultAPI:1.7')
}
processResources {
from (sourceSets.main.resources) {
filter ReplaceTokens, tokens: [version: project.version]
duplicatesStrategy(DuplicatesStrategy.INCLUDE)
}
}
assemble {
dependsOn(shadowJar)
}
jar {
archiveClassifier.set('original')
}
compileJava {
javaToolchains.compilerFor {
JavaLanguageVersion.of(16)
}
}
shadowJar {
archiveClassifier.set('')
setArchivesBaseName('AreaShop')
String base = "me.wiefferink.areashop.libraries"
relocate('me.wiefferink.interactivemessenger', "${base}.interactivemessenger")
relocate('me.wiefferink.bukkitdo', "${base}.bukkitdo")
relocate('io.papermc.lib', "${base}.paperlib")
relocate('io.github.bakedlibs.dough', "${base}.dough")
relocate("com.google.inject", "${base}.inject")
relocate("org.aopalliance", "${base}.aopalliance")
relocate("javax.inject", "${base}.javax.inject")
include {
include("com.google.inject")
minimize()
}
}
description = 'AreaShop'
+90
View File
@@ -0,0 +1,90 @@
plugins {
id("com.github.johnrengelman.shadow") version "7.1.2"
}
description = "AreaShop"
dependencies {
// Platform
compileOnlyApi(libs.spigot)
compileOnlyApi(libs.worldeditCore) {
exclude("com.google.guava", "guava")
}
compileOnlyApi(libs.worldeditBukkit) {
exclude("com.google.guava", "guava")
}
compileOnlyApi(libs.worldguardCore) {
exclude("com.google.guava", "guava")
}
compileOnlyApi(libs.worldguardBukkit) {
exclude("com.google.guava", "guava")
}
compileOnlyApi("com.github.MilkBowl:VaultAPI:1.7") {
exclude("com.google.guava", "guava")
}
// 3rd party libraries
implementation(libs.findbugs)
implementation("io.papermc:paperlib:1.0.7")
implementation("com.github.NLthijs48:InteractiveMessenger:e7749258ca")
implementation("com.github.NLthijs48:BukkitDo:819d51ec2b")
implementation("io.github.baked-libs:dough-data:1.0.3")
implementation("com.google.inject:guice:5.0.1") {
exclude("com.google.guava", "guava")
}
implementation("com.google.inject.extensions:guice-assistedinject:5.0.1") {
exclude("com.google.guava", "guava")
}
// Project submodules
implementation(projects.areashopInterface)
implementation(projects.areashopBukkit113)
implementation(projects.areashopNms)
// Adapters
runtimeOnly(projects.adapters.plugins.worldedit)
runtimeOnly(projects.adapters.plugins.worldguard)
runtimeOnly(projects.adapters.plugins.fastasyncworldedit)
runtimeOnly(project(":adapters:platform:bukkit-1-17", "reobf"))
runtimeOnly(project(":adapters:platform:bukkit-1-18", "reobf"))
}
tasks {
processResources {
filesMatching("plugin.yml") {
expand("version" to project.version)
}
}
assemble {
dependsOn(shadowJar)
}
jar {
archiveClassifier.set("original")
}
java {
withSourcesJar()
}
val javaComponent = project.components["java"] as AdhocComponentWithVariants
javaComponent.withVariantsFromConfiguration(configurations["shadowRuntimeElements"]) {
skip()
}
shadowJar {
archiveClassifier.set("")
base {
archiveBaseName.set("AreaShop")
}
val base = "me.wiefferink.areashop.libraries"
relocate("me.wiefferink.interactivemessenger", "${base}.interactivemessenger")
relocate("me.wiefferink.bukkitdo", "${base}.bukkitdo")
relocate("io.papermc.lib", "${base}.paperlib")
relocate("io.github.bakedlibs.dough", "${base}.dough")
relocate("com.google.inject", "${base}.inject")
relocate("org.aopalliance", "${base}.aopalliance")
relocate("javax.annotation", "${base}.javax.annotation")
relocate("javax.inject", "${base}.javax.inject")
}
}
@@ -14,6 +14,7 @@ import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import me.wiefferink.areashop.listeners.PlayerLoginLogoutListener;
import me.wiefferink.areashop.managers.CommandManager;
import me.wiefferink.areashop.managers.FeatureManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.Manager;
import me.wiefferink.areashop.managers.SignErrorLogger;
@@ -69,7 +70,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
private NMS nms;
private BukkitInterface bukkitInterface = null;
private MessageBridge messageBridge;
private FileManager fileManager = null;
private IFileManager fileManager = null;
private LanguageManager languageManager = null;
private CommandManager commandManager = null;
private SignLinkerManager signLinkerManager = null;
@@ -174,197 +175,95 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
String[] split = rawServerVersion.split("\\.");
String serverVersion = split[3];
try {
Class<?> nmsImpl = Class.forName("me.wiefferink.areashop.nms." + serverVersion + ".NMSImpl");
Class<?> nmsImpl = Class.forName("me.wiefferink.areashop.adapters.platform." + serverVersion + ".NMSImpl");
this.nms = nmsImpl.asSubclass(NMS.class).getConstructor().newInstance();
} catch (ReflectiveOperationException ex) {
ex.printStackTrace();
getLogger().severe("Failed to initialize NMS implementation!");
getServer().getPluginManager().disablePlugin(this);
error("Failed to initialize NMS implementation!");
shutdownOnError();
return;
}
// Find WorldEdit integration version to load
String weVersion = null;
String rawWeVersion = null;
String weBeta = null;
String weHandlerVersion;
Plugin plugin = getServer().getPluginManager().getPlugin("WorldEdit");
if(!(plugin instanceof WorldEditPlugin) || !plugin.isEnabled()) {
error("WorldEdit plugin is not present or has not loaded correctly");
error = true;
return;
} else {
worldEdit = (WorldEditPlugin)plugin;
rawWeVersion = worldEdit.getDescription().getVersion();
// Find beta version
Pattern pattern = Pattern.compile("beta-?\\d+");
Matcher matcher = pattern.matcher(rawWeVersion);
if (matcher.find()) {
weBeta = matcher.group();
}
// Get correct WorldEditInterface (handles things that changed version to version)
if(worldEdit.getDescription().getVersion().startsWith("7.")) {
weVersion = "7";
this.worldEdit = (WorldEditPlugin) plugin;
Plugin fawePlugin = getServer().getPluginManager().getPlugin("FastAsyncWorldEdit");
if (fawePlugin != null && fawePlugin.isEnabled()) {
weHandlerVersion = "FastAsyncWorldEditHandler";
info("Detected FastAsyncWorldEdit, using the fawe handler");
} else {
throw new IllegalStateException("Unknown WE Version: " + worldEdit.getDescription().getVersion());
weHandlerVersion = "WorldEditHandler";
}
weVersion = "WorldEditHandler" + weVersion;
}
// Find WorldGuard integration version to load
String wgVersion = null;
String rawWgVersion = null;
int major = 0;
int minor = 0;
int fixes = 0;
Integer build = null;
plugin = getServer().getPluginManager().getPlugin("WorldGuard");
if(!(plugin instanceof WorldGuardPlugin) || !plugin.isEnabled()) {
error("WorldGuard plugin is not present or has not loaded correctly");
error = true;
shutdownOnError();
return;
} else {
worldGuard = (WorldGuardPlugin)plugin;
// Get correct WorldGuardInterface (handles things that changed version to version)
try {
rawWgVersion = worldGuard.getDescription().getVersion();
if(rawWgVersion.contains("-SNAPSHOT;")) {
String buildNumber = rawWgVersion.substring(rawWgVersion.indexOf("-SNAPSHOT;") + 10);
if(buildNumber.contains("-")) {
buildNumber = buildNumber.substring(0, buildNumber.indexOf('-'));
if (Utils.isNumeric(buildNumber)) {
build = Integer.parseInt(buildNumber);
} else {
warn("Could not correctly parse the build of WorldGuard, raw version: " + rawWgVersion + ", buildNumber: " + buildNumber);
}
}
}
// Clear stuff from the version string that is not a number
String[] versionParts = rawWgVersion.split("\\.");
for(int i = 0; i < versionParts.length; i++) {
Pattern pattern = Pattern.compile("^\\d+");
Matcher matcher = pattern.matcher(versionParts[i]);
if(matcher.find()) {
versionParts[i] = matcher.group();
}
}
// Find major, minor and fix numbers
try {
if(versionParts.length > 0) {
major = Integer.parseInt(versionParts[0]);
}
if(versionParts.length > 1) {
minor = Integer.parseInt(versionParts[1]);
}
if(versionParts.length > 2) {
fixes = Integer.parseInt(versionParts[2]);
}
} catch(NumberFormatException e) {
warn("Something went wrong while parsing WorldGuard version number: " + rawWgVersion);
}
// Determine correct implementation to use
if(rawWgVersion.startsWith("7.")) {
wgVersion = "7";
}
} catch(Exception e) { // If version detection fails, at least try to load the latest version
warn("Parsing the WorldGuard version failed, assuming version 7:", rawWgVersion);
wgVersion = "7";
}
wgVersion = "WorldGuardHandler" + wgVersion;
this.worldGuard = (WorldGuardPlugin) plugin;
}
DependencyModule dependencyModule = new DependencyModule(worldEdit, worldGuard, getEconomy(), getPermissionProvider());
// Check if FastAsyncWorldEdit is installed
boolean fawe;
try {
Class.forName("com.fastasyncworldedit.core.FaweAPI" );
fawe = true;
} catch (ClassNotFoundException ignore) {
fawe = false;
}
if (fawe) {
weVersion = "FastAsyncWorldEditHandler";
}
DependencyModule dependencyModule = new DependencyModule(this.worldEdit, this.worldGuard, getEconomy(), getPermissionProvider());
// Load WorldEdit
try {
Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers." + weVersion);
// Check if we have a NMSHandler class at that location.
Class<?> clazz = Class.forName("me.wiefferink.areashop.adapters.plugins." + weHandlerVersion);
if(WorldEditInterface.class.isAssignableFrom(clazz)) { // Make sure it actually implements WorldEditInterface
worldEditInterface = (WorldEditInterface)clazz.getConstructor(AreaShopInterface.class).newInstance(this); // Set our handler
}
} catch(Exception e) {
error("Could not load the handler for WorldEdit (tried to load " + weVersion + "), report this problem to the author: " + ExceptionUtils.getStackTrace(e));
error = true;
weVersion = null;
error("Could not load the handler for WorldEdit (tried to load " + weHandlerVersion + "), report this problem to the author: " + ExceptionUtils.getStackTrace(e));
shutdownOnError();
return;
}
// Load WorldGuard
try {
Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers." + wgVersion);
Class<?> clazz = Class.forName("me.wiefferink.areashop.adapters.plugins.WorldGuardHandler");
// Check if we have a NMSHandler class at that location.
if(WorldGuardInterface.class.isAssignableFrom(clazz)) { // Make sure it actually implements WorldGuardInterface
worldGuardInterface = (WorldGuardInterface)clazz.getConstructor(AreaShopInterface.class).newInstance(this); // Set our handler
}
} catch(Exception e) {
error("Could not load the handler for WorldGuard (tried to load " + wgVersion + "), report this problem to the author:" + ExceptionUtils.getStackTrace(e));
error = true;
wgVersion = null;
}
// Load Bukkit implementation
String bukkitHandler;
try {
Class.forName("org.bukkit.block.data.type.WallSign");
bukkitHandler = "1_13";
} catch (ClassNotFoundException e) {
bukkitHandler = "1_12";
error("Could not load the handler for WorldGuard, report this problem to the author:" + ExceptionUtils.getStackTrace(e));
shutdownOnError();
return;
}
try {
Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers.BukkitHandler" + bukkitHandler);
Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers.BukkitHandler1_13");
bukkitInterface = (BukkitInterface)clazz.getConstructor(AreaShopInterface.class).newInstance(this);
} catch (Exception e) {
error("Could not load the Bukkit handler (used for sign updates), tried to load:", bukkitHandler + ", report this problem to the author:", ExceptionUtils.getStackTrace(e));
error = true;
bukkitHandler = null;
error("Could not load the Bukkit handler (used for sign updates), report this problem to the author:", ExceptionUtils.getStackTrace(e));
shutdownOnError();
return;
}
// Check if Vault is present
if(getServer().getPluginManager().getPlugin("Vault") == null) {
error("Vault plugin is not present or has not loaded correctly");
error = true;
shutdownOnError();
return;
}
AreaShopModule asModule = new AreaShopModule(this, messageBridge, nms, bukkitInterface, worldEditInterface, worldGuardInterface, signErrorLogger, dependencyModule);
injector = Guice.createInjector(Stage.PRODUCTION, new BukkitModule(getServer()), asModule);
// Load all data from files and check versions
fileManager = injector.getInstance(FileManager.class);
managers.add(fileManager);
fileManager = injector.getInstance(IFileManager.class);
managers.add((FileManager) fileManager);
boolean loadFilesResult = fileManager.loadFiles(false);
error = error || !loadFilesResult;
// Print loaded version of WG and WE in debug
if(wgVersion != null) {
AreaShop.debug("Loaded ", wgVersion, "(raw version:" + rawWgVersion + ", major:" + major + ", minor:" + minor + ", fixes:" + fixes + ", build:" + build + ", fawe:" + fawe + ")");
}
if(weVersion != null) {
AreaShop.debug("Loaded ", weVersion, "(raw version:" + rawWeVersion + ", beta:" + weBeta + ")");
}
if(bukkitHandler != null) {
AreaShop.debug("Loaded BukkitHandler", bukkitHandler);
}
setupLanguageManager();
if(error) {
error("The plugin has not started, fix the errors listed above");
return;
}
featureManager = injector.getInstance(FeatureManager.class);
featureManager.initializeFeatures(injector);
managers.add(featureManager);
@@ -391,7 +290,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
if(getConfig().getBoolean("checkForUpdates")) {
githubUpdateCheck = new GithubUpdateCheck(
this,
"NLThijs48",
"md5sha256",
"AreaShop"
).withVersionComparator((latestVersion, currentVersion) ->
!cleanVersion(latestVersion).equals(cleanVersion(currentVersion))
@@ -419,6 +318,11 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
}
}
private void shutdownOnError() {
error("The plugin has not started, fix the errors listed above");
getServer().getPluginManager().disablePlugin(this);
}
/**
* Cleanup a version number.
* @param version Version to clean
@@ -660,7 +564,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
* Method to get the FileManager (loads/save regions and can be used to get regions).
* @return The fileManager
*/
public FileManager getFileManager() {
public IFileManager getFileManager() {
return fileManager;
}
@@ -11,7 +11,7 @@ import me.wiefferink.areashop.events.notify.RentedRegionEvent;
import me.wiefferink.areashop.interfaces.WorldEditInterface;
import me.wiefferink.areashop.interfaces.WorldEditSelection;
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RegionFactory;
@@ -164,14 +164,14 @@ public class AddCommand extends CommandAreaShop {
} else {
type = "buy";
}
FileManager.AddResult result = plugin.getFileManager().checkRegionAdd(sender, region, world, isRent ? GeneralRegion.RegionType.RENT : GeneralRegion.RegionType.BUY);
if(result == FileManager.AddResult.ALREADYADDED) {
IFileManager.AddResult result = plugin.getFileManager().checkRegionAdd(sender, region, world, isRent ? GeneralRegion.RegionType.RENT : GeneralRegion.RegionType.BUY);
if(result == IFileManager.AddResult.ALREADYADDED) {
regionsAlready.add(plugin.getFileManager().getRegion(regionName));
} else if(result == FileManager.AddResult.ALREADYADDEDOTHERWORLD) {
} else if(result == IFileManager.AddResult.ALREADYADDEDOTHERWORLD) {
regionsAlreadyOtherWorld.add(plugin.getFileManager().getRegion(regionName));
} else if(result == FileManager.AddResult.BLACKLISTED) {
} else if(result == IFileManager.AddResult.BLACKLISTED) {
namesBlacklisted.add(regionName);
} else if(result == FileManager.AddResult.NOPERMISSION) {
} else if(result == IFileManager.AddResult.NOPERMISSION) {
namesNoPermission.add(regionName);
} else {
// Check if the player should be landlord
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
@@ -23,7 +23,7 @@ public class AddfriendCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Inject
private Plugin plugin;
@@ -4,7 +4,7 @@ import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.features.signs.RegionSign;
import me.wiefferink.areashop.features.signs.SignManager;
import me.wiefferink.areashop.interfaces.BukkitInterface;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.tools.Materials;
import me.wiefferink.areashop.tools.Utils;
@@ -28,7 +28,7 @@ public class AddsignCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Inject
private SignManager signManager;
@Inject
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.command.CommandSender;
@@ -21,7 +21,7 @@ public class BuyCommand extends CommandAreaShop {
@Inject
private Plugin plugin;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -4,7 +4,7 @@ import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.events.ask.DeletingRegionEvent;
import me.wiefferink.areashop.interfaces.WorldEditInterface;
import me.wiefferink.areashop.interfaces.WorldEditSelection;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
@@ -26,7 +26,7 @@ public class DelCommand extends CommandAreaShop {
@Inject
private WorldEditInterface worldEditInterface;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
@@ -22,7 +22,7 @@ public class DelfriendCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.RegionGroup;
import me.wiefferink.areashop.regions.RentRegion;
@@ -27,7 +27,7 @@ public class FindCommand extends CommandAreaShop {
@Inject
private Economy economy;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -3,7 +3,7 @@ package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.interfaces.WorldEditInterface;
import me.wiefferink.areashop.interfaces.WorldEditSelection;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RegionFactory;
import me.wiefferink.areashop.regions.RegionGroup;
@@ -23,7 +23,7 @@ public class GroupaddCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Inject
private RegionFactory regionFactory;
@Inject
@@ -3,7 +3,7 @@ package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.interfaces.WorldEditInterface;
import me.wiefferink.areashop.interfaces.WorldEditSelection;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RegionFactory;
import me.wiefferink.areashop.regions.RegionGroup;
@@ -23,7 +23,7 @@ public class GroupdelCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Inject
private RegionFactory regionFactory;
@Inject
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.RegionGroup;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.command.CommandSender;
@@ -18,7 +18,7 @@ public class GroupinfoCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.command.CommandSender;
@@ -16,7 +16,7 @@ public class GrouplistCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -2,14 +2,13 @@ package me.wiefferink.areashop.commands;
import io.github.bakedlibs.dough.blocks.BlockPosition;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RegionGroup;
import me.wiefferink.areashop.regions.RentRegion;
import me.wiefferink.areashop.tools.Utils;
import me.wiefferink.interactivemessenger.processing.Message;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -17,7 +16,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -30,7 +28,7 @@ public class InfoCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
@@ -24,7 +24,7 @@ public class MeCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.RentRegion;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.command.CommandSender;
@@ -18,7 +18,7 @@ public class RentCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.command.CommandSender;
@@ -18,7 +18,7 @@ public class ResellCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
@@ -20,7 +20,7 @@ public class SchematiceventCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.tools.Utils;
@@ -19,7 +19,7 @@ public class SellCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.RentRegion;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.command.CommandSender;
@@ -19,7 +19,7 @@ public class SetdurationCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Inject
private Plugin plugin;
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.Bukkit;
@@ -20,7 +20,7 @@ public class SetlandlordCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
@@ -24,7 +24,7 @@ public class SetownerCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
@@ -20,7 +20,7 @@ public class SetpriceCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
@@ -17,7 +17,7 @@ public class SetrestoreCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Inject
private Plugin plugin;
@@ -2,7 +2,7 @@ package me.wiefferink.areashop.commands;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
@@ -21,7 +21,7 @@ public class SetteleportCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -8,7 +8,7 @@ import me.wiefferink.areashop.events.ask.AddingRegionEvent;
import me.wiefferink.areashop.interfaces.WorldEditInterface;
import me.wiefferink.areashop.interfaces.WorldEditSelection;
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RegionFactory;
import me.wiefferink.areashop.regions.RegionGroup;
@@ -33,7 +33,7 @@ public class StackCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Inject
private WorldEditInterface worldEditInterface;
@Inject
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.tools.Utils;
import org.bukkit.command.CommandSender;
@@ -18,7 +18,7 @@ public class StopresellCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -17,7 +17,7 @@ public class TeleportCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -1,7 +1,7 @@
package me.wiefferink.areashop.commands;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RentRegion;
import me.wiefferink.areashop.tools.Utils;
@@ -19,7 +19,7 @@ public class UnrentCommand extends CommandAreaShop {
@Inject
private MessageBridge messageBridge;
@Inject
private FileManager fileManager;
private IFileManager fileManager;
@Override
public String getCommandStart() {
@@ -177,7 +177,9 @@ public class RegionSign {
if(!Materials.isSign(block.getType())) {
Material signType = getMaterial();
if (!blockHelper.canPlace(block.getLocation(), Bukkit.createBlockData(signType))) {
AreaShop.warn("Setting sign", key, "of region", getRegion().getName(), "failed, could not set sign block back");
errorLogger.submitWarning("Setting sign" + key + "of region" + getRegion().getName() + "failed, could not set sign block back");
this.remove();
return false;
}
// Don't do physics here, we first need to update the direction
block.setType(signType, false);
@@ -190,7 +192,7 @@ public class RegionSign {
} else if(blockData instanceof org.bukkit.block.data.type.Sign) {
((org.bukkit.block.data.type.Sign) blockData).setRotation(getFacing());
} else {
AreaShop.warn("Failed to update the facing direction of the sign at", getStringLocation(), "to ", getFacing(), ", region:", getRegion().getName());
errorLogger.submitWarning("Failed to update the facing direction of the sign at" + getStringLocation() + "to " + getFacing() + ", region:" + getRegion().getName());
return false;
}
block.setBlockData(blockData);
@@ -9,7 +9,7 @@ import me.wiefferink.areashop.events.ask.AddingRegionEvent;
import me.wiefferink.areashop.events.notify.UpdateRegionEvent;
import me.wiefferink.areashop.interfaces.BukkitInterface;
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.managers.SignLinkerManager;
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
import me.wiefferink.areashop.regions.BuyRegion;
@@ -50,7 +50,7 @@ public class SignListener implements Listener {
private final BukkitInterface bukkitInterface;
private final WorldGuardInterface worldGuardInterface;
private final RegionFactory regionFactory;
private final FileManager fileManager;
private final IFileManager fileManager;
public SignListener(
@Nonnull AreaShop plugin,
@@ -61,7 +61,7 @@ public class SignListener implements Listener {
@Nonnull BukkitInterface bukkitInterface,
@Nonnull WorldGuardInterface worldGuardInterface,
@Nonnull SignManager signManager,
@Nonnull FileManager fileManager) {
@Nonnull IFileManager fileManager) {
this.fileManager = fileManager;
this.signManager = signManager;
this.signLinkerManager = signLinkerManager;
@@ -252,14 +252,14 @@ public class SignListener implements Listener {
return;
}
FileManager.AddResult addResult = fileManager.checkRegionAdd(player, regionManager.getRegion(secondLine), event.getPlayer().getWorld(), GeneralRegion.RegionType.RENT);
if(addResult == FileManager.AddResult.BLACKLISTED) {
IFileManager.AddResult addResult = fileManager.checkRegionAdd(player, regionManager.getRegion(secondLine), event.getPlayer().getWorld(), GeneralRegion.RegionType.RENT);
if(addResult == IFileManager.AddResult.BLACKLISTED) {
messageBridge.message(player, "setup-blacklisted", secondLine);
} else if(addResult == FileManager.AddResult.ALREADYADDED) {
} else if(addResult == IFileManager.AddResult.ALREADYADDED) {
messageBridge.message(player, "setup-alreadyRentSign");
} else if(addResult == FileManager.AddResult.ALREADYADDEDOTHERWORLD) {
} else if(addResult == IFileManager.AddResult.ALREADYADDEDOTHERWORLD) {
messageBridge.message(player, "setup-alreadyOtherWorld");
} else if(addResult == FileManager.AddResult.NOPERMISSION) {
} else if(addResult == IFileManager.AddResult.NOPERMISSION) {
messageBridge.message(player, "setup-noPermission", secondLine);
} else if(thirdLine != null && !thirdLine.isEmpty() && !Utils.checkTimeFormat(thirdLine)) {
messageBridge.message(player, "setup-wrongDuration");
@@ -357,14 +357,14 @@ public class SignListener implements Listener {
messageBridge.message(player, "cmd-noRegion", secondLine);
return;
}
FileManager.AddResult addResult = plugin.getFileManager().checkRegionAdd(player, region, event.getPlayer().getWorld(), GeneralRegion.RegionType.BUY);
if(addResult == FileManager.AddResult.BLACKLISTED) {
IFileManager.AddResult addResult = plugin.getFileManager().checkRegionAdd(player, region, event.getPlayer().getWorld(), GeneralRegion.RegionType.BUY);
if(addResult == IFileManager.AddResult.BLACKLISTED) {
messageBridge.message(player, "setup-blacklisted", secondLine);
} else if(addResult == FileManager.AddResult.ALREADYADDED) {
} else if(addResult == IFileManager.AddResult.ALREADYADDED) {
messageBridge.message(player, "setup-alreadyRentSign");
} else if(addResult == FileManager.AddResult.ALREADYADDEDOTHERWORLD) {
} else if(addResult == IFileManager.AddResult.ALREADYADDEDOTHERWORLD) {
messageBridge.message(player, "setup-alreadyOtherWorld");
} else if(addResult == FileManager.AddResult.NOPERMISSION) {
} else if(addResult == IFileManager.AddResult.NOPERMISSION) {
messageBridge.message(player, "setup-noPermission", secondLine);
} else {
double price = 0.0;
@@ -8,7 +8,7 @@ import me.wiefferink.areashop.AreaShop;
import me.wiefferink.areashop.MessageBridge;
import me.wiefferink.areashop.interfaces.BukkitInterface;
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.managers.SignLinkerManager;
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
import me.wiefferink.areashop.regions.RegionFactory;
@@ -33,7 +33,7 @@ public class SignsModule extends AbstractModule {
@Nonnull BukkitInterface bukkitInterface,
@Nonnull WorldGuardInterface worldGuardInterface,
@Nonnull SignManager signManager,
@Nonnull FileManager fileManager
@Nonnull IFileManager fileManager
) {
final SignListener signListener = new SignListener(
plugin,
@@ -56,7 +56,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Singleton
public class FileManager extends Manager {
public class FileManager extends Manager implements IFileManager {
private final AreaShop plugin;
private final Map<String, GeneralRegion> regions;
@@ -81,25 +81,6 @@ public class FileManager extends Manager {
private final MessageBridge messageBridge;
private final RegionFactory regionFactory;
// Enum for region types
public enum AddResult {
BLACKLISTED("blacklisted"),
NOPERMISSION("nopermission"),
ALREADYADDED("alreadyadded"),
ALREADYADDEDOTHERWORLD("alreadyaddedotherworld"),
SUCCESS("success");
private final String value;
AddResult(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
/**
* Constructor, initialize variabeles.
*/
@@ -154,6 +135,7 @@ public class FileManager extends Manager {
* Get the folder where schematics are stored.
* @return The folder where schematics are stored
*/
@Override
public String getSchematicFolder() {
return schemFolder;
}
@@ -163,6 +145,7 @@ public class FileManager extends Manager {
* @param name The name of the group to get (will be normalized)
* @return The group if found, otherwise null
*/
@Override
public RegionGroup getGroup(String name) {
return groups.get(name.toLowerCase());
}
@@ -171,6 +154,7 @@ public class FileManager extends Manager {
* Get all groups.
* @return Collection with all groups (safe to modify)
*/
@Override
public Collection<RegionGroup> getGroups() {
return groups.values();
}
@@ -179,6 +163,7 @@ public class FileManager extends Manager {
* Get the default region settings as provided by the user (default.yml).
* @return YamlConfiguration with the settings (might miss settings, which should be filled in with {@link #getFallbackRegionSettings()})
*/
@Override
public YamlConfiguration getRegionSettings() {
return defaultConfig;
}
@@ -187,6 +172,7 @@ public class FileManager extends Manager {
* Get the default regions settings as provided by AreaShop (default.yml).
* @return YamlConfiguration with the default settings
*/
@Override
public YamlConfiguration getFallbackRegionSettings() {
return defaultConfigFallback;
}
@@ -195,6 +181,7 @@ public class FileManager extends Manager {
* Get the config file (config.yml).
* @return YamlConfiguration with the settings of users, with fallback to the settings provided by AreaShop
*/
@Override
public YamlConfiguration getConfig() {
return config;
}
@@ -204,6 +191,7 @@ public class FileManager extends Manager {
* @param name The name of the region to get (will be normalized)
* @return The region if found, otherwise null
*/
@Override
public @Nullable GeneralRegion getRegion(String name) {
return regions.get(name.toLowerCase());
}
@@ -213,6 +201,7 @@ public class FileManager extends Manager {
* @param name The name of the rental region (will be normalized)
* @return RentRegion if it could be found, otherwise null
*/
@Override
public @Nullable RentRegion getRent(String name) {
return rents.get(name.toLowerCase(Locale.ENGLISH));
}
@@ -222,6 +211,7 @@ public class FileManager extends Manager {
* @param name The name of the buy region (will be normalized)
* @return BuyRegion if it could be found, otherwise null
*/
@Override
public @Nullable BuyRegion getBuy(String name) {
return buys.get(name.toLowerCase(Locale.ENGLISH));
}
@@ -230,6 +220,7 @@ public class FileManager extends Manager {
* Get all rental regions.
* @return List of all rental regions
*/
@Override
public Collection<RentRegion> getRents() {
return new ArrayList<>(rents.values());
}
@@ -238,6 +229,7 @@ public class FileManager extends Manager {
* Get all rental regions.
* @return List of all rental regions
*/
@Override
public Collection<RentRegion> getRentsRef() {
return Collections.unmodifiableCollection(rents.values());
}
@@ -246,10 +238,12 @@ public class FileManager extends Manager {
* Get all buy regions.
* @return List of all buy regions
*/
@Override
public List<BuyRegion> getBuys() {
return new ArrayList<>(buys.values());
}
@Override
public Collection<BuyRegion> getBuysRef() {
return Collections.unmodifiableCollection(buys.values());
}
@@ -259,6 +253,7 @@ public class FileManager extends Manager {
* Get all regions.
* @return List of all regions (it is safe to modify the list)
*/
@Override
public List<GeneralRegion> getRegions() {
return new ArrayList<>(regions.values());
}
@@ -267,6 +262,7 @@ public class FileManager extends Manager {
* Get all regions.
* @return List of all regions (it is safe to modify the list)
*/
@Override
public Collection<GeneralRegion> getRegionsRef() {
return Collections.unmodifiableCollection(regions.values());
}
@@ -275,6 +271,7 @@ public class FileManager extends Manager {
* Get a list of names of all buy regions.
* @return A String list with all the names
*/
@Override
public List<String> getBuyNames() {
ArrayList<String> result = new ArrayList<>(buys.size());
for(BuyRegion region : buys.values()) {
@@ -287,6 +284,7 @@ public class FileManager extends Manager {
* Get a list of names of all rent regions.
* @return A String list with all the names
*/
@Override
public List<String> getRentNames() {
ArrayList<String> result = new ArrayList<>(rents.size());
for(RentRegion region : rents.values()) {
@@ -299,6 +297,7 @@ public class FileManager extends Manager {
* Get a list of names of all regions.
* @return A String list with all the names
*/
@Override
public List<String> getRegionNames() {
ArrayList<String> result = new ArrayList<>(regions.size());
for(GeneralRegion region : regions.values()) {
@@ -311,6 +310,7 @@ public class FileManager extends Manager {
* Get a list of names of all groups.
* @return A String list with all the names
*/
@Override
public List<String> getGroupNames() {
ArrayList<String> result = new ArrayList<>();
for(RegionGroup group : groups.values()) {
@@ -324,6 +324,7 @@ public class FileManager extends Manager {
* @param region Then region to add
* @return true when successful, otherwise false (denied by an event listener)
*/
@Override
public AddingRegionEvent addRegion(GeneralRegion region) {
AddingRegionEvent event = addRegionNoSave(region);
if (event.isCancelled()) {
@@ -339,6 +340,7 @@ public class FileManager extends Manager {
* @param region The region to add
* @return true when successful, otherwise false (denied by an event listener)
*/
@Override
public AddingRegionEvent addRegionNoSave(GeneralRegion region) {
AddingRegionEvent event = new AddingRegionEvent(region);
if(region == null) {
@@ -364,6 +366,7 @@ public class FileManager extends Manager {
/**
* Mark all RegionGroups that they should regenerate regions.
*/
@Override
public void markGroupsAutoDirty() {
for(RegionGroup group : getGroups()) {
group.autoDirty();
@@ -374,6 +377,7 @@ public class FileManager extends Manager {
* Add a RegionGroup.
* @param group The RegionGroup to add
*/
@Override
public void addGroup(RegionGroup group) {
groups.put(group.getName().toLowerCase(), group);
String lowGroup = group.getName().toLowerCase();
@@ -390,7 +394,11 @@ public class FileManager extends Manager {
* @param type The type the region should have in AreaShop
* @return The result if a player would want to add this region
*/
public AddResult checkRegionAdd(CommandSender sender, ProtectedRegion region, World world, RegionType type) {
@Override
public AddResult checkRegionAdd(CommandSender sender,
ProtectedRegion region,
World world,
RegionType type) {
Player player = null;
if(sender instanceof Player) {
player = (Player)sender;
@@ -432,6 +440,7 @@ public class FileManager extends Manager {
* @param giveMoneyBack use true to give money back to the player if someone is currently holding this region, otherwise false
* @return true if the region has been removed, false otherwise
*/
@Override
public DeletingRegionEvent deleteRegion(GeneralRegion region, boolean giveMoneyBack) {
DeletingRegionEvent event = new DeletingRegionEvent(region);
if(region == null) {
@@ -496,6 +505,7 @@ public class FileManager extends Manager {
* Remove a group.
* @param group Group to remove
*/
@Override
public void removeGroup(RegionGroup group) {
groups.remove(group.getLowerCaseName());
groupsConfig.set(group.getLowerCaseName(), null);
@@ -505,6 +515,7 @@ public class FileManager extends Manager {
/**
* Update all signs that need periodic updating.
*/
@Override
public void performPeriodicSignUpdate() {
Do.forAll(
plugin.getConfig().getInt("signs.regionsPerTick"),
@@ -520,6 +531,7 @@ public class FileManager extends Manager {
/**
* Send out rent expire warnings.
*/
@Override
public void sendRentExpireWarnings() {
Do.forAll(
plugin.getConfig().getInt("expireWarning.regionsPerTick"),
@@ -533,7 +545,9 @@ public class FileManager extends Manager {
* @param regions Regions to update
* @param confirmationReceiver The CommandSender that should be notified at completion
*/
public void updateRegions(final Collection<GeneralRegion> regions, final CommandSender confirmationReceiver) {
@Override
public void updateRegions(final Collection<GeneralRegion> regions,
final CommandSender confirmationReceiver) {
final int regionsPerTick = plugin.getConfig().getInt("update.regionsPerTick");
if(confirmationReceiver != null) {
messageBridge.message(confirmationReceiver, "reload-updateStart", regions.size(), regionsPerTick * 20);
@@ -554,6 +568,7 @@ public class FileManager extends Manager {
* Update a list of regions.
* @param regions The list of regions to update.
*/
@Override
public void updateRegions(Collection<GeneralRegion> regions) {
updateRegions(regions, null);
}
@@ -561,6 +576,7 @@ public class FileManager extends Manager {
/**
* Update all regions, happens in a task to minimize lag.
*/
@Override
public void updateAllRegions() {
updateRegions(getRegionsRef(), null);
}
@@ -569,6 +585,7 @@ public class FileManager extends Manager {
* Update all regions.
* @param confirmationReceiver Optional CommandSender that should receive progress messages
*/
@Override
public void updateAllRegions(CommandSender confirmationReceiver) {
updateRegions(getRegionsRef(), confirmationReceiver);
}
@@ -577,6 +594,7 @@ public class FileManager extends Manager {
/**
* Save the group file to disk.
*/
@Override
public void saveGroupsIsRequired() {
saveGroupsRequired = true;
}
@@ -585,6 +603,7 @@ public class FileManager extends Manager {
* Check if saving the groups file is required.
* @return true if changes are made and saving is required, otherwise false
*/
@Override
public boolean isSaveGroupsRequired() {
return saveGroupsRequired;
}
@@ -592,6 +611,7 @@ public class FileManager extends Manager {
/**
* Save the groups file to disk synchronously.
*/
@Override
public void saveGroupsNow() {
AreaShop.debug("saveGroupsNow() done");
saveGroupsRequired = false;
@@ -606,6 +626,7 @@ public class FileManager extends Manager {
/**
* Save all region related files spread over time (low load).
*/
@Override
public void saveRequiredFiles() {
if(isSaveGroupsRequired()) {
saveGroupsNow();
@@ -626,6 +647,7 @@ public class FileManager extends Manager {
/**
* Save all region related files directly (only for cases like onDisable()).
*/
@Override
public void saveRequiredFilesAtOnce() {
if(isSaveGroupsRequired()) {
saveGroupsNow();
@@ -642,6 +664,7 @@ public class FileManager extends Manager {
* Indicates that a/multiple WorldGuard regions need to be saved.
* @param worldName The world where the regions that should be saved is in
*/
@Override
public void saveIsRequiredForRegionWorld(String worldName) {
worldRegionsRequireSaving.add(worldName);
}
@@ -649,6 +672,7 @@ public class FileManager extends Manager {
/**
* Save all worldGuard regions that need saving.
*/
@Override
public void saveWorldGuardRegions() {
for(String world : worldRegionsRequireSaving) {
World bukkitWorld = Bukkit.getWorld(world);
@@ -669,6 +693,7 @@ public class FileManager extends Manager {
* Get the folder the region files are located in.
* @return The folder where the region.yml files are in
*/
@Override
public String getRegionFolder() {
return regionsPath;
}
@@ -678,6 +703,7 @@ public class FileManager extends Manager {
* @param region The region name to check
* @return true if the region may not be added, otherwise false
*/
@Override
public boolean isBlacklisted(String region) {
for(String line : plugin.getConfig().getStringList("blacklist")) {
Pattern pattern = Pattern.compile(line, Pattern.CASE_INSENSITIVE);
@@ -692,6 +718,7 @@ public class FileManager extends Manager {
/**
* Unrent regions that have no time left, regions to check per tick is in the config.
*/
@Override
public void checkRents() {
Do.forAll(
plugin.getConfig().getInt("expiration.regionsPerTick"),
@@ -703,6 +730,7 @@ public class FileManager extends Manager {
/**
* Check all regions and unrent/sell them if the player is inactive for too long.
*/
@Override
public void checkForInactiveRegions() {
Do.forAll(
plugin.getConfig().getInt("inactive.regionsPerTick"),
@@ -715,6 +743,7 @@ public class FileManager extends Manager {
/**
* Load the file with the versions, used to check if the other files need conversion.
*/
@Override
@SuppressWarnings("unchecked")
public void loadVersions() {
File file = new File(versionPath);
@@ -737,6 +766,7 @@ public class FileManager extends Manager {
/**
* Save the versions file to disk.
*/
@Override
public void saveVersions() {
if(!(new File(versionPath).exists())) {
AreaShop.debug("versions file created, this should happen only after installing or upgrading the plugin");
@@ -753,6 +783,7 @@ public class FileManager extends Manager {
* @param thisTick Load files in the current tick or a tick later
* @return true if the files are loaded correctly, otherwise false
*/
@Override
public boolean loadFiles(boolean thisTick) {
// Load config.yml + add defaults from .jar
boolean result = loadConfigFile();
@@ -784,6 +815,7 @@ public class FileManager extends Manager {
* Load the default.yml file
* @return true if it has been loaded successfully, otherwise false
*/
@Override
public boolean loadDefaultFile() {
boolean result = true;
File defaultFile = new File(defaultPath);
@@ -824,6 +856,7 @@ public class FileManager extends Manager {
* Load the default.yml file
* @return true if it has been loaded successfully, otherwise false
*/
@Override
public boolean loadConfigFile() {
boolean result = true;
File configFile = new File(configPath);
@@ -878,6 +911,7 @@ public class FileManager extends Manager {
* Load the groups.yml file from disk
* @return true if succeeded, otherwise false
*/
@Override
public boolean loadGroupsFile() {
boolean result = true;
File groupFile = new File(groupsPath);
@@ -903,6 +937,7 @@ public class FileManager extends Manager {
/**
* Load all region files.
*/
@Override
public void loadRegionFiles() {
regions.clear();
final File file = new File(regionsPath);
@@ -928,7 +963,7 @@ public class FileManager extends Manager {
List<String> noRegionType = new ArrayList<>();
List<String> noNamePaths = new ArrayList<>();
List<GeneralRegion> noWorld = new ArrayList<>();
List<GeneralRegion> noRegion = new ArrayList<>();
Map<GeneralRegion, File> noRegion = new HashMap<>();
List<GeneralRegion> incorrectDuration = new ArrayList<>();
for(File regionFile : regionFiles) {
if(regionFile.exists() && regionFile.isFile() && !regionFile.isHidden()) {
@@ -941,6 +976,8 @@ public class FileManager extends Manager {
regionConfig = YamlConfiguration.loadConfiguration(reader);
if(regionConfig.getKeys(false).isEmpty()) {
AreaShop.warn("Region file '" + regionFile.getName() + "' is empty, check for errors in the log.");
regionFile.delete();
continue;
}
} catch(IOException e) {
AreaShop.warn("Something went wrong reading region file: " + regionFile.getAbsolutePath());
@@ -966,7 +1003,7 @@ public class FileManager extends Manager {
} else if(region.getWorld() == null) {
noWorld.add(region);
} else if(region.getRegion() == null) {
noRegion.add(region);
noRegion.put(region, regionFile);
} else if(region instanceof RentRegion && !Utils.checkTimeFormat(((RentRegion)region).getDurationString())) {
incorrectDuration.add(region);
} else {
@@ -990,11 +1027,11 @@ public class FileManager extends Manager {
if(!noRegion.isEmpty()) {
List<String> noRegionNames = new ArrayList<>();
for(GeneralRegion region : noRegion) {
noRegionNames.add(region.getName());
for(Map.Entry<GeneralRegion, File> regionMap : noRegion.entrySet()) {
noRegionNames.add(regionMap.getKey().getName());
regionMap.getValue().delete();
}
AreaShop.warn("AreaShop regions that are missing their WorldGuard region: " + Utils.createCommaSeparatedList(noRegionNames));
AreaShop.warn("Remove these regions from AreaShop with '/as del' or recreate their regions in WorldGuard.");
AreaShop.warn("AreaShop regions that are missing their WorldGuard region are now being deleted: " + Utils.createCommaSeparatedList(noRegionNames));
}
boolean noWorldRegions = !noWorld.isEmpty();
@@ -1345,6 +1382,7 @@ public class FileManager extends Manager {
* @param groupName Name of the group to get the settings from
* @return The settings of the group
*/
@Override
public ConfigurationSection getGroupSettings(String groupName) {
return groupsConfig.getConfigurationSection(groupName.toLowerCase());
}
@@ -1355,6 +1393,7 @@ public class FileManager extends Manager {
* @param path The path to set
* @param setting The value to set
*/
@Override
public void setGroupSetting(RegionGroup group, String path, Object setting) {
groupsConfig.set(group.getName().toLowerCase() + "." + path, setting);
}
@@ -0,0 +1,395 @@
package me.wiefferink.areashop.managers;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.wiefferink.areashop.events.ask.AddingRegionEvent;
import me.wiefferink.areashop.events.ask.DeletingRegionEvent;
import me.wiefferink.areashop.regions.BuyRegion;
import me.wiefferink.areashop.regions.GeneralRegion;
import me.wiefferink.areashop.regions.RegionGroup;
import me.wiefferink.areashop.regions.RentRegion;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
public interface IFileManager {
/**
* Get the folder where schematics are stored.
*
* @return The folder where schematics are stored
*/
String getSchematicFolder();
/**
* Get a group.
*
* @param name The name of the group to get (will be normalized)
* @return The group if found, otherwise null
*/
RegionGroup getGroup(String name);
/**
* Get all groups.
*
* @return Collection with all groups (safe to modify)
*/
Collection<RegionGroup> getGroups();
/**
* Get the default region settings as provided by the user (default.yml).
*
* @return YamlConfiguration with the settings (might miss settings, which should be filled in with {@link #getFallbackRegionSettings()})
*/
YamlConfiguration getRegionSettings();
/**
* Get the default regions settings as provided by AreaShop (default.yml).
*
* @return YamlConfiguration with the default settings
*/
YamlConfiguration getFallbackRegionSettings();
/**
* Get the config file (config.yml).
*
* @return YamlConfiguration with the settings of users, with fallback to the settings provided by AreaShop
*/
YamlConfiguration getConfig();
/**
* Get a region.
*
* @param name The name of the region to get (will be normalized)
* @return The region if found, otherwise null
*/
@Nullable
GeneralRegion getRegion(String name);
/**
* Get a rental region.
*
* @param name The name of the rental region (will be normalized)
* @return RentRegion if it could be found, otherwise null
*/
@Nullable
RentRegion getRent(String name);
/**
* Get a buy region.
*
* @param name The name of the buy region (will be normalized)
* @return BuyRegion if it could be found, otherwise null
*/
@Nullable
BuyRegion getBuy(String name);
/**
* Get all rental regions.
*
* @return List of all rental regions
*/
Collection<RentRegion> getRents();
/**
* Get all rental regions.
*
* @return List of all rental regions
*/
Collection<RentRegion> getRentsRef();
/**
* Get all buy regions.
*
* @return List of all buy regions
*/
List<BuyRegion> getBuys();
Collection<BuyRegion> getBuysRef();
/**
* Get all regions.
*
* @return List of all regions (it is safe to modify the list)
*/
List<GeneralRegion> getRegions();
/**
* Get all regions.
*
* @return List of all regions (it is safe to modify the list)
*/
Collection<GeneralRegion> getRegionsRef();
/**
* Get a list of names of all buy regions.
*
* @return A String list with all the names
*/
List<String> getBuyNames();
/**
* Get a list of names of all rent regions.
*
* @return A String list with all the names
*/
List<String> getRentNames();
/**
* Get a list of names of all regions.
*
* @return A String list with all the names
*/
List<String> getRegionNames();
/**
* Get a list of names of all groups.
*
* @return A String list with all the names
*/
List<String> getGroupNames();
/**
* Add a region to the list and mark it as to-be-saved.
*
* @param region Then region to add
* @return true when successful, otherwise false (denied by an event listener)
*/
AddingRegionEvent addRegion(GeneralRegion region);
/**
* Add a region to the list without saving it to disk (useful for loading at startup).
*
* @param region The region to add
* @return true when successful, otherwise false (denied by an event listener)
*/
AddingRegionEvent addRegionNoSave(GeneralRegion region);
/**
* Mark all RegionGroups that they should regenerate regions.
*/
void markGroupsAutoDirty();
/**
* Add a RegionGroup.
*
* @param group The RegionGroup to add
*/
void addGroup(RegionGroup group);
/**
* Check if a player can add a certain region as rent or buy region.
*
* @param sender The player/console that wants to add a region
* @param region The WorldGuard region to add
* @param world The world the ProtectedRegion is located in
* @param type The type the region should have in AreaShop
* @return The result if a player would want to add this region
*/
AddResult checkRegionAdd(CommandSender sender,
ProtectedRegion region,
World world,
GeneralRegion.RegionType type);
/**
* Remove a region from the list.
*
* @param region The region to remove
* @param giveMoneyBack use true to give money back to the player if someone is currently holding this region, otherwise false
* @return true if the region has been removed, false otherwise
*/
DeletingRegionEvent deleteRegion(GeneralRegion region, boolean giveMoneyBack);
/**
* Remove a group.
*
* @param group Group to remove
*/
void removeGroup(RegionGroup group);
/**
* Update all signs that need periodic updating.
*/
void performPeriodicSignUpdate();
/**
* Send out rent expire warnings.
*/
void sendRentExpireWarnings();
/**
* Update regions in a task to minimize lag.
*
* @param regions Regions to update
* @param confirmationReceiver The CommandSender that should be notified at completion
*/
void updateRegions(Collection<GeneralRegion> regions, CommandSender confirmationReceiver);
/**
* Update a list of regions.
*
* @param regions The list of regions to update.
*/
void updateRegions(Collection<GeneralRegion> regions);
/**
* Update all regions, happens in a task to minimize lag.
*/
void updateAllRegions();
/**
* Update all regions.
*
* @param confirmationReceiver Optional CommandSender that should receive progress messages
*/
void updateAllRegions(CommandSender confirmationReceiver);
/**
* Save the group file to disk.
*/
void saveGroupsIsRequired();
/**
* Check if saving the groups file is required.
*
* @return true if changes are made and saving is required, otherwise false
*/
boolean isSaveGroupsRequired();
/**
* Save the groups file to disk synchronously.
*/
void saveGroupsNow();
/**
* Save all region related files spread over time (low load).
*/
void saveRequiredFiles();
/**
* Save all region related files directly (only for cases like onDisable()).
*/
void saveRequiredFilesAtOnce();
/**
* Indicates that a/multiple WorldGuard regions need to be saved.
*
* @param worldName The world where the regions that should be saved is in
*/
void saveIsRequiredForRegionWorld(String worldName);
/**
* Save all worldGuard regions that need saving.
*/
void saveWorldGuardRegions();
/**
* Get the folder the region files are located in.
*
* @return The folder where the region.yml files are in
*/
String getRegionFolder();
/**
* Check if a region is on the adding blacklist.
*
* @param region The region name to check
* @return true if the region may not be added, otherwise false
*/
boolean isBlacklisted(String region);
/**
* Unrent regions that have no time left, regions to check per tick is in the config.
*/
void checkRents();
/**
* Check all regions and unrent/sell them if the player is inactive for too long.
*/
void checkForInactiveRegions();
/**
* Load the file with the versions, used to check if the other files need conversion.
*/
@SuppressWarnings("unchecked")
void loadVersions();
/**
* Save the versions file to disk.
*/
void saveVersions();
/**
* Load all files from disk.
*
* @param thisTick Load files in the current tick or a tick later
* @return true if the files are loaded correctly, otherwise false
*/
boolean loadFiles(boolean thisTick);
/**
* Load the default.yml file
*
* @return true if it has been loaded successfully, otherwise false
*/
boolean loadDefaultFile();
/**
* Load the default.yml file
*
* @return true if it has been loaded successfully, otherwise false
*/
boolean loadConfigFile();
/**
* Load the groups.yml file from disk
*
* @return true if succeeded, otherwise false
*/
boolean loadGroupsFile();
/**
* Load all region files.
*/
void loadRegionFiles();
/**
* Get the settings of a group.
*
* @param groupName Name of the group to get the settings from
* @return The settings of the group
*/
ConfigurationSection getGroupSettings(String groupName);
/**
* Set a setting for a group.
*
* @param group The group to set it for
* @param path The path to set
* @param setting The value to set
*/
void setGroupSetting(RegionGroup group, String path, Object setting);
// Enum for region types
public enum AddResult {
BLACKLISTED("blacklisted"),
NOPERMISSION("nopermission"),
ALREADYADDED("alreadyadded"),
ALREADYADDEDOTHERWORLD("alreadyaddedotherworld"),
SUCCESS("success");
private final String value;
AddResult(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
}
@@ -12,6 +12,7 @@ import me.wiefferink.areashop.interfaces.WorldEditInterface;
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import me.wiefferink.areashop.managers.CommandManager;
import me.wiefferink.areashop.managers.FeatureManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.SignErrorLogger;
import me.wiefferink.areashop.managers.SignLinkerManager;
@@ -67,7 +68,7 @@ public class AreaShopModule extends AbstractModule {
bind(WorldEditInterface.class).toInstance(this.worldEditInterface);
bind(SignErrorLogger.class).toInstance(this.signErrorLogger);
// Setup managers
bind(FileManager.class).asEagerSingleton();
bind(IFileManager.class).to(FileManager.class).asEagerSingleton();
bind(FeatureManager.class).in(Singleton.class);
bind(CommandManager.class).in(Singleton.class);
bind(SignLinkerManager.class).in(Singleton.class);
@@ -13,7 +13,7 @@ import me.wiefferink.areashop.interfaces.GeneralRegionInterface;
import me.wiefferink.areashop.interfaces.WorldEditInterface;
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import me.wiefferink.areashop.managers.FeatureManager;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import me.wiefferink.areashop.tools.Utils;
import me.wiefferink.bukkitdo.Do;
import me.wiefferink.interactivemessenger.processing.Message;
@@ -415,7 +415,7 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
* Get the FileManager from the plugin.
* @return The FileManager (responsible for saving/loading regions and getting them)
*/
public FileManager getFileManager() {
public IFileManager getFileManager() {
return plugin.getFileManager();
}
@@ -11,7 +11,7 @@ import me.wiefferink.areashop.events.ask.AddingRegionEvent;
import me.wiefferink.areashop.features.signs.RegionSign;
import me.wiefferink.areashop.features.signs.SignManager;
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
@@ -34,7 +34,7 @@ import java.util.UUID;
public class ImportJob {
private final AreaShop plugin;
private final FileManager fileManager;
private final IFileManager fileManager;
private final SignManager signManager;
private final WorldGuardInterface worldGuardInterface;
private final CommandSender sender;
@@ -48,7 +48,7 @@ public class ImportJob {
@AssistedInject
ImportJob(
@Nonnull AreaShop plugin,
@Nonnull FileManager fileManager,
@Nonnull IFileManager fileManager,
@Nonnull SignManager signManager,
@Nonnull WorldGuardInterface worldGuardInterface,
@Nonnull MessageBridge messageBridge,
@@ -2,7 +2,7 @@ package me.wiefferink.areashop.regions;
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
import me.wiefferink.areashop.managers.FileManager;
import me.wiefferink.areashop.managers.IFileManager;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
@@ -16,7 +16,7 @@ import java.util.Set;
public class RegionGroup {
private final Plugin plugin;
private final FileManager fileManager;
private final IFileManager fileManager;
private final String name;
private final Set<String> regions;
private Set<String> autoRegions;
@@ -29,7 +29,7 @@ public class RegionGroup {
* @param name Name of the group, has to be unique
*/
@AssistedInject
RegionGroup(@Nonnull Plugin plugin, @Nonnull FileManager fileManager, @Assisted String name) {
RegionGroup(@Nonnull Plugin plugin, @Nonnull IFileManager fileManager, @Assisted String name) {
this.plugin = plugin;
this.fileManager = fileManager;
this.name = name;
+3 -3
View File
@@ -1,11 +1,11 @@
name: AreaShop
main: me.wiefferink.areashop.AreaShop
version: "@version@"
version: "${version}"
description: "Selling and renting WorldGuard regions to your players, highly configurable."
depend: [Vault, WorldGuard, WorldEdit]
softdepend: [Multiverse-Core, FastAsyncWorldEdit]
author: NLThijs48
website: https://github.com/NLthijs48/AreaShop
website: https://github.com/md5s256/AreaShop
commands:
AreaShop:
description: 'For all commands use /as help.'
@@ -13,7 +13,7 @@ commands:
aliases: [as]
awareness:
- !@UTF8
api-version: 1.13
api-version: 1.17
permissions:
areashop.*:
description: Give access to all commands of AreaShop
@@ -0,0 +1,22 @@
plugins.apply("io.papermc.paperweight.userdev")
dependencies {
paperDevBundle("1.17.1-R0.1-SNAPSHOT")
compileOnly(projects.areashopInterface)
compileOnly(projects.areashopNms)
}
description = "AreaShop NMS Helper 1-17"
tasks {
assemble {
dependsOn("reobfJar")
}
named("reobfJar", io.papermc.paperweight.tasks.RemapJar::class) {
outputJar.set(file("build/libs/${project.name}-${project.version}.jar"))
}
}
@@ -1,12 +1,11 @@
package me.wiefferink.areashop.nms.v1_17_R1;
package me.wiefferink.areashop.adapters.platform.v1_17_R1;
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock;
@@ -20,28 +19,28 @@ public class BlockBehaviourImpl implements BlockBehaviourHelper {
@Override
public boolean canPlace(Location location, BlockData blockData) {
Objects.requireNonNull(location.getWorld(), "Null World!");
final BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
final BlockPos blockPos = new BlockPos(location.getX(), location.getY(), location.getZ());
final CraftWorld craftWorld = (CraftWorld) location.getWorld();
final World world = craftWorld.getHandle();
final ServerLevel world = craftWorld.getHandle();
final CraftBlockData craftBlockData = (CraftBlockData) blockData;
final IBlockData ibd = craftBlockData.getState();
return ibd.canPlace(world, blockPosition);
final BlockState ibd = craftBlockData.getState();
return ibd.canSurvive(world, blockPos);
}
@Override
public boolean isBlockValid(Block block) {
final CraftBlock craftBlock = (CraftBlock) block;
final CraftWorld craftWorld = (CraftWorld) craftBlock.getWorld();
final World world = craftWorld.getHandle();
final IBlockData ibd = craftBlock.getNMS();
return ibd.canPlace(world, craftBlock.getPosition());
final ServerLevel world = craftWorld.getHandle();
final BlockState ibd = craftBlock.getNMS();
return ibd.canSurvive(world, craftBlock.getPosition());
}
@Override
public boolean isBlockStateValid(BlockState blockState) {
public boolean isBlockStateValid(org.bukkit.block.BlockState blockState) {
final CraftBlockState craftBlockState = (CraftBlockState) blockState;
final IBlockData ibd = craftBlockState.getHandle();
return ibd.canPlace(craftBlockState.getBlock().getCraftWorld().getHandle(), craftBlockState.getPosition());
final BlockState ibd = craftBlockState.getHandle();
return ibd.canSurvive(craftBlockState.getBlock().getCraftWorld().getHandle(), craftBlockState.getPosition());
}
}
@@ -1,4 +1,4 @@
package me.wiefferink.areashop.nms.v1_17_R1;
package me.wiefferink.areashop.adapters.platform.v1_17_R1;
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
import me.wiefferink.areashop.nms.NMS;
@@ -0,0 +1,21 @@
plugins.apply("io.papermc.paperweight.userdev")
dependencies {
paperDevBundle("1.18.1-R0.1-SNAPSHOT")
compileOnly(projects.areashopInterface)
compileOnly(projects.areashopNms)
}
description = "AreaShop NMS Helper 1-18"
tasks {
assemble {
dependsOn("reobfJar")
}
named("reobfJar", io.papermc.paperweight.tasks.RemapJar::class) {
outputJar.set(file("build/libs/${project.name}-${project.version}.jar"))
}
}
@@ -0,0 +1,46 @@
package me.wiefferink.areashop.adapters.platform.v1_18_R1;
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_18_R1.block.CraftBlockState;
import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData;
import java.util.Objects;
public class BlockBehaviourImpl implements BlockBehaviourHelper {
@Override
public boolean canPlace(Location location, BlockData blockData) {
Objects.requireNonNull(location.getWorld(), "Null World!");
final BlockPos blockPosition = new BlockPos(location.getX(), location.getY(), location.getZ());
final CraftWorld craftWorld = (CraftWorld) location.getWorld();
final ServerLevel world = craftWorld.getHandle();
final CraftBlockData craftBlockData = (CraftBlockData) blockData;
final BlockState ibd = craftBlockData.getState();
return ibd.canSurvive(world, blockPosition);
}
@Override
public boolean isBlockValid(Block block) {
final CraftBlock craftBlock = (CraftBlock) block;
final CraftWorld craftWorld = (CraftWorld) craftBlock.getWorld();
final ServerLevel world = craftWorld.getHandle();
final BlockState ibd = craftBlock.getNMS();
return ibd.canSurvive(world, craftBlock.getPosition());
}
@Override
public boolean isBlockStateValid(org.bukkit.block.BlockState blockState) {
final CraftBlockState craftBlockState = (CraftBlockState) blockState;
final BlockState ibd = craftBlockState.getHandle();
return ibd.canSurvive(craftBlockState.getBlock().getCraftWorld().getHandle(), craftBlockState.getPosition());
}
}
@@ -0,0 +1,15 @@
package me.wiefferink.areashop.adapters.platform.v1_18_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;
}
}
@@ -0,0 +1,9 @@
dependencies {
compileOnly(libs.spigot)
compileOnly(projects.areashopInterface)
compileOnly(libs.fastasyncworldeditCore)
compileOnly(libs.fastasyncworldeditBukkit)
compileOnly(libs.worldguardCore)
}
description = "AreaShop FastAsyncWorldEdit"
@@ -1,16 +1,17 @@
package me.wiefferink.areashop.handlers;
package me.wiefferink.areashop.adapters.plugins;
import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.extent.clipboard.MemoryOptimizedClipboard;
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader;
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
import com.fastasyncworldedit.core.object.FaweLimit;
import com.fastasyncworldedit.core.util.EditSessionBuilder;
import com.fastasyncworldedit.core.limit.FaweLimit;
import com.google.common.annotations.Beta;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.*;
@@ -115,7 +116,11 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
final CompletableFuture<Boolean> completableFuture = new CompletableFuture<>();
final FaweLimit limit = new FaweLimit();
limit.MAX_CHANGES = pluginInterface.getConfig().getInt("maximumBlocks");
EditSession editSession = new EditSessionBuilder(world).limit(limit).relightMode(RelightMode.OPTIMAL).build();
EditSession editSession = WorldEdit.getInstance().newEditSessionBuilder()
.world(world)
.limit(limit)
.relightMode(RelightMode.OPTIMAL)
.build();
editSession.setReorderMode(EditSession.ReorderMode.MULTI_STAGE);
ProtectedRegion region = regionInterface.getRegion();
final RegionType regionType = region.getType();
@@ -152,7 +157,7 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
}
clipboard.setOrigin(clipboard.getMinimumPoint());
ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard);
session.setBlockChangeLimit(limit.MAX_CHANGES);
session.setBlockChangeLimit((int) limit.MAX_CHANGES);
session.setClipboard(clipboardHolder);
// Build operation
@@ -219,7 +224,11 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
}
final FaweLimit limit = new FaweLimit();
limit.MAX_CHANGES = pluginInterface.getConfig().getInt("maximumBlocks");
EditSession editSession = new EditSessionBuilder(world).relightMode(RelightMode.OPTIMAL).limit(limit).build();
EditSession editSession = WorldEdit.getInstance().newEditSessionBuilder()
.world(world)
.relightMode(RelightMode.OPTIMAL)
.limit(limit)
.build();
final ProtectedRegion region = regionInterface.getRegion();
final BlockVector3 min = region.getMinimumPoint(), max = region.getMaximumPoint();
@@ -0,0 +1,9 @@
dependencies {
compileOnly(libs.spigot)
compileOnly(projects.areashopInterface)
compileOnly(libs.worldeditCore)
compileOnly(libs.worldeditBukkit)
compileOnly(libs.worldguardCore)
}
description = "AreaShop WorldEdit 7"
@@ -1,4 +1,4 @@
package me.wiefferink.areashop.handlers;
package me.wiefferink.areashop.adapters.plugins;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
@@ -37,9 +37,9 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class WorldEditHandler7 extends WorldEditInterface {
public class WorldEditHandler extends WorldEditInterface {
public WorldEditHandler7(AreaShopInterface pluginInterface) {
public WorldEditHandler(AreaShopInterface pluginInterface) {
super(pluginInterface);
}
@@ -0,0 +1,9 @@
dependencies {
compileOnly(libs.spigot)
compileOnly(projects.areashopInterface)
compileOnly(libs.worldeditCore)
compileOnly(libs.worldeditBukkit)
compileOnly(libs.worldguardCore)
}
description = "AreaShop WorldGuard 7"
@@ -1,4 +1,4 @@
package me.wiefferink.areashop.handlers;
package me.wiefferink.areashop.adapters.plugins;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector2;
@@ -27,9 +27,9 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
public class WorldGuardHandler7 extends WorldGuardInterface {
public class WorldGuardHandler extends WorldGuardInterface {
public WorldGuardHandler7(AreaShopInterface pluginInterface) {
public WorldGuardHandler(AreaShopInterface pluginInterface) {
super(pluginInterface);
}
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>
-6
View File
@@ -1,6 +0,0 @@
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly project(':areashop-interface')
}
description = 'AreaShop Bukkit 1.13 and higher'
+6
View File
@@ -0,0 +1,6 @@
dependencies {
compileOnly(libs.spigot)
compileOnly(projects.areashopInterface)
}
description = "AreaShop Bukkit 1.13 and higher"
@@ -9,6 +9,11 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Sign;
import org.bukkit.block.data.type.WallSign;
/**
* Sign handler for 1.13+
* @deprecated Obsolete as we don't support pre-1.13 versions anyway
*/
@Deprecated(forRemoval = true)
public class BukkitHandler1_13 extends BukkitInterface {
public BukkitHandler1_13(AreaShopInterface pluginInterface) {
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>
-7
View File
@@ -1,7 +0,0 @@
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.5'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.5'
}
description = 'AreaShop Interface'
+9
View File
@@ -0,0 +1,9 @@
dependencies {
compileOnly(libs.spigot)
compileOnly(libs.worldeditCore)
compileOnly(libs.worldeditBukkit)
compileOnly(libs.worldguardCore)
compileOnly(libs.worldguardBukkit)
}
description = "AreaShop Interface"
+5
View File
@@ -0,0 +1,5 @@
dependencies {
compileOnly(libs.spigot)
}
description = "AreaShop NMS Interface"
-54
View File
@@ -1,54 +0,0 @@
plugins {
id 'java'
}
group = 'me.wiefferink.areashop'
version = '2.7.0-SNAPSHOT'
subprojects {
plugins.apply('java')
repositories {
mavenCentral()
maven {
name = 'oss-sonatype'
url = uri("https://oss.sonatype.org/content/groups/public/")
}
maven {
name = 'paper-repo'
url = uri('https://papermc.io/repo/repository/maven-public/')
}
maven {
name = 'spigot-repo'
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}
maven {
name = 'jitpack'
url = uri('https://jitpack.io')
content {
includeGroupByRegex("com\\.github.*")
}
}
maven {
name = 'aikar-repo'
url = uri('https://repo.aikar.co/content/groups/aikar/')
}
maven {
name = 'enginehub-repo'
url = uri('https://maven.enginehub.org/repo/')
}
}
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile) {
javaToolchains.compilerFor {
JavaLanguageVersion.of(16)
}
options.release.set(16)
options.encoding = 'UTF-8'
options.fork = true
options.deprecation = true
}
}
}
+84
View File
@@ -0,0 +1,84 @@
plugins {
java
`java-library`
`maven-publish`
id("io.papermc.paperweight.userdev") version "1.3.3" apply false
idea
eclipse
}
group = "me.wiefferink"
version = "2.7.4"
subprojects {
group = rootProject.group
version = rootProject.version
apply {
plugin<JavaPlugin>()
plugin<JavaLibraryPlugin>()
if (project.path.contains("platform").not()) {
plugin<MavenPublishPlugin>()
}
plugin<IdeaPlugin>()
plugin<EclipsePlugin>()
}
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven {
name = "jitpack"
url = uri("https://jitpack.io")
content {
includeGroupByRegex("com\\.github.*")
}
}
maven("https://repo.aikar.co/content/groups/aikar/")
maven("https://maven.enginehub.org/repo/")
}
tasks {
withType(JavaCompile::class) {
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
options.release.set(17)
options.encoding = Charsets.UTF_8.name()
options.isFork = true
options.isDeprecation = true
}
withType(Javadoc::class) {
options.encoding = Charsets.UTF_8.name()
}
withType(ProcessResources::class) {
filteringCharset = Charsets.UTF_8.name()
}
}
if (project.path.contains("platform").not()) {
publishing {
publications {
create<MavenPublication>(project.name) {
from(components["java"])
pom {
scm {
connection.set("scm:git:git://github.com/md5sha256/AreaShop.git")
developerConnection.set("scm:git:ssh://github.com/md5sha256/AreaShop.git")
url.set("https://github.com/md5sha256/AreaShop/tree/dev/bleeding")
}
licenses {
license {
name.set("GNU General Public License v3.0")
url.set("https://github.com/md5sha256/AreaShop/blob/dev/bleeding/LICENSE")
}
}
}
}
}
}
}
}
+3
View File
@@ -0,0 +1,3 @@
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.java.installations.auto-download=false
+29
View File
@@ -0,0 +1,29 @@
[versions]
# Platforms
minecraft = "1.17.1-R0.1-SNAPSHOT"
findbugs = "3.0.2"
# Minecraft Plugins
worldedit = "7.2.8"
worldguard = "7.0.6"
fawe = "2.0.0"
# Gradle plugins
paperweight = "1.3.3"
[libraries]
# Platform
spigot = { group = "org.spigotmc", name = "spigot-api", version.ref = "minecraft" }
findbugs = { group = "com.google.code.findbugs", name = "jsr305", version.ref = "findbugs" }
# Minecraft Plugins
worldeditBukkit = { group = "com.sk89q.worldedit", name = "worldedit-bukkit", version.ref = "worldedit" }
worldeditCore = { group = "com.sk89q.worldedit", name = "worldedit-core", version.ref = "worldedit" }
worldguardBukkit = { group = "com.sk89q.worldguard", name = "worldguard-bukkit", version.ref = "worldguard" }
worldguardCore = { group = "com.sk89q.worldguard", name = "worldguard-core", version.ref = "worldguard" }
fastasyncworldeditBukkit = { group = "com.fastasyncworldedit", name = "FastAsyncWorldEdit-Bukkit", version.ref = "fawe" }
fastasyncworldeditCore = { group = "com.fastasyncworldedit", name = "FastAsyncWorldEdit-Core", version.ref = "fawe" }
[plugins]
# Gradle plugins
paperweightUserdev = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight" }
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>
@@ -1,15 +0,0 @@
repositories {
maven {
name = 'IS-Repo'
url = uri('https://mvn.intellectualsites.com/content/repositories/releases/')
}
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'com.fastasyncworldedit:FAWE-Bukkit:1.17-268'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.5'
compileOnly project(':areashop-interface')
}
description = 'AreaShop FastAsyncWorldEdit'
@@ -1,160 +0,0 @@
package me.wiefferink.areashop.handlers;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.flags.Flag;
import com.sk89q.worldguard.protection.flags.FlagContext;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
import com.sk89q.worldguard.protection.flags.RegionGroup;
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import me.wiefferink.areashop.interfaces.AreaShopInterface;
import me.wiefferink.areashop.interfaces.RegionAccessSet;
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
public class FastAsyncWorldEditWorldGuardHandler extends WorldGuardInterface {
public FastAsyncWorldEditWorldGuardHandler(AreaShopInterface pluginInterface) {
super(pluginInterface);
}
@Override
public RegionManager getRegionManager(World world) {
return WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(world));
}
@Override
public Set<ProtectedRegion> getApplicableRegionsSet(Location location) {
Set<ProtectedRegion> result = new HashSet<>();
BlockVector3 vector = BlockVector3.at(location.getX(), location.getY(), location.getZ());
for(ProtectedRegion region : getRegionManager(location.getWorld()).getRegions().values()) {
if(region.contains(vector)) {
result.add(region);
}
}
return result;
}
/**
* Build a DefaultDomain from a RegionAccessSet.
* @param regionAccessSet RegionAccessSet to read
* @return DefaultDomain containing the entities from the RegionAccessSet
*/
private DefaultDomain buildDomain(RegionAccessSet regionAccessSet) {
DefaultDomain owners = new DefaultDomain();
for(String playerName : regionAccessSet.getPlayerNames()) {
owners.addPlayer(playerName);
}
for(UUID uuid : regionAccessSet.getPlayerUniqueIds()) {
owners.addPlayer(uuid);
}
for(String group : regionAccessSet.getGroupNames()) {
owners.addGroup(group);
}
return owners;
}
@Override
public void setOwners(ProtectedRegion region, RegionAccessSet regionAccessSet) {
DefaultDomain defaultDomain = buildDomain(regionAccessSet);
if(!region.getOwners().toUserFriendlyString().equals(defaultDomain.toUserFriendlyString())) {
region.setOwners(defaultDomain);
}
}
@Override
public void setMembers(ProtectedRegion region, RegionAccessSet regionAccessSet) {
DefaultDomain defaultDomain = buildDomain(regionAccessSet);
if(!region.getMembers().toUserFriendlyString().equals(defaultDomain.toUserFriendlyString())) {
region.setMembers(defaultDomain);
}
}
@Override
public boolean containsMember(ProtectedRegion region, UUID player) {
return region.getMembers().contains(player);
}
@Override
public boolean containsOwner(ProtectedRegion region, UUID player) {
return region.getOwners().contains(player);
}
@Override
public RegionAccessSet getMembers(ProtectedRegion region) {
RegionAccessSet result = new RegionAccessSet();
result.getGroupNames().addAll(region.getMembers().getGroups());
result.getPlayerNames().addAll(region.getMembers().getPlayers());
result.getPlayerUniqueIds().addAll(region.getMembers().getUniqueIds());
return result;
}
@Override
public RegionAccessSet getOwners(ProtectedRegion region) {
RegionAccessSet result = new RegionAccessSet();
result.getGroupNames().addAll(region.getOwners().getGroups());
result.getPlayerNames().addAll(region.getOwners().getPlayers());
result.getPlayerUniqueIds().addAll(region.getOwners().getUniqueIds());
return result;
}
@Override
public Flag<?> fuzzyMatchFlag(String flagName) {
return Flags.fuzzyMatchFlag(WorldGuard.getInstance().getFlagRegistry(), flagName);
}
@Override
public <V> V parseFlagInput(Flag<V> flag, String input) throws InvalidFlagFormat {
return flag.parseInput(FlagContext.create().setInput(input).build());
}
@Override
public RegionGroup parseFlagGroupInput(RegionGroupFlag flag, String input) throws InvalidFlagFormat {
return flag.parseInput(FlagContext.create().setInput(input).build());
}
@Override
public Vector getMinimumPoint(ProtectedRegion region) {
BlockVector3 min = region.getMinimumPoint();
return new Vector(min.getX(), min.getY(), min.getZ());
}
@Override
public Vector getMaximumPoint(ProtectedRegion region) {
BlockVector3 min = region.getMaximumPoint();
return new Vector(min.getX(), min.getY(), min.getZ());
}
@Override
public List<Vector> getRegionPoints(ProtectedRegion region) {
List<Vector> result = new ArrayList<>();
for (BlockVector2 point : region.getPoints()) {
result.add(new Vector(point.getX(), 0,point.getZ()));
}
return result;
}
@Override
public ProtectedCuboidRegion createCuboidRegion(String name, Vector corner1, Vector corner2) {
return new ProtectedCuboidRegion(name, BlockVector3.at(corner1.getBlockX(), corner1.getBlockY(), corner1.getBlockZ()), BlockVector3.at(corner2.getBlockX(), corner2.getBlockY(), corner2.getBlockZ()));
}
}
-12
View File
@@ -1,12 +0,0 @@
repositories {
mavenLocal()
}
dependencies {
compileOnly 'org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT'
compileOnly project(':areashop-interface')
compileOnly project(':areashop-nms')
}
description = 'AreaShop NMS Helper'
-5
View File
@@ -1,5 +0,0 @@
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
}
description = 'AreaShop NMS Interface'
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>
-8
View File
@@ -1,8 +0,0 @@
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.5'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.5'
compileOnly project(':areashop-interface')
}
description = 'AreaShop WorldEdit 7'
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>
-8
View File
@@ -1,8 +0,0 @@
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.5'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.5'
compileOnly project(':areashop-interface')
}
description = 'AreaShop WorldGuard 7'
-15
View File
@@ -1,15 +0,0 @@
rootProject.name = 'areashop-parent'
include(':areashop-bukkit-1_13')
include(':areashop-worldguard-7')
include(':areashop-interface')
include(':areashop-nms')
include(':areashop-nms-1-17')
include(':areashop-worldedit-7')
include(':areashop-fastasyncworldedit')
include(':areashop')
project(':areashop').projectDir = file('AreaShop')
project(':areashop-nms').projectDir = file('hooks/areashop-nms')
project(':areashop-nms-1-17').projectDir = file('hooks/areashop-nms-1-17')
project(':areashop-worldedit-7').projectDir = file('hooks/areashop-worldedit-7')
project(':areashop-worldguard-7').projectDir = file('hooks/areashop-worldguard-7')
project(':areashop-fastasyncworldedit').projectDir = file('hooks/areashop-fastasyncworldedit')
+38
View File
@@ -0,0 +1,38 @@
pluginManagement {
repositories {
gradlePluginPortal()
maven {
name = "paper-repo"
url = uri("https://papermc.io/repo/repository/maven-public/")
}
}
}
buildCache {
local {
directory = File(rootDir, "build-cache")
removeUnusedEntriesAfterDays = 7
}
}
rootProject.name = "areashop-parent"
// Interfaces
include(":areashop-bukkit-1_13")
include(":areashop-interface")
include(":areashop-nms")
// Adapters
include(":adapters:platform:bukkit-1-17")
include(":adapters:platform:bukkit-1-18")
include(":adapters:plugins:worldedit")
include(":adapters:plugins:worldguard")
include(":adapters:plugins:fastasyncworldedit")
// Main project
include(":areashop")
project(":areashop").projectDir = file("AreaShop")
enableFeaturePreview("VERSION_CATALOGS")
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")