diff --git a/.gitignore b/.gitignore
index 3703d73a..855b5414 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,4 +32,5 @@ hs_err_pid*
.project
# JDT-specific (Eclipse Java Development Tools)
-.classpath
\ No newline at end of file
+.classpath
+/target/
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 66fa1d77..60ec2d72 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,22 +1,21 @@
-image: gradle:alpine
-
-variables:
- name: "FabledSkyBlock"
- path: "/builds/$CI_PROJECT_PATH"
- version: "2.1.0"
-
-before_script:
- - export GRADLE_USER_HOME=`pwd`/.gradle
-
stages:
- build
+variables:
+ name: "FabledSkyblock"
+ path: "/builds/$CI_PROJECT_PATH"
+ version: "2.1.0"
+
build:
stage: build
+ image: maven:3.5.3-jdk-8
script:
- - find $path/ -type f -name "*.gradle" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
- - gradle build
- - mv $path/build/libs/*.jar $path/
+ - find $path/ -type f -name "*.xml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
+ - find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
+ - mvn clean package
+ - find $path/ -depth -path '*original*' -delete
+ - mv $path/target/*.jar $path/
artifacts:
+ name: $name-$version
paths:
- - $path/*.jar
+ - "$path/*.jar"
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 27f4c44d..00000000
--- a/build.gradle
+++ /dev/null
@@ -1,109 +0,0 @@
-import org.apache.tools.ant.filters.ReplaceTokens
-allprojects {
- apply plugin: 'java'
- apply plugin: 'eclipse'
- group = 'com.songoda.skyblock'
- version = 'maven-version-number'
-}
-
-configurations {
- shade
- compile.extendsFrom shade
-}
-
-repositories {
- mavenCentral()
- jcenter()
-
- //Spigot
- maven {
- url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
- }
-
- // Bungeecord
- maven {
- url 'https://oss.sonatype.org/content/repositories/snapshots/'
- }
-
- // Songoda
- maven {
- url 'http://repo.songoda.com/artifactory/private'
- }
-
- // Mojang
- maven {
- url 'https://libraries.minecraft.net/'
- }
-
- //Jitpack
- maven {
- url 'https://jitpack.io'
- }
-
-}
-
-dependencies {
-
- // Spigot
- implementation (group: 'org.spigotmc', name: 'spigot-api', version: '1.14.4-R0.1-SNAPSHOT')
-
- // GameProfile's Mojang
- implementation (group: 'com.mojang', name: 'authlib', version: '1.5.3')
-
- // PlaceholderAPI
- implementation (group: 'be.maximvdw', name: 'placeholderapi', version: '2.5.1')
- implementation (group: 'me.clip', name: 'placeholderapi', version: '2.10.2')
-
- // Vault
- implementation (group: 'net.milkbowl', name: 'vault', version: '1.7.1')
-
- // Reserve
- implementation (group: 'net.tnemc', name: 'Reserve', version: '0.1.3.0')
-
- // Leaderheads
- implementation (group: 'me.robin', name: 'leaderheads', version: '1.0')
-
- // EpicSpawners
- implementation (group: 'com.songoda', name: 'epicspawners', version: '6-pre4')
-
- // EpicAnchors
- implementation (group: 'com.songoda', name: 'EpicAnchors', version: '1.4.2')
-
- // UltimateStacker
- implementation (group: 'com.songoda', name: 'ultimatestacker', version: '1.3.1')
-
- // WildStacker
- implementation (group: 'com.github.OmerBenGera', name: 'WildStackerAPI', version: 'b15')
-
- // WorldEdit
- implementation (group: 'com.sk89q', name: 'worldedit', version: '7.0.0')
-
- // Apache Commons
- shade (group: 'org.apache.commons', name: 'commons-lang3', version: '3.0')
- shade (group: 'commons-io', name: 'commons-io', version: '2.5')
-
- // JSON.org
- shade (group: 'org.json', name: 'json', version: '20190722')
-
- // Songoda Updater
- shade (group: 'com.songoda', name: 'songodaupdater', version: '1')
-
- shade fileTree(dir: 'libraries', include: '*.jar')
-
-}
-
-processResources {
- filter ReplaceTokens, tokens: ["version": project.property("version")]
- from (sourceSets.main.resources.srcDirs) {
- include '**/*.yml'
- }
-}
-
-jar {
- configurations.shade.each { dep ->
- from(project.zipTree(dep)){
- exclude 'META-INF', 'META-INF/**'
- exclude '**/*.yml'
- }
- }
-}
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
new file mode 100644
index 00000000..84e6c40c
--- /dev/null
+++ b/dependency-reduced-pom.xml
@@ -0,0 +1,190 @@
+
+
+ 4.0.0
+ com.songoda
+ skyblock
+ 2.1.0
+
+
+
+ true
+ src/main/resources
+
+
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+ 1.8
+ 1.8
+
+
+
+ maven-shade-plugin
+ 3.2.1
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+
+ mvdw-software
+ MVdW Public Repositories
+ http://repo.mvdw-software.be/content/groups/public/
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ minecraft-repo
+ https://libraries.minecraft.net/
+
+
+ placeholderapi
+ https://repo.extendedclip.com/content/repositories/placeholderapi/
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+ reserve-repo
+ https://dl.bintray.com/theneweconomy/java/
+
+
+ sonatype
+ https://oss.sonatype.org/content/repositories/snapshots/
+
+
+ private
+ https://repo.songoda.com/artifactory/private/
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.15.1-R0.1-SNAPSHOT
+ provided
+
+
+ commons-lang
+ commons-lang
+
+
+ guava
+ com.google.guava
+
+
+ gson
+ com.google.code.gson
+
+
+ bungeecord-chat
+ net.md-5
+
+
+ snakeyaml
+ org.yaml
+
+
+
+
+ me.clip
+ placeholderapi
+ 2.9.2
+ provided
+
+
+ com.github.MilkBowl
+ VaultAPI
+ 1.7
+ provided
+
+
+ bukkit
+ org.bukkit
+
+
+
+
+ net.tnemc
+ Reserve
+ 0.1.3.0
+ provided
+
+
+ me.robin
+ leaderheads
+ 1.0
+ provided
+
+
+ com.songoda
+ epicspawners
+ 6-pre4
+ provided
+
+
+ com.songoda
+ EpicAnchors
+ 1.4.2
+ provided
+
+
+ com.songoda
+ ultimatestacker
+ 1.3.1
+ provided
+
+
+ com.github.OmerBenGera
+ WildStackerAPI
+ b15
+ provided
+
+
+ com.sk89q
+ worldedit
+ 7.0.0
+ provided
+
+
+ com.mojang
+ authlib
+ 1.5.3
+ provided
+
+
+ log4j-core
+ org.apache.logging.log4j
+
+
+ commons-codec
+ commons-codec
+
+
+ log4j-api
+ org.apache.logging.log4j
+
+
+ guava
+ com.google.guava
+
+
+ gson
+ com.google.code.gson
+
+
+
+
+
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 5c2d1cf0..00000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 5f1b1201..00000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-bin.zip
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
deleted file mode 100644
index b0d6d0ab..00000000
--- a/gradlew
+++ /dev/null
@@ -1,188 +0,0 @@
-#!/usr/bin/env sh
-
-#
-# Copyright 2015 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100644
index 9991c503..00000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,100 +0,0 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem http://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/libraries/Skyblock-LegacyChunkSnapshot.jar b/libraries/Skyblock-LegacyChunkSnapshot.jar
deleted file mode 100644
index 6cb28256..00000000
Binary files a/libraries/Skyblock-LegacyChunkSnapshot.jar and /dev/null differ
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 00000000..77d7449a
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,178 @@
+
+
+ 4.0.0
+ com.songoda
+ skyblock
+ 2.1.0
+
+
+
+ src/main/resources
+ true
+
+
+
+
+ maven-compiler-plugin
+ 3.8.0
+
+ 1.8
+ 1.8
+
+
+
+ maven-shade-plugin
+ 3.2.1
+
+
+ package
+
+ shade
+
+
+
+
+
+
+
+
+
+ mvdw-software
+ MVdW Public Repositories
+ http://repo.mvdw-software.be/content/groups/public/
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ minecraft-repo
+ https://libraries.minecraft.net/
+
+
+ placeholderapi
+ https://repo.extendedclip.com/content/repositories/placeholderapi/
+
+
+ jitpack.io
+ https://jitpack.io
+
+
+ reserve-repo
+ https://dl.bintray.com/theneweconomy/java/
+
+
+ sonatype
+ https://oss.sonatype.org/content/repositories/snapshots/
+
+
+ private
+ https://repo.songoda.com/artifactory/private/
+
+
+
+
+ org.spigotmc
+ spigot-api
+ 1.15.1-R0.1-SNAPSHOT
+ provided
+
+
+ be.maximvdw
+ MVdWPlaceholderAPI
+ 2.1.1-SNAPSHOT
+
+
+ org.spigotmc
+ spigot
+
+
+
+
+ me.clip
+ placeholderapi
+ 2.9.2
+ provided
+
+
+ com.github.MilkBowl
+ VaultAPI
+ 1.7
+ provided
+
+
+ net.tnemc
+ Reserve
+ 0.1.3.0
+ provided
+
+
+ me.robin
+ leaderheads
+ 1.0
+ provided
+
+
+ com.songoda
+ epicspawners
+ 6-pre4
+ provided
+
+
+ com.songoda
+ EpicAnchors
+ 1.4.2
+ provided
+
+
+ com.songoda
+ ultimatestacker
+ 1.3.1
+ provided
+
+
+ com.github.OmerBenGera
+ WildStackerAPI
+ b15
+ provided
+
+
+ com.sk89q
+ worldedit
+ 7.0.0
+ provided
+
+
+ com.mojang
+ authlib
+ 1.5.3
+ provided
+
+
+ org.json
+ json
+ 20190722
+ compile
+
+
+ com.songoda
+ songodaupdater
+ 1
+ compile
+
+
+ org.apache.commons
+ commons-lang3
+ 3.0
+ compile
+
+
+ commons-io
+ commons-io
+ 2.5
+ compile
+
+
+
diff --git a/settings.gradle b/settings.gradle
deleted file mode 100644
index 0296c83a..00000000
--- a/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-rootProject.name = 'FabledSkyblock'
\ No newline at end of file
diff --git a/src/main/java/com/songoda/skyblock/SkyBlock.java b/src/main/java/com/songoda/skyblock/SkyBlock.java
index e5d78d73..8e985680 100644
--- a/src/main/java/com/songoda/skyblock/SkyBlock.java
+++ b/src/main/java/com/songoda/skyblock/SkyBlock.java
@@ -1,5 +1,15 @@
package com.songoda.skyblock;
+import java.io.File;
+
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.command.ConsoleCommandSender;
+import org.bukkit.event.HandlerList;
+import org.bukkit.generator.ChunkGenerator;
+import org.bukkit.plugin.PluginManager;
+import org.bukkit.plugin.java.JavaPlugin;
+
import com.songoda.skyblock.api.SkyBlockAPI;
import com.songoda.skyblock.ban.BanManager;
import com.songoda.skyblock.biome.BiomeManager;
@@ -16,7 +26,28 @@ import com.songoda.skyblock.island.IslandManager;
import com.songoda.skyblock.leaderboard.LeaderboardManager;
import com.songoda.skyblock.levelling.rework.IslandLevelManager;
import com.songoda.skyblock.limit.LimitationInstanceHandler;
-import com.songoda.skyblock.listeners.*;
+import com.songoda.skyblock.listeners.Block;
+import com.songoda.skyblock.listeners.Bucket;
+import com.songoda.skyblock.listeners.Chat;
+import com.songoda.skyblock.listeners.Death;
+import com.songoda.skyblock.listeners.Entity;
+import com.songoda.skyblock.listeners.EpicSpawners;
+import com.songoda.skyblock.listeners.Food;
+import com.songoda.skyblock.listeners.Grow;
+import com.songoda.skyblock.listeners.Interact;
+import com.songoda.skyblock.listeners.Inventory;
+import com.songoda.skyblock.listeners.Item;
+import com.songoda.skyblock.listeners.Join;
+import com.songoda.skyblock.listeners.Move;
+import com.songoda.skyblock.listeners.Portal;
+import com.songoda.skyblock.listeners.Projectile;
+import com.songoda.skyblock.listeners.Quit;
+import com.songoda.skyblock.listeners.Respawn;
+import com.songoda.skyblock.listeners.Spawner;
+import com.songoda.skyblock.listeners.Teleport;
+import com.songoda.skyblock.listeners.UltimateStacker;
+import com.songoda.skyblock.listeners.WildStacker;
+import com.songoda.skyblock.localization.LocalizationManager;
import com.songoda.skyblock.menus.Rollback;
import com.songoda.skyblock.menus.admin.Creator;
import com.songoda.skyblock.menus.admin.Generator;
@@ -38,17 +69,6 @@ import com.songoda.skyblock.world.WorldManager;
import com.songoda.skyblock.world.generator.VoidGenerator;
import com.songoda.update.Plugin;
import com.songoda.update.SongodaUpdate;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.event.HandlerList;
-import org.bukkit.generator.ChunkGenerator;
-import org.bukkit.plugin.PluginManager;
-import org.bukkit.plugin.java.JavaPlugin;
-
-import java.io.File;
-import java.util.UUID;
public class SkyBlock extends JavaPlugin {
@@ -78,6 +98,7 @@ public class SkyBlock extends JavaPlugin {
private EconomyManager economyManager;
private HologramManager hologramManager;
private LimitationInstanceHandler limitationHandler;
+ private LocalizationManager localizationManager;
public static SkyBlock getInstance() {
return instance;
@@ -94,6 +115,7 @@ public class SkyBlock extends JavaPlugin {
instance = this;
fileManager = new FileManager(this);
+ localizationManager = new LocalizationManager();
worldManager = new WorldManager(this);
userCacheManager = new UserCacheManager(this);
economyManager = new EconomyManager();
@@ -105,8 +127,7 @@ public class SkyBlock extends JavaPlugin {
cooldownManager = new CooldownManager(this);
limitationHandler = new LimitationInstanceHandler();
- if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration()
- .getBoolean("Island.Scoreboard.Enable")) {
+ if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Scoreboard.Enable")) {
scoreboardManager = new ScoreboardManager(this);
}
@@ -117,13 +138,11 @@ public class SkyBlock extends JavaPlugin {
structureManager = new StructureManager(this);
soundManager = new SoundManager(this);
- if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration()
- .getBoolean("Island.Generator.Enable")) {
+ if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Generator.Enable")) {
generatorManager = new GeneratorManager(this);
}
- if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration()
- .getBoolean("Island.Stackable.Enable")) {
+ if (fileManager.getConfig(new File(getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.Enable")) {
stackableManager = new StackableManager(this);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> stackableManager.loadSavedStackables(), 5L);
}
@@ -160,12 +179,9 @@ public class SkyBlock extends JavaPlugin {
pluginManager.registerEvents(new Food(this), this);
pluginManager.registerEvents(new Grow(this), this);
- if (pluginManager.isPluginEnabled("EpicSpawners"))
- pluginManager.registerEvents(new EpicSpawners(this), this);
- if (pluginManager.isPluginEnabled("WildStacker"))
- pluginManager.registerEvents(new WildStacker(this), this);
- if (pluginManager.isPluginEnabled("UltimateStacker"))
- pluginManager.registerEvents(new UltimateStacker(this), this);
+ if (pluginManager.isPluginEnabled("EpicSpawners")) pluginManager.registerEvents(new EpicSpawners(this), this);
+ if (pluginManager.isPluginEnabled("WildStacker")) pluginManager.registerEvents(new WildStacker(this), this);
+ if (pluginManager.isPluginEnabled("UltimateStacker")) pluginManager.registerEvents(new UltimateStacker(this), this);
pluginManager.registerEvents(new Rollback(), this);
pluginManager.registerEvents(new Levelling(), this);
@@ -335,4 +351,8 @@ public class SkyBlock extends JavaPlugin {
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
return new VoidGenerator();
}
+
+ public LocalizationManager getLocalizationManager() {
+ return localizationManager;
+ }
}
diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java
index f0bebbeb..55314a0f 100644
--- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java
+++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java
@@ -1,5 +1,6 @@
package com.songoda.skyblock.blockscanner;
+import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
@@ -12,6 +13,8 @@ import org.bukkit.Bukkit;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Material;
import org.bukkit.World;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.collect.Lists;
@@ -55,10 +58,14 @@ public final class BlockScanner extends BukkitRunnable {
private final Queue blocks;
private final ScannerTasks tasks;
+ private int scanY;
+
private BlockScanner(Map> snapshots, ScannerTasks tasks) {
this.blocks = new ConcurrentLinkedQueue<>();
this.tasks = tasks;
+ FileConfiguration config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "config.yml")).getFileConfiguration();
+
int threadCount = 0;
for (Entry> entry : snapshots.entrySet()) {
@@ -67,16 +74,37 @@ public final class BlockScanner extends BukkitRunnable {
threadCount += parts.size();
+ World world = entry.getKey();
+ final String env;
+
+ switch (world.getEnvironment()) {
+ case NETHER:
+ env = "Nether";
+ break;
+ case THE_END:
+ env = "End";
+ break;
+ default:
+ env = "Normal";
+ break;
+ }
+
+ final ConfigurationSection liquidSection = config.getConfigurationSection("Island.World." + env + ".Liquid");
+
+ System.out.println("LiquidSection: " + liquidSection);
+
for (List sub : parts) {
- queueWork(entry.getKey(), sub);
+ queueWork(world, liquidSection.getBoolean("Enable") ? liquidSection.getInt("Height") + 1 : 0, sub);
}
}
-
+
this.threadCount = threadCount;
}
- private void queueWork(World world, List subList) {
+ private void queueWork(World world, int scanY, List subList) {
+
+
Bukkit.getServer().getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> {
for (ChunkSnapshot shot : subList) {
@@ -85,7 +113,7 @@ public final class BlockScanner extends BukkitRunnable {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
- for (int y = 0; y < 256; y++) {
+ for (int y = scanY; y < 256; y++) {
final Material type = VERSION > 12 ? shot.getBlockType(x, y, z) : MaterialIDHelper.getLegacyMaterial(getBlockTypeID(shot, x, y, z));
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java
index 23535649..373820f9 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/ReloadCommand.java
@@ -42,10 +42,8 @@ public class ReloadCommand extends SubCommand {
FileManager fileManager = skyblock.getFileManager();
messageManager.sendMessage(sender,
- "&cPlease note that this command is not supported and may " + "cause issues that could put the plugin in an unstable state. "
- + "If you encounter any issues please stop your server, edit the configuration files, "
- + "and then start your server again. This command does NOT reload all the plugin files, only "
- + "the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml.");
+ "&cPlease note that this command is not supported and may " + "cause issues that could put the plugin in an unstable state. " + "If you encounter any issues please stop your server, edit the configuration files, "
+ + "and then start your server again. This command does NOT reload all the plugin files, only " + "the config.yml, language.yml, generators.yml, levelling.yml, and limits.yml.");
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
@@ -95,6 +93,7 @@ public class ReloadCommand extends SubCommand {
});
limitHandler.reloadAll();
+ skyblock.getLocalizationManager().reloadAll();
MenuClickRegistry.getInstance().reloadAll();
messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.Reload.Reloaded.Message"));
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveHologramCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveHologramCommand.java
index a2789855..d633f768 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveHologramCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/RemoveHologramCommand.java
@@ -9,7 +9,8 @@ import com.songoda.skyblock.hologram.HologramType;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.version.Sounds;
-import org.apache.commons.lang3.text.WordUtils;
+
+import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@@ -44,15 +45,15 @@ public class RemoveHologramCommand extends SubCommand {
HologramType hologramType = null;
switch (args[0].toLowerCase()) {
- case "level":
- hologramType = HologramType.Level;
- break;
- case "bank":
- hologramType = HologramType.Bank;
- break;
- case "votes":
- hologramType = HologramType.Votes;
- break;
+ case "level":
+ hologramType = HologramType.Level;
+ break;
+ case "bank":
+ hologramType = HologramType.Bank;
+ break;
+ case "votes":
+ hologramType = HologramType.Votes;
+ break;
}
if (hologramType != null) {
@@ -60,8 +61,7 @@ public class RemoveHologramCommand extends SubCommand {
FileConfiguration locationsConfigLoad = locationsConfig.getFileConfiguration();
if (locationsConfigLoad.getString("Location.Hologram.Leaderboard." + hologramType.name()) == null) {
- messageManager.sendMessage(sender,
- configLoad.getString("Command.Island.Admin.RemoveHologram.Set.Message"));
+ messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Set.Message"));
soundManager.playSound(sender, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
} else {
locationsConfigLoad.set("Location.Hologram.Leaderboard." + hologramType.name(), null);
@@ -73,8 +73,7 @@ public class RemoveHologramCommand extends SubCommand {
}
Bukkit.getServer().getScheduler().runTask(skyblock, () -> {
- HologramType hologramType1 = HologramType
- .valueOf(WordUtils.capitalize(args[0].toLowerCase()));
+ HologramType hologramType1 = HologramType.valueOf(WordUtils.capitalize(args[0].toLowerCase()));
Hologram hologram = hologramManager.getHologram(hologramType1);
if (hologram != null) {
@@ -82,9 +81,7 @@ public class RemoveHologramCommand extends SubCommand {
}
});
- messageManager.sendMessage(sender,
- configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message")
- .replace("%type", hologramType.name()));
+ messageManager.sendMessage(sender, configLoad.getString("Command.Island.Admin.RemoveHologram.Removed.Message").replace("%type", hologramType.name()));
soundManager.playSound(sender, Sounds.NOTE_PLING.bukkitSound(), 1.0F, 1.0F);
}
@@ -113,6 +110,6 @@ public class RemoveHologramCommand extends SubCommand {
@Override
public String[] getArguments() {
- return new String[]{"level", "bank", "votes"};
+ return new String[] { "level", "bank", "votes" };
}
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/SetHologramCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/SetHologramCommand.java
index fe29fc36..4f705231 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/SetHologramCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/SetHologramCommand.java
@@ -9,7 +9,8 @@ import com.songoda.skyblock.hologram.HologramType;
import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.sound.SoundManager;
import com.songoda.skyblock.utils.version.Sounds;
-import org.apache.commons.lang3.text.WordUtils;
+
+import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
diff --git a/src/main/java/com/songoda/skyblock/command/commands/admin/StackableCommand.java b/src/main/java/com/songoda/skyblock/command/commands/admin/StackableCommand.java
index be606d18..3d22ed19 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/admin/StackableCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/admin/StackableCommand.java
@@ -14,9 +14,11 @@ import com.songoda.skyblock.message.MessageManager;
import com.songoda.skyblock.stackable.Stackable;
import com.songoda.skyblock.stackable.StackableManager;
import com.songoda.skyblock.utils.StringUtil;
+import com.songoda.skyblock.utils.version.Materials;
public class StackableCommand extends SubCommand {
+ @SuppressWarnings("deprecation")
@Override
public void onCommandByPlayer(Player player, String[] args) {
final MessageManager messageManager = skyblock.getMessageManager();
@@ -52,14 +54,15 @@ public class StackableCommand extends SubCommand {
}
final StackableManager stackableManager = skyblock.getStackableManager();
+ final Materials type = Materials.getMaterials(block.getType(), block.getData());
- if (!stackableManager.isStackableMaterial(block.getType())) {
+ if (!stackableManager.isStackableMaterial(type)) {
messageManager.sendMessage(player, messageConfig.getString("Command.Island.Admin.Stackable.Target.Unstackable"));
return;
}
final Location loc = block.getLocation();
- Stackable stack = stackableManager.getStack(loc, block.getType());
+ Stackable stack = stackableManager.getStack(loc, type);
if (amount <= 1) {
messageManager.sendMessage(player, messageConfig.getString("Command.Island.Admin.Stackable.Target.Remove-Stack"));
@@ -70,7 +73,7 @@ public class StackableCommand extends SubCommand {
final int oldSize;
if (stack == null) {
- stack = new Stackable(loc, block.getType());
+ stack = new Stackable(loc, type);
stackableManager.addStack(stack);
oldSize = 0;
} else {
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java
index 3263a7fa..40f66bc4 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/AcceptCommand.java
@@ -159,15 +159,7 @@ public class AcceptCommand extends SubCommand {
"Scoreboard.Island.Team.Occupied.Displaylines"));
}
- Map displayVariables = new HashMap<>();
- displayVariables.put("%owner",
- configLoad.getString("Scoreboard.Island.Team.Word.Owner"));
- displayVariables.put("%operator", configLoad
- .getString("Scoreboard.Island.Team.Word.Operator"));
- displayVariables.put("%member",
- configLoad.getString("Scoreboard.Island.Team.Word.Member"));
-
- scoreboard.setDisplayVariables(displayVariables);
+
scoreboard.run();
}
}
@@ -189,15 +181,7 @@ public class AcceptCommand extends SubCommand {
configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
}
- Map displayVariables = new HashMap<>();
- displayVariables.put("%owner",
- configLoad.getString("Scoreboard.Island.Team.Word.Owner"));
- displayVariables.put("%operator",
- configLoad.getString("Scoreboard.Island.Team.Word.Operator"));
- displayVariables.put("%member",
- configLoad.getString("Scoreboard.Island.Team.Word.Member"));
- scoreboard.setDisplayVariables(displayVariables);
scoreboard.run();
}
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java
index f3f55aa8..b3b0ec65 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/UpgradeCommand.java
@@ -30,7 +30,6 @@ public class UpgradeCommand extends SubCommand {
if (!skyblock.getEconomyManager().isEconomy()) {
messageManager.sendMessage(player, configLoad.getString("Command.Island.Upgrade.Disabled.Message"));
soundManager.playSound(player, Sounds.ANVIL_LAND.bukkitSound(), 1.0F, 1.0F);
-
return;
}
diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java
index 7992e63a..89841913 100644
--- a/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java
+++ b/src/main/java/com/songoda/skyblock/command/commands/island/ValueCommand.java
@@ -10,7 +10,8 @@ import com.songoda.skyblock.utils.NumberUtil;
import com.songoda.skyblock.utils.version.Materials;
import com.songoda.skyblock.utils.version.NMSUtil;
import com.songoda.skyblock.utils.version.Sounds;
-import org.apache.commons.lang3.text.WordUtils;
+
+import org.apache.commons.lang.WordUtils;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
diff --git a/src/main/java/com/songoda/skyblock/config/FileChecker.java b/src/main/java/com/songoda/skyblock/config/FileChecker.java
index aeba61f4..334de872 100644
--- a/src/main/java/com/songoda/skyblock/config/FileChecker.java
+++ b/src/main/java/com/songoda/skyblock/config/FileChecker.java
@@ -1,9 +1,5 @@
package com.songoda.skyblock.config;
-import com.songoda.skyblock.SkyBlock;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.EnumMap;
@@ -11,29 +7,29 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+import com.songoda.skyblock.SkyBlock;
+
public class FileChecker {
private final FileManager fileManager;
private Map loadedFiles;
- public FileChecker(SkyBlock skyblock, FileManager fileManager, String configurationFileName,
- boolean applyComments) {
+ public FileChecker(SkyBlock skyblock, FileManager fileManager, String configurationFileName, boolean applyComments) {
this.fileManager = fileManager;
loadedFiles = new EnumMap<>(File.Type.class);
java.io.File configFile = new java.io.File(skyblock.getDataFolder(), configurationFileName);
- loadedFiles.put(File.Type.CREATED,
- new File(fileManager, configFile, YamlConfiguration.loadConfiguration(configFile)));
+ loadedFiles.put(File.Type.CREATED, new File(fileManager, configFile, YamlConfiguration.loadConfiguration(configFile)));
if (applyComments) {
- loadedFiles.put(File.Type.RESOURCE,
- new File(null, null, YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager
- .getConfigContent(new InputStreamReader(skyblock.getResource(configurationFileName)))))));
+ loadedFiles.put(File.Type.RESOURCE, new File(null, null, YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager.getConfigContent(new InputStreamReader(skyblock.getResource(configurationFileName)))))));
} else {
- loadedFiles.put(File.Type.RESOURCE, new File(null, null, YamlConfiguration
- .loadConfiguration(new InputStreamReader(skyblock.getResource(configurationFileName)))));
+ loadedFiles.put(File.Type.RESOURCE, new File(null, null, YamlConfiguration.loadConfiguration(new InputStreamReader(skyblock.getResource(configurationFileName)))));
}
}
@@ -103,8 +99,7 @@ public class FileChecker {
configKeys = new HashMap<>();
if (configFile != null && configFile.getName().equals("config.yml")) {
- this.configLoad = YamlConfiguration
- .loadConfiguration(new InputStreamReader(fileManager.getConfigContent(configFile)));
+ this.configLoad = YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager.getConfigContent(configFile)));
}
}
@@ -125,7 +120,8 @@ public class FileChecker {
}
public enum Type {
- CREATED, RESOURCE
+ CREATED,
+ RESOURCE
}
}
}
diff --git a/src/main/java/com/songoda/skyblock/config/FileManager.java b/src/main/java/com/songoda/skyblock/config/FileManager.java
index 0ddf9abe..d013732c 100644
--- a/src/main/java/com/songoda/skyblock/config/FileManager.java
+++ b/src/main/java/com/songoda/skyblock/config/FileManager.java
@@ -1,15 +1,18 @@
package com.songoda.skyblock.config;
-import com.google.common.io.ByteStreams;
-import com.songoda.skyblock.SkyBlock;
-import com.songoda.skyblock.island.IslandWorld;
-import org.bukkit.Bukkit;
-import org.bukkit.Location;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.configuration.file.YamlConfiguration;
-
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -17,6 +20,16 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.logging.Level;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+import com.google.common.io.ByteStreams;
+import com.songoda.skyblock.SkyBlock;
+import com.songoda.skyblock.island.IslandWorld;
+
public class FileManager {
private final SkyBlock skyblock;
@@ -32,13 +45,13 @@ public class FileManager {
if (!skyblock.getDataFolder().exists()) {
skyblock.getDataFolder().mkdir();
}
-
+
File structureDirectory = new File(skyblock.getDataFolder().toString() + "/structures");
if (!structureDirectory.exists()) {
structureDirectory.mkdir();
}
-
+
// Will remain null unless WorldEdit is present.
File schematicsDirectory = null;
@@ -57,17 +70,16 @@ public class FileManager {
configFiles.put("generators.yml", new File(skyblock.getDataFolder(), "generators.yml"));
configFiles.put("stackables.yml", new File(skyblock.getDataFolder(), "stackables.yml"));
configFiles.put("structures.yml", new File(skyblock.getDataFolder(), "structures.yml"));
- configFiles.put("structures/default.structure",
- new File(skyblock.getDataFolder().toString() + "/structures", "default.structure"));
-
+ configFiles.put("structures/default.structure", new File(skyblock.getDataFolder().toString() + "/structures", "default.structure"));
+
File oldStructureFile = new File(skyblock.getDataFolder().toString() + "/structures", "default.structure");
oldStructureFile.delete();
for (Entry configEntry : configFiles.entrySet()) {
-
+
String fileName = configEntry.getKey();
File configFile = configEntry.getValue();
-
+
if (fileName.equals("structures/default.structure")) {
configFile.delete();
try {
@@ -75,8 +87,7 @@ public class FileManager {
} catch (IOException e) {
e.printStackTrace();
}
- try (InputStream is = skyblock.getResource(fileName);
- OutputStream os = new FileOutputStream(configFile)) {
+ try (InputStream is = skyblock.getResource(fileName); OutputStream os = new FileOutputStream(configFile)) {
ByteStreams.copy(is, os);
} catch (IOException e) {
e.printStackTrace();
@@ -85,8 +96,7 @@ public class FileManager {
}
if (configFile.exists()) {
- if (fileName.equals("config.yml") || fileName.equals("language.yml")
- || fileName.equals("settings.yml")) {
+ if (fileName.equals("config.yml") || fileName.equals("language.yml") || fileName.equals("settings.yml")) {
FileChecker fileChecker;
if (fileName.equals("config.yml")) {
@@ -102,8 +112,7 @@ public class FileManager {
} else {
try {
configFile.createNewFile();
- try (InputStream is = skyblock.getResource(fileName);
- OutputStream os = new FileOutputStream(configFile)) {
+ try (InputStream is = skyblock.getResource(fileName); OutputStream os = new FileOutputStream(configFile)) {
ByteStreams.copy(is, os);
}
@@ -119,12 +128,8 @@ public class FileManager {
for (IslandWorld worldList : IslandWorld.values()) {
if (mainConfigLoad.getString("World." + worldList.name()) != null) {
- configLoad.set("World." + worldList.name() + ".nextAvailableLocation.x",
- mainConfigLoad.getDouble(
- "World." + worldList.name() + ".nextAvailableLocation.x"));
- configLoad.set("World." + worldList.name() + ".nextAvailableLocation.z",
- mainConfigLoad.getDouble(
- "World." + worldList.name() + ".nextAvailableLocation.z"));
+ configLoad.set("World." + worldList.name() + ".nextAvailableLocation.x", mainConfigLoad.getDouble("World." + worldList.name() + ".nextAvailableLocation.x"));
+ configLoad.set("World." + worldList.name() + ".nextAvailableLocation.z", mainConfigLoad.getDouble("World." + worldList.name() + ".nextAvailableLocation.z"));
}
}
@@ -135,8 +140,7 @@ public class FileManager {
}
}
} catch (IOException ex) {
- Bukkit.getServer().getLogger().log(Level.WARNING,
- "SkyBlock | Error: Unable to create configuration file.");
+ Bukkit.getServer().getLogger().log(Level.WARNING, "SkyBlock | Error: Unable to create configuration file.");
}
}
}
@@ -229,8 +233,7 @@ public class FileManager {
while ((currentLine = bufferedReader.readLine()) != null) {
if (currentLine.contains("#")) {
- addLine = currentLine.replace("[!]", "IMPORTANT").replace(":", "-").replaceFirst("#",
- pluginName + "_COMMENT_" + commentNum + ":");
+ addLine = currentLine.replace("[!]", "IMPORTANT").replace(":", "-").replaceFirst("#", pluginName + "_COMMENT_" + commentNum + ":");
whole.append(addLine + "\n");
commentNum++;
} else {
@@ -270,9 +273,7 @@ public class FileManager {
for (String line : lines) {
if (line.contains(skyblock.getDescription().getName() + "_COMMENT")) {
- config.append(line.replace("IMPORTANT", "[!]").replace("\n", "")
- .replace(skyblock.getDescription().getName() + "_COMMENT_", "#").replaceAll("[0-9]+:", "")
- + "\n");
+ config.append(line.replace("IMPORTANT", "[!]").replace("\n", "").replace(skyblock.getDescription().getName() + "_COMMENT_", "#").replaceAll("[0-9]+:", "") + "\n");
} else if (line.contains(":")) {
config.append(line + "\n");
}
@@ -301,8 +302,7 @@ public class FileManager {
configFile = configPath;
if (configPath.getName().equals("config.yml")) {
- configLoad = YamlConfiguration
- .loadConfiguration(new InputStreamReader(fileManager.getConfigContent(configFile)));
+ configLoad = YamlConfiguration.loadConfiguration(new InputStreamReader(fileManager.getConfigContent(configFile)));
} else {
configLoad = YamlConfiguration.loadConfiguration(configPath);
}
diff --git a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java
index eefc0136..cfa9443e 100644
--- a/src/main/java/com/songoda/skyblock/economy/EconomyManager.java
+++ b/src/main/java/com/songoda/skyblock/economy/EconomyManager.java
@@ -1,16 +1,18 @@
package com.songoda.skyblock.economy;
-import com.songoda.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
-import net.milkbowl.vault.economy.Economy;
-import net.milkbowl.vault.permission.Permission;
-import net.tnemc.core.Reserve;
-import net.tnemc.core.economy.EconomyAPI;
+import java.math.BigDecimal;
+
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.plugin.RegisteredServiceProvider;
-import java.math.BigDecimal;
+import com.songoda.skyblock.api.event.player.PlayerWithdrawMoneyEvent;
+
+import net.milkbowl.vault.economy.Economy;
+import net.milkbowl.vault.permission.Permission;
+import net.tnemc.core.Reserve;
+import net.tnemc.core.economy.EconomyAPI;
public class EconomyManager {
@@ -20,7 +22,7 @@ public class EconomyManager {
// Reserve
private EconomyAPI reserveEconomy = null;
-// private PermissionsAPI reservePermission = null;
+ // private PermissionsAPI reservePermission = null;
public EconomyManager() {
setup();
@@ -30,27 +32,22 @@ public class EconomyManager {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
RegisteredServiceProvider economyRsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
- if (economyRsp != null)
- this.vaultEconomy = economyRsp.getProvider();
+ if (economyRsp != null) this.vaultEconomy = economyRsp.getProvider();
RegisteredServiceProvider permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
- if (permissionRsp != null)
- this.vaultPermission = permissionRsp.getProvider();
+ if (permissionRsp != null) this.vaultPermission = permissionRsp.getProvider();
} else if (Bukkit.getServer().getPluginManager().getPlugin("Reserve") != null) {
- if (Reserve.instance().economyProvided())
- this.reserveEconomy = Reserve.instance().economy();
+ if (Reserve.instance().economyProvided()) this.reserveEconomy = Reserve.instance().economy();
-// if (Reserve.instance().permissionsProvided())
-// this.reservePermission = Reserve.instance().permissions();
+ // if (Reserve.instance().permissionsProvided())
+ // this.reservePermission = Reserve.instance().permissions();
}
}
public double getBalance(Player player) {
- if (this.vaultEconomy != null)
- return this.vaultEconomy.getBalance(player);
+ if (this.vaultEconomy != null) return this.vaultEconomy.getBalance(player);
- if (this.reserveEconomy != null)
- return this.reserveEconomy.getHoldings(player.getUniqueId()).doubleValue();
+ if (this.reserveEconomy != null) return this.reserveEconomy.getHoldings(player.getUniqueId()).doubleValue();
return 0;
}
@@ -60,30 +57,25 @@ public class EconomyManager {
}
public void withdraw(Player player, double money) {
- if (this.vaultEconomy != null)
- this.vaultEconomy.withdrawPlayer(player, money);
- else if (this.reserveEconomy != null)
- this.reserveEconomy.removeHoldings(player.getUniqueId(), new BigDecimal(money));
+ if (this.vaultEconomy != null) this.vaultEconomy.withdrawPlayer(player, money);
+ else if (this.reserveEconomy != null) this.reserveEconomy.removeHoldings(player.getUniqueId(), new BigDecimal(money));
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
}
public void deposit(Player player, double money) {
- if (this.vaultEconomy != null)
- this.vaultEconomy.depositPlayer(player, money);
- else if (this.reserveEconomy != null)
- this.reserveEconomy.addHoldings(player.getUniqueId(), new BigDecimal(money));
+ if (this.vaultEconomy != null) this.vaultEconomy.depositPlayer(player, money);
+ else if (this.reserveEconomy != null) this.reserveEconomy.addHoldings(player.getUniqueId(), new BigDecimal(money));
Bukkit.getServer().getPluginManager().callEvent(new PlayerWithdrawMoneyEvent(player, money));
}
public boolean hasPermission(String world, OfflinePlayer offlinePlayer, String perm) {
- if (this.vaultPermission != null)
- return this.vaultPermission.playerHas(world, offlinePlayer, perm);
+ if (this.vaultPermission != null) return this.vaultPermission.playerHas(world, offlinePlayer, perm);
-// if (this.reservePermission != null) {
-// // TODO
-// }
+ // if (this.reservePermission != null) {
+ // // TODO
+ // }
return false;
}
@@ -93,6 +85,6 @@ public class EconomyManager {
}
public boolean isPermission() {
- return this.vaultPermission != null/* || this.reservePermission != null*/;
+ return this.vaultPermission != null/* || this.reservePermission != null */;
}
}
diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java
index d9f3f47d..4763028f 100644
--- a/src/main/java/com/songoda/skyblock/island/Island.java
+++ b/src/main/java/com/songoda/skyblock/island/Island.java
@@ -755,13 +755,13 @@ public class Island {
Config config = fileManager
.getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml"));
-
+
try {
config.getFileConfiguration().save(config.getFile());
} catch (IOException e) {
e.printStackTrace();
}
-
+
config = fileManager
.getConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", ownerUUID.toString() + ".yml"));
FileConfiguration configLoad = config.getFileConfiguration();
diff --git a/src/main/java/com/songoda/skyblock/island/IslandManager.java b/src/main/java/com/songoda/skyblock/island/IslandManager.java
index 491fa8e2..c3a357ed 100644
--- a/src/main/java/com/songoda/skyblock/island/IslandManager.java
+++ b/src/main/java/com/songoda/skyblock/island/IslandManager.java
@@ -25,7 +25,6 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.IllegalPluginAccessException;
-import org.bukkit.scheduler.BukkitRunnable;
import com.google.common.base.Preconditions;
import com.songoda.skyblock.SkyBlock;
@@ -236,7 +235,8 @@ public class IslandManager {
Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> Bukkit.getServer().getPluginManager().callEvent(new IslandCreateEvent(island.getAPIWrapper(), player)));
- skyblock.getPlayerDataManager().getPlayerData(player).setIsland(player.getUniqueId());
+ data.setIsland(player.getUniqueId());
+ data.setOwner(player.getUniqueId());
if (scoreboardManager != null) {
Config languageConfig = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
@@ -639,12 +639,6 @@ public class IslandManager {
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
- HashMap displayVariables = new HashMap<>();
- displayVariables.put("%owner", configLoad.getString("Scoreboard.Island.Team.Word.Owner"));
- displayVariables.put("%operator", configLoad.getString("Scoreboard.Island.Team.Word.Operator"));
- displayVariables.put("%member", configLoad.getString("Scoreboard.Island.Team.Word.Member"));
-
- scoreboard.setDisplayVariables(displayVariables);
scoreboard.run();
}
} catch (IllegalPluginAccessException e) {
@@ -888,12 +882,7 @@ public class IslandManager {
scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', configLoad.getString("Scoreboard.Island.Team.Displayname")));
scoreboard.setDisplayList(configLoad.getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
- HashMap displayVariables = new HashMap<>();
- displayVariables.put("%owner", configLoad.getString("Scoreboard.Island.Team.Word.Owner"));
- displayVariables.put("%operator", configLoad.getString("Scoreboard.Island.Team.Word.Operator"));
- displayVariables.put("%member", configLoad.getString("Scoreboard.Island.Team.Word.Member"));
- scoreboard.setDisplayVariables(displayVariables);
}
scoreboard.run();
diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java
index e139049f..9291cec7 100644
--- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java
+++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandLevelManager.java
@@ -3,14 +3,18 @@ package com.songoda.skyblock.levelling.rework;
import java.io.File;
import java.util.ArrayList;
import java.util.EnumMap;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
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.CreatureSpawner;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
@@ -33,6 +37,20 @@ import com.songoda.skyblock.utils.version.NMSUtil;
public final class IslandLevelManager {
+ private static final Set CHECKED_DOUBLE_TYPES;
+
+ static {
+ CHECKED_DOUBLE_TYPES = EnumSet.noneOf(Materials.class);
+
+ CHECKED_DOUBLE_TYPES.add(Materials.SUNFLOWER);
+ CHECKED_DOUBLE_TYPES.add(Materials.LILAC);
+ CHECKED_DOUBLE_TYPES.add(Materials.LEGACY_DOUBLE_PLANT);
+ CHECKED_DOUBLE_TYPES.add(Materials.LARGE_FERN);
+ CHECKED_DOUBLE_TYPES.add(Materials.ROSE_BUSH);
+ CHECKED_DOUBLE_TYPES.add(Materials.PEONY);
+ CHECKED_DOUBLE_TYPES.add(Materials.TALL_GRASS);
+ }
+
private final static int VERSION = NMSUtil.getVersionNumber();
private Map inScan;
private Map worth;
@@ -46,6 +64,16 @@ public final class IslandLevelManager {
reloadWorth();
}
+ public static boolean isDoubleCheckedBlock(Block block) {
+ return CHECKED_DOUBLE_TYPES.contains(parseType(block));
+ }
+
+ @SuppressWarnings("deprecation")
+ private static Materials parseType(Block block) {
+ final Material blockType = block.getType();
+ return VERSION > 12 ? Materials.fromString(blockType.name()) : Materials.requestMaterials(blockType.name(), block.getData());
+ }
+
public void startScan(Player attemptScanner, Island island) {
if (!Bukkit.isPrimaryThread()) {
@@ -103,7 +131,7 @@ public final class IslandLevelManager {
final Materials material = Materials.fromString(key);
- if (material.isAvailable() || material.getPostItem() == null) continue;
+ if (material == null || !material.isAvailable()) continue;
worth.put(material, current.getLong("Points"));
}
@@ -151,23 +179,42 @@ public final class IslandLevelManager {
private static final AmountMaterialPair EMPTY = new AmountMaterialPair(null, 0);
- @SuppressWarnings("deprecation")
- public AmountMaterialPair getAmountAndType(BlockInfo info) {
+ AmountMaterialPair getAmountAndType(IslandScan scan, BlockInfo info) {
- final Block block = info.getWorld().getBlockAt(info.getX(), info.getY(), info.getZ());
- final Material blockType = block.getType();
+ Block block = info.getWorld().getBlockAt(info.getX(), info.getY(), info.getZ());
+ Material blockType = block.getType();
if (blockType == Material.AIR) return EMPTY;
- Materials finalType = VERSION > 12 ? Materials.fromString(blockType.name()) : Materials.requestMaterials(blockType.name(), block.getData());
+ Materials finalType = parseType(block);
if (finalType == null) return EMPTY;
- if (finalType == Materials.SPAWNER) finalType = Materials.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
+
+ final Location blockLocation = block.getLocation();
+
+ if (scan.getDoubleBlocks().contains(blockLocation)) return EMPTY;
+
+ if (CHECKED_DOUBLE_TYPES.contains(finalType)) {
+
+ final Block belowBlock = block.getRelative(BlockFace.DOWN);
+ final Materials belowType = parseType(belowBlock);
+
+ if (CHECKED_DOUBLE_TYPES.contains(belowType)) {
+ block = belowBlock;
+ blockType = belowType.parseMaterial();
+ scan.getDoubleBlocks().add(belowBlock.getLocation());
+ } else {
+ scan.getDoubleBlocks().add(block.getRelative(BlockFace.UP).getLocation());
+ }
+
+ } else if (finalType == Materials.SPAWNER) {
+ finalType = Materials.getSpawner(((CreatureSpawner) block.getState()).getSpawnedType());
+ }
final List calculators = CalculatorRegistry.getCalculators(blockType);
final StackableManager stackableManager = SkyBlock.getInstance().getStackableManager();
- final long stackSize = stackableManager == null ? 0 : stackableManager.getStackSizeOf(block.getLocation(), blockType);
+ final long stackSize = stackableManager == null ? 0 : stackableManager.getStackSizeOf(blockLocation, finalType);
if (calculators == null) {
diff --git a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java
index dd4a3e85..81c08f44 100644
--- a/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java
+++ b/src/main/java/com/songoda/skyblock/levelling/rework/IslandScan.java
@@ -4,15 +4,18 @@ import java.io.File;
import java.text.NumberFormat;
import java.util.EnumMap;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Queue;
+import java.util.Set;
import java.util.stream.Collectors;
import org.bukkit.Bukkit;
import org.bukkit.ChunkSnapshot;
+import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.file.FileConfiguration;
@@ -36,6 +39,7 @@ public final class IslandScan extends BukkitRunnable {
private static final NumberFormat FORMATTER = NumberFormat.getInstance();;
+ private final Set doubleBlocks;
private final Island island;
private final Map amounts;
private final Configuration config;
@@ -51,14 +55,14 @@ public final class IslandScan extends BukkitRunnable {
this.amounts = new EnumMap<>(Materials.class);
this.config = SkyBlock.getInstance().getFileManager().getConfig(new File(SkyBlock.getInstance().getDataFolder(), "language.yml")).getFileConfiguration();
this.runEveryX = config.getInt("Command.Island.Level.Scanning.Progress.Display-Every-X-Scan");
+ this.doubleBlocks = new HashSet<>();
}
public IslandScan start() {
final SkyBlock skyblock = SkyBlock.getInstance();
final FileConfiguration config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration();
- final FileConfiguration islandData = skyblock.getFileManager()
- .getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), this.island.getOwnerUUID().toString() + ".yml")).getFileConfiguration();
+ final FileConfiguration islandData = skyblock.getFileManager().getConfig(new File(new File(skyblock.getDataFolder().toString() + "/island-data"), this.island.getOwnerUUID().toString() + ".yml")).getFileConfiguration();
final boolean hasNether = config.getBoolean("Island.World.Nether.Enable") && islandData.getBoolean("Unlocked.Nether", false);
final boolean hasEnd = config.getBoolean("Island.World.End.Enable") && islandData.getBoolean("Unlocked.End", false);
@@ -109,7 +113,7 @@ public final class IslandScan extends BukkitRunnable {
if (scanned == 8500) break;
- final AmountMaterialPair pair = SkyBlock.getInstance().getLevellingManager().getAmountAndType(info);
+ final AmountMaterialPair pair = SkyBlock.getInstance().getLevellingManager().getAmountAndType(this, info);
if (pair.getType() != null) {
@@ -164,4 +168,8 @@ public final class IslandScan extends BukkitRunnable {
snapshots.put(skyblock.getWorldManager().getWorld(world), ChunkUtil.getChunksToScan(island, world).stream().map(org.bukkit.Chunk::getChunkSnapshot).collect(Collectors.toList()));
}
+ public Set getDoubleBlocks() {
+ return doubleBlocks;
+ }
+
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Block.java b/src/main/java/com/songoda/skyblock/listeners/Block.java
index d7f1ed45..04d1f5ce 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Block.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Block.java
@@ -7,7 +7,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.commons.lang3.text.WordUtils;
+import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -85,22 +85,27 @@ public class Block implements Listener {
if (!islandManager.hasPermission(player, blockLocation, "Destroy")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
if (stackableManager != null && stackableManager.isStacked(blockLocation)) {
- Stackable stackable = stackableManager.getStack(block.getLocation(), block.getType());
+ Stackable stackable = stackableManager.getStack(block.getLocation(), Materials.getMaterials(block.getType(), block.getData()));
if (stackable != null) {
Material material = block.getType();
byte data = block.getData();
int droppedAmount = 0;
if (event.getPlayer().isSneaking()) {
- droppedAmount = stackable.getSize();
- block.getWorld().dropItemNaturally(blockLocation.clone().add(0.5, 0.5, 0.5), new ItemStack(material, droppedAmount, block.getData()));
+ Location dropLoc = blockLocation.clone().add(0.5, 0.5, 0.5);
+ int count = stackable.getSize();
+ droppedAmount = count;
+ while (count > 64) {
+ dropLoc.getWorld().dropItemNaturally(dropLoc, new ItemStack(material, 64, data));
+ count -= 64;
+ }
+ dropLoc.getWorld().dropItemNaturally(dropLoc, new ItemStack(material, count, block.getData()));
block.setType(Material.AIR);
stackable.setSize(0);
} else {
@@ -146,14 +151,23 @@ public class Block implements Listener {
|| LocationUtil.isLocationLocation(block.getLocation(), island.getLocation(world, IslandEnvironment.Main).clone())) {
if (configLoad.getBoolean("Island.Spawn.Protection")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Break.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
if (event.isCancelled() || !configLoad.getBoolean("Island.Block.Level.Enable")) return;
+ if (IslandLevelManager.isDoubleCheckedBlock(block)) {
+
+ final org.bukkit.block.Block belowBlock = block.getRelative(BlockFace.DOWN);
+
+ if (IslandLevelManager.isDoubleCheckedBlock(belowBlock)) {
+ block = belowBlock;
+ }
+
+ }
+
final Materials materials;
if (block.getType() == Materials.SPAWNER.parseMaterial()) {
@@ -189,7 +203,7 @@ public class Block implements Listener {
if (!worldManager.isIslandWorld(block.getWorld())) return;
Location blockLoc = block.getLocation();
-
+
Island island = islandManager.getIslandAtLocation(blockLoc);
if (island == null) {
@@ -198,24 +212,23 @@ public class Block implements Listener {
}
if (levellingManager.isScanning(island)) {
- skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
+ skyblock.getMessageManager().sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
event.setCancelled(true);
return;
}
if (!islandManager.hasPermission(player, blockLoc, "Place")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
-
+
Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
IslandWorld world = worldManager.getIslandWorld(block.getWorld());
-
+
if (configLoad.getBoolean("Island.WorldBorder.Block") && block.getType() == Material.DISPENSER) {
if (!islandManager.isLocationAtIsland(island, blockLoc, world)) {
event.setCancelled(true);
@@ -238,8 +251,7 @@ public class Block implements Listener {
}
if (isObstructing) {
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.SpawnProtection.Place.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
event.setCancelled(true);
@@ -254,9 +266,8 @@ public class Block implements Listener {
if (limits.isBlockLimitExceeded(player, block, limit)) {
Materials material = Materials.getMaterials(block.getType(), block.getData());
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
- .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
+ .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
event.setCancelled(true);
@@ -338,8 +349,8 @@ public class Block implements Listener {
// Filter valid players on the island
Set possiblePlayers = new HashSet<>();
for (Player p : Bukkit.getOnlinePlayers()) {
- boolean isMember = island.hasRole(IslandRole.Owner, p.getUniqueId()) || island.hasRole(IslandRole.Member, p.getUniqueId())
- || island.hasRole(IslandRole.Coop, p.getUniqueId()) || island.hasRole(IslandRole.Operator, p.getUniqueId());
+ boolean isMember = island.hasRole(IslandRole.Owner, p.getUniqueId()) || island.hasRole(IslandRole.Member, p.getUniqueId()) || island.hasRole(IslandRole.Coop, p.getUniqueId())
+ || island.hasRole(IslandRole.Operator, p.getUniqueId());
if (isMember && islandManager.isLocationAtIsland(island, p.getLocation(), world)) {
possiblePlayers.add(p);
}
@@ -387,8 +398,7 @@ public class Block implements Listener {
IslandWorld world = worldManager.getIslandWorld(event.getBlock().getWorld());
for (org.bukkit.block.Block block : event.getBlocks()) {
- if (!islandManager.isLocationAtIsland(island, block.getLocation(), world)
- || !islandManager.isLocationAtIsland(island, block.getRelative(event.getDirection()).getLocation(), world)) {
+ if (!islandManager.isLocationAtIsland(island, block.getLocation(), world) || !islandManager.isLocationAtIsland(island, block.getRelative(event.getDirection()).getLocation(), world)) {
event.setCancelled(true);
return;
}
@@ -513,8 +523,7 @@ public class Block implements Listener {
// Check ice/snow forming
if (block.getType() == Material.ICE || block.getType() == Material.SNOW) {
- if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.IceAndSnow"))
- event.setCancelled(true);
+ if (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Weather.IceAndSnow")) event.setCancelled(true);
return;
}
@@ -550,8 +559,8 @@ public class Block implements Listener {
// Filter valid players on the island.
Set possiblePlayers = new HashSet<>();
for (Player player : Bukkit.getOnlinePlayers()) {
- boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) || island.hasRole(IslandRole.Member, player.getUniqueId())
- || island.hasRole(IslandRole.Coop, player.getUniqueId()) || island.hasRole(IslandRole.Operator, player.getUniqueId());
+ boolean isMember = island.hasRole(IslandRole.Owner, player.getUniqueId()) || island.hasRole(IslandRole.Member, player.getUniqueId()) || island.hasRole(IslandRole.Coop, player.getUniqueId())
+ || island.hasRole(IslandRole.Operator, player.getUniqueId());
if (isMember && islandManager.isLocationAtIsland(island, player.getLocation(), world)) {
possiblePlayers.add(player);
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Interact.java b/src/main/java/com/songoda/skyblock/listeners/Interact.java
index 08edf155..3458ce02 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Interact.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Interact.java
@@ -1,26 +1,8 @@
package com.songoda.skyblock.listeners;
-import com.songoda.skyblock.SkyBlock;
-import com.songoda.skyblock.config.FileManager;
-import com.songoda.skyblock.island.Island;
-import com.songoda.skyblock.island.IslandLevel;
-import com.songoda.skyblock.island.IslandManager;
-import com.songoda.skyblock.island.IslandWorld;
-import com.songoda.skyblock.levelling.rework.IslandLevelManager;
-import com.songoda.skyblock.limit.impl.BlockLimitation;
-import com.songoda.skyblock.message.MessageManager;
-import com.songoda.skyblock.sound.SoundManager;
-import com.songoda.skyblock.stackable.Stackable;
-import com.songoda.skyblock.stackable.StackableManager;
-import com.songoda.skyblock.utils.NumberUtil;
-import com.songoda.skyblock.utils.item.InventoryUtil;
-import com.songoda.skyblock.utils.structure.StructureUtil;
-import com.songoda.skyblock.utils.version.Materials;
-import com.songoda.skyblock.utils.version.NMSUtil;
-import com.songoda.skyblock.utils.version.Sounds;
-import com.songoda.skyblock.world.WorldManager;
+import java.io.File;
-import org.apache.commons.lang3.text.WordUtils;
+import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@@ -46,7 +28,25 @@ import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
-import java.io.File;
+import com.songoda.skyblock.SkyBlock;
+import com.songoda.skyblock.config.FileManager;
+import com.songoda.skyblock.island.Island;
+import com.songoda.skyblock.island.IslandLevel;
+import com.songoda.skyblock.island.IslandManager;
+import com.songoda.skyblock.island.IslandWorld;
+import com.songoda.skyblock.levelling.rework.IslandLevelManager;
+import com.songoda.skyblock.limit.impl.BlockLimitation;
+import com.songoda.skyblock.message.MessageManager;
+import com.songoda.skyblock.sound.SoundManager;
+import com.songoda.skyblock.stackable.Stackable;
+import com.songoda.skyblock.stackable.StackableManager;
+import com.songoda.skyblock.utils.NumberUtil;
+import com.songoda.skyblock.utils.item.InventoryUtil;
+import com.songoda.skyblock.utils.structure.StructureUtil;
+import com.songoda.skyblock.utils.version.Materials;
+import com.songoda.skyblock.utils.version.NMSUtil;
+import com.songoda.skyblock.utils.version.Sounds;
+import com.songoda.skyblock.world.WorldManager;
public class Interact implements Listener {
@@ -83,8 +83,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "DragonEggUse")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -93,8 +92,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Beacon")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -103,8 +101,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -113,8 +110,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Place") || !islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -127,16 +123,25 @@ public class Interact implements Listener {
if (!skyblock.getIslandManager().hasPermission(player, "Projectile")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- if (stackableManager != null && stackableManager.isStackableMaterial(event.getMaterial()) && event.getClickedBlock().getType() == event.getMaterial() && !player.isSneaking()
- && islandManager.hasPermission(player, block.getLocation(), "Place")
+
+ final Materials blockType = Materials.getMaterials(event.getClickedBlock().getType(), event.getClickedBlock().getData());
+ final Materials heldType;
+ final ItemStack item = event.getItem();
+
+ if (item != null && item.getType() != Material.AIR) {
+ heldType = Materials.getMaterials(event.getItem().getType(), (byte) event.getItem().getDurability());
+ } else {
+ heldType = Materials.AIR;
+ }
+
+ if (stackableManager != null && stackableManager.isStackableMaterial(heldType) && blockType == heldType && !player.isSneaking() && islandManager.hasPermission(player, block.getLocation(), "Place")
&& (!skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Stackable.RequirePermission")
|| player.hasPermission("fabledskyblock.stackable"))) {
if (NMSUtil.getVersionNumber() > 8) {
@@ -144,8 +149,8 @@ public class Interact implements Listener {
}
if (levellingManager.isScanning(island)) {
- skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
+ skyblock.getMessageManager().sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Command.Island.Level.Scanning.BlockPlacing.Message"));
event.setCancelled(true);
return;
}
@@ -157,9 +162,8 @@ public class Interact implements Listener {
if (limits.isBlockLimitExceeded(player, block, limit)) {
Materials material = Materials.getMaterials(block.getType(), block.getData());
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
- .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Limit.Block.Exceeded.Message")
+ .replace("%type", WordUtils.capitalizeFully(material.name().replace("_", " "))).replace("%limit", NumberUtil.formatNumber(limit)));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
event.setCancelled(true);
@@ -167,11 +171,11 @@ public class Interact implements Listener {
}
Location location = event.getClickedBlock().getLocation();
- Stackable stackable = stackableManager.getStack(location, event.getMaterial());
+ Stackable stackable = stackableManager.getStack(location, blockType);
int itemAmount = event.getItem().getAmount();
if (stackable == null) {
- stackableManager.addStack(stackable = new Stackable(location, event.getMaterial()));
+ stackableManager.addStack(stackable = new Stackable(location, blockType));
stackable.setSize(itemAmount + 1);
} else {
stackable.setSize(stackable.getSize() + itemAmount);
@@ -182,7 +186,7 @@ public class Interact implements Listener {
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
FileConfiguration configLoad = config.getFileConfiguration();
-
+
if (!configLoad.getBoolean("Island.Block.Level.Enable")) return;
Materials materials = Materials.getMaterials(block.getType(), block.getData());
@@ -218,8 +222,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -228,26 +231,21 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Anvil")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
- } else if (block.getType() == Materials.LEGACY_BED_BLOCK.parseMaterial() || block.getType() == Materials.WHITE_BED.parseMaterial()
- || block.getType() == Materials.ORANGE_BED.parseMaterial() || block.getType() == Materials.MAGENTA_BED.parseMaterial()
- || block.getType() == Materials.LIGHT_BLUE_BED.parseMaterial() || block.getType() == Materials.YELLOW_BED.parseMaterial()
+ } else if (block.getType() == Materials.LEGACY_BED_BLOCK.parseMaterial() || block.getType() == Materials.WHITE_BED.parseMaterial() || block.getType() == Materials.ORANGE_BED.parseMaterial()
+ || block.getType() == Materials.MAGENTA_BED.parseMaterial() || block.getType() == Materials.LIGHT_BLUE_BED.parseMaterial() || block.getType() == Materials.YELLOW_BED.parseMaterial()
|| block.getType() == Materials.LIME_BED.parseMaterial() || block.getType() == Materials.PINK_BED.parseMaterial() || block.getType() == Materials.GRAY_BED.parseMaterial()
- || block.getType() == Materials.LIGHT_GRAY_BED.parseMaterial() || block.getType() == Materials.CYAN_BED.parseMaterial()
- || block.getType() == Materials.CYAN_BED.parseMaterial() || block.getType() == Materials.PURPLE_BED.parseMaterial()
- || block.getType() == Materials.BLUE_BED.parseMaterial() || block.getType() == Materials.BROWN_BED.parseMaterial()
- || block.getType() == Materials.GREEN_BED.parseMaterial() || block.getType() == Materials.RED_BED.parseMaterial()
- || block.getType() == Materials.BLACK_BED.parseMaterial()) {
+ || block.getType() == Materials.LIGHT_GRAY_BED.parseMaterial() || block.getType() == Materials.CYAN_BED.parseMaterial() || block.getType() == Materials.CYAN_BED.parseMaterial()
+ || block.getType() == Materials.PURPLE_BED.parseMaterial() || block.getType() == Materials.BLUE_BED.parseMaterial() || block.getType() == Materials.BROWN_BED.parseMaterial()
+ || block.getType() == Materials.GREEN_BED.parseMaterial() || block.getType() == Materials.RED_BED.parseMaterial() || block.getType() == Materials.BLACK_BED.parseMaterial()) {
if (!islandManager.hasPermission(player, block.getLocation(), "Bed")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -257,50 +255,43 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Brewing")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
- } else if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST
- || (NMSUtil.getVersionNumber() > 9 && (block.getType() == Materials.SHULKER_BOX.parseMaterial() || block.getType() == Materials.BLACK_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.BLUE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.BROWN_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.CYAN_SHULKER_BOX.parseMaterial() || block.getType() == Materials.GRAY_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.GREEN_SHULKER_BOX.parseMaterial() || block.getType() == Materials.LIGHT_BLUE_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.LIGHT_GRAY_SHULKER_BOX.parseMaterial() || block.getType() == Materials.LIME_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.MAGENTA_SHULKER_BOX.parseMaterial() || block.getType() == Materials.ORANGE_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.PINK_SHULKER_BOX.parseMaterial() || block.getType() == Materials.PURPLE_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.RED_SHULKER_BOX.parseMaterial() || block.getType() == Materials.WHITE_SHULKER_BOX.parseMaterial()
- || block.getType() == Materials.YELLOW_SHULKER_BOX.parseMaterial()))) {
- if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
- event.setCancelled(true);
+ } else if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST || (NMSUtil.getVersionNumber() > 9 && (block.getType() == Materials.SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.BLACK_SHULKER_BOX.parseMaterial() || block.getType() == Materials.BLUE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.BROWN_SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.CYAN_SHULKER_BOX.parseMaterial() || block.getType() == Materials.GRAY_SHULKER_BOX.parseMaterial() || block.getType() == Materials.GREEN_SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.LIGHT_BLUE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.LIGHT_GRAY_SHULKER_BOX.parseMaterial() || block.getType() == Materials.LIME_SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.MAGENTA_SHULKER_BOX.parseMaterial() || block.getType() == Materials.ORANGE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.PINK_SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.PURPLE_SHULKER_BOX.parseMaterial() || block.getType() == Materials.RED_SHULKER_BOX.parseMaterial() || block.getType() == Materials.WHITE_SHULKER_BOX.parseMaterial()
+ || block.getType() == Materials.YELLOW_SHULKER_BOX.parseMaterial()))) {
+ if (!islandManager.hasPermission(player, block.getLocation(), "Storage")) {
+ event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
- soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
- return;
- }
- } else
+ return;
+ }
+ } else
if (block.getType() == Materials.CRAFTING_TABLE.parseMaterial()) {
if (!islandManager.hasPermission(player, block.getLocation(), "Workbench")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
- } else if (block.getType() == Material.BIRCH_DOOR || block.getType() == Material.ACACIA_DOOR || block.getType() == Material.DARK_OAK_DOOR
- || block.getType() == Material.JUNGLE_DOOR || block.getType() == Material.SPRUCE_DOOR || block.getType() == Materials.LEGACY_WOODEN_DOOR.parseMaterial()
- || block.getType() == Materials.OAK_DOOR.parseMaterial()) {
+ } else if (block.getType() == Material.BIRCH_DOOR || block.getType() == Material.ACACIA_DOOR || block.getType() == Material.DARK_OAK_DOOR || block.getType() == Material.JUNGLE_DOOR
+ || block.getType() == Material.SPRUCE_DOOR || block.getType() == Materials.LEGACY_WOODEN_DOOR.parseMaterial() || block.getType() == Materials.OAK_DOOR.parseMaterial()) {
if (!islandManager.hasPermission(player, block.getLocation(), "Door")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -310,8 +301,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Enchant")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -320,21 +310,19 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Furnace")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
- } else if (block.getType() == Material.STONE_BUTTON || block.getType() == Materials.OAK_BUTTON.parseMaterial()
- || block.getType() == Materials.SPRUCE_BUTTON.parseMaterial() || block.getType() == Materials.BIRCH_BUTTON.parseMaterial()
- || block.getType() == Materials.JUNGLE_BUTTON.parseMaterial() || block.getType() == Materials.ACACIA_BUTTON.parseMaterial()
+ } else if (block.getType() == Material.STONE_BUTTON || block.getType() == Materials.OAK_BUTTON.parseMaterial() || block.getType() == Materials.SPRUCE_BUTTON.parseMaterial()
+ || block.getType() == Materials.BIRCH_BUTTON.parseMaterial() || block.getType() == Materials.JUNGLE_BUTTON.parseMaterial() || block.getType() == Materials.ACACIA_BUTTON.parseMaterial()
|| block.getType() == Materials.DARK_OAK_BUTTON.parseMaterial() || block.getType() == Materials.LEVER.parseMaterial()) {
if (!islandManager.hasPermission(player, block.getLocation(), "LeverButton")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -344,37 +332,35 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Jukebox")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
- } else if (block.getType() == Materials.OAK_TRAPDOOR.parseMaterial() || block.getType() == Materials.SPRUCE_TRAPDOOR.parseMaterial()
- || block.getType() == Materials.BIRCH_TRAPDOOR.parseMaterial() || block.getType() == Materials.JUNGLE_TRAPDOOR.parseMaterial()
- || block.getType() == Materials.ACACIA_TRAPDOOR.parseMaterial() || block.getType() == Materials.DARK_OAK_TRAPDOOR.parseMaterial()
+ } else if (block.getType() == Materials.OAK_TRAPDOOR.parseMaterial() || block.getType() == Materials.SPRUCE_TRAPDOOR.parseMaterial() || block.getType() == Materials.BIRCH_TRAPDOOR.parseMaterial()
+ || block.getType() == Materials.JUNGLE_TRAPDOOR.parseMaterial() || block.getType() == Materials.ACACIA_TRAPDOOR.parseMaterial() || block.getType() == Materials.DARK_OAK_TRAPDOOR.parseMaterial()
|| block.getType() == Material.NOTE_BLOCK || block.getType() == Material.HOPPER || block.getType() == Materials.COMPARATOR.parseMaterial()
- || block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_OFF.parseMaterial()
- || block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_ON.parseMaterial() || block.getType() == Materials.REPEATER.parseMaterial()
- || block.getType() == Materials.LEGACY_DIODE_BLOCK_OFF.parseMaterial() || block.getType() == Materials.LEGACY_DIODE_BLOCK_ON.parseMaterial()) {
+ || block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_OFF.parseMaterial() || block.getType() == Materials.LEGACY_REDSTONE_COMPARATOR_ON.parseMaterial()
+ || block.getType() == Materials.REPEATER.parseMaterial() || block.getType() == Materials.LEGACY_DIODE_BLOCK_OFF.parseMaterial()
+ || block.getType() == Materials.LEGACY_DIODE_BLOCK_ON.parseMaterial()) {
if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
} else
- if (block.getType() == Materials.OAK_FENCE_GATE.parseMaterial() || block.getType() == Material.ACACIA_FENCE_GATE
- || block.getType() == Material.BIRCH_FENCE_GATE || block.getType() == Material.DARK_OAK_FENCE_GATE || block.getType() == Material.JUNGLE_FENCE_GATE
- || block.getType() == Material.SPRUCE_FENCE_GATE) {
+ if (block.getType() == Materials.OAK_FENCE_GATE.parseMaterial() || block.getType() == Material.ACACIA_FENCE_GATE || block.getType() == Material.BIRCH_FENCE_GATE
+ || block.getType() == Material.DARK_OAK_FENCE_GATE || block.getType() == Material.JUNGLE_FENCE_GATE || block.getType() == Material.SPRUCE_FENCE_GATE) {
if (!islandManager.hasPermission(player, block.getLocation(), "Gate")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml"))
- .getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -384,8 +370,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "DropperDispenser")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -394,8 +380,8 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -404,8 +390,8 @@ public class Interact implements Listener {
if (player.getFoodLevel() < 20 && !islandManager.hasPermission(player, block.getLocation(), "Cake")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -414,16 +400,16 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Hopper")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
}
- } else if ((player.getGameMode() == GameMode.SURVIVAL) && (block.getType() == Material.OBSIDIAN) && (event.getItem() != null)
- && (event.getItem().getType() != Material.AIR) && (event.getItem().getType() == Material.BUCKET)) {
- if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
- .getBoolean("Island.Block.Obsidian.Enable") && islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
+ } else if ((player.getGameMode() == GameMode.SURVIVAL) && (block.getType() == Material.OBSIDIAN) && (event.getItem() != null) && (event.getItem().getType() != Material.AIR)
+ && (event.getItem().getType() == Material.BUCKET)) {
+ if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.Obsidian.Enable")
+ && islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
int NMSVersion = NMSUtil.getVersionNumber();
boolean isInventoryFull = false;
@@ -460,8 +446,8 @@ public class Interact implements Listener {
}
} else
if (block.getType() == Materials.END_PORTAL_FRAME.parseMaterial()) {
- if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration()
- .getBoolean("Island.Block.EndFrame.Enable") && islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
+ if (skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Block.EndFrame.Enable")
+ && islandManager.hasPermission(player, block.getLocation(), "Destroy")) {
if (NMSUtil.getVersionNumber() > 8 && event.getHand() == EquipmentSlot.OFF_HAND) return;
@@ -476,19 +462,24 @@ public class Interact implements Listener {
boolean hasEye = ((block.getData() >> 2) & 1) == 1;
if (is == null || is.getType() == Material.AIR) {
+
+ int size = 1;
+
if (stackableManager != null && stackableManager.isStacked(block.getLocation())) {
- Stackable stackable = stackableManager.getStack(block.getLocation(), Materials.END_PORTAL_FRAME.parseMaterial());
+ Stackable stackable = stackableManager.getStack(block.getLocation(), Materials.END_PORTAL_FRAME);
stackable.takeOne();
if (stackable.getSize() <= 1) {
stackableManager.removeStack(stackable);
}
+
+ size = stackable.getSize();
} else {
block.setType(Material.AIR);
}
player.getInventory().addItem(new ItemStack(Materials.END_PORTAL_FRAME.parseMaterial(), 1));
- if (hasEye) player.getInventory().addItem(new ItemStack(Materials.ENDER_EYE.parseMaterial(), 1));
+ if (hasEye && size == 1) player.getInventory().addItem(new ItemStack(Materials.ENDER_EYE.parseMaterial(), 1));
player.updateInventory();
FileManager.Config config = skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "config.yml"));
@@ -522,8 +513,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Bucket")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
player.updateInventory();
@@ -533,8 +523,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "WaterCollection")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
player.updateInventory();
@@ -544,8 +533,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "SpawnEgg")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
player.updateInventory();
@@ -554,8 +542,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "EntityPlacement")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
player.updateInventory();
@@ -568,8 +555,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Fire")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -580,13 +566,11 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Crop")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
- } else if (block.getType() == Materials.STONE_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.OAK_PRESSURE_PLATE.parseMaterial()
- || block.getType() == Materials.SPRUCE_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.BIRCH_PRESSURE_PLATE.parseMaterial()
- || block.getType() == Materials.JUNGLE_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.ACACIA_PRESSURE_PLATE.parseMaterial()
+ } else if (block.getType() == Materials.STONE_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.OAK_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.SPRUCE_PRESSURE_PLATE.parseMaterial()
+ || block.getType() == Materials.BIRCH_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.JUNGLE_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.ACACIA_PRESSURE_PLATE.parseMaterial()
|| block.getType() == Materials.DARK_OAK_PRESSURE_PLATE.parseMaterial() || block.getType() == Materials.LIGHT_WEIGHTED_PRESSURE_PLATE.parseMaterial()
|| block.getType() == Materials.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {
if (!islandManager.hasPermission(player, block.getLocation(), "PressurePlate")) {
@@ -597,8 +581,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, block.getLocation(), "Redstone")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -617,32 +600,30 @@ public class Interact implements Listener {
if (event.getAction() == Action.LEFT_CLICK_BLOCK) {
ItemStack structureTool = StructureUtil.getTool();
- if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta())
- && (event.getItem().getItemMeta().getDisplayName().equals(structureTool.getItemMeta().getDisplayName()))) {
- if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*")
- || player.hasPermission("fabledskyblock.admin.*") || player.hasPermission("fabledskyblock.*")) {
+ if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName().equals(structureTool.getItemMeta().getDisplayName()))) {
+ if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*")) {
event.setCancelled(true);
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(1, event.getClickedBlock().getLocation());
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Structure.Tool.Position.Message").replace("%position", "1"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message").replace("%position", "1"));
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
}
}
} else if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
ItemStack structureTool = StructureUtil.getTool();
- if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta())
- && (event.getItem().getItemMeta().getDisplayName().equals(structureTool.getItemMeta().getDisplayName()))) {
- if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*")
- || player.hasPermission("fabledskyblock.admin.*") || player.hasPermission("fabledskyblock.*")) {
+ if ((event.getItem().getType() == structureTool.getType()) && (event.getItem().hasItemMeta()) && (event.getItem().getItemMeta().getDisplayName().equals(structureTool.getItemMeta().getDisplayName()))) {
+ if (player.hasPermission("fabledskyblock.admin.structure.selection") || player.hasPermission("fabledskyblock.admin.structure.*") || player.hasPermission("fabledskyblock.admin.*")
+ || player.hasPermission("fabledskyblock.*")) {
event.setCancelled(true);
skyblock.getPlayerDataManager().getPlayerData(player).getArea().setPosition(2, event.getClickedBlock().getLocation());
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Structure.Tool.Position.Message").replace("%position", "2"));
+ messageManager.sendMessage(player,
+ skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Structure.Tool.Position.Message").replace("%position", "2"));
soundManager.playSound(player, Sounds.WOOD_CLICK.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -670,8 +651,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Leash")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -687,8 +667,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, horse.getLocation(), "HorseInventory")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -697,8 +676,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, horse.getLocation(), "MobRiding")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -708,8 +686,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "MobRiding")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -718,15 +695,13 @@ public class Interact implements Listener {
} else if (entity.getType().equals(EntityType.SHEEP)) {
if (!islandManager.hasPermission(player, entity.getLocation(), "EntityPlacement")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else if (entity.getType().equals(EntityType.ITEM_FRAME)) {
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "Storage")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
} else if (entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
@@ -734,8 +709,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Milking")) {
event.setCancelled(true);
- messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration()
- .getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -745,8 +719,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Trading")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -755,8 +728,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Storage")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -765,8 +737,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "MinecartBoat")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -775,8 +746,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "Hopper")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
return;
@@ -784,8 +754,8 @@ public class Interact implements Listener {
}
if (entity.getType() == EntityType.HORSE) {
- if (!(is.getType() == Material.GOLDEN_APPLE || is.getType() == Material.GOLDEN_CARROT || is.getType() == Material.SUGAR || is.getType() == Material.WHEAT
- || is.getType() == Material.APPLE || is.getType() == Material.HAY_BLOCK)) {
+ if (!(is.getType() == Material.GOLDEN_APPLE || is.getType() == Material.GOLDEN_CARROT || is.getType() == Material.SUGAR || is.getType() == Material.WHEAT || is.getType() == Material.APPLE
+ || is.getType() == Material.HAY_BLOCK)) {
return;
}
} else if (entity.getType() == EntityType.SHEEP || entity.getType() == EntityType.COW || entity.getType() == EntityType.MUSHROOM_COW) {
@@ -807,10 +777,9 @@ public class Interact implements Listener {
}
}
} else if (entity.getType() == EntityType.WOLF) {
- if (!(is.getType() == Material.BONE || is.getType() == Materials.PORKCHOP.parseMaterial() || is.getType() == Materials.BEEF.parseMaterial()
- || is.getType() == Materials.CHICKEN.parseMaterial() || is.getType() == Material.RABBIT || is.getType() == Material.MUTTON || is.getType() == Material.ROTTEN_FLESH
- || is.getType() == Materials.COOKED_PORKCHOP.parseMaterial() || is.getType() == Material.COOKED_BEEF || is.getType() == Material.COOKED_CHICKEN
- || is.getType() == Material.COOKED_RABBIT || is.getType() == Material.COOKED_MUTTON)) {
+ if (!(is.getType() == Material.BONE || is.getType() == Materials.PORKCHOP.parseMaterial() || is.getType() == Materials.BEEF.parseMaterial() || is.getType() == Materials.CHICKEN.parseMaterial()
+ || is.getType() == Material.RABBIT || is.getType() == Material.MUTTON || is.getType() == Material.ROTTEN_FLESH || is.getType() == Materials.COOKED_PORKCHOP.parseMaterial()
+ || is.getType() == Material.COOKED_BEEF || is.getType() == Material.COOKED_CHICKEN || is.getType() == Material.COOKED_RABBIT || is.getType() == Material.COOKED_MUTTON)) {
return;
}
} else if (entity.getType() == EntityType.OCELOT) {
@@ -849,8 +818,7 @@ public class Interact implements Listener {
if (!islandManager.hasPermission(player, entity.getLocation(), "AnimalBreeding")) {
event.setCancelled(true);
- messageManager.sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ messageManager.sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
soundManager.playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -865,8 +833,7 @@ public class Interact implements Listener {
if (!skyblock.getIslandManager().hasPermission(player, event.getVehicle().getLocation(), "MobHurting")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -880,8 +847,7 @@ public class Interact implements Listener {
if (!skyblock.getIslandManager().hasPermission(player, event.getVehicle().getLocation(), "MobHurting")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
@@ -904,8 +870,7 @@ public class Interact implements Listener {
if (!skyblock.getIslandManager().hasPermission(player, entity.getLocation(), "ArmorStandUse")) {
event.setCancelled(true);
- skyblock.getMessageManager().sendMessage(player,
- skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
+ skyblock.getMessageManager().sendMessage(player, skyblock.getFileManager().getConfig(new File(skyblock.getDataFolder(), "language.yml")).getFileConfiguration().getString("Island.Settings.Permission.Message"));
skyblock.getSoundManager().playSound(player, Sounds.VILLAGER_NO.bukkitSound(), 1.0F, 1.0F);
}
}
diff --git a/src/main/java/com/songoda/skyblock/listeners/Join.java b/src/main/java/com/songoda/skyblock/listeners/Join.java
index f20ea3b4..657b2db7 100644
--- a/src/main/java/com/songoda/skyblock/listeners/Join.java
+++ b/src/main/java/com/songoda/skyblock/listeners/Join.java
@@ -82,11 +82,11 @@ public class Join implements Listener {
Method getProfileMethod = entityPlayer.getClass().getMethod("getProfile");
GameProfile gameProfile = (GameProfile) getProfileMethod.invoke(entityPlayer);
Property property = gameProfile.getProperties().get("textures").iterator().next();
- playerTexture = new String[]{property.getSignature(), property.getValue()};
+ playerTexture = new String[] { property.getSignature(), property.getValue() };
} catch (Exception e) {
- playerTexture = new String[]{
+ playerTexture = new String[] {
"K9P4tCIENYbNpDuEuuY0shs1x7iIvwXi4jUUVsATJfwsAIZGS+9OZ5T2HB0tWBoxRvZNi73Vr+syRdvTLUWPusVXIg+2fhXmQoaNEtnQvQVGQpjdQP0TkZtYG8PbvRxE6Z75ddq+DVx/65OSNHLWIB/D+Rg4vINh4ukXNYttn9QvauDHh1aW7/IkIb1Bc0tLcQyqxZQ3mdglxJfgIerqnlA++Lt7TxaLdag4y1NhdZyd3OhklF5B0+B9zw/qP8QCzsZU7VzJIcds1+wDWKiMUO7+60OSrIwgE9FPamxOQDFoDvz5BOULQEeNx7iFMB+eBYsapCXpZx0zf1bduppBUbbVC9wVhto/J4tc0iNyUq06/esHUUB5MHzdJ0Y6IZJAD/xIw15OLCUH2ntvs8V9/cy5/n8u3JqPUM2zhUGeQ2p9FubUGk4Q928L56l3omRpKV+5QYTrvF+AxFkuj2hcfGQG3VE2iYZO6omXe7nRPpbJlHkMKhE8Xvd1HP4PKpgivSkHBoZ92QEUAmRzZydJkp8CNomQrZJf+MtPiNsl/Q5RQM+8CQThg3+4uWptUfP5dDFWOgTnMdA0nIODyrjpp+bvIJnsohraIKJ7ZDnj4tIp4ObTNKDFC/8j8JHz4VCrtr45mbnzvB2DcK8EIB3JYT7ElJTHnc5BKMyLy5SKzuw=",
- "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19"};
+ "eyJ0aW1lc3RhbXAiOjE1MjkyNTg0MTE4NDksInByb2ZpbGVJZCI6Ijg2NjdiYTcxYjg1YTQwMDRhZjU0NDU3YTk3MzRlZWQ3IiwicHJvZmlsZU5hbWUiOiJTdGV2ZSIsInNpZ25hdHVyZVJlcXVpcmVkIjp0cnVlLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZGMxYzc3Y2U4ZTU0OTI1YWI1ODEyNTQ0NmVjNTNiMGNkZDNkMGNhM2RiMjczZWI5MDhkNTQ4Mjc4N2VmNDAxNiJ9LCJDQVBFIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjc2N2Q0ODMyNWVhNTMyNDU2MTQwNmI4YzgyYWJiZDRlMjc1NWYxMTE1M2NkODVhYjA1NDVjYzIifX19" };
}
PlayerData playerData = playerDataManager.getPlayerData(player);
@@ -99,10 +99,8 @@ public class Join implements Listener {
playerDataManager.storeIsland(player);
- cooldownManager.addCooldownPlayer(CooldownType.Biome,
- cooldownManager.loadCooldownPlayer(CooldownType.Biome, player));
- cooldownManager.addCooldownPlayer(CooldownType.Creation,
- cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
+ cooldownManager.addCooldownPlayer(CooldownType.Biome, cooldownManager.loadCooldownPlayer(CooldownType.Biome, player));
+ cooldownManager.addCooldownPlayer(CooldownType.Creation, cooldownManager.loadCooldownPlayer(CooldownType.Creation, player));
if (scoreboardManager != null) {
Config config = fileManager.getConfig(new File(skyblock.getDataFolder(), "language.yml"));
@@ -112,49 +110,30 @@ public class Join implements Listener {
if (island != null) {
OfflinePlayer offlinePlayer = Bukkit.getServer().getOfflinePlayer(island.getOwnerUUID());
- cooldownManager.addCooldownPlayer(CooldownType.Levelling,
- cooldownManager.loadCooldownPlayer(CooldownType.Levelling, offlinePlayer));
- cooldownManager.addCooldownPlayer(CooldownType.Ownership,
- cooldownManager.loadCooldownPlayer(CooldownType.Ownership, offlinePlayer));
+ cooldownManager.addCooldownPlayer(CooldownType.Levelling, cooldownManager.loadCooldownPlayer(CooldownType.Levelling, offlinePlayer));
+ cooldownManager.addCooldownPlayer(CooldownType.Ownership, cooldownManager.loadCooldownPlayer(CooldownType.Ownership, offlinePlayer));
if (island.getRole(IslandRole.Member).size() == 0 && island.getRole(IslandRole.Operator).size() == 0) {
- scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
- config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
+ scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Solo.Displayname")));
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
- scoreboard.setDisplayList(config.getFileConfiguration()
- .getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
+ scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Empty.Displaylines"));
} else {
- scoreboard.setDisplayList(config.getFileConfiguration()
- .getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
+ scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Solo.Occupied.Displaylines"));
}
} else {
- scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
- config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname")));
+ scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Island.Team.Displayname")));
if (islandManager.getVisitorsAtIsland(island).size() == 0) {
- scoreboard.setDisplayList(config.getFileConfiguration()
- .getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
+ scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Empty.Displaylines"));
} else {
- scoreboard.setDisplayList(config.getFileConfiguration()
- .getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
+ scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Island.Team.Occupied.Displaylines"));
}
- Map displayVariables = new HashMap<>();
- displayVariables.put("%owner",
- config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Owner"));
- displayVariables.put("%operator",
- config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Operator"));
- displayVariables.put("%member",
- config.getFileConfiguration().getString("Scoreboard.Island.Team.Word.Member"));
-
- scoreboard.setDisplayVariables(displayVariables);
}
} else {
- scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&',
- config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
- scoreboard.setDisplayList(
- config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
+ scoreboard.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getFileConfiguration().getString("Scoreboard.Tutorial.Displayname")));
+ scoreboard.setDisplayList(config.getFileConfiguration().getStringList("Scoreboard.Tutorial.Displaylines"));
}
scoreboard.run();
diff --git a/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java b/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java
new file mode 100644
index 00000000..b4ef3980
--- /dev/null
+++ b/src/main/java/com/songoda/skyblock/localization/LocalizationManager.java
@@ -0,0 +1,64 @@
+package com.songoda.skyblock.localization;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.bukkit.configuration.Configuration;
+
+import com.google.common.collect.Sets;
+import com.songoda.skyblock.SkyBlock;
+import com.songoda.skyblock.island.IslandRole;
+import com.songoda.skyblock.localization.type.Localization;
+import com.songoda.skyblock.localization.type.impl.BlankLocalization;
+import com.songoda.skyblock.localization.type.impl.EnumLocalization;
+import com.songoda.skyblock.localization.type.impl.MaterialsLocalization;
+import com.songoda.skyblock.utils.version.Materials;
+
+public final class LocalizationManager {
+
+ private final Localization> def = new BlankLocalization("", Object.class);
+
+ private Map, Localization>> map;
+
+ public LocalizationManager() {
+ this.map = new HashMap<>();
+ registerLocalizationFor(Materials.class, new MaterialsLocalization("Materials"));
+ registerLocalizationFor(IslandRole.class, new EnumLocalization<>("IslandRoles", IslandRole.class));
+ }
+
+ public void registerLocalizationFor(Class> type, Localization> toUse) {
+
+ if (type == null) throw new IllegalArgumentException("type cannot be null");
+ if (toUse == null) throw new IllegalArgumentException("toUse cannot be null");
+ if (toUse == def) throw new IllegalArgumentException("Cannot register default localization.");
+
+ map.put(type, toUse);
+
+ final SkyBlock inst = SkyBlock.getInstance();
+
+ toUse.reload(inst.getFileManager().getConfig(new File(inst.getDataFolder(), "language.yml")).getFileConfiguration().getConfigurationSection(toUse.getKeysPath()));
+ }
+
+ public void reloadAll() {
+
+ final SkyBlock inst = SkyBlock.getInstance();
+ final Configuration config = inst.getFileManager().getConfig(new File(inst.getDataFolder(), "language.yml")).getFileConfiguration();
+
+ for (Localization> locale : Sets.newHashSet(map.values())) {
+ locale.reload(config.getConfigurationSection(locale.getKeysPath()));
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public Localization getLocalizationFor(Class type) {
+
+ Localization locale = (Localization) map.get(type);
+
+ if (locale == null) locale = (Localization) def;
+
+ return locale;
+ }
+
+}
diff --git a/src/main/java/com/songoda/skyblock/localization/type/Localization.java b/src/main/java/com/songoda/skyblock/localization/type/Localization.java
new file mode 100644
index 00000000..01f06f45
--- /dev/null
+++ b/src/main/java/com/songoda/skyblock/localization/type/Localization.java
@@ -0,0 +1,54 @@
+package com.songoda.skyblock.localization.type;
+
+import java.util.Map;
+import java.util.Objects;
+
+import org.bukkit.configuration.ConfigurationSection;
+
+public abstract class Localization {
+
+ private final Class type;
+ private final String keysPath;
+ private final Map values;
+
+ public Localization(String keysPath, Class type) {
+ this.type = Objects.requireNonNull(type, "type cannot be null");
+ this.keysPath = "ClassLocalization." + Objects.requireNonNull(keysPath, "keysPath canoot be null.");
+ this.values = Objects.requireNonNull(newValueMapInstance(type), "type cannot be null");
+ }
+
+ public abstract void reload(ConfigurationSection section);
+
+ protected abstract Map newValueMapInstance(Class type);
+
+ protected final Map getValues() {
+ return values;
+ }
+
+ public final String getKeysPath() {
+ return keysPath;
+ }
+
+ public final Class getType() {
+ return type;
+ }
+
+ public String getLocale(T object) {
+
+ String value = getValues().get(object);
+
+ if (value == null) value = getDefaultLocaleFor(object);
+
+ return value;
+ }
+
+ public String getDefaultLocaleFor(T object) {
+
+ String name = object.toString().toLowerCase();
+
+ if (name.length() > 1) name = name.substring(0, 1).toUpperCase() + name.substring(1);
+
+ return name;
+ }
+
+}
diff --git a/src/main/java/com/songoda/skyblock/localization/type/impl/BlankLocalization.java b/src/main/java/com/songoda/skyblock/localization/type/impl/BlankLocalization.java
new file mode 100644
index 00000000..790bcaf8
--- /dev/null
+++ b/src/main/java/com/songoda/skyblock/localization/type/impl/BlankLocalization.java
@@ -0,0 +1,31 @@
+package com.songoda.skyblock.localization.type.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.bukkit.configuration.ConfigurationSection;
+
+import com.songoda.skyblock.localization.type.Localization;
+
+public final class BlankLocalization extends Localization