mirror of
https://github.com/md5sha256/AreaShop.git
synced 2026-11-06 17:32:43 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d9a58a170 | ||
|
|
e64e884c2a | ||
|
|
6ad4ff9deb | ||
|
|
eec9806492 | ||
|
|
43b2ae8278 | ||
|
|
6d5a92e389 | ||
|
|
7d7a62ffa0 | ||
|
|
44456d87b6 | ||
|
|
d92c710b27 | ||
|
|
3dceaf98cd | ||
|
|
33c29a3756 | ||
|
|
771734360f | ||
|
|
539e908d32 | ||
|
|
088471aa3c | ||
|
|
5a95c95670 | ||
|
|
5a5d627d51 | ||
|
|
9b5434a4b2 | ||
|
|
e13717950b | ||
|
|
03ed2803bd | ||
|
|
b3f1225934 | ||
|
|
68651899b7 | ||
|
|
4a7a4ca4ee | ||
|
|
0d272c8fe9 | ||
|
|
6b2c905939 | ||
|
|
7ab782799b | ||
|
|
bea82eae88 | ||
|
|
4ac0e045bd | ||
|
|
e5061b218e | ||
|
|
40fdfba47d | ||
|
|
e9260cede6 | ||
|
|
bb297c9ff1 | ||
|
|
666742ad56 | ||
|
|
36eb8c3a5e | ||
|
|
06a9f7b28e | ||
|
|
e101780420 | ||
|
|
6abe99e807 | ||
|
|
a1d18521ee |
No files matched your search
@@ -0,0 +1,23 @@
|
||||
name: Java CI with Gradle
|
||||
|
||||
on: [ push, pull_request ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on someone else's repo
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: ["ubuntu-latest", "windows-latest"]
|
||||
runs-on: "${{ matrix.os }}"
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: gradle/wrapper-validation-action@v1.0.4
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'zulu'
|
||||
cache: 'gradle'
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew clean build
|
||||
+20
-37
@@ -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
|
||||
@@ -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,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'
|
||||
@@ -0,0 +1,95 @@
|
||||
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.1.0") {
|
||||
exclude("com.google.guava", "guava")
|
||||
}
|
||||
implementation("com.google.inject.extensions:guice-assistedinject:5.1.0") {
|
||||
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"))
|
||||
runtimeOnly(project(":adapters:platform:bukkit-1-18-1", "reobf"))
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -90,7 +91,7 @@ public final class AreaShop extends JavaPlugin implements AreaShopApi {
|
||||
public static final String defaultFile = "default.yml";
|
||||
public static final String configFile = "config.yml";
|
||||
public static final String configFileHidden = "hiddenConfig.yml";
|
||||
public static final String signLogFile = "sign-errors.yml";
|
||||
public static final String signLogFile = "sign-errors.log";
|
||||
public static final String versionFile = "versions";
|
||||
|
||||
// Euro tag for in the config
|
||||
@@ -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;
|
||||
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;
|
||||
} 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";
|
||||
} else {
|
||||
throw new IllegalStateException("Unknown WE Version: " + worldEdit.getDescription().getVersion());
|
||||
}
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
// Load WorldEdit
|
||||
try {
|
||||
Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers." + weVersion);
|
||||
// Check if we have a NMSHandler class at that location.
|
||||
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;
|
||||
}
|
||||
|
||||
// Load WorldGuard
|
||||
try {
|
||||
Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers." + wgVersion);
|
||||
// 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";
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> clazz = Class.forName("me.wiefferink.areashop.handlers.BukkitHandler" + bukkitHandler);
|
||||
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;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Find WorldEdit integration version to load
|
||||
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");
|
||||
return;
|
||||
} else {
|
||||
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 {
|
||||
weHandlerVersion = "WorldEditHandler";
|
||||
}
|
||||
}
|
||||
|
||||
plugin = getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if(!(plugin instanceof WorldGuardPlugin) || !plugin.isEnabled()) {
|
||||
error("WorldGuard plugin is not present or has not loaded correctly");
|
||||
shutdownOnError();
|
||||
return;
|
||||
} else {
|
||||
this.worldGuard = (WorldGuardPlugin) plugin;
|
||||
}
|
||||
|
||||
DependencyModule dependencyModule = new DependencyModule(this.worldEdit, this.worldGuard, getEconomy(), getPermissionProvider());
|
||||
|
||||
// Load WorldEdit
|
||||
try {
|
||||
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 " + weHandlerVersion + "), report this problem to the author: " + ExceptionUtils.getStackTrace(e));
|
||||
shutdownOnError();
|
||||
return;
|
||||
}
|
||||
|
||||
// Load WorldGuard
|
||||
try {
|
||||
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, report this problem to the author:" + ExceptionUtils.getStackTrace(e));
|
||||
shutdownOnError();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
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), report this problem to the author:", ExceptionUtils.getStackTrace(e));
|
||||
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;
|
||||
@@ -45,6 +45,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class GeneralRegion implements GeneralRegionInterface, Comparable<GeneralRegion>, ReplacementProvider {
|
||||
|
||||
@@ -415,7 +416,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();
|
||||
}
|
||||
|
||||
@@ -809,6 +810,40 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save all blocks in a region for restoring later.
|
||||
* @param fileName The name of the file to save to (extension and folder will be added)
|
||||
* @return true if the region has been saved properly, otherwise false
|
||||
*/
|
||||
public CompletableFuture<Boolean> saveRegionBlocksAsync(String fileName) {
|
||||
if (!worldEditInterface.supportsAsyncOperations()) {
|
||||
return CompletableFuture.completedFuture(saveRegionBlocks(fileName));
|
||||
}
|
||||
// Check if the region is correct
|
||||
ProtectedRegion region = getRegion();
|
||||
if(region == null) {
|
||||
AreaShop.debug("Region '" + getName() + "' does not exist in WorldGuard, save failed");
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
// The path to save the schematic
|
||||
File saveFile = new File(plugin.getFileManager().getSchematicFolder() + File.separator + fileName);
|
||||
// Create parent directories
|
||||
File parent = saveFile.getParentFile();
|
||||
if(parent != null && !parent.exists()) {
|
||||
if(!parent.mkdirs()) {
|
||||
AreaShop.warn("Did not save region " + getName() + ", schematic directory could not be created: " + saveFile.getAbsolutePath());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
}
|
||||
return worldEditInterface.saveRegionBlocksAsync(saveFile, this)
|
||||
.thenApply(result -> {
|
||||
if(result) {
|
||||
AreaShop.debug("Saved schematic async for region " + getName());
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore all blocks in a region for restoring later.
|
||||
* @param fileName The name of the file to save to (extension and folder will be added)
|
||||
@@ -831,6 +866,35 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore all blocks in a region for restoring later.
|
||||
* @param fileName The name of the file to save to (extension and folder will be added)
|
||||
* @return true if the region has been restored properly, otherwise false
|
||||
*/
|
||||
public CompletableFuture<Boolean> restoreRegionBlocksAsync(String fileName) {
|
||||
if (!worldEditInterface.supportsAsyncOperations()) {
|
||||
return CompletableFuture.completedFuture(restoreRegionBlocks(fileName));
|
||||
}
|
||||
if(getRegion() == null) {
|
||||
AreaShop.debug("Region '" + getName() + "' does not exist in WorldGuard, restore failed");
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
// The path to save the schematic
|
||||
File restoreFile = new File(plugin.getFileManager().getSchematicFolder() + File.separator + fileName);
|
||||
return worldEditInterface.restoreRegionBlocksAsync(restoreFile, this)
|
||||
.thenApply(result -> {
|
||||
if(result) {
|
||||
AreaShop.debug("Restored schematic async for region " + getName());
|
||||
// Sync back to main
|
||||
Do.syncLater(10, getSignsFeature().signManager()::update);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reset all flags of the region.
|
||||
*/
|
||||
@@ -1452,14 +1516,23 @@ public abstract class GeneralRegion implements GeneralRegionInterface, Comparabl
|
||||
String save = profileSection.getString(type.getValue() + ".save");
|
||||
String restore = profileSection.getString(type.getValue() + ".restore");
|
||||
// Save the region if needed
|
||||
boolean async = worldEditInterface.supportsAsyncOperations();
|
||||
if(save != null && !save.isEmpty()) {
|
||||
save = Message.fromString(save).replacements(this).getSingle();
|
||||
saveRegionBlocks(save);
|
||||
if (async) {
|
||||
saveRegionBlocksAsync(save);
|
||||
} else {
|
||||
saveRegionBlocks(save);
|
||||
}
|
||||
}
|
||||
// Restore the region if needed
|
||||
if(restore != null && !restore.isEmpty()) {
|
||||
restore = Message.fromString(restore).replacements(this).getSingle();
|
||||
restoreRegionBlocks(restore);
|
||||
if (async) {
|
||||
restoreRegionBlocksAsync(restore);
|
||||
} else {
|
||||
restoreRegionBlocks(restore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -121,6 +121,8 @@ debug: false
|
||||
version: ${project.version}
|
||||
# Maximum number of blocks to save to or restore from a .schemetic file.
|
||||
maximumBlocks: 1000000
|
||||
# Maximum number of entities to save to or restore from a .schematic file (FAWE only)
|
||||
maximumEntities: 1000
|
||||
# Maximum number of locations the teleport function should check to find a safe spot.
|
||||
maximumTries: 50000
|
||||
|
||||
|
||||
@@ -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/md5sha256/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"))
|
||||
}
|
||||
|
||||
}
|
||||
+14
-15
@@ -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
-1
@@ -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"))
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
+15
@@ -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,21 @@
|
||||
plugins.apply("io.papermc.paperweight.userdev")
|
||||
|
||||
dependencies {
|
||||
paperDevBundle("1.18.2-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"))
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_18_R2;
|
||||
|
||||
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_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.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());
|
||||
}
|
||||
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package me.wiefferink.areashop.adapters.platform.v1_18_R2;
|
||||
|
||||
import me.wiefferink.areashop.nms.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.nms.NMS;
|
||||
|
||||
public class NMSImpl implements NMS {
|
||||
|
||||
private final BlockBehaviourImpl blockBehaviourHelper = new BlockBehaviourImpl();
|
||||
|
||||
@Override
|
||||
public BlockBehaviourHelper blockBehaviourHelper() {
|
||||
return this.blockBehaviourHelper;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
dependencies {
|
||||
compileOnly(libs.spigot)
|
||||
compileOnly(projects.areashopInterface)
|
||||
compileOnly(libs.fastasyncworldeditCore)
|
||||
compileOnly(libs.fastasyncworldeditBukkit)
|
||||
compileOnly(libs.worldguardCore)
|
||||
}
|
||||
|
||||
description = "AreaShop FastAsyncWorldEdit"
|
||||
+233
-39
@@ -1,19 +1,23 @@
|
||||
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.internal.exception.FaweException;
|
||||
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.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.*;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
@@ -35,14 +39,12 @@ import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.BoundingBox;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
// Future: this class could use the schematic save/paste api of FAWE: https://github.com/boy0001/FastAsyncWorldedit/wiki/Pasting-a-schematic
|
||||
// This would not allow for shaping the schematic to a polygon region though
|
||||
@@ -57,7 +59,8 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
|
||||
private final BoundingBox boundingBox;
|
||||
|
||||
public RegionBoundMask(final ProtectedRegion region) {
|
||||
final BlockVector3 min = region.getMinimumPoint(), max = region.getMaximumPoint();
|
||||
final BlockVector3 min = region.getMinimumPoint();
|
||||
final BlockVector3 max = region.getMaximumPoint();
|
||||
this.boundingBox = new BoundingBox(min.getX(), min.getY(), min.getZ(), max.getX(), max.getY(), max.getZ());
|
||||
}
|
||||
|
||||
@@ -81,16 +84,19 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAsyncOperations() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Beta
|
||||
public CompletableFuture<Boolean> restoreRegionBlocksAsync(File rawFile, GeneralRegionInterface regionInterface) {
|
||||
File file = null;
|
||||
ClipboardFormat format = null;
|
||||
for (ClipboardFormat formatOption : BuiltInClipboardFormat.values()) {
|
||||
if (new File(rawFile.getAbsolutePath() + "." + formatOption.getPrimaryFileExtension())
|
||||
.exists()) {
|
||||
file = new File(
|
||||
rawFile.getAbsolutePath() + "." + formatOption.getPrimaryFileExtension());
|
||||
format = formatOption;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -99,6 +105,11 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
|
||||
+ ", schematic file does not exist: " + rawFile.getAbsolutePath());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
ClipboardFormat format = ClipboardFormats.findByFile(file);
|
||||
if (format == null) {
|
||||
pluginInterface.debugI("Did not restore region " + regionInterface.getName() + ", could not find a valid clipboard format");
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
pluginInterface.debugI("Trying to restore region", regionInterface.getName(), " from file",
|
||||
file.getAbsolutePath(), "with format", format.getName());
|
||||
|
||||
@@ -112,32 +123,37 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
|
||||
+ regionInterface.getWorldName());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
final CompletableFuture<Boolean> completableFuture = new CompletableFuture<>();
|
||||
final FaweLimit limit = new FaweLimit();
|
||||
final FaweLimit limit = FaweLimit.MAX.copy();
|
||||
limit.MAX_CHANGES = pluginInterface.getConfig().getInt("maximumBlocks");
|
||||
EditSession editSession = new EditSessionBuilder(world).limit(limit).relightMode(RelightMode.OPTIMAL).build();
|
||||
limit.MAX_ENTITIES = pluginInterface.getConfig().getInt("maximumEntities", (int) (limit.MAX_CHANGES / 1000));
|
||||
EditSession editSession = pluginInterface.getWorldEdit().getWorldEdit()
|
||||
.newEditSessionBuilder()
|
||||
.world(world)
|
||||
.limit(limit)
|
||||
.build();
|
||||
editSession.setReorderMode(EditSession.ReorderMode.MULTI_STAGE);
|
||||
ProtectedRegion region = regionInterface.getRegion();
|
||||
final RegionType regionType = region.getType();
|
||||
// Get the origin and size of the region
|
||||
final BlockVector3 origin = BlockVector3
|
||||
.at(region.getMinimumPoint().getBlockX(), region.getMinimumPoint().getBlockY(),
|
||||
BlockVector3 origin = BlockVector3
|
||||
.at(region.getMinimumPoint().getBlockX(),
|
||||
region.getMinimumPoint().getBlockY(),
|
||||
region.getMinimumPoint().getBlockZ());
|
||||
final RegionBoundMask mask = new RegionBoundMask(region);
|
||||
final File finalFile = file;
|
||||
final String regionName = regionInterface.getName();
|
||||
final double regionWidth = regionInterface.getWidth(), regionHeight = regionInterface.getHeight(), regionDepth = regionInterface.getDepth();
|
||||
final LocalSession session =
|
||||
new LocalSession(pluginInterface.getWorldEdit().getLocalConfiguration());
|
||||
final CompletableFuture<Boolean> completableFuture = new CompletableFuture<>();
|
||||
final RegionType regionType = region.getType();
|
||||
final Mask mask = new RegionBoundMask(region);
|
||||
FaweAPI.getTaskManager().async(() -> {
|
||||
boolean result = true;
|
||||
// Read the schematic and paste it into the world
|
||||
try (Closer closer = Closer.create()) {
|
||||
FileInputStream fis = closer.register(new FileInputStream(finalFile));
|
||||
BufferedInputStream bis = closer.register(new BufferedInputStream(fis));
|
||||
NBTInputStream nbtStream = new NBTInputStream(new GZIPInputStream(bis));
|
||||
ClipboardReader reader = new FastSchematicReader(nbtStream);
|
||||
final FileInputStream fis = closer.register(new FileInputStream(finalFile));
|
||||
final ClipboardReader reader = format.getReader(fis);
|
||||
final Clipboard clipboard = reader.read();
|
||||
|
||||
Clipboard clipboard = reader.read();
|
||||
if (clipboard.getDimensions().getY() != regionHeight
|
||||
|| clipboard.getDimensions().getX() != regionWidth
|
||||
|| clipboard.getDimensions().getZ() != regionDepth) {
|
||||
@@ -152,7 +168,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
|
||||
@@ -173,35 +189,29 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
|
||||
"exceeded the block limit while restoring schematic of " + regionInterface.getName()
|
||||
+ ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: "
|
||||
+ pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
CompletableFuture.completedFuture(false);
|
||||
result = false;
|
||||
} catch (IOException e) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"An error occured while restoring schematic of " + regionInterface.getName()
|
||||
"An error occurred while restoring schematic of " + regionInterface.getName()
|
||||
+ ", enable debug to see the complete stacktrace");
|
||||
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
|
||||
CompletableFuture.completedFuture(false);
|
||||
result = false;
|
||||
} catch (Exception e) {
|
||||
pluginInterface.getLogger()
|
||||
.warning("crashed during restore of " + regionInterface.getName());
|
||||
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
|
||||
CompletableFuture.completedFuture(false);
|
||||
result = false;
|
||||
}
|
||||
editSession.flushQueue();
|
||||
CompletableFuture.completedFuture(true);
|
||||
completableFuture.complete(result);
|
||||
});
|
||||
return completableFuture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionInterface) {
|
||||
return restoreRegionBlocksAsync(rawFile, regionInterface).join();
|
||||
}
|
||||
|
||||
|
||||
@Beta
|
||||
public CompletableFuture<Boolean> saveRegionBlocksAsync(File file, GeneralRegionInterface regionInterface) {
|
||||
// TODO implement using the FastAsyncWorldEdit api to save async
|
||||
ClipboardFormat format = BuiltInClipboardFormat.MINECRAFT_STRUCTURE;
|
||||
ClipboardFormat format = BuiltInClipboardFormat.FAST;
|
||||
// TODO allow selecting FAWE format in the config? (when enabled you cannot go back to vanilla WorldEdit easily)
|
||||
|
||||
file = new File(file.getAbsolutePath() + "." + format.getPrimaryFileExtension());
|
||||
@@ -219,7 +229,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 = pluginInterface.getWorldEdit().getWorldEdit().newEditSessionBuilder()
|
||||
.world(world)
|
||||
.relightMode(RelightMode.OPTIMAL)
|
||||
.limit(limit)
|
||||
.build();
|
||||
|
||||
final ProtectedRegion region = regionInterface.getRegion();
|
||||
final BlockVector3 min = region.getMinimumPoint(), max = region.getMaximumPoint();
|
||||
@@ -244,6 +258,7 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
|
||||
+ ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: "
|
||||
+ pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
completableFuture.complete(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try (Closer closer = Closer.create()) {
|
||||
@@ -253,7 +268,7 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
|
||||
writer.write(clipboard);
|
||||
} catch (IOException e) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"An error occured while saving schematic of " + regionName
|
||||
"An error occurred while saving schematic of " + regionName
|
||||
+ ", enable debug to see the complete stacktrace");
|
||||
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
|
||||
completableFuture.complete(false);
|
||||
@@ -262,15 +277,194 @@ public class FastAsyncWorldEditHandler extends WorldEditInterface {
|
||||
.warning("Crashed during save of " + regionName);
|
||||
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
|
||||
completableFuture.complete(false);
|
||||
return;
|
||||
}
|
||||
completableFuture.complete(true);
|
||||
});
|
||||
return completableFuture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean restoreRegionBlocks(File rawFile, GeneralRegionInterface regionInterface) {
|
||||
// TODO implement using the FastAsyncWorldEdit api to paste async
|
||||
File file = null;
|
||||
for (ClipboardFormat formatOption : BuiltInClipboardFormat.values()) {
|
||||
if (new File(rawFile.getAbsolutePath() + "." + formatOption.getPrimaryFileExtension())
|
||||
.exists()) {
|
||||
file = new File(
|
||||
rawFile.getAbsolutePath() + "." + formatOption.getPrimaryFileExtension());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (file == null) {
|
||||
pluginInterface.getLogger().info("Did not restore region " + regionInterface.getName()
|
||||
+ ", schematic file does not exist: " + rawFile.getAbsolutePath());
|
||||
return false;
|
||||
}
|
||||
ClipboardFormat format = ClipboardFormats.findByFile(file);
|
||||
if (format == null) {
|
||||
pluginInterface.debugI("Did not restore region " + regionInterface.getName() + ", could not find a valid clipboard format");
|
||||
return false;
|
||||
}
|
||||
pluginInterface.debugI("Trying to restore region", regionInterface.getName(), " from file",
|
||||
file.getAbsolutePath(), "with format", format.getName());
|
||||
|
||||
com.sk89q.worldedit.world.World world = null;
|
||||
if (regionInterface.getName() != null) {
|
||||
world = BukkitAdapter.adapt(regionInterface.getWorld());
|
||||
}
|
||||
if (world == null) {
|
||||
pluginInterface.getLogger().info(
|
||||
"Did not restore region " + regionInterface.getName() + ", world not found: "
|
||||
+ regionInterface.getWorldName());
|
||||
return false;
|
||||
}
|
||||
final FaweLimit limit = FaweLimit.MAX.copy();
|
||||
limit.MAX_CHANGES = pluginInterface.getConfig().getInt("maximumBlocks");
|
||||
limit.MAX_ENTITIES = pluginInterface.getConfig().getInt("maximumEntities", (int) (limit.MAX_CHANGES / 1000));
|
||||
EditSession editSession = pluginInterface.getWorldEdit().getWorldEdit()
|
||||
.newEditSessionBuilder()
|
||||
.world(world)
|
||||
.limit(limit)
|
||||
.build();
|
||||
editSession.setReorderMode(EditSession.ReorderMode.MULTI_STAGE);
|
||||
ProtectedRegion region = regionInterface.getRegion();
|
||||
// Get the origin and size of the region
|
||||
BlockVector3 origin = BlockVector3
|
||||
.at(region.getMinimumPoint().getBlockX(), region.getMinimumPoint().getBlockY(),
|
||||
region.getMinimumPoint().getBlockZ());
|
||||
|
||||
|
||||
// Read the schematic and paste it into the world
|
||||
try(Closer closer = Closer.create()) {
|
||||
final FileInputStream fis = closer.register(new FileInputStream(file));
|
||||
final ClipboardReader reader = format.getReader(fis);
|
||||
final Clipboard clipboard = reader.read();
|
||||
if (clipboard.getDimensions().getY() != regionInterface.getHeight()
|
||||
|| clipboard.getDimensions().getX() != regionInterface.getWidth()
|
||||
|| clipboard.getDimensions().getZ() != regionInterface.getDepth()) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"Size of the region " + regionInterface.getName()
|
||||
+ " is not the same as the schematic to restore!");
|
||||
pluginInterface.debugI(
|
||||
"schematic|region, x:" + clipboard.getDimensions().getX() + "|"
|
||||
+ regionInterface.getWidth() + ", y:" + clipboard.getDimensions().getY()
|
||||
+ "|" + regionInterface.getHeight() + ", z:" + clipboard.getDimensions()
|
||||
.getZ() + "|" + regionInterface.getDepth());
|
||||
}
|
||||
clipboard.setOrigin(clipboard.getMinimumPoint());
|
||||
ClipboardHolder clipboardHolder = new ClipboardHolder(clipboard);
|
||||
LocalSession session =
|
||||
new LocalSession(pluginInterface.getWorldEdit().getLocalConfiguration());
|
||||
session.setBlockChangeLimit(pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
session.setClipboard(clipboardHolder);
|
||||
|
||||
// Build operation
|
||||
|
||||
BlockTransformExtent extent = new BlockTransformExtent(clipboard);
|
||||
ForwardExtentCopy copy =
|
||||
new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(),
|
||||
editSession, origin);
|
||||
copy.setTransform(clipboardHolder.getTransform());
|
||||
// Mask to region (for polygon and other weird shaped regions)
|
||||
// TODO make this more efficient (especially for polygon regions)
|
||||
if (region.getType() != RegionType.CUBOID) {
|
||||
copy.setSourceMask(new RegionBoundMask(region));
|
||||
}
|
||||
Operations.completeLegacy(copy);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"exceeded the block limit while restoring schematic of " + regionInterface.getName()
|
||||
+ ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: "
|
||||
+ pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
return false;
|
||||
} catch (FaweException ex) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"exceeded the block entity limit while restoring schematic of " + regionInterface.getName()
|
||||
+ ", limit passed by AreaShop: "
|
||||
+ pluginInterface.getConfig().getInt("maximumEntities"));
|
||||
return false;
|
||||
}
|
||||
catch (IOException e) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"An error occurred while restoring schematic of " + regionInterface.getName()
|
||||
+ ", enable debug to see the complete stacktrace");
|
||||
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
pluginInterface.getLogger()
|
||||
.warning("crashed during restore of " + regionInterface.getName());
|
||||
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
|
||||
return false;
|
||||
}
|
||||
editSession.flushQueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveRegionBlocks(File file, GeneralRegionInterface regionInterface) {
|
||||
return saveRegionBlocksAsync(file, regionInterface).join();
|
||||
// TODO implement using the FastAsyncWorldEdit api to save async
|
||||
ClipboardFormat format = BuiltInClipboardFormat.FAST;
|
||||
// TODO allow selecting FAWE format in the config? (when enabled you cannot go back to vanilla WorldEdit easily)
|
||||
|
||||
file = new File(file.getAbsolutePath() + "." + format.getPrimaryFileExtension());
|
||||
pluginInterface.debugI("Trying to save region", regionInterface.getName(), " to file",
|
||||
file.getAbsolutePath(), "with format", format.getName());
|
||||
com.sk89q.worldedit.world.World world = null;
|
||||
if (regionInterface.getWorld() != null) {
|
||||
world = BukkitAdapter.adapt(regionInterface.getWorld());
|
||||
}
|
||||
if (world == null) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"Did not save region " + regionInterface.getName() + ", world not found: "
|
||||
+ regionInterface.getWorldName());
|
||||
return false;
|
||||
}
|
||||
EditSession editSession =
|
||||
pluginInterface.getWorldEdit().getWorldEdit()
|
||||
.newEditSessionBuilder()
|
||||
.world(world)
|
||||
.maxBlocks(pluginInterface.getConfig().getInt("maximumBlocks"))
|
||||
.build();
|
||||
|
||||
// Create a clipboard
|
||||
CuboidRegion selection =
|
||||
new CuboidRegion(world, regionInterface.getRegion().getMinimumPoint(),
|
||||
regionInterface.getRegion().getMaximumPoint());
|
||||
BlockArrayClipboard clipboard = new BlockArrayClipboard(selection);
|
||||
clipboard.setOrigin(regionInterface.getRegion().getMinimumPoint());
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(editSession,
|
||||
new CuboidRegion(world, regionInterface.getRegion().getMinimumPoint(),
|
||||
regionInterface.getRegion().getMaximumPoint()), clipboard,
|
||||
regionInterface.getRegion().getMinimumPoint());
|
||||
try {
|
||||
Operations.completeLegacy(copy);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"Exceeded the block limit while saving schematic of " + regionInterface.getName()
|
||||
+ ", limit in exception: " + e.getBlockLimit() + ", limit passed by AreaShop: "
|
||||
+ pluginInterface.getConfig().getInt("maximumBlocks"));
|
||||
return false;
|
||||
}
|
||||
|
||||
try (Closer closer = Closer.create()) {
|
||||
FileOutputStream fos = closer.register(new FileOutputStream(file));
|
||||
BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos));
|
||||
ClipboardWriter writer = closer.register(format.getWriter(bos));
|
||||
writer.write(clipboard);
|
||||
} catch (IOException e) {
|
||||
pluginInterface.getLogger().warning(
|
||||
"An error occurred while saving schematic of " + regionInterface.getName()
|
||||
+ ", enable debug to see the complete stacktrace");
|
||||
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
pluginInterface.getLogger()
|
||||
.warning("Crashed during save of " + regionInterface.getName());
|
||||
pluginInterface.debugI(ExceptionUtils.getStackTrace(e));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,9 @@
|
||||
dependencies {
|
||||
compileOnly(libs.spigot)
|
||||
compileOnly(projects.areashopInterface)
|
||||
compileOnly(libs.worldeditCore)
|
||||
compileOnly(libs.worldeditBukkit)
|
||||
compileOnly(libs.worldguardCore)
|
||||
}
|
||||
|
||||
description = "AreaShop WorldEdit 7"
|
||||
+3
-3
@@ -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"
|
||||
+3
-3
@@ -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>
|
||||
@@ -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'
|
||||
@@ -0,0 +1,6 @@
|
||||
dependencies {
|
||||
compileOnly(libs.spigot)
|
||||
compileOnly(projects.areashopInterface)
|
||||
}
|
||||
|
||||
description = "AreaShop Bukkit 1.13 and higher"
|
||||
+5
@@ -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) {
|
||||
|
||||
@@ -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,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'
|
||||
@@ -0,0 +1,9 @@
|
||||
dependencies {
|
||||
compileOnly(libs.spigot)
|
||||
compileOnly(libs.worldeditCore)
|
||||
compileOnly(libs.worldeditBukkit)
|
||||
compileOnly(libs.worldguardCore)
|
||||
compileOnly(libs.worldguardBukkit)
|
||||
}
|
||||
|
||||
description = "AreaShop Interface"
|
||||
+26
@@ -3,6 +3,7 @@ package me.wiefferink.areashop.interfaces;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class WorldEditInterface {
|
||||
protected final AreaShopInterface pluginInterface;
|
||||
@@ -11,6 +12,10 @@ public abstract class WorldEditInterface {
|
||||
this.pluginInterface = pluginInterface;
|
||||
}
|
||||
|
||||
public boolean supportsAsyncOperations() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Different way to restore blocks per implementation, newer ones support entities as well.
|
||||
* Why: the schematic api has changed between WorldEdit 5 and 6, and the schematic format changed between 6 and 7
|
||||
@@ -20,6 +25,16 @@ public abstract class WorldEditInterface {
|
||||
*/
|
||||
public abstract boolean restoreRegionBlocks(File file, GeneralRegionInterface regionInterface);
|
||||
|
||||
/**
|
||||
* Different way to restore blocks per implementation, newer ones support entities as well.
|
||||
* @param file File to try restoring from to the location of the region
|
||||
* @param regionInterface Region to restore from
|
||||
* @return true when successful, otherwise false
|
||||
*/
|
||||
public CompletableFuture<Boolean> restoreRegionBlocksAsync(File file, GeneralRegionInterface regionInterface) {
|
||||
return CompletableFuture.completedFuture(restoreRegionBlocks(file, regionInterface));
|
||||
}
|
||||
|
||||
/**
|
||||
* Different way to save blocks per implementation, newer ones support entities as well.
|
||||
* Why: the schematic api has changed between WorldEdit 5 and 6, and the schematic format changed between 6 and 7
|
||||
@@ -29,6 +44,17 @@ public abstract class WorldEditInterface {
|
||||
*/
|
||||
public abstract boolean saveRegionBlocks(File file, GeneralRegionInterface regionInterface);
|
||||
|
||||
/**
|
||||
* Different way to save blocks per implementation, newer ones support entities as well.
|
||||
* Why: the schematic api has changed between WorldEdit 5 and 6, and the schematic format changed between 6 and 7
|
||||
* @param file File to try saving the region to
|
||||
* @param regionInterface Region to restore from
|
||||
* @return true when successful, otherwise false
|
||||
*/
|
||||
public CompletableFuture<Boolean> saveRegionBlocksAsync(File file, GeneralRegionInterface regionInterface) {
|
||||
return CompletableFuture.completedFuture(saveRegionBlocks(file, regionInterface));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the selection of the player.
|
||||
* Why: the underlying WorldEdit selection class has changed from interface <-> class
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
dependencies {
|
||||
compileOnly(libs.spigot)
|
||||
}
|
||||
|
||||
description = "AreaShop NMS Interface"
|
||||
File renamed without changes.
File renamed without changes.
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
plugins {
|
||||
java
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("io.papermc.paperweight.userdev") version "1.3.5" apply false
|
||||
idea
|
||||
eclipse
|
||||
}
|
||||
|
||||
group = "me.wiefferink"
|
||||
version = "2.7.6"
|
||||
|
||||
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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
org.gradle.parallel=true
|
||||
org.gradle.caching=true
|
||||
org.gradle.java.installations.auto-download=false
|
||||
@@ -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.1"
|
||||
|
||||
# Gradle plugins
|
||||
paperweight = "1.3.5"
|
||||
|
||||
[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
@@ -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.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -32,10 +32,10 @@
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
|
||||
@@ -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'
|
||||
-160
@@ -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()));
|
||||
}
|
||||
}
|
||||
@@ -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'
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -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'
|
||||
@@ -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')
|
||||
@@ -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 = 30
|
||||
}
|
||||
}
|
||||
|
||||
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:platform:bukkit-1-18-1")
|
||||
include(":adapters:plugins:worldedit")
|
||||
include(":adapters:plugins:worldguard")
|
||||
include(":adapters:plugins:fastasyncworldedit")
|
||||
|
||||
// Main project
|
||||
include(":areashop")
|
||||
|
||||
project(":areashop").projectDir = file("AreaShop")
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
Reference in new issue
Block a user