mirror of
https://github.com/md5sha256/AreaShop.git
synced 2026-11-07 09:52:38 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b50d57739f | ||
|
|
ce9438eaeb | ||
|
|
47cc259c40 | ||
|
|
e6ae122b86 | ||
|
|
2562075b90 | ||
|
|
9fc5d8a314 | ||
|
|
e96b179c48 | ||
|
|
49bed6f655 | ||
|
|
ffc5b03a75 | ||
|
|
69fea8ab7e | ||
|
|
29fc2c4205 | ||
|
|
2dd6d4ec4a | ||
|
|
789073f6d6 | ||
|
|
d211bf2f43 | ||
|
|
a6659cb14d | ||
|
|
880218cca0 | ||
|
|
3426381273 | ||
|
|
80a73fecea | ||
|
|
590d5a4988 | ||
|
|
dda4a090fb | ||
|
|
3a415513dd | ||
|
|
8ec6a43dc8 | ||
|
|
2d81614f5f | ||
|
|
8fb035015d | ||
|
|
77088a3a72 | ||
|
|
2c2f40b0ea | ||
|
|
07406c3987 | ||
|
|
82a90b350d | ||
|
|
151fbe8000 | ||
|
|
f2a4dd71e3 | ||
|
|
d4cc70f954 | ||
|
|
8001047480 | ||
|
|
af1486a6fa | ||
|
|
36a2d054d6 | ||
|
|
7429b0a206 |
No files matched your search
@@ -1,23 +0,0 @@
|
||||
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
|
||||
@@ -0,0 +1,38 @@
|
||||
name : "build"
|
||||
|
||||
on : [ "pull_request", "push" ]
|
||||
|
||||
jobs :
|
||||
build :
|
||||
strategy :
|
||||
matrix :
|
||||
java : [ 16 ]
|
||||
# java: ["1.8", "11"]
|
||||
os : [ "ubuntu-18.04" ]
|
||||
runs-on : "${{ matrix.os }}"
|
||||
steps :
|
||||
- name : "Checkout Repository"
|
||||
uses : "actions/checkout@v2.3.4"
|
||||
|
||||
- name : "Checkout submodules"
|
||||
uses : "srt32/git-actions@v0.0.3"
|
||||
with :
|
||||
args : "git submodule update --init --recursive"
|
||||
|
||||
- name : "Restore Gradle cache"
|
||||
uses : "actions/cache@v2"
|
||||
with :
|
||||
path : "~/.gradle/caches"
|
||||
key : "${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}"
|
||||
restore-keys : |
|
||||
${{ runner.os }}-gradle-
|
||||
- name : "Setup JDK ${{ matrix.java }}"
|
||||
uses : "actions/setup-java@v1.4.3"
|
||||
with :
|
||||
java-version : "${{ matrix.java }}"
|
||||
|
||||
- name : "Grant execute permission for gradlew"
|
||||
run : "chmod +x gradlew"
|
||||
|
||||
- name : "Build with Gradle"
|
||||
run : "./gradlew clean build"
|
||||
+18
-168
@@ -1,180 +1,32 @@
|
||||
|
||||
# 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+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
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
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
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### 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
|
||||
|
||||
.idea/*
|
||||
|
||||
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
|
||||
|
||||
*.iml
|
||||
modules.xml
|
||||
.idea/misc.xml
|
||||
*.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
.idea/sonarlint
|
||||
|
||||
### macOS ###
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
|
||||
.mvn/wrapper/maven-wrapper.jar
|
||||
target
|
||||
|
||||
# Eclipse m2e generated files
|
||||
# Eclipse Core
|
||||
.project
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.classpath
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
### Locally stored "Eclipse launch configurations" ###
|
||||
*.launch
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
### IntelliJ IDEA ###
|
||||
*.iml
|
||||
.idea
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
desktop.ini
|
||||
|
||||
### Gradle ###
|
||||
.gradle
|
||||
build/
|
||||
build-cache/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
@@ -190,5 +42,3 @@ gradle-app.setting
|
||||
|
||||
### Gradle Patch ###
|
||||
**/build/
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/macos,windows,intellij+all,gradle,maven
|
||||
@@ -0,0 +1,60 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'com.github.johnrengelman.shadow' version '7.0.0'
|
||||
}
|
||||
|
||||
description = 'AreaShop'
|
||||
version = '2.6.4'
|
||||
|
||||
dependencies {
|
||||
// Spigot api
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||
|
||||
// Libs
|
||||
implementation 'com.github.NLthijs48:InteractiveMessenger:e7749258ca'
|
||||
implementation 'co.aikar:taskchain-bukkit:3.7.2'
|
||||
implementation 'io.papermc:paperlib:1.0.6'
|
||||
|
||||
// Hooks
|
||||
implementation project(':areashop-interface')
|
||||
implementation project(':areashop-worldguard-7')
|
||||
implementation project(':areashop-worldedit-7')
|
||||
implementation project(':areashop-fawe-1-16')
|
||||
implementation project(':areashop-fawe-1-17')
|
||||
implementation project(':areashop-nms-1-16-5')
|
||||
implementation project(':areashop-nms-1-17')
|
||||
|
||||
// Runtime plugins
|
||||
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.5'
|
||||
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.5'
|
||||
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 {
|
||||
archiveBaseName.set('AreaShop')
|
||||
classifier('original')
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName.set('AreaShop')
|
||||
String relocationBase = 'me.wiefferink.areashop.shaded'
|
||||
classifier('')
|
||||
relocate('co.aikar.taskchain', "${relocationBase}.taskchain")
|
||||
relocate('me.wiefferink.interactivemessenger', "${relocationBase}.interactivemessenger")
|
||||
relocate('org.bstats', "${relocationBase}.bstats")
|
||||
relocate('io.papermc', "${relocationBase}.papermc")
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
plugins {
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
}
|
||||
|
||||
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
|
||||
api("io.papermc:paperlib:1.0.8")
|
||||
api("com.github.NLthijs48:InteractiveMessenger:e7749258ca")
|
||||
api("com.github.NLthijs48:BukkitDo:819d51ec2b")
|
||||
api("io.github.baked-libs:dough-data:1.2.0")
|
||||
api("com.google.inject:guice:7.0.0") {
|
||||
exclude("com.google.guava", "guava")
|
||||
}
|
||||
api("com.google.inject.extensions:guice-assistedinject:7.0.0") {
|
||||
exclude("com.google.guava", "guava")
|
||||
}
|
||||
implementation("net.kyori:adventure-text-minimessage:4.14.0")
|
||||
implementation("net.kyori:adventure-platform-bukkit:4.3.0")
|
||||
implementation("org.spongepowered:configurate-yaml:4.1.2")
|
||||
|
||||
// Project submodules
|
||||
api(projects.areashopInterface)
|
||||
api(projects.areashopNms)
|
||||
api(projects.adapters.platform.platformInterface)
|
||||
api(projects.adapters.platform.paper)
|
||||
|
||||
if (!providers.environmentVariable("JITPACK").isPresent) {
|
||||
// We don't need these adapters if we are only publishing an api jar
|
||||
runtimeOnly(projects.adapters.plugins.worldedit)
|
||||
runtimeOnly(projects.adapters.plugins.worldguard)
|
||||
runtimeOnly(projects.adapters.plugins.fastasyncworldedit)
|
||||
runtimeOnly(project(":adapters:platform:bukkit-1-17", "reobf"))
|
||||
runtimeOnly(projects.adapters.platform.bukkitModern)
|
||||
}
|
||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.57.1")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
|
||||
}
|
||||
|
||||
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
tasks {
|
||||
processResources {
|
||||
filesMatching("plugin.yml") {
|
||||
expand("version" to project.version)
|
||||
}
|
||||
}
|
||||
|
||||
assemble {
|
||||
if (!providers.environmentVariable("JITPACK").isPresent) {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
archiveBaseName.set("AreaShop")
|
||||
if (!providers.environmentVariable("JITPACK").isPresent) {
|
||||
archiveClassifier.set("original")
|
||||
} else {
|
||||
archiveClassifier.set("")
|
||||
}
|
||||
}
|
||||
|
||||
if (providers.environmentVariable("JITPACK").isPresent) {
|
||||
artifacts {
|
||||
archives(jar)
|
||||
}
|
||||
}
|
||||
|
||||
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("com.google.errorprone", "${base}.errorprone")
|
||||
relocate("org.aopalliance", "${base}.aopalliance")
|
||||
relocate("javax.annotation", "${base}.javax.annotation")
|
||||
relocate("jakarta.inject", "${base}.jakarta.inject")
|
||||
relocate("org.jetbrains.annotations", "${base}.jetbrains.annotations")
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package me.wiefferink.areashop;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import me.wiefferink.interactivemessenger.Log;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import me.wiefferink.interactivemessenger.source.LanguageManager;
|
||||
import me.wiefferink.interactivemessenger.translation.Transifex;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Collections;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
|
||||
public class ASLanguageManager extends LanguageManager {
|
||||
private JavaPlugin plugin;
|
||||
private String jarLanguagePath;
|
||||
private File languageFolder;
|
||||
private String wgPrefix;
|
||||
private List<String> chatPrefix;
|
||||
private Map<String, List<String>> currentLanguage, defaultLanguage;
|
||||
|
||||
public ASLanguageManager(JavaPlugin plugin,
|
||||
String jarLanguagePath,
|
||||
String currentLanguageName,
|
||||
String defaultLanguageName,
|
||||
List<String> chatPrefix,
|
||||
String wgPrefix) {
|
||||
super(plugin, jarLanguagePath, currentLanguageName, defaultLanguageName, chatPrefix);
|
||||
this.plugin = plugin;
|
||||
this.jarLanguagePath = jarLanguagePath;
|
||||
this.chatPrefix = chatPrefix;
|
||||
this.languageFolder = new File(plugin.getDataFolder() + File.separator + jarLanguagePath);
|
||||
|
||||
Message.init(this, plugin.getLogger());
|
||||
saveDefaults();
|
||||
currentLanguage = loadLanguage(currentLanguageName);
|
||||
if (defaultLanguageName.equals(currentLanguageName)) {
|
||||
defaultLanguage = currentLanguage;
|
||||
} else {
|
||||
defaultLanguage = loadLanguage(defaultLanguageName);
|
||||
}
|
||||
this.wgPrefix = wgPrefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMessage(String key) {
|
||||
List<String> message;
|
||||
if (key.equalsIgnoreCase(Message.CHATLANGUAGEVARIABLE)) {
|
||||
message = chatPrefix;
|
||||
} else if (key.equalsIgnoreCase("wgPrefix")) {
|
||||
message = new ArrayList<>();
|
||||
message.add(wgPrefix);
|
||||
} else if (currentLanguage.containsKey(key)) {
|
||||
message = currentLanguage.get(key);
|
||||
} else {
|
||||
message = defaultLanguage.get(key);
|
||||
}
|
||||
if (message == null) {
|
||||
Log.warn("Did not find message '" + key + "' in the current or default language");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return new ArrayList<>(message);
|
||||
}
|
||||
|
||||
private void saveDefaults() {
|
||||
// Create the language folder if it not exists
|
||||
if (!languageFolder.exists()) {
|
||||
if (!languageFolder.mkdirs()) {
|
||||
Log.warn("Could not create language directory: " + languageFolder.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
}
|
||||
File jarPath;
|
||||
try {
|
||||
// Read jar as ZIP file
|
||||
jarPath = new File(plugin.getClass()
|
||||
.getProtectionDomain()
|
||||
.getCodeSource()
|
||||
.getLocation()
|
||||
.toURI());
|
||||
} catch (URISyntaxException e) {
|
||||
Log.error("Failed to find location of jar file:", ExceptionUtils.getStackTrace(e));
|
||||
return;
|
||||
}
|
||||
try (ZipFile jar = new ZipFile(jarPath);) {
|
||||
Enumeration<? extends ZipEntry> entries = jar.entries();
|
||||
|
||||
// Each entry is a file or directory
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
|
||||
// Filter to YAML files in the language directory
|
||||
if (!entry.isDirectory() && entry.getName()
|
||||
.startsWith(jarLanguagePath + "/") && entry.getName()
|
||||
.endsWith(".yml")) {
|
||||
// Save the file to disk
|
||||
File targetFile = new File(languageFolder.getAbsolutePath() + File.separator + entry.getName()
|
||||
.substring(entry.getName().lastIndexOf("/")));
|
||||
try (
|
||||
InputStream input = jar.getInputStream(entry);
|
||||
OutputStream output = new FileOutputStream(targetFile)
|
||||
) {
|
||||
byte[] bytes = input.readAllBytes();
|
||||
output.write(bytes);
|
||||
} catch (IOException e) {
|
||||
Log.warn("Something went wrong saving a default language file: " + targetFile.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (
|
||||
IOException e) {
|
||||
Log.error("Failed to read zip file:", ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, List<String>> loadLanguage(String key) {
|
||||
return loadLanguage(key, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the specified language
|
||||
*
|
||||
* @param key The language to load
|
||||
* @param convert try conversion or not (infinite recursion prevention)
|
||||
* @return Map with the messages loaded from the file
|
||||
*/
|
||||
private Map<String, List<String>> loadLanguage(String key, boolean convert) {
|
||||
Map<String, List<String>> result = new HashMap<>();
|
||||
|
||||
// Load the language file
|
||||
boolean convertFromTransifex = false;
|
||||
File file = new File(languageFolder.getAbsolutePath() + File.separator + key + ".yml");
|
||||
try (
|
||||
InputStream inputStream = new FileInputStream(file);
|
||||
Reader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)
|
||||
) {
|
||||
// Detect empty language files, happens when the YAML parsers prints an exception (it does return an empty YamlConfiguration though)
|
||||
YamlConfiguration ymlFile = YamlConfiguration.loadConfiguration(reader);
|
||||
if (ymlFile.getKeys(false).isEmpty()) {
|
||||
Log.warn("Language file " + key + ".yml has zero messages.");
|
||||
return result;
|
||||
}
|
||||
|
||||
// Retrieve the messages from the YAML file and create the result
|
||||
if (convert && Transifex.needsConversion(ymlFile)) {
|
||||
convertFromTransifex = true;
|
||||
} else {
|
||||
for (String messageKey : ymlFile.getKeys(false)) {
|
||||
List<String> toPut;
|
||||
if (ymlFile.isList(messageKey)) {
|
||||
toPut = ymlFile.getStringList(messageKey);
|
||||
} else {
|
||||
toPut = Collections.singletonList(ymlFile.getString(messageKey));
|
||||
}
|
||||
result.put(messageKey, new ArrayList<>(toPut));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.warn("Could not load language file: " + file.getAbsolutePath());
|
||||
}
|
||||
|
||||
// Do conversion (after block above closed the reader)
|
||||
if (convertFromTransifex) {
|
||||
if (!Transifex.convertFrom(file)) {
|
||||
Log.warn("Failed to convert " + file.getName() + " from the Transifex layout to the AreaShop layout, check the errors above");
|
||||
}
|
||||
return loadLanguage(key, false);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,39 +0,0 @@
|
||||
package me.wiefferink.areashop;
|
||||
|
||||
import me.wiefferink.areashop.features.signs.SignManager;
|
||||
import me.wiefferink.areashop.interfaces.AreaShopInterface;
|
||||
import me.wiefferink.areashop.managers.CommandManager;
|
||||
import me.wiefferink.areashop.managers.FeatureManager;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface AreaShopApi extends AreaShopInterface {
|
||||
|
||||
/**
|
||||
* Function to get the CommandManager.
|
||||
*
|
||||
* @return the CommandManager
|
||||
*/
|
||||
@Nonnull CommandManager getCommandManager();
|
||||
|
||||
/**
|
||||
* Get the SignLinkerManager.
|
||||
* Handles sign linking mode.
|
||||
*
|
||||
* @return The SignLinkerManager
|
||||
*/
|
||||
@Nonnull SignLinkerManager getSignlinkerManager();
|
||||
|
||||
/**
|
||||
* Get the FeatureManager.
|
||||
* Manages region specific features.
|
||||
*
|
||||
* @return The FeatureManager
|
||||
*/
|
||||
@Nonnull FeatureManager getFeatureManager();
|
||||
|
||||
|
||||
@Nonnull SignManager getSignManager();
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package me.wiefferink.areashop;
|
||||
|
||||
public interface MessageBridge {
|
||||
/**
|
||||
* Send a message to a target without a prefix.
|
||||
*
|
||||
* @param target The target to send the message to
|
||||
* @param key The key of the language string
|
||||
* @param replacements The replacements to insert in the message
|
||||
*/
|
||||
void messageNoPrefix(Object target, String key, Object... replacements);
|
||||
|
||||
/**
|
||||
* Send a message to a target, prefixed by the default chat prefix.
|
||||
*
|
||||
* @param target The target to send the message to
|
||||
* @param key The key of the language string
|
||||
* @param replacements The replacements to insert in the message
|
||||
*/
|
||||
void message(Object target, String key, Object... replacements);
|
||||
}
|
||||
@@ -1,54 +1,29 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.events.ask.AddingRegionEvent;
|
||||
import me.wiefferink.areashop.events.ask.BuyingRegionEvent;
|
||||
import me.wiefferink.areashop.events.ask.RentingRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.BoughtRegionEvent;
|
||||
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.IFileManager;
|
||||
import me.wiefferink.areashop.managers.FileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import me.wiefferink.bukkitdo.Do;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Singleton
|
||||
public class AddCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private AreaShop plugin;
|
||||
@Inject
|
||||
private WorldEditInterface worldEditInterface;
|
||||
@Inject
|
||||
private WorldGuardInterface worldGuardInterface;
|
||||
@Inject
|
||||
private RegionFactory regionFactory;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop add";
|
||||
@@ -77,12 +52,12 @@ public class AddCommand extends CommandAreaShop {
|
||||
&& !sender.hasPermission("areashop.createbuy")
|
||||
&& !sender.hasPermission("areashop.createbuy.member")
|
||||
&& !sender.hasPermission("areashop.createbuy.owner")) {
|
||||
messageBridge.message(sender, "add-noPermission");
|
||||
plugin.message(sender, "add-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length < 2 || args[1] == null || (!"rent".equalsIgnoreCase(args[1]) && !"buy".equalsIgnoreCase(args[1]))) {
|
||||
messageBridge.message(sender, "add-help");
|
||||
plugin.message(sender, "add-help");
|
||||
return;
|
||||
}
|
||||
Map<String, ProtectedRegion> regions = new HashMap<>();
|
||||
@@ -93,18 +68,18 @@ public class AddCommand extends CommandAreaShop {
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if(player == null) {
|
||||
messageBridge.message(sender, "cmd-weOnlyByPlayer");
|
||||
plugin.message(sender, "cmd-weOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
WorldEditSelection selection = worldEditInterface.getPlayerSelection(player);
|
||||
WorldEditSelection selection = plugin.getWorldEditHandler().getPlayerSelection(player);
|
||||
if(selection == null) {
|
||||
messageBridge.message(player, "cmd-noSelection");
|
||||
plugin.message(player, "cmd-noSelection");
|
||||
return;
|
||||
}
|
||||
world = selection.getWorld();
|
||||
regions = Utils.getWorldEditRegionsInSelection(selection).stream().collect(Collectors.toMap(ProtectedRegion::getId, region -> region));
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(player, "cmd-noWERegionsFound");
|
||||
plugin.message(player, "cmd-noWERegionsFound");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -112,7 +87,7 @@ public class AddCommand extends CommandAreaShop {
|
||||
if(args.length == 4) {
|
||||
world = Bukkit.getWorld(args[3]);
|
||||
if(world == null) {
|
||||
messageBridge.message(sender, "add-incorrectWorld", args[3]);
|
||||
plugin.message(sender, "add-incorrectWorld", args[3]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -120,19 +95,19 @@ public class AddCommand extends CommandAreaShop {
|
||||
}
|
||||
} else {
|
||||
if(args.length < 4) {
|
||||
messageBridge.message(sender, "add-specifyWorld");
|
||||
plugin.message(sender, "add-specifyWorld");
|
||||
return;
|
||||
} else {
|
||||
world = Bukkit.getWorld(args[3]);
|
||||
if(world == null) {
|
||||
messageBridge.message(sender, "add-incorrectWorld", args[3]);
|
||||
plugin.message(sender, "add-incorrectWorld", args[3]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
ProtectedRegion region = plugin.getRegionManager(world).getRegion(args[2]);
|
||||
if(region == null) {
|
||||
messageBridge.message(sender, "cmd-noRegion", args[2]);
|
||||
plugin.message(sender, "cmd-noRegion", args[2]);
|
||||
return;
|
||||
}
|
||||
regions.put(args[2], region);
|
||||
@@ -149,29 +124,28 @@ public class AddCommand extends CommandAreaShop {
|
||||
TreeSet<String> namesBlacklisted = new TreeSet<>();
|
||||
TreeSet<String> namesNoPermission = new TreeSet<>();
|
||||
TreeSet<String> namesAddCancelled = new TreeSet<>(); // Denied by an event listener
|
||||
Do.forAll(
|
||||
plugin.getConfig().getInt("adding.regionsPerTick"),
|
||||
regions.entrySet(),
|
||||
regionEntry -> {
|
||||
Utils.runAsBatches(regions.entrySet(),
|
||||
Math.min(plugin.getConfig().getInt("adding.regionsPerTick"), 1),
|
||||
(regionEntry) -> {
|
||||
String regionName = regionEntry.getKey();
|
||||
ProtectedRegion region = regionEntry.getValue();
|
||||
// Determine if the player is an owner or member of the region
|
||||
boolean isMember = finalPlayer != null && worldGuardInterface.containsMember(region, finalPlayer.getUniqueId());
|
||||
boolean isOwner = finalPlayer != null && worldGuardInterface.containsOwner(region, finalPlayer.getUniqueId());
|
||||
boolean isMember = finalPlayer != null && plugin.getWorldGuardHandler().containsMember(region, finalPlayer.getUniqueId());
|
||||
boolean isOwner = finalPlayer != null && plugin.getWorldGuardHandler().containsOwner(region, finalPlayer.getUniqueId());
|
||||
String type;
|
||||
if(isRent) {
|
||||
type = "rent";
|
||||
} else {
|
||||
type = "buy";
|
||||
}
|
||||
IFileManager.AddResult result = plugin.getFileManager().checkRegionAdd(sender, region, world, isRent ? GeneralRegion.RegionType.RENT : GeneralRegion.RegionType.BUY);
|
||||
if(result == IFileManager.AddResult.ALREADYADDED) {
|
||||
FileManager.AddResult result = plugin.getFileManager().checkRegionAdd(sender, region, world, isRent ? GeneralRegion.RegionType.RENT : GeneralRegion.RegionType.BUY);
|
||||
if(result == FileManager.AddResult.ALREADYADDED) {
|
||||
regionsAlready.add(plugin.getFileManager().getRegion(regionName));
|
||||
} else if(result == IFileManager.AddResult.ALREADYADDEDOTHERWORLD) {
|
||||
} else if(result == FileManager.AddResult.ALREADYADDEDOTHERWORLD) {
|
||||
regionsAlreadyOtherWorld.add(plugin.getFileManager().getRegion(regionName));
|
||||
} else if(result == IFileManager.AddResult.BLACKLISTED) {
|
||||
} else if(result == FileManager.AddResult.BLACKLISTED) {
|
||||
namesBlacklisted.add(regionName);
|
||||
} else if(result == IFileManager.AddResult.NOPERMISSION) {
|
||||
} else if(result == FileManager.AddResult.NOPERMISSION) {
|
||||
namesNoPermission.add(regionName);
|
||||
} else {
|
||||
// Check if the player should be landlord
|
||||
@@ -179,8 +153,8 @@ public class AddCommand extends CommandAreaShop {
|
||||
&& ((sender.hasPermission("areashop.create" + type + ".owner") && isOwner)
|
||||
|| (sender.hasPermission("areashop.create" + type + ".member") && isMember)));
|
||||
List<UUID> existing = new ArrayList<>();
|
||||
existing.addAll(worldGuardInterface.getOwners(region).asUniqueIdList());
|
||||
existing.addAll(worldGuardInterface.getMembers(region).asUniqueIdList());
|
||||
existing.addAll(plugin.getWorldGuardHandler().getOwners(region).asUniqueIdList());
|
||||
existing.addAll(plugin.getWorldGuardHandler().getMembers(region).asUniqueIdList());
|
||||
|
||||
AreaShop.debug("regionAddLandlordStatus:", regionName,
|
||||
"landlord:", landlord,
|
||||
@@ -192,7 +166,7 @@ public class AddCommand extends CommandAreaShop {
|
||||
"memberPermission:", sender.hasPermission("areashop.create" + type + ".member"));
|
||||
|
||||
if(isRent) {
|
||||
RentRegion rent = regionFactory.createRentRegion(regionName, world);
|
||||
RentRegion rent = new RentRegion(regionName, world);
|
||||
// Set landlord
|
||||
if(landlord) {
|
||||
rent.setLandlord(finalPlayer.getUniqueId(), finalPlayer.getName());
|
||||
@@ -235,7 +209,7 @@ public class AddCommand extends CommandAreaShop {
|
||||
|
||||
regionsSuccess.add(rent);
|
||||
} else {
|
||||
BuyRegion buy = regionFactory.createBuyRegion(regionName, world);
|
||||
BuyRegion buy = new BuyRegion(regionName, world);
|
||||
// Set landlord
|
||||
if(landlord) {
|
||||
buy.setLandlord(finalPlayer.getUniqueId(), finalPlayer.getName());
|
||||
@@ -279,40 +253,39 @@ public class AddCommand extends CommandAreaShop {
|
||||
regionsSuccess.add(buy);
|
||||
}
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
}, false).thenAccept(
|
||||
(success) -> {
|
||||
if(!regionsSuccess.isEmpty()) {
|
||||
messageBridge.message(sender, "add-success", args[1], Utils.combinedMessage(regionsSuccess, "region"));
|
||||
plugin.message(sender, "add-success", args[1], Utils.combinedMessage(regionsSuccess, "region"));
|
||||
}
|
||||
if(!regionsAlready.isEmpty()) {
|
||||
messageBridge.message(sender, "add-failed", Utils.combinedMessage(regionsAlready, "region"));
|
||||
plugin.message(sender, "add-failed", Utils.combinedMessage(regionsAlready, "region"));
|
||||
}
|
||||
if(!regionsAlreadyOtherWorld.isEmpty()) {
|
||||
messageBridge.message(sender, "add-failedOtherWorld", Utils.combinedMessage(regionsAlreadyOtherWorld, "region"));
|
||||
plugin.message(sender, "add-failedOtherWorld", Utils.combinedMessage(regionsAlreadyOtherWorld, "region"));
|
||||
}
|
||||
if(!regionsRentCancelled.isEmpty()) {
|
||||
messageBridge.message(sender, "add-rentCancelled", Utils.combinedMessage(regionsRentCancelled, "region"));
|
||||
plugin.message(sender, "add-rentCancelled", Utils.combinedMessage(regionsRentCancelled, "region"));
|
||||
}
|
||||
if(!regionsBuyCancelled.isEmpty()) {
|
||||
messageBridge.message(sender, "add-buyCancelled", Utils.combinedMessage(regionsBuyCancelled, "region"));
|
||||
plugin.message(sender, "add-buyCancelled", Utils.combinedMessage(regionsBuyCancelled, "region"));
|
||||
}
|
||||
if(!namesBlacklisted.isEmpty()) {
|
||||
messageBridge.message(sender, "add-blacklisted", Utils.createCommaSeparatedList(namesBlacklisted));
|
||||
plugin.message(sender, "add-blacklisted", Utils.createCommaSeparatedList(namesBlacklisted));
|
||||
}
|
||||
if(!namesNoPermission.isEmpty()) {
|
||||
messageBridge.message(sender, "add-noPermissionRegions", Utils.createCommaSeparatedList(namesNoPermission));
|
||||
messageBridge.message(sender, "add-noPermissionOwnerMember");
|
||||
plugin.message(sender, "add-noPermissionRegions", Utils.createCommaSeparatedList(namesNoPermission));
|
||||
plugin.message(sender, "add-noPermissionOwnerMember");
|
||||
}
|
||||
if(!namesAddCancelled.isEmpty()) {
|
||||
messageBridge.message(sender, "add-rentCancelled", Utils.createCommaSeparatedList(namesAddCancelled));
|
||||
plugin.message(sender, "add-rentCancelled", Utils.createCommaSeparatedList(namesAddCancelled));
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
List<String> result = new LinkedList<>();
|
||||
if(toComplete == 2) {
|
||||
if(sender.hasPermission("areashop.createrent")) {
|
||||
result.add("rent");
|
||||
@@ -321,7 +294,8 @@ public class AddCommand extends CommandAreaShop {
|
||||
result.add("buy");
|
||||
}
|
||||
} else if(toComplete == 3) {
|
||||
if(sender instanceof Player player) {
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player)sender;
|
||||
if(sender.hasPermission("areashop.createrent") || sender.hasPermission("areashop.createbuy")) {
|
||||
for(ProtectedRegion region : plugin.getRegionManager(player.getWorld()).getRegions().values()) {
|
||||
result.add(region.getId());
|
||||
|
||||
@@ -1,142 +1,135 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class AddfriendCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop addfriend";
|
||||
}
|
||||
|
||||
@Inject
|
||||
private OfflinePlayerHelper offlinePlayerHelper;
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.addfriendall") || target.hasPermission("areashop.addfriend")) {
|
||||
return "help-addFriend";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject
|
||||
private BukkitSchedulerExecutor executor;
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.addfriend") && !sender.hasPermission("areashop.addfriendall")) {
|
||||
plugin.message(sender, "addfriend-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop addfriend";
|
||||
}
|
||||
if(args.length < 2) {
|
||||
plugin.message(sender, "addfriend-help");
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (target.hasPermission("areashop.addfriendall") || target.hasPermission("areashop.addfriend")) {
|
||||
return "help-addFriend";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if(args.length <= 2) {
|
||||
if(sender instanceof Player) {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
region = plugin.getFileManager().getRegion(args[2]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "cmd-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(sender.hasPermission("areashop.addfriendall")) {
|
||||
if((region instanceof RentRegion && !((RentRegion)region).isRented())
|
||||
|| (region instanceof BuyRegion && !((BuyRegion)region).isSold())) {
|
||||
plugin.message(sender, "addfriend-noOwner", region);
|
||||
return;
|
||||
}
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(friend.getLastPlayed() == 0 && !friend.isOnline() && !plugin.getConfig().getBoolean("addFriendNotExistingPlayers")) {
|
||||
plugin.message(sender, "addfriend-notVisited", args[1], region);
|
||||
return;
|
||||
}
|
||||
if(region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
plugin.message(sender, "addfriend-alreadyAdded", friend.getName(), region);
|
||||
return;
|
||||
}
|
||||
if(region.isOwner(friend.getUniqueId())) {
|
||||
plugin.message(sender, "addfriend-self", friend.getName(), region);
|
||||
return;
|
||||
}
|
||||
if(region.getFriendsFeature().addFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
plugin.message(sender, "addfriend-successOther", friend.getName(), region);
|
||||
}
|
||||
} else {
|
||||
if(sender.hasPermission("areashop.addfriend") && sender instanceof Player) {
|
||||
if(region.isOwner((Player)sender)) {
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(friend.getLastPlayed() == 0 && !friend.isOnline() && !plugin.getConfig().getBoolean("addFriendNotExistingPlayers")) {
|
||||
plugin.message(sender, "addfriend-notVisited", args[1], region);
|
||||
return;
|
||||
}
|
||||
if(region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
plugin.message(sender, "addfriend-alreadyAdded", friend.getName(), region);
|
||||
return;
|
||||
}
|
||||
if(region.isOwner(friend.getUniqueId())) {
|
||||
plugin.message(sender, "addfriend-self", friend.getName(), region);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.addfriend") && !sender.hasPermission("areashop.addfriendall")) {
|
||||
messageBridge.message(sender, "addfriend-noPermission");
|
||||
return;
|
||||
}
|
||||
if(region.getFriendsFeature().addFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
plugin.message(sender, "addfriend-success", friend.getName(), region);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "addfriend-noPermissionOther", region);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "addfriend-noPermission", region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length < 2) {
|
||||
messageBridge.message(sender, "addfriend-help");
|
||||
return;
|
||||
}
|
||||
|
||||
GeneralRegion region;
|
||||
if (args.length == 2) {
|
||||
if (sender instanceof Player player) {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(player.getLocation());
|
||||
if (regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if (regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
region = fileManager.getRegion(args[2]);
|
||||
if (region == null) {
|
||||
messageBridge.message(sender, "cmd-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (sender.hasPermission("areashop.addfriendall")) {
|
||||
if ((region instanceof RentRegion rentRegion && !rentRegion.isRented())
|
||||
|| (region instanceof BuyRegion buyRegion && !buyRegion.isSold())) {
|
||||
messageBridge.message(sender, "addfriend-noOwner", region);
|
||||
return;
|
||||
}
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(args[1]).thenAcceptAsync(friend -> {
|
||||
if (friend.hasPlayedBefore() && !friend.isOnline() && !plugin.getConfig().getBoolean("addFriendNotExistingPlayers")) {
|
||||
messageBridge.message(sender, "addfriend-notVisited", args[1], region);
|
||||
} else if (region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
messageBridge.message(sender, "addfriend-alreadyAdded", friend.getName(), region);
|
||||
} else if (region.isOwner(friend.getUniqueId())) {
|
||||
messageBridge.message(sender, "addfriend-self", friend.getName(), region);
|
||||
} else if (region.getFriendsFeature().addFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
messageBridge.message(sender, "addfriend-successOther", friend.getName(), region);
|
||||
}
|
||||
}, this.executor);
|
||||
return;
|
||||
}
|
||||
if (!sender.hasPermission("areashop.addfriend") || !(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "addfriend-noPermission", region);
|
||||
return;
|
||||
}
|
||||
if (!region.isOwner(player)) {
|
||||
messageBridge.message(sender, "addfriend-noPermissionOther", region);
|
||||
return;
|
||||
}
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(args[1]).thenAcceptAsync(friend -> {
|
||||
if (friend.getLastPlayed() == 0 && !friend.isOnline() && !plugin.getConfig().getBoolean("addFriendNotExistingPlayers")) {
|
||||
messageBridge.message(sender, "addfriend-notVisited", args[1], region);
|
||||
} else if (region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
messageBridge.message(sender, "addfriend-alreadyAdded", friend.getName(), region);
|
||||
} else if (region.isOwner(friend.getUniqueId())) {
|
||||
messageBridge.message(sender, "addfriend-self", friend.getName(), region);
|
||||
} else if (region.getFriendsFeature().addFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
messageBridge.message(sender, "addfriend-success", friend.getName(), region);
|
||||
}
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if (toComplete == 2) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if (toComplete == 3) {
|
||||
result.addAll(fileManager.getRegionNames());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
for(Player player : Utils.getOnlinePlayers()) {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if(toComplete == 3) {
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,132 +1,128 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.features.signs.RegionSign;
|
||||
import me.wiefferink.areashop.features.signs.SignManager;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.features.signs.SignsFeature;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.tools.Materials;
|
||||
import me.wiefferink.areashop.tools.SignUtils;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Sign;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
public class AddsignCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private SignManager signManager;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop addsign";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop addsign";
|
||||
}
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (target.hasPermission("areashop.addsign")) {
|
||||
return "help-addsign";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.addsign")) {
|
||||
return "help-addsign";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.addsign")) {
|
||||
plugin.message(sender, "addsign-noPermission");
|
||||
return;
|
||||
}
|
||||
if (!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.addsign")) {
|
||||
messageBridge.message(sender, "addsign-noPermission");
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
// Get the sign
|
||||
Block block = null;
|
||||
BlockIterator blockIterator = new BlockIterator(player, 100);
|
||||
while (blockIterator.hasNext() && block == null) {
|
||||
Block next = blockIterator.next();
|
||||
if (next.getType() != Material.AIR) {
|
||||
block = next;
|
||||
}
|
||||
}
|
||||
if (block == null || !Materials.isSign(block.getType())) {
|
||||
plugin.message(sender, "addsign-noSign");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the sign
|
||||
Block block = null;
|
||||
BlockIterator blockIterator = new BlockIterator(player, 100);
|
||||
while(blockIterator.hasNext() && block == null) {
|
||||
Block next = blockIterator.next();
|
||||
if(next.getType() != Material.AIR) {
|
||||
block = next;
|
||||
}
|
||||
}
|
||||
if(block == null || !Materials.isSign(block.getType())) {
|
||||
messageBridge.message(sender, "addsign-noSign");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if (args.length > 1) {
|
||||
// Get region by argument
|
||||
region = plugin.getFileManager().getRegion(args[1]);
|
||||
if (region == null) {
|
||||
plugin.message(sender, "cmd-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Get region by sign position
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(block.getLocation());
|
||||
if (regions.isEmpty()) {
|
||||
plugin.message(sender, "addsign-noRegions");
|
||||
return;
|
||||
} else if (regions.size() > 1) {
|
||||
plugin.message(sender, "addsign-couldNotDetect", regions.get(0).getName(), regions.get(1).getName());
|
||||
return;
|
||||
}
|
||||
region = regions.get(0);
|
||||
}
|
||||
String profile = null;
|
||||
if (args.length > 2) {
|
||||
profile = args[2];
|
||||
Set<String> profiles = plugin.getConfig().getConfigurationSection("signProfiles").getKeys(false);
|
||||
if (!profiles.contains(profile)) {
|
||||
plugin.message(sender, "addsign-wrongProfile", Utils.createCommaSeparatedList(profiles), region);
|
||||
return;
|
||||
}
|
||||
}
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if (regionSign != null) {
|
||||
plugin.message(sender, "addsign-alreadyRegistered", regionSign.getRegion());
|
||||
return;
|
||||
}
|
||||
|
||||
GeneralRegion region;
|
||||
if(args.length > 1) {
|
||||
// Get region by argument
|
||||
region = fileManager.getRegion(args[1]);
|
||||
if(region == null) {
|
||||
messageBridge.message(sender, "cmd-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Get region by sign position
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(block.getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "addsign-noRegions");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "addsign-couldNotDetect", regions.get(0).getName(), regions.get(1).getName());
|
||||
return;
|
||||
}
|
||||
region = regions.get(0);
|
||||
}
|
||||
String profile = null;
|
||||
if(args.length > 2) {
|
||||
profile = args[2];
|
||||
Set<String> profiles = plugin.getConfig().getConfigurationSection("signProfiles").getKeys(false);
|
||||
if(!profiles.contains(profile)) {
|
||||
messageBridge.message(sender, "addsign-wrongProfile", Utils.createCommaSeparatedList(profiles), region);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Optional<RegionSign> optionalRegionSign = signManager.signFromLocation(block.getLocation());
|
||||
if(optionalRegionSign.isPresent()) {
|
||||
RegionSign regionSign = optionalRegionSign.get();
|
||||
messageBridge.message(sender, "addsign-alreadyRegistered", regionSign.getRegion());
|
||||
return;
|
||||
}
|
||||
final BlockData data = block.getBlockData();
|
||||
final BlockFace rotation;
|
||||
if (data instanceof Sign) {
|
||||
rotation = ((Sign) data).getRotation();
|
||||
} else if (data instanceof WallSign) {
|
||||
rotation = ((WallSign) data).getFacing();
|
||||
} else {
|
||||
rotation = null;
|
||||
}
|
||||
region.getSignsFeature().addSign(block.getLocation(), block.getType(), rotation, profile);
|
||||
if (profile == null) {
|
||||
plugin.message(sender, "addsign-success", region);
|
||||
} else {
|
||||
plugin.message(sender, "addsign-successProfile", profile, region);
|
||||
}
|
||||
region.update();
|
||||
}
|
||||
|
||||
region.getSignsFeature().addSign(block.getLocation(), block.getType(), SignUtils.getSignFacing(block), profile);
|
||||
if(profile == null) {
|
||||
messageBridge.message(sender, "addsign-success", region);
|
||||
} else {
|
||||
messageBridge.message(sender, "addsign-successProfile", profile, region);
|
||||
}
|
||||
region.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(fileManager.getRegionNames());
|
||||
} else if(toComplete == 3) {
|
||||
result.addAll(plugin.getConfig().getStringList("signProfiles"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if (toComplete == 2) {
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
} else if (toComplete == 3) {
|
||||
result.addAll(plugin.getConfig().getStringList("signProfiles"));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,15 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class BuyCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop buy";
|
||||
@@ -39,17 +26,18 @@ public class BuyCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.buy")) {
|
||||
messageBridge.message(sender, "buy-noPermission");
|
||||
plugin.message(sender, "buy-noPermission");
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
if(args.length > 1 && args[1] != null) {
|
||||
BuyRegion region = fileManager.getBuy(args[1]);
|
||||
BuyRegion region = plugin.getFileManager().getBuy(args[1]);
|
||||
if(region == null) {
|
||||
messageBridge.message(player, "buy-notBuyable", args[1]);
|
||||
plugin.message(player, "buy-notBuyable", args[1]);
|
||||
} else {
|
||||
region.buy(player);
|
||||
}
|
||||
@@ -57,9 +45,9 @@ public class BuyCommand extends CommandAreaShop {
|
||||
// get the region by location
|
||||
List<BuyRegion> regions = Utils.getImportantBuyRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
} else {
|
||||
regions.get(0).buy(player);
|
||||
}
|
||||
@@ -70,7 +58,7 @@ public class BuyCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
for(BuyRegion region : fileManager.getBuysRef()) {
|
||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||
if(!region.isSold()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
|
||||
@@ -1,29 +1,23 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.tools.SimpleMessageBridge;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Abstract class for generalising command classes.
|
||||
*/
|
||||
public abstract class CommandAreaShop {
|
||||
|
||||
final AreaShop plugin = AreaShop.getInstance();
|
||||
|
||||
private final Map<String, CommandTime> lastUsed;
|
||||
|
||||
protected CommandAreaShop() {
|
||||
public CommandAreaShop() {
|
||||
lastUsed = new HashMap<>();
|
||||
}
|
||||
|
||||
@@ -49,7 +43,7 @@ public abstract class CommandAreaShop {
|
||||
* @return A collection with all the possibilities for argument to complete
|
||||
*/
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
return new ArrayList<>();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,8 +81,7 @@ public abstract class CommandAreaShop {
|
||||
return true;
|
||||
}
|
||||
|
||||
Message m = message.prefix().append(Message.fromKey("confirm-yes").replacements(command));
|
||||
SimpleMessageBridge.send(m, sender);
|
||||
message.prefix().append(Message.fromKey("confirm-yes").replacements(command)).send(sender);
|
||||
lastUsed.put(sender.getName(), new CommandTime(command, now));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
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.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
@@ -17,17 +12,10 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Singleton
|
||||
public class DelCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private WorldEditInterface worldEditInterface;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop del";
|
||||
@@ -48,23 +36,24 @@ public class DelCommand extends CommandAreaShop {
|
||||
|
||||
&& !sender.hasPermission("areashop.destroyrent")
|
||||
&& !sender.hasPermission("areashop.destroyrent.landlord")) {
|
||||
messageBridge.message(sender, "del-noPermission");
|
||||
plugin.message(sender, "del-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2) {
|
||||
// Only players can have a selection
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-weOnlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-weOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
WorldEditSelection selection = worldEditInterface.getPlayerSelection(player);
|
||||
Player player = (Player)sender;
|
||||
WorldEditSelection selection = plugin.getWorldEditHandler().getPlayerSelection(player);
|
||||
if(selection == null) {
|
||||
messageBridge.message(player, "cmd-noSelection");
|
||||
plugin.message(player, "cmd-noSelection");
|
||||
return;
|
||||
}
|
||||
List<GeneralRegion> regions = Utils.getRegionsInSelection(selection);
|
||||
if(regions == null || regions.isEmpty()) {
|
||||
messageBridge.message(player, "cmd-noRegionsFound");
|
||||
if(regions.isEmpty()) {
|
||||
plugin.message(player, "cmd-noRegionsFound");
|
||||
return;
|
||||
}
|
||||
// Start removing the regions that he has permission for
|
||||
@@ -85,7 +74,7 @@ public class DelCommand extends CommandAreaShop {
|
||||
}
|
||||
}
|
||||
|
||||
DeletingRegionEvent event = fileManager.deleteRegion(region, true);
|
||||
DeletingRegionEvent event = plugin.getFileManager().deleteRegion(region, true);
|
||||
if (event.isCancelled()) {
|
||||
regionsCancelled.add(region);
|
||||
} else {
|
||||
@@ -95,46 +84,50 @@ public class DelCommand extends CommandAreaShop {
|
||||
|
||||
// Send messages
|
||||
if(!namesSuccess.isEmpty()) {
|
||||
messageBridge.message(sender, "del-success", Utils.createCommaSeparatedList(namesSuccess));
|
||||
plugin.message(sender, "del-success", Utils.createCommaSeparatedList(namesSuccess));
|
||||
}
|
||||
if(!regionsFailed.isEmpty()) {
|
||||
messageBridge.message(sender, "del-failed", Utils.combinedMessage(regionsFailed, "region"));
|
||||
plugin.message(sender, "del-failed", Utils.combinedMessage(regionsFailed, "region"));
|
||||
}
|
||||
if(!regionsCancelled.isEmpty()) {
|
||||
messageBridge.message(sender, "del-cancelled", Utils.combinedMessage(regionsCancelled, "region"));
|
||||
plugin.message(sender, "del-cancelled", Utils.combinedMessage(regionsCancelled, "region"));
|
||||
}
|
||||
} else {
|
||||
GeneralRegion region = fileManager.getRegion(args[1]);
|
||||
if(region == null) {
|
||||
messageBridge.message(sender, "cmd-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
boolean isLandlord = sender instanceof Player && region.isLandlord(((Player)sender).getUniqueId());
|
||||
if(region instanceof RentRegion) {
|
||||
// Remove the rent if the player has permission
|
||||
if(sender.hasPermission("areashop.destroyrent") || (isLandlord && sender.hasPermission("areashop.destroyrent.landlord"))) {
|
||||
DeletingRegionEvent event = fileManager.deleteRegion(region, true);
|
||||
if (event.isCancelled()) {
|
||||
messageBridge.message(sender, "general-cancelled", event.getReason());
|
||||
} else {
|
||||
messageBridge.message(sender, "destroy-successRent", region);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "destroy-noPermissionRent", region);
|
||||
}
|
||||
} else if(region instanceof BuyRegion) {
|
||||
// Remove the buy if the player has permission
|
||||
if(sender.hasPermission("areashop.destroybuy") || (isLandlord && sender.hasPermission("areashop.destroybuy.landlord"))) {
|
||||
DeletingRegionEvent event = fileManager.deleteRegion(region, true);
|
||||
if (event.isCancelled()) {
|
||||
messageBridge.message(sender, "general-cancelled", event.getReason());
|
||||
} else {
|
||||
messageBridge.message(sender, "destroy-successBuy", region);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "destroy-noPermissionBuy", region);
|
||||
}
|
||||
}
|
||||
CompletableFuture<GeneralRegion> future = plugin.getFileManager().getRegionUnsafe(args[1]);
|
||||
Utils.newChain()
|
||||
.future(future)
|
||||
.syncLast(region -> {
|
||||
if(region == null) {
|
||||
plugin.message(sender, "cmd-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
boolean isLandlord = sender instanceof Player && region.isLandlord(((Player)sender).getUniqueId());
|
||||
if(region instanceof RentRegion) {
|
||||
// Remove the rent if the player has permission
|
||||
if(sender.hasPermission("areashop.destroyrent") || (isLandlord && sender.hasPermission("areashop.destroyrent.landlord"))) {
|
||||
DeletingRegionEvent event = plugin.getFileManager().deleteRegion(region, true);
|
||||
if (event.isCancelled()) {
|
||||
plugin.message(sender, "general-cancelled", event.getReason());
|
||||
} else {
|
||||
plugin.message(sender, "destroy-successRent", region);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "destroy-noPermissionRent", region);
|
||||
}
|
||||
} else if(region instanceof BuyRegion) {
|
||||
// Remove the buy if the player has permission
|
||||
if(sender.hasPermission("areashop.destroybuy") || (isLandlord && sender.hasPermission("areashop.destroybuy.landlord"))) {
|
||||
DeletingRegionEvent event = plugin.getFileManager().deleteRegion(region, true);
|
||||
if (event.isCancelled()) {
|
||||
plugin.message(sender, "general-cancelled", event.getReason());
|
||||
} else {
|
||||
plugin.message(sender, "destroy-successBuy", region);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "destroy-noPermissionBuy", region);
|
||||
}
|
||||
}
|
||||
}).execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +135,7 @@ public class DelCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result = fileManager.getRegionNames();
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,134 +1,120 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class DelfriendCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop delfriend";
|
||||
}
|
||||
|
||||
@Inject
|
||||
private OfflinePlayerHelper offlinePlayerHelper;
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.delfriendall") || target.hasPermission("areashop.delfriend")) {
|
||||
return "help-delFriend";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Inject
|
||||
private BukkitSchedulerExecutor executor;
|
||||
/**
|
||||
* Check if a person can remove friends.
|
||||
* @param person The person to check
|
||||
* @param region The region to check for
|
||||
* @return true if the person can remove friends, otherwise false
|
||||
*/
|
||||
public static boolean canUse(CommandSender person, GeneralRegion region) {
|
||||
if(person.hasPermission("areashop.delfriendall")) {
|
||||
return true;
|
||||
}
|
||||
if(person instanceof Player) {
|
||||
Player player = (Player)person;
|
||||
return region.isOwner(player) && player.hasPermission("areashop.delfriend");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop delfriend";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (target.hasPermission("areashop.delfriendall") || target.hasPermission("areashop.delfriend")) {
|
||||
return "help-delFriend";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a person can remove friends.
|
||||
*
|
||||
* @param person The person to check
|
||||
* @param region The region to check for
|
||||
* @return true if the person can remove friends, otherwise false
|
||||
*/
|
||||
public static boolean canUse(CommandSender person, GeneralRegion region) {
|
||||
if (person.hasPermission("areashop.delfriendall")) {
|
||||
return true;
|
||||
}
|
||||
if (person instanceof Player player) {
|
||||
return region.isOwner(player) && player.hasPermission("areashop.delfriend");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.delfriend") && !sender.hasPermission("areashop.delfriendall")) {
|
||||
messageBridge.message(sender, "delfriend-noPermission");
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
messageBridge.message(sender, "delfriend-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if (args.length == 2) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(player.getLocation());
|
||||
if (regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if (regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
region = fileManager.getRegion(args[2]);
|
||||
if (region == null) {
|
||||
messageBridge.message(sender, "cmd-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (sender.hasPermission("areashop.delfriendall")) {
|
||||
if ((region instanceof RentRegion rentRegion && !rentRegion.isRented())
|
||||
|| (region instanceof BuyRegion buyRegion && !buyRegion.isSold())) {
|
||||
messageBridge.message(sender, "delfriend-noOwner", region);
|
||||
return;
|
||||
}
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(args[1]).thenAcceptAsync(friend -> {
|
||||
if (!region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
messageBridge.message(sender, "delfriend-notAdded", friend.getName(), region);
|
||||
return;
|
||||
}
|
||||
if (region.getFriendsFeature().deleteFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
messageBridge.message(sender, "delfriend-successOther", friend.getName(), region);
|
||||
}
|
||||
}, this.executor);
|
||||
return;
|
||||
}
|
||||
if (!sender.hasPermission("areashop.delfriend") || !(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "delfriend-noPermission", region);
|
||||
return;
|
||||
}
|
||||
if (!region.isOwner(player)) {
|
||||
messageBridge.message(sender, "delfriend-noPermissionOther", region);
|
||||
return;
|
||||
}
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(args[1]).thenAcceptAsync(friend -> {
|
||||
if (!region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
messageBridge.message(sender, "delfriend-notAdded", friend.getName(), region);
|
||||
} else if (region.getFriendsFeature().deleteFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
messageBridge.message(sender, "delfriend-success", friend.getName(), region);
|
||||
}
|
||||
}, this.executor);
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.delfriend") && !sender.hasPermission("areashop.delfriendall")) {
|
||||
plugin.message(sender, "delfriend-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2) {
|
||||
plugin.message(sender, "delfriend-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if(args.length <= 2) {
|
||||
if(sender instanceof Player) {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
region = plugin.getFileManager().getRegion(args[2]);
|
||||
if(region == null) {
|
||||
plugin.message(sender, "cmd-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(sender.hasPermission("areashop.delfriendall")) {
|
||||
if((region instanceof RentRegion && !((RentRegion)region).isRented())
|
||||
|| (region instanceof BuyRegion && !((BuyRegion)region).isSold())) {
|
||||
plugin.message(sender, "delfriend-noOwner", region);
|
||||
return;
|
||||
}
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(!region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
plugin.message(sender, "delfriend-notAdded", friend.getName(), region);
|
||||
return;
|
||||
}
|
||||
if(region.getFriendsFeature().deleteFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
plugin.message(sender, "delfriend-successOther", friend.getName(), region);
|
||||
}
|
||||
} else {
|
||||
if(sender.hasPermission("areashop.delfriend") && sender instanceof Player) {
|
||||
if(region.isOwner((Player)sender)) {
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(!region.getFriendsFeature().getFriends().contains(friend.getUniqueId())) {
|
||||
plugin.message(sender, "delfriend-notAdded", friend.getName(), region);
|
||||
return;
|
||||
}
|
||||
if(region.getFriendsFeature().deleteFriend(friend.getUniqueId(), sender)) {
|
||||
region.update();
|
||||
plugin.message(sender, "delfriend-success", friend.getName(), region);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "delfriend-noPermissionOther", region);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "delfriend-noPermission", region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
@@ -138,7 +124,7 @@ public class DelfriendCommand extends CommandAreaShop {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if(toComplete == 3) {
|
||||
result.addAll(fileManager.getRegionNames());
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.features.signs.RegionSign;
|
||||
import me.wiefferink.areashop.features.signs.SignManager;
|
||||
import me.wiefferink.areashop.features.signs.SignsFeature;
|
||||
import me.wiefferink.areashop.tools.Materials;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -14,16 +11,9 @@ import org.bukkit.util.BlockIterator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Singleton
|
||||
public class DelsignCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private SignManager signManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop delsign";
|
||||
@@ -40,37 +30,35 @@ public class DelsignCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.delsign")) {
|
||||
messageBridge.message(sender, "delsign-noPermission");
|
||||
plugin.message(sender, "delsign-noPermission");
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
|
||||
// Get the sign
|
||||
Block block = null;
|
||||
BlockIterator blockIterator = new BlockIterator(player, 100);
|
||||
while(blockIterator.hasNext() && block == null) {
|
||||
Block next = blockIterator.next();
|
||||
if(!next.getType().isAir()) {
|
||||
if(next.getType() != Material.AIR) {
|
||||
block = next;
|
||||
}
|
||||
}
|
||||
if(block == null || !Materials.isSign(block.getType())) {
|
||||
messageBridge.message(sender, "delsign-noSign");
|
||||
plugin.message(sender, "delsign-noSign");
|
||||
return;
|
||||
}
|
||||
Optional<RegionSign> optionalSign = signManager.removeSign(block.getLocation());
|
||||
if(optionalSign.isEmpty()) {
|
||||
messageBridge.message(sender, "delsign-noRegion");
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if(regionSign == null) {
|
||||
plugin.message(sender, "delsign-noRegion");
|
||||
return;
|
||||
}
|
||||
RegionSign regionSign = optionalSign.get();
|
||||
messageBridge.message(sender, "delsign-success", regionSign.getRegion());
|
||||
plugin.message(sender, "delsign-success", regionSign.getRegion());
|
||||
regionSign.remove();
|
||||
// Sometimes the RegionSign data is corrupted. Forcefully set the block to air
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,35 +1,20 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.RegionGroup;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
@Singleton
|
||||
public class FindCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private Economy economy;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop find";
|
||||
@@ -46,20 +31,21 @@ public class FindCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.find")) {
|
||||
messageBridge.message(sender, "find-noPermission");
|
||||
plugin.message(sender, "find-noPermission");
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
if(args.length <= 1 || args[1] == null || (!args[1].equalsIgnoreCase("buy") && !args[1].equalsIgnoreCase("rent"))) {
|
||||
messageBridge.message(sender, "find-help");
|
||||
plugin.message(sender, "find-help");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
double balance = 0.0;
|
||||
if(economy != null) {
|
||||
balance = economy.getBalance(player);
|
||||
if(plugin.getEconomy() != null) {
|
||||
balance = plugin.getEconomy().getBalance(player);
|
||||
}
|
||||
double maxPrice = 0;
|
||||
boolean maxPriceSet = false;
|
||||
@@ -70,23 +56,23 @@ public class FindCommand extends CommandAreaShop {
|
||||
maxPrice = Double.parseDouble(args[2]);
|
||||
maxPriceSet = true;
|
||||
} catch(NumberFormatException e) {
|
||||
messageBridge.message(sender, "find-wrongMaxPrice", args[2]);
|
||||
plugin.message(sender, "find-wrongMaxPrice", args[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Parse optional group argument
|
||||
if(args.length >= 4) {
|
||||
group = fileManager.getGroup(args[3]);
|
||||
group = plugin.getFileManager().getGroup(args[3]);
|
||||
if(group == null) {
|
||||
messageBridge.message(sender, "find-wrongGroup", args[3]);
|
||||
plugin.message(sender, "find-wrongGroup", args[3]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Find buy regions
|
||||
if(args[1].equalsIgnoreCase("buy")) {
|
||||
Collection<BuyRegion> regions = fileManager.getBuysRef();
|
||||
List<BuyRegion> results = new LinkedList<>();
|
||||
List<BuyRegion> regions = plugin.getFileManager().getBuys();
|
||||
List<BuyRegion> results = new ArrayList<>();
|
||||
for(BuyRegion region : regions) {
|
||||
if(!region.isSold()
|
||||
&& ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))
|
||||
@@ -105,9 +91,9 @@ public class FindCommand extends CommandAreaShop {
|
||||
|
||||
// Teleport
|
||||
if(maxPriceSet) {
|
||||
messageBridge.message(player, "find-successMax", "buy", Utils.formatCurrency(maxPrice), onlyInGroup, region);
|
||||
plugin.message(player, "find-successMax", "buy", Utils.formatCurrency(maxPrice), onlyInGroup, region);
|
||||
} else {
|
||||
messageBridge.message(player, "find-success", "buy", Utils.formatCurrency(balance), onlyInGroup, region);
|
||||
plugin.message(player, "find-success", "buy", Utils.formatCurrency(balance), onlyInGroup, region);
|
||||
}
|
||||
region.getTeleportFeature().teleportPlayer(player, region.getBooleanSetting("general.findTeleportToSign"), false);
|
||||
} else {
|
||||
@@ -116,17 +102,17 @@ public class FindCommand extends CommandAreaShop {
|
||||
onlyInGroup = Message.fromKey("find-onlyInGroup").replacements(args[3]);
|
||||
}
|
||||
if(maxPriceSet) {
|
||||
messageBridge.message(player, "find-noneFoundMax", "buy", Utils.formatCurrency(maxPrice), onlyInGroup);
|
||||
plugin.message(player, "find-noneFoundMax", "buy", Utils.formatCurrency(maxPrice), onlyInGroup);
|
||||
} else {
|
||||
messageBridge.message(player, "find-noneFound", "buy", Utils.formatCurrency(balance), onlyInGroup);
|
||||
plugin.message(player, "find-noneFound", "buy", Utils.formatCurrency(balance), onlyInGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find rental regions
|
||||
else {
|
||||
Collection<RentRegion> regions = fileManager.getRentsRef();
|
||||
List<RentRegion> results = new LinkedList<>();
|
||||
List<RentRegion> regions = plugin.getFileManager().getRents();
|
||||
List<RentRegion> results = new ArrayList<>();
|
||||
for(RentRegion region : regions) {
|
||||
if(!region.isRented()
|
||||
&& ((region.getPrice() <= balance && !maxPriceSet) || (region.getPrice() <= maxPrice && maxPriceSet))
|
||||
@@ -145,9 +131,9 @@ public class FindCommand extends CommandAreaShop {
|
||||
|
||||
// Teleport
|
||||
if(maxPriceSet) {
|
||||
messageBridge.message(player, "find-successMax", "rent", Utils.formatCurrency(maxPrice), onlyInGroup, region);
|
||||
plugin.message(player, "find-successMax", "rent", Utils.formatCurrency(maxPrice), onlyInGroup, region);
|
||||
} else {
|
||||
messageBridge.message(player, "find-success", "rent", Utils.formatCurrency(balance), onlyInGroup, region);
|
||||
plugin.message(player, "find-success", "rent", Utils.formatCurrency(balance), onlyInGroup, region);
|
||||
}
|
||||
region.getTeleportFeature().teleportPlayer(player, region.getBooleanSetting("general.findTeleportToSign"), false);
|
||||
} else {
|
||||
@@ -156,9 +142,9 @@ public class FindCommand extends CommandAreaShop {
|
||||
onlyInGroup = Message.fromKey("find-onlyInGroup").replacements(args[3]);
|
||||
}
|
||||
if(maxPriceSet) {
|
||||
messageBridge.message(player, "find-noneFoundMax", "rent", Utils.formatCurrency(maxPrice), onlyInGroup);
|
||||
plugin.message(player, "find-noneFoundMax", "rent", Utils.formatCurrency(maxPrice), onlyInGroup);
|
||||
} else {
|
||||
messageBridge.message(player, "find-noneFound", "rent", Utils.formatCurrency(balance), onlyInGroup);
|
||||
plugin.message(player, "find-noneFound", "rent", Utils.formatCurrency(balance), onlyInGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.interfaces.WorldEditInterface;
|
||||
import me.wiefferink.areashop.interfaces.WorldEditSelection;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
import me.wiefferink.areashop.regions.RegionGroup;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -17,19 +11,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
@Singleton
|
||||
public class GroupaddCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private RegionFactory regionFactory;
|
||||
@Inject
|
||||
private WorldEditInterface worldEditInterface;
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop groupadd";
|
||||
@@ -46,31 +29,32 @@ public class GroupaddCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.groupadd")) {
|
||||
messageBridge.message(sender, "groupadd-noPermission");
|
||||
plugin.message(sender, "groupadd-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2 || args[1] == null) {
|
||||
messageBridge.message(sender, "groupadd-help");
|
||||
plugin.message(sender, "groupadd-help");
|
||||
return;
|
||||
}
|
||||
RegionGroup group = fileManager.getGroup(args[1]);
|
||||
RegionGroup group = plugin.getFileManager().getGroup(args[1]);
|
||||
if(group == null) {
|
||||
group = regionFactory.createRegionGroup(args[1]);
|
||||
fileManager.addGroup(group);
|
||||
group = new RegionGroup(plugin, args[1]);
|
||||
plugin.getFileManager().addGroup(group);
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-weOnlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-weOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
WorldEditSelection selection = worldEditInterface.getPlayerSelection(player);
|
||||
Player player = (Player)sender;
|
||||
WorldEditSelection selection = plugin.getWorldEditHandler().getPlayerSelection(player);
|
||||
if(selection == null) {
|
||||
messageBridge.message(player, "cmd-noSelection");
|
||||
plugin.message(player, "cmd-noSelection");
|
||||
return;
|
||||
}
|
||||
List<GeneralRegion> regions = Utils.getRegionsInSelection(selection);
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(player, "cmd-noRegionsFound");
|
||||
plugin.message(player, "cmd-noRegionsFound");
|
||||
return;
|
||||
}
|
||||
TreeSet<GeneralRegion> regionsSuccess = new TreeSet<>();
|
||||
@@ -83,24 +67,24 @@ public class GroupaddCommand extends CommandAreaShop {
|
||||
}
|
||||
}
|
||||
if(!regionsSuccess.isEmpty()) {
|
||||
messageBridge.message(player, "groupadd-weSuccess", group.getName(), Utils.combinedMessage(regionsSuccess, "region"));
|
||||
plugin.message(player, "groupadd-weSuccess", group.getName(), Utils.combinedMessage(regionsSuccess, "region"));
|
||||
}
|
||||
if(!regionsFailed.isEmpty()) {
|
||||
messageBridge.message(player, "groupadd-weFailed", group.getName(), Utils.combinedMessage(regionsFailed, "region"));
|
||||
plugin.message(player, "groupadd-weFailed", group.getName(), Utils.combinedMessage(regionsFailed, "region"));
|
||||
}
|
||||
// Update all regions, this does it in a task, updating them without lag
|
||||
fileManager.updateRegions(new ArrayList<>(regionsSuccess), player);
|
||||
plugin.getFileManager().updateRegions(new ArrayList<>(regionsSuccess), player);
|
||||
} else {
|
||||
GeneralRegion region = fileManager.getRegion(args[2]);
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[2]);
|
||||
if(region == null) {
|
||||
messageBridge.message(sender, "cmd-notRegistered", args[2]);
|
||||
plugin.message(sender, "cmd-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
if(group.addMember(region)) {
|
||||
region.update();
|
||||
messageBridge.message(sender, "groupadd-success", group.getName(), group.getMembers().size(), region);
|
||||
plugin.message(sender, "groupadd-success", group.getName(), group.getMembers().size(), region);
|
||||
} else {
|
||||
messageBridge.message(sender, "groupadd-failed", group.getName(), region);
|
||||
plugin.message(sender, "groupadd-failed", group.getName(), region);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,9 +93,9 @@ public class GroupaddCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result = fileManager.getGroupNames();
|
||||
result = plugin.getFileManager().getGroupNames();
|
||||
} else if(toComplete == 3) {
|
||||
result = fileManager.getRegionNames();
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.interfaces.WorldEditInterface;
|
||||
import me.wiefferink.areashop.interfaces.WorldEditSelection;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
import me.wiefferink.areashop.regions.RegionGroup;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -17,18 +11,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
@Singleton
|
||||
public class GroupdelCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private RegionFactory regionFactory;
|
||||
@Inject
|
||||
private WorldEditInterface worldEditInterface;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop groupdel";
|
||||
@@ -45,32 +29,33 @@ public class GroupdelCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.groupdel")) {
|
||||
messageBridge.message(sender, "groupdel-noPermission");
|
||||
plugin.message(sender, "groupdel-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2 || args[1] == null) {
|
||||
messageBridge.message(sender, "groupdel-help");
|
||||
plugin.message(sender, "groupdel-help");
|
||||
return;
|
||||
}
|
||||
RegionGroup group = fileManager.getGroup(args[1]);
|
||||
RegionGroup group = plugin.getFileManager().getGroup(args[1]);
|
||||
if(group == null) {
|
||||
messageBridge.message(sender, "groupdel-wrongGroup", args[1]);
|
||||
plugin.message(sender, "groupdel-wrongGroup", args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length == 2) {
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-weOnlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-weOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
WorldEditSelection selection = worldEditInterface.getPlayerSelection(player);
|
||||
Player player = (Player)sender;
|
||||
WorldEditSelection selection = plugin.getWorldEditHandler().getPlayerSelection(player);
|
||||
if(selection == null) {
|
||||
messageBridge.message(player, "cmd-noSelection");
|
||||
plugin.message(player, "cmd-noSelection");
|
||||
return;
|
||||
}
|
||||
List<GeneralRegion> regions = Utils.getRegionsInSelection(selection);
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(player, "cmd-noRegionsFound");
|
||||
plugin.message(player, "cmd-noRegionsFound");
|
||||
return;
|
||||
}
|
||||
TreeSet<GeneralRegion> regionsSuccess = new TreeSet<>();
|
||||
@@ -83,25 +68,25 @@ public class GroupdelCommand extends CommandAreaShop {
|
||||
}
|
||||
}
|
||||
if(!regionsSuccess.isEmpty()) {
|
||||
messageBridge.message(player, "groupdel-weSuccess", group.getName(), Utils.combinedMessage(regionsSuccess, "region"));
|
||||
plugin.message(player, "groupdel-weSuccess", group.getName(), Utils.combinedMessage(regionsSuccess, "region"));
|
||||
}
|
||||
if(!regionsFailed.isEmpty()) {
|
||||
messageBridge.message(player, "groupdel-weFailed", group.getName(), Utils.combinedMessage(regionsFailed, "region"));
|
||||
plugin.message(player, "groupdel-weFailed", group.getName(), Utils.combinedMessage(regionsFailed, "region"));
|
||||
}
|
||||
// Update all regions, this does it in a task, updating them without lag
|
||||
fileManager.updateRegions(regionsSuccess, player);
|
||||
plugin.getFileManager().updateRegions(new ArrayList<>(regionsSuccess), player);
|
||||
group.saveRequired();
|
||||
} else {
|
||||
GeneralRegion region = fileManager.getRegion(args[2]);
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[2]);
|
||||
if(region == null) {
|
||||
messageBridge.message(sender, "cmd-notRegistered", args[2]);
|
||||
plugin.message(sender, "cmd-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
if(group.removeMember(region)) {
|
||||
region.update();
|
||||
messageBridge.message(sender, "groupdel-success", group.getName(), group.getMembers().size(), region);
|
||||
plugin.message(sender, "groupdel-success", group.getName(), group.getMembers().size(), region);
|
||||
} else {
|
||||
messageBridge.message(sender, "groupdel-failed", group.getName(), region);
|
||||
plugin.message(sender, "groupdel-failed", group.getName(), region);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,9 +95,9 @@ public class GroupdelCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result = fileManager.getGroupNames();
|
||||
result = plugin.getFileManager().getGroupNames();
|
||||
} else if(toComplete == 3) {
|
||||
result = fileManager.getRegionNames();
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.RegionGroup;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,14 +8,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
public class GroupinfoCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop groupinfo";
|
||||
@@ -37,23 +27,23 @@ public class GroupinfoCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.groupinfo")) {
|
||||
messageBridge.message(sender, "groupinfo-noPermission");
|
||||
plugin.message(sender, "groupinfo-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2 || args[1] == null) {
|
||||
messageBridge.message(sender, "groupinfo-help");
|
||||
plugin.message(sender, "groupinfo-help");
|
||||
return;
|
||||
}
|
||||
RegionGroup group = fileManager.getGroup(args[1]);
|
||||
RegionGroup group = plugin.getFileManager().getGroup(args[1]);
|
||||
if(group == null) {
|
||||
messageBridge.message(sender, "groupinfo-noGroup", args[1]);
|
||||
plugin.message(sender, "groupinfo-noGroup", args[1]);
|
||||
return;
|
||||
}
|
||||
Set<String> members = group.getMembers();
|
||||
if(members.isEmpty()) {
|
||||
messageBridge.message(sender, "groupinfo-noMembers", group.getName());
|
||||
plugin.message(sender, "groupinfo-noMembers", group.getName());
|
||||
} else {
|
||||
messageBridge.message(sender, "groupinfo-members", group.getName(), Utils.createCommaSeparatedList(members));
|
||||
plugin.message(sender, "groupinfo-members", group.getName(), Utils.createCommaSeparatedList(members));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +51,7 @@ public class GroupinfoCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result = fileManager.getGroupNames();
|
||||
result = plugin.getFileManager().getGroupNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,13 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class GrouplistCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop grouplist";
|
||||
@@ -34,14 +24,14 @@ public class GrouplistCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.grouplist")) {
|
||||
messageBridge.message(sender, "grouplist-noPermission");
|
||||
plugin.message(sender, "grouplist-noPermission");
|
||||
return;
|
||||
}
|
||||
List<String> groups = fileManager.getGroupNames();
|
||||
List<String> groups = plugin.getFileManager().getGroupNames();
|
||||
if(groups.isEmpty()) {
|
||||
messageBridge.message(sender, "grouplist-noGroups");
|
||||
plugin.message(sender, "grouplist-noGroups");
|
||||
} else {
|
||||
messageBridge.message(sender, "grouplist-success", Utils.createCommaSeparatedList(groups));
|
||||
plugin.message(sender, "grouplist-success", Utils.createCommaSeparatedList(groups));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import me.wiefferink.areashop.managers.CommandManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class HelpCommand extends CommandAreaShop {
|
||||
|
||||
private final CommandManager commandManager;
|
||||
|
||||
public HelpCommand(@Nonnull CommandManager commandManager) {
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop help";
|
||||
@@ -30,6 +19,6 @@ public class HelpCommand extends CommandAreaShop {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
commandManager.showHelp(sender);
|
||||
plugin.getCommandManager().showHelp(sender);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,11 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.regions.ImportJobFactory;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class ImportCommand extends CommandAreaShop {
|
||||
|
||||
/* RegionGroup priority usage:
|
||||
@@ -18,10 +13,6 @@ public class ImportCommand extends CommandAreaShop {
|
||||
1: Settings from /worlds/<world>/config.yml
|
||||
2: Settings from /worlds/<world>/parent-regions.yml (if their priority is set it is added to this value)
|
||||
*/
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private ImportJobFactory importJobFactory;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
@@ -45,17 +36,17 @@ public class ImportCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.import")) {
|
||||
messageBridge.message(sender, "import-noPermission");
|
||||
plugin.message(sender, "import-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length < 2) {
|
||||
messageBridge.message(sender, "import-help");
|
||||
plugin.message(sender, "import-help");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!"RegionForSale".equalsIgnoreCase(args[1])) {
|
||||
messageBridge.message(sender, "import-wrongSource");
|
||||
plugin.message(sender, "import-wrongSource");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +54,7 @@ public class ImportCommand extends CommandAreaShop {
|
||||
return;
|
||||
}
|
||||
|
||||
importJobFactory.createImportJob(sender).execute();
|
||||
new ImportJob(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+32
-52
@@ -1,17 +1,16 @@
|
||||
package me.wiefferink.areashop.regions;
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
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.IFileManager;
|
||||
import me.wiefferink.areashop.features.signs.SignsFeature;
|
||||
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.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -21,52 +20,33 @@ import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ImportJob {
|
||||
|
||||
private final AreaShop plugin;
|
||||
private final IFileManager fileManager;
|
||||
private final SignManager signManager;
|
||||
private final WorldGuardInterface worldGuardInterface;
|
||||
private final CommandSender sender;
|
||||
private final MessageBridge messageBridge;
|
||||
private final RegionFactory regionFactory;
|
||||
|
||||
/**
|
||||
* Create and execute the import.
|
||||
* @param sender CommandSender that should receive progress updates
|
||||
*/
|
||||
@AssistedInject
|
||||
ImportJob(
|
||||
@Nonnull AreaShop plugin,
|
||||
@Nonnull IFileManager fileManager,
|
||||
@Nonnull SignManager signManager,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull RegionFactory regionFactory,
|
||||
@Assisted @Nonnull CommandSender sender) {
|
||||
this.regionFactory = regionFactory;
|
||||
public ImportJob(CommandSender sender) {
|
||||
this.sender = sender;
|
||||
this.plugin = plugin;
|
||||
this.signManager = signManager;
|
||||
this.fileManager = fileManager;
|
||||
this.worldGuardInterface = worldGuardInterface;
|
||||
this.messageBridge = messageBridge;
|
||||
this.plugin = AreaShop.getInstance();
|
||||
execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public void execute() {
|
||||
private void execute() {
|
||||
// Check for RegionForSale data
|
||||
File regionForSaleFolder = new File(plugin.getDataFolder().getParentFile().getAbsolutePath(), "RegionForSale");
|
||||
if(!regionForSaleFolder.exists()) {
|
||||
@@ -90,8 +70,8 @@ public class ImportJob {
|
||||
message("import-start");
|
||||
|
||||
// Group with settings for all imported regions
|
||||
RegionGroup regionForSaleGroup = regionFactory.createRegionGroup("RegionForSale");
|
||||
fileManager.addGroup(regionForSaleGroup);
|
||||
RegionGroup regionForSaleGroup = new RegionGroup(plugin, "RegionForSale");
|
||||
plugin.getFileManager().addGroup(regionForSaleGroup);
|
||||
|
||||
// Import /RegionForSale/config.yml settings
|
||||
File regionForSaleConfigFile = new File(regionForSaleFolder.getAbsolutePath(), "config.yml");
|
||||
@@ -169,11 +149,11 @@ public class ImportJob {
|
||||
worldConfig = new YamlConfiguration();
|
||||
} else {
|
||||
// RegionGroup with all world settings
|
||||
RegionGroup worldGroup = regionFactory.createRegionGroup("RegionForSale-" + worldFolder.getName());
|
||||
RegionGroup worldGroup = new RegionGroup(plugin, "RegionForSale-" + worldFolder.getName());
|
||||
importRegionSettings(worldConfig, worldGroup.getSettings(), null, false);
|
||||
worldGroup.setSetting("priority", 1);
|
||||
worldGroup.addWorld(worldFolder.getName());
|
||||
fileManager.addGroup(regionForSaleGroup);
|
||||
plugin.getFileManager().addGroup(regionForSaleGroup);
|
||||
worldGroup.saveRequired();
|
||||
}
|
||||
|
||||
@@ -205,7 +185,7 @@ public class ImportJob {
|
||||
}
|
||||
|
||||
// Import parent region settings into a RegionGroup
|
||||
RegionGroup parentRegionGroup = regionFactory.createRegionGroup( "RegionForSale-" + worldFolder.getName() + "-" + parentRegionName);
|
||||
RegionGroup parentRegionGroup = new RegionGroup(plugin, "RegionForSale-" + worldFolder.getName() + "-" + parentRegionName);
|
||||
importRegionSettings(parentRegionSection, parentRegionGroup.getSettings(), null, false);
|
||||
parentRegionGroup.setSetting("priority", 2 + parentRegionSection.getLong("info.priority", 0));
|
||||
parentRegionGroup.saveRequired();
|
||||
@@ -217,7 +197,7 @@ public class ImportJob {
|
||||
|
||||
// Read and import regions
|
||||
for(String regionKey : regions.getKeys(false)) {
|
||||
GeneralRegion existingRegion = fileManager.getRegion(regionKey);
|
||||
GeneralRegion existingRegion = plugin.getFileManager().getRegion(regionKey);
|
||||
if(existingRegion != null) {
|
||||
if(world.getName().equalsIgnoreCase(existingRegion.getWorldName())) {
|
||||
messageNoPrefix("import-alreadyAdded", regionKey);
|
||||
@@ -260,9 +240,9 @@ public class ImportJob {
|
||||
// Create region
|
||||
GeneralRegion region;
|
||||
if(rentable || (owner != null && !isBought)) {
|
||||
region = regionFactory.createRentRegion(regionKey, world);
|
||||
region = new RentRegion(regionKey, world);
|
||||
} else {
|
||||
region = regionFactory.createBuyRegion(regionKey, world);
|
||||
region = new BuyRegion(regionKey, world);
|
||||
}
|
||||
AddingRegionEvent event = plugin.getFileManager().addRegion(region);
|
||||
if (event.isCancelled()) {
|
||||
@@ -279,16 +259,16 @@ public class ImportJob {
|
||||
if(owner != null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(owner);
|
||||
if(offlinePlayer.hasPlayedBefore()) {
|
||||
if(offlinePlayer != null) {
|
||||
existing.add(offlinePlayer.getUniqueId());
|
||||
}
|
||||
}
|
||||
for(UUID uuid : worldGuardInterface.getOwners(worldGuardRegion).asUniqueIdList()) {
|
||||
for(UUID uuid : plugin.getWorldGuardHandler().getOwners(worldGuardRegion).asUniqueIdList()) {
|
||||
if(!existing.contains(uuid)) {
|
||||
existing.add(uuid);
|
||||
}
|
||||
}
|
||||
for(UUID uuid : worldGuardInterface.getMembers(worldGuardRegion).asUniqueIdList()) {
|
||||
for(UUID uuid : plugin.getWorldGuardHandler().getMembers(worldGuardRegion).asUniqueIdList()) {
|
||||
if(!existing.contains(uuid)) {
|
||||
existing.add(uuid);
|
||||
}
|
||||
@@ -310,9 +290,9 @@ public class ImportJob {
|
||||
}
|
||||
|
||||
// Update all regions
|
||||
fileManager.updateAllRegions(sender);
|
||||
plugin.getFileManager().updateAllRegions(sender);
|
||||
// Write all imported regions and settings to disk
|
||||
fileManager.saveRequiredFiles();
|
||||
plugin.getFileManager().saveRequiredFiles();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -393,7 +373,8 @@ public class ImportJob {
|
||||
|
||||
// Set rented until
|
||||
if(from.isLong("info.last-withdrawal")
|
||||
&& region instanceof RentRegion rentRegion) {
|
||||
&& region instanceof RentRegion) {
|
||||
RentRegion rentRegion = (RentRegion)region;
|
||||
long lastWithdrawal = from.getLong("info.last-withdrawal");
|
||||
// Because the rental duration is already imported into the region and its parents this should be correct
|
||||
rentRegion.setRentedUntil(lastWithdrawal + rentRegion.getDuration());
|
||||
@@ -418,9 +399,8 @@ public class ImportJob {
|
||||
}
|
||||
|
||||
// Check if this location is already added to a region
|
||||
Optional<RegionSign> optionalRegionSign = signManager.signFromLocation(location);
|
||||
if(optionalRegionSign.isPresent()) {
|
||||
RegionSign regionSign = optionalRegionSign.get();
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(location);
|
||||
if(regionSign != null) {
|
||||
if(!regionSign.getRegion().equals(region)) {
|
||||
message("import-signAlreadyAdded", region.getName(), signLocation, regionSign.getRegion().getName());
|
||||
}
|
||||
@@ -444,7 +424,7 @@ public class ImportJob {
|
||||
}
|
||||
}
|
||||
|
||||
private static final List<TimeUnit> timeUnitLookup = new ArrayList<>() {
|
||||
private static final List<TimeUnit> timeUnitLookup = new ArrayList<TimeUnit>() {
|
||||
{
|
||||
add(new TimeUnit(60 * 24 * 30 * 12, "year"));
|
||||
add(new TimeUnit(60 * 24 * 30, "month"));
|
||||
@@ -479,10 +459,10 @@ public class ImportJob {
|
||||
* @param replacements The replacements to insert in the message
|
||||
*/
|
||||
public void messageNoPrefix(String key, Object... replacements) {
|
||||
messageBridge.messageNoPrefix(sender, key, replacements);
|
||||
plugin.messageNoPrefix(sender, key, replacements);
|
||||
|
||||
if(!(sender instanceof ConsoleCommandSender)) {
|
||||
messageBridge.messageNoPrefix(Bukkit.getConsoleSender(), key, replacements);
|
||||
plugin.messageNoPrefix(Bukkit.getConsoleSender(), key, replacements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,10 +472,10 @@ public class ImportJob {
|
||||
* @param replacements The replacements to insert in the message
|
||||
*/
|
||||
public void message(String key, Object... replacements) {
|
||||
messageBridge.message(sender, key, replacements);
|
||||
plugin.message(sender, key, replacements);
|
||||
|
||||
if(!(sender instanceof ConsoleCommandSender)) {
|
||||
messageBridge.message(Bukkit.getConsoleSender(), key, replacements);
|
||||
plugin.message(Bukkit.getConsoleSender(), key, replacements);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,12 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RegionGroup;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.SimpleMessageBridge;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.apache.logging.log4j.message.SimpleMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -29,14 +18,8 @@ import java.util.Set;
|
||||
|
||||
// TODO fix '/as info' help message hitting replacement limit (improve depth tracking?)
|
||||
// TODO add info about autoExtend
|
||||
@Singleton
|
||||
public class InfoCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop info";
|
||||
@@ -67,7 +50,7 @@ public class InfoCommand extends CommandAreaShop {
|
||||
try {
|
||||
page = Integer.parseInt(pageInput);
|
||||
} catch(NumberFormatException e) {
|
||||
messageBridge.message(sender, "info-wrongPage", pageInput);
|
||||
plugin.message(sender, "info-wrongPage", pageInput);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -75,7 +58,7 @@ public class InfoCommand extends CommandAreaShop {
|
||||
regions.removeIf(generalRegion -> !filterGroup.isMember(generalRegion));
|
||||
}
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "info-noRegions");
|
||||
plugin.message(sender, "info-noRegions");
|
||||
} else {
|
||||
// First sort by type, then by name
|
||||
regions.sort((one, two) -> {
|
||||
@@ -91,7 +74,7 @@ public class InfoCommand extends CommandAreaShop {
|
||||
if(filterGroup != null) {
|
||||
limitedToGroup = Message.fromKey("info-limitedToGroup").replacements(filterGroup.getName());
|
||||
}
|
||||
messageBridge.message(sender, keyHeader, limitedToGroup);
|
||||
plugin.message(sender, keyHeader, limitedToGroup);
|
||||
// Page entries
|
||||
int totalPages = (int)Math.ceil(regions.size() / (double)itemsPerPage); // Clip page to correct boundaries, not much need to tell the user
|
||||
if(regions.size() == itemsPerPage + 1) { // 19 total items is mapped to 1 page of 19
|
||||
@@ -118,7 +101,7 @@ public class InfoCommand extends CommandAreaShop {
|
||||
state = "Reselling";
|
||||
}
|
||||
}
|
||||
messageBridge.messageNoPrefix(sender, "info-entry" + state, region);
|
||||
plugin.messageNoPrefix(sender, "info-entry" + state, region);
|
||||
linesPrinted++;
|
||||
}
|
||||
Message footer = Message.empty();
|
||||
@@ -144,7 +127,7 @@ public class InfoCommand extends CommandAreaShop {
|
||||
for(int i = linesPrinted; i < maximumItems - 1; i++) {
|
||||
sender.sendMessage(" ");
|
||||
}
|
||||
SimpleMessageBridge.send(footer, sender);
|
||||
footer.send(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -175,7 +158,7 @@ public class InfoCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.info")) {
|
||||
messageBridge.message(sender, "info-noPermission");
|
||||
plugin.message(sender, "info-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length > 1 && args[1] != null) {
|
||||
@@ -184,9 +167,9 @@ public class InfoCommand extends CommandAreaShop {
|
||||
Set<String> groupFilters = new HashSet<>(Arrays.asList("all", "rented", "forrent", "sold", "forsale", "reselling"));
|
||||
if(groupFilters.contains(args[1].toLowerCase()) && args.length > 2) {
|
||||
if(!Utils.isNumeric(args[2])) {
|
||||
filterGroup = fileManager.getGroup(args[2]);
|
||||
filterGroup = plugin.getFileManager().getGroup(args[2]);
|
||||
if(filterGroup == null) {
|
||||
messageBridge.message(sender, "info-noFiltergroup", args[2]);
|
||||
plugin.message(sender, "info-noFiltergroup", args[2]);
|
||||
return;
|
||||
}
|
||||
// Pass page number to args[2] if available
|
||||
@@ -198,48 +181,48 @@ public class InfoCommand extends CommandAreaShop {
|
||||
|
||||
// All regions
|
||||
if(args[1].equalsIgnoreCase("all")) {
|
||||
showSortedPagedList(sender, new ArrayList<>(fileManager.getRegionsRef()), filterGroup, "info-allHeader", (args.length > 2 ? args[2] : null), "info all");
|
||||
showSortedPagedList(sender, plugin.getFileManager().getRegions(), filterGroup, "info-allHeader", (args.length > 2 ? args[2] : null), "info all");
|
||||
}
|
||||
|
||||
// Rented regions
|
||||
else if(args[1].equalsIgnoreCase("rented")) {
|
||||
List<RentRegion> regions = new ArrayList<>(fileManager.getRentsRef());
|
||||
List<RentRegion> regions = plugin.getFileManager().getRents();
|
||||
regions.removeIf(RentRegion::isAvailable);
|
||||
showSortedPagedList(sender, regions, filterGroup, "info-rentedHeader", (args.length > 2 ? args[2] : null), "info rented");
|
||||
}
|
||||
// Forrent regions
|
||||
else if(args[1].equalsIgnoreCase("forrent")) {
|
||||
List<RentRegion> regions = new ArrayList<>(fileManager.getRentsRef());
|
||||
List<RentRegion> regions = plugin.getFileManager().getRents();
|
||||
regions.removeIf(RentRegion::isRented);
|
||||
showSortedPagedList(sender, regions, filterGroup, "info-forrentHeader", (args.length > 2 ? args[2] : null), "info forrent");
|
||||
}
|
||||
// Sold regions
|
||||
else if(args[1].equalsIgnoreCase("sold")) {
|
||||
List<BuyRegion> regions = new ArrayList<>(fileManager.getBuysRef());
|
||||
List<BuyRegion> regions = plugin.getFileManager().getBuys();
|
||||
regions.removeIf(BuyRegion::isAvailable);
|
||||
showSortedPagedList(sender, regions, filterGroup, "info-soldHeader", (args.length > 2 ? args[2] : null), "info sold");
|
||||
}
|
||||
// Forsale regions
|
||||
else if(args[1].equalsIgnoreCase("forsale")) {
|
||||
List<BuyRegion> regions = new ArrayList<>(fileManager.getBuysRef());
|
||||
List<BuyRegion> regions = plugin.getFileManager().getBuys();
|
||||
regions.removeIf(BuyRegion::isSold);
|
||||
showSortedPagedList(sender, regions, filterGroup, "info-forsaleHeader", (args.length > 2 ? args[2] : null), "info forsale");
|
||||
}
|
||||
// Reselling regions
|
||||
else if(args[1].equalsIgnoreCase("reselling")) {
|
||||
List<BuyRegion> regions = new ArrayList<>(fileManager.getBuysRef());
|
||||
List<BuyRegion> regions = plugin.getFileManager().getBuys();
|
||||
regions.removeIf(region -> !region.isInResellingMode());
|
||||
showSortedPagedList(sender, regions, filterGroup, "info-resellingHeader", (args.length > 2 ? args[2] : null), "info reselling");
|
||||
}
|
||||
|
||||
// List of regions without a group
|
||||
else if(args[1].equalsIgnoreCase("nogroup")) {
|
||||
List<GeneralRegion> regions = new ArrayList<>(fileManager.getRegionsRef());
|
||||
for(RegionGroup group : fileManager.getGroups()) {
|
||||
List<GeneralRegion> regions = plugin.getFileManager().getRegions();
|
||||
for(RegionGroup group : plugin.getFileManager().getGroups()) {
|
||||
regions.removeAll(group.getMemberRegions());
|
||||
}
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "info-nogroupNone");
|
||||
plugin.message(sender, "info-nogroupNone");
|
||||
} else {
|
||||
showSortedPagedList(sender, regions, filterGroup, "info-nogroupHeader", (args.length > 2 ? args[2] : null), "info nogroup");
|
||||
}
|
||||
@@ -251,17 +234,17 @@ public class InfoCommand extends CommandAreaShop {
|
||||
RentRegion rent = null;
|
||||
BuyRegion buy = null;
|
||||
if(args.length > 2) {
|
||||
rent = fileManager.getRent(args[2]);
|
||||
buy = fileManager.getBuy(args[2]);
|
||||
rent = plugin.getFileManager().getRent(args[2]);
|
||||
buy = plugin.getFileManager().getBuy(args[2]);
|
||||
} else {
|
||||
if(sender instanceof Player) {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
if(regions.get(0) instanceof RentRegion) {
|
||||
@@ -271,26 +254,26 @@ public class InfoCommand extends CommandAreaShop {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(rent == null && buy == null) {
|
||||
messageBridge.message(sender, "info-regionNotExisting", args[2]);
|
||||
plugin.message(sender, "info-regionNotExisting", args[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(rent != null) {
|
||||
messageBridge.message(sender, "info-regionHeaderRent", rent);
|
||||
plugin.message(sender, "info-regionHeaderRent", rent);
|
||||
if(rent.isRented()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionRented", rent);
|
||||
messageBridge.messageNoPrefix(sender, "info-regionExtending", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionRented", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionExtending", rent);
|
||||
// Money back
|
||||
if(UnrentCommand.canUse(sender, rent)) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionMoneyBackRentClick", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionMoneyBackRentClick", rent);
|
||||
} else {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionMoneyBackRent", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionMoneyBackRent", rent);
|
||||
}
|
||||
// Friends
|
||||
if(!rent.getFriendsFeature().getFriendNames().isEmpty()) {
|
||||
@@ -298,30 +281,30 @@ public class InfoCommand extends CommandAreaShop {
|
||||
if(DelfriendCommand.canUse(sender, rent)) {
|
||||
messagePart = "info-friendRemove";
|
||||
}
|
||||
messageBridge.messageNoPrefix(sender, "info-regionFriends", rent, Utils.combinedMessage(rent.getFriendsFeature().getFriendNames(), messagePart));
|
||||
plugin.messageNoPrefix(sender, "info-regionFriends", rent, Utils.combinedMessage(rent.getFriendsFeature().getFriendNames(), messagePart));
|
||||
}
|
||||
} else {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionCanBeRented", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionCanBeRented", rent);
|
||||
}
|
||||
if(rent.getLandlordName() != null) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionLandlord", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionLandlord", rent);
|
||||
}
|
||||
// Maximum extends
|
||||
if(rent.getMaxExtends() != -1) {
|
||||
if(rent.getMaxExtends() == 0) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionNoExtending", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionNoExtending", rent);
|
||||
} else if(rent.isRented()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionExtendsLeft", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionExtendsLeft", rent);
|
||||
} else {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionMaxExtends", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionMaxExtends", rent);
|
||||
}
|
||||
}
|
||||
// If maxExtends is zero it does not make sense to show this message
|
||||
if(rent.getMaxRentTime() != -1 && rent.getMaxExtends() != 0) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionMaxRentTime", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionMaxRentTime", rent);
|
||||
}
|
||||
if(rent.getInactiveTimeUntilUnrent() != -1) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionInactiveUnrent", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionInactiveUnrent", rent);
|
||||
}
|
||||
// Teleport
|
||||
Message tp = Message.fromKey("info-prefix");
|
||||
@@ -339,48 +322,48 @@ public class InfoCommand extends CommandAreaShop {
|
||||
}
|
||||
if(foundSomething) {
|
||||
tp.append(".");
|
||||
SimpleMessageBridge.send(tp, sender);
|
||||
tp.send(sender);
|
||||
}
|
||||
// Signs
|
||||
List<String> signLocations = new ArrayList<>();
|
||||
for(BlockPosition location : rent.getSignsFeature().signManager().allSignLocations()) {
|
||||
signLocations.add(Message.fromKey("info-regionSignLocation").replacements(location.getWorld().getName(), location.getX(), location.getY(), location.getZ()).getPlain());
|
||||
for(Location location : rent.getSignsFeature().getSignLocations()) {
|
||||
signLocations.add(Message.fromKey("info-regionSignLocation").replacements(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()).getPlain());
|
||||
}
|
||||
if(!signLocations.isEmpty()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionSigns", Utils.createCommaSeparatedList(signLocations));
|
||||
plugin.messageNoPrefix(sender, "info-regionSigns", Utils.createCommaSeparatedList(signLocations));
|
||||
}
|
||||
// Groups
|
||||
if(sender.hasPermission("areashop.groupinfo") && !rent.getGroupNames().isEmpty()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionGroups", Utils.createCommaSeparatedList(rent.getGroupNames()));
|
||||
plugin.messageNoPrefix(sender, "info-regionGroups", Utils.createCommaSeparatedList(rent.getGroupNames()));
|
||||
}
|
||||
// Restoring
|
||||
if(rent.isRestoreEnabled()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionRestoringRent", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionRestoringRent", rent);
|
||||
}
|
||||
// Restrictions
|
||||
if(!rent.isRented()) {
|
||||
if(rent.restrictedToRegion()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionRestrictedRegionRent", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionRestrictedRegionRent", rent);
|
||||
} else if(rent.restrictedToWorld()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionRestrictedWorldRent", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionRestrictedWorldRent", rent);
|
||||
}
|
||||
}
|
||||
messageBridge.messageNoPrefix(sender, "info-regionFooterRent", rent);
|
||||
plugin.messageNoPrefix(sender, "info-regionFooterRent", rent);
|
||||
} else if(buy != null) {
|
||||
messageBridge.message(sender, "info-regionHeaderBuy", buy);
|
||||
plugin.message(sender, "info-regionHeaderBuy", buy);
|
||||
if(buy.isSold()) {
|
||||
if(buy.isInResellingMode()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionReselling", buy);
|
||||
messageBridge.messageNoPrefix(sender, "info-regionReselPrice", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionReselling", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionReselPrice", buy);
|
||||
} else {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionBought", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionBought", buy);
|
||||
}
|
||||
// Money back
|
||||
if(!buy.getBooleanSetting("buy.sellDisabled")) {
|
||||
if (SellCommand.canUse(sender, buy)) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionMoneyBackBuyClick", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionMoneyBackBuyClick", buy);
|
||||
} else {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionMoneyBackBuy", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionMoneyBackBuy", buy);
|
||||
}
|
||||
}
|
||||
// Friends
|
||||
@@ -389,16 +372,16 @@ public class InfoCommand extends CommandAreaShop {
|
||||
if(DelfriendCommand.canUse(sender, buy)) {
|
||||
messagePart = "info-friendRemove";
|
||||
}
|
||||
messageBridge.messageNoPrefix(sender, "info-regionFriends", buy, Utils.combinedMessage(buy.getFriendsFeature().getFriendNames(), messagePart));
|
||||
plugin.messageNoPrefix(sender, "info-regionFriends", buy, Utils.combinedMessage(buy.getFriendsFeature().getFriendNames(), messagePart));
|
||||
}
|
||||
} else {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionCanBeBought", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionCanBeBought", buy);
|
||||
}
|
||||
if(buy.getLandlord() != null) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionLandlord", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionLandlord", buy);
|
||||
}
|
||||
if(buy.getInactiveTimeUntilSell() != -1) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionInactiveSell", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionInactiveSell", buy);
|
||||
}
|
||||
// Teleport
|
||||
Message tp = Message.fromKey("info-prefix");
|
||||
@@ -416,42 +399,42 @@ public class InfoCommand extends CommandAreaShop {
|
||||
}
|
||||
if(foundSomething) {
|
||||
tp.append(".");
|
||||
SimpleMessageBridge.send(tp, sender);
|
||||
tp.send(sender);
|
||||
}
|
||||
// Signs
|
||||
List<String> signLocations = new ArrayList<>();
|
||||
for(BlockPosition location : buy.getSignsFeature().signManager().allSignLocations()) {
|
||||
signLocations.add(Message.fromKey("info-regionSignLocation").replacements(location.getWorld().getName(), location.getX(), location.getY(), location.getZ()).getPlain());
|
||||
for(Location location : buy.getSignsFeature().getSignLocations()) {
|
||||
signLocations.add(Message.fromKey("info-regionSignLocation").replacements(location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()).getPlain());
|
||||
}
|
||||
if(!signLocations.isEmpty()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionSigns", Utils.createCommaSeparatedList(signLocations));
|
||||
plugin.messageNoPrefix(sender, "info-regionSigns", Utils.createCommaSeparatedList(signLocations));
|
||||
}
|
||||
// Groups
|
||||
if(sender.hasPermission("areashop.groupinfo") && !buy.getGroupNames().isEmpty()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionGroups", Utils.createCommaSeparatedList(buy.getGroupNames()));
|
||||
plugin.messageNoPrefix(sender, "info-regionGroups", Utils.createCommaSeparatedList(buy.getGroupNames()));
|
||||
}
|
||||
// Restoring
|
||||
if(buy.isRestoreEnabled()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionRestoringBuy", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionRestoringBuy", buy);
|
||||
}
|
||||
// Restrictions
|
||||
if(!buy.isSold()) {
|
||||
if(buy.restrictedToRegion()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionRestrictedRegionBuy", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionRestrictedRegionBuy", buy);
|
||||
} else if(buy.restrictedToWorld()) {
|
||||
messageBridge.messageNoPrefix(sender, "info-regionRestrictedWorldBuy", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionRestrictedWorldBuy", buy);
|
||||
}
|
||||
}
|
||||
messageBridge.messageNoPrefix(sender, "info-regionFooterBuy", buy);
|
||||
plugin.messageNoPrefix(sender, "info-regionFooterBuy", buy);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "info-regionHelp");
|
||||
plugin.message(sender, "info-regionHelp");
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "info-help");
|
||||
plugin.message(sender, "info-help");
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "info-help");
|
||||
plugin.message(sender, "info-help");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,8 +449,8 @@ public class InfoCommand extends CommandAreaShop {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if(start[2].equalsIgnoreCase("region")) {
|
||||
result.addAll(fileManager.getBuyNames());
|
||||
result.addAll(fileManager.getRentNames());
|
||||
result.addAll(plugin.getFileManager().getBuyNames());
|
||||
result.addAll(plugin.getFileManager().getRentNames());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -14,16 +9,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
public class LinksignsCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private SignLinkerManager signLinkerManager;
|
||||
@Inject
|
||||
private AreaShop plugin;
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop linksigns";
|
||||
@@ -40,16 +27,17 @@ public class LinksignsCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.linksigns")) {
|
||||
messageBridge.message(sender, "linksigns-noPermission");
|
||||
plugin.message(sender, "linksigns-noPermission");
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
|
||||
if(signLinkerManager.isInSignLinkMode(player)) {
|
||||
signLinkerManager.exitSignLinkMode(player);
|
||||
Player player = (Player)sender;
|
||||
if(plugin.getSignlinkerManager().isInSignLinkMode(player)) {
|
||||
plugin.getSignlinkerManager().exitSignLinkMode(player);
|
||||
} else {
|
||||
// Get the profile
|
||||
String profile = null;
|
||||
@@ -66,12 +54,12 @@ public class LinksignsCommand extends CommandAreaShop {
|
||||
}
|
||||
message.addAll(Message.fromKey("addsign-profile").replacements(p).get());
|
||||
}
|
||||
messageBridge.message(sender, "addsign-wrongProfile", Message.fromList(message));
|
||||
plugin.message(sender, "addsign-wrongProfile", Message.fromList(message));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
signLinkerManager.enterSignLinkMode(player, profile);
|
||||
plugin.getSignlinkerManager().enterSignLinkMode(player, profile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -19,20 +14,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
public class MeCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Inject
|
||||
private OfflinePlayerHelper offlinePlayerHelper;
|
||||
|
||||
@Inject
|
||||
private BukkitSchedulerExecutor executor;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop me";
|
||||
@@ -49,77 +32,76 @@ public class MeCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.me")) {
|
||||
messageBridge.message(sender, "me-noPermission");
|
||||
plugin.message(sender, "me-noPermission");
|
||||
return;
|
||||
}
|
||||
OfflinePlayer player = null;
|
||||
if(!(sender instanceof Player)) {
|
||||
if(args.length <= 1) {
|
||||
messageBridge.message(sender, "me-notAPlayer");
|
||||
plugin.message(sender, "me-notAPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
player = (OfflinePlayer)sender;
|
||||
}
|
||||
if(args.length > 1) {
|
||||
// Lookup offline players async
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(args[1]).thenAcceptAsync(offlinePlayer -> {
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
messageBridge.message(sender, "me-noPlayer", args[1]);
|
||||
} else {
|
||||
sendMessageAboutRegions(sender, offlinePlayer);
|
||||
}
|
||||
}, this.executor);
|
||||
player = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(player == null) {
|
||||
plugin.message(sender, "me-noPlayer", args[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(player == null) {
|
||||
return;
|
||||
}
|
||||
sendMessageAboutRegions(sender, player);
|
||||
}
|
||||
|
||||
private void sendMessageAboutRegions(CommandSender sender, OfflinePlayer target) {
|
||||
// Get the regions owned by the player
|
||||
Set<RentRegion> rentRegions = new HashSet<>();
|
||||
for(RentRegion region : fileManager.getRentsRef()) {
|
||||
if(region.isOwner(target)) {
|
||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||
if(region.isOwner(player)) {
|
||||
rentRegions.add(region);
|
||||
}
|
||||
}
|
||||
Set<BuyRegion> buyRegions = new HashSet<>();
|
||||
for(BuyRegion region : fileManager.getBuysRef()) {
|
||||
if(region.isOwner(target)) {
|
||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||
if(region.isOwner(player)) {
|
||||
buyRegions.add(region);
|
||||
}
|
||||
}
|
||||
// Get the regions the player is added as friend
|
||||
Set<GeneralRegion> friendRegions = new HashSet<>();
|
||||
for(GeneralRegion region : fileManager.getRegionsRef()) {
|
||||
if(region.getFriendsFeature().getFriends().contains(target.getUniqueId())) {
|
||||
for(GeneralRegion region : plugin.getFileManager().getRegions()) {
|
||||
if(region.getFriendsFeature().getFriends().contains(player.getUniqueId())) {
|
||||
friendRegions.add(region);
|
||||
}
|
||||
}
|
||||
|
||||
// Send messages
|
||||
boolean foundSome = !rentRegions.isEmpty() || !buyRegions.isEmpty() || !friendRegions.isEmpty();
|
||||
if(!foundSome) {
|
||||
messageBridge.message(sender, "me-nothing", target.getName());
|
||||
return;
|
||||
if(foundSome) {
|
||||
plugin.message(sender, "me-header", player.getName());
|
||||
}
|
||||
messageBridge.message(sender, "me-header", target.getName());
|
||||
if(!rentRegions.isEmpty()) {
|
||||
for(RentRegion region : rentRegions) {
|
||||
messageBridge.messageNoPrefix(sender, "me-rentLine", region);
|
||||
plugin.messageNoPrefix(sender, "me-rentLine", region);
|
||||
}
|
||||
}
|
||||
if(!buyRegions.isEmpty()) {
|
||||
for(BuyRegion region : buyRegions) {
|
||||
messageBridge.messageNoPrefix(sender, "me-buyLine", region);
|
||||
plugin.messageNoPrefix(sender, "me-buyLine", region);
|
||||
}
|
||||
}
|
||||
if(!friendRegions.isEmpty()) {
|
||||
for(GeneralRegion region : friendRegions) {
|
||||
messageBridge.messageNoPrefix(sender, "me-friendLine", region);
|
||||
plugin.messageNoPrefix(sender, "me-friendLine", region);
|
||||
}
|
||||
}
|
||||
messageBridge.messageNoPrefix(sender, "me-clickHint");
|
||||
|
||||
if(!foundSome) {
|
||||
plugin.message(sender, "me-nothing", player.getName());
|
||||
} else {
|
||||
plugin.messageNoPrefix(sender, "me-clickHint");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.tools.SimpleMessageBridge;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -18,12 +10,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class MessageCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop message";
|
||||
@@ -38,18 +26,18 @@ public class MessageCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final String[] args) {
|
||||
if(!sender.hasPermission("areashop.message")) {
|
||||
messageBridge.message(sender, "message-noPermission");
|
||||
plugin.message(sender, "message-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length < 3) {
|
||||
messageBridge.message(sender, "message-help");
|
||||
plugin.message(sender, "message-help");
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[1]);
|
||||
if(player == null) {
|
||||
messageBridge.message(sender, "message-notOnline", args[1]);
|
||||
plugin.message(sender, "message-notOnline", args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,8 +45,7 @@ public class MessageCommand extends CommandAreaShop {
|
||||
System.arraycopy(args, 2, messageArgs, 0, args.length - 2);
|
||||
String message = StringUtils.join(messageArgs, " ");
|
||||
|
||||
Message m = Message.fromString(message);
|
||||
SimpleMessageBridge.send(m, player);
|
||||
Message.fromString(message).send(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@Singleton
|
||||
public class ReloadCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private AreaShop plugin;
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop reload";
|
||||
@@ -33,7 +23,7 @@ public class ReloadCommand extends CommandAreaShop {
|
||||
// Reload the configuration files and update all region flags/signs
|
||||
plugin.reload(sender);
|
||||
} else {
|
||||
messageBridge.message(sender, "reload-noPermission");
|
||||
plugin.message(sender, "reload-noPermission");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,14 +8,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class RentCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop rent";
|
||||
@@ -36,17 +26,18 @@ public class RentCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.rent")) {
|
||||
messageBridge.message(sender, "rent-noPermission");
|
||||
plugin.message(sender, "rent-noPermission");
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
if(args.length > 1 && args[1] != null) {
|
||||
RentRegion rent = fileManager.getRent(args[1]);
|
||||
RentRegion rent = plugin.getFileManager().getRent(args[1]);
|
||||
if(rent == null) {
|
||||
messageBridge.message(sender, "rent-notRentable", args[1]);
|
||||
plugin.message(sender, "rent-notRentable", args[1]);
|
||||
} else {
|
||||
rent.rent(player);
|
||||
}
|
||||
@@ -54,9 +45,9 @@ public class RentCommand extends CommandAreaShop {
|
||||
// get the region by location
|
||||
List<RentRegion> regions = Utils.getImportantRentRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
} else {
|
||||
regions.get(0).rent(player);
|
||||
}
|
||||
@@ -67,7 +58,7 @@ public class RentCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
for(RentRegion region : fileManager.getRentsRef()) {
|
||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||
if(!region.isRented()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,14 +8,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class ResellCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop resell";
|
||||
@@ -36,24 +26,24 @@ public class ResellCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.resell") && !sender.hasPermission("areashop.resellall")) {
|
||||
messageBridge.message(sender, "resell-noPermissionOther");
|
||||
plugin.message(sender, "resell-noPermissionOther");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length <= 1) {
|
||||
messageBridge.message(sender, "resell-help");
|
||||
plugin.message(sender, "resell-help");
|
||||
return;
|
||||
}
|
||||
double price;
|
||||
try {
|
||||
price = Double.parseDouble(args[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
messageBridge.message(sender, "resell-wrongPrice", args[1]);
|
||||
plugin.message(sender, "resell-wrongPrice", args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(price < 0) {
|
||||
messageBridge.message(sender, "resell-wrongPrice", args[1]);
|
||||
plugin.message(sender, "resell-wrongPrice", args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,53 +53,53 @@ public class ResellCommand extends CommandAreaShop {
|
||||
// get the region by location
|
||||
List<BuyRegion> regions = Utils.getImportantBuyRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
buy = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
buy = fileManager.getBuy(args[2]);
|
||||
buy = plugin.getFileManager().getBuy(args[2]);
|
||||
if(buy == null) {
|
||||
messageBridge.message(sender, "resell-notRegistered", args[2]);
|
||||
plugin.message(sender, "resell-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(buy == null) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
}
|
||||
if(!buy.isSold()) {
|
||||
messageBridge.message(sender, "resell-notBought", buy);
|
||||
plugin.message(sender, "resell-notBought", buy);
|
||||
return;
|
||||
}
|
||||
if(sender.hasPermission("areashop.resellall")) {
|
||||
buy.enableReselling(price);
|
||||
buy.update();
|
||||
messageBridge.message(sender, "resell-success", buy);
|
||||
plugin.message(sender, "resell-success", buy);
|
||||
} else if(sender.hasPermission("areashop.resell") && sender instanceof Player) {
|
||||
if(!buy.isOwner((Player)sender)) {
|
||||
messageBridge.message(sender, "resell-noPermissionOther", buy);
|
||||
plugin.message(sender, "resell-noPermissionOther", buy);
|
||||
return;
|
||||
}
|
||||
|
||||
if(buy.getBooleanSetting("buy.resellDisabled")) {
|
||||
messageBridge.message(sender, "resell-disabled", buy);
|
||||
plugin.message(sender, "resell-disabled", buy);
|
||||
return;
|
||||
}
|
||||
|
||||
buy.enableReselling(price);
|
||||
buy.update();
|
||||
messageBridge.message(sender, "resell-success", buy);
|
||||
plugin.message(sender, "resell-success", buy);
|
||||
} else {
|
||||
messageBridge.message(sender, "resell-noPermission", buy);
|
||||
plugin.message(sender, "resell-noPermission", buy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +107,7 @@ public class ResellCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 3) {
|
||||
for(BuyRegion region : fileManager.getBuysRef()) {
|
||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||
if(region.isSold() && !region.isInResellingMode()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
@@ -14,14 +10,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SchematiceventCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop schemevent";
|
||||
@@ -38,21 +28,21 @@ public class SchematiceventCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.schematicevents")) {
|
||||
messageBridge.message(sender, "schemevent-noPermission");
|
||||
plugin.message(sender, "schemevent-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
if(args.length < 3 || args[1] == null || args[2] == null) {
|
||||
messageBridge.message(sender, "schemevent-help");
|
||||
plugin.message(sender, "schemevent-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = fileManager.getRegion(args[1]);
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[1]);
|
||||
if(region == null) {
|
||||
messageBridge.message(sender, "cmd-notRegistered", args[1]);
|
||||
plugin.message(sender, "cmd-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
if(region.getRegion() == null) {
|
||||
messageBridge.message(sender, "general-noRegion", region);
|
||||
plugin.message(sender, "general-noRegion", region);
|
||||
return;
|
||||
}
|
||||
GeneralRegion.RegionEvent event = null;
|
||||
@@ -68,21 +58,21 @@ public class SchematiceventCommand extends CommandAreaShop {
|
||||
for(GeneralRegion.RegionEvent value : GeneralRegion.RegionEvent.values()) {
|
||||
values.add(value.getValue().toLowerCase());
|
||||
}
|
||||
messageBridge.message(sender, "schemevent-wrongEvent", args[2], Utils.createCommaSeparatedList(values), region);
|
||||
plugin.message(sender, "schemevent-wrongEvent", args[2], Utils.createCommaSeparatedList(values), region);
|
||||
return;
|
||||
}
|
||||
region.handleSchematicEvent(event);
|
||||
region.update();
|
||||
messageBridge.message(sender, "schemevent-success", args[2], region);
|
||||
plugin.message(sender, "schemevent-success", args[2], region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(fileManager.getRegionNames());
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
} else if(toComplete == 3) {
|
||||
GeneralRegion region = fileManager.getRegion(start[2]);
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(start[2]);
|
||||
if(region != null) {
|
||||
if(region instanceof RentRegion) {
|
||||
result.addAll(Arrays.asList("created", "deleted", "rented", "unrented"));
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
@@ -13,14 +9,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SellCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop sell";
|
||||
@@ -44,7 +34,8 @@ public class SellCommand extends CommandAreaShop {
|
||||
if(person.hasPermission("areashop.sell")) {
|
||||
return true;
|
||||
}
|
||||
if(person instanceof Player player) {
|
||||
if(person instanceof Player) {
|
||||
Player player = (Player)person;
|
||||
return region.isOwner(player) && person.hasPermission("areashop.sellown");
|
||||
}
|
||||
return false;
|
||||
@@ -53,36 +44,36 @@ public class SellCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.sell") && !sender.hasPermission("areashop.sellown")) {
|
||||
messageBridge.message(sender, "sell-noPermission");
|
||||
plugin.message(sender, "sell-noPermission");
|
||||
return;
|
||||
}
|
||||
BuyRegion buy;
|
||||
if(args.length <= 1) {
|
||||
if(sender instanceof Player player) {
|
||||
if(sender instanceof Player) {
|
||||
// get the region by location
|
||||
List<BuyRegion> regions = Utils.getImportantBuyRegions((player).getLocation());
|
||||
List<BuyRegion> regions = Utils.getImportantBuyRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
buy = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
buy = fileManager.getBuy(args[1]);
|
||||
buy = plugin.getFileManager().getBuy(args[1]);
|
||||
}
|
||||
if(buy == null) {
|
||||
messageBridge.message(sender, "sell-notRegistered");
|
||||
plugin.message(sender, "sell-notRegistered");
|
||||
return;
|
||||
}
|
||||
if(!buy.isSold()) {
|
||||
messageBridge.message(sender, "sell-notBought", buy);
|
||||
plugin.message(sender, "sell-notBought", buy);
|
||||
return;
|
||||
}
|
||||
buy.sell(true, sender);
|
||||
@@ -92,7 +83,7 @@ public class SellCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
for(BuyRegion region : fileManager.getBuysRef()) {
|
||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||
if(region.isSold()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SetTransferCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop settransfer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (target.hasPermission("areashop.settransfer")) {
|
||||
return "help-settransfer";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.settransfer")) {
|
||||
messageBridge.message(sender, "settransfer-noPermission");
|
||||
return;
|
||||
}
|
||||
if (args.length <= 2 || args[1] == null || args[2] == null) {
|
||||
messageBridge.message(sender, "settransfer-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = fileManager.getRegion(args[1]);
|
||||
if (region == null) {
|
||||
messageBridge.message(sender, "settransfer-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
boolean value;
|
||||
if (args[2].equalsIgnoreCase("true")) {
|
||||
value = true;
|
||||
} else if (args[2].equalsIgnoreCase("false")) {
|
||||
value = false;
|
||||
} else {
|
||||
messageBridge.message(sender, "settransfer-invalidSetting", args[2]);
|
||||
return;
|
||||
}
|
||||
region.setTransferEnabled(value);
|
||||
messageBridge.message(sender, "settransfer-success", args[2], region);
|
||||
region.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if (toComplete == 2) {
|
||||
result = fileManager.getRegionNames();
|
||||
} else if (toComplete == 3) {
|
||||
result.add("true");
|
||||
result.add("false");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,15 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SetdurationCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setduration";
|
||||
@@ -39,11 +26,11 @@ public class SetdurationCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.setduration") && (!sender.hasPermission("areashop.setduration.landlord") && sender instanceof Player)) {
|
||||
messageBridge.message(sender, "setduration-noPermission");
|
||||
plugin.message(sender, "setduration-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 3 || args[1] == null || args[2] == null) {
|
||||
messageBridge.message(sender, "setduration-help");
|
||||
plugin.message(sender, "setduration-help");
|
||||
return;
|
||||
}
|
||||
int regionArgument = 3;
|
||||
@@ -56,48 +43,48 @@ public class SetdurationCommand extends CommandAreaShop {
|
||||
// get the region by location
|
||||
List<RentRegion> regions = Utils.getImportantRentRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
rent = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
rent = fileManager.getRent(args[regionArgument]);
|
||||
rent = plugin.getFileManager().getRent(args[regionArgument]);
|
||||
}
|
||||
if(rent == null) {
|
||||
messageBridge.message(sender, "setduration-notRegistered", args[regionArgument]);
|
||||
plugin.message(sender, "setduration-notRegistered", args[regionArgument]);
|
||||
return;
|
||||
}
|
||||
if(!sender.hasPermission("areashop.setduration") && !(sender instanceof Player && rent.isLandlord(((Player)sender).getUniqueId()))) {
|
||||
messageBridge.message(sender, "setduration-noLandlord", rent);
|
||||
plugin.message(sender, "setduration-noLandlord", rent);
|
||||
return;
|
||||
}
|
||||
if("default".equalsIgnoreCase(args[1]) || "reset".equalsIgnoreCase(args[1])) {
|
||||
rent.setDuration(null);
|
||||
rent.update();
|
||||
messageBridge.message(sender, "setduration-successRemoved", rent);
|
||||
plugin.message(sender, "setduration-successRemoved", rent);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
Integer.parseInt(args[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
messageBridge.message(sender, "setduration-wrongAmount", args[1], rent);
|
||||
plugin.message(sender, "setduration-wrongAmount", args[1], rent);
|
||||
return;
|
||||
}
|
||||
if(!Utils.checkTimeFormat(args[1] + " " + args[2])) {
|
||||
messageBridge.message(sender, "setduration-wrongFormat", args[1] + " " + args[2], rent);
|
||||
plugin.message(sender, "setduration-wrongFormat", args[1] + " " + args[2], rent);
|
||||
return;
|
||||
}
|
||||
rent.setDuration(args[1] + " " + args[2]);
|
||||
rent.update();
|
||||
messageBridge.message(sender, "setduration-success", rent);
|
||||
plugin.message(sender, "setduration-success", rent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +97,7 @@ public class SetdurationCommand extends CommandAreaShop {
|
||||
result.addAll(plugin.getConfig().getStringList("months"));
|
||||
result.addAll(plugin.getConfig().getStringList("years"));
|
||||
} else if(toComplete == 4) {
|
||||
result = fileManager.getRentNames();
|
||||
result = plugin.getFileManager().getRentNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,100 +1,87 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SetlandlordCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private OfflinePlayerHelper offlinePlayerHelper;
|
||||
@Inject
|
||||
private BukkitSchedulerExecutor executor;
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setlandlord";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setlandlord";
|
||||
}
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.setlandlord")) {
|
||||
return "help-setlandlord";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (target.hasPermission("areashop.setlandlord")) {
|
||||
return "help-setlandlord";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.setlandlord")) {
|
||||
plugin.message(sender, "setlandlord-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2) {
|
||||
plugin.message(sender, "setlandlord-help");
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
||||
GeneralRegion region;
|
||||
if(args.length < 3) {
|
||||
if(sender instanceof Player) {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
region = plugin.getFileManager().getRegion(args[2]);
|
||||
}
|
||||
if(region == null) {
|
||||
plugin.message(sender, "cmd-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
String playerName = player.getName();
|
||||
if(playerName == null || playerName.isEmpty()) {
|
||||
playerName = args[1];
|
||||
}
|
||||
region.setLandlord(player.getUniqueId(), playerName);
|
||||
region.update();
|
||||
plugin.message(sender, "setlandlord-success", playerName, region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.setlandlord")) {
|
||||
messageBridge.message(sender, "setlandlord-noPermission");
|
||||
return;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
messageBridge.message(sender, "setlandlord-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if (args.length < 3) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(player.getLocation());
|
||||
if (regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if (regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
region = fileManager.getRegion(args[2]);
|
||||
}
|
||||
if (region == null) {
|
||||
messageBridge.message(sender, "cmd-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
this.offlinePlayerHelper.lookupOfflinePlayerAsync(args[1]).thenAcceptAsync(offlinePlayer -> {
|
||||
String playerName = offlinePlayer.getName();
|
||||
if (playerName == null || playerName.isEmpty()) {
|
||||
playerName = args[1];
|
||||
}
|
||||
region.setLandlord(offlinePlayer.getUniqueId(), playerName);
|
||||
region.update();
|
||||
messageBridge.message(sender, "setlandlord-success", playerName, region);
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if (toComplete == 2) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if (toComplete == 3) {
|
||||
result.addAll(fileManager.getRegionNames());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
for(Player player : Utils.getOnlinePlayers()) {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if(toComplete == 3) {
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -18,119 +14,115 @@ import java.util.Calendar;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Singleton
|
||||
public class SetownerCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private OfflinePlayerHelper offlinePlayerHelper;
|
||||
@Inject
|
||||
private BukkitSchedulerExecutor executor;
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setowner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setowner";
|
||||
}
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if(target.hasPermission("areashop.setownerrent") || target.hasPermission("areashop.setownerbuy")) {
|
||||
return "help-setowner";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (target.hasPermission("areashop.setownerrent") || target.hasPermission("areashop.setownerbuy")) {
|
||||
return "help-setowner";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.setownerrent") && !sender.hasPermission("areashop.setownerbuy")) {
|
||||
plugin.message(sender, "setowner-noPermission");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if(args.length < 2) {
|
||||
plugin.message(sender, "setowner-help");
|
||||
return;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
if(sender instanceof Player) {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
region = plugin.getFileManager().getRegion(args[2]);
|
||||
}
|
||||
if(region == null) {
|
||||
plugin.message(sender, "setowner-notRegistered");
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.setownerrent") && !sender.hasPermission("areashop.setownerbuy")) {
|
||||
messageBridge.message(sender, "setowner-noPermission");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if (args.length < 2) {
|
||||
messageBridge.message(sender, "setowner-help");
|
||||
return;
|
||||
}
|
||||
if (args.length == 2) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(player.getLocation());
|
||||
if (regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if (regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
if(region instanceof RentRegion && !sender.hasPermission("areashop.setownerrent")) {
|
||||
plugin.message(sender, "setowner-noPermissionRent", region);
|
||||
return;
|
||||
}
|
||||
if(region instanceof BuyRegion && !sender.hasPermission("areashop.setownerbuy")) {
|
||||
plugin.message(sender, "setowner-noPermissionBuy", region);
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
region = fileManager.getRegion(args[2]);
|
||||
}
|
||||
if (region == null) {
|
||||
messageBridge.message(sender, "setowner-notRegistered");
|
||||
return;
|
||||
}
|
||||
UUID uuid = null;
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(player != null) {
|
||||
uuid = player.getUniqueId();
|
||||
}
|
||||
if(uuid == null) {
|
||||
plugin.message(sender, "setowner-noPlayer", args[1], region);
|
||||
return;
|
||||
}
|
||||
|
||||
if (region instanceof RentRegion && !sender.hasPermission("areashop.setownerrent")) {
|
||||
messageBridge.message(sender, "setowner-noPermissionRent", region);
|
||||
return;
|
||||
}
|
||||
if (region instanceof BuyRegion && !sender.hasPermission("areashop.setownerbuy")) {
|
||||
messageBridge.message(sender, "setowner-noPermissionBuy", region);
|
||||
return;
|
||||
}
|
||||
if(region instanceof RentRegion) {
|
||||
RentRegion rent = (RentRegion)region;
|
||||
if(rent.isRenter(uuid)) {
|
||||
// extend
|
||||
rent.setRentedUntil(rent.getRentedUntil() + rent.getDuration());
|
||||
rent.setRenter(uuid);
|
||||
plugin.message(sender, "setowner-succesRentExtend", region);
|
||||
} else {
|
||||
// change
|
||||
if(!rent.isRented()) {
|
||||
rent.setRentedUntil(Calendar.getInstance().getTimeInMillis() + rent.getDuration());
|
||||
}
|
||||
rent.setRenter(uuid);
|
||||
plugin.message(sender, "setowner-succesRent", region);
|
||||
}
|
||||
}
|
||||
if(region instanceof BuyRegion) {
|
||||
BuyRegion buy = (BuyRegion)region;
|
||||
buy.setBuyer(uuid);
|
||||
plugin.message(sender, "setowner-succesBuy", region);
|
||||
}
|
||||
region.getFriendsFeature().deleteFriend(region.getOwner(), null);
|
||||
region.update();
|
||||
region.saveRequired();
|
||||
}
|
||||
|
||||
this.offlinePlayerHelper.lookupUuidAsync(args[1]).thenAcceptAsync(optionalUuid -> {
|
||||
if (optionalUuid.isEmpty()) {
|
||||
messageBridge.message(sender, "setowner-noPlayer", args[1], region);
|
||||
return;
|
||||
}
|
||||
final UUID uuid = optionalUuid.get();
|
||||
if (region instanceof RentRegion rent) {
|
||||
if (rent.isRenter(uuid)) {
|
||||
// extend
|
||||
rent.setRentedUntil(rent.getRentedUntil() + rent.getDuration());
|
||||
rent.setRenter(uuid);
|
||||
messageBridge.message(sender, "setowner-succesRentExtend", region);
|
||||
} else {
|
||||
// change
|
||||
if (!rent.isRented()) {
|
||||
rent.setRentedUntil(Calendar.getInstance().getTimeInMillis() + rent.getDuration());
|
||||
}
|
||||
rent.setRenter(uuid);
|
||||
messageBridge.message(sender, "setowner-succesRent", region);
|
||||
}
|
||||
}
|
||||
if (region instanceof BuyRegion buy) {
|
||||
buy.setBuyer(uuid);
|
||||
messageBridge.message(sender, "setowner-succesBuy", region);
|
||||
}
|
||||
region.getFriendsFeature().deleteFriend(region.getOwner(), null);
|
||||
region.update();
|
||||
region.saveRequired();
|
||||
}, this.executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if (toComplete == 2) {
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if (toComplete == 3) {
|
||||
result.addAll(fileManager.getRegionNames());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
for(Player player : Utils.getOnlinePlayers()) {
|
||||
result.add(player.getName());
|
||||
}
|
||||
} else if(toComplete == 3) {
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
@@ -14,14 +10,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SetpriceCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setprice";
|
||||
@@ -38,11 +28,11 @@ public class SetpriceCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.setprice") && (!sender.hasPermission("areashop.setprice.landlord") && sender instanceof Player)) {
|
||||
messageBridge.message(sender, "setprice-noPermission");
|
||||
plugin.message(sender, "setprice-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length < 2 || args[1] == null) {
|
||||
messageBridge.message(sender, "setprice-help");
|
||||
plugin.message(sender, "setprice-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
@@ -51,27 +41,27 @@ public class SetpriceCommand extends CommandAreaShop {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
region = fileManager.getRegion(args[2]);
|
||||
region = plugin.getFileManager().getRegion(args[2]);
|
||||
}
|
||||
if(region == null) {
|
||||
messageBridge.message(sender, "setprice-notRegistered", args[2]);
|
||||
plugin.message(sender, "setprice-notRegistered", args[2]);
|
||||
return;
|
||||
}
|
||||
if(!sender.hasPermission("areashop.setprice") && !(sender instanceof Player && region.isLandlord(((Player)sender).getUniqueId()))) {
|
||||
messageBridge.message(sender, "setprice-noLandlord", region);
|
||||
plugin.message(sender, "setprice-noLandlord", region);
|
||||
return;
|
||||
}
|
||||
if("default".equalsIgnoreCase(args[1]) || "reset".equalsIgnoreCase(args[1])) {
|
||||
@@ -81,22 +71,22 @@ public class SetpriceCommand extends CommandAreaShop {
|
||||
((BuyRegion)region).setPrice(null);
|
||||
}
|
||||
region.update();
|
||||
messageBridge.message(sender, "setprice-successRemoved", region);
|
||||
plugin.message(sender, "setprice-successRemoved", region);
|
||||
return;
|
||||
}
|
||||
double price;
|
||||
try {
|
||||
price = Double.parseDouble(args[1]);
|
||||
} catch(NumberFormatException e) {
|
||||
messageBridge.message(sender, "setprice-wrongPrice", args[1], region);
|
||||
plugin.message(sender, "setprice-wrongPrice", args[1], region);
|
||||
return;
|
||||
}
|
||||
if(region instanceof RentRegion) {
|
||||
((RentRegion)region).setPrice(price);
|
||||
messageBridge.message(sender, "setprice-successRent", region);
|
||||
plugin.message(sender, "setprice-successRent", region);
|
||||
} else if(region instanceof BuyRegion) {
|
||||
((BuyRegion)region).setPrice(price);
|
||||
messageBridge.message(sender, "setprice-successBuy", region);
|
||||
plugin.message(sender, "setprice-successBuy", region);
|
||||
}
|
||||
region.update();
|
||||
}
|
||||
@@ -105,7 +95,7 @@ public class SetpriceCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if(toComplete == 3) {
|
||||
result = fileManager.getRegionNames();
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,27 +1,13 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SetrestoreCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop setrestore";
|
||||
@@ -38,16 +24,16 @@ public class SetrestoreCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.setrestore")) {
|
||||
messageBridge.message(sender, "setrestore-noPermission");
|
||||
plugin.message(sender, "setrestore-noPermission");
|
||||
return;
|
||||
}
|
||||
if(args.length <= 2 || args[1] == null || args[2] == null) {
|
||||
messageBridge.message(sender, "setrestore-help");
|
||||
plugin.message(sender, "setrestore-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = fileManager.getRegion(args[1]);
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[1]);
|
||||
if(region == null) {
|
||||
messageBridge.message(sender, "setrestore-notRegistered", args[1]);
|
||||
plugin.message(sender, "setrestore-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
Boolean value = null;
|
||||
@@ -63,9 +49,9 @@ public class SetrestoreCommand extends CommandAreaShop {
|
||||
}
|
||||
if(args.length > 3) {
|
||||
region.setSchematicProfile(args[3]);
|
||||
messageBridge.message(sender, "setrestore-successProfile", valueString, args[3], region);
|
||||
plugin.message(sender, "setrestore-successProfile", valueString, args[3], region);
|
||||
} else {
|
||||
messageBridge.message(sender, "setrestore-success", valueString, region);
|
||||
plugin.message(sender, "setrestore-success", valueString, region);
|
||||
}
|
||||
region.update();
|
||||
}
|
||||
@@ -74,16 +60,13 @@ public class SetrestoreCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result = fileManager.getRegionNames();
|
||||
result = plugin.getFileManager().getRegionNames();
|
||||
} else if(toComplete == 3) {
|
||||
result.add("true");
|
||||
result.add("false");
|
||||
result.add("general");
|
||||
} else if(toComplete == 4) {
|
||||
ConfigurationSection schemProfiles = fileManager.getConfig().getConfigurationSection("schematicProfiles");
|
||||
if (schemProfiles != null) {
|
||||
result.addAll(schemProfiles.getKeys(false));
|
||||
}
|
||||
result.addAll(plugin.getConfig().getConfigurationSection("schematicProfiles").getKeys(false));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
@@ -15,14 +11,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SetteleportCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop settp";
|
||||
@@ -43,9 +33,10 @@ public class SetteleportCommand extends CommandAreaShop {
|
||||
* @return true if the person can set the teleport location, otherwise false
|
||||
*/
|
||||
public static boolean canUse(CommandSender person, GeneralRegion region) {
|
||||
if(!(person instanceof Player player)) {
|
||||
if(!(person instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player)person;
|
||||
return player.hasPermission("areashop.setteleportall")
|
||||
|| region.isOwner(player) && player.hasPermission("areashop.setteleport");
|
||||
}
|
||||
@@ -53,34 +44,35 @@ public class SetteleportCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.setteleport") && !sender.hasPermission("areashop.setteleportall")) {
|
||||
messageBridge.message(sender, "setteleport-noPermission");
|
||||
plugin.message(sender, "setteleport-noPermission");
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "onlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
Player player = (Player)sender;
|
||||
GeneralRegion region;
|
||||
if(args.length < 2) {
|
||||
// get the region by location
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
region = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
region = fileManager.getRegion(args[1]);
|
||||
region = plugin.getFileManager().getRegion(args[1]);
|
||||
}
|
||||
|
||||
boolean owner;
|
||||
|
||||
if(region == null) {
|
||||
messageBridge.message(player, "setteleport-noRentOrBuy", args[1]);
|
||||
plugin.message(player, "setteleport-noRentOrBuy", args[1]);
|
||||
return;
|
||||
}
|
||||
if(region instanceof RentRegion) {
|
||||
@@ -89,10 +81,10 @@ public class SetteleportCommand extends CommandAreaShop {
|
||||
owner = player.getUniqueId().equals(((BuyRegion)region).getBuyer());
|
||||
}
|
||||
if(!player.hasPermission("areashop.setteleport")) {
|
||||
messageBridge.message(player, "setteleport-noPermission", region);
|
||||
plugin.message(player, "setteleport-noPermission", region);
|
||||
return;
|
||||
} else if(!owner && !player.hasPermission("areashop.setteleportall")) {
|
||||
messageBridge.message(player, "setteleport-noPermissionOther", region);
|
||||
plugin.message(player, "setteleport-noPermissionOther", region);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,23 +92,23 @@ public class SetteleportCommand extends CommandAreaShop {
|
||||
if(args.length > 2 && args[2] != null && (args[2].equalsIgnoreCase("reset") || args[2].equalsIgnoreCase("yes") || args[2].equalsIgnoreCase("true"))) {
|
||||
region.getTeleportFeature().setTeleport(null);
|
||||
region.update();
|
||||
messageBridge.message(player, "setteleport-reset", region);
|
||||
plugin.message(player, "setteleport-reset", region);
|
||||
return;
|
||||
}
|
||||
if(!player.hasPermission("areashop.setteleportoutsideregion") && (wgRegion == null || !wgRegion.contains(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()))) {
|
||||
messageBridge.message(player, "setteleport-notInside", region);
|
||||
plugin.message(player, "setteleport-notInside", region);
|
||||
return;
|
||||
}
|
||||
region.getTeleportFeature().setTeleport(player.getLocation());
|
||||
region.update();
|
||||
messageBridge.message(player, "setteleport-success", region);
|
||||
plugin.message(player, "setteleport-success", region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(fileManager.getRegionNames());
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
} else if(toComplete == 3) {
|
||||
result.add("reset");
|
||||
}
|
||||
|
||||
@@ -2,47 +2,27 @@ package me.wiefferink.areashop.commands;
|
||||
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
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.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
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.block.BlockFace;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class StackCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private WorldEditInterface worldEditInterface;
|
||||
@Inject
|
||||
private WorldGuardInterface worldGuardInterface;
|
||||
@Inject
|
||||
private RegionFactory regionFactory;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop stack";
|
||||
@@ -60,17 +40,18 @@ public class StackCommand extends CommandAreaShop {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
// Check permission
|
||||
if(!sender.hasPermission("areashop.stack")) {
|
||||
messageBridge.message(sender, "stack-noPermission");
|
||||
plugin.message(sender, "stack-noPermission");
|
||||
return;
|
||||
}
|
||||
// Only from ingame
|
||||
if(!(sender instanceof final Player player)) {
|
||||
messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
final Player player = (Player)sender;
|
||||
// Specify enough arguments
|
||||
if(args.length < 5) {
|
||||
messageBridge.message(sender, "stack-help");
|
||||
plugin.message(sender, "stack-help");
|
||||
return;
|
||||
}
|
||||
// Check amount
|
||||
@@ -81,7 +62,7 @@ public class StackCommand extends CommandAreaShop {
|
||||
// Incorrect number
|
||||
}
|
||||
if(tempAmount <= 0) {
|
||||
messageBridge.message(player, "stack-wrongAmount", args[1]);
|
||||
plugin.message(player, "stack-wrongAmount", args[1]);
|
||||
return;
|
||||
}
|
||||
// Check gap
|
||||
@@ -89,27 +70,27 @@ public class StackCommand extends CommandAreaShop {
|
||||
try {
|
||||
gap = Integer.parseInt(args[2]);
|
||||
} catch(NumberFormatException e) {
|
||||
messageBridge.message(player, "stack-wrongGap", args[2]);
|
||||
plugin.message(player, "stack-wrongGap", args[2]);
|
||||
return;
|
||||
}
|
||||
// Check region type
|
||||
if(!"rent".equalsIgnoreCase(args[4]) && !"buy".equalsIgnoreCase(args[4])) {
|
||||
messageBridge.message(sender, "stack-help");
|
||||
plugin.message(sender, "stack-help");
|
||||
return;
|
||||
}
|
||||
// Get WorldEdit selection
|
||||
final WorldEditSelection selection = worldEditInterface.getPlayerSelection(player);
|
||||
final WorldEditSelection selection = plugin.getWorldEditHandler().getPlayerSelection(player);
|
||||
if(selection == null) {
|
||||
messageBridge.message(player, "stack-noSelection");
|
||||
plugin.message(player, "stack-noSelection");
|
||||
return;
|
||||
}
|
||||
// Get or create group
|
||||
RegionGroup group = null;
|
||||
if(args.length > 5) {
|
||||
group = fileManager.getGroup(args[5]);
|
||||
group = plugin.getFileManager().getGroup(args[5]);
|
||||
if(group == null) {
|
||||
group = regionFactory.createRegionGroup(args[5]);
|
||||
fileManager.addGroup(group);
|
||||
group = new RegionGroup(plugin, args[5]);
|
||||
plugin.getFileManager().addGroup(group);
|
||||
}
|
||||
}
|
||||
// Get facing of the player (must be clearly one of the four directions to make sure it is no mistake)
|
||||
@@ -120,7 +101,7 @@ public class StackCommand extends CommandAreaShop {
|
||||
facing = BlockFace.UP;
|
||||
}
|
||||
if(!(facing == BlockFace.NORTH || facing == BlockFace.EAST || facing == BlockFace.SOUTH || facing == BlockFace.WEST || facing == BlockFace.UP || facing == BlockFace.DOWN)) {
|
||||
messageBridge.message(player, "stack-unclearDirection", facing.toString().toLowerCase().replace('_', '-'));
|
||||
plugin.message(player, "stack-unclearDirection", facing.toString().toLowerCase().replace('_', '-'));
|
||||
return;
|
||||
}
|
||||
Vector shift = new Vector(0, 0, 0);
|
||||
@@ -157,8 +138,8 @@ public class StackCommand extends CommandAreaShop {
|
||||
if(group != null) {
|
||||
groupsMessage = Message.fromKey("stack-addToGroup").replacements(group.getName());
|
||||
}
|
||||
messageBridge.message(player, "stack-accepted", amount, type, gap, nameTemplate, groupsMessage);
|
||||
messageBridge.message(player, "stack-addStart", amount, regionsPerTick * 20);
|
||||
plugin.message(player, "stack-accepted", amount, type, gap, nameTemplate, groupsMessage);
|
||||
plugin.message(player, "stack-addStart", amount, regionsPerTick * 20);
|
||||
|
||||
Location minimumLocation = selection.getMinimumLocation();
|
||||
Vector minimumVector = new Vector(minimumLocation.getX(), minimumLocation.getY(), minimumLocation.getZ());
|
||||
@@ -195,24 +176,24 @@ public class StackCommand extends CommandAreaShop {
|
||||
tooHigh++;
|
||||
continue;
|
||||
}
|
||||
ProtectedCuboidRegion region = worldGuardInterface.createCuboidRegion(regionName, minimum,maximum);
|
||||
ProtectedCuboidRegion region = plugin.getWorldGuardHandler().createCuboidRegion(regionName, minimum,maximum);
|
||||
manager.addRegion(region);
|
||||
|
||||
// Add the region to AreaShop
|
||||
GeneralRegion newRegion;
|
||||
if(rentRegions) {
|
||||
newRegion = regionFactory.createRentRegion(regionName, selection.getWorld());
|
||||
newRegion = new RentRegion(regionName, selection.getWorld());
|
||||
|
||||
} else {
|
||||
newRegion = regionFactory.createBuyRegion(regionName, selection.getWorld());
|
||||
newRegion = new BuyRegion(regionName, selection.getWorld());
|
||||
}
|
||||
|
||||
if(finalGroup != null) {
|
||||
finalGroup.addMember(newRegion);
|
||||
}
|
||||
AddingRegionEvent event = fileManager.addRegion(newRegion);
|
||||
AddingRegionEvent event = plugin.getFileManager().addRegion(newRegion);
|
||||
if (event.isCancelled()) {
|
||||
messageBridge.message(player, "general-cancelled", event.getReason());
|
||||
plugin.message(player, "general-cancelled", event.getReason());
|
||||
continue;
|
||||
}
|
||||
newRegion.handleSchematicEvent(GeneralRegion.RegionEvent.CREATED);
|
||||
@@ -229,7 +210,7 @@ public class StackCommand extends CommandAreaShop {
|
||||
if(tooLow > 0) {
|
||||
wrong.append(Message.fromKey("stack-tooLow").replacements(tooLow));
|
||||
}
|
||||
messageBridge.message(player, "stack-addComplete", added, wrong);
|
||||
plugin.message(player, "stack-addComplete", added, wrong);
|
||||
}
|
||||
this.cancel();
|
||||
}
|
||||
@@ -264,7 +245,7 @@ public class StackCommand extends CommandAreaShop {
|
||||
result.add("rent");
|
||||
result.add("buy");
|
||||
} else if(toComplete == 6) {
|
||||
result.addAll(fileManager.getGroupNames());
|
||||
result.addAll(plugin.getFileManager().getGroupNames());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -12,14 +8,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class StopresellCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop stopresell";
|
||||
@@ -36,7 +26,7 @@ public class StopresellCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.stopresell") && !sender.hasPermission("areashop.stopresellall")) {
|
||||
messageBridge.message(sender, "stopresell-noPermissionOther");
|
||||
plugin.message(sender, "stopresell-noPermissionOther");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -46,47 +36,47 @@ public class StopresellCommand extends CommandAreaShop {
|
||||
// get the region by location
|
||||
List<BuyRegion> regions = Utils.getImportantBuyRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
buy = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
buy = fileManager.getBuy(args[1]);
|
||||
buy = plugin.getFileManager().getBuy(args[1]);
|
||||
if(buy == null) {
|
||||
messageBridge.message(sender, "stopresell-notRegistered", args[1]);
|
||||
plugin.message(sender, "stopresell-notRegistered", args[1]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(buy == null) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
}
|
||||
if(!buy.isInResellingMode()) {
|
||||
messageBridge.message(sender, "stopresell-notResell", buy);
|
||||
plugin.message(sender, "stopresell-notResell", buy);
|
||||
return;
|
||||
}
|
||||
if(sender.hasPermission("areashop.stopresellall")) {
|
||||
buy.disableReselling();
|
||||
buy.update();
|
||||
messageBridge.message(sender, "stopresell-success", buy);
|
||||
plugin.message(sender, "stopresell-success", buy);
|
||||
} else if(sender.hasPermission("areashop.stopresell") && sender instanceof Player) {
|
||||
if(buy.isOwner((Player)sender)) {
|
||||
buy.disableReselling();
|
||||
buy.update();
|
||||
messageBridge.message(sender, "stopresell-success", buy);
|
||||
plugin.message(sender, "stopresell-success", buy);
|
||||
} else {
|
||||
messageBridge.message(sender, "stopresell-noPermissionOther", buy);
|
||||
plugin.message(sender, "stopresell-noPermissionOther", buy);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "stopresell-noPermission", buy);
|
||||
plugin.message(sender, "stopresell-noPermission", buy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +84,7 @@ public class StopresellCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
for(BuyRegion region : fileManager.getBuysRef()) {
|
||||
for(BuyRegion region : plugin.getFileManager().getBuys()) {
|
||||
if(region.isSold() && region.isInResellingMode()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -11,14 +7,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class TeleportCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop tp";
|
||||
@@ -39,9 +29,10 @@ public class TeleportCommand extends CommandAreaShop {
|
||||
* @return true if the person can teleport to it, otherwise false
|
||||
*/
|
||||
public static boolean canUse(CommandSender person, GeneralRegion region) {
|
||||
if(!(person instanceof Player player)) {
|
||||
if(!(person instanceof Player)) {
|
||||
return false;
|
||||
}
|
||||
Player player = (Player)person;
|
||||
return player.hasPermission("areashop.teleportall")
|
||||
|| region.isOwner(player) && player.hasPermission("areashop.teleport")
|
||||
|| region.isAvailable() && player.hasPermission("areashop.teleportavailable")
|
||||
@@ -51,20 +42,21 @@ public class TeleportCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.teleport") && !sender.hasPermission("areashop.teleportall") && !sender.hasPermission("areashop.teleportavailable") && !sender.hasPermission("areashop.teleportavailablesign") && !sender.hasPermission("areashop.teleportsign") && !sender.hasPermission("areashop.teleportsignall") && !sender.hasPermission("areashop.teleportfriend") && !sender.hasPermission("teleportfriendsign")) {
|
||||
messageBridge.message(sender, "teleport-noPermission");
|
||||
plugin.message(sender, "teleport-noPermission");
|
||||
return;
|
||||
}
|
||||
if(!(sender instanceof Player player)) {
|
||||
messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
if(!(sender instanceof Player)) {
|
||||
plugin.message(sender, "cmd-onlyByPlayer");
|
||||
return;
|
||||
}
|
||||
if(args.length <= 1 || args[1] == null) {
|
||||
messageBridge.message(sender, "teleport-help");
|
||||
plugin.message(sender, "teleport-help");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region = fileManager.getRegion(args[1]);
|
||||
Player player = (Player)sender;
|
||||
GeneralRegion region = plugin.getFileManager().getRegion(args[1]);
|
||||
if(region == null) {
|
||||
messageBridge.message(player, "teleport-noRentOrBuy", args[1]);
|
||||
plugin.message(player, "teleport-noRentOrBuy", args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,14 +65,14 @@ public class TeleportCommand extends CommandAreaShop {
|
||||
|| args[2].equalsIgnoreCase("yes")
|
||||
|| args[2].equalsIgnoreCase("true")
|
||||
);
|
||||
region.getTeleportFeature().teleportPlayer(player, toSign);
|
||||
region.getTeleportFeature().teleportPlayer(player, toSign, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
result.addAll(fileManager.getRegionNames());
|
||||
result.addAll(plugin.getFileManager().getRegionNames());
|
||||
} else if(toComplete == 3) {
|
||||
result.add("sign");
|
||||
}
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Singleton
|
||||
public class TransferCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
@Inject
|
||||
private Plugin plugin;
|
||||
@Inject
|
||||
private Server server;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop transfer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(CommandSender target) {
|
||||
if (!target.hasPermission("areashop.transfer")) {
|
||||
return null;
|
||||
}
|
||||
return "help-transfer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!sender.hasPermission("areashop.transfer")) {
|
||||
this.messageBridge.message(sender, "transfer-noPermission");
|
||||
return;
|
||||
}
|
||||
if (sender instanceof Player player) {
|
||||
handlePlayer(player, args);
|
||||
} else {
|
||||
this.messageBridge.message(sender, "cmd-onlyByPlayer");
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePlayer(Player player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
this.messageBridge.message(player, "transfer-help");
|
||||
return;
|
||||
}
|
||||
String targetPlayerName = args[1];
|
||||
if (targetPlayerName.equals(player.getName())) {
|
||||
this.messageBridge.message(player, "transfer-transferSelf");
|
||||
return;
|
||||
}
|
||||
GeneralRegion region;
|
||||
if (args.length > 2) {
|
||||
String targetRegionName = args[2];
|
||||
region = this.fileManager.getRegion(targetRegionName);
|
||||
if (region == null) {
|
||||
messageBridge.message(player, "cmd-noRegion");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(player.getLocation());
|
||||
if (regions.isEmpty()) {
|
||||
messageBridge.message(player, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if (regions.size() > 1) {
|
||||
messageBridge.message(player, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
}
|
||||
region = regions.get(0);
|
||||
}
|
||||
if (!region.isTransferEnabled()) {
|
||||
this.messageBridge.message(player, "transfer-disabled");
|
||||
return;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer targetPlayer = this.server.getOfflinePlayer(targetPlayerName);
|
||||
if (!targetPlayer.hasPlayedBefore()) {
|
||||
// Unknown player
|
||||
this.messageBridge.message(player, "transfer-noPlayer", targetPlayerName);
|
||||
return;
|
||||
}
|
||||
if (region.isLandlord(player.getUniqueId())) {
|
||||
// Transfer ownership if same as landlord
|
||||
region.getFriendsFeature().deleteFriend(region.getOwner(), null);
|
||||
region.setOwner(targetPlayer.getUniqueId());
|
||||
region.setLandlord(targetPlayer.getUniqueId(), targetPlayerName);
|
||||
this.messageBridge.message(player, "transfer-transferred-owner", targetPlayerName, region);
|
||||
if (targetPlayer.isOnline()) {
|
||||
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-owner", targetPlayerName, region);
|
||||
}
|
||||
region.update();
|
||||
region.saveRequired();
|
||||
return;
|
||||
}
|
||||
if (!region.isOwner(player.getUniqueId())) {
|
||||
// Cannot transfer tenant if we aren't the current tenant
|
||||
this.messageBridge.message(player, "transfer-notCurrentTenant");
|
||||
return;
|
||||
}
|
||||
region.getFriendsFeature().deleteFriend(region.getOwner(), null);
|
||||
// Swap the owner/occupant (renter or buyer)
|
||||
region.setOwner(targetPlayer.getUniqueId());
|
||||
|
||||
this.messageBridge.message(player, "transfer-transferred-tenant", targetPlayerName, region);
|
||||
if (targetPlayer.isOnline()) {
|
||||
this.messageBridge.message(targetPlayer.getPlayer(), "transfer-transferred-tenant", targetPlayerName, region);
|
||||
}
|
||||
region.update();
|
||||
region.saveRequired();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
if (toComplete == 2) {
|
||||
Collection<? extends Player> players = this.server.getOnlinePlayers();
|
||||
List<String> ret = new ArrayList<>(players.stream()
|
||||
.map(Player::getName)
|
||||
.toList());
|
||||
if (sender instanceof Player player) {
|
||||
ret.remove(player.getName());
|
||||
}
|
||||
return ret;
|
||||
} else if (toComplete == 3) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
return this.fileManager.getRegionNames();
|
||||
}
|
||||
UUID uuid = player.getUniqueId();
|
||||
return new ArrayList<>(this.fileManager.getRegions()
|
||||
.stream()
|
||||
.filter(region -> region.isOwner(uuid) || region.isLandlord(uuid))
|
||||
.map(GeneralRegion::getName)
|
||||
.toList());
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
package me.wiefferink.areashop.commands;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
@@ -13,14 +9,8 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class UnrentCommand extends CommandAreaShop {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
@Inject
|
||||
private IFileManager fileManager;
|
||||
|
||||
@Override
|
||||
public String getCommandStart() {
|
||||
return "areashop unrent";
|
||||
@@ -44,7 +34,8 @@ public class UnrentCommand extends CommandAreaShop {
|
||||
if(person.hasPermission("areashop.unrent")) {
|
||||
return true;
|
||||
}
|
||||
if(person instanceof Player player) {
|
||||
if(person instanceof Player) {
|
||||
Player player = (Player)person;
|
||||
return region.isOwner(player) && person.hasPermission("areashop.unrentown");
|
||||
}
|
||||
return false;
|
||||
@@ -53,7 +44,7 @@ public class UnrentCommand extends CommandAreaShop {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!sender.hasPermission("areashop.unrent") && !sender.hasPermission("areashop.unrentown")) {
|
||||
messageBridge.message(sender, "unrent-noPermission");
|
||||
plugin.message(sender, "unrent-noPermission");
|
||||
return;
|
||||
}
|
||||
RentRegion rent;
|
||||
@@ -62,27 +53,27 @@ public class UnrentCommand extends CommandAreaShop {
|
||||
// get the region by location
|
||||
List<RentRegion> regions = Utils.getImportantRentRegions(((Player)sender).getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(sender, "cmd-noRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-noRegionsAtLocation");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(sender, "cmd-moreRegionsAtLocation");
|
||||
plugin.message(sender, "cmd-moreRegionsAtLocation");
|
||||
return;
|
||||
} else {
|
||||
rent = regions.get(0);
|
||||
}
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
plugin.message(sender, "cmd-automaticRegionOnlyByPlayer");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
rent = fileManager.getRent(args[1]);
|
||||
rent = plugin.getFileManager().getRent(args[1]);
|
||||
}
|
||||
if(rent == null) {
|
||||
messageBridge.message(sender, "unrent-notRegistered");
|
||||
plugin.message(sender, "unrent-notRegistered");
|
||||
return;
|
||||
}
|
||||
if(!rent.isRented()) {
|
||||
messageBridge.message(sender, "unrent-notRented", rent);
|
||||
plugin.message(sender, "unrent-notRented", rent);
|
||||
return;
|
||||
}
|
||||
rent.unRent(true, sender);
|
||||
@@ -92,7 +83,7 @@ public class UnrentCommand extends CommandAreaShop {
|
||||
public List<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
if(toComplete == 2) {
|
||||
for(RentRegion region : fileManager.getRentsRef()) {
|
||||
for(RentRegion region : plugin.getFileManager().getRents()) {
|
||||
if(region.isRented()) {
|
||||
result.add(region.getName());
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package me.wiefferink.areashop.features;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.events.ask.AddingRegionEvent;
|
||||
import me.wiefferink.areashop.events.ask.BuyingRegionEvent;
|
||||
import me.wiefferink.areashop.events.ask.DeletingRegionEvent;
|
||||
@@ -25,14 +22,8 @@ import org.bukkit.event.EventPriority;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class CommandsFeature extends RegionFeature {
|
||||
|
||||
@Inject
|
||||
CommandsFeature(AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run command for a certain event.
|
||||
* @param region Region to execute the events for
|
||||
@@ -45,7 +36,7 @@ public class CommandsFeature extends RegionFeature {
|
||||
return;
|
||||
}
|
||||
List<String> commands = eventCommandProfileSection.getStringList(event.getValue() + "." + (before ? "before" : "after"));
|
||||
if(commands.isEmpty()) {
|
||||
if(commands == null || commands.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
region.runCommands(Bukkit.getConsoleSender(), commands);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package me.wiefferink.areashop.features;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.events.ask.BuyingRegionEvent;
|
||||
import me.wiefferink.areashop.events.ask.RentingRegionEvent;
|
||||
@@ -21,16 +19,8 @@ import me.wiefferink.areashop.events.notify.UpdateRegionEvent;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
@Singleton
|
||||
public class DebugFeature extends RegionFeature {
|
||||
|
||||
@Inject
|
||||
DebugFeature(@Nonnull AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void buyingRegion(BuyingRegionEvent event) {
|
||||
AreaShop.debug("BuyingRegionEvent: " + event.getPlayer().getName() + " is trying to buy " + event.getRegion().getName());
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package me.wiefferink.areashop.features;
|
||||
|
||||
import me.wiefferink.areashop.features.signs.SignsFeature;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface FeatureFactory {
|
||||
|
||||
@Nonnull
|
||||
SignsFeature createSignsFeature(@Nonnull GeneralRegion generalRegion);
|
||||
|
||||
@Nonnull
|
||||
TeleportFeature createTeleportFeature(@Nonnull GeneralRegion generalRegion);
|
||||
|
||||
@Nonnull
|
||||
FriendsFeature createFriendsFeature(@Nonnull GeneralRegion generalRegion);
|
||||
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
package me.wiefferink.areashop.features;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.events.askandnotify.AddedFriendEvent;
|
||||
import me.wiefferink.areashop.events.askandnotify.DeletedFriendEvent;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
@@ -12,7 +7,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -21,12 +15,7 @@ import java.util.UUID;
|
||||
|
||||
public class FriendsFeature extends RegionFeature {
|
||||
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
|
||||
@AssistedInject
|
||||
public FriendsFeature(@Nonnull AreaShop plugin, @Assisted @Nonnull GeneralRegion region) {
|
||||
super(plugin);
|
||||
public FriendsFeature(GeneralRegion region) {
|
||||
setRegion(region);
|
||||
}
|
||||
|
||||
@@ -41,7 +30,7 @@ public class FriendsFeature extends RegionFeature {
|
||||
AddedFriendEvent event = new AddedFriendEvent(getRegion(), Bukkit.getOfflinePlayer(player), by);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) {
|
||||
messageBridge.message(by, "general-cancelled", event.getReason(), this);
|
||||
plugin.message(by, "general-cancelled", event.getReason(), this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,7 +52,7 @@ public class FriendsFeature extends RegionFeature {
|
||||
DeletedFriendEvent event = new DeletedFriendEvent(getRegion(), Bukkit.getOfflinePlayer(player), by);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) {
|
||||
messageBridge.message(by, "general-cancelled", event.getReason(), this);
|
||||
plugin.message(by, "general-cancelled", event.getReason(), this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,7 +92,7 @@ public class FriendsFeature extends RegionFeature {
|
||||
HashSet<String> result = new HashSet<>();
|
||||
for(UUID friend : getFriends()) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(friend);
|
||||
if(player != null && player.getName() != null) {
|
||||
if(player.hasPlayedBefore() && player.getName() != null) {
|
||||
result.add(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package me.wiefferink.areashop.features;
|
||||
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/*
|
||||
Possible future feature classes:
|
||||
- RestrictedToRegion feature
|
||||
@@ -29,14 +28,11 @@ Possible future feature classes:
|
||||
*/
|
||||
|
||||
public abstract class RegionFeature implements Listener {
|
||||
public static final AreaShop plugin = AreaShop.getInstance();
|
||||
|
||||
protected final AreaShop plugin;
|
||||
protected YamlConfiguration config = plugin.getConfig();
|
||||
private GeneralRegion region;
|
||||
|
||||
protected RegionFeature(@Nonnull AreaShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the region for this feature.
|
||||
* @param region Feature region
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+8
-21
@@ -5,34 +5,20 @@ import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.events.notify.UpdateRegionEvent;
|
||||
import me.wiefferink.areashop.interfaces.RegionAccessSet;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Singleton
|
||||
public class WorldGuardRegionFlagsFeature extends RegionFeature {
|
||||
|
||||
@Inject
|
||||
private WorldGuardInterface worldGuardInterface;
|
||||
@Inject
|
||||
private WorldGuardPlugin worldGuard;
|
||||
|
||||
@Inject
|
||||
WorldGuardRegionFlagsFeature(@Nonnull AreaShop plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void regionUpdate(UpdateRegionEvent event) {
|
||||
@@ -83,6 +69,7 @@ public class WorldGuardRegionFlagsFeature extends RegionFeature {
|
||||
boolean result = true;
|
||||
|
||||
Set<String> flagNames = flags.getKeys(false);
|
||||
WorldGuardPlugin worldGuard = plugin.getWorldGuard();
|
||||
|
||||
// Get the region
|
||||
ProtectedRegion worldguardRegion = region.getRegion();
|
||||
@@ -94,14 +81,14 @@ public class WorldGuardRegionFlagsFeature extends RegionFeature {
|
||||
for(String flagName : flagNames) {
|
||||
String value = Message.fromString(flags.getString(flagName)).replacements(region).getPlain();
|
||||
// In the config normal Bukkit color codes are used, those only need to be translated on 5.X WorldGuard versions
|
||||
if(worldGuard.getDescription().getVersion().startsWith("5.")) {
|
||||
if(plugin.getWorldGuard().getDescription().getVersion().startsWith("5.")) {
|
||||
value = translateBukkitToWorldGuardColors(value);
|
||||
}
|
||||
if(flagName.equalsIgnoreCase("members")) {
|
||||
worldGuardInterface.setMembers(worldguardRegion, parseAccessSet(value));
|
||||
plugin.getWorldGuardHandler().setMembers(worldguardRegion, parseAccessSet(value));
|
||||
//AreaShop.debug(" Flag " + flagName + " set: " + members.toUserFriendlyString());
|
||||
} else if(flagName.equalsIgnoreCase("owners")) {
|
||||
worldGuardInterface.setOwners(worldguardRegion, parseAccessSet(value));
|
||||
plugin.getWorldGuardHandler().setOwners(worldguardRegion, parseAccessSet(value));
|
||||
//AreaShop.debug(" Flag " + flagName + " set: " + owners.toUserFriendlyString());
|
||||
} else if(flagName.equalsIgnoreCase("priority")) {
|
||||
try {
|
||||
@@ -136,7 +123,7 @@ public class WorldGuardRegionFlagsFeature extends RegionFeature {
|
||||
String flagSetting = null;
|
||||
com.sk89q.worldguard.protection.flags.RegionGroup groupValue = null;
|
||||
|
||||
Flag<?> foundFlag = worldGuardInterface.fuzzyMatchFlag(flagName);
|
||||
Flag<?> foundFlag = plugin.getWorldGuardHandler().fuzzyMatchFlag(flagName);
|
||||
if(foundFlag == null) {
|
||||
AreaShop.warn("Found wrong flag in flagProfiles section: " + flagName + ", check if that is the correct WorldGuard flag");
|
||||
continue;
|
||||
@@ -158,7 +145,7 @@ public class WorldGuardRegionFlagsFeature extends RegionFeature {
|
||||
if(part.startsWith("g:")) {
|
||||
if(part.length() > 2) {
|
||||
try {
|
||||
groupValue = worldGuardInterface.parseFlagGroupInput(groupFlag, part.substring(2));
|
||||
groupValue = plugin.getWorldGuardHandler().parseFlagGroupInput(groupFlag, part.substring(2));
|
||||
} catch(InvalidFlagFormat e) {
|
||||
AreaShop.warn("Found wrong group value for flag " + flagName);
|
||||
}
|
||||
@@ -242,7 +229,7 @@ public class WorldGuardRegionFlagsFeature extends RegionFeature {
|
||||
*/
|
||||
private <V> void setFlag(ProtectedRegion region, Flag<V> flag, String value) throws InvalidFlagFormat {
|
||||
V current = region.getFlag(flag);
|
||||
V next = worldGuardInterface.parseFlagInput(flag, value);
|
||||
V next = plugin.getWorldGuardHandler().parseFlagInput(flag, value);
|
||||
|
||||
if(!Objects.equals(current, next)) {
|
||||
region.setFlag(flag, next);
|
||||
@@ -268,7 +255,7 @@ public class WorldGuardRegionFlagsFeature extends RegionFeature {
|
||||
result = result.replace("&1", "&B");
|
||||
result = result.replace("&d", "&p");
|
||||
result = result.replace("&5", "&P");
|
||||
result = result.replace("&0", "&0");
|
||||
//result = result.replace("&0", "&0");
|
||||
result = result.replace("&8", "&1");
|
||||
result = result.replace("&7", "&2");
|
||||
result = result.replace("&f", "&w");
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
package me.wiefferink.areashop.features.signs;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.managers.SignErrorLogger;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.interfaces.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.tools.Materials;
|
||||
import me.wiefferink.areashop.tools.SignUtils;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -26,270 +24,308 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* Sign that is connected to a region to display information and interact with the region.
|
||||
*/
|
||||
public class RegionSign {
|
||||
|
||||
private final BlockBehaviourHelper blockHelper;
|
||||
private final SignErrorLogger errorLogger;
|
||||
|
||||
private final SignsFeature signsFeature;
|
||||
private final String key;
|
||||
public static final BlockBehaviourHelper behaviourHelper = AreaShop.getInstance().getNMSHelper().behaviourHelper();
|
||||
public static Level invalidSignLogLevel;
|
||||
public static boolean removeInvalidSigns;
|
||||
|
||||
static {
|
||||
YamlConfiguration configuration = AreaShop.getInstance().getConfig();
|
||||
removeInvalidSigns = configuration.getBoolean("signs.removeInvalid");
|
||||
final String rawLogLevel = configuration.getString("signs.invalidSignLogLevel", "WARNING");
|
||||
try {
|
||||
assert rawLogLevel != null;
|
||||
invalidSignLogLevel = Level.parse(rawLogLevel);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
AreaShop.warn("Invalid Logging Level: " + rawLogLevel);
|
||||
invalidSignLogLevel = Level.WARNING;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@AssistedInject
|
||||
RegionSign(
|
||||
@Nonnull BlockBehaviourHelper blockBehaviourHelper,
|
||||
@Nonnull SignErrorLogger signErrorLogger,
|
||||
@Assisted @Nonnull SignsFeature signsFeature,
|
||||
@Assisted @Nonnull String key
|
||||
) {
|
||||
this.blockHelper = blockBehaviourHelper;
|
||||
this.errorLogger = signErrorLogger;
|
||||
this.signsFeature = signsFeature;
|
||||
this.key = key;
|
||||
}
|
||||
private static boolean canLogSignError() {
|
||||
return AreaShop.getInstance().getLogger().isLoggable(invalidSignLogLevel);
|
||||
}
|
||||
|
||||
public BlockPosition getPosition() {
|
||||
return new BlockPosition(getLocation());
|
||||
}
|
||||
private static void logSignError(String... messages) {
|
||||
if (invalidSignLogLevel == Level.OFF) {
|
||||
return;
|
||||
}
|
||||
if (invalidSignLogLevel == Level.SEVERE) {
|
||||
AreaShop.error((Object) messages);
|
||||
} else if (invalidSignLogLevel == Level.WARNING) {
|
||||
AreaShop.warn((Object) messages);
|
||||
} else if (invalidSignLogLevel.intValue() >= Level.FINE.intValue()) {
|
||||
AreaShop.debug((Object) messages);
|
||||
} else {
|
||||
AreaShop.info((Object) messages);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the location of this sign.
|
||||
* @return The location of this sign
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return Utils.configToLocation(getRegion().getConfig().getConfigurationSection("general.signs." + key + ".location"));
|
||||
}
|
||||
private final SignsFeature signsFeature;
|
||||
private final String key;
|
||||
|
||||
/**
|
||||
* Location string to be used as key in maps.
|
||||
* @return Location string
|
||||
*/
|
||||
public String getStringLocation() {
|
||||
return SignsFeature.locationToString(getLocation());
|
||||
}
|
||||
public RegionSign(SignsFeature signsFeature, String key) {
|
||||
this.signsFeature = signsFeature;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Chunk string to be used as key in maps.
|
||||
* @return Chunk string
|
||||
*/
|
||||
public String getStringChunk() {
|
||||
return SignsFeature.chunkToString(getLocation());
|
||||
}
|
||||
/**
|
||||
* Get the location of this sign.
|
||||
*
|
||||
* @return The location of this sign
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return Utils.configToLocation(getRegion().getConfig().getConfigurationSection("general.signs." + key + ".location"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the region this sign is linked to.
|
||||
* @return The region this sign is linked to
|
||||
*/
|
||||
public GeneralRegion getRegion() {
|
||||
return signsFeature.getRegion();
|
||||
}
|
||||
/**
|
||||
* Location string to be used as key in maps.
|
||||
*
|
||||
* @return Location string
|
||||
*/
|
||||
public String getStringLocation() {
|
||||
return SignsFeature.locationToString(getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this sign from the region.
|
||||
*/
|
||||
public void remove() {
|
||||
Location location = getLocation();
|
||||
if (location != null && location.getWorld() != null) {
|
||||
location.getBlock().setType(Material.AIR);
|
||||
this.signsFeature.signManager().removeSign(this);
|
||||
}
|
||||
getRegion().setSetting("general.signs." + key, null);
|
||||
// Remove the sign from the region's sign manager
|
||||
}
|
||||
/**
|
||||
* Chunk string to be used as key in maps.
|
||||
*
|
||||
* @return Chunk string
|
||||
*/
|
||||
public String getStringChunk() {
|
||||
return SignsFeature.chunkToString(getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ConfigurationSection defining the sign layout.
|
||||
* @return The sign layout config
|
||||
*/
|
||||
public ConfigurationSection getProfile() {
|
||||
return getRegion().getConfigurationSectionSetting("general.signProfile", "signProfiles", getRegion().getConfig().get("general.signs." + key + ".profile"));
|
||||
}
|
||||
/**
|
||||
* Get the region this sign is linked to.
|
||||
*
|
||||
* @return The region this sign is linked to
|
||||
*/
|
||||
public GeneralRegion getRegion() {
|
||||
return signsFeature.getRegion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the facing of the sign as saved in the config.
|
||||
* @return BlockFace the sign faces, or null if unknown
|
||||
*/
|
||||
public BlockFace getFacing() {
|
||||
try {
|
||||
return BlockFace.valueOf(getRegion().getConfig().getString("general.signs." + key + ".facing"));
|
||||
} catch(NullPointerException | IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Remove this sign from the region.
|
||||
*/
|
||||
public void remove() {
|
||||
getLocation().getBlock().setType(Material.AIR);
|
||||
signsFeature.getSignsRef().remove(getStringLocation());
|
||||
SignsFeature.getAllSigns().remove(getStringLocation());
|
||||
SignsFeature.getSignsByChunk().get(getStringChunk()).remove(this);
|
||||
getRegion().setSetting("general.signs." + key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material of the sign as saved in the config.
|
||||
* @return Material of the sign,Material.AIR if none.
|
||||
*/
|
||||
public Material getMaterial() {
|
||||
String name = getRegion().getConfig().getString("general.signs." + key + ".signType");
|
||||
Material result = Materials.signNameToMaterial(name);
|
||||
return result == null ? Material.AIR : result;
|
||||
}
|
||||
/**
|
||||
* Get the ConfigurationSection defining the sign layout.
|
||||
*
|
||||
* @return The sign layout config
|
||||
*/
|
||||
public ConfigurationSection getProfile() {
|
||||
return getRegion().getConfigurationSectionSetting("general.signProfile", "signProfiles", getRegion().getConfig().get("general.signs." + key + ".profile"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update this sign.
|
||||
* @return true if the update was successful, otherwise false
|
||||
*/
|
||||
public boolean update() {
|
||||
// Ignore updates of signs in chunks that are not loaded
|
||||
Location signLocation = getLocation();
|
||||
if(signLocation == null
|
||||
|| signLocation.getWorld() == null
|
||||
|| !signLocation.getWorld().isChunkLoaded(signLocation.getBlockX() >> 4, signLocation.getBlockZ() >> 4)) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get the facing of the sign as saved in the config.
|
||||
*
|
||||
* @return BlockFace the sign faces, or null if unknown
|
||||
*/
|
||||
public BlockFace getFacing() {
|
||||
try {
|
||||
return BlockFace.valueOf(getRegion().getConfig().getString("general.signs." + key + ".facing"));
|
||||
} catch (NullPointerException | IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(getRegion().isDeleted()) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get the material of the sign as saved in the config.
|
||||
*
|
||||
* @return Material of the sign, usually, a sign or {@link Material#AIR} if none.
|
||||
*/
|
||||
public Material getMaterial() {
|
||||
String name = getRegion().getConfig().getString("general.signs." + key + ".signType");
|
||||
Material result = Materials.signNameToMaterial(name);
|
||||
return result == null ? Material.AIR : result;
|
||||
}
|
||||
|
||||
YamlConfiguration regionConfig = getRegion().getConfig();
|
||||
ConfigurationSection signConfig = getProfile();
|
||||
Block block = signLocation.getBlock();
|
||||
if(signConfig == null || !signConfig.isSet(getRegion().getState().getValue())) {
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Update this sign.
|
||||
*
|
||||
* @return true if the update was successful, otherwise false
|
||||
*/
|
||||
public boolean update() {
|
||||
// Ignore updates of signs in chunks that are not loaded
|
||||
Location signLocation = getLocation();
|
||||
if (signLocation == null
|
||||
|| signLocation.getWorld() == null
|
||||
|| !signLocation.getWorld().isChunkLoaded(signLocation.getBlockX() >> 4, signLocation.getBlockZ() >> 4)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ConfigurationSection stateConfig = signConfig.getConfigurationSection(getRegion().getState().getValue());
|
||||
if (getRegion().isDeleted()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the lines
|
||||
String[] signLines = new String[4];
|
||||
boolean signEmpty = true;
|
||||
for(int i = 0; i < 4; i++) {
|
||||
signLines[i] = stateConfig.getString("line" + (i + 1));
|
||||
signEmpty &= (signLines[i] == null || signLines[i].isEmpty());
|
||||
}
|
||||
if(signEmpty) {
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
YamlConfiguration regionConfig = getRegion().getConfig();
|
||||
ConfigurationSection signConfig = getProfile();
|
||||
Block block = signLocation.getBlock();
|
||||
if (signConfig == null || !signConfig.isSet(getRegion().getState().getValue())) {
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Place the sign back (with proper rotation and type) after it has been hidden or (indirectly) destroyed
|
||||
if(!Materials.isSign(block.getType())) {
|
||||
Material signType = getMaterial();
|
||||
if (!blockHelper.canPlace(block.getLocation(), Bukkit.createBlockData(signType))) {
|
||||
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);
|
||||
ConfigurationSection stateConfig = signConfig.getConfigurationSection(getRegion().getState().getValue());
|
||||
assert stateConfig != null;
|
||||
// Get the lines
|
||||
String[] signLines = new String[4];
|
||||
boolean signEmpty = true;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
signLines[i] = stateConfig.getString("line" + (i + 1));
|
||||
signEmpty &= (signLines[i] == null || signLines[i].isEmpty());
|
||||
}
|
||||
if (signEmpty) {
|
||||
block.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
final BlockStateSnapshotResult snapshot = PaperLib.getBlockState(block, false);
|
||||
final BlockState blockState = snapshot.getState();
|
||||
final BlockData blockData = blockState.getBlockData();
|
||||
final SignErrorLogger errorLogger = AreaShop.getInstance().getSignErrorLogger();
|
||||
Material signType = getMaterial();
|
||||
// Place the sign back (with proper rotation and type) after it has been hidden or (indirectly) destroyed
|
||||
if (!Materials.isSign(blockState.getType())) {
|
||||
// Don't do physics here, we first need to update the direction
|
||||
blockState.setType(signType);
|
||||
if (blockData instanceof WallSign) {
|
||||
((WallSign) blockData).setFacing(getFacing());
|
||||
} else if (blockData instanceof Sign) {
|
||||
((org.bukkit.block.data.type.Sign) blockData).setRotation(getFacing());
|
||||
}
|
||||
blockState.setBlockData(blockData);
|
||||
blockState.update(false, true);
|
||||
// Check if the sign has popped
|
||||
if (!Materials.isSign(block.getType())) {
|
||||
final String message = String.format("Setting sign of $1%s of region $2%s failed, could not set sign block back", key, getRegion().getName());
|
||||
errorLogger.submitWarning(message);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
final String message = "Setting sign $1%s of region $2%s failed, RegionSign material was: $3%s";
|
||||
errorLogger.submitWarning(String.format(message, key, getRegion().getName(), signType.name()));
|
||||
}
|
||||
|
||||
BlockState blockState = PaperLib.getBlockState(block, false).getState();
|
||||
BlockData blockData = blockState.getBlockData();
|
||||
// Save current rotation and type
|
||||
if (!regionConfig.isString("general.signs." + key + ".signType")) {
|
||||
getRegion().setSetting("general.signs." + key + ".signType", block.getType().name());
|
||||
}
|
||||
if (!regionConfig.isString("general.signs." + key + ".facing")) {
|
||||
final BlockFace rotation;
|
||||
if (Materials.isSign(block.getType())) {
|
||||
BlockData data = blockState.getBlockData();
|
||||
if (data instanceof org.bukkit.block.data.type.Sign) {
|
||||
rotation = ((org.bukkit.block.data.type.Sign) block.getBlockData()).getRotation();
|
||||
} else if (data instanceof WallSign) {
|
||||
rotation = ((WallSign) data).getFacing();
|
||||
} else {
|
||||
rotation = null;
|
||||
}
|
||||
} else {
|
||||
rotation = null;
|
||||
}
|
||||
getRegion().setSetting("general.signs." + key + ".facing", rotation == null ? null : rotation.toString());
|
||||
}
|
||||
|
||||
if(blockData instanceof WallSign) {
|
||||
((WallSign) blockData).setFacing(getFacing());
|
||||
} else if(blockData instanceof org.bukkit.block.data.type.Sign) {
|
||||
((org.bukkit.block.data.type.Sign) blockData).setRotation(getFacing());
|
||||
} else {
|
||||
errorLogger.submitWarning("Failed to update the facing direction of the sign at" + getStringLocation() + "to " + getFacing() + ", region:" + getRegion().getName());
|
||||
return false;
|
||||
}
|
||||
block.setBlockData(blockData);
|
||||
// Apply replacements and color and then set it on the sign
|
||||
Sign signState = (Sign) blockState;
|
||||
for (int i = 0; i < signLines.length; i++) {
|
||||
if (signLines[i] == null) {
|
||||
signState.setLine(i, "");
|
||||
continue;
|
||||
}
|
||||
signLines[i] = Message.fromString(signLines[i]).replacements(getRegion()).getSingle();
|
||||
signLines[i] = Utils.applyColors(signLines[i]);
|
||||
signState.setLine(i, signLines[i]);
|
||||
}
|
||||
// BlockState#update *should* return true here.
|
||||
return blockState.update(true, false);
|
||||
}
|
||||
|
||||
// Check if the sign has popped
|
||||
if(!Materials.isSign(block.getType())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Check if the sign needs to update periodically.
|
||||
*
|
||||
* @return true if it needs periodic updates, otherwise false
|
||||
*/
|
||||
public boolean needsPeriodicUpdate() {
|
||||
ConfigurationSection signConfig = getProfile();
|
||||
if (signConfig == null || !signConfig.isSet(getRegion().getState().getValue().toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save current rotation and type
|
||||
if(!regionConfig.isString("general.signs." + key + ".signType")) {
|
||||
getRegion().setSetting("general.signs." + key + ".signType", block.getType().name());
|
||||
}
|
||||
if(!regionConfig.isString("general.signs." + key + ".facing")) {
|
||||
BlockFace signFacing = SignUtils.getSignFacing(block);
|
||||
getRegion().setSetting("general.signs." + key + ".facing", signFacing == null ? null : signFacing.toString());
|
||||
}
|
||||
ConfigurationSection stateConfig = signConfig.getConfigurationSection(getRegion().getState().getValue().toLowerCase());
|
||||
if (stateConfig == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Apply replacements and color and then set it on the sign
|
||||
Sign signState = (Sign) PaperLib.getBlockState(block, false).getState();
|
||||
for(int i = 0; i < signLines.length; i++) {
|
||||
if(signLines[i] == null) {
|
||||
signState.setLine(i, "");
|
||||
continue;
|
||||
}
|
||||
signLines[i] = Message.fromString(signLines[i]).replacements(getRegion()).getSingle();
|
||||
signLines[i] = Utils.applyColors(signLines[i]);
|
||||
signState.setLine(i, signLines[i]);
|
||||
}
|
||||
signState.update(false, false);
|
||||
return true;
|
||||
}
|
||||
// Check the lines for the timeleft tag
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
String line = stateConfig.getString("line" + i);
|
||||
if (line != null && !line.isEmpty() && line.contains(Message.VARIABLE_START + AreaShop.tagTimeLeft + Message.VARIABLE_END)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the sign needs to update periodically.
|
||||
* @return true if it needs periodic updates, otherwise false
|
||||
*/
|
||||
public boolean needsPeriodicUpdate() {
|
||||
ConfigurationSection signConfig = getProfile();
|
||||
if(signConfig == null || !signConfig.isSet(getRegion().getState().getValue().toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Run commands when a player clicks a sign.
|
||||
*
|
||||
* @param clicker The player that clicked the sign
|
||||
* @param clickType The type of clicking
|
||||
* @return true if the commands ran successfully, false if any of them failed
|
||||
*/
|
||||
public boolean runSignCommands(Player clicker, GeneralRegion.ClickType clickType) {
|
||||
ConfigurationSection signConfig = getProfile();
|
||||
if (signConfig == null) {
|
||||
return false;
|
||||
}
|
||||
ConfigurationSection stateConfig = signConfig.getConfigurationSection(getRegion().getState().getValue().toLowerCase());
|
||||
|
||||
ConfigurationSection stateConfig = signConfig.getConfigurationSection(getRegion().getState().getValue().toLowerCase());
|
||||
if(stateConfig == null) {
|
||||
return false;
|
||||
}
|
||||
// Run player commands if specified
|
||||
List<String> playerCommands = new ArrayList<>();
|
||||
for (String command : stateConfig.getStringList(clickType.getValue() + "Player")) {
|
||||
// TODO move variable checking code to InteractiveMessenger?
|
||||
playerCommands.add(command.replace(Message.VARIABLE_START + AreaShop.tagClicker + Message.VARIABLE_END, clicker.getName()));
|
||||
}
|
||||
getRegion().runCommands(clicker, playerCommands);
|
||||
|
||||
// Check the lines for the timeleft tag
|
||||
for(int i = 1; i <= 4; i++) {
|
||||
String line = stateConfig.getString("line" + i);
|
||||
if(line != null && line.contains(Message.VARIABLE_START + AreaShop.tagTimeLeft + Message.VARIABLE_END)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Run console commands if specified
|
||||
List<String> consoleCommands = new ArrayList<>();
|
||||
for (String command : stateConfig.getStringList(clickType.getValue() + "Console")) {
|
||||
consoleCommands.add(command.replace(Message.VARIABLE_START + AreaShop.tagClicker + Message.VARIABLE_END, clicker.getName()));
|
||||
}
|
||||
getRegion().runCommands(Bukkit.getConsoleSender(), consoleCommands);
|
||||
|
||||
/**
|
||||
* Run commands when a player clicks a sign.
|
||||
* @param clicker The player that clicked the sign
|
||||
* @param clickType The type of clicking
|
||||
* @return true if the commands ran successfully, false if any of them failed
|
||||
*/
|
||||
public boolean runSignCommands(Player clicker, GeneralRegion.ClickType clickType) {
|
||||
ConfigurationSection signConfig = getProfile();
|
||||
if(signConfig == null) {
|
||||
return false;
|
||||
}
|
||||
ConfigurationSection stateConfig = signConfig.getConfigurationSection(getRegion().getState().getValue().toLowerCase());
|
||||
return !playerCommands.isEmpty() || !consoleCommands.isEmpty();
|
||||
}
|
||||
|
||||
// Run player commands if specified
|
||||
List<String> playerCommands = new ArrayList<>();
|
||||
for(String command : stateConfig.getStringList(clickType.getValue() + "Player")) {
|
||||
// TODO move variable checking code to InteractiveMessenger?
|
||||
playerCommands.add(command.replace(Message.VARIABLE_START + AreaShop.tagClicker + Message.VARIABLE_END, clicker.getName()));
|
||||
}
|
||||
getRegion().runCommands(clicker, playerCommands);
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof RegionSign && ((RegionSign) object).getRegion().equals(this.getRegion()) && ((RegionSign) object).key.equals(this.key);
|
||||
}
|
||||
|
||||
// Run console commands if specified
|
||||
List<String> consoleCommands = new ArrayList<>();
|
||||
for(String command : stateConfig.getStringList(clickType.getValue() + "Console")) {
|
||||
consoleCommands.add(command.replace(Message.VARIABLE_START + AreaShop.tagClicker + Message.VARIABLE_END, clicker.getName()));
|
||||
}
|
||||
getRegion().runCommands(Bukkit.getConsoleSender(), consoleCommands);
|
||||
|
||||
return !playerCommands.isEmpty() || !consoleCommands.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof RegionSign && ((RegionSign)object).getRegion().equals(this.getRegion()) && ((RegionSign)object).key.equals(this.key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(key, getRegion().getName());
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(key, getRegion().getName());
|
||||
}
|
||||
}
|
||||
@@ -1,83 +1,121 @@
|
||||
package me.wiefferink.areashop.features.signs;
|
||||
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import io.github.bakedlibs.dough.blocks.ChunkPosition;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class SignCache {
|
||||
|
||||
private final Map<Long, RegionSign> allSigns = new HashMap<>();
|
||||
private final Map<Long, Collection<RegionSign>> signsByChunk = new HashMap<>();
|
||||
|
||||
public Optional<RegionSign> signAtLocation(long position) {
|
||||
return Optional.ofNullable(this.allSigns.get(position));
|
||||
}
|
||||
|
||||
public Collection<RegionSign> signsAtChunk(long position) {
|
||||
return Collections.unmodifiableCollection(this.signsByChunk.getOrDefault(position, Collections.emptyList()));
|
||||
}
|
||||
|
||||
public Collection<RegionSign> allSigns() {
|
||||
return Collections.unmodifiableCollection(this.allSigns.values());
|
||||
}
|
||||
|
||||
public Collection<BlockPosition> allSignLocations() {
|
||||
Collection<BlockPosition> positions = new ArrayList<>(this.signsByChunk.size());
|
||||
for (RegionSign sign : this.allSigns.values()) {
|
||||
positions.add(sign.getPosition());
|
||||
}
|
||||
return positions;
|
||||
}
|
||||
|
||||
public void addSign(RegionSign regionSign) {
|
||||
BlockPosition blockPosition = regionSign.getPosition();
|
||||
this.allSigns.put(blockPosition.getPosition(), regionSign);
|
||||
ChunkPosition chunkPosition = new ChunkPosition(blockPosition.getChunk());
|
||||
Collection<RegionSign> signs = this.signsByChunk.computeIfAbsent(chunkPosition.getPosition(), x -> new HashSet<>());
|
||||
signs.add(regionSign);
|
||||
}
|
||||
|
||||
public Optional<RegionSign> removeSign(Location location) {
|
||||
return removeSign(new BlockPosition(location));
|
||||
}
|
||||
|
||||
public Optional<RegionSign> removeSign(BlockPosition position) {
|
||||
RegionSign removed = this.allSigns.remove(position.getPosition());
|
||||
if (removed != null) {
|
||||
World world = position.getWorld();
|
||||
ChunkPosition chunkPosition = new ChunkPosition(world, position.getChunkX(), position.getChunkZ());
|
||||
this.signsByChunk.remove(chunkPosition.getPosition());
|
||||
// Remove the sign from the region
|
||||
}
|
||||
return Optional.ofNullable(removed);
|
||||
}
|
||||
|
||||
public void removeSign(RegionSign regionSign) {
|
||||
BlockPosition blockPosition = regionSign.getPosition();
|
||||
this.allSigns.remove(blockPosition.getPosition());
|
||||
ChunkPosition chunkPosition = new ChunkPosition(blockPosition.getChunk());
|
||||
long packedChunkPos = chunkPosition.getPosition();
|
||||
Collection<RegionSign> signs = this.signsByChunk.get(packedChunkPos);
|
||||
if (signs != null) {
|
||||
signs.remove(regionSign);
|
||||
if (signs.isEmpty()) {
|
||||
this.signsByChunk.remove(packedChunkPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.allSigns.clear();
|
||||
this.signsByChunk.clear();
|
||||
}
|
||||
|
||||
}
|
||||
package me.wiefferink.areashop.features.signs;
|
||||
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.events.notify.UpdateRegionEvent;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SignCache implements Listener {
|
||||
|
||||
private final Map<String, RegionSign> allSigns = new HashMap<>();
|
||||
private final Map<String, List<RegionSign>> signsByChunk = new HashMap<>();
|
||||
|
||||
public void registerListeners() {
|
||||
Bukkit.getPluginManager().registerEvents(this, AreaShop.getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a location to a string to use as map key.
|
||||
*
|
||||
* @param location The location to get the key for
|
||||
* @return A string to use in a map for a location
|
||||
*/
|
||||
public static String locationToString(Location location) {
|
||||
return location.getWorld().getName() + ";" + location.getBlockX() + ";" + location.getBlockY() + ";" + location.getBlockZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a chunk to a string to use as map key.
|
||||
*
|
||||
* @param location The location to get the key for
|
||||
* @return A string to use in a map for a chunk
|
||||
*/
|
||||
public static String chunkToString(Location location) {
|
||||
return location.getWorld().getName() + ";" + (location.getBlockX() >> 4) + ";" + (location.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a chunk to a string to use as map key.
|
||||
* Use a Location argument to prevent chunk loading!
|
||||
*
|
||||
* @param chunk The location to get the key for
|
||||
* @return A string to use in a map for a chunk
|
||||
*/
|
||||
public static String chunkToString(Chunk chunk) {
|
||||
return chunk.getWorld().getName() + ";" + chunk.getX() + ";" + chunk.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a sign by a location.
|
||||
*
|
||||
* @param location The location to get the sign for
|
||||
* @return The RegionSign that is at the location, or null if none
|
||||
*/
|
||||
public RegionSign getSignByLocation(Location location) {
|
||||
return allSigns.get(locationToString(location));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the map with all signs.
|
||||
*
|
||||
* @return Map with all signs: locationString -> RegionSign
|
||||
*/
|
||||
public Map<String, RegionSign> getAllSigns() {
|
||||
return allSigns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the map with signs by chunk.
|
||||
*
|
||||
* @return Map with signs by chunk: chunkString -> List<RegionSign>
|
||||
*/
|
||||
public Map<String, List<RegionSign>> getSignsByChunk() {
|
||||
return signsByChunk;
|
||||
}
|
||||
|
||||
public void addSign(RegionSign regionSign) {
|
||||
signsByChunk.computeIfAbsent(regionSign.getStringChunk(), (unused) -> new ArrayList<>()).add(regionSign);
|
||||
}
|
||||
|
||||
public void removeSign(RegionSign regionSign) {
|
||||
final List<RegionSign> signs = signsByChunk.get(regionSign.getStringChunk());
|
||||
if (signs != null) {
|
||||
signs.remove(regionSign);
|
||||
}
|
||||
allSigns.remove(regionSign.getStringLocation());
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
HandlerList.unregisterAll(this);
|
||||
signsByChunk.clear();
|
||||
allSigns.clear();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void regionUpdate(UpdateRegionEvent event) {
|
||||
event.getRegion().getSignsFeature().update();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
List<RegionSign> chunkSigns = signsByChunk.get(chunkToString(event.getChunk()));
|
||||
if (chunkSigns == null) {
|
||||
return;
|
||||
}
|
||||
int batchSize = Math.max(chunkSigns.size() / 10, 10);
|
||||
Utils.runAsBatches(chunkSigns, batchSize, RegionSign::update, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package me.wiefferink.areashop.features.signs;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface SignFactory {
|
||||
|
||||
@Nonnull RegionSign createRegionSign(@Nonnull SignsFeature signsFeature, @Nonnull String key);
|
||||
|
||||
}
|
||||
@@ -1,449 +0,0 @@
|
||||
package me.wiefferink.areashop.features.signs;
|
||||
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import io.github.bakedlibs.dough.blocks.ChunkPosition;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.events.ask.AddingRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.UpdateRegionEvent;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Materials;
|
||||
import me.wiefferink.areashop.tools.SignUtils;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import me.wiefferink.bukkitdo.Do;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class SignListener implements Listener {
|
||||
|
||||
private final BlockBehaviourHelper behaviourHelper;
|
||||
private final AreaShop plugin;
|
||||
private final MessageBridge messageBridge;
|
||||
private final SignManager signManager;
|
||||
private final SignLinkerManager signLinkerManager;
|
||||
private final WorldGuardInterface worldGuardInterface;
|
||||
private final RegionFactory regionFactory;
|
||||
private final IFileManager fileManager;
|
||||
|
||||
public SignListener(
|
||||
@Nonnull AreaShop plugin,
|
||||
@Nonnull BlockBehaviourHelper behaviourHelper,
|
||||
@Nonnull RegionFactory regionFactory,
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull SignLinkerManager signLinkerManager,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nonnull SignManager signManager,
|
||||
@Nonnull IFileManager fileManager) {
|
||||
this.fileManager = fileManager;
|
||||
this.signManager = signManager;
|
||||
this.signLinkerManager = signLinkerManager;
|
||||
this.regionFactory = regionFactory;
|
||||
this.behaviourHelper = behaviourHelper;
|
||||
this.plugin = plugin;
|
||||
this.worldGuardInterface = worldGuardInterface;
|
||||
this.messageBridge = messageBridge;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void regionUpdate(UpdateRegionEvent event) {
|
||||
SignsFeature signsFeature = event.getRegion().getSignsFeature();
|
||||
signsFeature.signManager().update();
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
Chunk chunk = event.getChunk();
|
||||
Optional<SignCache> optional = this.signManager.getCacheForWorld(chunk.getWorld());
|
||||
if (optional.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final SignCache signCache = optional.get();
|
||||
Collection<RegionSign> chunkSigns = new ArrayList<>(signCache.signsAtChunk(ChunkPosition.getAsLong(chunk.getX(), chunk.getZ())));
|
||||
if(chunkSigns.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Do.forAll(chunkSigns, RegionSign::update);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onIndirectSignBreak(BlockPhysicsEvent event) {
|
||||
// Check if the block is a sign
|
||||
if(!Materials.isSign(event.getBlock().getType()) || behaviourHelper.isBlockValid(event.getBlock())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the sign is really the same as a saved rent
|
||||
final Optional<RegionSign> optionalSign = this.signManager.signFromLocation(event.getBlock().getLocation());
|
||||
if(optionalSign.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RegionSign regionSign = optionalSign.get();
|
||||
|
||||
// Remove the sign so that it does not fall on the floor as an item (next region update will place it back when possible)
|
||||
AreaShop.debug("onIndirectSignBreak: Removed block of sign for", regionSign.getRegion().getName(), "at", regionSign.getStringLocation());
|
||||
event.getBlock().setType(Material.AIR);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onSignBreak(BlockBreakEvent event) {
|
||||
if(event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
Block block = event.getBlock();
|
||||
// Check if it is a sign
|
||||
if(Materials.isSign(block.getType())) {
|
||||
// Check if the rent sign is really the same as a saved rent
|
||||
Optional<RegionSign> optional = signManager.signFromLocation(block.getLocation());
|
||||
if(optional.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RegionSign regionSign = optional.get();
|
||||
// Remove the sign of the rental region if the player has permission
|
||||
if(event.getPlayer().hasPermission("areashop.delsign")) {
|
||||
signManager.removeSign(regionSign);
|
||||
messageBridge.message(event.getPlayer(), "delsign-success", regionSign.getRegion());
|
||||
} else { // Cancel the breaking of the sign
|
||||
event.setCancelled(true);
|
||||
messageBridge.message(event.getPlayer(), "delsign-noPermission", regionSign.getRegion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSignClick(PlayerInteractEvent event) {
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only listen to left and right clicks on blocks
|
||||
if (!(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only care about clicking blocks
|
||||
if(!Materials.isSign(block.getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this sign belongs to a region
|
||||
Optional<RegionSign> optional = signManager.signFromLocation(block.getLocation());
|
||||
if(optional.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RegionSign regionSign = optional.get();
|
||||
|
||||
// Ignore players that are in sign link mode (which will handle the event itself)
|
||||
Player player = event.getPlayer();
|
||||
if(signLinkerManager.isInSignLinkMode(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the clicktype
|
||||
GeneralRegion.ClickType clickType = null;
|
||||
if(player.isSneaking() && event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
clickType = GeneralRegion.ClickType.SHIFTLEFTCLICK;
|
||||
} else if(!player.isSneaking() && event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
clickType = GeneralRegion.ClickType.LEFTCLICK;
|
||||
} else if(player.isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
clickType = GeneralRegion.ClickType.SHIFTRIGHTCLICK;
|
||||
} else if(!player.isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
clickType = GeneralRegion.ClickType.RIGHTCLICK;
|
||||
}
|
||||
|
||||
boolean ran = regionSign.runSignCommands(player, clickType);
|
||||
|
||||
// Only cancel event if at least one command has been executed
|
||||
event.setCancelled(ran);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if(!plugin.isReady()) {
|
||||
messageBridge.message(player, "general-notReady");
|
||||
return;
|
||||
}
|
||||
// Check if the sign is meant for this plugin
|
||||
if(event.getLine(0).contains(plugin.getConfig().getString("signTags.rent"))) {
|
||||
if(!player.hasPermission("areashop.createrent") && !player.hasPermission("areashop.createrent.member") && !player.hasPermission("areashop.createrent.owner")) {
|
||||
messageBridge.message(player, "setup-noPermissionRent");
|
||||
return;
|
||||
}
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
String fourthLine = event.getLine(3);
|
||||
|
||||
// Get the regionManager for accessing regions
|
||||
RegionManager regionManager = plugin.getRegionManager(event.getPlayer().getWorld());
|
||||
|
||||
// If the secondLine does not contain a name try to find the region by location
|
||||
if(secondLine == null || secondLine.isEmpty()) {
|
||||
Set<ProtectedRegion> regions = worldGuardInterface.getApplicableRegionsSet(event.getBlock().getLocation());
|
||||
if(regions != null) {
|
||||
boolean first = true;
|
||||
ProtectedRegion candidate = null;
|
||||
for(ProtectedRegion pr : regions) {
|
||||
if(first) {
|
||||
candidate = pr;
|
||||
first = false;
|
||||
} else {
|
||||
if(pr.getPriority() > candidate.getPriority()) {
|
||||
candidate = pr;
|
||||
} else if(pr.getParent() != null && pr.getParent().equals(candidate)) {
|
||||
candidate = pr;
|
||||
} else {
|
||||
messageBridge.message(player, "setup-couldNotDetect", candidate.getId(), pr.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(candidate != null) {
|
||||
secondLine = candidate.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean priceSet = fourthLine != null && !fourthLine.isEmpty();
|
||||
boolean durationSet = thirdLine != null && !thirdLine.isEmpty();
|
||||
// check if all the lines are correct
|
||||
if(secondLine == null || secondLine.isEmpty()) {
|
||||
messageBridge.message(player, "setup-noRegion");
|
||||
return;
|
||||
}
|
||||
ProtectedRegion region = regionManager.getRegion(secondLine);
|
||||
if(region == null) {
|
||||
messageBridge.message(player, "cmd-noRegion", secondLine);
|
||||
return;
|
||||
}
|
||||
|
||||
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 == IFileManager.AddResult.ALREADYADDED) {
|
||||
messageBridge.message(player, "setup-alreadyRentSign");
|
||||
} else if(addResult == IFileManager.AddResult.ALREADYADDEDOTHERWORLD) {
|
||||
messageBridge.message(player, "setup-alreadyOtherWorld");
|
||||
} 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");
|
||||
} else {
|
||||
double price = 0.0;
|
||||
if(priceSet) {
|
||||
// Check the fourth line
|
||||
try {
|
||||
price = Double.parseDouble(fourthLine);
|
||||
} catch(NumberFormatException e) {
|
||||
messageBridge.message(player, "setup-wrongPrice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add rent to the FileManager
|
||||
final RentRegion rent = regionFactory.createRentRegion(secondLine, event.getPlayer().getWorld());
|
||||
boolean isMember = worldGuardInterface.containsMember(rent.getRegion(), player.getUniqueId());
|
||||
boolean isOwner = worldGuardInterface.containsOwner(rent.getRegion(), player.getUniqueId());
|
||||
boolean landlord = (!player.hasPermission("areashop.createrent")
|
||||
&& ((player.hasPermission("areashop.createrent.owner") && isOwner)
|
||||
|| (player.hasPermission("areashop.createrent.member") && isMember)));
|
||||
|
||||
if(landlord) {
|
||||
rent.setLandlord(player.getUniqueId(), player.getName());
|
||||
}
|
||||
if(priceSet) {
|
||||
rent.setPrice(price);
|
||||
}
|
||||
if(durationSet) {
|
||||
rent.setDuration(thirdLine);
|
||||
}
|
||||
rent.getSignsFeature().addSign(event.getBlock().getLocation(), event.getBlock().getType(), SignUtils.getSignFacing(event.getBlock()), null);
|
||||
|
||||
AddingRegionEvent addingRegionEvent = plugin.getFileManager().addRegion(rent);
|
||||
if (addingRegionEvent.isCancelled()) {
|
||||
messageBridge.message(player, "general-cancelled", addingRegionEvent.getReason());
|
||||
return;
|
||||
}
|
||||
|
||||
rent.handleSchematicEvent(GeneralRegion.RegionEvent.CREATED);
|
||||
messageBridge.message(player, "setup-rentSuccess", rent);
|
||||
// Update the region after the event has written its lines
|
||||
Do.sync(rent::update);
|
||||
}
|
||||
} else if(event.getLine(0).contains(plugin.getConfig().getString("signTags.buy"))) {
|
||||
// Check for permission
|
||||
if(!player.hasPermission("areashop.createbuy") && !player.hasPermission("areashop.createbuy.member") && !player.hasPermission("areashop.createbuy.owner")) {
|
||||
messageBridge.message(player, "setup-noPermissionBuy");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
|
||||
// Get the regionManager for accessing regions
|
||||
RegionManager regionManager = plugin.getRegionManager(event.getPlayer().getWorld());
|
||||
|
||||
// If the secondLine does not contain a name try to find the region by location
|
||||
if(secondLine == null || secondLine.isEmpty()) {
|
||||
Set<ProtectedRegion> regions = worldGuardInterface.getApplicableRegionsSet(event.getBlock().getLocation());
|
||||
if(regions != null) {
|
||||
boolean first = true;
|
||||
ProtectedRegion candidate = null;
|
||||
for(ProtectedRegion pr : regions) {
|
||||
if(first) {
|
||||
candidate = pr;
|
||||
first = false;
|
||||
} else {
|
||||
if(pr.getPriority() > candidate.getPriority()) {
|
||||
candidate = pr;
|
||||
} else if(pr.getParent() != null && pr.getParent().equals(candidate)) {
|
||||
candidate = pr;
|
||||
} else {
|
||||
messageBridge.message(player, "setup-couldNotDetect", candidate.getId(), pr.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(candidate != null) {
|
||||
secondLine = candidate.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean priceSet = thirdLine != null && !thirdLine.isEmpty();
|
||||
// Check if all the lines are correct
|
||||
if(secondLine == null || secondLine.isEmpty()) {
|
||||
messageBridge.message(player, "setup-noRegion");
|
||||
return;
|
||||
}
|
||||
ProtectedRegion region = regionManager.getRegion(secondLine);
|
||||
if(region == null) {
|
||||
messageBridge.message(player, "cmd-noRegion", secondLine);
|
||||
return;
|
||||
}
|
||||
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 == IFileManager.AddResult.ALREADYADDED) {
|
||||
messageBridge.message(player, "setup-alreadyRentSign");
|
||||
} else if(addResult == IFileManager.AddResult.ALREADYADDEDOTHERWORLD) {
|
||||
messageBridge.message(player, "setup-alreadyOtherWorld");
|
||||
} else if(addResult == IFileManager.AddResult.NOPERMISSION) {
|
||||
messageBridge.message(player, "setup-noPermission", secondLine);
|
||||
} else {
|
||||
double price = 0.0;
|
||||
if(priceSet) {
|
||||
// Check the fourth line
|
||||
try {
|
||||
price = Double.parseDouble(thirdLine);
|
||||
} catch(NumberFormatException e) {
|
||||
messageBridge.message(player, "setup-wrongPrice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add buy to the FileManager
|
||||
final BuyRegion buy = regionFactory.createBuyRegion(secondLine, event.getPlayer().getWorld());
|
||||
boolean isMember = worldGuardInterface.containsMember(buy.getRegion(), player.getUniqueId());
|
||||
boolean isOwner = worldGuardInterface.containsOwner(buy.getRegion(), player.getUniqueId());
|
||||
boolean landlord = (!player.hasPermission("areashop.createbuy")
|
||||
&& ((player.hasPermission("areashop.createbuy.owner") && isOwner)
|
||||
|| (player.hasPermission("areashop.createbuy.member") && isMember)));
|
||||
|
||||
if(landlord) {
|
||||
buy.setLandlord(player.getUniqueId(), player.getName());
|
||||
}
|
||||
if(priceSet) {
|
||||
buy.setPrice(price);
|
||||
}
|
||||
buy.getSignsFeature().addSign(event.getBlock().getLocation(), event.getBlock().getType(), SignUtils.getSignFacing(event.getBlock()), null);
|
||||
|
||||
AddingRegionEvent addingRegionEvent = plugin.getFileManager().addRegion(buy);
|
||||
if (addingRegionEvent.isCancelled()) {
|
||||
messageBridge.message(player, "general-cancelled", addingRegionEvent.getReason());
|
||||
return;
|
||||
}
|
||||
|
||||
buy.handleSchematicEvent(GeneralRegion.RegionEvent.CREATED);
|
||||
messageBridge.message(player, "setup-buySuccess", buy);
|
||||
// Update the region after the event has written its lines
|
||||
Do.sync(buy::update);
|
||||
}
|
||||
} else if(event.getLine(0).contains(plugin.getConfig().getString("signTags.add"))) {
|
||||
// Check for permission
|
||||
if(!player.hasPermission("areashop.addsign")) {
|
||||
messageBridge.message(player, "addsign-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
|
||||
GeneralRegion region;
|
||||
if(secondLine != null && !secondLine.isEmpty()) {
|
||||
// Get region by secondLine of the sign
|
||||
region = fileManager.getRegion(secondLine);
|
||||
if(region == null) {
|
||||
messageBridge.message(player, "addSign-notRegistered", secondLine);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Get region by sign position
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(event.getBlock().getLocation());
|
||||
if(regions.isEmpty()) {
|
||||
messageBridge.message(player, "addsign-noRegions");
|
||||
return;
|
||||
} else if(regions.size() > 1) {
|
||||
messageBridge.message(player, "addsign-couldNotDetectSign", regions.get(0).getName(), regions.get(1).getName());
|
||||
return;
|
||||
}
|
||||
region = regions.get(0);
|
||||
}
|
||||
|
||||
if(thirdLine == null || thirdLine.isEmpty()) {
|
||||
region.getSignsFeature().addSign(event.getBlock().getLocation(), event.getBlock().getType(), SignUtils.getSignFacing(event.getBlock()), null);
|
||||
messageBridge.message(player, "addsign-success", region);
|
||||
} else {
|
||||
region.getSignsFeature().addSign(event.getBlock().getLocation(), event.getBlock().getType(), SignUtils.getSignFacing(event.getBlock()), thirdLine);
|
||||
messageBridge.message(player, "addsign-successProfile", thirdLine, region);
|
||||
}
|
||||
|
||||
// Update the region later because this event will do it first
|
||||
Do.sync(region::update);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package me.wiefferink.areashop.features.signs;
|
||||
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.managers.Manager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class SignManager extends Manager {
|
||||
|
||||
private final Map<World, SignCache> signCacheMap = new HashMap<>();
|
||||
|
||||
public Collection<BlockPosition> allSignLocations() {
|
||||
final Set<BlockPosition> set = new HashSet<>(signCacheMap.size());
|
||||
for (SignCache signCache : signCacheMap.values()) {
|
||||
set.addAll(signCache.allSignLocations());
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public Collection<RegionSign> allSigns() {
|
||||
final Set<RegionSign> signs = new HashSet<>(signCacheMap.size());
|
||||
for (SignCache signCache : signCacheMap.values()) {
|
||||
signs.addAll(signCache.allSigns());
|
||||
}
|
||||
return signs;
|
||||
}
|
||||
|
||||
public SignCache cacheForWorld(World world) {
|
||||
return this.signCacheMap.computeIfAbsent(world, x -> new SignCache());
|
||||
}
|
||||
|
||||
public Optional<SignCache> getCacheForWorld(World world) {
|
||||
return Optional.ofNullable(this.signCacheMap.get(world));
|
||||
}
|
||||
|
||||
public Optional<RegionSign> signFromLocation(Location location) {
|
||||
final World world = location.getWorld();
|
||||
return getCacheForWorld(world)
|
||||
.flatMap(cache -> cache.signAtLocation(BlockPosition.getAsLong(location)));
|
||||
}
|
||||
|
||||
public void addSign(RegionSign regionSign) {
|
||||
Location location = regionSign.getLocation();
|
||||
cacheForWorld(location.getWorld()).addSign(regionSign);
|
||||
}
|
||||
|
||||
public void removeSign(RegionSign regionSign) {
|
||||
Location location = regionSign.getLocation();
|
||||
if (location.getWorld() == null) {
|
||||
return;
|
||||
}
|
||||
cacheForWorld(location.getWorld()).removeSign(regionSign);
|
||||
}
|
||||
|
||||
public Optional<RegionSign> removeSign(Location location) {
|
||||
if (location == null || location.getWorld() == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return removeSign(new BlockPosition(location));
|
||||
}
|
||||
|
||||
public Optional<RegionSign> removeSign(BlockPosition blockPosition) {
|
||||
return getCacheForWorld(blockPosition.getWorld()).flatMap(cache -> cache.removeSign(blockPosition));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all signs connected to this region.
|
||||
* @return true if all signs are updated correctly, false if one or more updates failed
|
||||
*/
|
||||
public boolean update() {
|
||||
boolean result = true;
|
||||
for (SignCache signCache : this.signCacheMap.values()) {
|
||||
for (RegionSign sign : signCache.allSigns()) {
|
||||
result &= sign.update();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any of the signs need periodic updating.
|
||||
* @return true if one or more of the signs need periodic updating, otherwise false
|
||||
*/
|
||||
public boolean needsPeriodicUpdate() {
|
||||
boolean result = false;
|
||||
for (SignCache signCache : this.signCacheMap.values()) {
|
||||
for (RegionSign sign : signCache.allSigns()) {
|
||||
if (result) {
|
||||
break;
|
||||
}
|
||||
if (sign.needsPeriodicUpdate()) {
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public void shutdown() {
|
||||
update();
|
||||
this.signCacheMap.values().forEach(SignCache::clear);
|
||||
this.signCacheMap.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,108 +1,634 @@
|
||||
package me.wiefferink.areashop.features.signs;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import io.github.bakedlibs.dough.blocks.ChunkPosition;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.events.ask.AddingRegionEvent;
|
||||
import me.wiefferink.areashop.features.RegionFeature;
|
||||
import me.wiefferink.areashop.interfaces.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.managers.FileManager;
|
||||
import me.wiefferink.areashop.managers.SignErrorLogger;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Materials;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Sign;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
public class SignsFeature extends RegionFeature {
|
||||
|
||||
private final SignManager internalSignManager = new SignManager();
|
||||
private final SignManager globalSignManager;
|
||||
private final SignFactory signFactory;
|
||||
/**
|
||||
* Constructor.
|
||||
* @param region The region to bind to
|
||||
*/
|
||||
@AssistedInject
|
||||
SignsFeature(@Nonnull AreaShop plugin,
|
||||
@Nonnull SignManager signManager,
|
||||
@Nonnull SignFactory signFactory,
|
||||
@Assisted @Nonnull GeneralRegion region
|
||||
) {
|
||||
super(plugin);
|
||||
this.globalSignManager = signManager;
|
||||
this.signFactory = signFactory;
|
||||
setRegion(region);
|
||||
// Setup current signs
|
||||
ConfigurationSection signSection = region.getConfig().getConfigurationSection("general.signs");
|
||||
if (signSection == null) {
|
||||
return;
|
||||
}
|
||||
for(String signKey : signSection.getKeys(false)) {
|
||||
RegionSign sign = signFactory.createRegionSign(this, signKey);
|
||||
Location location = sign.getLocation();
|
||||
if(location == null) {
|
||||
AreaShop.warn("Sign with key " + signKey + " of region " + region.getName() + " does not have a proper location");
|
||||
continue;
|
||||
}
|
||||
this.globalSignManager.cacheForWorld(location.getWorld()).addSign(sign);
|
||||
this.internalSignManager.addSign(sign);
|
||||
}
|
||||
}
|
||||
public static final SignCache signCache = new SignCache();
|
||||
|
||||
/**
|
||||
* Convert a location to a string to use as map key.
|
||||
* @param location The location to get the key for
|
||||
* @return A string to use in a map for a location
|
||||
*/
|
||||
public static String locationToString(Location location) {
|
||||
return location.getWorld().getName() + ";" + location.getBlockX() + ";" + location.getBlockY() + ";" + location.getBlockZ();
|
||||
}
|
||||
private static final BlockBehaviourHelper behaviourHelper = AreaShop.getInstance().getNMSHelper().behaviourHelper();
|
||||
|
||||
/**
|
||||
* Convert a chunk to a string to use as map key.
|
||||
* @param location The location to get the key for
|
||||
* @return A string to use in a map for a chunk
|
||||
*/
|
||||
public static String chunkToString(Location location) {
|
||||
return location.getWorld().getName() + ";" + (location.getBlockX() >> 4) + ";" + (location.getBlockZ() >> 4);
|
||||
}
|
||||
static {
|
||||
signCache.registerListeners();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
public static void shutdownGlobalState() {
|
||||
signCache.shutdown();
|
||||
}
|
||||
|
||||
}
|
||||
private Map<String, RegionSign> signs;
|
||||
|
||||
public SignManager signManager() {
|
||||
return this.internalSignManager;
|
||||
}
|
||||
public SignsFeature() {
|
||||
|
||||
/**
|
||||
* Add a sign to this region.
|
||||
* @param location The location of the sign
|
||||
* @param signType The type of the sign (WALL_SIGN or SIGN_POST)
|
||||
* @param facing The orientation of the sign
|
||||
* @param profile The profile to use with this sign (null for default)
|
||||
*/
|
||||
public void addSign(Location location, Material signType, BlockFace facing, String profile) {
|
||||
int i = 0;
|
||||
while(getRegion().getConfig().isSet("general.signs." + i)) {
|
||||
i++;
|
||||
}
|
||||
String signPath = "general.signs." + i + ".";
|
||||
getRegion().setSetting(signPath + "location", Utils.locationToConfig(location));
|
||||
getRegion().setSetting(signPath + "facing", facing != null ? facing.name() : null);
|
||||
getRegion().setSetting(signPath + "signType", signType != null ? signType.name() : null);
|
||||
if(profile != null && !profile.isEmpty()) {
|
||||
getRegion().setSetting(signPath + "profile", profile);
|
||||
}
|
||||
// Add to the map
|
||||
RegionSign regionSign = this.signFactory.createRegionSign(this, String.valueOf(i));
|
||||
this.globalSignManager.addSign(regionSign);
|
||||
this.internalSignManager.addSign(regionSign);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param region The region to bind to
|
||||
*/
|
||||
public SignsFeature(GeneralRegion region) {
|
||||
setRegion(region);
|
||||
signs = new HashMap<>();
|
||||
// Setup current signs
|
||||
ConfigurationSection signSection = region.getConfig().getConfigurationSection("general.signs");
|
||||
SignErrorLogger errorLogger = AreaShop.getInstance().getSignErrorLogger();
|
||||
if (signSection != null) {
|
||||
for (String signKey : signSection.getKeys(false)) {
|
||||
RegionSign sign = new RegionSign(this, signKey);
|
||||
Location location = sign.getLocation();
|
||||
if (location == null) {
|
||||
final String message = "Sign with key $1%s of region $2%s does not have a proper location";
|
||||
errorLogger.submitWarning(String.format(message, signKey, region.getName()));
|
||||
continue;
|
||||
}
|
||||
signs.put(sign.getStringLocation(), sign);
|
||||
signCache.addSign(sign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a location to a string to use as map key.
|
||||
*
|
||||
* @param location The location to get the key for
|
||||
* @return A string to use in a map for a location
|
||||
*/
|
||||
public static String locationToString(Location location) {
|
||||
return location.getWorld().getName() + ";" + location.getBlockX() + ";" + location.getBlockY() + ";" + location.getBlockZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a chunk to a string to use as map key.
|
||||
*
|
||||
* @param location The location to get the key for
|
||||
* @return A string to use in a map for a chunk
|
||||
*/
|
||||
public static String chunkToString(Location location) {
|
||||
return location.getWorld().getName() + ";" + (location.getBlockX() >> 4) + ";" + (location.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a chunk to a string to use as map key.
|
||||
* Use a Location argument to prevent chunk loading!
|
||||
*
|
||||
* @param chunk The location to get the key for
|
||||
* @return A string to use in a map for a chunk
|
||||
*/
|
||||
public static String chunkToString(Chunk chunk) {
|
||||
return chunk.getWorld().getName() + ";" + chunk.getX() + ";" + chunk.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a sign by a location.
|
||||
*
|
||||
* @param location The location to get the sign for
|
||||
* @return The RegionSign that is at the location, or null if none
|
||||
*/
|
||||
public static RegionSign getSignByLocation(Location location) {
|
||||
return signCache.getSignByLocation(location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the map with all signs.
|
||||
*
|
||||
* @return Map with all signs: locationString -> RegionSign
|
||||
*/
|
||||
public static Map<String, RegionSign> getAllSigns() {
|
||||
return signCache.getAllSigns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the map with signs by chunk.
|
||||
*
|
||||
* @return Map with signs by chunk: chunkString -> List<RegionSign>
|
||||
*/
|
||||
public static Map<String, List<RegionSign>> getSignsByChunk() {
|
||||
return signCache.getSignsByChunk();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// Deregister signs from the registry
|
||||
if (signs != null) {
|
||||
for (Map.Entry<String, RegionSign> entry : signs.entrySet()) {
|
||||
signCache.removeSign(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSignBreak(BlockBreakEvent event) {
|
||||
Block block = event.getBlock();
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
// Check if it is a sign
|
||||
if (Materials.isSign(block.getType())) {
|
||||
// Check if the rent sign is really the same as a saved rent
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region object is still active!");
|
||||
}
|
||||
// Remove the sign of the rental region if the player has permission
|
||||
if (event.getPlayer().hasPermission("areashop.delsign")) {
|
||||
regionSign.remove();
|
||||
plugin.message(event.getPlayer(), "delsign-success", regionSign.getRegion());
|
||||
} else { // Cancel the breaking of the sign
|
||||
event.setCancelled(true);
|
||||
plugin.message(event.getPlayer(), "delsign-noPermission", regionSign.getRegion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onIndirectSignBreak(BlockPhysicsEvent event) {
|
||||
final Block block = event.getBlock();
|
||||
|
||||
// Check if the sign is really the same as a saved rent
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(event.getBlock().getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
// Check if the block is a sign
|
||||
if (!Materials.isSign(event.getBlock().getType())) {
|
||||
return;
|
||||
}
|
||||
// If the block is in an invalid position then we remove the sign
|
||||
if (!behaviourHelper.isBlockValid(block)) {
|
||||
regionSign.remove();
|
||||
}
|
||||
|
||||
// Remove the sign so that it does not fall on the floor as an item (next region update will place it back when possible)
|
||||
AreaShop.debug("onIndirectSignBreak: Removed block of sign for", regionSign.getRegion().getName(), "at", regionSign.getStringLocation());
|
||||
event.getBlock().setType(Material.AIR);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onSignClick(PlayerInteractEvent event) {
|
||||
Block block = event.getClickedBlock();
|
||||
if (block == null) {
|
||||
return;
|
||||
}
|
||||
// Check if this sign belongs to a region
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
|
||||
// Only listen to left and right clicks on blocks
|
||||
if (!(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Only care about clicking blocks
|
||||
if (!Materials.isSign(block.getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Ignore players that are in sign link mode (which will handle the event itself)
|
||||
Player player = event.getPlayer();
|
||||
if (plugin.getSignlinkerManager().isInSignLinkMode(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the clicktype
|
||||
GeneralRegion.ClickType clickType = null;
|
||||
if (player.isSneaking() && event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
clickType = GeneralRegion.ClickType.SHIFTLEFTCLICK;
|
||||
} else if (!player.isSneaking() && event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
clickType = GeneralRegion.ClickType.LEFTCLICK;
|
||||
} else if (player.isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
clickType = GeneralRegion.ClickType.SHIFTRIGHTCLICK;
|
||||
} else if (!player.isSneaking() && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
clickType = GeneralRegion.ClickType.RIGHTCLICK;
|
||||
}
|
||||
|
||||
boolean ran = regionSign.runSignCommands(player, clickType);
|
||||
|
||||
// Only cancel event if at least one command has been executed
|
||||
event.setCancelled(ran);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(event.getBlock().getLocation());
|
||||
if (regionSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (regionSign.getRegion().invalidated()) {
|
||||
AreaShop.warn("SignsFeature: Sign feature for an invalidated region is still active!");
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
if (!plugin.isReady()) {
|
||||
plugin.message(player, "general-notReady");
|
||||
return;
|
||||
}
|
||||
|
||||
final BlockFace rotation;
|
||||
final BlockData data = event.getBlock().getBlockData();
|
||||
if (data instanceof Sign) {
|
||||
rotation = ((Sign) data).getRotation();
|
||||
} else if (data instanceof WallSign) {
|
||||
rotation = ((WallSign) data).getFacing();
|
||||
} else {
|
||||
rotation = null;
|
||||
}
|
||||
|
||||
final String line0 = event.getLine(0) == null ? "" : event.getLine(0);
|
||||
|
||||
// Check if the sign is meant for this plugin
|
||||
if (line0.contains(plugin.getConfig().getString("signTags.rent"))) {
|
||||
if (!player.hasPermission("areashop.createrent") && !player.hasPermission("areashop.createrent.member") && !player.hasPermission("areashop.createrent.owner")) {
|
||||
plugin.message(player, "setup-noPermissionRent");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
String fourthLine = event.getLine(3);
|
||||
|
||||
// Get the regionManager for accessing regions
|
||||
RegionManager regionManager = plugin.getRegionManager(event.getPlayer().getWorld());
|
||||
|
||||
// If the secondLine does not contain a name try to find the region by location
|
||||
if (secondLine == null || secondLine.isEmpty()) {
|
||||
Set<ProtectedRegion> regions = plugin.getWorldGuardHandler().getApplicableRegionsSet(event.getBlock().getLocation());
|
||||
if (regions != null) {
|
||||
boolean first = true;
|
||||
ProtectedRegion candidate = null;
|
||||
for (ProtectedRegion pr : regions) {
|
||||
if (first) {
|
||||
candidate = pr;
|
||||
first = false;
|
||||
} else {
|
||||
if (pr.getPriority() > candidate.getPriority()) {
|
||||
candidate = pr;
|
||||
} else if (pr.getParent() != null && pr.getParent().equals(candidate)) {
|
||||
candidate = pr;
|
||||
} else {
|
||||
plugin.message(player, "setup-couldNotDetect", candidate.getId(), pr.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (candidate != null) {
|
||||
secondLine = candidate.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean priceSet = fourthLine != null && !fourthLine.isEmpty();
|
||||
boolean durationSet = thirdLine != null && !thirdLine.isEmpty();
|
||||
// check if all the lines are correct
|
||||
if (secondLine == null || secondLine.isEmpty()) {
|
||||
plugin.message(player, "setup-noRegion");
|
||||
return;
|
||||
}
|
||||
ProtectedRegion region = regionManager.getRegion(secondLine);
|
||||
if (region == null) {
|
||||
plugin.message(player, "cmd-noRegion", secondLine);
|
||||
return;
|
||||
}
|
||||
|
||||
FileManager.AddResult addResult = plugin.getFileManager().checkRegionAdd(player, regionManager.getRegion(secondLine), event.getPlayer().getWorld(), GeneralRegion.RegionType.RENT);
|
||||
|
||||
switch (addResult) {
|
||||
case BLACKLISTED:
|
||||
plugin.message(player, "setup-blacklisted", secondLine);
|
||||
break;
|
||||
case ALREADYADDED:
|
||||
plugin.message(player, "setup-alreadyRentSign");
|
||||
break;
|
||||
case ALREADYADDEDOTHERWORLD:
|
||||
plugin.message(player, "setup-alreadyOtherWorld");
|
||||
break;
|
||||
case NOPERMISSION:
|
||||
plugin.message(player, "setup-noPermission", secondLine);
|
||||
break;
|
||||
default:
|
||||
if (thirdLine != null && !thirdLine.isEmpty() && !Utils.checkTimeFormat(thirdLine)) {
|
||||
plugin.message(player, "setup-wrongDuration");
|
||||
break;
|
||||
}
|
||||
double price = 0.0;
|
||||
if (priceSet) {
|
||||
// Check the fourth line
|
||||
try {
|
||||
price = Double.parseDouble(fourthLine);
|
||||
} catch (NumberFormatException e) {
|
||||
plugin.message(player, "setup-wrongPrice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add rent to the FileManager
|
||||
final RentRegion rent = new RentRegion(secondLine, event.getPlayer().getWorld());
|
||||
boolean isMember = plugin.getWorldGuardHandler().containsMember(rent.getRegion(), player.getUniqueId());
|
||||
boolean isOwner = plugin.getWorldGuardHandler().containsOwner(rent.getRegion(), player.getUniqueId());
|
||||
boolean landlord = (!player.hasPermission("areashop.createrent")
|
||||
&& ((player.hasPermission("areashop.createrent.owner") && isOwner)
|
||||
|| (player.hasPermission("areashop.createrent.member") && isMember)));
|
||||
|
||||
if (landlord) {
|
||||
rent.setLandlord(player.getUniqueId(), player.getName());
|
||||
}
|
||||
if (priceSet) {
|
||||
rent.setPrice(price);
|
||||
}
|
||||
if (durationSet) {
|
||||
rent.setDuration(thirdLine);
|
||||
}
|
||||
rent.getSignsFeature().addSign(event.getBlock().getLocation(), event.getBlock().getType(), rotation, null);
|
||||
|
||||
AddingRegionEvent addingRegionEvent = plugin.getFileManager().addRegion(rent);
|
||||
if (addingRegionEvent.isCancelled()) {
|
||||
plugin.message(player, "general-cancelled", addingRegionEvent.getReason());
|
||||
return;
|
||||
}
|
||||
|
||||
rent.handleSchematicEvent(GeneralRegion.RegionEvent.CREATED);
|
||||
plugin.message(player, "setup-rentSuccess", rent);
|
||||
// Update the region after the event has written its lines
|
||||
Bukkit.getScheduler().runTask(plugin, rent::update);
|
||||
|
||||
}
|
||||
} else if (line0.contains(plugin.getConfig().getString("signTags.buy"))) {
|
||||
// Check for permission
|
||||
if (!player.hasPermission("areashop.createbuy") && !player.hasPermission("areashop.createbuy.member") && !player.hasPermission("areashop.createbuy.owner")) {
|
||||
plugin.message(player, "setup-noPermissionBuy");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
|
||||
// Get the regionManager for accessing regions
|
||||
RegionManager regionManager = plugin.getRegionManager(event.getPlayer().getWorld());
|
||||
|
||||
// If the secondLine does not contain a name try to find the region by location
|
||||
if (secondLine == null || secondLine.isEmpty()) {
|
||||
Set<ProtectedRegion> regions = plugin.getWorldGuardHandler().getApplicableRegionsSet(event.getBlock().getLocation());
|
||||
if (regions != null) {
|
||||
boolean first = true;
|
||||
ProtectedRegion candidate = null;
|
||||
for (ProtectedRegion pr : regions) {
|
||||
if (first) {
|
||||
candidate = pr;
|
||||
first = false;
|
||||
} else {
|
||||
if (pr.getPriority() > candidate.getPriority()) {
|
||||
candidate = pr;
|
||||
} else if (pr.getParent() != null && pr.getParent().equals(candidate)) {
|
||||
candidate = pr;
|
||||
} else {
|
||||
plugin.message(player, "setup-couldNotDetect", candidate.getId(), pr.getId());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (candidate != null) {
|
||||
secondLine = candidate.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean priceSet = thirdLine != null && !thirdLine.isEmpty();
|
||||
// Check if all the lines are correct
|
||||
if (secondLine == null || secondLine.isEmpty()) {
|
||||
plugin.message(player, "setup-noRegion");
|
||||
return;
|
||||
}
|
||||
ProtectedRegion region = regionManager.getRegion(secondLine);
|
||||
if (region == null) {
|
||||
plugin.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) {
|
||||
plugin.message(player, "setup-blacklisted", secondLine);
|
||||
} else if (addResult == FileManager.AddResult.ALREADYADDED) {
|
||||
plugin.message(player, "setup-alreadyRentSign");
|
||||
} else if (addResult == FileManager.AddResult.ALREADYADDEDOTHERWORLD) {
|
||||
plugin.message(player, "setup-alreadyOtherWorld");
|
||||
} else if (addResult == FileManager.AddResult.NOPERMISSION) {
|
||||
plugin.message(player, "setup-noPermission", secondLine);
|
||||
} else {
|
||||
double price = 0.0;
|
||||
if (priceSet) {
|
||||
// Check the fourth line
|
||||
try {
|
||||
price = Double.parseDouble(thirdLine);
|
||||
} catch (NumberFormatException e) {
|
||||
plugin.message(player, "setup-wrongPrice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Add buy to the FileManager
|
||||
final BuyRegion buy = new BuyRegion(secondLine, event.getPlayer().getWorld());
|
||||
boolean isMember = plugin.getWorldGuardHandler().containsMember(buy.getRegion(), player.getUniqueId());
|
||||
boolean isOwner = plugin.getWorldGuardHandler().containsOwner(buy.getRegion(), player.getUniqueId());
|
||||
boolean landlord = (!player.hasPermission("areashop.createbuy")
|
||||
&& ((player.hasPermission("areashop.createbuy.owner") && isOwner)
|
||||
|| (player.hasPermission("areashop.createbuy.member") && isMember)));
|
||||
|
||||
if (landlord) {
|
||||
buy.setLandlord(player.getUniqueId(), player.getName());
|
||||
}
|
||||
if (priceSet) {
|
||||
buy.setPrice(price);
|
||||
}
|
||||
buy.getSignsFeature().addSign(event.getBlock().getLocation(), event.getBlock().getType(), rotation, null);
|
||||
|
||||
AddingRegionEvent addingRegionEvent = plugin.getFileManager().addRegion(buy);
|
||||
if (addingRegionEvent.isCancelled()) {
|
||||
plugin.message(player, "general-cancelled", addingRegionEvent.getReason());
|
||||
return;
|
||||
}
|
||||
|
||||
buy.handleSchematicEvent(GeneralRegion.RegionEvent.CREATED);
|
||||
plugin.message(player, "setup-buySuccess", buy);
|
||||
// Update the region after the event has written its lines
|
||||
Bukkit.getScheduler().runTask(plugin, buy::update);
|
||||
}
|
||||
} else if (event.getLine(0).contains(plugin.getConfig().getString("signTags.add"))) {
|
||||
// Check for permission
|
||||
if (!player.hasPermission("areashop.addsign")) {
|
||||
plugin.message(player, "addsign-noPermission");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the other lines
|
||||
String secondLine = event.getLine(1);
|
||||
String thirdLine = event.getLine(2);
|
||||
|
||||
GeneralRegion region;
|
||||
if (secondLine != null && !secondLine.isEmpty()) {
|
||||
// Get region by secondLine of the sign
|
||||
region = plugin.getFileManager().getRegion(secondLine);
|
||||
if (region == null) {
|
||||
plugin.message(player, "addSign-notRegistered", secondLine);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Get region by sign position
|
||||
List<GeneralRegion> regions = Utils.getImportantRegions(event.getBlock().getLocation());
|
||||
if (regions.isEmpty()) {
|
||||
plugin.message(player, "addsign-noRegions");
|
||||
return;
|
||||
} else if (regions.size() > 1) {
|
||||
plugin.message(player, "addsign-couldNotDetectSign", regions.get(0).getName(), regions.get(1).getName());
|
||||
return;
|
||||
}
|
||||
region = regions.get(0);
|
||||
}
|
||||
String profile = thirdLine == null || thirdLine.isEmpty() ? null : thirdLine;
|
||||
region.getSignsFeature().addSign(event.getBlock().getLocation(), event.getBlock().getType(), rotation, profile);
|
||||
if (profile == null) {
|
||||
plugin.message(player, "addsign-success", region);
|
||||
} else {
|
||||
plugin.message(player, "addsign-successProfile", thirdLine, region);
|
||||
}
|
||||
|
||||
// Update the region later because this event will do it first
|
||||
Bukkit.getScheduler().runTask(plugin, region::update);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all signs connected to this region.
|
||||
*
|
||||
* @return true if all signs are updated correctly, false if one or more updates failed
|
||||
*/
|
||||
public boolean update() {
|
||||
boolean result = true;
|
||||
for (RegionSign sign : signs.values()) {
|
||||
result &= sign.update();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if any of the signs need periodic updating.
|
||||
*
|
||||
* @return true if one or more of the signs need periodic updating, otherwise false
|
||||
*/
|
||||
public boolean needsPeriodicUpdate() {
|
||||
for (RegionSign sign : signs.values()) {
|
||||
if (sign.needsPeriodicUpdate()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the signs of this region.
|
||||
*
|
||||
* @return List of signs
|
||||
*/
|
||||
public List<RegionSign> getSigns() {
|
||||
return new ArrayList<>(signs.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the signs of this region.
|
||||
*
|
||||
* @return Map with signs: locationString -> RegionSign
|
||||
*/
|
||||
Map<String, RegionSign> getSignsRef() {
|
||||
return signs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list with all sign locations.
|
||||
*
|
||||
* @return A List with all sign locations
|
||||
*/
|
||||
public List<Location> getSignLocations() {
|
||||
List<Location> result = new ArrayList<>(signs.size());
|
||||
for (RegionSign sign : signs.values()) {
|
||||
result.add(sign.getLocation());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a sign to this region.
|
||||
*
|
||||
* @param location The location of the sign
|
||||
* @param signType The type of the sign (WALL_SIGN or SIGN_POST)
|
||||
* @param facing The orientation of the sign
|
||||
* @param profile The profile to use with this sign (null for default)
|
||||
*/
|
||||
public void addSign(Location location, Material signType, BlockFace facing, String profile) {
|
||||
int i = 0;
|
||||
final YamlConfiguration configuration = getRegion().getConfig();
|
||||
while (configuration.isSet("general.signs." + i)) {
|
||||
i++;
|
||||
}
|
||||
String signPath = "general.signs." + i + ".";
|
||||
getRegion().setSetting(signPath + "location", Utils.locationToConfig(location));
|
||||
getRegion().setSetting(signPath + "facing", facing != null ? facing.name() : null);
|
||||
getRegion().setSetting(signPath + "signType", signType != null ? signType.name() : null);
|
||||
if (profile != null && !profile.isEmpty()) {
|
||||
getRegion().setSetting(signPath + "profile", profile);
|
||||
}
|
||||
// Add to the map
|
||||
RegionSign sign = new RegionSign(this, i + "");
|
||||
signs.put(sign.getStringLocation(), sign);
|
||||
signCache.addSign(sign);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package me.wiefferink.areashop.features.signs;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.regions.RegionFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class SignsModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(SignManager.class).asEagerSingleton();
|
||||
install(new FactoryModuleBuilder().build(SignFactory.class));
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SignListener provideSignListener(@Nonnull AreaShop plugin,
|
||||
@Nonnull BlockBehaviourHelper behaviourHelper,
|
||||
@Nonnull RegionFactory regionFactory,
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull SignLinkerManager signLinkerManager,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nonnull SignManager signManager,
|
||||
@Nonnull IFileManager fileManager
|
||||
) {
|
||||
final SignListener signListener = new SignListener(
|
||||
plugin,
|
||||
behaviourHelper,
|
||||
regionFactory,
|
||||
messageBridge,
|
||||
signLinkerManager,
|
||||
worldGuardInterface,
|
||||
signManager,
|
||||
fileManager
|
||||
);
|
||||
plugin.getServer().getPluginManager().registerEvents(signListener, plugin);
|
||||
return signListener;
|
||||
}
|
||||
|
||||
}
|
||||
+94
-103
@@ -1,12 +1,10 @@
|
||||
package me.wiefferink.areashop.listeners;
|
||||
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.regions.BuyRegion;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.regions.RentRegion;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import me.wiefferink.bukkitdo.Do;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -16,7 +14,6 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -24,115 +21,109 @@ import java.util.List;
|
||||
* Notify region expiry and track activity time.
|
||||
*/
|
||||
public final class PlayerLoginLogoutListener implements Listener {
|
||||
private final AreaShop plugin;
|
||||
|
||||
private final AreaShop plugin;
|
||||
private final MessageBridge messageBridge;
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param plugin The AreaShop plugin
|
||||
*/
|
||||
public PlayerLoginLogoutListener(AreaShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param plugin The AreaShop plugin
|
||||
*/
|
||||
public PlayerLoginLogoutListener(@Nonnull AreaShop plugin, @Nonnull MessageBridge messageBridge) {
|
||||
this.plugin = plugin;
|
||||
this.messageBridge = messageBridge;
|
||||
}
|
||||
/**
|
||||
* Called when a sign is changed.
|
||||
*
|
||||
* @param event The event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if (event.getResult() != Result.ALLOWED) {
|
||||
return;
|
||||
}
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
/**
|
||||
* Called when a sign is changed.
|
||||
* @param event The event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if(event.getResult() != Result.ALLOWED) {
|
||||
return;
|
||||
}
|
||||
final Player player = event.getPlayer();
|
||||
// Schedule task to check for notifications, prevents a lag spike at login
|
||||
Utils.runCancellingTaskTimer(() -> {
|
||||
// Delay until all regions are loaded
|
||||
if (!plugin.isReady()) {
|
||||
return true;
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
return false;
|
||||
}
|
||||
// Notify for rents that almost run out
|
||||
for (RentRegion region : plugin.getFileManager().getRents()) {
|
||||
if (region.isRenter(player)) {
|
||||
String warningSetting = region.getStringSetting("rent.warningOnLoginTime");
|
||||
if (warningSetting == null || warningSetting.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
long warningTime = Utils.durationStringToLong(warningSetting);
|
||||
if (region.getTimeLeft() < warningTime) {
|
||||
// Send the warning message later to let it appear after general MOTD messages
|
||||
AreaShop.getInstance().message(player, "rent-expireWarning", region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule task to check for notifications, prevents a lag spike at login
|
||||
Do.syncTimerLater(25, 25, () -> {
|
||||
// Delay until all regions are loaded
|
||||
if(!plugin.isReady()) {
|
||||
return true;
|
||||
}
|
||||
if(!player.isOnline()) {
|
||||
return false;
|
||||
}
|
||||
// Notify for rents that almost run out
|
||||
for(RentRegion region : plugin.getFileManager().getRentsRef()) {
|
||||
if(region.isRenter(player)) {
|
||||
String warningSetting = region.getStringSetting("rent.warningOnLoginTime");
|
||||
if(warningSetting == null || warningSetting.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
long warningTime = Utils.durationStringToLong(warningSetting);
|
||||
if(region.getTimeLeft() < warningTime) {
|
||||
// Send the warning message later to let it appear after general MOTD messages
|
||||
messageBridge.message(player, "rent-expireWarning", region);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Notify admins for plugin updates
|
||||
AreaShop.getInstance().notifyUpdate(player);
|
||||
return false;
|
||||
}, 25, 25, false);
|
||||
|
||||
// Notify admins for plugin updates
|
||||
this.plugin.notifyUpdate(player);
|
||||
return false;
|
||||
});
|
||||
// Check if the player has regions that use an old name of him and update them
|
||||
Utils.runCancellingTaskTimer(() -> {
|
||||
if (!plugin.isReady()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the player has regions that use an old name of him and update them
|
||||
Do.syncTimerLater(22, 10, () -> {
|
||||
if(!plugin.isReady()) {
|
||||
return true;
|
||||
}
|
||||
List<GeneralRegion> regions = new ArrayList<>();
|
||||
for (GeneralRegion region : plugin.getFileManager().getRegions()) {
|
||||
if (region.isOwner(player)) {
|
||||
regions.add(region);
|
||||
}
|
||||
}
|
||||
final String name = player.getName();
|
||||
Utils.runAsBatches(regions,
|
||||
plugin.getConfig().getInt("nameupdate.regionsPerTick"),
|
||||
(region) -> {
|
||||
if (region instanceof BuyRegion || region instanceof RentRegion) {
|
||||
String key = region instanceof BuyRegion ? "buy.buyerName" : "rent.renterName";
|
||||
if (!name.equals(region.getStringSetting("buy.buyerName"))) {
|
||||
region.setSetting(key, player.getName());
|
||||
region.update();
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
return false;
|
||||
}, 22, 10, false);
|
||||
}
|
||||
|
||||
List<GeneralRegion> regions = new ArrayList<>();
|
||||
for(GeneralRegion region : plugin.getFileManager().getRegionsRef()) {
|
||||
if(region.isOwner(player)) {
|
||||
regions.add(region);
|
||||
}
|
||||
}
|
||||
// Active time updates
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLogout(PlayerQuitEvent event) {
|
||||
updateLastActive(event.getPlayer());
|
||||
}
|
||||
|
||||
Do.forAll(
|
||||
plugin.getConfig().getInt("nameupdate.regionsPerTick"),
|
||||
regions,
|
||||
region -> {
|
||||
if(region instanceof BuyRegion) {
|
||||
if(!player.getName().equals(region.getStringSetting("buy.buyerName"))) {
|
||||
region.setSetting("buy.buyerName", player.getName());
|
||||
region.update();
|
||||
}
|
||||
} else if(region instanceof RentRegion) {
|
||||
if(!player.getName().equals(region.getStringSetting("rent.renterName"))) {
|
||||
region.setSetting("rent.renterName", player.getName());
|
||||
region.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
updateLastActive(event.getPlayer());
|
||||
}
|
||||
|
||||
// Active time updates
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLogout(PlayerQuitEvent event) {
|
||||
updateLastActive(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
updateLastActive(event.getPlayer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the last active time for all regions the player is owner off.
|
||||
* @param player The player to update the active times for
|
||||
*/
|
||||
private void updateLastActive(Player player) {
|
||||
for(GeneralRegion region : plugin.getFileManager().getRegionsRef()) {
|
||||
if(region.isOwner(player)) {
|
||||
region.updateLastActiveTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Update the last active time for all regions the player is owner off.
|
||||
*
|
||||
* @param player The player to update the active times for
|
||||
*/
|
||||
private void updateLastActive(Player player) {
|
||||
for (GeneralRegion region : plugin.getFileManager().getRegions()) {
|
||||
if (region.isOwner(player)) {
|
||||
region.updateLastActiveTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
package me.wiefferink.areashop.managers;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.commands.AddCommand;
|
||||
import me.wiefferink.areashop.commands.AddfriendCommand;
|
||||
import me.wiefferink.areashop.commands.AddsignCommand;
|
||||
@@ -29,7 +24,6 @@ import me.wiefferink.areashop.commands.RentCommand;
|
||||
import me.wiefferink.areashop.commands.ResellCommand;
|
||||
import me.wiefferink.areashop.commands.SchematiceventCommand;
|
||||
import me.wiefferink.areashop.commands.SellCommand;
|
||||
import me.wiefferink.areashop.commands.SetTransferCommand;
|
||||
import me.wiefferink.areashop.commands.SetdurationCommand;
|
||||
import me.wiefferink.areashop.commands.SetlandlordCommand;
|
||||
import me.wiefferink.areashop.commands.SetownerCommand;
|
||||
@@ -39,73 +33,55 @@ import me.wiefferink.areashop.commands.SetteleportCommand;
|
||||
import me.wiefferink.areashop.commands.StackCommand;
|
||||
import me.wiefferink.areashop.commands.StopresellCommand;
|
||||
import me.wiefferink.areashop.commands.TeleportCommand;
|
||||
import me.wiefferink.areashop.commands.TransferCommand;
|
||||
import me.wiefferink.areashop.commands.UnrentCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.command.*;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import java.util.*;
|
||||
|
||||
@Singleton
|
||||
public class CommandManager extends Manager implements CommandExecutor, TabCompleter {
|
||||
private final List<CommandAreaShop> commands;
|
||||
private final AreaShop plugin;
|
||||
private final MessageBridge messageBridge;
|
||||
public class CommandManager extends Manager implements TabExecutor {
|
||||
private final ArrayList<CommandAreaShop> commands;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@Inject
|
||||
CommandManager(@Nonnull AreaShop plugin, @Nonnull MessageBridge messageBridge, @Nonnull
|
||||
Injector injector) {
|
||||
this.plugin = plugin;
|
||||
this.messageBridge = messageBridge;
|
||||
commands = new ArrayList<>(34);
|
||||
commands.add(new HelpCommand(this));
|
||||
commands.add(injector.getInstance(RentCommand.class));
|
||||
commands.add(injector.getInstance(UnrentCommand.class));
|
||||
commands.add(injector.getInstance(BuyCommand.class));
|
||||
commands.add(injector.getInstance(SellCommand.class));
|
||||
commands.add(injector.getInstance(TransferCommand.class));
|
||||
commands.add(injector.getInstance(MeCommand.class));
|
||||
commands.add(injector.getInstance(InfoCommand.class));
|
||||
commands.add(injector.getInstance(TeleportCommand.class));
|
||||
commands.add(injector.getInstance(SetteleportCommand.class));
|
||||
commands.add(injector.getInstance(AddfriendCommand.class));
|
||||
commands.add(injector.getInstance(DelfriendCommand.class));
|
||||
commands.add(injector.getInstance(FindCommand.class));
|
||||
commands.add(injector.getInstance(ResellCommand.class));
|
||||
commands.add(injector.getInstance(StopresellCommand.class));
|
||||
commands.add(injector.getInstance(SetrestoreCommand.class));
|
||||
commands.add(injector.getInstance(SetpriceCommand.class));
|
||||
commands.add(injector.getInstance(SetownerCommand.class));
|
||||
commands.add(injector.getInstance(SetdurationCommand.class));
|
||||
commands.add(injector.getInstance(SetTransferCommand.class));
|
||||
commands.add(injector.getInstance(ReloadCommand.class));
|
||||
commands.add(injector.getInstance(GroupaddCommand.class));
|
||||
commands.add(injector.getInstance(GroupdelCommand.class));
|
||||
commands.add(injector.getInstance(GrouplistCommand.class));
|
||||
commands.add(injector.getInstance(GroupinfoCommand.class));
|
||||
commands.add(injector.getInstance(SchematiceventCommand.class));
|
||||
commands.add(injector.getInstance(AddCommand.class));
|
||||
commands.add(injector.getInstance(DelCommand.class));
|
||||
commands.add(injector.getInstance(AddsignCommand.class));
|
||||
commands.add(injector.getInstance(DelsignCommand.class));
|
||||
commands.add(injector.getInstance(LinksignsCommand.class));
|
||||
commands.add(injector.getInstance(StackCommand.class));
|
||||
commands.add(injector.getInstance(SetlandlordCommand.class));
|
||||
commands.add(injector.getInstance(MessageCommand.class));
|
||||
commands.add(injector.getInstance(ImportCommand.class));
|
||||
public CommandManager() {
|
||||
commands = new ArrayList<>();
|
||||
commands.add(new HelpCommand());
|
||||
commands.add(new RentCommand());
|
||||
commands.add(new UnrentCommand());
|
||||
commands.add(new BuyCommand());
|
||||
commands.add(new SellCommand());
|
||||
commands.add(new MeCommand());
|
||||
commands.add(new InfoCommand());
|
||||
commands.add(new TeleportCommand());
|
||||
commands.add(new SetteleportCommand());
|
||||
commands.add(new AddfriendCommand());
|
||||
commands.add(new DelfriendCommand());
|
||||
commands.add(new FindCommand());
|
||||
commands.add(new ResellCommand());
|
||||
commands.add(new StopresellCommand());
|
||||
commands.add(new SetrestoreCommand());
|
||||
commands.add(new SetpriceCommand());
|
||||
commands.add(new SetownerCommand());
|
||||
commands.add(new SetdurationCommand());
|
||||
commands.add(new ReloadCommand());
|
||||
commands.add(new GroupaddCommand());
|
||||
commands.add(new GroupdelCommand());
|
||||
commands.add(new GrouplistCommand());
|
||||
commands.add(new GroupinfoCommand());
|
||||
commands.add(new SchematiceventCommand());
|
||||
commands.add(new AddCommand());
|
||||
commands.add(new DelCommand());
|
||||
commands.add(new AddsignCommand());
|
||||
commands.add(new DelsignCommand());
|
||||
commands.add(new LinksignsCommand());
|
||||
commands.add(new StackCommand());
|
||||
commands.add(new SetlandlordCommand());
|
||||
commands.add(new MessageCommand());
|
||||
commands.add(new ImportCommand());
|
||||
|
||||
// Register commands in bukkit
|
||||
plugin.getCommand("AreaShop").setExecutor(this);
|
||||
plugin.getCommand("AreaShop").setTabCompleter(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,13 +98,13 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
||||
*/
|
||||
public void showHelp(CommandSender target) {
|
||||
if(!target.hasPermission("areashop.help")) {
|
||||
messageBridge.message(target, "help-noPermission");
|
||||
plugin.message(target, "help-noPermission");
|
||||
return;
|
||||
}
|
||||
// Add all messages to a list
|
||||
ArrayList<String> messages = new ArrayList<>();
|
||||
messageBridge.message(target, "help-header");
|
||||
messageBridge.message(target, "help-alias");
|
||||
plugin.message(target, "help-header");
|
||||
plugin.message(target, "help-alias");
|
||||
for(CommandAreaShop command : commands) {
|
||||
String help = command.getHelp(target);
|
||||
if(help != null && !help.isEmpty()) {
|
||||
@@ -137,14 +113,14 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
||||
}
|
||||
// Send the messages to the target
|
||||
for(String message : messages) {
|
||||
messageBridge.messageNoPrefix(target, message);
|
||||
plugin.messageNoPrefix(target, message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if(!plugin.isReady()) {
|
||||
messageBridge.message(sender, "general-notReady");
|
||||
plugin.message(sender, "general-notReady");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -170,9 +146,9 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
||||
} else {
|
||||
// Indicate that the '/as updaterents' and '/as updatebuys' commands are removed
|
||||
if("updaterents".equalsIgnoreCase(args[0]) || "updatebuys".equalsIgnoreCase(args[0])) {
|
||||
messageBridge.message(sender, "reload-updateCommandChanged");
|
||||
plugin.message(sender, "reload-updateCommandChanged");
|
||||
} else {
|
||||
messageBridge.message(sender, "cmd-notValid");
|
||||
plugin.message(sender, "cmd-notValid");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -182,10 +158,10 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
if(!sender.hasPermission("areashop.tabcomplete")) {
|
||||
return result;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> result = new ArrayList<>();
|
||||
int toCompleteNumber = args.length;
|
||||
String toCompletePrefix = args[args.length - 1].toLowerCase();
|
||||
//AreaShop.debug("toCompleteNumber=" + toCompleteNumber + ", toCompletePrefix=" + toCompletePrefix + ", length=" + toCompletePrefix.length());
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
package me.wiefferink.areashop.managers;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.ProvisionException;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.features.CommandsFeature;
|
||||
import me.wiefferink.areashop.features.DebugFeature;
|
||||
import me.wiefferink.areashop.features.FeatureFactory;
|
||||
import me.wiefferink.areashop.features.FriendsFeature;
|
||||
import me.wiefferink.areashop.features.RegionFeature;
|
||||
import me.wiefferink.areashop.features.TeleportFeature;
|
||||
@@ -15,65 +10,57 @@ import me.wiefferink.areashop.features.WorldGuardRegionFlagsFeature;
|
||||
import me.wiefferink.areashop.features.signs.SignsFeature;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Singleton
|
||||
public class FeatureManager extends Manager {
|
||||
|
||||
private static final Collection<Class<? extends RegionFeature>> globalFeatureClasses = Arrays.asList(
|
||||
CommandsFeature.class,
|
||||
// List of defined features
|
||||
private static final Set<Class<? extends RegionFeature>> featureClasses = new HashSet<>(Arrays.asList(
|
||||
DebugFeature.class,
|
||||
SignsFeature.class,
|
||||
FriendsFeature.class,
|
||||
WorldGuardRegionFlagsFeature.class,
|
||||
DebugFeature.class
|
||||
);
|
||||
TeleportFeature.class,
|
||||
CommandsFeature.class
|
||||
));
|
||||
// One instance of each feature, registered for event handling
|
||||
private final Set<RegionFeature> globalFeatures = new HashSet<>();
|
||||
private final Map<Class<? extends RegionFeature>, Function<GeneralRegion, ? extends RegionFeature>> regionFeatureConstructors = new HashMap<>();
|
||||
private final Set<RegionFeature> globalFeatures;
|
||||
private final Map<Class<? extends RegionFeature>, Constructor<? extends RegionFeature>> regionFeatureConstructors;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@Inject
|
||||
FeatureManager(@Nonnull FeatureFactory featureFactory) {
|
||||
// Setup constructors for region specific features
|
||||
regionFeatureConstructors.put(SignsFeature.class, wrapInstantiator(SignsFeature.class, featureFactory::createSignsFeature));
|
||||
regionFeatureConstructors.put(TeleportFeature.class, wrapInstantiator(TeleportFeature.class, featureFactory::createTeleportFeature));
|
||||
regionFeatureConstructors.put(FriendsFeature.class, wrapInstantiator(FriendsFeature.class, featureFactory::createFriendsFeature));
|
||||
}
|
||||
|
||||
public void initializeFeatures(@Nonnull Injector injector) {
|
||||
public FeatureManager() {
|
||||
// Instantiate and register global features (one per type, for event handling)
|
||||
for(Class<? extends RegionFeature> clazz : globalFeatureClasses) {
|
||||
globalFeatures = new HashSet<>();
|
||||
for(Class<? extends RegionFeature> clazz : featureClasses) {
|
||||
try {
|
||||
RegionFeature feature = injector.getInstance(clazz);
|
||||
Constructor<? extends RegionFeature> constructor = clazz.getConstructor();
|
||||
RegionFeature feature = constructor.newInstance();
|
||||
feature.listen();
|
||||
globalFeatures.add(feature);
|
||||
} catch(ProvisionException e) {
|
||||
} catch(InstantiationException | IllegalAccessException | InvocationTargetException | IllegalArgumentException e) {
|
||||
AreaShop.error("Failed to instantiate global feature:", clazz, e);
|
||||
} catch(NoSuchMethodException e) {
|
||||
// Feature does not have a global part
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends RegionFeature> void registerNonGlobalFeature(@Nonnull Class<T> clazz, @Nonnull Function<GeneralRegion, T> constructor) {
|
||||
this.regionFeatureConstructors.put(clazz, constructor);
|
||||
}
|
||||
|
||||
private <T extends RegionFeature> Function<GeneralRegion, T> wrapInstantiator(Class<T> clazz, Function<GeneralRegion, T> function
|
||||
) {
|
||||
return region -> {
|
||||
// Setup constructors for region specific features
|
||||
regionFeatureConstructors = new HashMap<>();
|
||||
for(Class<? extends RegionFeature> clazz : featureClasses) {
|
||||
try {
|
||||
return function.apply(region);
|
||||
} catch (Throwable e) {
|
||||
AreaShop.error("Failed to instantiate feature", clazz, "for region", region, e, e.getCause());
|
||||
return null;
|
||||
regionFeatureConstructors.put(clazz, clazz.getConstructor(GeneralRegion.class));
|
||||
} catch(NoSuchMethodException | IllegalArgumentException e) {
|
||||
// The feature does not have a region specific part
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -81,6 +68,8 @@ public class FeatureManager extends Manager {
|
||||
for(RegionFeature feature : globalFeatures) {
|
||||
feature.shutdown();
|
||||
}
|
||||
// FIXME make this system less hacky!
|
||||
SignsFeature.shutdownGlobalState();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +79,12 @@ public class FeatureManager extends Manager {
|
||||
* @return The feature class
|
||||
*/
|
||||
public RegionFeature getRegionFeature(GeneralRegion region, Class<? extends RegionFeature> featureClazz) {
|
||||
return regionFeatureConstructors.get(featureClazz).apply(region);
|
||||
try {
|
||||
return regionFeatureConstructors.get(featureClazz).newInstance(region);
|
||||
} catch(InstantiationException | InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
|
||||
AreaShop.error("Failed to instantiate feature", featureClazz, "for region", region, e, e.getCause());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,399 +0,0 @@
|
||||
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 (readonly)
|
||||
*
|
||||
* @return Unmodifiable collection of all rental regions
|
||||
*/
|
||||
Collection<RentRegion> getRentsRef();
|
||||
|
||||
/**
|
||||
* Get all buy regions.
|
||||
*
|
||||
* @return List of all buy regions
|
||||
*/
|
||||
List<BuyRegion> getBuys();
|
||||
|
||||
/**
|
||||
* Get all buy regions (readonly)
|
||||
* @return Unmodifiable collection of all buy regions
|
||||
*/
|
||||
Collection<BuyRegion> getBuysRef();
|
||||
|
||||
/**
|
||||
* Get all regions.
|
||||
*
|
||||
* @return List of all regions (it is safe to modify the list)
|
||||
*/
|
||||
List<GeneralRegion> getRegions();
|
||||
|
||||
/**
|
||||
* Get all regions (readonly)
|
||||
*
|
||||
* @return Unmodifiable collection of all regions
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package me.wiefferink.areashop.managers;
|
||||
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
|
||||
public abstract class Manager {
|
||||
|
||||
final AreaShop plugin = AreaShop.getInstance();
|
||||
|
||||
/**
|
||||
* Called at shutdown of the plugin.
|
||||
*/
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
package me.wiefferink.areashop.managers;
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.features.signs.RegionSign;
|
||||
import me.wiefferink.areashop.features.signs.SignManager;
|
||||
import me.wiefferink.areashop.features.signs.SignsFeature;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import me.wiefferink.areashop.tools.Materials;
|
||||
import me.wiefferink.areashop.tools.SignUtils;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Sign;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -29,23 +27,14 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@Singleton
|
||||
public class SignLinkerManager extends Manager implements Listener {
|
||||
private final Map<UUID, SignLinker> signLinkers;
|
||||
private boolean eventsRegistered;
|
||||
|
||||
@Inject
|
||||
private AreaShop plugin;
|
||||
@Inject
|
||||
private SignManager signManager;
|
||||
@Inject
|
||||
private MessageBridge messageBridge;
|
||||
|
||||
SignLinkerManager() {
|
||||
public SignLinkerManager() {
|
||||
signLinkers = new HashMap<>();
|
||||
eventsRegistered = false;
|
||||
}
|
||||
@@ -64,8 +53,8 @@ public class SignLinkerManager extends Manager implements Listener {
|
||||
*/
|
||||
public void enterSignLinkMode(Player player, String profile) {
|
||||
signLinkers.put(player.getUniqueId(), new SignLinker(player, profile));
|
||||
messageBridge.message(player, "linksigns-first");
|
||||
messageBridge.message(player, "linksigns-next");
|
||||
plugin.message(player, "linksigns-first");
|
||||
plugin.message(player, "linksigns-next");
|
||||
if(!eventsRegistered) {
|
||||
eventsRegistered = true;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
@@ -82,7 +71,7 @@ public class SignLinkerManager extends Manager implements Listener {
|
||||
eventsRegistered = false;
|
||||
HandlerList.unregisterAll(this);
|
||||
}
|
||||
messageBridge.message(player, "linksigns-stopped");
|
||||
plugin.message(player, "linksigns-stopped");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,13 +107,13 @@ public class SignLinkerManager extends Manager implements Listener {
|
||||
for(GeneralRegion region : regions) {
|
||||
names.add(region.getName());
|
||||
}
|
||||
messageBridge.message(player, "linksigns-multipleRegions", Utils.createCommaSeparatedList(names));
|
||||
messageBridge.message(player, "linksigns-multipleRegionsAdvice");
|
||||
plugin.message(player, "linksigns-multipleRegions", Utils.createCommaSeparatedList(names));
|
||||
plugin.message(player, "linksigns-multipleRegionsAdvice");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// No regions found within the maximum range
|
||||
messageBridge.message(player, "linksigns-noRegions");
|
||||
plugin.message(player, "linksigns-noRegions");
|
||||
} else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||
Block block = null;
|
||||
BlockIterator blockIterator = new BlockIterator(player, 100);
|
||||
@@ -135,17 +124,25 @@ public class SignLinkerManager extends Manager implements Listener {
|
||||
}
|
||||
}
|
||||
if(block == null || !Materials.isSign(block.getType())) {
|
||||
messageBridge.message(player, "linksigns-noSign");
|
||||
plugin.message(player, "linksigns-noSign");
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<RegionSign> optional = signManager.signFromLocation(block.getLocation());
|
||||
if(optional.isPresent()) {
|
||||
RegionSign regionSign = optional.get();
|
||||
messageBridge.message(player, "linksigns-alreadyRegistered", regionSign.getRegion());
|
||||
RegionSign regionSign = SignsFeature.getSignByLocation(block.getLocation());
|
||||
if(regionSign != null) {
|
||||
plugin.message(player, "linksigns-alreadyRegistered", regionSign.getRegion());
|
||||
return;
|
||||
}
|
||||
linker.setSign(block.getLocation(), block.getType(), SignUtils.getSignFacing(block));
|
||||
final BlockData blockData = block.getBlockData();
|
||||
final BlockFace rotation;
|
||||
if (blockData instanceof Sign) {
|
||||
rotation = ((Sign) blockData).getRotation();
|
||||
} else if (blockData instanceof WallSign) {
|
||||
rotation = ((WallSign) blockData).getFacing();
|
||||
} else {
|
||||
rotation = null;
|
||||
}
|
||||
linker.setSign(block.getLocation(), block.getType(), rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +181,7 @@ public class SignLinkerManager extends Manager implements Listener {
|
||||
this.region = region;
|
||||
hasRegion = true;
|
||||
if(!isComplete()) {
|
||||
messageBridge.message(linker, "linksigns-regionFound", region);
|
||||
plugin.message(linker, "linksigns-regionFound", region);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
@@ -195,7 +192,7 @@ public class SignLinkerManager extends Manager implements Listener {
|
||||
this.facing = facing;
|
||||
hasSign = true;
|
||||
if(!isComplete()) {
|
||||
messageBridge.message(linker, "linksigns-signFound", location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
plugin.message(linker, "linksigns-signFound", location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
finish();
|
||||
}
|
||||
@@ -204,14 +201,14 @@ public class SignLinkerManager extends Manager implements Listener {
|
||||
if(isComplete()) {
|
||||
region.getSignsFeature().addSign(location, type, facing, profile);
|
||||
if(profile == null) {
|
||||
messageBridge.message(linker, "addsign-success", region);
|
||||
plugin.message(linker, "addsign-success", region);
|
||||
} else {
|
||||
messageBridge.message(linker, "addsign-successProfile", region, profile);
|
||||
plugin.message(linker, "addsign-successProfile", region, profile);
|
||||
}
|
||||
region.update();
|
||||
reset();
|
||||
|
||||
messageBridge.message(linker, "linksigns-next");
|
||||
plugin.message(linker, "linksigns-next");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
package me.wiefferink.areashop.modules;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Singleton;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.areashop.features.FeatureFactory;
|
||||
import me.wiefferink.areashop.features.signs.SignManager;
|
||||
import me.wiefferink.areashop.features.signs.SignsModule;
|
||||
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.FileManager;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.managers.SignErrorLogger;
|
||||
import me.wiefferink.areashop.managers.SignLinkerManager;
|
||||
import me.wiefferink.areashop.platform.adapter.PlatformAdapter;
|
||||
import me.wiefferink.areashop.regions.ImportJobFactory;
|
||||
import me.wiefferink.areashop.regions.RegionModule;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class AreaShopModule extends AbstractModule {
|
||||
|
||||
private final AreaShop instance;
|
||||
private final WorldGuardInterface worldGuardInterface;
|
||||
private final WorldEditInterface worldEditInterface;
|
||||
private final PlatformAdapter platformAdapter;
|
||||
private final MessageBridge messageBridge;
|
||||
private final SignErrorLogger signErrorLogger;
|
||||
private final AbstractModule[] extras;
|
||||
|
||||
public AreaShopModule(@Nonnull AreaShop instance,
|
||||
@Nonnull MessageBridge messageBridge,
|
||||
@Nonnull PlatformAdapter platformAdapter,
|
||||
@Nonnull WorldEditInterface worldEditInterface,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nonnull SignErrorLogger signErrorLogger,
|
||||
@Nonnull AbstractModule... extras
|
||||
) {
|
||||
this.instance = instance;
|
||||
this.messageBridge = messageBridge;
|
||||
this.platformAdapter = platformAdapter;
|
||||
this.signErrorLogger = signErrorLogger;
|
||||
this.worldEditInterface = worldEditInterface;
|
||||
this.worldGuardInterface = worldGuardInterface;
|
||||
this.extras = extras;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Arrays.stream(this.extras).forEach(this::install);
|
||||
bind(Plugin.class).toInstance(this.instance);
|
||||
bind(AreaShop.class).toInstance(this.instance);
|
||||
bind(MessageBridge.class).toInstance(this.messageBridge);
|
||||
bind(WorldGuardInterface.class).toInstance(this.worldGuardInterface);
|
||||
bind(SignManager.class).asEagerSingleton();
|
||||
bind(WorldEditInterface.class).toInstance(this.worldEditInterface);
|
||||
bind(SignErrorLogger.class).toInstance(this.signErrorLogger);
|
||||
// Setup managers
|
||||
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);
|
||||
install(new SignsModule());
|
||||
install(new RegionModule());
|
||||
install(new FactoryModuleBuilder().build(FeatureFactory.class));
|
||||
install(new FactoryModuleBuilder().build(ImportJobFactory.class));
|
||||
requestStaticInjection(Utils.class);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package me.wiefferink.areashop.modules;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.inventory.ItemFactory;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.ServicesManager;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scoreboard.ScoreboardManager;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class BukkitModule extends AbstractModule {
|
||||
|
||||
private final Server server;
|
||||
|
||||
public BukkitModule(@Nonnull Server server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(Server.class).toInstance(this.server);
|
||||
bind(PluginManager.class).toInstance(this.server.getPluginManager());
|
||||
bind(BukkitScheduler.class).toInstance(this.server.getScheduler());
|
||||
bind(PluginManager.class).toInstance(this.server.getPluginManager());
|
||||
bind(ServicesManager.class).toInstance(this.server.getServicesManager());
|
||||
bind(ItemFactory.class).toInstance(this.server.getItemFactory());
|
||||
bind(ConsoleCommandSender.class).toInstance(this.server.getConsoleSender());
|
||||
bind(ScoreboardManager.class).toInstance(this.server.getScoreboardManager());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package me.wiefferink.areashop.modules;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class DependencyModule extends AbstractModule {
|
||||
|
||||
private final WorldEditPlugin worldEditPlugin;
|
||||
private final WorldGuardPlugin worldGuardPlugin;
|
||||
private final Economy economy;
|
||||
private final Permission permission;
|
||||
|
||||
public DependencyModule(@Nonnull WorldEditPlugin worldEditPlugin,
|
||||
@Nonnull WorldGuardPlugin worldGuardPlugin,
|
||||
@Nullable Economy economy,
|
||||
@Nullable Permission permission
|
||||
) {
|
||||
this.worldEditPlugin = worldEditPlugin;
|
||||
this.worldGuardPlugin = worldGuardPlugin;
|
||||
this.economy = economy;
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(WorldEditPlugin.class).toInstance(this.worldEditPlugin);
|
||||
bind(WorldGuardPlugin.class).toInstance(this.worldGuardPlugin);
|
||||
bind(Economy.class).toInstance(this.economy);
|
||||
bind(Permission.class).toInstance(this.permission);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package me.wiefferink.areashop.modules;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import me.wiefferink.areashop.adapters.platform.MinecraftPlatform;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.BlockBehaviourHelper;
|
||||
import me.wiefferink.areashop.platform.adapter.PlatformAdapter;
|
||||
import me.wiefferink.areashop.tools.BukkitSchedulerExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlatformModule extends AbstractModule {
|
||||
|
||||
private final MinecraftPlatform minecraftPlatform;
|
||||
private final PlatformAdapter platformAdapter;
|
||||
|
||||
public PlatformModule(@NotNull MinecraftPlatform platform,
|
||||
@NotNull PlatformAdapter platformAdapter) {
|
||||
this.minecraftPlatform = platform;
|
||||
this.platformAdapter = platformAdapter;
|
||||
}
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(MinecraftPlatform.class).toInstance(this.minecraftPlatform);
|
||||
bind(OfflinePlayerHelper.class).toInstance(this.minecraftPlatform.offlinePlayerHelper());
|
||||
bind(PlatformAdapter.class).toInstance(this.platformAdapter);
|
||||
bind(BlockBehaviourHelper.class).toInstance(this.platformAdapter.blockBehaviourHelper());
|
||||
bind(BukkitSchedulerExecutor.class).asEagerSingleton();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package me.wiefferink.areashop.regions;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.events.ask.BuyingRegionEvent;
|
||||
import me.wiefferink.areashop.events.ask.ResellingRegionEvent;
|
||||
@@ -9,11 +7,7 @@ import me.wiefferink.areashop.events.ask.SellingRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.BoughtRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.ResoldRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.SoldRegionEvent;
|
||||
import me.wiefferink.areashop.interfaces.WorldEditInterface;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.managers.FeatureManager;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -22,55 +16,17 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BuyRegion extends GeneralRegion {
|
||||
|
||||
private final Economy economy;
|
||||
|
||||
@AssistedInject
|
||||
BuyRegion(
|
||||
@Nonnull AreaShop plugin,
|
||||
@Nonnull FeatureManager featureManager,
|
||||
@Nonnull WorldEditInterface worldEditInterface,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nullable Economy economy,
|
||||
@Assisted @Nonnull YamlConfiguration config
|
||||
) {
|
||||
super(plugin, featureManager, worldEditInterface, worldGuardInterface, config);
|
||||
this.economy = economy;
|
||||
public BuyRegion(YamlConfiguration config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
@AssistedInject
|
||||
BuyRegion(
|
||||
@Nonnull AreaShop plugin,
|
||||
@Nonnull FeatureManager featureManager,
|
||||
@Nonnull WorldEditInterface worldEditInterface,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nullable Economy economy,
|
||||
@Assisted @Nonnull String name,
|
||||
@Assisted @Nonnull World world
|
||||
) {
|
||||
super(plugin, featureManager, worldEditInterface, worldGuardInterface, name, world);
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOwner(UUID player) {
|
||||
return isBuyer(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getOwner() {
|
||||
return getBuyer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(UUID player) {
|
||||
setBuyer(player);
|
||||
public BuyRegion(String name, World world) {
|
||||
super(name, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -252,20 +208,31 @@ public class BuyRegion extends GeneralRegion {
|
||||
|
||||
@Override
|
||||
public Object provideReplacement(String variable) {
|
||||
return switch (variable) {
|
||||
case AreaShop.tagPrice -> getFormattedPrice();
|
||||
case AreaShop.tagRawPrice -> getPrice();
|
||||
case AreaShop.tagPlayerName -> getPlayerName();
|
||||
case AreaShop.tagPlayerUUID -> getBuyer();
|
||||
case AreaShop.tagResellPrice -> getFormattedResellPrice();
|
||||
case AreaShop.tagRawResellPrice -> getResellPrice();
|
||||
case AreaShop.tagMoneyBackAmount -> getFormattedMoneyBackAmount();
|
||||
case AreaShop.tagRawMoneyBackAmount -> getMoneyBackAmount();
|
||||
case AreaShop.tagMoneyBackPercentage ->
|
||||
getMoneyBackPercentage() % 1.0 == 0.0 ? (int) getMoneyBackPercentage() : getMoneyBackPercentage();
|
||||
case AreaShop.tagMaxInactiveTime -> this.getFormattedInactiveTimeUntilSell();
|
||||
default -> super.provideReplacement(variable);
|
||||
};
|
||||
switch(variable) {
|
||||
case AreaShop.tagPrice:
|
||||
return getFormattedPrice();
|
||||
case AreaShop.tagRawPrice:
|
||||
return getPrice();
|
||||
case AreaShop.tagPlayerName:
|
||||
return getPlayerName();
|
||||
case AreaShop.tagPlayerUUID:
|
||||
return getBuyer();
|
||||
case AreaShop.tagResellPrice:
|
||||
return getFormattedResellPrice();
|
||||
case AreaShop.tagRawResellPrice:
|
||||
return getResellPrice();
|
||||
case AreaShop.tagMoneyBackAmount:
|
||||
return getFormattedMoneyBackAmount();
|
||||
case AreaShop.tagRawMoneyBackAmount:
|
||||
return getMoneyBackAmount();
|
||||
case AreaShop.tagMoneyBackPercentage:
|
||||
return getMoneyBackPercentage() % 1.0 == 0.0 ? (int)getMoneyBackPercentage() : getMoneyBackPercentage();
|
||||
case AreaShop.tagMaxInactiveTime:
|
||||
return this.getFormattedInactiveTimeUntilSell();
|
||||
|
||||
default:
|
||||
return super.provideReplacement(variable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -297,7 +264,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(economy == null) {
|
||||
if(plugin.getEconomy() == null) {
|
||||
message(offlinePlayer, "general-noEconomy");
|
||||
return false;
|
||||
}
|
||||
@@ -368,12 +335,12 @@ public class BuyRegion extends GeneralRegion {
|
||||
}
|
||||
|
||||
// Check if the player has enough money
|
||||
if (isResell && !economy.has(offlinePlayer, getWorldName(), getResellPrice())) {
|
||||
message(offlinePlayer, "buy-lowMoneyResell", Utils.formatCurrency(economy.getBalance(offlinePlayer, getWorldName())));
|
||||
if (isResell && !plugin.getEconomy().has(offlinePlayer, getWorldName(), getResellPrice())) {
|
||||
message(offlinePlayer, "buy-lowMoneyResell", Utils.formatCurrency(plugin.getEconomy().getBalance(offlinePlayer, getWorldName())));
|
||||
return false;
|
||||
}
|
||||
if (!isResell && !economy.has(offlinePlayer, getWorldName(), getPrice())) {
|
||||
message(offlinePlayer, "buy-lowMoney", Utils.formatCurrency(economy.getBalance(offlinePlayer, getWorldName())));
|
||||
if (!isResell && !plugin.getEconomy().has(offlinePlayer, getWorldName(), getPrice())) {
|
||||
message(offlinePlayer, "buy-lowMoney", Utils.formatCurrency(plugin.getEconomy().getBalance(offlinePlayer, getWorldName())));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -390,7 +357,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
getFriendsFeature().clearFriends();
|
||||
double resellPrice = getResellPrice();
|
||||
// Transfer the money to the previous owner
|
||||
EconomyResponse r = economy.withdrawPlayer(offlinePlayer, getWorldName(), getResellPrice());
|
||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(offlinePlayer, getWorldName(), getResellPrice());
|
||||
if(!r.transactionSuccess()) {
|
||||
message(offlinePlayer, "buy-payError");
|
||||
AreaShop.debug("Something went wrong with getting money from " + offlinePlayer.getName() + " while buying " + getName() + ": " + r.errorMessage);
|
||||
@@ -399,15 +366,17 @@ public class BuyRegion extends GeneralRegion {
|
||||
r = null;
|
||||
OfflinePlayer oldOwnerPlayer = Bukkit.getOfflinePlayer(oldOwner);
|
||||
String oldOwnerName = getPlayerName();
|
||||
if(oldOwnerPlayer != null && oldOwnerPlayer.getName() != null) {
|
||||
r = economy.depositPlayer(oldOwnerPlayer, getWorldName(), getResellPrice());
|
||||
if(oldOwnerPlayer.hasPlayedBefore() && oldOwnerPlayer.getName() != null) {
|
||||
r = plugin.getEconomy().depositPlayer(oldOwnerPlayer, getWorldName(), getResellPrice());
|
||||
oldOwnerName = oldOwnerPlayer.getName();
|
||||
} else if(oldOwnerName != null) {
|
||||
r = economy.depositPlayer(oldOwnerName, getWorldName(), getResellPrice());
|
||||
r = plugin.getEconomy().depositPlayer(oldOwnerName, getWorldName(), getResellPrice());
|
||||
}
|
||||
if(r == null || !r.transactionSuccess()) {
|
||||
AreaShop.warn("Something went wrong with paying '" + oldOwnerName + "' " + getFormattedPrice() + " for his resell of region " + getName() + " to " + offlinePlayer.getName());
|
||||
}
|
||||
// Resell is done, disable that now
|
||||
disableReselling();
|
||||
|
||||
// Set the owner
|
||||
setBuyer(offlinePlayer.getUniqueId());
|
||||
@@ -419,9 +388,6 @@ public class BuyRegion extends GeneralRegion {
|
||||
// Notify about updates
|
||||
this.notifyAndUpdate(new ResoldRegionEvent(this, oldOwner));
|
||||
|
||||
// Resell is done, disable that now
|
||||
disableReselling();
|
||||
|
||||
// Send message to the player
|
||||
message(offlinePlayer, "buy-successResale", oldOwnerName);
|
||||
Player seller = Bukkit.getPlayer(oldOwner);
|
||||
@@ -438,7 +404,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
}
|
||||
|
||||
// Substract the money from the players balance
|
||||
EconomyResponse r = economy.withdrawPlayer(offlinePlayer, getWorldName(), getPrice());
|
||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(offlinePlayer, getWorldName(), getPrice());
|
||||
if(!r.transactionSuccess()) {
|
||||
message(offlinePlayer, "buy-payError");
|
||||
return false;
|
||||
@@ -451,9 +417,9 @@ public class BuyRegion extends GeneralRegion {
|
||||
String landlordName = getLandlordName();
|
||||
if(landlordName != null) {
|
||||
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
||||
r = economy.depositPlayer(landlordPlayer, getWorldName(), getPrice());
|
||||
r = plugin.getEconomy().depositPlayer(landlordPlayer, getWorldName(), getPrice());
|
||||
} else {
|
||||
r = economy.depositPlayer(landlordName, getWorldName(), getPrice());
|
||||
r = plugin.getEconomy().depositPlayer(landlordName, getWorldName(), getPrice());
|
||||
}
|
||||
if(r != null && !r.transactionSuccess()) {
|
||||
AreaShop.warn("Something went wrong with paying '" + landlordName + "' " + getFormattedPrice() + " for his sell of region " + getName() + " to " + offlinePlayer.getName());
|
||||
@@ -484,7 +450,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean sell(boolean giveMoneyBack, CommandSender executor) {
|
||||
boolean own = executor instanceof Player player && this.isBuyer(player);
|
||||
boolean own = executor instanceof Player && this.isBuyer((Player)executor);
|
||||
if(executor != null) {
|
||||
if(!executor.hasPermission("areashop.sell") && !own) {
|
||||
message(executor, "sell-noPermissionOther");
|
||||
@@ -503,7 +469,7 @@ public class BuyRegion extends GeneralRegion {
|
||||
}
|
||||
}
|
||||
|
||||
if(economy == null) {
|
||||
if(plugin.getEconomy() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -528,9 +494,9 @@ public class BuyRegion extends GeneralRegion {
|
||||
EconomyResponse r;
|
||||
if(landlordName != null) {
|
||||
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
||||
r = economy.withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
|
||||
r = plugin.getEconomy().withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
|
||||
} else {
|
||||
r = economy.withdrawPlayer(landlordName, getWorldName(), moneyBack);
|
||||
r = plugin.getEconomy().withdrawPlayer(landlordName, getWorldName(), moneyBack);
|
||||
}
|
||||
if(r == null || !r.transactionSuccess()) {
|
||||
noPayBack = true;
|
||||
@@ -539,14 +505,14 @@ public class BuyRegion extends GeneralRegion {
|
||||
|
||||
// Give back the money
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(getBuyer());
|
||||
if(player.hasPlayedBefore() && !noPayBack) {
|
||||
if(player != null && !noPayBack) {
|
||||
EconomyResponse response = null;
|
||||
boolean error = false;
|
||||
try {
|
||||
if(player.getName() != null) {
|
||||
response = economy.depositPlayer(player, getWorldName(), moneyBack);
|
||||
response = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
|
||||
} else if(getPlayerName() != null) {
|
||||
response = economy.depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
||||
response = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
error = true;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +0,0 @@
|
||||
package me.wiefferink.areashop.regions;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface ImportJobFactory {
|
||||
|
||||
@Nonnull ImportJob createImportJob(@Nonnull CommandSender commandSender);
|
||||
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package me.wiefferink.areashop.regions;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface RegionFactory {
|
||||
|
||||
@Nonnull BuyRegion createBuyRegion(@Nonnull YamlConfiguration yamlConfiguration);
|
||||
|
||||
@Nonnull BuyRegion createBuyRegion(@Nonnull String name, @Nonnull World world);
|
||||
|
||||
@Nonnull RentRegion createRentRegion(@Nonnull YamlConfiguration yamlConfiguration);
|
||||
|
||||
@Nonnull RentRegion createRentRegion(@Nonnull String name, @Nonnull World world);
|
||||
|
||||
@Nonnull RegionGroup createRegionGroup(@Nonnull String name);
|
||||
|
||||
}
|
||||
@@ -1,13 +1,9 @@
|
||||
package me.wiefferink.areashop.regions;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import me.wiefferink.areashop.managers.IFileManager;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -15,8 +11,7 @@ import java.util.Set;
|
||||
// TODO consider switching to saving lowercase regions
|
||||
public class RegionGroup {
|
||||
|
||||
private final Plugin plugin;
|
||||
private final IFileManager fileManager;
|
||||
private final AreaShop plugin;
|
||||
private final String name;
|
||||
private final Set<String> regions;
|
||||
private Set<String> autoRegions;
|
||||
@@ -28,10 +23,8 @@ public class RegionGroup {
|
||||
* @param plugin The AreaShop plugin
|
||||
* @param name Name of the group, has to be unique
|
||||
*/
|
||||
@AssistedInject
|
||||
RegionGroup(@Nonnull Plugin plugin, @Nonnull IFileManager fileManager, @Assisted String name) {
|
||||
public RegionGroup(AreaShop plugin, String name) {
|
||||
this.plugin = plugin;
|
||||
this.fileManager = fileManager;
|
||||
this.name = name;
|
||||
this.autoDirty = true;
|
||||
setSetting("name", name);
|
||||
@@ -48,7 +41,7 @@ public class RegionGroup {
|
||||
public Set<String> getAutoRegions() {
|
||||
if(autoDirty) {
|
||||
autoRegions = new HashSet<>();
|
||||
for(GeneralRegion region : fileManager.getRegionsRef()) {
|
||||
for(GeneralRegion region : plugin.getFileManager().getRegions()) {
|
||||
if(worlds.contains(region.getWorldName())) {
|
||||
autoRegions.add(region.getName());
|
||||
}
|
||||
@@ -156,7 +149,7 @@ public class RegionGroup {
|
||||
public Set<GeneralRegion> getMemberRegions() {
|
||||
Set<GeneralRegion> result = new HashSet<>();
|
||||
for(String playerName : getMembers()) {
|
||||
result.add(fileManager.getRegion(playerName));
|
||||
result.add(plugin.getFileManager().getRegion(playerName));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -199,7 +192,7 @@ public class RegionGroup {
|
||||
* @return The ConfigurationSection with the settings of the group
|
||||
*/
|
||||
public ConfigurationSection getSettings() {
|
||||
ConfigurationSection result = fileManager.getGroupSettings(name);
|
||||
ConfigurationSection result = plugin.getFileManager().getGroupSettings(name);
|
||||
if(result != null) {
|
||||
return result;
|
||||
} else {
|
||||
@@ -213,20 +206,20 @@ public class RegionGroup {
|
||||
* @param setting The value to set
|
||||
*/
|
||||
public void setSetting(String path, Object setting) {
|
||||
fileManager.setGroupSetting(this, path, setting);
|
||||
plugin.getFileManager().setGroupSetting(this, path, setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates this file needs to be saved, will actually get saved later by a task.
|
||||
*/
|
||||
public void saveRequired() {
|
||||
fileManager.saveGroupsIsRequired();
|
||||
plugin.getFileManager().saveGroupsIsRequired();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the groups to disk now, normally saveRequired() is preferred because of performance.
|
||||
*/
|
||||
public void saveNow() {
|
||||
fileManager.saveGroupsNow();
|
||||
plugin.getFileManager().saveGroupsNow();
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package me.wiefferink.areashop.regions;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
|
||||
public class RegionModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
install(new FactoryModuleBuilder().build(RegionFactory.class));
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,11 @@
|
||||
package me.wiefferink.areashop.regions;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.events.ask.RentingRegionEvent;
|
||||
import me.wiefferink.areashop.events.ask.UnrentingRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.RentedRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.UnrentedRegionEvent;
|
||||
import me.wiefferink.areashop.interfaces.WorldEditInterface;
|
||||
import me.wiefferink.areashop.interfaces.WorldGuardInterface;
|
||||
import me.wiefferink.areashop.managers.FeatureManager;
|
||||
import me.wiefferink.areashop.tools.Utils;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -21,8 +15,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@@ -32,25 +24,14 @@ import java.util.UUID;
|
||||
import static me.wiefferink.areashop.tools.Utils.millisToHumanFormat;
|
||||
|
||||
public class RentRegion extends GeneralRegion {
|
||||
|
||||
private long warningsDoneUntil = System.currentTimeMillis();
|
||||
private final Economy economy;
|
||||
private long warningsDoneUntil = Calendar.getInstance().getTimeInMillis();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param config All settings of this region
|
||||
*/
|
||||
@AssistedInject
|
||||
RentRegion(
|
||||
@Nonnull AreaShop plugin,
|
||||
@Nonnull FeatureManager featureManager,
|
||||
@Nonnull WorldEditInterface worldEditInterface,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nullable Economy economy,
|
||||
@Assisted @Nonnull YamlConfiguration config
|
||||
) {
|
||||
super(plugin, featureManager, worldEditInterface, worldGuardInterface, config);
|
||||
this.economy = economy;
|
||||
public RentRegion(YamlConfiguration config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,34 +39,8 @@ public class RentRegion extends GeneralRegion {
|
||||
* @param name The name of the region (correct casing)
|
||||
* @param world The world of the WorldGuard region
|
||||
*/
|
||||
@AssistedInject
|
||||
RentRegion(
|
||||
@Nonnull AreaShop plugin,
|
||||
@Nonnull FeatureManager featureManager,
|
||||
@Nonnull WorldEditInterface worldEditInterface,
|
||||
@Nonnull WorldGuardInterface worldGuardInterface,
|
||||
@Nullable Economy economy,
|
||||
@Assisted @Nonnull String name,
|
||||
@Assisted @Nonnull World world
|
||||
) {
|
||||
super(plugin, featureManager, worldEditInterface, worldGuardInterface, name, world);
|
||||
this.economy = economy;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isOwner(UUID player) {
|
||||
return isRenter(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getOwner() {
|
||||
return getRenter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOwner(UUID player) {
|
||||
setRenter(player);
|
||||
public RentRegion(String name, World world) {
|
||||
super(name, world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -181,28 +136,43 @@ public class RentRegion extends GeneralRegion {
|
||||
|
||||
@Override
|
||||
public Object provideReplacement(String variable) {
|
||||
return switch (variable) {
|
||||
case AreaShop.tagPrice -> getFormattedPrice();
|
||||
case AreaShop.tagRawPrice -> getPrice();
|
||||
case AreaShop.tagDuration -> getDurationString();
|
||||
case AreaShop.tagPlayerName -> getPlayerName();
|
||||
case AreaShop.tagPlayerUUID -> getRenter();
|
||||
case AreaShop.tagRentedUntil ->
|
||||
new SimpleDateFormat(plugin.getConfig().getString("timeFormatChat")).format(new Date(getRentedUntil()));
|
||||
case AreaShop.tagRentedUntilShort ->
|
||||
new SimpleDateFormat(plugin.getConfig().getString("timeFormatSign")).format(new Date(getRentedUntil()));
|
||||
case AreaShop.tagTimeLeft -> getTimeLeftString();
|
||||
case AreaShop.tagMoneyBackAmount -> getFormattedMoneyBackAmount();
|
||||
case AreaShop.tagRawMoneyBackAmount -> getMoneyBackAmount();
|
||||
case AreaShop.tagMoneyBackPercentage ->
|
||||
(getMoneyBackPercentage() % 1.0) == 0.0 ? (int) getMoneyBackPercentage() : getMoneyBackPercentage();
|
||||
case AreaShop.tagTimesExtended -> this.getTimesExtended();
|
||||
case AreaShop.tagMaxExtends -> this.getMaxExtends();
|
||||
case AreaShop.tagExtendsLeft -> getMaxExtends() - getTimesExtended();
|
||||
case AreaShop.tagMaxRentTime -> millisToHumanFormat(getMaxRentTime());
|
||||
case AreaShop.tagMaxInactiveTime -> this.getFormattedInactiveTimeUntilUnrent();
|
||||
default -> super.provideReplacement(variable);
|
||||
};
|
||||
switch(variable) {
|
||||
case AreaShop.tagPrice:
|
||||
return getFormattedPrice();
|
||||
case AreaShop.tagRawPrice:
|
||||
return getPrice();
|
||||
case AreaShop.tagDuration:
|
||||
return getDurationString();
|
||||
case AreaShop.tagPlayerName:
|
||||
return getPlayerName();
|
||||
case AreaShop.tagPlayerUUID:
|
||||
return getRenter();
|
||||
case AreaShop.tagRentedUntil:
|
||||
return new SimpleDateFormat(plugin.getConfig().getString("timeFormatChat")).format(new Date(getRentedUntil()));
|
||||
case AreaShop.tagRentedUntilShort:
|
||||
return new SimpleDateFormat(plugin.getConfig().getString("timeFormatSign")).format(new Date(getRentedUntil()));
|
||||
case AreaShop.tagTimeLeft:
|
||||
return getTimeLeftString();
|
||||
case AreaShop.tagMoneyBackAmount:
|
||||
return getFormattedMoneyBackAmount();
|
||||
case AreaShop.tagRawMoneyBackAmount:
|
||||
return getMoneyBackAmount();
|
||||
case AreaShop.tagMoneyBackPercentage:
|
||||
return (getMoneyBackPercentage() % 1.0) == 0.0 ? (int)getMoneyBackPercentage() : getMoneyBackPercentage();
|
||||
case AreaShop.tagTimesExtended:
|
||||
return this.getTimesExtended();
|
||||
case AreaShop.tagMaxExtends:
|
||||
return this.getMaxExtends();
|
||||
case AreaShop.tagExtendsLeft:
|
||||
return getMaxExtends() - getTimesExtended();
|
||||
case AreaShop.tagMaxRentTime:
|
||||
return millisToHumanFormat(getMaxRentTime());
|
||||
case AreaShop.tagMaxInactiveTime:
|
||||
return this.getFormattedInactiveTimeUntilUnrent();
|
||||
|
||||
default:
|
||||
return super.provideReplacement(variable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -345,7 +315,7 @@ public class RentRegion extends GeneralRegion {
|
||||
* @return The amount of money the player should get back
|
||||
*/
|
||||
public double getMoneyBackAmount() {
|
||||
long currentTime = Calendar.getInstance().getTimeInMillis();
|
||||
Long currentTime = Calendar.getInstance().getTimeInMillis();
|
||||
Double timeLeft = (double)(getRentedUntil() - currentTime);
|
||||
double percentage = (getMoneyBackPercentage()) / 100.0;
|
||||
Double timePeriod = (double)(getDuration());
|
||||
@@ -449,7 +419,7 @@ public class RentRegion extends GeneralRegion {
|
||||
}
|
||||
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(getRenter());
|
||||
return rent(offlinePlayer);
|
||||
return offlinePlayer != null && rent(offlinePlayer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -458,7 +428,7 @@ public class RentRegion extends GeneralRegion {
|
||||
* @return true if it succeeded and false if not
|
||||
*/
|
||||
public boolean rent(OfflinePlayer offlinePlayer) {
|
||||
if(economy == null) {
|
||||
if(plugin.getEconomy() == null) {
|
||||
message(offlinePlayer, "general-noEconomy");
|
||||
return false;
|
||||
}
|
||||
@@ -570,11 +540,11 @@ public class RentRegion extends GeneralRegion {
|
||||
}
|
||||
|
||||
// Check if the player has enough money
|
||||
if(!economy.has(offlinePlayer, getWorldName(), price)) {
|
||||
if(!plugin.getEconomy().has(offlinePlayer, getWorldName(), price)) {
|
||||
if(extend) {
|
||||
message(offlinePlayer, "rent-lowMoneyExtend", Utils.formatCurrency(economy.getBalance(offlinePlayer, getWorldName())));
|
||||
message(offlinePlayer, "rent-lowMoneyExtend", Utils.formatCurrency(plugin.getEconomy().getBalance(offlinePlayer, getWorldName())));
|
||||
} else {
|
||||
message(offlinePlayer, "rent-lowMoneyRent", Utils.formatCurrency(economy.getBalance(offlinePlayer, getWorldName())));
|
||||
message(offlinePlayer, "rent-lowMoneyRent", Utils.formatCurrency(plugin.getEconomy().getBalance(offlinePlayer, getWorldName())));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -588,7 +558,7 @@ public class RentRegion extends GeneralRegion {
|
||||
}
|
||||
|
||||
// Substract the money from the players balance
|
||||
EconomyResponse r = economy.withdrawPlayer(offlinePlayer, getWorldName(), price);
|
||||
EconomyResponse r = plugin.getEconomy().withdrawPlayer(offlinePlayer, getWorldName(), price);
|
||||
if(!r.transactionSuccess()) {
|
||||
message(offlinePlayer, "rent-payError");
|
||||
AreaShop.debug("Something went wrong with getting money from " + offlinePlayer.getName() + " while renting " + getName() + ": " + r.errorMessage);
|
||||
@@ -602,9 +572,9 @@ public class RentRegion extends GeneralRegion {
|
||||
String landlordName = getLandlordName();
|
||||
if(landlordName != null) {
|
||||
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
||||
r = economy.depositPlayer(landlordPlayer, getWorldName(), price);
|
||||
r = plugin.getEconomy().depositPlayer(landlordPlayer, getWorldName(), price);
|
||||
} else {
|
||||
r = economy.depositPlayer(landlordName, getWorldName(), price);
|
||||
r = plugin.getEconomy().depositPlayer(landlordName, getWorldName(), price);
|
||||
}
|
||||
if(r == null || !r.transactionSuccess()) {
|
||||
AreaShop.warn("Something went wrong with paying '" + landlordName + "' " + Utils.formatCurrency(price) + " for his rent of region " + getName() + " to " + offlinePlayer.getName());
|
||||
@@ -668,15 +638,15 @@ public class RentRegion extends GeneralRegion {
|
||||
}
|
||||
}
|
||||
|
||||
if(economy == null) {
|
||||
if(plugin.getEconomy() == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Broadcast and check event
|
||||
UnrentingRegionEvent unrentingRegionEvent = new UnrentingRegionEvent(this);
|
||||
Bukkit.getPluginManager().callEvent(unrentingRegionEvent);
|
||||
if(unrentingRegionEvent.isCancelled()) {
|
||||
message(executor, "general-cancelled", unrentingRegionEvent.getReason());
|
||||
UnrentingRegionEvent event = new UnrentingRegionEvent(this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) {
|
||||
message(executor, "general-cancelled", event.getReason());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -692,9 +662,9 @@ public class RentRegion extends GeneralRegion {
|
||||
EconomyResponse r;
|
||||
if(landlordName != null) {
|
||||
if(landlordPlayer != null && landlordPlayer.getName() != null) {
|
||||
r = economy.withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
|
||||
r = plugin.getEconomy().withdrawPlayer(landlordPlayer, getWorldName(), moneyBack);
|
||||
} else {
|
||||
r = economy.withdrawPlayer(landlordName, getWorldName(), moneyBack);
|
||||
r = plugin.getEconomy().withdrawPlayer(landlordName, getWorldName(), moneyBack);
|
||||
}
|
||||
if(r == null || !r.transactionSuccess()) {
|
||||
noPayBack = true;
|
||||
@@ -708,9 +678,9 @@ public class RentRegion extends GeneralRegion {
|
||||
boolean error = false;
|
||||
try {
|
||||
if(player.getName() != null) {
|
||||
r = economy.depositPlayer(player, getWorldName(), moneyBack);
|
||||
r = plugin.getEconomy().depositPlayer(player, getWorldName(), moneyBack);
|
||||
} else if(getPlayerName() != null) {
|
||||
r = economy.depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
||||
r = plugin.getEconomy().depositPlayer(getPlayerName(), getWorldName(), moneyBack);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
error = true;
|
||||
@@ -730,17 +700,13 @@ public class RentRegion extends GeneralRegion {
|
||||
// Remove friends, the owner and renteduntil values
|
||||
getFriendsFeature().clearFriends();
|
||||
UUID oldRenter = getRenter();
|
||||
setRenter(null);
|
||||
setRentedUntil(null);
|
||||
setTimesExtended(-1);
|
||||
removeLastActiveTime();
|
||||
|
||||
// Notify about updates
|
||||
Bukkit.getPluginManager().callEvent(new UnrentedRegionEvent(this, oldRenter, Math.max(0, moneyBack)));
|
||||
// Placed here so when event is passed, the player renting can still be accessed
|
||||
setRenter(null);
|
||||
// Update world (has to be after setting renter to null)
|
||||
this.update();
|
||||
|
||||
this.notifyAndUpdate(new UnrentedRegionEvent(this, oldRenter, Math.max(0, moneyBack)));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
|
||||
import jakarta.inject.Inject;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class BukkitSchedulerExecutor implements Executor {
|
||||
|
||||
private final Plugin plugin;
|
||||
private final BukkitScheduler scheduler;
|
||||
|
||||
@Inject
|
||||
public BukkitSchedulerExecutor(@NotNull Plugin plugin, @NotNull BukkitScheduler scheduler) {
|
||||
this.plugin = plugin;
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(@NotNull Runnable command) {
|
||||
this.scheduler.runTask(this.plugin, command);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -18,234 +18,242 @@ import java.util.logging.Logger;
|
||||
|
||||
public class GithubUpdateCheck {
|
||||
|
||||
public static final String API_HOST = "https://api.github.com/repos";
|
||||
public static final String API_LATEST_RELEASE = "releases/latest";
|
||||
public static final String USER_AGENT = "md5sha256 AreaShop GithubUpdateCheck";
|
||||
public static final boolean DEBUG = false;
|
||||
public static final String API_HOST = "https://api.github.com/repos";
|
||||
public static final String API_LATEST_RELEASE = "releases/latest";
|
||||
public static final String USER_AGENT = "GithubUpdateCheck by NLThijs48";
|
||||
public static final boolean DEBUG = false;
|
||||
private static final Gson GSON = new GsonBuilder().create();
|
||||
|
||||
private final String author;
|
||||
private final String repository;
|
||||
private final Plugin plugin;
|
||||
private final Logger logger;
|
||||
private URL url;
|
||||
private VersionComparator versionComparator;
|
||||
private final String author;
|
||||
private final String repository;
|
||||
private final Plugin plugin;
|
||||
private final Logger logger;
|
||||
private final String currentVersion;
|
||||
private URL url;
|
||||
private VersionComparator versionComparator;
|
||||
// Status
|
||||
private boolean checking;
|
||||
private boolean error;
|
||||
private boolean hasUpdate;
|
||||
private String latestVersion;
|
||||
|
||||
// Status
|
||||
private boolean checking;
|
||||
private boolean error;
|
||||
private boolean hasUpdate;
|
||||
private String latestVersion;
|
||||
private final String currentVersion;
|
||||
/**
|
||||
* Create a new GithubUpdateCheck with the required information.
|
||||
*
|
||||
* @param plugin The plugin to create it for (used for logging and checking version)
|
||||
* @param author The author of the plugin as used on Github
|
||||
* @param repository The repository name of the plugin on Github
|
||||
*/
|
||||
public GithubUpdateCheck(Plugin plugin, String author, String repository) {
|
||||
this.plugin = plugin;
|
||||
this.logger = plugin.getLogger();
|
||||
this.author = author;
|
||||
this.repository = repository;
|
||||
this.currentVersion = plugin.getDescription().getVersion();
|
||||
this.versionComparator = (latest, current) ->
|
||||
!latest.equalsIgnoreCase(current);
|
||||
|
||||
/**
|
||||
* Create a new GithubUpdateCheck with the required information.
|
||||
* @param plugin The plugin to create it for (used for logging and checking version)
|
||||
* @param author The author of the plugin as used on Github
|
||||
* @param repository The repository name of the plugin on Github
|
||||
*/
|
||||
public GithubUpdateCheck(Plugin plugin, String author, String repository) {
|
||||
this.plugin = plugin;
|
||||
this.logger = plugin.getLogger();
|
||||
this.author = author;
|
||||
this.repository = repository;
|
||||
this.currentVersion = plugin.getDescription().getVersion();
|
||||
this.versionComparator = (latest, current) ->
|
||||
!latest.equalsIgnoreCase(current);
|
||||
this.checking = false;
|
||||
this.error = false;
|
||||
this.hasUpdate = false;
|
||||
}
|
||||
|
||||
this.checking = false;
|
||||
this.error = false;
|
||||
this.hasUpdate = false;
|
||||
}
|
||||
/**
|
||||
* Change the version comparator.
|
||||
*
|
||||
* @param versionComparator VersionComparator to use for checking if one version is newer than the other
|
||||
* @return this
|
||||
*/
|
||||
public GithubUpdateCheck withVersionComparator(VersionComparator versionComparator) {
|
||||
this.versionComparator = versionComparator;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the version comparator.
|
||||
* @param versionComparator VersionComparator to use for checking if one version is newer than the other
|
||||
* @return this
|
||||
*/
|
||||
public GithubUpdateCheck withVersionComparator(VersionComparator versionComparator) {
|
||||
this.versionComparator = versionComparator;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Check if an update is available.
|
||||
*/
|
||||
public void checkUpdate() {
|
||||
checkUpdate(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an update is available.
|
||||
*/
|
||||
public void checkUpdate() {
|
||||
checkUpdate(null);
|
||||
}
|
||||
/**
|
||||
* Check if an update is available.
|
||||
*
|
||||
* @param callback Callback to execute when the update check is done
|
||||
* @return GithubUpdateCheck containing the status of the check
|
||||
*/
|
||||
public GithubUpdateCheck checkUpdate(UpdateCallback callback) {
|
||||
checking = true;
|
||||
final GithubUpdateCheck self = this;
|
||||
// Check for update on async thread
|
||||
Utils.newChain()
|
||||
.async(() -> {
|
||||
try {
|
||||
try {
|
||||
String rawUrl = API_HOST + "/" + author + "/" + repository + "/" + API_LATEST_RELEASE;
|
||||
url = new URL(rawUrl);
|
||||
} catch (MalformedURLException e) {
|
||||
logger.severe("Invalid url: '" + url + "', are the author '" + author + "' and repository '" + repository + "' correct?");
|
||||
error = true;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an update is available.
|
||||
* @param callback Callback to execute when the update check is done
|
||||
* @return GithubUpdateCheck containing the status of the check
|
||||
*/
|
||||
public GithubUpdateCheck checkUpdate(UpdateCallback callback) {
|
||||
checking = true;
|
||||
final GithubUpdateCheck self = this;
|
||||
// Check for update on asyn thread
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
try {
|
||||
String rawUrl = API_HOST + "/" + author + "/" + repository + "/" + API_LATEST_RELEASE;
|
||||
url = new URL(rawUrl);
|
||||
} catch(MalformedURLException e) {
|
||||
logger.severe("Invalid url: '" + url + "', are the author '" + author + "' and repository '" + repository + "' correct?");
|
||||
error = true;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
URLConnection conn = url.openConnection();
|
||||
// Give up after 15 seconds
|
||||
conn.setConnectTimeout(15000);
|
||||
// Identify ourselves
|
||||
conn.addRequestProperty("User-Agent", USER_AGENT);
|
||||
// Make sure we access the correct api version
|
||||
conn.addRequestProperty("Accept", "application/vnd.github.v3+json");
|
||||
// We want to read the result
|
||||
conn.setDoOutput(true);
|
||||
// Open connection
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
|
||||
String response = reader.readLine();
|
||||
debug("Response:", response);
|
||||
|
||||
try {
|
||||
URLConnection conn = url.openConnection();
|
||||
// Give up after 15 seconds
|
||||
conn.setConnectTimeout(15000);
|
||||
// Identify ourselves
|
||||
conn.addRequestProperty("User-Agent", USER_AGENT);
|
||||
// Make sure we access the correct api version
|
||||
conn.addRequestProperty("Accept", "application/vnd.github.v3+json");
|
||||
// We want to read the result
|
||||
conn.setDoOutput(true);
|
||||
// Open connection
|
||||
try(BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
|
||||
String response = reader.readLine();
|
||||
debug("Response:", response);
|
||||
JsonObject latestRelease = GSON.fromJson(response, JsonObject.class);
|
||||
|
||||
JSONObject latestRelease = (JSONObject)JSONValue.parse(response);
|
||||
if (latestRelease.isJsonNull()) {
|
||||
logger.warning("Failed to get api response from " + url);
|
||||
error = true;
|
||||
return;
|
||||
}
|
||||
debug("json: " + latestRelease.toString());
|
||||
|
||||
if(latestRelease.isEmpty()) {
|
||||
logger.warning("Failed to get api response from " + url);
|
||||
error = true;
|
||||
return;
|
||||
}
|
||||
debug("json: " + latestRelease.toJSONString());
|
||||
// Latest version
|
||||
latestVersion = latestRelease.get("tag_name").getAsString();
|
||||
debug("Tag name:", latestVersion);
|
||||
|
||||
// Latest version
|
||||
latestVersion = (String)latestRelease.get("tag_name");
|
||||
debug("Tag name:", latestVersion);
|
||||
// Current version
|
||||
debug("Plugin version:", currentVersion);
|
||||
|
||||
// Current version
|
||||
debug("Plugin version:", currentVersion);
|
||||
// Compare version
|
||||
hasUpdate = versionComparator.isNewer(latestVersion, currentVersion);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.severe("Failed to get latest release:" + ExceptionUtils
|
||||
.getStackTrace(e));
|
||||
error = true;
|
||||
} catch (ClassCastException e) {
|
||||
logger.info("Unexpected structure of the result, failed to parse it");
|
||||
error = true;
|
||||
}
|
||||
} finally {
|
||||
checking = false;
|
||||
debug("result:", self);
|
||||
}
|
||||
}
|
||||
).syncLast(x -> {
|
||||
if (callback != null) {
|
||||
callback.run(this);
|
||||
}
|
||||
}).execute();
|
||||
return this;
|
||||
}
|
||||
|
||||
// Compare version
|
||||
hasUpdate = versionComparator.isNewer(latestVersion, currentVersion);
|
||||
}
|
||||
} catch(IOException e) {
|
||||
logger.severe("Failed to get latest release:" + ExceptionUtils.getStackTrace(e));
|
||||
error = true;
|
||||
} catch(ClassCastException e) {
|
||||
logger.info("Unexpected structure of the result, failed to parse it");
|
||||
error = true;
|
||||
}
|
||||
} finally {
|
||||
checking = false;
|
||||
debug("result:", self);
|
||||
if(callback != null) {
|
||||
// Switch back to main thread and call the callback
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
callback.run(self);
|
||||
}
|
||||
}.runTask(plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(plugin);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Check if an update check is running.
|
||||
*
|
||||
* @return true if an update check is running
|
||||
*/
|
||||
public boolean isChecking() {
|
||||
return checking;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an update check is running.
|
||||
* @return true if an update check is running
|
||||
*/
|
||||
public boolean isChecking() {
|
||||
return checking;
|
||||
}
|
||||
/**
|
||||
* Check if the update check failed.
|
||||
*
|
||||
* @return true if the update check failed (an error message has been logged)
|
||||
*/
|
||||
public boolean hasFailed() {
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the update check failed.
|
||||
* @return true if the update check failed (an error message has been logged)
|
||||
*/
|
||||
public boolean hasFailed() {
|
||||
return error;
|
||||
}
|
||||
/**
|
||||
* Check if an update has been found.
|
||||
*
|
||||
* @return true if an update has been found
|
||||
*/
|
||||
public boolean hasUpdate() {
|
||||
return hasUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an update has been found.
|
||||
* @return true if an update has been found
|
||||
*/
|
||||
public boolean hasUpdate() {
|
||||
return hasUpdate;
|
||||
}
|
||||
/**
|
||||
* Get the repository that this update checker is checking.
|
||||
*
|
||||
* @return Used repository
|
||||
*/
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the repository that this update checker is checking.
|
||||
* @return Used repository
|
||||
*/
|
||||
public String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
/**
|
||||
* Get the author that this update checker is checking.
|
||||
*
|
||||
* @return Used author
|
||||
*/
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the author that this update checker is checking.
|
||||
* @return Used author
|
||||
*/
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
/**
|
||||
* Get the current version.
|
||||
*
|
||||
* @return Current version of the plugin
|
||||
*/
|
||||
public String getCurrentVersion() {
|
||||
return currentVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current version.
|
||||
* @return Current version of the plugin
|
||||
*/
|
||||
public String getCurrentVersion() {
|
||||
return currentVersion;
|
||||
}
|
||||
/**
|
||||
* Get the latest version.
|
||||
*
|
||||
* @return Latest version of the plugin (if checking is complete)
|
||||
*/
|
||||
public String getLatestVersion() {
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest version.
|
||||
* @return Latest version of the plugin (if checking is complete)
|
||||
*/
|
||||
public String getLatestVersion() {
|
||||
return latestVersion;
|
||||
}
|
||||
/**
|
||||
* Print a debug message if DEBUG is enabled.
|
||||
*
|
||||
* @param message Message to print
|
||||
*/
|
||||
private void debug(Object... message) {
|
||||
if (DEBUG) {
|
||||
logger.info("[" + this.getClass().getSimpleName() + "] [DEBUG] " + StringUtils
|
||||
.join(message, " "));
|
||||
}
|
||||
}
|
||||
|
||||
public interface VersionComparator {
|
||||
/**
|
||||
* Check if a version should be considered 'newer' than another.
|
||||
* @param latestVersion Version that is available on Github
|
||||
* @param currentVersion Version of the current plugin
|
||||
* @return true if the latestVersion is newer than the localVersion, otherwise false
|
||||
*/
|
||||
boolean isNewer(String latestVersion, String currentVersion);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GithubUpdateCheck(" + StringUtils.join(Arrays.asList(
|
||||
"author=" + author,
|
||||
"repository=" + repository,
|
||||
"plugin=" + plugin.getName(),
|
||||
"checking=" + checking,
|
||||
"hasUpdate=" + hasUpdate,
|
||||
"error=" + error,
|
||||
"currentVersion=" + currentVersion,
|
||||
"latestVersion=" + latestVersion
|
||||
), ", ") + ")";
|
||||
}
|
||||
|
||||
public interface UpdateCallback {
|
||||
void run(GithubUpdateCheck result);
|
||||
}
|
||||
public interface VersionComparator {
|
||||
/**
|
||||
* Check if a version should be considered 'newer' than another.
|
||||
*
|
||||
* @param latestVersion Version that is available on Github
|
||||
* @param currentVersion Version of the current plugin
|
||||
* @return true if the latestVersion is newer than the localVersion, otherwise false
|
||||
*/
|
||||
boolean isNewer(String latestVersion, String currentVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a debug message if DEBUG is enabled.
|
||||
* @param message Message to print
|
||||
*/
|
||||
private void debug(Object... message) {
|
||||
if(DEBUG) {
|
||||
logger.info("[" + this.getClass().getSimpleName() + "] [DEBUG] " + StringUtils.join(message, " "));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GithubUpdateCheck(" + StringUtils.join(Arrays.asList(
|
||||
"author=" + author,
|
||||
"repository=" + repository,
|
||||
"plugin=" + plugin.getName(),
|
||||
"checking=" + checking,
|
||||
"hasUpdate=" + hasUpdate,
|
||||
"error=" + error,
|
||||
"currentVersion=" + currentVersion,
|
||||
"latestVersion=" + latestVersion
|
||||
), ", ") + ")";
|
||||
}
|
||||
public interface UpdateCallback {
|
||||
void run(GithubUpdateCheck result);
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
import me.wiefferink.interactivemessenger.generators.TellrawGenerator;
|
||||
import me.wiefferink.interactivemessenger.parsers.YamlParser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.chat.ComponentSerializer;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.loader.HeaderMode;
|
||||
import org.spongepowered.configurate.yaml.NodeStyle;
|
||||
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class LanguageConverter {
|
||||
|
||||
public static void performConversion(ConfigurationNode root) throws ConfigurateException {
|
||||
if (!root.isMap()) {
|
||||
convertNode(root);
|
||||
return;
|
||||
}
|
||||
Map<Object, ? extends ConfigurationNode> map = root.childrenMap();
|
||||
for (Map.Entry<Object, ? extends ConfigurationNode> entry : map.entrySet()) {
|
||||
ConfigurationNode node = entry.getValue();
|
||||
if (node.isMap()) {
|
||||
performConversion(node);
|
||||
} else {
|
||||
convertNode(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void performConversion(File toConvert, File output) throws IOException {
|
||||
YamlConfigurationLoader loader = YamlConfigurationLoader.builder()
|
||||
.source(() -> new BufferedReader(new FileReader(toConvert, StandardCharsets.UTF_8)))
|
||||
.sink(() -> new BufferedWriter(new FileWriter(output, StandardCharsets.UTF_8)))
|
||||
.headerMode(HeaderMode.PRESERVE)
|
||||
.nodeStyle(NodeStyle.BLOCK)
|
||||
.build();
|
||||
ConfigurationNode root = loader.load();
|
||||
performConversion(root);
|
||||
loader.save(root);
|
||||
}
|
||||
|
||||
public static List<String> convertRawList(List<String> messages) {
|
||||
List<String> jsonMessages = TellrawGenerator.generate(YamlParser.parse(messages));
|
||||
List<String> converted = new ArrayList<>();
|
||||
for (String json : jsonMessages) {
|
||||
BaseComponent[] bungeeComponents = ComponentSerializer.parse(json);
|
||||
Component convertedComponent = BungeeComponentSerializer.get()
|
||||
.deserialize(bungeeComponents);
|
||||
String miniMessage = MiniMessage.miniMessage()
|
||||
.serialize(convertedComponent);
|
||||
converted.add(miniMessage);
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
|
||||
private static void convertNode(ConfigurationNode node) throws ConfigurateException {
|
||||
boolean isList = node.isList();
|
||||
List<String> messages;
|
||||
if (isList) {
|
||||
messages = node.getList(String.class, Collections.emptyList());
|
||||
} else {
|
||||
messages = Collections.singletonList(node.getString());
|
||||
}
|
||||
List<String> converted = convertRawList(messages);
|
||||
if (converted.size() == 1) {
|
||||
node.set(String.class, converted.get(0));
|
||||
} else {
|
||||
node.setList(String.class, converted);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,8 +1,14 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Materials {
|
||||
|
||||
private Materials() {
|
||||
@@ -19,11 +25,11 @@ public class Materials {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Material.getMaterial(name);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
ex.printStackTrace();
|
||||
return Material.matchMaterial(name);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
AreaShop.debug("Materials.get() null result:", name);
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,7 +38,7 @@ public class Materials {
|
||||
* @return true if the given material is a sign
|
||||
*/
|
||||
public static boolean isSign(Material material) {
|
||||
return Tag.SIGNS.isTagged(material);
|
||||
return Tag.SIGNS.isTagged(material) || Tag.WALL_SIGNS.isTagged(material);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,8 +48,9 @@ public class Materials {
|
||||
*/
|
||||
public static boolean isSign(String name) {
|
||||
try {
|
||||
return isSign(Material.getMaterial(name));
|
||||
return isSign(Material.matchMaterial(name));
|
||||
} catch (IllegalArgumentException ex) {
|
||||
AreaShop.debug("Invalid Material: " + name + " passed when performing sign check.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
/**
|
||||
* Parse math from a string
|
||||
* Adapted from:
|
||||
* https://stackoverflow.com/questions/3422673/how-to-evaluate-a-math-expression-given-in-string-form
|
||||
*/
|
||||
public final class OperandParser {
|
||||
|
||||
private final String str;
|
||||
|
||||
private OperandParser(final String str) {
|
||||
this.str = str;
|
||||
}
|
||||
|
||||
public static double parse(final String str) throws ParseException {
|
||||
return new OperandParser(str).parse();
|
||||
}
|
||||
|
||||
|
||||
private int pos = -1, ch;
|
||||
|
||||
private void nextChar() {
|
||||
ch = (++pos < str.length()) ? str.charAt(pos) : -1;
|
||||
}
|
||||
|
||||
private boolean eat(int charToEat) {
|
||||
while (ch == ' ') nextChar();
|
||||
if (ch == charToEat) {
|
||||
nextChar();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private double parse() throws ParseException {
|
||||
nextChar();
|
||||
double x = parseExpression();
|
||||
if (pos < str.length())
|
||||
{
|
||||
throw new ParseException("Unexpected: " + (char) ch);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
// Grammar:
|
||||
// expression = term | expression `+` term | expression `-` term
|
||||
// term = factor | term `*` factor | term `/` factor
|
||||
// factor = `+` factor | `-` factor | `(` expression `)`
|
||||
// | number | functionName factor | factor `^` factor
|
||||
|
||||
private double parseExpression() throws ParseException {
|
||||
double x = parseTerm();
|
||||
for (; ; ) {
|
||||
if (eat('+')) {
|
||||
// addition
|
||||
x += parseTerm();
|
||||
}
|
||||
else if (eat('-')) {
|
||||
// subtraction
|
||||
x -= parseTerm();
|
||||
}
|
||||
else return x;
|
||||
}
|
||||
}
|
||||
|
||||
private double parseTerm() throws ParseException {
|
||||
double x = parseFactor();
|
||||
for (; ; ) {
|
||||
if (eat('*')) {
|
||||
// multiplication
|
||||
x *= parseFactor();
|
||||
}
|
||||
else if (eat('/')) {
|
||||
// division
|
||||
x /= parseFactor();
|
||||
}
|
||||
else return x;
|
||||
}
|
||||
}
|
||||
|
||||
private double parseFactor() throws ParseException {
|
||||
if (eat('+')) {
|
||||
// unary plus
|
||||
return parseFactor();
|
||||
}
|
||||
if (eat('-')) {
|
||||
// unary minus
|
||||
return -parseFactor();
|
||||
}
|
||||
|
||||
double x;
|
||||
int startPos = this.pos;
|
||||
if (eat('(')) {
|
||||
// parentheses
|
||||
x = parseExpression();
|
||||
eat(')');
|
||||
} else if ((ch >= '0' && ch <= '9') || ch == '.') {
|
||||
// numbers
|
||||
while ((ch >= '0' && ch <= '9') || ch == '.') {
|
||||
nextChar();
|
||||
}
|
||||
x = Double.parseDouble(str.substring(startPos, this.pos));
|
||||
} else if (ch >= 'a' && ch <= 'z') {
|
||||
// functions
|
||||
while (ch >= 'a' && ch <= 'z') {
|
||||
nextChar();
|
||||
}
|
||||
String func = str.substring(startPos, this.pos);
|
||||
x = parseFactor();
|
||||
x = switch (func) {
|
||||
case "sqrt" -> Math.sqrt(x);
|
||||
case "sin" -> Math.sin(Math.toRadians(x));
|
||||
case "cos" -> Math.cos(Math.toRadians(x));
|
||||
case "tan" -> Math.tan(Math.toRadians(x));
|
||||
default -> throw new ParseException("Unknown function: " + func);
|
||||
};
|
||||
} else {
|
||||
throw new ParseException("Unexpected: " + (char) ch);
|
||||
}
|
||||
|
||||
if (eat('^')) {
|
||||
// exponentiation
|
||||
x = Math.pow(x, parseFactor());
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
public static class ParseException extends Exception {
|
||||
|
||||
public ParseException() {
|
||||
}
|
||||
|
||||
public ParseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ParseException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ParseException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public ParseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Sign;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
|
||||
/**
|
||||
* Sign Utilities class
|
||||
*/
|
||||
public final class SignUtils {
|
||||
|
||||
private SignUtils() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link BlockFace} of a sign block
|
||||
* If the passed {@link Block} is not an instance of either
|
||||
* a {@link Sign} or {@link WallSign}, this method will return <code>null</code>
|
||||
*
|
||||
* @param block The sign
|
||||
* @return Returns the {@link BlockFace} of the sign or <code>null</code>
|
||||
*/
|
||||
public static BlockFace getSignFacing(Block block) {
|
||||
if (block == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockState blockState = block.getState();
|
||||
BlockData blockData = blockState.getBlockData();
|
||||
|
||||
if (blockData instanceof WallSign wallSign) {
|
||||
return wallSign.getFacing();
|
||||
} else if (blockData instanceof org.bukkit.block.data.type.Sign sign) {
|
||||
return sign.getRotation();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the {@link BlockFace} in which the sign will face
|
||||
* If the passed {@link Block} is not an instance of either
|
||||
* a {@link Sign} or {@link WallSign}, this method will return <code>null</code>.
|
||||
*
|
||||
* @param block The sign block
|
||||
* @param facing The new {@link BlockFace} the sign should face
|
||||
* @return Returns <code>true</code> if the sign was successfully placed, <code>false</code> otherwise
|
||||
*/
|
||||
public static boolean setSignFacing(Block block, BlockFace facing) {
|
||||
if (block == null || facing == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockState blockState = block.getState();
|
||||
BlockData blockData = blockState.getBlockData();
|
||||
|
||||
if (blockData instanceof WallSign wallSign) {
|
||||
wallSign.setFacing(facing);
|
||||
} else if (blockData instanceof org.bukkit.block.data.type.Sign sign) {
|
||||
sign.setRotation(facing);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
block.setBlockData(blockData);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link Block} which a given sign is attached to.
|
||||
* This method will return <code>null</code> if the passed {@link Block}
|
||||
* is not an instance of either a {@link Sign} or {@link WallSign}.
|
||||
*
|
||||
* @param block The sign {@link Block}
|
||||
* @return Returns the block which the sign is attached to or null
|
||||
*/
|
||||
public static Block getSignAttachedTo(Block block) {
|
||||
if (block == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
BlockState blockState = block.getState();
|
||||
|
||||
BlockData blockData = blockState.getBlockData();
|
||||
|
||||
if (blockData instanceof WallSign wallSign) {
|
||||
return block.getRelative(wallSign.getFacing().getOppositeFace());
|
||||
} else if (blockData instanceof Sign) {
|
||||
return block.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import me.wiefferink.areashop.MessageBridge;
|
||||
import me.wiefferink.interactivemessenger.Log;
|
||||
import me.wiefferink.interactivemessenger.generators.ConsoleGenerator;
|
||||
import me.wiefferink.interactivemessenger.generators.TellrawGenerator;
|
||||
import me.wiefferink.interactivemessenger.parsers.YamlParser;
|
||||
import me.wiefferink.interactivemessenger.processing.Message;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.apache.commons.lang.exception.ExceptionUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@Singleton
|
||||
public class SimpleMessageBridge implements MessageBridge {
|
||||
|
||||
/**
|
||||
* Send a message to a target without a prefix.
|
||||
* @param target The target to send the message to
|
||||
* @param key The key of the language string
|
||||
* @param replacements The replacements to insert in the message
|
||||
*/
|
||||
@Override
|
||||
public void messageNoPrefix(Object target, String key, Object... replacements) {
|
||||
Message m = Message.fromKey(key).replacements(replacements);
|
||||
send(m, target);
|
||||
}
|
||||
|
||||
public static void send(Message message, Object target) {
|
||||
if(AreaShop.useMiniMessage()) {
|
||||
|
||||
if(target instanceof Audience audience) {
|
||||
if(message.get() == null || message.get().isEmpty() || (message.get().size() == 1 && message.get()
|
||||
.get(0)
|
||||
.isEmpty())) {
|
||||
return;
|
||||
}
|
||||
message.doReplacements();
|
||||
|
||||
StringBuilder messageStr = new StringBuilder();
|
||||
for(String line : message.get()) {
|
||||
messageStr.append(line);
|
||||
}
|
||||
|
||||
MiniMessage mm = MiniMessage.miniMessage();
|
||||
Component parsed = mm.deserialize(messageStr.toString());
|
||||
audience.sendMessage(parsed);
|
||||
}
|
||||
else {
|
||||
AreaShop.error("AreaShop sent a non-supported Object as the Audience for a Message!");
|
||||
}
|
||||
} else {
|
||||
message.send(target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to a target, prefixed by the default chat prefix.
|
||||
* @param target The target to send the message to
|
||||
* @param key The key of the language string
|
||||
* @param replacements The replacements to insert in the message
|
||||
*/
|
||||
@Override
|
||||
public void message(Object target, String key, Object... replacements) {
|
||||
Message m = Message.fromKey(key).prefix().replacements(replacements);
|
||||
send(m, target);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class SpigotOfflinePlayerHelper implements OfflinePlayerHelper {
|
||||
|
||||
private final Plugin plugin;
|
||||
|
||||
public SpigotOfflinePlayerHelper(@NotNull Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Optional<UUID>> lookupUuidAsync(String username) {
|
||||
return lookupOfflinePlayerAsync(username).thenApply(player -> {
|
||||
if (player.hasPlayedBefore()) {
|
||||
return Optional.of(player.getUniqueId());
|
||||
}
|
||||
return Optional.empty();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<OfflinePlayer> lookupOfflinePlayerAsync(String username) {
|
||||
final CompletableFuture<OfflinePlayer> future = new CompletableFuture<>();
|
||||
final Server server = this.plugin.getServer();
|
||||
server.getScheduler().runTaskAsynchronously(this.plugin, () -> {
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer player = server.getOfflinePlayer(username);
|
||||
future.complete(player);
|
||||
});
|
||||
return future;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package me.wiefferink.areashop.tools;
|
||||
|
||||
import me.wiefferink.areashop.adapters.platform.MinecraftPlatform;
|
||||
import me.wiefferink.areashop.adapters.platform.OfflinePlayerHelper;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SpigotPlatform implements MinecraftPlatform {
|
||||
|
||||
private final OfflinePlayerHelper offlinePlayerHelper;
|
||||
|
||||
public SpigotPlatform(@NotNull Plugin plugin) {
|
||||
this.offlinePlayerHelper = new SpigotOfflinePlayerHelper(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayerHelper offlinePlayerHelper() {
|
||||
return this.offlinePlayerHelper;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,40 +0,0 @@
|
||||
package me.wiefferink.areashop.tools.version;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
|
||||
public enum PreReleaseType {
|
||||
|
||||
UNKNOWN("unknown"),
|
||||
|
||||
ALPHA("alpha"),
|
||||
BETA("beta"),
|
||||
SNAPSHOT("snapshot"),
|
||||
RELEASE_CANDIDATE("rc");
|
||||
|
||||
private static final PreReleaseType[] VALUES = values();
|
||||
|
||||
private final String asString;
|
||||
|
||||
PreReleaseType(String asString) {
|
||||
this.asString = asString;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PreReleaseType parse(String release) {
|
||||
if (release.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
String sanitized = release.toLowerCase(Locale.ENGLISH);
|
||||
for (PreReleaseType preReleaseType : VALUES) {
|
||||
if (preReleaseType.asString.equals(sanitized)) {
|
||||
return preReleaseType;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
return this.asString;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package me.wiefferink.areashop.tools.version;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public record Version(String original, VersionData versionData) {
|
||||
|
||||
/**
|
||||
* Semver pattern, cg1 = major, cg2 = minor, cg3 = patch, cg4 = prerelease and cg5 = buildmetadata
|
||||
* Taken from https://semver.org/ and https://regex101.com/r/vkijKf/1/
|
||||
*/
|
||||
public static final Pattern SEMVER_PATTERN = Pattern.compile(
|
||||
"^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$");
|
||||
|
||||
|
||||
public static Version parse(String version) {
|
||||
Matcher matcher = SEMVER_PATTERN.matcher(version);
|
||||
if (!matcher.find()) {
|
||||
throw new IllegalArgumentException("Invalid version: " + version);
|
||||
}
|
||||
String majorRaw = matcher.group(1);
|
||||
String minorRaw = matcher.group(2);
|
||||
String patchRaw = matcher.group(3);
|
||||
String preReleaseRaw = matcher.group(4);
|
||||
int major;
|
||||
int minor;
|
||||
try {
|
||||
major = Integer.parseInt(majorRaw);
|
||||
minor = Integer.parseInt(minorRaw);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException("Invalid version: " + version);
|
||||
}
|
||||
if (patchRaw == null || patchRaw.isEmpty()) {
|
||||
return new Version(version, new VersionData(major, minor, 0, null));
|
||||
}
|
||||
int patch;
|
||||
try {
|
||||
patch = Integer.parseInt(patchRaw);
|
||||
} catch (NumberFormatException ex) {
|
||||
throw new IllegalArgumentException("Invalid version: " + version);
|
||||
}
|
||||
if (preReleaseRaw == null || preReleaseRaw.isEmpty()) {
|
||||
return new Version(version, new VersionData(major, minor, patch, null));
|
||||
}
|
||||
PreReleaseType releaseType = PreReleaseType.parse(preReleaseRaw);
|
||||
return new Version(version, new VersionData(major, minor, patch, releaseType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.original;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package me.wiefferink.areashop.tools.version;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record VersionData(int major, int minor, int patch, PreReleaseType preReleaseType)
|
||||
implements Comparable<VersionData> {
|
||||
|
||||
|
||||
public VersionData(int major, int minor, int patch) {
|
||||
this(major, minor, patch, null);
|
||||
}
|
||||
|
||||
public VersionData(int major, int minor) {
|
||||
this(major, minor, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%d.%d.%d", major, minor, patch);
|
||||
}
|
||||
|
||||
public boolean isNewerThan(VersionData other) {
|
||||
return compareTo(other) > 0;
|
||||
}
|
||||
|
||||
public boolean isOlderThan(VersionData other) {
|
||||
return compareTo(other) < 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull VersionData o) {
|
||||
int majorComp = Integer.compare(this.major, o.major);
|
||||
if (majorComp != 0) {
|
||||
return majorComp;
|
||||
}
|
||||
int minorComp = Integer.compare(this.minor, o.minor);
|
||||
if (minorComp != 0) {
|
||||
return minorComp;
|
||||
}
|
||||
int patchComp = Integer.compare(this.patch, o.patch);
|
||||
if (patchComp != 0) {
|
||||
return patchComp;
|
||||
}
|
||||
if (this.preReleaseType == null && o.preReleaseType == null) {
|
||||
return 0;
|
||||
}
|
||||
if (this.preReleaseType == null) {
|
||||
return 1;
|
||||
}
|
||||
return this.preReleaseType.compareTo(o.preReleaseType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package me.wiefferink.areashop.tools.version;
|
||||
|
||||
public class VersionUtil {
|
||||
|
||||
public static VersionData MC_1_17_1 = new VersionData(1, 17, 1);
|
||||
|
||||
public static Version parseMinecraftVersion(String minecraftVersion) {
|
||||
// Expecting 1.X.X-R0.1-SNAPSHOT
|
||||
int stripLength = "-R0.1-SNAPSHOT".length();
|
||||
int length = minecraftVersion.length();
|
||||
if (length <= stripLength) {
|
||||
throw new IllegalArgumentException("Invalid minecraft version: " + minecraftVersion);
|
||||
}
|
||||
String strippedVersion = minecraftVersion.substring(0, length - stripLength);
|
||||
try {
|
||||
return Version.parse(strippedVersion);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw new IllegalArgumentException("Invalid minecraft version: " + minecraftVersion, ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,35 +6,16 @@
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ GENERAL: Options that influence the global state of the plugin │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
||||
# Chat prefix used for all messages in the chat
|
||||
# Chat prefix used for all messages in the chat, also changes the greeting messages.
|
||||
chatPrefix:
|
||||
- '[darkgreen][AreaShop][reset]'
|
||||
- ' hover: AreaShop region management plugin'
|
||||
- ' hover: %lang:action|Click to check the available commands|%'
|
||||
- ' command: /areashop help'
|
||||
- ' '
|
||||
|
||||
# WorldGuard doesn't support MiniMessage, so when setting WorldGuard Greetings, this prefix is used instead. (Bukkit color codes)
|
||||
wgPrefix: '&2[AreaShop] &r'
|
||||
|
||||
# The language file that should be used, check the 'lang' folder for build-in languages (use the filename without .yml here).
|
||||
# More information can be found here: https://github.com/NLthijs48/AreaShop/wiki/Language-support.
|
||||
# NOTE: If you want to use MiniMessage, make sure you're using mmLanguage below.
|
||||
language: EN
|
||||
|
||||
# Whether you want to use MiniMessage (in Paper) or stick to the older built-in language management for AreaShop messages.
|
||||
useMiniMessage: false
|
||||
|
||||
# Chat prefix used for all messages in chat
|
||||
# **THIS IS ONLY APPLICABLE IF UseMiniMessage IS SET TO TRUE**
|
||||
mmChatPrefix:
|
||||
- '<click:run_command:/areashop help><hover:show_text:"AreaShop region management plugin<newline>%lang:action|Click to check the available commands|%"><dark_green>[AreaShop]<reset> '
|
||||
|
||||
# The language file that should be used, check the 'lang' folder for build-in languages (use the filename without .yml here).
|
||||
# **THIS IS ONLY APPLICABLE IF UseMiniMessage IS SET TO TRUE**
|
||||
mmLanguage: ENMM
|
||||
|
||||
# The tags that need to be written on the first line of a sign to add it to AreaShop.
|
||||
signTags:
|
||||
# Add a rental region.
|
||||
@@ -140,10 +121,6 @@ debug: false
|
||||
version: ${project.version}
|
||||
# Maximum number of blocks to save to or restore from a .schemetic file.
|
||||
maximumBlocks: 1000000
|
||||
# Whether to forcefully clear "hanging" entities (painting, itemframes, etc.) on region restore
|
||||
# Only enable this option if hanging entities at the destination aren't removed on restore normally
|
||||
# If set to true, there may be a performance impact when performing region restores.
|
||||
forceClearEntities: false
|
||||
# Maximum number of locations the teleport function should check to find a safe spot.
|
||||
maximumTries: 50000
|
||||
|
||||
@@ -201,4 +178,4 @@ maximumTries: 50000
|
||||
# %tpyaw% The exact yaw of the teleport location
|
||||
# %tpyawround% The rounded yaw of the teleport location
|
||||
# %tpworld% The world name of the teleport location
|
||||
# %lang:<languageKey>|Optional arguments|% Insert a message from your language yml file, for example: '%lang:timeleft-ended%' or '%lang:timeleft-years|15|%'
|
||||
# %lang:<languageKey>|Optional arguments|% Insert a message from EN.yml, for example: '%lang:timeleft-ended%' or '%lang:timeleft-years|15|%'
|
||||
@@ -34,8 +34,6 @@ general:
|
||||
landlordName: ''
|
||||
# Disable to prevent counting this region towards limits set by 'limitGroups' in config.yml.
|
||||
countForLimits: true
|
||||
# Whether transferring tenant <--> tenant and landlord <--> landlord should be enabled
|
||||
transferMode: false
|
||||
|
||||
##### Set the layout and functions of the signs.
|
||||
# The following sections can be added for performing certain commands when the sign is clicked:
|
||||
@@ -122,18 +120,18 @@ general:
|
||||
block-break: 'deny g:non_members'
|
||||
block-place: 'deny g:non_members'
|
||||
forrent:
|
||||
greeting: '%lang:wgPrefix%%lang:greeting-forrent%'
|
||||
greeting: '%lang:prefix%%lang:greeting-forrent%'
|
||||
rented:
|
||||
members: '%uuid%, %friendsuuid%'
|
||||
greeting: '%lang:wgPrefix%%lang:greeting-rented%'
|
||||
greeting: '%lang:prefix%%lang:greeting-rented%'
|
||||
forsale:
|
||||
greeting: '%lang:wgPrefix%%lang:greeting-forsale%'
|
||||
greeting: '%lang:prefix%%lang:greeting-forsale%'
|
||||
sold:
|
||||
members: '%uuid%, %friendsuuid%'
|
||||
greeting: '%lang:wgPrefix%%lang:greeting-bought%'
|
||||
greeting: '%lang:prefix%%lang:greeting-bought%'
|
||||
resell:
|
||||
members: '%uuid%, %friendsuuid%'
|
||||
greeting: '%lang:wgPrefix%%lang:greeting-resale%'
|
||||
greeting: '%lang:prefix%%lang:greeting-resale%'
|
||||
|
||||
##### Save and restore schematics to clean up regions.
|
||||
# After 'save:' or 'restore:' you enter the name of the file to restore from/to (.schematic is added automatically).
|
||||
|
||||
@@ -13,30 +13,30 @@
|
||||
"action": "[gold][bold]<%0%>[/bold]"
|
||||
"button": "[bold]<%0%>[/bold]"
|
||||
"command":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: %lang:action|Benutze %1%|%"
|
||||
- " command: %1%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: %lang:action|Benutze %1%|%"
|
||||
- " command: %1%"
|
||||
"helpCommand":
|
||||
- "[gold]%0% [gray]-[reset]"
|
||||
- " hover: %lang:action|Benutze %0%|%"
|
||||
- " command: %0%"
|
||||
- "[gold]%0% [gray]-[reset]"
|
||||
- " hover: %lang:action|Benutze %0%|%"
|
||||
- " command: %0%"
|
||||
"region": "%lang:tRegion|%region%|%"
|
||||
"tRegion":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Region %0%"
|
||||
- " hover: %lang:action|Region information|%"
|
||||
- " command: /areashop info region %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Region %0%"
|
||||
- " hover: %lang:action|Region information|%"
|
||||
- " command: /areashop info region %0%"
|
||||
"player": "%lang:tPlayer|%player%|%"
|
||||
"tPlayer":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Spieler %0%"
|
||||
- " hover: %lang:action|Regionen von %0%|%"
|
||||
- " command: /areashop info player %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Spieler %0%"
|
||||
- " hover: %lang:action|Regionen von %0%|%"
|
||||
- " command: /areashop info player %0%"
|
||||
"landlord":
|
||||
- "[bold]%landlord%[/bold]"
|
||||
- " hover: Vermieter %landlord%"
|
||||
- " hover: %lang:action|Regionen von %landlord%|%"
|
||||
- " command: /areashop info player %landlord%"
|
||||
- "[bold]%landlord%[/bold]"
|
||||
- " hover: Vermieter %landlord%"
|
||||
- " hover: %lang:action|Regionen von %landlord%|%"
|
||||
- " command: /areashop info player %landlord%"
|
||||
"total-maximum": "Du kannst nicht mehr als %0% Region(en) mieten/kaufen (Du hast bereits %1% in Gruppe '%2%')."
|
||||
"confirm-yes": " [gray]Klicken um %lang:command|den Command zu bestätigen|1%0%|%[gray] oder zu wiederholen."
|
||||
"general-notReady": "AreaShop ist noch nicht vollständig geladen, bitte warten."
|
||||
@@ -142,15 +142,15 @@
|
||||
"reload-noPermission": "Du hast keine Berechtigungen um die Konfigurationsdateien neu zu laden."
|
||||
"reload-updateCommandChanged": "'/as updaterents' und '/as updatebuys' wurden entfernt, bitte benutze '/as reload' um die Regionen neu zu laden."
|
||||
"info-help":
|
||||
- "/as info[break]"
|
||||
- " %lang:command|all|/as info all|%[break]"
|
||||
- " %lang:command|rented|/as info rented|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|forrent|/as info forrent|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|sold|/as info sold|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|forsale|/as info forsale|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|reselling|/as info reselling|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|nogroup|/as info nogroup [Seite]|%[break]"
|
||||
- " %lang:command|region|/as info region|% [Region]"
|
||||
- "/as info[break]"
|
||||
- " %lang:command|all|/as info all|%[break]"
|
||||
- " %lang:command|rented|/as info rented|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|forrent|/as info forrent|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|sold|/as info sold|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|forsale|/as info forsale|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|reselling|/as info reselling|% [Gruppe] [Seite][break]"
|
||||
- " %lang:command|nogroup|/as info nogroup [Seite]|%[break]"
|
||||
- " %lang:command|region|/as info region|% [Region]"
|
||||
"info-noPermission": "Du hast keine Berechtigung, Informationen über Regionen zu erhalten."
|
||||
"info-allHeader": "Alle Regionen%0%:"
|
||||
"info-rentedHeader": "Gemietete Regionen%0%:"
|
||||
@@ -171,11 +171,11 @@
|
||||
"info-entryReselling": "[darkgreen][bold]►[reset] %lang:region%: [gray]Verkauft an %lang:player% (Weiterverkauf)."
|
||||
"info-pageStatus": "[gold]Seite %0%/%1%"
|
||||
"info-pageNoPrevious":
|
||||
- " [darkgray][bold]◄Vorherige[/bold] "
|
||||
- " hover: Das ist bereits die erste Seite."
|
||||
- " [darkgray][bold]◄Vorherige[/bold] "
|
||||
- " hover: Das ist bereits die erste Seite."
|
||||
"info-pageNoNext":
|
||||
- " [darkgray][bold]Nächste►[/bold]"
|
||||
- " hover: Das ist bereits die letzte Seite."
|
||||
- " [darkgray][bold]Nächste►[/bold]"
|
||||
- " hover: Das ist bereits die letzte Seite."
|
||||
"info-playerHelp": "/as info player <Spielername>."
|
||||
"info-playerRents": "Gemietete Regionen von %lang:tPlayer|%0%|%: [gray]%1%"
|
||||
"info-playerNoRents": "%lang:tPlayer|%0%|% hat bisher keine Region(en) gemietet."
|
||||
@@ -188,66 +188,66 @@
|
||||
"info-regionBought": "[darkgreen][bold]►[reset] Gekauft von %lang:player%."
|
||||
"info-regionReselling": "[darkgreen][bold]►[reset] Gekauft von %lang:player%, derzeit Weiterverkauf."
|
||||
"info-regionExtending":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Verlängern für[/bold]"
|
||||
- " hover: Miete verlängern für %region%"
|
||||
- " hover: mit %duration% für %price%"
|
||||
- " hover: %lang:action|Mieter Verlängern für %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% für %duration%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Verlängern für[/bold]"
|
||||
- " hover: Miete verlängern für %region%"
|
||||
- " hover: mit %duration% für %price%"
|
||||
- " hover: %lang:action|Mieter Verlängern für %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% für %duration%."
|
||||
"info-regionCanBeRented":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Mieten für[/bold]"
|
||||
- " hover: Miete %region% für %price% für %duration%"
|
||||
- " hover: %lang:action|Miete %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% für %duration%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Mieten für[/bold]"
|
||||
- " hover: Miete %region% für %price% für %duration%"
|
||||
- " hover: %lang:action|Miete %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% für %duration%."
|
||||
"info-regionCanBeBought":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Kaufen für[/bold]"
|
||||
- " hover: Kaufe %region% für %price%"
|
||||
- " hover: %lang:action|Kaufe %region%|%"
|
||||
- " command: /areashop buy %region%"
|
||||
- ": [gray]%price%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Kaufen für[/bold]"
|
||||
- " hover: Kaufe %region% für %price%"
|
||||
- " hover: %lang:action|Kaufe %region%|%"
|
||||
- " command: /areashop buy %region%"
|
||||
- ": [gray]%price%."
|
||||
"info-regionReselPrice": "[darkgreen][bold]►[reset] Weiterverkaufspreis: [gray]%resellprice% (Du kannst es von %lang:player% kaufen)."
|
||||
"info-regionFriends": "[darkgreen][bold]►[reset] Hinzugefügte Freunde: [gray]%0%."
|
||||
"info-friend": "%lang:tPlayer|%0%|%"
|
||||
"info-friendRemove":
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "[red]✕[gray]"
|
||||
- " hover: Region %region%"
|
||||
- " hover: %lang:action|Lösche %0% als Freund|%"
|
||||
- " command: /areashop delfriend %0% %region%"
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "[red]✕[gray]"
|
||||
- " hover: Region %region%"
|
||||
- " hover: %lang:action|Lösche %0% als Freund|%"
|
||||
- " command: /areashop delfriend %0% %region%"
|
||||
"info-regionMoneyBackBuy": "[darkgreen][bold]►[reset] Verkaufpreis: [gray]%moneyback% (%moneybackpercent%% des Kaufpreises)."
|
||||
"info-regionMoneyBackBuyClick":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Verkaufsrückzahlung[/bold]"
|
||||
- " hover: Verkaufe %region% und bekomme %moneyback% zurück"
|
||||
- " hover: %lang:action|Verkaufe %region%|%"
|
||||
- " command: /areashop sell %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% des Kaufpreises)."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Verkaufsrückzahlung[/bold]"
|
||||
- " hover: Verkaufe %region% und bekomme %moneyback% zurück"
|
||||
- " hover: %lang:action|Verkaufe %region%|%"
|
||||
- " command: /areashop sell %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% des Kaufpreises)."
|
||||
"info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Rückzahlung bei Mietkündigung: [gray]%moneyback% (%moneybackpercent%% der verbleibenden Zeit)."
|
||||
"info-regionMoneyBackRentClick":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Mietrückzahlung[/bold]"
|
||||
- " hover: Entmiete %region% und bekomme %moneyback% zurück"
|
||||
- " hover: %lang:action|Unrent %region%|%"
|
||||
- " command: /areashop unrent %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% der verbleibenden Zeit)."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Mietrückzahlung[/bold]"
|
||||
- " hover: Entmiete %region% und bekomme %moneyback% zurück"
|
||||
- " hover: %lang:action|Unrent %region%|%"
|
||||
- " command: /areashop unrent %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% der verbleibenden Zeit)."
|
||||
"info-regionMaxExtends": "[darkgreen][bold]►[reset] Maximale Anzahl an Verlängerungen: [gray]%maxextends% ."
|
||||
"info-regionNoExtending": "[darkgreen][bold]►[reset] Miete kann nicht verlängert werden."
|
||||
"info-regionExtendsLeft": "[darkgreen][bold]►[reset] Verbleibende Mietverlängerungen: [gray]%extendsleft% von %maxextends% ."
|
||||
"info-regionMaxRentTime": "[darkgreen][bold]►[reset] Miete im Voraus: [gray]Maximal %maxrenttime%."
|
||||
"info-prefix": "[darkgreen][bold]►[reset] "
|
||||
"info-regionTeleport":
|
||||
- "[bold]Gehe zu der Region[/bold]"
|
||||
- " hover: %lang:action|Teleport to %region%|%"
|
||||
- " command: /areashop tp %region%"
|
||||
- "[bold]Gehe zu der Region[/bold]"
|
||||
- " hover: %lang:action|Teleport to %region%|%"
|
||||
- " command: /areashop tp %region%"
|
||||
"info-setRegionTeleport":
|
||||
- "[bold]Setze den Teleport Punkt[/bold]"
|
||||
- " hover: %region%"
|
||||
- " hover: %lang:action|Set teleport location|%"
|
||||
- " command: /areashop settp %region%"
|
||||
- "[bold]Setze den Teleport Punkt[/bold]"
|
||||
- " hover: %region%"
|
||||
- " hover: %lang:action|Set teleport location|%"
|
||||
- " command: /areashop settp %region%"
|
||||
"info-regionSigns": "[darkgreen][bold]►[reset] Verbundene Schilder: [gray]%0%."
|
||||
"info-regionSignLocation": "[gray](%0%, %1%, %2%, %3%)[reset]"
|
||||
"info-regionGroups": "[darkgreen][bold]►[reset] Zugewiesene Gruppen: [gray]%0%."
|
||||
@@ -377,10 +377,10 @@
|
||||
"addsign-couldNotDetectSign": "Mehrere Regionen um das Schild herum gefunden, bitte gewünschte Region in die zweite Zeile eintragen (zwei der gefundenen Regionen: %lang:tRegion|%0%|% und %lang:tRegion|%1%|%)."
|
||||
"addsign-wrongProfile": "Das eingetragene Profil existiert nicht. Bitte benutze eines der folgenden (überprüfe config): [gray]%0%."
|
||||
"addsign-profile":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Schildprofil %0%"
|
||||
- " hover: %lang:action|Use this profile|%"
|
||||
- " command: /areashop linksigns %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Schildprofil %0%"
|
||||
- " hover: %lang:action|Use this profile|%"
|
||||
- " command: /areashop linksigns %0%"
|
||||
"addsign-success": "Das Schild wurde hinzugefügt zu %lang:region%."
|
||||
"addsign-successProfile": "Das Schild wurde zu %lang:region% mit dem Profil %0% hinzugefügt."
|
||||
"addsign-alreadyRegistered": "Dieses Schild ist bereits für die Region %lang:region% registriert."
|
||||
@@ -393,16 +393,16 @@
|
||||
"me-header": "Regionen von %lang:tPlayer|%0%|%:"
|
||||
"me-notAPlayer": "Du bist kein Spieler, darum können dir keine Regionen gehören."
|
||||
"me-rentLine":
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%timeleft% übrig"
|
||||
- " hover: bis %until%"
|
||||
- ")."
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%timeleft% übrig"
|
||||
- " hover: bis %until%"
|
||||
- ")."
|
||||
"me-buyLine": "[darkgreen][bold]►[reset] %lang:region%."
|
||||
"me-friendLine":
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "Im Besitz von %lang:player%"
|
||||
- " hover: Du wurdest als Freund hinzugefügt"
|
||||
- ")."
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "Im Besitz von %lang:player%"
|
||||
- " hover: Du wurdest als Freund hinzugefügt"
|
||||
- ")."
|
||||
"me-nothing": "%lang:tPlayer|%0%|% hat keine gemieteten oder gekaufen Regionen und wurde nicht als Freund zu einem hinzugefügt."
|
||||
"me-noPlayer": "%0% konnte nicht gefunden werden, möglicherweise war er nie auf diesem Server."
|
||||
"me-clickHint": "[gray][italic]Klicke auf eine Region, um weitere Details zu erhalten."
|
||||
@@ -457,13 +457,13 @@
|
||||
"linksigns-noPermission": "Du hast keine Berechtigungen um den Schilder-Massenverbindungsmodus zu benutzen."
|
||||
"linksigns-stopped": "Schilder-Verbindungsmodus verlassen."
|
||||
"stack-help":
|
||||
- "/as stack <Menge> <Abstand> <Name> <rent|buy> [Gruppe]."
|
||||
- "[gray]<Menge> Nummer der Regionen, die erstellt werden."
|
||||
- "[gray]<Abstand> Block-Abstand zwischen den Regionen."
|
||||
- "[gray]<Name> Namen der Regionen (Nummer wird dahinter sein)."
|
||||
- "[gray]<rent|buy> Macht die Regionen zu kauf- oder Mietregionen"
|
||||
- "[gray][Gruppe] Eine Gruppe, die zu den erstellten Regionen hinzugefügt wird."
|
||||
- "Die Regionen werden in deiner Blickrichtung erstellt."
|
||||
- "/as stack <Menge> <Abstand> <Name> <rent|buy> [Gruppe]."
|
||||
- "[gray]<Menge> Nummer der Regionen, die erstellt werden."
|
||||
- "[gray]<Abstand> Block-Abstand zwischen den Regionen."
|
||||
- "[gray]<Name> Namen der Regionen (Nummer wird dahinter sein)."
|
||||
- "[gray]<rent|buy> Macht die Regionen zu kauf- oder Mietregionen"
|
||||
- "[gray][Gruppe] Eine Gruppe, die zu den erstellten Regionen hinzugefügt wird."
|
||||
- "Die Regionen werden in deiner Blickrichtung erstellt."
|
||||
"stack-accepted": "Erstelle %0% %1% Regionen mit %2% Blöcken Abstand, Namen beginnend mit %3% und einer Zahl dahinter. %4%"
|
||||
"stack-addToGroup": "Gruppe '%0%' wird zu den erstellten Regionen hinzugefügt."
|
||||
"stack-noPermission": "Du hast keine Berechtigungen um Regionen massenweise in AreaShop zu erstellen und hinzuzufügen."
|
||||
@@ -482,30 +482,30 @@
|
||||
"message-noPermission": "Du hast keine Berechtigung AreaShop Nachrichten zu senden."
|
||||
"message-notOnline": "%0% ist nicht online."
|
||||
"confirm-rent":
|
||||
- "%lang:prefix%Bist du sicher, dass du %lang:tRegion|%0%|% mieten willst?"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klick zum Mieten %0%|%"
|
||||
- "hover: %lang:action|Rent %0%|%"
|
||||
- "command: /areashop rent %0%"
|
||||
- "%lang:prefix%Bist du sicher, dass du %lang:tRegion|%0%|% mieten willst?"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klick zum Mieten %0%|%"
|
||||
- "hover: %lang:action|Rent %0%|%"
|
||||
- "command: /areashop rent %0%"
|
||||
"confirm-extend":
|
||||
- "%lang:prefix%Bist du sicher, dass du %lang:tRegion|%0%|% verlängern willst?"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klick zum Verlängern %0%|%"
|
||||
- "hover: %lang:action|Verlängern %0%|%"
|
||||
- "command: /areashop rent %0%"
|
||||
- "%lang:prefix%Bist du sicher, dass du %lang:tRegion|%0%|% verlängern willst?"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klick zum Verlängern %0%|%"
|
||||
- "hover: %lang:action|Verlängern %0%|%"
|
||||
- "command: /areashop rent %0%"
|
||||
"confirm-unrent":
|
||||
- "%lang:prefix%Bist du sicher, dass du %lang:tRegion|%0%|% nicht länger mieten möchtest?"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klick zum Auflösen %0%|%"
|
||||
- "hover: %lang:action|Mietvertrag auslösen %0%|%"
|
||||
- "command: /areashop unrent %0%"
|
||||
- "%lang:prefix%Bist du sicher, dass du %lang:tRegion|%0%|% nicht länger mieten möchtest?"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klick zum Auflösen %0%|%"
|
||||
- "hover: %lang:action|Mietvertrag auslösen %0%|%"
|
||||
- "command: /areashop unrent %0%"
|
||||
"confirm-buy":
|
||||
- "%lang:prefix% Bist du sicher das du %lang:tRegion|%0%|% kaufen möchtest?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click to buy %0%|%"
|
||||
- " hover: %lang:action|Buy %0%|%"
|
||||
- " command: /areashop buy %0% "
|
||||
- "%lang:prefix% Bist du sicher das du %lang:tRegion|%0%|% kaufen möchtest?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click to buy %0%|%"
|
||||
- " hover: %lang:action|Buy %0%|%"
|
||||
- " command: /areashop buy %0% "
|
||||
"confirm-sell":
|
||||
- "%lang:prefix% Bist du sicher, dass du %lang:tRegion|%0%|% verkaufen willst?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klick zum Verkaufen von %0%|%"
|
||||
- " hover: %lang:action|Verkaufe %0%|%"
|
||||
- " command: /areashop sell %0% "
|
||||
- "%lang:prefix% Bist du sicher, dass du %lang:tRegion|%0%|% verkaufen willst?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klick zum Verkaufen von %0%|%"
|
||||
- " hover: %lang:action|Verkaufe %0%|%"
|
||||
- " command: /areashop sell %0% "
|
||||
"timeleft-years": "%0% Jahre"
|
||||
"timeleft-months": "%0% Monate"
|
||||
"timeleft-days": "%0% Tage"
|
||||
@@ -518,4 +518,4 @@
|
||||
"greeting-rented": "%region% ist vermietet an %player% bis %until%."
|
||||
"greeting-forsale": "%region% kann gekauft werden für %price%."
|
||||
"greeting-bought": "%region% ist Eigentum von %player%."
|
||||
"greeting-resale": "%region% kann für %resellprice% von 1%player% gekauft werden."
|
||||
"greeting-resale": "%region% kann für %resellprice% von 1%player% gekauft werden."
|
||||
@@ -1,566 +0,0 @@
|
||||
# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
|
||||
# ║ Language file of the AreaShop plugin created by NLThijs48, Github can be found at https://github.com/NLthijs48/AreaShop
|
||||
# ║ English language file, plugin version 2.5.0
|
||||
# ║
|
||||
# ║ This file will be overwritten at each startup/reload of the plugin, if you want to change anything then do the following:
|
||||
# ║ 1: Make a copy of this file
|
||||
# ║ 2: Rename it to `servername.yml`
|
||||
# ║ 3: Change the `language` setting in config.yml to `servername`, do not include `.yml`
|
||||
# ║ 4: Change the messages in the new file to your liking
|
||||
# ║ 5: Use `/as reload`or reload/restart your server to see the changes
|
||||
# ╚═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
|
||||
action: "<gold><bold><%0%></bold>"
|
||||
|
||||
button: "<bold><%0%></bold>"
|
||||
|
||||
command:
|
||||
- "<click:run_command:%1%><hover:show_text:'<gold><bold>\\<Use %1%>'><bold>%0%</bold></hover></click>"
|
||||
|
||||
helpCommand:
|
||||
- "<click:run_command:%0%><hover:show_text:'<gold><bold>\\<Use %0%>'><gold>%0% <gray>- <reset>"
|
||||
|
||||
region: "%lang:tRegion|%region%|%"
|
||||
|
||||
tRegion:
|
||||
- "<click:run_command:/areashop info region %0%><hover:show_text:'Region %0%<newline>%lang:action|Region information|%'><bold>%0%</bold></hover></click>"
|
||||
|
||||
player: "%lang:tPlayer|%player%|%"
|
||||
|
||||
tPlayer:
|
||||
- "<click:run_command:/areashop info player %0%><hover:show_text:'Player %0%<newline>%lang:action|Regions of player %0%|%'><bold>%0%</bold></hover></click>"
|
||||
|
||||
landlord:
|
||||
- "<click:run_command:/areashop info player %landlord%><hover:show_text:'Landlord %landlord%\n%lang:action|Regions of %landlord%|%'><bold>%landlord%</bold></hover></click>"
|
||||
|
||||
total-maximum: "You can't rent and buy more than %0% region(s) in total (you already have %1% in group '%2%')."
|
||||
|
||||
confirm-yes: " <gray>Click to %lang:command|Confirm|%0%|%<gray>, or repeat the command."
|
||||
|
||||
general-notReady: "AreaShop has not fully loaded yet, please wait."
|
||||
general-noWorld: "You cannot do that, the world of %lang:region% is currently unavailable (world '%world%')."
|
||||
general-noRegion: "You cannot do that, the WorldGuard region is currently unavailable (region %lang:region%)."
|
||||
general-noEconomy: "There is no Economy plugin installed or it is not setup correctly, notify the server owner about this."
|
||||
general-cancelled: "%0%"
|
||||
|
||||
cmd-notValid: "That command is not valid, use '/as help' for info."
|
||||
cmd-onlyByPlayer: "This command can only be run by a player."
|
||||
cmd-weOnlyByPlayer: "Using a WorldEdit selection is only possible as a player, specify the region name as extra argument."
|
||||
cmd-noSelection: "You don't have a WorldEdit selection."
|
||||
cmd-noRegionsFound: "No regions registered in AreaShop are found in your selection."
|
||||
cmd-noWERegionsFound: "No WorldEdit regions intersecting your selection are found."
|
||||
cmd-notRegistered: "Region '%0%' is not available in AreaShop."
|
||||
cmd-noRegion: "'%0%' is not a valid WorldGuard region."
|
||||
cmd-noRegionsAtLocation: "No regions found at your location, specify the region as argument."
|
||||
cmd-moreRegionsAtLocation: "More than one region has been found at your location, specify the region as argument."
|
||||
cmd-automaticRegionOnlyByPlayer: "Automatically determining the region is only possible for players, specify the region as argument."
|
||||
|
||||
help-header: "Help page, commands that you can execute."
|
||||
help-noPermission: "You do not have permission to view the help page."
|
||||
help-alias: "Command aliases: /areashop, /as."
|
||||
help-help: "%lang:helpCommand|/as help|% Shows this help page."
|
||||
help-info: "%lang:helpCommand|/as info|% Get info about current regions."
|
||||
help-rent: "%lang:helpCommand|/as rent|% Rent a region or extend your current rent."
|
||||
help-buy: "%lang:helpCommand|/as buy|% Buy a region."
|
||||
help-unrent: "%lang:helpCommand|/as unrent|% Unrent a region."
|
||||
help-sell: "%lang:helpCommand|/as sell|% Sell a region."
|
||||
help-reload: "%lang:helpCommand|/as reload|% Reload all files and update the regions."
|
||||
help-setrestore: "%lang:helpCommand|/as setrestore|% Set restoring on/off and choose profile."
|
||||
help-setprice: "%lang:helpCommand|/as setprice|% Change the price of a region."
|
||||
help-setduration: "%lang:helpCommand|/as setduration|% Change the duration of a rent region."
|
||||
help-teleport: "%lang:helpCommand|/as tp|% Teleport to a rent/buy region."
|
||||
help-setteleport: "%lang:helpCommand|/as settp|% Set teleport position for a region."
|
||||
help-find: "%lang:helpCommand|/as find|% Find an empty buy or rent."
|
||||
help-groupadd: "%lang:helpCommand|/as groupadd|% Add a region to a group."
|
||||
help-groupdel: "%lang:helpCommand|/as groupdel|% Delete a region from a group."
|
||||
help-grouplist: "%lang:helpCommand|/as grouplist|% Display all groups currently registered."
|
||||
help-groupinfo: "%lang:helpCommand|/as groupinfo|% Display information about a group."
|
||||
help-schemevent: "%lang:helpCommand|/as schemevent|% Trigger a schematic event for a region."
|
||||
help-add: "%lang:helpCommand|/as add|% Register a region as rent or buy."
|
||||
help-del: "%lang:helpCommand|/as del|% Delete a registered region from AreaShop."
|
||||
help-addsign: "%lang:helpCommand|/as addsign|% Add a sign to an existing region."
|
||||
help-delsign: "%lang:helpCommand|/as delsign|% Delete the sign you are looking at."
|
||||
help-me: "%lang:helpCommand|/as me|% Check which regions you have (+expiration)."
|
||||
help-setowner: "%lang:helpCommand|/as setowner|% Set region owner or extend the rent."
|
||||
help-resell: "%lang:helpCommand|/as resell|% Put a region into resell mode."
|
||||
help-stopResell: "%lang:helpCommand|/as stopresell|% Put a region back into sold mode."
|
||||
help-addFriend: "%lang:helpCommand|/as addfriend|% Add a friend to a region."
|
||||
help-delFriend: "%lang:helpCommand|/as delfriend|% Delete a friend from a region."
|
||||
help-linksigns: "%lang:helpCommand|/as linksigns|% Use bulk sign linking mode."
|
||||
help-stack: "%lang:helpCommand|/as stack|% Create multiple regions and add them."
|
||||
help-setlandlord: "%lang:helpCommand|/as setlandlord|% Set the landlord of a region."
|
||||
help-import: "%lang:helpCommand|/as import|% Import region from RegionForSale."
|
||||
|
||||
rent-help: "/as rent [region], the region you stand in will be used if not specified."
|
||||
rent-noPermission: "You don't have permission to rent a region."
|
||||
rent-maximum: "You can't rent more than %0% region(s) (you already have %1% in group '%2%')."
|
||||
rent-maximumExtend: "You can't extend this rent because you have more than %0% region(s) (you already have %1% in group '%2%')."
|
||||
rent-payError: "Something went wrong with paying, try again later."
|
||||
rent-rented: "You rented %lang:region% until %until%, you can extend your rent by rightclicking the sign again or using /as rent."
|
||||
rent-extended: "You extended your rent of %lang:region% until %until%."
|
||||
rent-extendedToMax: "You extended your rent of %lang:region% until %until% (which is the maximum rental time of %maxrenttime%)."
|
||||
rent-lowMoneyExtend: "You don't have enough money to extend the rent (you have %0% and you need %price%)."
|
||||
rent-lowMoneyRent: "You don't have enough money to rent %lang:region% (you have %0% and you need %price%)."
|
||||
rent-someoneElse: "Someone else already rented %lang:region%."
|
||||
rent-notRentable: "Region '%0%' is not available for renting (not registered in AreaShop or it is a buy region)."
|
||||
rent-maxExtends: "You cannot extend this rent anymore (the maximum is %maxextends% times), however after the rent is over you can rent %lang:region% again."
|
||||
rent-maxRentTime: "You cannot rent %lang:region% more time in advance, the maximum time is %maxrenttime% and you have currently rented it for %timeleft%."
|
||||
rent-restrictedToWorld: "You need to be in the '%world%' world to rent %lang:region% (you are in '%0%')."
|
||||
rent-restrictedToRegion: "You need to be inside %lang:region% to rent it."
|
||||
rent-expireWarning: "Your region %lang:region% has %timeleft% left, be sure to extend it if you want to keep it."
|
||||
rent-expiringSoon: "Your region %lang:tRegion|%0%|% has %1% left, be sure to extend it if you want to keep it."
|
||||
rent-alreadyAtFull: "%lang:region% is already at or above the maximum rental time, you cannot extend it yet."
|
||||
|
||||
buy-help: "/as buy [region], the region you stand in will be used if not specified."
|
||||
buy-noPermission: "You don't have permission to buy a region."
|
||||
buy-noPermissionResell: "You don't have permission to buy a region in resell mode."
|
||||
buy-noPermissionNoResell: "You don't have permission to buy a region that is not in resell mode."
|
||||
buy-notBuyable: "Region '%0%' is not available for buying (not registered in AreaShop or it is a rental region)."
|
||||
buy-maximum: "You can't buy more than %0% region(s) (you already have %1% in group '%2%')."
|
||||
buy-payError: "Something went wrong with paying, try again later."
|
||||
buy-succes: "You successfully bought %lang:region%."
|
||||
buy-successResale: "You successfully bought %lang:region% from %lang:tPlayer|%0%|%."
|
||||
buy-successSeller: "Your region %lang:region% has been sold to %lang:player% for %0%."
|
||||
buy-lowMoney: "You don't have enough money to buy %lang:region% (you have %0% and you need %price%)."
|
||||
buy-lowMoneyResell: "You don't have enough money to buy %lang:region% (you have %0% and you need %resellprice%)."
|
||||
buy-yours: "You already own %lang:region%."
|
||||
buy-someoneElse: "Someone else already bought %lang:region%."
|
||||
buy-restrictedToWorld: "You need to be in the '%world%' world to buy %lang:region% (you are in '%0%')."
|
||||
buy-restrictedToRegion: "You need to be inside %lang:region% to buy it."
|
||||
|
||||
unrent-help: "/as unrent [region], the region you stand in will be used if not specified."
|
||||
unrent-noPermission: "You don't have permission to unrent a region."
|
||||
unrent-noPermissionOther: "You don't have permission to unrent another region."
|
||||
unrent-notRegistered: "The region can't be unrented because it is not registered for renting."
|
||||
unrent-notRented: "The region can't be unrented because it is not rented."
|
||||
unrent-unrented: "%lang:region% of %lang:player% has been unrented."
|
||||
unrent-expired: "Your rent of %lang:region% has expired."
|
||||
|
||||
sell-help: "/as sell [region], the region you stand in will be used if not specified."
|
||||
sell-notRegistered: "The region can't be sold because it is not registered for buying."
|
||||
sell-notBought: "The region can't be sold because it is not someone's property."
|
||||
sell-sold: "%lang:region% of %lang:player% has been sold."
|
||||
sell-noPermission: "You don't have permission to sell a region."
|
||||
sell-noPermissionOther: "You don't have permission to sell another region."
|
||||
sell-disabled: "Selling has been disabled for this region."
|
||||
|
||||
reload-reloading: "Reloaded all configuration and region files."
|
||||
reload-updateStart: ""
|
||||
reload-updateComplete: ""
|
||||
reload-noPermission: "You don't have permission to reload the config files."
|
||||
reload-updateCommandChanged: "'/as updaterents' and '/as updatebuys' have been removed, '/as reload' will also update the regions now so use that command instead."
|
||||
|
||||
info-help:
|
||||
- "/as info<newline>"
|
||||
- " %lang:command|all|/as info all|%<newline>"
|
||||
- " %lang:command|rented|/as info rented|% [group] [page]<newline>"
|
||||
- " %lang:command|forrent|/as info forrent|% [group] [page]<newline>"
|
||||
- " %lang:command|sold|/as info sold|% [group] [page]<newline>"
|
||||
- " %lang:command|forsale|/as info forsale|% [group] [page]<newline>"
|
||||
- " %lang:command|reselling|/as info reselling|% [group] [page]<newline>"
|
||||
- " %lang:command|nogroup|/as info nogroup [page]|%<newline>"
|
||||
- " %lang:command|region|/as info region|% <region>"
|
||||
info-noPermission: "You don't have permission to get information about regions."
|
||||
info-allHeader: "All regions%0%:"
|
||||
info-rentedHeader: "Rented regions%0%:"
|
||||
info-forrentHeader: "For rent regions%0%:"
|
||||
info-forsaleHeader: "For sale regions%0%:"
|
||||
info-soldHeader: "Sold regions%0%:"
|
||||
info-resellingHeader: "Reselling regions%0%:"
|
||||
info-nogroupHeader: "Regions without group%0%:"
|
||||
info-limitedToGroup: " (limited to group %0%)"
|
||||
info-nogroupNone: "There are no regions without a group."
|
||||
info-noFiltergroup: "Group '%0%' does not exist and therefore cannot be used to limit the results."
|
||||
info-noRegions: "No regions have been found."
|
||||
info-wrongPage: "%0% is not a correct page number."
|
||||
info-entryForrent: "<dark_green><bold>►<reset> %lang:region%: <gray>For rent for %price% per %duration%."
|
||||
info-entryRented: "<dark_green><bold>►<reset> %lang:region%: <gray>Rented to %lang:player%."
|
||||
info-entryForsale: "<dark_green><bold>►<reset> %lang:region%: <gray>For sale for %price%."
|
||||
info-entrySold: "<dark_green><bold>►<reset> %lang:region%: <gray>Sold to %lang:player%."
|
||||
info-entryReselling: "<dark_green><bold>►<reset> %lang:region%: <gray>Sold to %lang:player% (reselling)."
|
||||
info-pageStatus:
|
||||
- "<gold>Page %0%/%1%"
|
||||
info-pagePrevious:
|
||||
- " <click:run_command:/areashop %0%><hover:show_text:'%lang:action|Show previous page|%'><gold><bold>◄Previous</bold></hover></click> "
|
||||
info-pageNoPrevious:
|
||||
- " <hover:show_text:'This is already the first page'><dark_gray><bold>◄Previous</bold></hover> "
|
||||
info-pageNext:
|
||||
- " <click:run_command:/areashop %0%><hover:show_text:'%lang:action|Show next page|%'><gold><bold>Next►</bold></hover></click> "
|
||||
info-pageNoNext:
|
||||
- " <hover:show_text:'This is already the last page'><dark_gray><bold>Next►</bold></hover> "
|
||||
info-playerHelp: "/as info player [name]."
|
||||
info-playerRents: "Regions rented by %lang:tPlayer|%0%|%: <gray>%1%"
|
||||
info-playerNoRents: "%lang:tPlayer|%0%|% has not rented a region."
|
||||
info-playerBuys: "Regions bought by %lang:tPlayer|%0%|%: <gray>%1%."
|
||||
info-playerNoBuys: "%lang:tPlayer|%0%|% has not bought a region."
|
||||
info-regionHelp: "/as info region [name], the region you stand in will be used if not specified."
|
||||
info-regionHeaderRent: "<dark_green>Information about %lang:region%:"
|
||||
info-regionHeaderBuy: "<dark_green>Information about %lang:region%:"
|
||||
info-regionFooterRent: ""
|
||||
info-regionFooterBuy: ""
|
||||
info-regionRented: "<dark_green><bold>►<reset> Rented by %lang:player% until: <gray>%until%."
|
||||
info-regionBought: "<dark_green><bold>►<reset> Bought by %lang:player%."
|
||||
info-regionReselling: "<dark_green><bold>►<reset> Bought by %lang:player%, currently reselling."
|
||||
info-regionExtending:
|
||||
- "<dark_green><bold>►<reset> "
|
||||
- "<click:run_command:/areashop rent %region%><hover:show_text:'Extend rent of %region% with %duration% for %price%<newline>%lang:action|Extend rent of %region%|%'><bold>Extend for</bold></hover></click>"
|
||||
- ": <gray>%price% per %duration%."
|
||||
info-regionCanBeRented:
|
||||
- "<dark_green><bold>►<reset> "
|
||||
- "<click:run_command:/areashop rent %region%><hover:show_text:'Rent %region% for %price% per %duration%<newline>%lang:action|Rent %region%|%'><bold>Rent for</bold></hover></click>"
|
||||
- ": <gray>%price% per %duration%."
|
||||
info-regionCanBeBought:
|
||||
- "<dark_green><bold>►<reset> "
|
||||
- "<click:run_command:/areashop buy %region%><hover:show_text:'Buy %region% for %price%<newline>%lang:action|Buy %region%|%'><bold>Buy for</bold></hover></click>"
|
||||
- ": <gray>%price%."
|
||||
info-regionReselPrice: "<dark_green><bold>►<reset> Resell price: <gray>%resellprice% (you can buy it from %lang:player%)."
|
||||
info-regionFriends: "<dark_green><bold>►<reset> Added friends: <gray>%0%."
|
||||
info-friend: "%lang:tPlayer|%0%|%"
|
||||
info-friendRemove:
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "<click:run_command:/areashop delfriend %0% %region%><hover:show_text:'Region %region%<newline>%lang:action|Remove %0% as friend|%'><red>✕<gray></hover></click>"
|
||||
info-regionMoneyBackBuy:
|
||||
- "<dark_green><bold>►<reset> Selling payback: <gray>%moneyback% (%moneybackpercent%% of the price)."
|
||||
info-regionMoneyBackBuyClick:
|
||||
- "<dark_green><bold>►<reset> "
|
||||
- "<click:run_command:/areashop sell %region%><hover:show_text:'Sell %region% and get back %moneyback%<newline>%lang:action|Sell %region%|%'><bold>Selling payback</bold></hover></click>"
|
||||
- ": <gray>%moneyback% (%moneybackpercent%% of the price)."
|
||||
info-regionMoneyBackRent:
|
||||
- "<dark_green><bold>►<reset> Unrenting payback: <gray>%moneyback% (%moneybackpercent%% of the remaining time)."
|
||||
info-regionMoneyBackRentClick:
|
||||
- "<dark_green><bold>►<reset> "
|
||||
- "<click:run_command:/areashop unrent %region%><hover:show_text:'Unrent %region% and get back %moneyback%<newline>%lang:action|Unrent %region%|%'><bold>Unrenting payback</bold></hover></click>"
|
||||
- ": <gray>%moneyback% (%moneybackpercent%% of the remaining time)."
|
||||
info-regionMaxExtends: "<dark_green><bold>►<reset> Maximum number of extensions: <gray>%maxextends% time(s)."
|
||||
info-regionNoExtending: "<dark_green><bold>►<reset> Rent cannot be extended."
|
||||
info-regionExtendsLeft: "<dark_green><bold>►<reset> Extensions left: <gray>%extendsleft% time(s) out of %maxextends%."
|
||||
info-regionMaxRentTime: "<dark_green><bold>►<reset> In advance renting: <gray>%maxrenttime% at maximum."
|
||||
info-prefix: "<dark_green><bold>►<reset> "
|
||||
info-regionTeleport:
|
||||
- "<click:run_command:/areashop tp %region%><hover:show_text:'%lang:action|Teleport to %region%|%'><bold>Go to the region</bold></hover></click>"
|
||||
info-setRegionTeleport:
|
||||
- "<click:run_command:/areashop settp %region%><hover:show_text:'%region%<newline>%lang:action|Set teleport location|%'><bold>set teleport location</bold></hover></click>"
|
||||
info-regionSigns: "<dark_green><bold>►<reset> Connected signs: <gray>%0%."
|
||||
info-regionSignLocation: "<gray>(%0%, %1%, %2%, %3%)<reset>"
|
||||
info-regionGroups: "<dark_green><bold>►<reset> Assigned groups: <gray>%0%."
|
||||
info-regionInactiveUnrent: "<dark_green><bold>►<reset> Auto unrent after: <gray>%inactivetime% of inactivity by the player."
|
||||
info-regionInactiveSell: "<dark_green><bold>►<reset> Auto sell after: <gray>%inactivetime% of inactivity by the player."
|
||||
info-regionRestrictedRegionRent: "<dark_green><bold>►<reset> You must be inside %lang:region% to rent it."
|
||||
info-regionRestrictedWorldRent: "<dark_green><bold>►<reset> You need to be inside world '%world%' to rent %lang:region%."
|
||||
info-regionRestrictedRegionBuy: "<dark_green><bold>►<reset> You must be inside %lang:region% to buy it."
|
||||
info-regionRestrictedWorldBuy: "<dark_green><bold>►<reset> You need to be inside world '%world%' to buy %lang:region%."
|
||||
info-regionRestoringRent: "<dark_green><bold>►<reset> Restoring is enabled <gray>(region will reset at unrent)."
|
||||
info-regionRestoringBuy: "<dark_green><bold>►<reset> Restoring is enabled <gray>(region will reset at sell)."
|
||||
info-regionLandlord: "<dark_green><bold>►<reset> Landlord: <gray>%lang:landlord% (receives the money)."
|
||||
info-regionNotExisting: "The specified region is not registered: %0%."
|
||||
|
||||
setrestore-help: "/as setrestore [region] [true|false|general] [profile]."
|
||||
setrestore-noPermission: "You don't have permission to change the restore settings."
|
||||
setrestore-notRegistered: "The specified region is not registered: %0%."
|
||||
setrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or general."
|
||||
setrestore-success: "Successfully set the restore setting of %lang:region% to '%0%'."
|
||||
setrestore-successProfile: "Successfully set the restore setting of %lang:region% to '%0%' and the profile to '%1%'."
|
||||
|
||||
setprice-noPermission: "You don't have permission to change the price of a region."
|
||||
setprice-help: "/as setprice [price] [region], the region you stand in will be used if not specified."
|
||||
setprice-notRegistered: "The specified region is not registered: %0%."
|
||||
setprice-wrongPrice: "'%0%' is not a valid price."
|
||||
setprice-successRent: "Price of region %lang:region% changed to %price% per %duration%."
|
||||
setprice-successBuy: "Price of region %lang:region% changed to %price%."
|
||||
setprice-successRemoved: "Price of %lang:region% has been removed, it will now use the price from a group or the default.yml file, new price: %price%."
|
||||
setprice-noLandlord: "You don't have permission to change the price because you are not the landlord of %lang:region%."
|
||||
|
||||
setduration-noPermission: "You don't have permission to change the duration of a rent."
|
||||
setduration-help: "/as setduration [amount] [identifier] [region], the region you stand in will be used if not specified."
|
||||
setduration-notRegistered: "%0% is not registered for renting."
|
||||
setduration-wrongAmount: "'%0%' is not a valid amount, use a whole number."
|
||||
setduration-wrongFormat: "'%0%' is not a proper timeformat, check the documentation on Bukkit."
|
||||
setduration-success: "Duration of region %lang:region% changed to '%duration%'."
|
||||
setduration-noLandlord: "You don't have permission to change the duration because you are not the landlord of %lang:region%."
|
||||
setduration-successRemoved: "Duration of %lang:region% has been removed, it will now use the duration from a group or the default.yml file, new duration: %duration%."
|
||||
|
||||
setup-noRegion: "You did not specify a region on the second line."
|
||||
setup-alreadyRentSign: "The region you specified is already added to AreaShop as a rent region, add signs with <as> on the first line or '/as addsign'."
|
||||
setup-alreadyOtherWorld: "The region you specified is already added to AreaShop in another world, regions from different worlds still need different names."
|
||||
setup-alreadyBuySign: "The region you specified is already added to AreaShop as a buy region, add signs with <as> on the first line or '/as addsign'."
|
||||
setup-noDuration: "You did not specify how long the region can be rented, do this on the third line."
|
||||
setup-wrongDuration: "The time specified is not in the correct format, example: 1 day."
|
||||
setup-noPrice: "You did not specify the price on the fourth line."
|
||||
setup-wrongPrice: "You did not specify the price correctly, use numbers only."
|
||||
setup-rentSuccess: "Renting of region %lang:region% is setup correctly."
|
||||
setup-buySuccess: "Buying of region %lang:region% is setup correctly."
|
||||
setup-noPermissionRent: "You don't have permission for setting up rental regions."
|
||||
setup-noPermissionBuy: "You don't have permission for setting up buy regions."
|
||||
setup-couldNotDetect: "Found multiple regions with the same priority and/or parent/child relation, specify one on the second line (2 of the regions that were found: %lang:tRegion|%0%|% and %lang:tRegion|%1%|%)."
|
||||
setup-blacklisted: "%0% is on the blacklist and cannot be added to AreaShop."
|
||||
setup-noPermission: "You cannot add the region '%0%', you are not an owner/member or don't have the permission for it."
|
||||
|
||||
destroy-noPermissionRent: "You don't have permission for deregistering a rental region."
|
||||
destroy-noPermissionBuy: "You don't have permission for deregistering a buy region."
|
||||
destroy-successRent: "%lang:region% successfully deregistered as rental region."
|
||||
destroy-successBuy: "%lang:region% successfully deregistered as buy region."
|
||||
|
||||
teleport-help: "/as tp [region] [sign]."
|
||||
teleport-noRentOrBuy: "The specified region is not registered: %0%."
|
||||
teleport-noPermission: "You don't have permission to teleport to your region."
|
||||
teleport-noPermissionOther: "You don't have permission to teleport to regions you do not own."
|
||||
teleport-noPermissionSign: "You don't have permission to teleport to the sign of your region."
|
||||
teleport-noPermissionOtherSign: "You don't have permission to teleport to signs of regions you do not own."
|
||||
teleport-noPermissionFriend: "You don't have permission to teleport to regions you are added to as a friend."
|
||||
teleport-noPermissionFriendSign: "You don't have permission to teleport to the sign of regions you are added to as a friend."
|
||||
teleport-noPermissionAvailable: "You don't have permission to teleport to available regions."
|
||||
teleport-noPermissionAvailableSign: "You don't have permission to teleport to the sign of available regions."
|
||||
teleport-success: "You teleported to %lang:region%."
|
||||
teleport-successSign: "You teleported to the sign of %lang:region%."
|
||||
teleport-noSafe: "No safe position found in %lang:region%, no spots in the region left or maximum tries exceeded (%0%/%1%)."
|
||||
teleport-blocked: "You can't teleport because the position is outside the region, and you are forced to teleport inside."
|
||||
teleport-changedToSign: "You only have permission to teleport to the sign and not inside the region, teleporting to sign."
|
||||
teleport-changedToNoSign: "No sign available to teleport to, trying to teleport inside the region instead."
|
||||
teleport-wrongWorld: "You need to be in world '%world%' to teleport to %lang:region%, but you are in world '%0%'."
|
||||
|
||||
setteleport-help: "/as settp [region] [reset], the region you stand in will be used if not specified."
|
||||
setteleport-noPermission: "You don't have permission to set the teleport location."
|
||||
setteleport-noPermissionOther: "You don't have permission to set the teleport location for a region you do not own."
|
||||
setteleport-noRentOrBuy: "The specified region is not registered: %0%."
|
||||
setteleport-success: "Teleport location of %lang:region% set."
|
||||
setteleport-notInside: "The location has to be inside the region."
|
||||
setteleport-reset: "Teleport location of %lang:region% has been reset."
|
||||
|
||||
find-help: "/as find [buy|rent] [maxprice] [group]."
|
||||
find-noPermission: "You don't have permission to search regions and teleport to them."
|
||||
find-success: "Found a %0% region: %lang:region%, while searching with a max price of your balance: %1%%2%."
|
||||
find-successMax: "Found a %0% region: %lang:region%, while searching with a max price of %1%%2%."
|
||||
find-wrongMaxPrice: "The specified maximum price is not a correct number: %0%."
|
||||
find-wrongGroup: "The specified group does not exist: %0%."
|
||||
find-noneFound: "No %0% region found while searching with a max price of your balance: %1%%2%."
|
||||
find-noneFoundMax: "No %0% region found while searching with a max price of %1%%2%."
|
||||
find-onlyInGroup: ", only searched for regions in group: %0%."
|
||||
|
||||
groupadd-help: "/as groupadd [group] [region], if no region specified all regions from your WorldEdit selection are used."
|
||||
groupadd-noPermission: "You don't have permission to add regions to groups."
|
||||
groupadd-success: "Region %lang:region% has been added to group '%0%', this group now has %1% member(s)."
|
||||
groupadd-failed: "Region %lang:region% is already a member of group '%0%'."
|
||||
groupadd-weSuccess: "Added to group %0%: <gray>%1%."
|
||||
groupadd-weFailed: "Were already in group %0%: <gray>%1%."
|
||||
|
||||
groupdel-help: "/as groupdel [group] [region], if no region specified all regions from your WorldEdit selection are used."
|
||||
groupdel-noPermission: "You don't have permission to remove regions from groups."
|
||||
groupdel-wrongGroup: "Group %0% not found, check '/as grouplist' for registered groups."
|
||||
groupdel-success: "Region %lang:region% has been removed from group '%0%', this group now has %1% member(s)."
|
||||
groupdel-failed: "Region %lang:region% is not a member of group '%0%'."
|
||||
groupdel-weSuccess: "Removed from group %0%: <gray>%1%."
|
||||
groupdel-weFailed: "Were not in group %0% anyway: <gray>%1%."
|
||||
|
||||
grouplist-noPermission: "You don't have permission to display the registered groups."
|
||||
grouplist-noGroups: "There are currently no groups registered."
|
||||
grouplist-success: "The following groups are registered: <gray>%0%."
|
||||
|
||||
groupinfo-help: "/as groupinfo [group]."
|
||||
groupinfo-noPermission: "You don't have permission to display information about a group."
|
||||
groupinfo-noGroup: "There is no group registered with the name '%0%', use /as grouplist to check groups."
|
||||
groupinfo-members: "The following regions are member of group %0%: <gray>%1%."
|
||||
groupinfo-noMembers: "Group %0% does not have any members."
|
||||
|
||||
schemevent-help: "/as schemevent [region] [created|deleted|rented|unrented|bought|sold]."
|
||||
schemevent-wrongEvent: "The specified event '%0%' does not exist, use one of the following: <gray>%1%."
|
||||
schemevent-success: "Event '%0%' has successfully been triggered for region %lang:region%."
|
||||
schemevent-noPermission: "You don't have permission to trigger schematic events."
|
||||
|
||||
add-help: "/as add [rent|buy] [region] [world]."
|
||||
add-noPermission: "You don't have permission to add a region to AreaShop."
|
||||
add-success: "Added as %0%: <gray>%1%."
|
||||
add-failed: "Already registered: <gray>%0%."
|
||||
add-failedOtherWorld: "Already registered from another world: <gray>%0%."
|
||||
add-blacklisted: "On the blacklist: <gray>%0%."
|
||||
add-rentCancelled: "Rent cancelled: <gray>%0%."
|
||||
add-buyCancelled: "Buy cancelled: <gray>%0%."
|
||||
add-addCancelled: "Add cancelled: <gray>%0%."
|
||||
add-specifyWorld: "Specify the world of the region when using from console."
|
||||
add-incorrectWorld: "World '%0%' not found, try again (case-sensitive)."
|
||||
add-noPermissionRegions: "No permission to add: <gray>%0%."
|
||||
add-noPermissionOwnerMember: "<gray>You either are not a member/owner of these regions or have no permission to add your regions."
|
||||
|
||||
del-noPermission: "You don't have permission to remove regions."
|
||||
del-success: "Removed regions: <gray>%0%."
|
||||
del-failed: "No permission to remove or not registered: <gray>%0%."
|
||||
del-cancelled: "Delete cancelled: <gray>%0%."
|
||||
|
||||
addsign-help: "/as addsign [region] [profile]."
|
||||
addsign-noSign: "You are not looking at a sign."
|
||||
addsign-noRegions: "No region found around the sign position."
|
||||
addSign-notRegistered: "The specified region is not registered in AreaShop: %0% (it first needs to be added to AreaShop before a sign can be added)."
|
||||
addsign-couldNotDetect: "Found multiple regions around the sign, specify region as extra argument (2 of the regions that were found: %lang:tRegion|%0%|% and %lang:tRegion|%1%|%)."
|
||||
addsign-couldNotDetectSign: "Found multiple regions around the sign, specify region on the second line (2 of the regions that were found: %lang:tRegion|%0%|% and %lang:tRegion|%1%|%)."
|
||||
addsign-wrongProfile: "The specified profile does not exist, use one of the following (check config): <gray>%0%."
|
||||
addsign-profile:
|
||||
- "<click:run_command:/areashop linksigns %0%><hover:show_text:'Signprofile %0%<newline>%lang:action|Use this profile|%'><bold>%0%</bold></hover></click>"
|
||||
addsign-success: "The sign has been added to %lang:region%."
|
||||
addsign-successProfile: "The sign has been added to %lang:region% with profile %0%."
|
||||
addsign-alreadyRegistered: "That sign is already registered for region %lang:region%."
|
||||
addsign-noPermission: "You don't have permission to add a sign."
|
||||
|
||||
delsign-noSign: "You are not looking at a sign."
|
||||
delsign-noPermission: "You don't have permission to delete a sign."
|
||||
delsign-noRegion: "That sign does not belong to an AreaShop region."
|
||||
delsign-success: "The sign has been removed from region %lang:region%."
|
||||
|
||||
me-noPermission: "You don't have permission to check which regions you have."
|
||||
me-header: "Regions of %lang:tPlayer|%0%|%:"
|
||||
me-notAPlayer: "You are not a player so you can't have any regions."
|
||||
me-rentLine:
|
||||
- "<dark_green><bold>►<reset> %lang:region% <gray>("
|
||||
- "<hover:show_text:'until %until%'>%timeleft% left</hover>"
|
||||
- ")."
|
||||
me-buyLine: "<dark_green><bold>►<reset> %lang:region%."
|
||||
me-friendLine:
|
||||
- "<dark_green><bold>►<reset> %lang:region% <gray>("
|
||||
- "<hover:show_text:'You are added as friend'>owned by %lang:player%</hover>"
|
||||
- ")."
|
||||
me-nothing: "%lang:tPlayer|%0%|% has not rented or bought regions and is not added as friend to one."
|
||||
me-noPlayer: "%0% cannot be found, probably never joined the server."
|
||||
me-clickHint: "<gray><italic>Click a region name to see details."
|
||||
|
||||
setowner-help: "/as setowner [player] [region], the region you stand in will be used if not specified."
|
||||
setowner-noPermission: "You don't have permission to set the owner of a region."
|
||||
setowner-noPermissionRent: "You don't have permission to set the owner of rent regions."
|
||||
setowner-noPermissionBuy: "You don't have permission to set the owner of buy regions."
|
||||
setowner-notRegistered: "The specified region is not registered, owner cannot be set."
|
||||
setowner-noPlayer: "Could not get the UUID of the specified player: %0%."
|
||||
setowner-succesRent: "Owner of %lang:region% successfully changed to %lang:player%, rented until %until% (%timeleft% left)."
|
||||
setowner-succesRentExtend: "Owner was already %lang:player%, rent extended with '%duration%', now rented until %until% (%timeleft% left)."
|
||||
setowner-succesBuy: "Owner of %lang:region% successfully changed to %lang:player%."
|
||||
|
||||
resell-help: "/as resell [price] [region], the region you stand in will be used if not specified."
|
||||
resell-wrongPrice: "'%0%' is not a valid price."
|
||||
resell-notRegistered: "The specified region is not registered: %0%."
|
||||
resell-notBought: "You can't resell %lang:region% because it is not sold yet."
|
||||
resell-success: "%lang:region% is successfully put into reselling mode for %resellprice%."
|
||||
resell-noPermission: "You don't have permission to set your region in reselling mode."
|
||||
resell-noPermissionOther: "You don't have permission to set regions in reselling mode."
|
||||
resell-disabled: "Reselling has been disabled for this region."
|
||||
|
||||
stopresell-help: "/as stopresell [region], the region you stand in will be used if not specified."
|
||||
stopresell-notRegistered: "The specified region is not registered: %0%."
|
||||
stopresell-notResell: "You can't stop reselling %lang:region% because it is not in resell mode."
|
||||
stopresell-success: "%lang:region% is successfully put back into sold mode."
|
||||
stopresell-noPermission: "You don't have permission to set your region back to sold mode."
|
||||
stopresell-noPermissionOther: "You don't have permission to set regions back to sold mode."
|
||||
|
||||
addfriend-help: "/as addfriend [player] [region], the region you stand in will be used if not specified."
|
||||
addfriend-noPermissionOther: "You don't have permission to add friends to regions that are not yours."
|
||||
addfriend-noPermission: "You don't have permission to add friends to your region."
|
||||
addfriend-successOther: "%lang:tPlayer|%0%|% has been added as friend to region %lang:region%."
|
||||
addfriend-success: "%lang:tPlayer|%0%|% has been added as friend to your region %lang:region%."
|
||||
addfriend-alreadyAdded: "%lang:tPlayer|%0%|% is already added as friend to %lang:region%."
|
||||
addfriend-self: "Adding the owner of the region as friend would be pointless."
|
||||
addfriend-noOwner: "You cannot add friends to a region without owner."
|
||||
addfriend-notVisited: "You cannot add %0% because he did not visit the server yet."
|
||||
|
||||
delfriend-help: "/as delfriend [player] [region], the region you stand in will be used if not specified."
|
||||
delfriend-noPermissionOther: "You don't have permission to delete friends from regions that are not yours."
|
||||
delfriend-noPermission: "You don't have permission to delete friends from your region."
|
||||
delfriend-successOther: "%lang:tPlayer|%0%|% has been deleted as friend from region %lang:region%."
|
||||
delfriend-success: "%lang:tPlayer|%0%|% has been deleted as friend from your region %lang:region%."
|
||||
delfriend-notAdded: "%lang:tPlayer|%0%|% is not added as friend to %lang:region%."
|
||||
delfriend-noOwner: "You cannot remove friends from a region without owner."
|
||||
|
||||
linksigns-multipleRegions: "Found multiple regions: <gray>%0%."
|
||||
linksigns-multipleRegionsAdvice: "Click another time to try again or use '/as linksigns' to stop."
|
||||
linksigns-noRegions: "No AreaShop regions found in the direction of your cursor, make sure the region is added to AreaShop <gray>(maximum range 100 blocks)."
|
||||
linksigns-regionFound: "Region %lang:region% has been found, now point to a sign and leftclick to link it."
|
||||
linksigns-signFound: "Found a sign at (%0%, %1%, %2%), now point towards a region and rightclick to link it"
|
||||
linksigns-noSign: "No sign found in the direction of your cursor, make sure you have a direct sight to a sign and click again <gray>(maximum range 100 blocks)."
|
||||
linksigns-alreadyRegistered: "That sign is already registered for region %lang:region%, click again to select another sign."
|
||||
linksigns-first: "You have entered sign linking mode."
|
||||
linksigns-next: "<gray>Leftclick to select a sign, rightclick to select a region, use /as linksigns to stop."
|
||||
linksigns-noPermission: "You don't have permission to enter bulk sign linking mode."
|
||||
linksigns-stopped: "Exited sign linking mode."
|
||||
|
||||
stack-help:
|
||||
- "/as stack [amount] [gap] [name] [rent|buy] [group].<newline>"
|
||||
- " <gray>[amount] Number of regions that will be created.<newline>"
|
||||
- " <gray>[gap] Blocks distance between the regions.<newline>"
|
||||
- " <gray>[name] Name of the regions (number will be behind it).<newline>"
|
||||
- " <gray>[rent|buy] Make then rent or buy regions.<newline>"
|
||||
- " <gray>[group] A group to add the created regions to.<newline>"
|
||||
- " <gray>The regions will be created in the direction you are facing."
|
||||
stack-accepted: "Starting to create %0% %1% regions with %2% blocks in between, names start with %3% and have a number behind them.%4%"
|
||||
stack-addToGroup: " Created regions will be added to the group '%0%'."
|
||||
stack-noPermission: "You don't have permission to create and add regions to AreaShop in bulk."
|
||||
stack-wrongAmount: "'%0%' is not a correct amount of regions."
|
||||
stack-wrongGap: "'%0%' is not a correct number for the number of blocks gap between regions."
|
||||
stack-noSelection: "You don't have a selection that indicates where the first region should be created."
|
||||
stack-addStart: "<gray>Adding %0% regions at %1% per second."
|
||||
stack-addComplete: "<gray>Added %0% regions%1%."
|
||||
stack-tooHigh: ", %0% regions skipped because they were above Y=256"
|
||||
stack-tooLow: ", %0% regions skipped because they were below Y=0"
|
||||
stack-unclearDirection: "Please look clearly in the north, east, south, west, up or down direction, currently detected %0%."
|
||||
|
||||
setlandlord-help: "/as setlandlord [player] [region], the region you stand in will be used if not specified."
|
||||
setlandlord-noPermission: "You don't have permission to set the landlord for a region."
|
||||
setlandlord-success: "%lang:landlord% has successfully been set as landlord of %lang:region%."
|
||||
|
||||
message-help: "/as message [player] [message...]"
|
||||
message-noPermission: "You do not have permission to send AreaShop messages."
|
||||
message-notOnline: "%0% is not online."
|
||||
|
||||
import-help: "/as import RegionForSale"
|
||||
import-wrongSource: "Specify from where you want to import data, options: RegionForSale."
|
||||
import-noPluginFolder: "Could not find the %0% folder, are you sure you are importing from the correct source?"
|
||||
import-noWorldsFolder: "There is no 'plugins/RegionForSale/worlds' folder, therefore nothing could be imported."
|
||||
import-confirm: "Are you sure you want to import all regions from RegionForSale?"
|
||||
import-start: "Starting import of RegionForSale data:"
|
||||
import-doWorld: "<dark_green><bold>► World %0%:"
|
||||
import-noBukkitWorld: "<red>Could not find world in Bukkit."
|
||||
import-noRegionManager: "<red>Could not get RegionManager from WorldGuard, are regions enabled in this world?"
|
||||
import-noRegions: "<red>No regions.yml file found."
|
||||
import-loadRegionsFailed: "<red>Could not load regions.yml at: %0%"
|
||||
import-invalidRegionSection: "<red>Invalid section in regions.yml: %0%."
|
||||
import-noWorldGuardRegion: "<red>WorldGuard region not found: %0%."
|
||||
import-noWorldGuardRegionParent: "<red>WorldGuard region for parent region not found: %0%."
|
||||
import-buyAndRent: "<gold>%0% can be bought and rented, only adding as buy in AreaShop (cannot be both)."
|
||||
import-noBuyAndNoRent: "<red>%0% cannot be bought and cannot be rented, skipping import."
|
||||
import-imported: "<green>%lang:tRegion|%0%|% imported."
|
||||
import-loadWorldConfigFailed: "<red>Loading world-specific config.yml failed: %0%."
|
||||
import-improperParentRegion: "<red>Parent region %0% does not have readable settings."
|
||||
import-alreadyAdded: "<red>Region '%0%' has already been added."
|
||||
import-alreadyAddedOtherWorld: "<red>Region '%0%' has already been added in world %1%, regions in different worlds cannot have the same name in AreaShop."
|
||||
import-invalidSignLocation: "<red>Failed to import a sign of region '%0%', invalid location: '%1%'."
|
||||
import-signAlreadyAdded: "<red>Skipped adding sign at location '%1%' to region '%0%', it is already added to region '%2%'."
|
||||
import-moneyBackFailed: "<red>Failed to parse buy price '%0%' and sell price '%1%' to set the money back percentage."
|
||||
|
||||
confirm-rent:
|
||||
- "%lang:prefix%Are you sure you want to rent %lang:tRegion|%0%|%?<newline>"
|
||||
- "<click:run_command:/areashop rent %0%><hover:show_text:'%lang:action|Rent %0%|%'><dark_green><bold>►<reset> %lang:button|Click to rent %0%|%</hover></click>"
|
||||
confirm-extend:
|
||||
- "%lang:prefix%Are you sure you want to extend %lang:tRegion|%0%|%?<newline>"
|
||||
- "<click:run_command:/areashop rent %0%><hover:show_text:'%lang:action|Extend %0%|%'><dark_green><bold>►<reset> %lang:button|Click to extend %0%|%</hover></click>"
|
||||
confirm-unrent:
|
||||
- "%lang:prefix%Are you sure you want to stop renting %lang:tRegion|%0%|%?<newline>"
|
||||
- "<click:run_command:/areashop unrent %0%><hover:show_text:'%lang:action|Stop renting %0%|%'><dark_green><bold>►<reset> %lang:button|Click to unrent %0%|%</hover></click>"
|
||||
confirm-buy:
|
||||
- "%lang:prefix%Are you sure you want to buy %lang:tRegion|%0%|%?<newline>"
|
||||
- "<click:run_command:/areashop buy %0%><hover:show_text:'%lang:action|Buy %0%|%'><dark_green><bold>►<reset> %lang:button|Click to buy %0%|%</hover></click>"
|
||||
confirm-sell:
|
||||
- "%lang:prefix%Are you sure you want to sell %lang:tRegion|%0%|%?<newline>"
|
||||
- "<dark_green><bold>►<reset> %lang:button|Click to sell %0%|%"
|
||||
- "<click:run_command:/areashop sell %0%><hover:show_text:'%lang:action|Sell %0%|%'><dark_green><bold>►<reset> %lang:button|Click to sell %0%|%</hover></click>"
|
||||
|
||||
timeleft-years: "%0% years"
|
||||
timeleft-months: "%0% months"
|
||||
timeleft-days: "%0% days"
|
||||
timeleft-hours: "%0% hours"
|
||||
timeleft-minutes: "%0% minutes"
|
||||
timeleft-second: "%0% second"
|
||||
timeleft-seconds: "%0% seconds"
|
||||
timeleft-ended: "Expired"
|
||||
|
||||
greeting-forrent: "%region% can be rented for %price% per %duration%."
|
||||
greeting-rented: "%region% is rented by %player% until %until%."
|
||||
greeting-forsale: "%region% can be bought for %price%."
|
||||
greeting-bought: "%region% is bought by %player%."
|
||||
greeting-resale: "%region% can be bought for %resellprice% from %player%."
|
||||
|
||||
update-playerNotify:
|
||||
- "<dark_green>Update from AreaShop V%0% to AreaShop V%1% available, get the latest version at "
|
||||
- "<click:open_url:'https://github.com/md5sha256/releases'><hover:show_text:'%lang:action|Go to the AreaShop Github Releases|%'><bold>Github</bold></hover></click>"
|
||||
- " (and leave a review)."
|
||||
@@ -1,4 +1,4 @@
|
||||
# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
|
||||
# ╔═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
|
||||
# ║ Language file of the AreaShop plugin created by NLThijs48, Github can be found at https://github.com/NLthijs48/AreaShop
|
||||
# ║ English language file, plugin version 2.5.0
|
||||
# ║
|
||||
@@ -80,7 +80,6 @@ help-reload: "%lang:helpCommand|/as reload|% Reload all files and update the reg
|
||||
help-setrestore: "%lang:helpCommand|/as setrestore|% Set restoring on/off and choose profile."
|
||||
help-setprice: "%lang:helpCommand|/as setprice|% Change the price of a region."
|
||||
help-setduration: "%lang:helpCommand|/as setduration|% Change the duration of a rent region."
|
||||
help-settransfer: "%lang:helpCommand|/as settransfer|% Set transfer on/off."
|
||||
help-teleport: "%lang:helpCommand|/as tp|% Teleport to a rent/buy region."
|
||||
help-setteleport: "%lang:helpCommand|/as settp|% Set teleport position for a region."
|
||||
help-find: "%lang:helpCommand|/as find|% Find an empty buy or rent."
|
||||
@@ -103,7 +102,6 @@ help-linksigns: "%lang:helpCommand|/as linksigns|% Use bulk sign linking mode."
|
||||
help-stack: "%lang:helpCommand|/as stack|% Create multiple regions and add them."
|
||||
help-setlandlord: "%lang:helpCommand|/as setlandlord|% Set the landlord of a region."
|
||||
help-import: "%lang:helpCommand|/as import|% Import region from RegionForSale."
|
||||
help-transfer: "%lang:helpCommand|/as transfer|% Transfer a region to another player."
|
||||
|
||||
rent-help: "/as rent [region], the region you stand in will be used if not specified."
|
||||
rent-noPermission: "You don't have permission to rent a region."
|
||||
@@ -158,15 +156,6 @@ sell-noPermission: "You don't have permission to sell a region."
|
||||
sell-noPermissionOther: "You don't have permission to sell another region."
|
||||
sell-disabled: "Selling has been disabled for this region."
|
||||
|
||||
transfer-help: "/as transfer <player> [region], the region you stand in will be used if not specified."
|
||||
transfer-noPermission: "You don't have permission to transfer a region."
|
||||
transfer-disabled: "Transferring has been disabled for this region."
|
||||
transfer-transferred-owner: "%lang:region% has been transferred and is now owned by %0%."
|
||||
transfer-transferred-tenant: "%lang:region% has been transferred and is now occupied by %0%."
|
||||
transfer-noPlayer: "Unknown player: %0%"
|
||||
transfer-notCurrentTenant: "You are not the current tenant of this region."
|
||||
transfer-transferSelf: "You cannot transfer a region to yourself."
|
||||
|
||||
reload-reloading: "Reloaded all configuration and region files."
|
||||
reload-updateStart: ""
|
||||
reload-updateComplete: ""
|
||||
@@ -314,12 +303,6 @@ setrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or
|
||||
setrestore-success: "Successfully set the restore setting of %lang:region% to '%0%'."
|
||||
setrestore-successProfile: "Successfully set the restore setting of %lang:region% to '%0%' and the profile to '%1%'."
|
||||
|
||||
settransfer-help: "/as settransfer <region> <true|false>."
|
||||
settransfer-noPermission: "You don't have permission to change the transfer settings."
|
||||
settransfer-notRegistered: "The specified region is not registered: %0%."
|
||||
settransfer-invalidSetting: "'%0%' is not a valid state, should be true, false or general."
|
||||
settransfer-success: "Successfully set the transfer setting of %lang:region% to '%0%'."
|
||||
|
||||
setprice-noPermission: "You don't have permission to change the price of a region."
|
||||
setprice-help: "/as setprice <price> [region], the region you stand in will be used if not specified."
|
||||
setprice-notRegistered: "The specified region is not registered: %0%."
|
||||
@@ -636,7 +619,7 @@ greeting-resale: "%region% can be bought for %resellprice% from %player%."
|
||||
|
||||
update-playerNotify:
|
||||
- "[darkgreen]Update from AreaShop V%0% to AreaShop V%1% available, get the latest version at "
|
||||
- "[bold]Github[/bold]"
|
||||
- " hover: %lang:action|Go to the AreaShop Github Releases|%"
|
||||
- " link: https://github.com/md5sha256/releases"
|
||||
- " (and leave a review)."
|
||||
- "[bold]Spigot[/bold]"
|
||||
- " hover: %lang:action|Go to the Spigot AreaShop page|%"
|
||||
- " link: https://www.spigotmc.org/resources/areashop.2991/"
|
||||
- " (and leave a review)."
|
||||
@@ -13,30 +13,30 @@
|
||||
"action": "[gold][bold]<%0%>[/bold]"
|
||||
"button": "[bold]<%0%>[/bold]"
|
||||
"command":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: %lang:action|Use %1%|%"
|
||||
- " command: %1%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: %lang:action|Use %1%|%"
|
||||
- " command: %1%"
|
||||
"helpCommand":
|
||||
- "[gold]%0% [gray]-[reset]"
|
||||
- " hover: %lang:action|Use %0%|%"
|
||||
- " command: %0%"
|
||||
- "[gold]%0% [gray]-[reset]"
|
||||
- " hover: %lang:action|Use %0%|%"
|
||||
- " command: %0%"
|
||||
"region": "%lang:tRegion|%region%|%"
|
||||
"tRegion":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Region %0%"
|
||||
- " hover: %lang:action|Region information|%"
|
||||
- " command: /areashop info region %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Region %0%"
|
||||
- " hover: %lang:action|Region information|%"
|
||||
- " command: /areashop info region %0%"
|
||||
"player": "%lang:tPlayer|%player%|%"
|
||||
"tPlayer":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Player %0%"
|
||||
- " hover: %lang:action|Regions of %0%|%"
|
||||
- " command: /areashop info player %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Player %0%"
|
||||
- " hover: %lang:action|Regions of %0%|%"
|
||||
- " command: /areashop info player %0%"
|
||||
"landlord":
|
||||
- "[bold]%landlord%[/bold]"
|
||||
- " hover: Landlord %landlord%"
|
||||
- " hover: %lang:action|Regions of %landlord%|%"
|
||||
- " command: /areashop info player %landlord%"
|
||||
- "[bold]%landlord%[/bold]"
|
||||
- " hover: Landlord %landlord%"
|
||||
- " hover: %lang:action|Regions of %landlord%|%"
|
||||
- " command: /areashop info player %landlord%"
|
||||
"total-maximum": "No puedes alquilar o comprar %0% region(es) en total (ya tienes %1% en el grupo '%2%')."
|
||||
"confirm-yes": " [gray]Haz click en %lang:command|Confirm||%[gray], o reenvía el comando."
|
||||
"general-notReady": "AreaShop no se ha cargado todavía. Espera un poco."
|
||||
@@ -143,15 +143,15 @@
|
||||
"reload-noPermission": "No tienes permiso para recargar los archivos de configuración."
|
||||
"reload-updateCommandChanged": "Los comandos '/as updaterents' y '/as updatebuys' han sido borrados, '/as reload' actualizará las regiones. Puedes usar este comando en vez de los 2 primeros."
|
||||
"info-help":
|
||||
- "/as info[break]"
|
||||
- " %lang:command|all|/as info all|%[break]"
|
||||
- " %lang:command|rented|/as info rented|% [group] [page][break]"
|
||||
- " %lang:command|forrent|/as info forrent|% [group] [page][break]"
|
||||
- " %lang:command|sold|/as info sold|% [group] [page][break]"
|
||||
- " %lang:command|forsale|/as info forsale|% [group] [page][break]"
|
||||
- " %lang:command|reselling|/as info reselling|% [group] [page][break]"
|
||||
- " %lang:command|nogroup|/as info nogroup [page]|%[break]"
|
||||
- " %lang:command|region|/as info region|% [region]"
|
||||
- "/as info[break]"
|
||||
- " %lang:command|all|/as info all|%[break]"
|
||||
- " %lang:command|rented|/as info rented|% [group] [page][break]"
|
||||
- " %lang:command|forrent|/as info forrent|% [group] [page][break]"
|
||||
- " %lang:command|sold|/as info sold|% [group] [page][break]"
|
||||
- " %lang:command|forsale|/as info forsale|% [group] [page][break]"
|
||||
- " %lang:command|reselling|/as info reselling|% [group] [page][break]"
|
||||
- " %lang:command|nogroup|/as info nogroup [page]|%[break]"
|
||||
- " %lang:command|region|/as info region|% [region]"
|
||||
"info-noPermission": "No tienes permiso para ver información sobre las regiones."
|
||||
"info-allHeader": "Todas las regiones%0%:"
|
||||
"info-rentedHeader": "Regiones alquiladas%0%:"
|
||||
@@ -172,19 +172,19 @@
|
||||
"info-entryReselling": "[darkgreen][bold]►[reset] %lang:region%: [gray]Vendida a %lang:player% (reventa)."
|
||||
"info-pageStatus": "[gold]Pagina %0%/%1%"
|
||||
"info-pagePrevious":
|
||||
- " [gold][bold]◄Anterior[/bold] "
|
||||
- " hover: %lang:action|Mostrar la página anterior|%"
|
||||
- " command: %0%"
|
||||
- " [gold][bold]◄Anterior[/bold] "
|
||||
- " hover: %lang:action|Mostrar la página anterior|%"
|
||||
- " command: %0%"
|
||||
"info-pageNoPrevious":
|
||||
- " [darkgray][bold]◄Anterior[/bold] "
|
||||
- " hover: Esta es la primera página"
|
||||
- " [darkgray][bold]◄Anterior[/bold] "
|
||||
- " hover: Esta es la primera página"
|
||||
"info-pageNext":
|
||||
- " [gold][bold]Siguiente►[/bold]"
|
||||
- " hover: %lang:action|Mostrar la página siguiente|%"
|
||||
- " command: %0%"
|
||||
- " [gold][bold]Siguiente►[/bold]"
|
||||
- " hover: %lang:action|Mostrar la página siguiente|%"
|
||||
- " command: %0%"
|
||||
"info-pageNoNext":
|
||||
- " [darkgray][bold]Next►[/bold]"
|
||||
- " hover: Esta es la última pagina"
|
||||
- " [darkgray][bold]Next►[/bold]"
|
||||
- " hover: Esta es la última pagina"
|
||||
"info-playerHelp": "/as info player <nombre>."
|
||||
"info-playerRents": "Regiones alquiladas por %lang:tPlayer|%0%|%: [gray]%1%"
|
||||
"info-playerNoRents": "%lang:tPlayer|%0%|% no ha alquilado una región."
|
||||
@@ -197,66 +197,66 @@
|
||||
"info-regionBought": "[darkgreen][bold]►[reset] Comprada por %lang:player%."
|
||||
"info-regionReselling": "[darkgreen][bold]►[reset] Comprada por %lang:player%, actualvente en reventa."
|
||||
"info-regionExtending":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Extender por[/bold]"
|
||||
- " hover: Extender el alquiler de %region%"
|
||||
- " hover: con %duration% por %price%"
|
||||
- " hover: %lang:action|Extender el alquiler de %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% por %duration%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Extender por[/bold]"
|
||||
- " hover: Extender el alquiler de %region%"
|
||||
- " hover: con %duration% por %price%"
|
||||
- " hover: %lang:action|Extender el alquiler de %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% por %duration%."
|
||||
"info-regionCanBeRented":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Alquilar por[/bold]"
|
||||
- " hover: Alquilar %region% por %price% durante %duration%"
|
||||
- " hover: %lang:action|Alquilar %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% por %duration%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Alquilar por[/bold]"
|
||||
- " hover: Alquilar %region% por %price% durante %duration%"
|
||||
- " hover: %lang:action|Alquilar %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% por %duration%."
|
||||
"info-regionCanBeBought":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Comprar por[/bold]"
|
||||
- " hover: Comprar %region% por %price%"
|
||||
- " hover: %lang:action|Comprar %region%|%"
|
||||
- " command: /areashop buy %region%"
|
||||
- ": [gray]%price%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Comprar por[/bold]"
|
||||
- " hover: Comprar %region% por %price%"
|
||||
- " hover: %lang:action|Comprar %region%|%"
|
||||
- " command: /areashop buy %region%"
|
||||
- ": [gray]%price%."
|
||||
"info-regionReselPrice": "[darkgreen][bold]►[reset] Precio de reventa: [gray]%resellprice% (puedes comprarla de %lang:player%)."
|
||||
"info-regionFriends": "[darkgreen][bold]►[reset] Jugadores agregados: [gray]%0%."
|
||||
"info-friend": "%lang:tPlayer|%0%|%"
|
||||
"info-friendRemove":
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "[red]✕[gray]"
|
||||
- " hover: Region %region%"
|
||||
- " hover: %lang:action|Borrar a %0% como amigo|%"
|
||||
- " command: /areashop delfriend %0% %region%"
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "[red]✕[gray]"
|
||||
- " hover: Region %region%"
|
||||
- " hover: %lang:action|Borrar a %0% como amigo|%"
|
||||
- " command: /areashop delfriend %0% %region%"
|
||||
"info-regionMoneyBackBuy": "[darkgreen][bold]►[reset] Paga de venta: [gray]%moneyback% (%moneybackpercent%% del precio)."
|
||||
"info-regionMoneyBackBuyClick":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Paga de venta[/bold]"
|
||||
- " hover: Vender %region% y recuperar %moneyback%"
|
||||
- " hover: %lang:action|Vender %region%|%"
|
||||
- " command: /areashop sell %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% del precio)."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Paga de venta[/bold]"
|
||||
- " hover: Vender %region% y recuperar %moneyback%"
|
||||
- " hover: %lang:action|Vender %region%|%"
|
||||
- " command: /areashop sell %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% del precio)."
|
||||
"info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Paga por desalquilar: [gray]%moneyback% (%moneybackpercent%% del tiempo restante)."
|
||||
"info-regionMoneyBackRentClick":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Paga por desalquilar[/bold]"
|
||||
- " hover: Desalquilar %region% y recuperar %moneyback%"
|
||||
- " hover: %lang:action|Desalquilar %region%|%"
|
||||
- " command: /areashop unrent %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% del tiempo restante)."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Paga por desalquilar[/bold]"
|
||||
- " hover: Desalquilar %region% y recuperar %moneyback%"
|
||||
- " hover: %lang:action|Desalquilar %region%|%"
|
||||
- " command: /areashop unrent %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% del tiempo restante)."
|
||||
"info-regionMaxExtends": "[darkgreen][bold]►[reset] Numero de extensiones máximas: [gray]%maxextends% veces."
|
||||
"info-regionNoExtending": "[darkgreen][bold]►[reset] No se puede extender el alquiler."
|
||||
"info-regionExtendsLeft": "[darkgreen][bold]►[reset] Extensiones restantes: [gray]%extendsleft% veces de %maxextends%."
|
||||
"info-regionMaxRentTime": "[darkgreen][bold]►[reset] Alquiler por adelantado: [gray]%maxrenttime% como máximo."
|
||||
"info-prefix": "[darkgreen][bold]►[reset] "
|
||||
"info-regionTeleport":
|
||||
- "[bold]Ir a la region[/bold]"
|
||||
- " hover: %lang:action|Teletransportarse a %region%|%"
|
||||
- " command: /areashop tp %region%"
|
||||
- "[bold]Ir a la region[/bold]"
|
||||
- " hover: %lang:action|Teletransportarse a %region%|%"
|
||||
- " command: /areashop tp %region%"
|
||||
"info-setRegionTeleport":
|
||||
- "[bold]Configurar un punto de teletransporte[/bold]"
|
||||
- " hover: %region%"
|
||||
- " hover: %lang:action|Configurar un punto de teletransporte|%"
|
||||
- " command: /areashop settp %region%"
|
||||
- "[bold]Configurar un punto de teletransporte[/bold]"
|
||||
- " hover: %region%"
|
||||
- " hover: %lang:action|Configurar un punto de teletransporte|%"
|
||||
- " command: /areashop settp %region%"
|
||||
"info-regionSigns": "[darkgreen][bold]►[reset] Carteles conectados: [gray]%0%."
|
||||
"info-regionSignLocation": "[gray](%0%, %1%, %2%, %3%)[reset]"
|
||||
"info-regionGroups": "[darkgreen][bold]►[reset] Grupos asignados: [gray]%0%."
|
||||
@@ -388,10 +388,10 @@
|
||||
"addsign-couldNotDetectSign": "Se han encontrado muchas regiones alrededor del cartel, especifica la región en la segunda línea (2 de las regiones que se han encontrado: %lang:tRegion|%0%|% and %lang:tRegion|%1%|%)."
|
||||
"addsign-wrongProfile": "El perfil especificado no existe, usa uno de los siguientes (comprueba la config): [gray]%0%."
|
||||
"addsign-profile":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Signprofile %0%"
|
||||
- " hover: %lang:action|Usar este perfil|%"
|
||||
- " command: /areashop linksigns %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Signprofile %0%"
|
||||
- " hover: %lang:action|Usar este perfil|%"
|
||||
- " command: /areashop linksigns %0%"
|
||||
"addsign-success": "El cartel ha sido agregado a %lang:region%."
|
||||
"addsign-successProfile": "El cartel ha sido agregado a %lang:region% con el perfil %0%."
|
||||
"addsign-alreadyRegistered": "Este cartel ya está registrado para la región %lang:region%."
|
||||
@@ -404,16 +404,16 @@
|
||||
"me-header": "Regiones de %lang:tPlayer|%0%|%:"
|
||||
"me-notAPlayer": "No eres un jugador, y no puedes tener regiones."
|
||||
"me-rentLine":
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%timeleft% restante"
|
||||
- " hover: hasta %until%"
|
||||
- ")."
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%timeleft% restante"
|
||||
- " hover: hasta %until%"
|
||||
- ")."
|
||||
"me-buyLine": "[darkgreen][bold]►[reset] %lang:region%."
|
||||
"me-friendLine":
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "de %lang:player%"
|
||||
- " hover: Estás agregado como amigo"
|
||||
- ")."
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "de %lang:player%"
|
||||
- " hover: Estás agregado como amigo"
|
||||
- ")."
|
||||
"me-nothing": "%lang:tPlayer|%0%|% no ha comprado/alquilado regiones y no está agregado como amigo a ninguna."
|
||||
"me-noPlayer": "%0% no existe. Comprueba si ha entrado al servidor."
|
||||
"me-clickHint": "[gray][italic]Haz click en un nombre de región para ver los detalles."
|
||||
@@ -468,13 +468,13 @@
|
||||
"linksigns-noPermission": "No tienes permiso para entrar en el modo de linkeo de carteles."
|
||||
"linksigns-stopped": "Has salido del modo de linkeo de carteles."
|
||||
"stack-help":
|
||||
- "/as stack <cantidad> <espacio> <ombre> <rent|buy> [grupo].[break]"
|
||||
- " [gray]<cantidad> Número de regiones que serán creadas.[break]"
|
||||
- " [gray]<espacio> Bloques de distancia entre regiones.[break]"
|
||||
- " [gray]<nombre> Nombre de las regiones (el número estará detrás).[break]"
|
||||
- " [gray]<rent|buy> Hacer las regiones de compra o alquiler.[break]"
|
||||
- " [gray][grupo] Un grupo para agregar las regiones.[break]"
|
||||
- " [gray]Las regiones serán creadas en la dirección en que estás mirando."
|
||||
- "/as stack <cantidad> <espacio> <ombre> <rent|buy> [grupo].[break]"
|
||||
- " [gray]<cantidad> Número de regiones que serán creadas.[break]"
|
||||
- " [gray]<espacio> Bloques de distancia entre regiones.[break]"
|
||||
- " [gray]<nombre> Nombre de las regiones (el número estará detrás).[break]"
|
||||
- " [gray]<rent|buy> Hacer las regiones de compra o alquiler.[break]"
|
||||
- " [gray][grupo] Un grupo para agregar las regiones.[break]"
|
||||
- " [gray]Las regiones serán creadas en la dirección en que estás mirando."
|
||||
"stack-accepted": "Empezando a crear %0% %1% regiones con %2% bloques en medio, los nombres empiezan con %3% y tienen un número detrás.%4%"
|
||||
"stack-addToGroup": "Las regiones creadas serán añadidas al grupo '%0%'."
|
||||
"stack-noPermission": "No tienes permiso para crear y agregar regiones."
|
||||
@@ -517,30 +517,30 @@
|
||||
"import-signAlreadyAdded": "[red]Omitido cartel en la ubicación '%1%' a la región '%0%', ya que ya ha sido añadida a la región '%2%"
|
||||
"import-moneyBackFailed": "[red]Fallo al analizar el precio de compra '%0%' y venta '%1%' para establecer en porcentaje de dinero devuelto"
|
||||
"confirm-rent":
|
||||
- "%lang:prefix%Quieres alquilar la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Haz click para alquilarla %0%|%"
|
||||
- " hover: %lang:action|Alquilar %0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
- "%lang:prefix%Quieres alquilar la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Haz click para alquilarla %0%|%"
|
||||
- " hover: %lang:action|Alquilar %0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
"confirm-extend":
|
||||
- "%lang:prefix%Quieres extender el alquiler de la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click para extender %0%|%"
|
||||
- " hover: %lang:action|Extender %0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
- "%lang:prefix%Quieres extender el alquiler de la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click para extender %0%|%"
|
||||
- " hover: %lang:action|Extender %0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
"confirm-unrent":
|
||||
- "%lang:prefix%Quieres dejar de alquilar la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click para dejar de alquilar %0%|%"
|
||||
- " hover: %lang:action|Dejar de alquilar %0%|%"
|
||||
- " command: /areashop unrent %0%"
|
||||
- "%lang:prefix%Quieres dejar de alquilar la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click para dejar de alquilar %0%|%"
|
||||
- " hover: %lang:action|Dejar de alquilar %0%|%"
|
||||
- " command: /areashop unrent %0%"
|
||||
"confirm-buy":
|
||||
- "%lang:prefix%Quieres comprar la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click para comprar %0%|%"
|
||||
- " hover: %lang:action|Comprar %0%|%"
|
||||
- " command: /areashop buy %0%"
|
||||
- "%lang:prefix%Quieres comprar la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click para comprar %0%|%"
|
||||
- " hover: %lang:action|Comprar %0%|%"
|
||||
- " command: /areashop buy %0%"
|
||||
"confirm-sell":
|
||||
- "%lang:prefix%Quieres vender la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click to sell %0%|%"
|
||||
- " hover: %lang:action|Sell %0%|%"
|
||||
- " command: /areashop sell %0%"
|
||||
- "%lang:prefix%Quieres vender la %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Click to sell %0%|%"
|
||||
- " hover: %lang:action|Sell %0%|%"
|
||||
- " command: /areashop sell %0%"
|
||||
"timeleft-years": "%0% años"
|
||||
"timeleft-months": "%0% meses"
|
||||
"timeleft-days": "%0% días"
|
||||
@@ -554,4 +554,4 @@
|
||||
"greeting-forsale": "%region% puede ser comprada por %price%."
|
||||
"greeting-bought": "%region% está comprada por %player%."
|
||||
"greeting-resale": "%region% puede ser comprada por %resaleprice% al jugador %player%."
|
||||
"update-playerNotify": "[darkgreen]Hay una actualización disponible para AreaShop (V%0% - %1%). Consigue la más reciente en https://github.com/NLthijs48/AreaShop/releases."
|
||||
"update-playerNotify": "[darkgreen]Hay una actualización disponible para AreaShop (V%0% - %1%). Consigue la más reciente en https://github.com/NLthijs48/AreaShop/releases."
|
||||
@@ -13,30 +13,30 @@
|
||||
"action": "[gold][bold]<%0%>[/bold]"
|
||||
"button": "[bold]<%0%>[/bold]"
|
||||
"command":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: %lang:action|Utilisez %1%|%"
|
||||
- " command: %1%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: %lang:action|Utilisez %1%|%"
|
||||
- " command: %1%"
|
||||
"helpCommand":
|
||||
- "[gold]%0% [gray]-[reset]"
|
||||
- " hover: %lang:action|Utilisez %0%|%"
|
||||
- " command: %0%"
|
||||
- "[gold]%0% [gray]-[reset]"
|
||||
- " hover: %lang:action|Utilisez %0%|%"
|
||||
- " command: %0%"
|
||||
"region": "%lang:tRegion|%region%|%"
|
||||
"tRegion":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Région %0%"
|
||||
- " hover: %lang:action|Information sur la région|%"
|
||||
- " command: /areashop info region %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Région %0%"
|
||||
- " hover: %lang:action|Information sur la région|%"
|
||||
- " command: /areashop info region %0%"
|
||||
"player": "%lang:tPlayer|%player%|%"
|
||||
"tPlayer":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Joueur %0%"
|
||||
- " hover: %lang:action|Régions de %0%|%"
|
||||
- " command: /areashop info player %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Joueur %0%"
|
||||
- " hover: %lang:action|Régions de %0%|%"
|
||||
- " command: /areashop info player %0%"
|
||||
"landlord":
|
||||
- "[bold]%landlord%[/bold]"
|
||||
- " hover: Bailleur %landlord%"
|
||||
- " hover: %lang:action|Région de %landlord%|%"
|
||||
- " command: /areashop info player %landlord%"
|
||||
- "[bold]%landlord%[/bold]"
|
||||
- " hover: Bailleur %landlord%"
|
||||
- " hover: %lang:action|Région de %landlord%|%"
|
||||
- " command: /areashop info player %landlord%"
|
||||
"total-maximum": "Vous ne pouvez pas louer ou acheter plus de %0% région(s) au total (vous possédez déjà %1% dans le groupe '%2%')."
|
||||
"confirm-yes": " [gray]Clique ici %lang:command|Confirm%0% |%[gray], ou refait la commande."
|
||||
"general-notReady": "AreaShop n'est pas totalement chargé, merci d'attendre."
|
||||
@@ -143,15 +143,15 @@
|
||||
"reload-noPermission": "Vous n'avez pas la permission de recharger les fichiers."
|
||||
"reload-updateCommandChanged": "'/as updaterents' et '/as updatebuys' ont été supprimées, '/as reload' est la commande à utiliser pour mettre à jour les régions."
|
||||
"info-help":
|
||||
- "/as info[break]"
|
||||
- " %lang:command|all|/as info all|%[break]"
|
||||
- " %lang:command|rented|/as info rented|% [group] [page][break]"
|
||||
- " %lang:command|forrent|/as info forrent|% [group] [page][break]"
|
||||
- " %lang:command|sold|/as info sold|% [group] [page][break]"
|
||||
- " %lang:command|forsale|/as info forsale|% [group] [page][break]"
|
||||
- " %lang:command|reselling|/as info reselling|% [group] [page][break]"
|
||||
- " %lang:command|nogroup|/as info nogroup [page]|%[break]"
|
||||
- " %lang:command|region|/as info region|% [region]"
|
||||
- "/as info[break]"
|
||||
- " %lang:command|all|/as info all|%[break]"
|
||||
- " %lang:command|rented|/as info rented|% [group] [page][break]"
|
||||
- " %lang:command|forrent|/as info forrent|% [group] [page][break]"
|
||||
- " %lang:command|sold|/as info sold|% [group] [page][break]"
|
||||
- " %lang:command|forsale|/as info forsale|% [group] [page][break]"
|
||||
- " %lang:command|reselling|/as info reselling|% [group] [page][break]"
|
||||
- " %lang:command|nogroup|/as info nogroup [page]|%[break]"
|
||||
- " %lang:command|region|/as info region|% [region]"
|
||||
"info-noPermission": "Vous n'avez pas la permission d'avoir des informations à propos des régions."
|
||||
"info-allHeader": "Toutes les régions%0%:"
|
||||
"info-rentedHeader": "Les régions louées%0%:"
|
||||
@@ -172,19 +172,19 @@
|
||||
"info-entryReselling": "[darkgreen][bold]►[reset] %lang:region%: [gray]Vendu à %lang:player% (revente)."
|
||||
"info-pageStatus": "[gold]Page %0%/%1%"
|
||||
"info-pagePrevious":
|
||||
- "[gold][bold]◄Précédent[/bold] "
|
||||
- "hover: %lang:action|Montrer la page précédente |%"
|
||||
- "command: /areashop %0%"
|
||||
- "[gold][bold]◄Précédent[/bold] "
|
||||
- "hover: %lang:action|Montrer la page précédente |%"
|
||||
- "command: /areashop %0%"
|
||||
"info-pageNoPrevious":
|
||||
- " [darkgray][bold]◄Précédent[/bold] "
|
||||
- " hover: C'est déjà la premier page"
|
||||
- " [darkgray][bold]◄Précédent[/bold] "
|
||||
- " hover: C'est déjà la premier page"
|
||||
"info-pageNext":
|
||||
- "[gold][bold]Suivant►[/bold]"
|
||||
- "hover: %lang:action|Page suivante|%"
|
||||
- "commande: /areashop "
|
||||
- "[gold][bold]Suivant►[/bold]"
|
||||
- "hover: %lang:action|Page suivante|%"
|
||||
- "commande: /areashop "
|
||||
"info-pageNoNext":
|
||||
- " [darkgray][bold]Suivaznt►[/bold]"
|
||||
- " hover: C'est déjà la dernière page"
|
||||
- " [darkgray][bold]Suivaznt►[/bold]"
|
||||
- " hover: C'est déjà la dernière page"
|
||||
"info-playerHelp": "/as info player <name>"
|
||||
"info-playerRents": "Régions louée par %lang:tPlayer|%0%|%: [gray]%1%"
|
||||
"info-playerNoRents": "%lang:tPlayer|%0%|% n'a de régions louées."
|
||||
@@ -197,66 +197,66 @@
|
||||
"info-regionBought": "[darkgreen][bold]►[reset] Achetée par %lang:player%."
|
||||
"info-regionReselling": "[darkgreen][bold]►[reset] Achetée par %lang:player%, actuellement en revente."
|
||||
"info-regionExtending":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Etendre pour[/bold]"
|
||||
- " hover: Etendre votre location de %region%"
|
||||
- " hover: pour %duration% coutant %price%"
|
||||
- " hover: %lang:action|Etendre votre location de %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% pour %duration%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Etendre pour[/bold]"
|
||||
- " hover: Etendre votre location de %region%"
|
||||
- " hover: pour %duration% coutant %price%"
|
||||
- " hover: %lang:action|Etendre votre location de %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% pour %duration%."
|
||||
"info-regionCanBeRented":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Louer pour[/bold]"
|
||||
- " hover: Louer %region% pour %price% pour %duration%"
|
||||
- " hover: %lang:action|Rent %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% pour %duration%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Louer pour[/bold]"
|
||||
- " hover: Louer %region% pour %price% pour %duration%"
|
||||
- " hover: %lang:action|Rent %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% pour %duration%."
|
||||
"info-regionCanBeBought":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Prix d'achat[/bold]"
|
||||
- " hover: Acheter%region% pour %price%"
|
||||
- " hover: %lang:action|Acheter %region%|%"
|
||||
- " command: /areashop buy %region%"
|
||||
- ": [gray]%price%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Prix d'achat[/bold]"
|
||||
- " hover: Acheter%region% pour %price%"
|
||||
- " hover: %lang:action|Acheter %region%|%"
|
||||
- " command: /areashop buy %region%"
|
||||
- ": [gray]%price%."
|
||||
"info-regionReselPrice": "[darkgreen][bold]►[reset] Prix de revente : [gray]%resellprice% (vous pouvez l'acheter à %player%)."
|
||||
"info-regionFriends": "[darkgreen][bold]►[reset] Ami(s) ajouté(s) : [gray]%0%."
|
||||
"info-friend": "%lang:tPlayer|%0%|%"
|
||||
"info-friendRemove":
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "[red]✕[gray]"
|
||||
- " hover: Région %region%"
|
||||
- " hover: %lang:action|retirer %0% comme ami|%"
|
||||
- " command: /areashop delfriend %0% %region%"
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "[red]✕[gray]"
|
||||
- " hover: Région %region%"
|
||||
- " hover: %lang:action|retirer %0% comme ami|%"
|
||||
- " command: /areashop delfriend %0% %region%"
|
||||
"info-regionMoneyBackBuy": "[darkgreen][bold]►[reset] Prix de revente : [gray]%moneyback% (%moneybackpercent%% du prix)"
|
||||
"info-regionMoneyBackBuyClick":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Retour sur investissement de la vente[/bold]"
|
||||
- " hover: Vendez %region% et recupérer %moneyback% de retour sur investissement"
|
||||
- " hover: %lang:action|Vendre %region%|%"
|
||||
- " command: /areashop sell %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% du prix)."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Retour sur investissement de la vente[/bold]"
|
||||
- " hover: Vendez %region% et recupérer %moneyback% de retour sur investissement"
|
||||
- " hover: %lang:action|Vendre %region%|%"
|
||||
- " command: /areashop sell %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% du prix)."
|
||||
"info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Remboursement de location : [gray]%moneyback% (%moneybackpercent%% du temps restant)"
|
||||
"info-regionMoneyBackRentClick":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Prorata du loyer remboursé[/bold]"
|
||||
- " hover: Cesser la location %region% et récupérer %moneyback%"
|
||||
- " hover: %lang:action|Cesser la location%region%|%"
|
||||
- " command: /areashop unrent %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% du temps restant)."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Prorata du loyer remboursé[/bold]"
|
||||
- " hover: Cesser la location %region% et récupérer %moneyback%"
|
||||
- " hover: %lang:action|Cesser la location%region%|%"
|
||||
- " command: /areashop unrent %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% du temps restant)."
|
||||
"info-regionMaxExtends": "[darkgreen][bold]►[reset] Nombre maximum de région : [gray]%maxextends% fois."
|
||||
"info-regionNoExtending": "[darkgreen][bold]►[reset] La location ne peut être allongée."
|
||||
"info-regionExtendsLeft": "[darkgreen][bold]►[reset] Extensions restantes : [gray]%extendsleft% fois sur %maxextends%."
|
||||
"info-regionMaxRentTime": "[darkgreen][bold]►[reset] Location à l'avance : [gray]%maxrenttime% au maximum"
|
||||
"info-prefix": "[darkgreen][bold]►[reset] "
|
||||
"info-regionTeleport":
|
||||
- "[bold]Aller à la région[/bold]"
|
||||
- " hover: %lang:action|Se téleporter à %region%|%"
|
||||
- " command: /areashop tp %region%"
|
||||
- "[bold]Aller à la région[/bold]"
|
||||
- " hover: %lang:action|Se téleporter à %region%|%"
|
||||
- " command: /areashop tp %region%"
|
||||
"info-setRegionTeleport":
|
||||
- "[bold]Définir la position de téléportation[/bold]"
|
||||
- " hover: %region%"
|
||||
- " hover: %lang:action|Définir la position de téléportation|%"
|
||||
- " command: /areashop settp %region%"
|
||||
- "[bold]Définir la position de téléportation[/bold]"
|
||||
- " hover: %region%"
|
||||
- " hover: %lang:action|Définir la position de téléportation|%"
|
||||
- " command: /areashop settp %region%"
|
||||
"info-regionSigns": "[darkgreen][bold]►[reset] Pancartes connectées: [gray]%0%."
|
||||
"info-regionSignLocation": "[gray](%0%, %1%, %2%, %3%)[reset]"
|
||||
"info-regionGroups": "[darkgreen][bold]►[reset] Assigné aux groupes: [gray]%0%."
|
||||
@@ -390,10 +390,10 @@
|
||||
"addsign-couldNotDetectSign": "Plusieurs régions ont été trouvées à proximité du panneau. Spécifiez la région à la deuxième ligne (2 des régions trouvées: %lang:tRegion|%0%|% et %lang:tRegion|%1%|%)."
|
||||
"addsign-wrongProfile": "Le profil spécifié n'existe pas, utilisez l'un de la liste suivante (Vérifiez la config): [gray]%0%."
|
||||
"addsign-profile":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Connexion profil %0%"
|
||||
- " hover: %lang:action|Utiliser ce profil|%"
|
||||
- " command: /areashop linksigns %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Connexion profil %0%"
|
||||
- " hover: %lang:action|Utiliser ce profil|%"
|
||||
- " command: /areashop linksigns %0%"
|
||||
"addsign-success": "Le panneau a été ajouté à %lang:region%."
|
||||
"addsign-successProfile": "Le panneau a été ajouté à %lang:region%. avec le profile %0%."
|
||||
"addsign-alreadyRegistered": "Ce panneau est déjà enregistré pour la région %lang:region%."
|
||||
@@ -406,16 +406,16 @@
|
||||
"me-header": "Régions de %lang:tPlayer|%0%|%:"
|
||||
"me-notAPlayer": "Vous n'êtes pas un joueur. Vous ne pouvez donc pas avoir de régions."
|
||||
"me-rentLine":
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%timeleft% restant"
|
||||
- "⇥hover: depuis %until%"
|
||||
- ")."
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%timeleft% restant"
|
||||
- "⇥hover: depuis %until%"
|
||||
- ")."
|
||||
"me-buyLine": "[darkgreen][bold]►[reset] %lang:region%."
|
||||
"me-friendLine":
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "propriétaire: %lang:player%"
|
||||
- "⇥hover: Vous avez ajouté comme ami"
|
||||
- ")."
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "propriétaire: %lang:player%"
|
||||
- "⇥hover: Vous avez ajouté comme ami"
|
||||
- ")."
|
||||
"me-nothing": "%lang:tPlayer|%0%|% n'a pas loué ou acheté de régions et n'a pas été ajouté comme ami dans l'un entre eux."
|
||||
"me-noPlayer": "%0% n'a pas été trouvé, il ne s'est peut être jamais connecté sur le serveur."
|
||||
"me-clickHint": "[gray][italic]Cliquez sur le nom d'une région pour voir les détails."
|
||||
@@ -470,13 +470,13 @@
|
||||
"linksigns-noPermission": "Vous n'avez pas la permission de rentrer dans le mode de liaison d'un panneau."
|
||||
"linksigns-stopped": "Vous êtes sorti du mode de liaison d'un panneau."
|
||||
"stack-help":
|
||||
- "/as stack <montant> <écart> <nom> <rent|buy> [groupe].[break]"
|
||||
- "⇥[gray<montant> Nombre de régions qui sera créé.[break]"
|
||||
- "⇥[gray]<écart> Distance en blocs entre les régions.[break]"
|
||||
- "⇥[gray]<nom> Nom des régions (un nombre sera ajouté à la fin[break]"
|
||||
- "⇥[gray]<rent|buy> Définir comme location (rent) ou achat (but).[break]"
|
||||
- "⇥[gray][groupe] Un groupe pour ajouter les régions créées..[break]"
|
||||
- "⇥[gray]Les régions seront créés dans la direction que vous faites face."
|
||||
- "/as stack <montant> <écart> <nom> <rent|buy> [groupe].[break]"
|
||||
- "⇥[gray<montant> Nombre de régions qui sera créé.[break]"
|
||||
- "⇥[gray]<écart> Distance en blocs entre les régions.[break]"
|
||||
- "⇥[gray]<nom> Nom des régions (un nombre sera ajouté à la fin[break]"
|
||||
- "⇥[gray]<rent|buy> Définir comme location (rent) ou achat (but).[break]"
|
||||
- "⇥[gray][groupe] Un groupe pour ajouter les régions créées..[break]"
|
||||
- "⇥[gray]Les régions seront créés dans la direction que vous faites face."
|
||||
"stack-accepted": "Commence à créer %0% %1% régions avec %2% blocs entre chacune, dont les noms commencent avec %3% et ont un chiffre derrière. %4%"
|
||||
"stack-addToGroup": "Les régions créées ont été ajoutées au groupe '%0%'."
|
||||
"stack-noPermission": "Vous n'avez pas la permission de créer et d'ajouter des régions à AreaShop en vrac."
|
||||
@@ -519,30 +519,30 @@
|
||||
"import-signAlreadyAdded": "[red] Ignoré l'ajout de la pancarte à la location '%1%' de la région '%0%', il est déjà ajouté à la région '%2%'."
|
||||
"import-moneyBackFailed": "[red] Échec de l'analyse du prix d'achat '%0%' et du prix de vente '%1%' pour définir le pourcentage de remboursement."
|
||||
"confirm-rent":
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir louer %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour louer %0%|%"
|
||||
- " hover: %lang:action|Louer%0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir louer %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour louer %0%|%"
|
||||
- " hover: %lang:action|Louer%0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
"confirm-extend":
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir prolonger la location %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour prolonger la location%0%|%"
|
||||
- " hover: %lang:action|Prolonger la location%0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir prolonger la location %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour prolonger la location%0%|%"
|
||||
- " hover: %lang:action|Prolonger la location%0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
"confirm-unrent":
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir arrêter la location %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour arrêter la location%0%|%"
|
||||
- " hover: %lang:action|Arrêter la location%0%|%"
|
||||
- " command: /areashop unrent %0%"
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir arrêter la location %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour arrêter la location%0%|%"
|
||||
- " hover: %lang:action|Arrêter la location%0%|%"
|
||||
- " command: /areashop unrent %0%"
|
||||
"confirm-buy":
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir acheter %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour acheter %0%|%"
|
||||
- " hover: %lang:action|Acheter%0%|%"
|
||||
- " command: /areashop buy%0%"
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir acheter %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour acheter %0%|%"
|
||||
- " hover: %lang:action|Acheter%0%|%"
|
||||
- " command: /areashop buy%0%"
|
||||
"confirm-sell":
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir vendre %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour vendre %0%|%"
|
||||
- " hover: %lang:action|Vendre%0%|%"
|
||||
- " command: /areashop sell %0%"
|
||||
- "%lang:prefix%Êtes-vous sur de vouloir vendre %lang:tRegion|%0%|%?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Cliquez ici pour vendre %0%|%"
|
||||
- " hover: %lang:action|Vendre%0%|%"
|
||||
- " command: /areashop sell %0%"
|
||||
"timeleft-years": "%0% années"
|
||||
"timeleft-months": "%0% mois"
|
||||
"timeleft-days": "%0% jours"
|
||||
@@ -557,8 +557,8 @@
|
||||
"greeting-bought": "%region% est la propriété de %player%."
|
||||
"greeting-resale": "%region% peut être acheté pour %resellprice%. Offre par %player%."
|
||||
"update-playerNotify":
|
||||
- "[darkgreen]Mise à jours de AreaShop V%0% à AreaShop V%1% disponible, récupérez la nouvelle version sur "
|
||||
- "[bold]Spigot[/bold]"
|
||||
- " hover: %lang:action|Aller à la page Spigot de AreaShop|%"
|
||||
- " link: https://www.spigotmc.org/resources/areashop.2991/"
|
||||
- "(et laissez un avis)."
|
||||
- "[darkgreen]Mise à jours de AreaShop V%0% à AreaShop V%1% disponible, récupérez la nouvelle version sur "
|
||||
- "[bold]Spigot[/bold]"
|
||||
- " hover: %lang:action|Aller à la page Spigot de AreaShop|%"
|
||||
- " link: https://www.spigotmc.org/resources/areashop.2991/"
|
||||
- "(et laissez un avis)."
|
||||
@@ -13,30 +13,30 @@
|
||||
"action": "[gold][bold]<%0%>[/bold]"
|
||||
"button": "[bold]<%0%>[/bold]"
|
||||
"command":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: %lang:action|Gebruik %1%|%"
|
||||
- " command: %1%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: %lang:action|Gebruik %1%|%"
|
||||
- " command: %1%"
|
||||
"helpCommand":
|
||||
- "[gold]%0% [gray]-[reset]"
|
||||
- " hover: %lang:action|Gebruik %0%|%"
|
||||
- " command: %0%"
|
||||
- "[gold]%0% [gray]-[reset]"
|
||||
- " hover: %lang:action|Gebruik %0%|%"
|
||||
- " command: %0%"
|
||||
"region": "%lang:tRegion|%region%|%"
|
||||
"tRegion":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Gebied %0%"
|
||||
- " hover: %lang:action|Gebied informatie|%"
|
||||
- " command: /areashop info region %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Gebied %0%"
|
||||
- " hover: %lang:action|Gebied informatie|%"
|
||||
- " command: /areashop info region %0%"
|
||||
"player": "%lang:tPlayer|%player%|%"
|
||||
"tPlayer":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Speler %0%"
|
||||
- " hover: %lang:action|Gebieden van %0%|%"
|
||||
- " command: /areashop info player %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Speler %0%"
|
||||
- " hover: %lang:action|Gebieden van %0%|%"
|
||||
- " command: /areashop info player %0%"
|
||||
"landlord":
|
||||
- "[bold]%landlord%[/bold]"
|
||||
- " hover: Landeigenaar %landlord%"
|
||||
- " hover: %lang:action|Gebieden van %landlord%|%"
|
||||
- " command: /areashop info player %landlord%"
|
||||
- "[bold]%landlord%[/bold]"
|
||||
- " hover: Landeigenaar %landlord%"
|
||||
- " hover: %lang:action|Gebieden van %landlord%|%"
|
||||
- " command: /areashop info player %landlord%"
|
||||
"total-maximum": "Je kunt niet meer dan %0% gebied(en) kopen en huren in totaal (je hebt er al %1% in groep '%2%')."
|
||||
"confirm-yes": " [gray]Klik om te %lang:command|bevestigen|%0%|%[gray], of herhaal het commando."
|
||||
"general-notReady": "AreaShop is nog niet volledig geladen, even geduld."
|
||||
@@ -143,15 +143,15 @@
|
||||
"reload-noPermission": "Je hebt geen toestemming om configuratiebestanden te herladen."
|
||||
"reload-updateCommandChanged": "'/as updaterents' en '/as updatebuys' zijn verwijderd, '/as reload' updated nu ook de gebieden, gebruik dus dat commando."
|
||||
"info-help":
|
||||
- "/as info[break]"
|
||||
- " %lang:command|all|/as info all|%[break]"
|
||||
- " %lang:command|rented|/as info rented|% [group] [page][break]"
|
||||
- " %lang:command|forrent|/as info forrent|% [group] [page][break]"
|
||||
- " %lang:command|sold|/as info sold|% [group] [page][break]"
|
||||
- " %lang:command|forsale|/as info forsale|% [group] [page][break]"
|
||||
- " %lang:command|reselling|/as info reselling|% [group] [page][break]"
|
||||
- " %lang:command|nogroup|/as info nogroup [page]|%[break]"
|
||||
- " %lang:command|region|/as info region|% [region]"
|
||||
- "/as info[break]"
|
||||
- " %lang:command|all|/as info all|%[break]"
|
||||
- " %lang:command|rented|/as info rented|% [group] [page][break]"
|
||||
- " %lang:command|forrent|/as info forrent|% [group] [page][break]"
|
||||
- " %lang:command|sold|/as info sold|% [group] [page][break]"
|
||||
- " %lang:command|forsale|/as info forsale|% [group] [page][break]"
|
||||
- " %lang:command|reselling|/as info reselling|% [group] [page][break]"
|
||||
- " %lang:command|nogroup|/as info nogroup [page]|%[break]"
|
||||
- " %lang:command|region|/as info region|% [region]"
|
||||
"info-noPermission": "Je hebt geen toestemming om informatie over gebieden te bekijken."
|
||||
"info-allHeader": "Alle gebieden%0%:"
|
||||
"info-rentedHeader": "Verhuurde gebieden%0%:"
|
||||
@@ -172,19 +172,19 @@
|
||||
"info-entryReselling": "[darkgreen][bold]►[reset] %lang:region%: [gray]Verkocht aan %lang:player% (aan het doorverkopen)."
|
||||
"info-pageStatus": "[gold]Pagina %0%/%1%"
|
||||
"info-pagePrevious":
|
||||
- " [gold][bold]◄Vorige[/bold] "
|
||||
- " hover: %lang:action|Laat de vorige pagina zien|%"
|
||||
- " command: /areashop %0%"
|
||||
- " [gold][bold]◄Vorige[/bold] "
|
||||
- " hover: %lang:action|Laat de vorige pagina zien|%"
|
||||
- " command: /areashop %0%"
|
||||
"info-pageNoPrevious":
|
||||
- " [darkgray][bold]◄Vorige[/bold] "
|
||||
- " hover: Dit is al de eerste pagina"
|
||||
- " [darkgray][bold]◄Vorige[/bold] "
|
||||
- " hover: Dit is al de eerste pagina"
|
||||
"info-pageNext":
|
||||
- " [gold][bold]Volgende►[/bold]"
|
||||
- " hover: %lang:action|Laat de volgende pagina zien|%"
|
||||
- " command: /areashop %0%"
|
||||
- " [gold][bold]Volgende►[/bold]"
|
||||
- " hover: %lang:action|Laat de volgende pagina zien|%"
|
||||
- " command: /areashop %0%"
|
||||
"info-pageNoNext":
|
||||
- " [darkgray][bold]Volgende►[/bold]"
|
||||
- " hover: Dit is al de laatste pagina"
|
||||
- " [darkgray][bold]Volgende►[/bold]"
|
||||
- " hover: Dit is al de laatste pagina"
|
||||
"info-playerHelp": "/as info player <naam>."
|
||||
"info-playerRents": "Gebieden gehuurd door %lang:tPlayer|%0%|%: [gray]%1%."
|
||||
"info-playerNoRents": "%lang:tPlayer|%0%|% heeft geen gebieden gehuurd."
|
||||
@@ -197,66 +197,66 @@
|
||||
"info-regionBought": "[darkgreen][bold]►[reset] Gekocht door %lang:player%."
|
||||
"info-regionReselling": "[darkgreen][bold]►[reset] Gekocht door %lang:player%, aan het doorverkopen."
|
||||
"info-regionExtending":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Verleng voor[/bold]"
|
||||
- " hover: Verleng huur van %region%"
|
||||
- " hover: met %duration% voor %price%"
|
||||
- " hover: %lang:action|Verleng de huur van %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% per %duration%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Verleng voor[/bold]"
|
||||
- " hover: Verleng huur van %region%"
|
||||
- " hover: met %duration% voor %price%"
|
||||
- " hover: %lang:action|Verleng de huur van %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% per %duration%."
|
||||
"info-regionCanBeRented":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Huur voor[/bold]"
|
||||
- " hover: Huur %region% voor %price% per %duration%"
|
||||
- " hover: %lang:action|Huur %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% per %duration%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Huur voor[/bold]"
|
||||
- " hover: Huur %region% voor %price% per %duration%"
|
||||
- " hover: %lang:action|Huur %region%|%"
|
||||
- " command: /areashop rent %region%"
|
||||
- ": [gray]%price% per %duration%."
|
||||
"info-regionCanBeBought":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Koop voor[/bold]"
|
||||
- " hover: Koop %region% voor %price%"
|
||||
- " hover: %lang:action|Koop %region%|%"
|
||||
- " command: /areashop buy %region%"
|
||||
- ": [gray]%price%."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Koop voor[/bold]"
|
||||
- " hover: Koop %region% voor %price%"
|
||||
- " hover: %lang:action|Koop %region%|%"
|
||||
- " command: /areashop buy %region%"
|
||||
- ": [gray]%price%."
|
||||
"info-regionReselPrice": "[darkgreen][bold]►[reset] Doorverkoop prijs: [gray]%resellprice% (je kunt het kopen van %lang:player%)."
|
||||
"info-regionFriends": "[darkgreen][bold]►[reset] Toegevoegde vrienden: [gray]%0%."
|
||||
"info-friend": "%lang:tPlayer|%0%|%"
|
||||
"info-friendRemove":
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "[red]✕[gray]"
|
||||
- " hover: Gebied %region%"
|
||||
- " hover: %lang:action|Verwijder %0% as friend|%"
|
||||
- " command: /areashop delfriend %0% %region%"
|
||||
- "%lang:info-friend|%0%|%"
|
||||
- "[red]✕[gray]"
|
||||
- " hover: Gebied %region%"
|
||||
- " hover: %lang:action|Verwijder %0% as friend|%"
|
||||
- " command: /areashop delfriend %0% %region%"
|
||||
"info-regionMoneyBackBuy": "[darkgreen][bold]►[reset] Verkoop terugbetaling: [gray]%moneyback% (%moneybackpercent%% van de prijs)."
|
||||
"info-regionMoneyBackBuyClick":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Verkoop terugbetaling[/bold]"
|
||||
- " hover: Verkoop %region% en krijg %moneyback% terug"
|
||||
- " hover: %lang:action|Verkoop %region%|%"
|
||||
- " command: /areashop sell %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% van de prijs)."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Verkoop terugbetaling[/bold]"
|
||||
- " hover: Verkoop %region% en krijg %moneyback% terug"
|
||||
- " hover: %lang:action|Verkoop %region%|%"
|
||||
- " command: /areashop sell %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% van de prijs)."
|
||||
"info-regionMoneyBackRent": "[darkgreen][bold]►[reset] Stop met huren terugbetaling: [gray]%moneyback% (%moneybackpercent%% van de overgebleven tijd)."
|
||||
"info-regionMoneyBackRentClick":
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Stop met huren terugbetaling[/bold]"
|
||||
- " hover: Stop met huren van %region% en krijg %moneyback% terug"
|
||||
- " hover: %lang:action|Stop met huren van %region%|%"
|
||||
- " command: /areashop unrent %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% van de overgebleven tijd)."
|
||||
- "[darkgreen][bold]►[reset] "
|
||||
- "[bold]Stop met huren terugbetaling[/bold]"
|
||||
- " hover: Stop met huren van %region% en krijg %moneyback% terug"
|
||||
- " hover: %lang:action|Stop met huren van %region%|%"
|
||||
- " command: /areashop unrent %region%"
|
||||
- ": [gray]%moneyback% (%moneybackpercent%% van de overgebleven tijd)."
|
||||
"info-regionMaxExtends": "[darkgreen][bold]►[reset] Maximaal keer verlengen: [gray]%maxextends% keer."
|
||||
"info-regionNoExtending": "[darkgreen][bold]►[reset] Huur kan niet verlengt worden."
|
||||
"info-regionExtendsLeft": "[darkgreen][bold]►[reset] Verlengingen over: [gray]%extendsleft% keer van de %maxextends%."
|
||||
"info-regionMaxRentTime": "[darkgreen][bold]►[reset] Huurtijd: [gray]maximaal %maxrenttime%."
|
||||
"info-prefix": "[darkgreen][bold]►[reset] "
|
||||
"info-regionTeleport":
|
||||
- "[bold]Ga naar het gebied[/bold]"
|
||||
- " hover: %lang:action|Ga naar %region%|%"
|
||||
- " command: /areashop tp %region%"
|
||||
- "[bold]Ga naar het gebied[/bold]"
|
||||
- " hover: %lang:action|Ga naar %region%|%"
|
||||
- " command: /areashop tp %region%"
|
||||
"info-setRegionTeleport":
|
||||
- "[bold]stel teleporteer locatie in[/bold]"
|
||||
- " hover: %region%"
|
||||
- " hover: %lang:action|Stel teleporteer locatie in|%"
|
||||
- " command: /areashop settp %region%"
|
||||
- "[bold]stel teleporteer locatie in[/bold]"
|
||||
- " hover: %region%"
|
||||
- " hover: %lang:action|Stel teleporteer locatie in|%"
|
||||
- " command: /areashop settp %region%"
|
||||
"info-regionSigns": "[darkgreen][bold]►[reset] Verbonden borden: [gray]%0%."
|
||||
"info-regionSignLocation": "[gray](%0%, %1%, %2%, %3%)[reset]"
|
||||
"info-regionGroups": "[darkgreen][bold]►[reset] Toegewezen groepen: [gray]%0%."
|
||||
@@ -390,10 +390,10 @@
|
||||
"addsign-couldNotDetectSign": "Meerdere gebieden gevonden op de lokatie van het bord, geef het gebied aan op de tweede regel (2 van de gevonden gebieden: %lang:tRegion|%0%|% en %lang:tRegion|%1%|%)."
|
||||
"addsign-wrongProfile": "Het aangegeven profiel bestaat niet, gebruik een van de volgende (check de config): [gray]%0%."
|
||||
"addsign-profile":
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Bord profiel %0%"
|
||||
- " hover: %lang:action|Gebruik dit profiel|%"
|
||||
- " command: /areashop linksigns %0%"
|
||||
- "[bold]%0%[/bold]"
|
||||
- " hover: Bord profiel %0%"
|
||||
- " hover: %lang:action|Gebruik dit profiel|%"
|
||||
- " command: /areashop linksigns %0%"
|
||||
"addsign-success": "Het bord is toegevoegd aan %lang:region%."
|
||||
"addsign-successProfile": "Het bord is toegevoegd aan %lang:region% met profiel %0%."
|
||||
"addsign-alreadyRegistered": "Dat bord is al geregistreerd voor gebied %lang:region%."
|
||||
@@ -406,16 +406,16 @@
|
||||
"me-header": "Gebieden van %lang:tPlayer|%0%|%:"
|
||||
"me-notAPlayer": "Je bent geen speler dus je kunt geen gebieden hebben."
|
||||
"me-rentLine":
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%timeleft% over"
|
||||
- " hover: tot %until%"
|
||||
- ")."
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%timeleft% over"
|
||||
- " hover: tot %until%"
|
||||
- ")."
|
||||
"me-buyLine": "[darkgreen][bold]►[reset] %lang:region%."
|
||||
"me-friendLine":
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%lang:player% is eigenaar"
|
||||
- " hover: Je bent toegevoegd als vriend"
|
||||
- ")."
|
||||
- "[darkgreen][bold]►[reset] %lang:region% [gray]("
|
||||
- "%lang:player% is eigenaar"
|
||||
- " hover: Je bent toegevoegd als vriend"
|
||||
- ")."
|
||||
"me-nothing": "%lang:tPlayer|%0%|% heeft geen gebieden gekocht of gehuurd en is niet als vriend toegevoegd bij gebieden."
|
||||
"me-noPlayer": "%0% kan niet gevonden worden, is waarschijnlijk nooit op de server geweest."
|
||||
"me-clickHint": "[gray][italic]Klik op een naam van een gebied voor details."
|
||||
@@ -470,13 +470,13 @@
|
||||
"linksigns-noPermission": "Je hebt geen toestemming om massa bord-koppel modus te gebruiken."
|
||||
"linksigns-stopped": "Je bent gestopt met bord-koppel modus."
|
||||
"stack-help":
|
||||
- "/as stack <aantal> <afstand> <naam> <rent|buy> [groep].[break]"
|
||||
- " [gray]<aantal> Het aantal gebieden dat word gemaakt.[break]"
|
||||
- " [gray]<afstand> Blokken afstand tussen de gebieden.[break]"
|
||||
- " [gray]<naam> Naam van de gebieden (komt een nummer achter).[break]"
|
||||
- " [gray]<rent|buy> Maak ze huur of koop gebieden.[break]"
|
||||
- " [gray][groep] Groep waaraan de gebieden worden toegevoegd.[break]"
|
||||
- " [gray]De gebieden zullen worden gemaakt in de richting waarnaar je kijkt."
|
||||
- "/as stack <aantal> <afstand> <naam> <rent|buy> [groep].[break]"
|
||||
- " [gray]<aantal> Het aantal gebieden dat word gemaakt.[break]"
|
||||
- " [gray]<afstand> Blokken afstand tussen de gebieden.[break]"
|
||||
- " [gray]<naam> Naam van de gebieden (komt een nummer achter).[break]"
|
||||
- " [gray]<rent|buy> Maak ze huur of koop gebieden.[break]"
|
||||
- " [gray][groep] Groep waaraan de gebieden worden toegevoegd.[break]"
|
||||
- " [gray]De gebieden zullen worden gemaakt in de richting waarnaar je kijkt."
|
||||
"stack-accepted": "Begonnen met %0% %1% gebieden maken met %2% blokken ruimte ertussen, namen beginnen met %3% en hebben een nummer erachter.%4%"
|
||||
"stack-addToGroup": " Gemaakte gebieden zullen worden toegevoegd aan de groep '%0%'."
|
||||
"stack-noPermission": "Je hebt geen toestemming om in grote aantallen gebieden toe te voegen aan AreaShop."
|
||||
@@ -519,30 +519,30 @@
|
||||
"import-signAlreadyAdded": "[red]Het toevoegen van een bordje op locatie '%1%' aan gebied '%0%' is overgeslagen, het is al aan gebied '%2%' toegevoegd."
|
||||
"import-moneyBackFailed": "[red]Het ontleden van de koop prijs '%0%' en de verkoop prijs '%1%' om het geld terug percentage in te voegen is mislukt."
|
||||
"confirm-rent":
|
||||
- "%lang:prefix%Weet je zeker dat je %lang:tRegion|%0%|% wilt huren?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klik om %0% te huren|%"
|
||||
- " hover: %lang:action|Huur %0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
- "%lang:prefix%Weet je zeker dat je %lang:tRegion|%0%|% wilt huren?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klik om %0% te huren|%"
|
||||
- " hover: %lang:action|Huur %0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
"confirm-extend":
|
||||
- "%lang:prefix%Weet je zeker dat je de huur van %lang:tRegion|%0%|% wilt verlengen?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klik om %0% te verlengen|%"
|
||||
- " hover: %lang:action|Verleng %0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
- "%lang:prefix%Weet je zeker dat je de huur van %lang:tRegion|%0%|% wilt verlengen?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klik om %0% te verlengen|%"
|
||||
- " hover: %lang:action|Verleng %0%|%"
|
||||
- " command: /areashop rent %0%"
|
||||
"confirm-unrent":
|
||||
- "%lang:prefix%Weet je zeker dat je de huur van %lang:tRegion|%0%|% wilt stoppen?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Stop de huur van %0%|%"
|
||||
- " hover: %lang:action|Stop de huur van %0%|%"
|
||||
- " command: /areashop unrent %0%"
|
||||
- "%lang:prefix%Weet je zeker dat je de huur van %lang:tRegion|%0%|% wilt stoppen?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Stop de huur van %0%|%"
|
||||
- " hover: %lang:action|Stop de huur van %0%|%"
|
||||
- " command: /areashop unrent %0%"
|
||||
"confirm-buy":
|
||||
- "%lang:prefix%Weet je zeker dat je %lang:tRegion|%0%|% wilt kopen?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klik om %0% te kopen|%"
|
||||
- " hover: %lang:action|Koop %0%|%"
|
||||
- " command: /areashop buy %0%"
|
||||
- "%lang:prefix%Weet je zeker dat je %lang:tRegion|%0%|% wilt kopen?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klik om %0% te kopen|%"
|
||||
- " hover: %lang:action|Koop %0%|%"
|
||||
- " command: /areashop buy %0%"
|
||||
"confirm-sell":
|
||||
- "%lang:prefix%Weet je zeker dat je %lang:tRegion|%0%|% wilt verkopen?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klik om %0% te verkopen|%"
|
||||
- " hover: %lang:action|Verkoop %0%|%"
|
||||
- " command: /areashop sell %0%"
|
||||
- "%lang:prefix%Weet je zeker dat je %lang:tRegion|%0%|% wilt verkopen?[break]"
|
||||
- "[darkgreen][bold]►[reset] %lang:button|Klik om %0% te verkopen|%"
|
||||
- " hover: %lang:action|Verkoop %0%|%"
|
||||
- " command: /areashop sell %0%"
|
||||
"timeleft-years": "%0% jaren"
|
||||
"timeleft-months": "%0% maanden"
|
||||
"timeleft-days": "%0% dagen"
|
||||
@@ -557,8 +557,8 @@
|
||||
"greeting-bought": "%region% is gekocht door %player%."
|
||||
"greeting-resale": "%region% kan gekocht worden voor %resellprice% van %player%."
|
||||
"update-playerNotify":
|
||||
- "[darkgreen]Update van AreaShop V%0% naar AreaShop V%1% beschikbaar, download de laatste versie op "
|
||||
- "[bold]Spigot[/bold]"
|
||||
- " hover: %lang:action|Ga naar de Spigot AreaShop pagina|%"
|
||||
- " link: https://www.spigotmc.org/resources/areashop.2991/"
|
||||
- " (en schrijf een review)."
|
||||
- "[darkgreen]Update van AreaShop V%0% naar AreaShop V%1% beschikbaar, download de laatste versie op "
|
||||
- "[bold]Spigot[/bold]"
|
||||
- " hover: %lang:action|Ga naar de Spigot AreaShop pagina|%"
|
||||
- " link: https://www.spigotmc.org/resources/areashop.2991/"
|
||||
- " (en schrijf een review)."
|
||||
Loaded 100 of 164 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user