Version 2.0
Using Spigot maven repository now. Improved test deployment scripts. Removed checks for updates. Code-style.
This commit is contained in:
		| @@ -5,6 +5,6 @@ full text of GPLv3 can be found in the file "GPLv3" | |||||||
|  |  | ||||||
|  |  | ||||||
| # LGPLv3 | # LGPLv3 | ||||||
| * src/main/java/de/craftinc/borderprotection/LocationSerializer.java | * src/main/java/de/craftinc/borderprotection/util/LocationSerializer2D.java | ||||||
|  |  | ||||||
| full text of LGPLv3 can be found in the file "LGPLv3" | full text of LGPLv3 can be found in the file "LGPLv3" | ||||||
|   | |||||||
							
								
								
									
										40
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										40
									
								
								pom.xml
									
									
									
									
									
								
							| @@ -4,16 +4,16 @@ | |||||||
|     <modelVersion>4.0.0</modelVersion> |     <modelVersion>4.0.0</modelVersion> | ||||||
|     <groupId>de.craftinc</groupId> |     <groupId>de.craftinc</groupId> | ||||||
|     <artifactId>CraftincBorderProtection</artifactId> |     <artifactId>CraftincBorderProtection</artifactId> | ||||||
|     <name>Craft Inc. BorderProtection</name> |     <name>CraftInc-BorderProtection</name> | ||||||
|     <packaging>jar</packaging> |     <packaging>jar</packaging> | ||||||
|     <version>2.0-beta</version> |     <version>2.0</version> | ||||||
|  |  | ||||||
|     <properties> |     <properties> | ||||||
|         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||||||
|     </properties> |     </properties> | ||||||
|  |  | ||||||
|     <build> |     <build> | ||||||
|         <finalName>${project.name} ${project.version}</finalName> |         <finalName>${project.name}-${project.version}</finalName> | ||||||
|         <resources> |         <resources> | ||||||
|             <resource> |             <resource> | ||||||
|                 <directory>src/main/resources</directory> |                 <directory>src/main/resources</directory> | ||||||
| @@ -55,27 +55,27 @@ | |||||||
|         </plugins> |         </plugins> | ||||||
|     </build> |     </build> | ||||||
|  |  | ||||||
|  |     <repositories> | ||||||
|  |         <repository> | ||||||
|  |             <id>spigot-repo</id> | ||||||
|  |             <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||||||
|  |         </repository> | ||||||
|  |     </repositories> | ||||||
|  |  | ||||||
|     <dependencies> |     <dependencies> | ||||||
|  |         <!--Spigot API--> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>org.spigotmc</groupId> | ||||||
|  |             <artifactId>spigot-api</artifactId> | ||||||
|  |             <version>1.10.2-R0.1-SNAPSHOT</version> | ||||||
|  |             <scope>provided</scope> | ||||||
|  |         </dependency> | ||||||
|  |         <!--Bukkit API--> | ||||||
|         <dependency> |         <dependency> | ||||||
|             <groupId>org.bukkit</groupId> |             <groupId>org.bukkit</groupId> | ||||||
|             <artifactId>bukkit</artifactId> |             <artifactId>bukkit</artifactId> | ||||||
|             <version>1.6.4-R2.0</version> |             <version>1.10.2-R0.1-SNAPSHOT</version> | ||||||
|             <type>jar</type> |             <scope>provided</scope> | ||||||
|             <scope>compile</scope> |  | ||||||
|         </dependency> |  | ||||||
|         <dependency> |  | ||||||
|             <groupId>org.bukkit</groupId> |  | ||||||
|             <artifactId>craftbukkit</artifactId> |  | ||||||
|             <version>1.6.4-R2.0</version> |  | ||||||
|             <type>jar</type> |  | ||||||
|             <scope>compile</scope> |  | ||||||
|         </dependency> |         </dependency> | ||||||
|     </dependencies> |     </dependencies> | ||||||
|  |  | ||||||
|     <repositories> |  | ||||||
|         <repository> |  | ||||||
|             <id>bukkit-repo</id> |  | ||||||
|             <url>http://repo.bukkit.org/content/groups/public</url> |  | ||||||
|         </repository> |  | ||||||
|     </repositories> |  | ||||||
| </project> | </project> | ||||||
|   | |||||||
| @@ -1,160 +1,202 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
|  |  | ||||||
| SCRIPT_DIR=$(readlink -f $(dirname "$0")) | # Craft Inc. BorderProtection | ||||||
| SERVICE='craftbukkit*.jar' | # Copyright (C) 2016  Paul Schulze | ||||||
| #USERNAME="minecraft" | # | ||||||
| CPU_COUNT=2 | # This program is free software: you can redistribute it and/or modify | ||||||
| BUKKIT="$SCRIPT_DIR/../target/lib/$SERVICE" | # it under the terms of the GNU General Public License as published by | ||||||
| INVOCATION="java -Xmx1000M -Xms300M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=$CPU_COUNT -XX:+AggressiveOpts -jar $BUKKIT nogui" | # the Free Software Foundation, either version 3 of the License, or | ||||||
| MCPATH="$SCRIPT_DIR/../bukkit-testserver" | # (at your option) any later version. | ||||||
|  | # | ||||||
|  | # This program is distributed in the hope that it will be useful, | ||||||
|  | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | # GNU General Public License for more details. | ||||||
|  | # | ||||||
|  | # You should have received a copy of the GNU General Public License | ||||||
|  | # along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  | ||||||
| if [ ! -d "$MCPATH" ]; then |  | ||||||
|     mkdir -p "$MCPATH" | SERVICE='craftbukkit-1.10.2.jar' | ||||||
|  |  | ||||||
|  | # numbers of CPU cores; used only for the parallel garbage collector threads | ||||||
|  | CPU_COUNT=8 | ||||||
|  |  | ||||||
|  | # maximum memory which the JAVA VM is allowed to allocate (M is megabyte) | ||||||
|  | XMX=-Xmx10000M | ||||||
|  |  | ||||||
|  | # initial memory which the JAVA VM is allocating (M is megabyte) | ||||||
|  | XMS=-Xms3000M | ||||||
|  |  | ||||||
|  | # Replace with path which contains your craftbukkit.jar | ||||||
|  | MCPATH="$(dirname "$0")/../bukkit-testserver" | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | # ======================================================================== | ||||||
|  | # == Don't change anything below this line unless you know what you do. == | ||||||
|  | # ======================================================================== | ||||||
|  | BUKKIT="$MCPATH/$SERVICE" | ||||||
|  | INVOCATION="java $XMX $XMS -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=$CPU_COUNT -XX:+AggressiveOpts -jar $BUKKIT nogui" | ||||||
|  |  | ||||||
|  | if [[ "$MCPATH" == '/my/path/to/craftbukkit' ]]; then | ||||||
|  |     echo "Please configure the \"MCPATH\" variable in the $0 file." >&2 | ||||||
|  |     exit 1 | ||||||
| fi | fi | ||||||
|  |  | ||||||
| ME=$(whoami) | SCREEN_NAME="$(cat "$MCPATH/screen_name" 2> /dev/null)" | ||||||
| as_user() { | if [[ -z "$SCREEN_NAME" ]]; then | ||||||
|     #if [ $ME == $USERNAME ] ; then |     SCREEN_NAME="minecraft.$(head -c12 /dev/urandom | xxd -p)" | ||||||
|         bash -c "$1" |     echo -n "$SCREEN_NAME" > "$MCPATH/screen_name" | ||||||
|     #else | fi | ||||||
|         #su - $USERNAME -c "$1" |  | ||||||
|     #fi | psgrep() { | ||||||
|  |     psgreptmp=$(mktemp) | ||||||
|  |  | ||||||
|  |     ps auxww > "$psgreptmp" | ||||||
|  |     grep -v "$$" "$psgreptmp" | egrep --color=auto -i "$1" | ||||||
|  |     rm "$psgreptmp" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | send_to_screen() { | ||||||
|  |     screen -p 0 -S "$SCREEN_NAME" -X stuff "$1 | ||||||
|  | " | ||||||
|  | } | ||||||
|  |  | ||||||
|  | mc_service_running() { | ||||||
|  |     psgrep "$SERVICE" | grep -v -i 'screen' | grep 'java' | grep -- "$XMX" | grep -- "$XMS" | grep "$BUKKIT" > /dev/null | ||||||
|  |     return $? | ||||||
| } | } | ||||||
|  |  | ||||||
| mc_start() { | mc_start() { | ||||||
|     if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |     if ! mc_status; then | ||||||
|     then |         echo "Starting..." | ||||||
|         echo "Tried to start but $SERVICE was already running!" |  | ||||||
|     else |  | ||||||
|         echo "$SERVICE was not running... starting." |  | ||||||
|         cd "$MCPATH" |         cd "$MCPATH" | ||||||
|         as_user "cd "$MCPATH" && screen -dmS minecraft $INVOCATION" |         screen -dmS "$SCREEN_NAME" $INVOCATION | ||||||
|         sleep 7 |         sleep 2 | ||||||
|         if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |         mc_status | ||||||
|         then |  | ||||||
|             echo "$SERVICE is now running." |  | ||||||
|         else |  | ||||||
|             echo "Could not start $SERVICE." |  | ||||||
|         fi |  | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
|  |  | ||||||
| mc_stop() { | mc_stop() { | ||||||
|     if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |     if mc_status; then | ||||||
|     then | #        echo "Sending message to users..." | ||||||
|         echo "$SERVICE is running... stopping." | #        send_to_screen 'say SERVER SHUTTING DOWN IN 10 SECONDS!' | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-all\"\015'" | #        sleep 10 | ||||||
|         sleep 2 |         echo "Saving..." | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"stop\"\015'" |         send_to_screen 'save-all' | ||||||
|         sleep 6 |         sleep 1 | ||||||
|     else |         echo "Stopping..." | ||||||
|         echo "$SERVICE was not running." |         send_to_screen 'stop' | ||||||
|     fi |         sleep 3 | ||||||
|     if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |         mc_status | ||||||
|     then |  | ||||||
|         echo "$SERVICE could not be shut down... still running." |  | ||||||
|     else |  | ||||||
|         echo "$SERVICE is shut down." |  | ||||||
|     fi |     fi | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| mc_save() { | mc_save() { | ||||||
|     if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |     if mc_status; then | ||||||
|     then |         echo "Saving..." | ||||||
|         echo "$SERVICE is running... saving." |         send_to_screen 'save-all' | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-all\"\015'" |  | ||||||
|     else |  | ||||||
|         echo "$SERVICE was not running." |  | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
|  |  | ||||||
| mc_reload() { |  | ||||||
|     if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null | mc_restart_or_start() { | ||||||
|     then |     if mc_service_running; then | ||||||
|         echo "$SERVICE is running... reloading." |         mc_stop | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"reload\"\015'" |         sleep 1 | ||||||
|  |         mc_start | ||||||
|     else |     else | ||||||
|         echo "$SERVICE was not running." |         mc_start | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
|  |  | ||||||
| mc_reload_or_start() { | mc_reset_permissions() { | ||||||
|     if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |     if mc_status; then | ||||||
|     then |         echo "Unbanning ddidderr..." | ||||||
|         echo "$SERVICE was already running! Doing a reload now!" |         send_to_screen 'pardon ddidderr' | ||||||
|         mc_reload |         echo "Unbanning mice_on_drugs..." | ||||||
|     else |         send_to_screen 'pardon mice_on_drugs' | ||||||
|         echo "$SERVICE was not running... starting." |         echo "Unbanning Mochaccino..." | ||||||
|         cd "$MCPATH" |         send_to_screen 'pardon Mochaccino' | ||||||
|         as_user "cd \"$MCPATH\" && screen -dmS minecraft $INVOCATION" |  | ||||||
|         sleep 7 |         echo "ddidder -> admin" | ||||||
|         if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |         send_to_screen 'pex user ddidderr group set admin' | ||||||
|         then |         echo "mice_on_drugs -> mod" | ||||||
|             echo "$SERVICE is now running." |         send_to_screen 'pex user mice_on_drugs group set mod' | ||||||
|         else |         echo "Mochaccino -> mod" | ||||||
|             echo "Could not start $SERVICE." |         send_to_screen 'pex user Mochaccino group set mod' | ||||||
|         fi |  | ||||||
|  |         echo "Reloading permissions..." | ||||||
|  |         send_to_screen 'pex reload' | ||||||
|  |         echo "DONE" | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
|  |  | ||||||
| mc_ddidderr_admin() { | mc_custom_command() { | ||||||
|     if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |     if mc_status; then | ||||||
|     then |         if [[ -z "$1" ]]; then | ||||||
|         echo "$SERVICE is running... making ddidder to admin and reloading permissions." |             echo "You must specify a command." >&2 | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"pex user ddidderr group set admin\"\015'" |             exit 1 | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"pex reload\"\015'" |         fi | ||||||
|  |  | ||||||
|  |         echo "Trying to issue command: \"$1\"" | ||||||
|  |         send_to_screen "$1" | ||||||
|  |         tail -fn50 "$MCPATH/logs/latest.log" | ||||||
|  |     fi | ||||||
|  | } | ||||||
|  |  | ||||||
|  | mc_status() { | ||||||
|  |     if mc_service_running; then | ||||||
|  |         echo "$SERVICE is running." | ||||||
|  |         return 0 | ||||||
|     else |     else | ||||||
|         echo "$SERVICE was not running." |         echo "$SERVICE is stopped." | ||||||
|  |         return 1 | ||||||
|  |     fi | ||||||
|  | } | ||||||
|  |  | ||||||
|  | mc_online() { | ||||||
|  |     if mc_status; then | ||||||
|  |         send_to_screen 'list' | ||||||
|  |         sleep 2s | ||||||
|  |         tac "$MCPATH/logs/latest.log" | egrep -om 1 "There are.*players online" | ||||||
|     fi |     fi | ||||||
| } | } | ||||||
|  |  | ||||||
| case "$1" in | case "$1" in | ||||||
|     start) |     start) | ||||||
|         echo "Starting Minecraft..." |  | ||||||
|         mc_start |         mc_start | ||||||
|         echo "DONE" |  | ||||||
|         ;; |         ;; | ||||||
|     stop) |     stop) | ||||||
|         echo "Stopping Minecraft..." |  | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER SHUTTING DOWN!\"\015'" |  | ||||||
|         mc_stop |         mc_stop | ||||||
|         echo "DONE" |  | ||||||
|         ;; |         ;; | ||||||
|     restart) |     restart) | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER REBOOT IN 10 SECONDS.\"\015'" |  | ||||||
|         $0 stop |         $0 stop | ||||||
|         sleep 1 |         sleep 2 | ||||||
|         $0 start |         $0 start | ||||||
|         ;; |         ;; | ||||||
|     reload) |     restart_or_start) | ||||||
|         mc_reload |         mc_restart_or_start | ||||||
|         ;; |         ;; | ||||||
|     reload_or_start) |     reset_permissions) | ||||||
|         echo "Starting or reloading Minecraft..." |         mc_reset_permissions | ||||||
|         mc_reload_or_start |  | ||||||
|         echo "DONE" |  | ||||||
|         ;; |         ;; | ||||||
|     ddidderr_admin) |     custom) | ||||||
|         mc_ddidderr_admin |         mc_custom_command "${*:2}" | ||||||
|         ;; |         ;; | ||||||
|     connected) |     online) | ||||||
|         as_user "screen -p 0 -S minecraft -X eval 'stuff \"who\"\015'" |         mc_online | ||||||
|         sleep 2s |  | ||||||
|         tac "$MCPATH"/server.log | grep -m 1 "Connected" |  | ||||||
|         ;; |         ;; | ||||||
|     status) |     status) | ||||||
|         if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null |         mc_status | ||||||
|         then |  | ||||||
|             echo "$SERVICE is running." |  | ||||||
|         else |  | ||||||
|             echo "$SERVICE is not running." |  | ||||||
|         fi |  | ||||||
|         ;; |         ;; | ||||||
|     save) |     save) | ||||||
|         mc_save |         mc_save | ||||||
|         ;; |         ;; | ||||||
|     *) |     *) | ||||||
|         echo "Usage: /etc/init.d/minecraft {start|stop|restart|connected|status}" |         echo "Usage: $0 {start|stop|restart|save|online|status|reset_permissions}" | ||||||
|         exit 1 |         exit 1 | ||||||
|         ;; |         ;; | ||||||
| esac | esac | ||||||
|   | |||||||
| @@ -1,29 +1,57 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
|  |  | ||||||
|  | # Craft Inc. BorderProtection | ||||||
|  | # Copyright (C) 2016  Paul Schulze | ||||||
|  | # | ||||||
|  | # This program is free software: you can redistribute it and/or modify | ||||||
|  | # it under the terms of the GNU General Public License as published by | ||||||
|  | # the Free Software Foundation, either version 3 of the License, or | ||||||
|  | # (at your option) any later version. | ||||||
|  | # | ||||||
|  | # This program is distributed in the hope that it will be useful, | ||||||
|  | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||||
|  | # GNU General Public License for more details. | ||||||
|  | # | ||||||
|  | # You should have received a copy of the GNU General Public License | ||||||
|  | # along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||||
|  |  | ||||||
| SCRIPT_DIR="$(dirname "$0")" | SCRIPT_DIR="$(dirname "$0")" | ||||||
|  |  | ||||||
| DEVELOPER=$(whoami) | DEVELOPER="$(whoami)" | ||||||
|  |  | ||||||
| if [ $DEVELOPER = "tobi" ]; then |  | ||||||
| 	BUKKIT_DIR="$HOME/minecraft/testbuk" |  | ||||||
| 	PLUGIN_DIR="$HOME/minecraft/testbuk/plugins" |  | ||||||
| 	START_STOP_SCRIPT="$BUKKIT_DIR/../minecraft.sh" |  | ||||||
| else |  | ||||||
| BUKKIT_DIR="$SCRIPT_DIR/../bukkit-testserver" | BUKKIT_DIR="$SCRIPT_DIR/../bukkit-testserver" | ||||||
| PLUGIN_DIR="$SCRIPT_DIR/../bukkit-testserver/plugins" | PLUGIN_DIR="$SCRIPT_DIR/../bukkit-testserver/plugins" | ||||||
| START_STOP_SCRIPT="$SCRIPT_DIR/minecraft.sh" | START_STOP_SCRIPT="$SCRIPT_DIR/minecraft.sh" | ||||||
|  | BUILD_TOOLS_DIR="$BUKKIT_DIR/buildtools" | ||||||
|  |  | ||||||
|  | mkdir -p "$BUILD_TOOLS_DIR" | ||||||
|  | # get build tools | ||||||
|  | if [ ! -f "$BUILD_TOOLS_DIR/BuildTools.jar" ]; then | ||||||
|  |     wget -O- 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar' > "$BUILD_TOOLS_DIR/BuildTools.jar" | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  | cp -f "$BUILD_TOOLS_DIR"/craftbukkit*.jar "$BUKKIT_DIR/" | ||||||
|  |  | ||||||
|  | # run build tools | ||||||
|  | if [ ! -f "$BUKKIT_DIR"/craftbukkit*.jar ]; then | ||||||
|  |     cd "$BUILD_TOOLS_DIR" | ||||||
|  |     java -jar ./BuildTools.jar | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echo 'eula=TRUE' > "$BUKKIT_DIR/eula.txt" | ||||||
|  |  | ||||||
| # TODO: This is a bad solution! Maven should write necessary information into an extra file. | # TODO: This is a bad solution! Maven should write necessary information into an extra file. | ||||||
| ARTIFACT_ID="$(grep -C5 '<groupId>de.craftinc' "$SCRIPT_DIR/../pom.xml" | grep '<name>' | sed 's/[ \t]*<name>//g' | sed 's/<\/name>[ \t]*//g')" | ARTIFACT_ID="$(grep -C5 '<groupId>de.craftinc' "$SCRIPT_DIR/../pom.xml" | grep '<name>' | sed 's/[ \t]*<name>//g' | sed 's/<\/name>[ \t]*//g')" | ||||||
|  |  | ||||||
| # TODO: This is a bad solution! Maven should write necessary information into an extra file. | # TODO: This is a bad solution! Maven should write necessary information into an extra file. | ||||||
| VERSION="$(grep -C5 '<groupId>de.craftinc' "$SCRIPT_DIR/../pom.xml" | grep '<version>' | sed 's/[ \t]*<version>//g' | sed 's/<\/version>[ \t]*//g')" | VERSION="$(grep -C5 '<groupId>de.craftinc' "$SCRIPT_DIR/../pom.xml" | grep '<version>' | sed 's/[ \t]*<version>//g' | sed 's/<\/version>[ \t]*//g')" | ||||||
|  |  | ||||||
|  | rm -rf "$PLUGIN_DIR" | ||||||
| mkdir -p "$PLUGIN_DIR" | mkdir -p "$PLUGIN_DIR" | ||||||
|  |  | ||||||
| cp "$SCRIPT_DIR/../target/$ARTIFACT_ID $VERSION".jar "$PLUGIN_DIR/" | cp "$SCRIPT_DIR/../target/$ARTIFACT_ID-$VERSION".jar "$PLUGIN_DIR/" | ||||||
|  |  | ||||||
| echo -e "ddidderr\nmice_on_drugs\nMochaccino" > "$BUKKIT_DIR/ops.txt" | echo -e "ddidderr\nmice_on_drugs\nMochaccino" > "$BUKKIT_DIR/ops.txt" | ||||||
|  |  | ||||||
| $START_STOP_SCRIPT reload_or_start | $START_STOP_SCRIPT restart_or_start | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -65,21 +65,21 @@ public class Messages | |||||||
|         return sb.toString(); |         return sb.toString(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private static String borderExplanation = |     private static final String borderExplanation = | ||||||
|             "One day the holy mods and administrators will expand the border. It is then your mission to explore " + |             "One day the holy mods and administrators will expand the border. It is then your mission to explore " + | ||||||
|             "strange new worlds, to seek out new life and new civilizations, to boldly go where no one has gone before."; |             "strange new worlds, to seek out new life and new civilizations, to boldly go where no one has gone before."; | ||||||
|  |  | ||||||
|     public static String borderMessage = |     public static final String borderMessage = | ||||||
|             ChatColor.YELLOW + "Sorry Dude! " + |             ChatColor.YELLOW + "Sorry Dude! " + | ||||||
|             ChatColor.WHITE + "This is the border... the final frontier! " + borderExplanation + NEWLINE + |             ChatColor.WHITE + "This is the border... the final frontier! " + borderExplanation + NEWLINE + | ||||||
|             makeCmd("/cibp get", "shows the borders of the current world"); |             makeCmd("/cibp get", "shows the borders of the current world"); | ||||||
|  |  | ||||||
|     public static String borderTeleportMessage = |     public static final String borderTeleportMessage = | ||||||
|             ChatColor.YELLOW + "Sorry Dude! " + |             ChatColor.YELLOW + "Sorry Dude! " + | ||||||
|             ChatColor.WHITE + "You cannot teleport outside the border. " + borderExplanation + NEWLINE + |             ChatColor.WHITE + "You cannot teleport outside the border. " + borderExplanation + NEWLINE + | ||||||
|             makeCmd("/cibp get", "shows the borders of the current world"); |             makeCmd("/cibp get", "shows the borders of the current world"); | ||||||
|  |  | ||||||
|     public static String helpGeneral = |     public static final String helpGeneral = | ||||||
|             ChatColor.GREEN + pluginName + " - Usage:" + NEWLINE + |             ChatColor.GREEN + pluginName + " - Usage:" + NEWLINE + | ||||||
|             ChatColor.WHITE + "Commands are always related to the current world." + NEWLINE + |             ChatColor.WHITE + "Commands are always related to the current world." + NEWLINE + | ||||||
|             makeCmd("help", "shows this help") + |             makeCmd("help", "shows this help") + | ||||||
| @@ -90,15 +90,14 @@ public class Messages | |||||||
|             makeCmd("set", "Square border with distance (d) from 0,0.", "r", "<d>") + |             makeCmd("set", "Square border with distance (d) from 0,0.", "r", "<d>") + | ||||||
|             makeCmd("set", "Rectangle defined by two points. Point=x,z.", "r", "<p1>", "<p2>") + |             makeCmd("set", "Rectangle defined by two points. Point=x,z.", "r", "<p1>", "<p2>") + | ||||||
|             makeCmd("set", "Circle border with radius from 0,0.", "c", "<radius>") + |             makeCmd("set", "Circle border with radius from 0,0.", "c", "<radius>") + | ||||||
|             makeCmd("set", "Circle defined by center and radius. Center=x,z.", "c", "<c>", "<r>") + |             makeCmd("set", "Circle defined by center and radius. Center=x,z.", "c", "<c>", "<r>"); | ||||||
|             makeCmd("checkversion", "Checks for a newer version."); |  | ||||||
|  |  | ||||||
|     public static String borderCreationSuccessful |     public static final String borderCreationSuccessful | ||||||
|             = ChatColor.YELLOW + "New border was set " + |             = ChatColor.YELLOW + "New border was set " + | ||||||
|               ChatColor.GREEN + "successfully" + |               ChatColor.GREEN + "successfully" + | ||||||
|               ChatColor.YELLOW + "!"; |               ChatColor.YELLOW + "!"; | ||||||
|  |  | ||||||
|     public static String commandIssuedByNonPlayer |     public static final String commandIssuedByNonPlayer | ||||||
|             = ChatColor.RED + "Only a player can use " + pluginName + " commands!"; |             = ChatColor.RED + "Only a player can use " + pluginName + " commands!"; | ||||||
|  |  | ||||||
|     public static String borderInfo( String worldName, Border border ) |     public static String borderInfo( String worldName, Border border ) | ||||||
| @@ -115,56 +114,41 @@ public class Messages | |||||||
|                ChatColor.WHITE + "Border is " + borderEnabled + ChatColor.WHITE + "."; |                ChatColor.WHITE + "Border is " + borderEnabled + ChatColor.WHITE + "."; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public static String borderInfoNoBorderSet = |     public static final String borderInfoNoBorderSet = | ||||||
|             ChatColor.YELLOW + "No border in this world."; |             ChatColor.YELLOW + "No border in this world."; | ||||||
|  |  | ||||||
|     public static String noPermissionSet = |     public static final String noPermissionSet = | ||||||
|             ChatColor.RED + "Sorry, you don't have permission to change the border."; |             ChatColor.RED + "Sorry, you don't have permission to change the border."; | ||||||
|  |  | ||||||
|     public static String noPermissionCheckversion = |     public static final String borderEnabled = | ||||||
|             ChatColor.RED + "Sorry, you don't have permission to check for new versions."; |  | ||||||
|  |  | ||||||
|     public static String borderEnabled = |  | ||||||
|             ChatColor.YELLOW + "Border enabled."; |             ChatColor.YELLOW + "Border enabled."; | ||||||
|  |  | ||||||
|     public static String borderDisabled = |     public static final String borderDisabled = | ||||||
|             ChatColor.YELLOW + "Border disabled."; |             ChatColor.YELLOW + "Border disabled."; | ||||||
|  |  | ||||||
|     public static String borderSaveException = |     public static final String borderSaveException = | ||||||
|             ChatColor.RED + "Error: Could not save border on server. After the next reload this border will be lost!"; |             ChatColor.RED + "Error: Could not save border on server. After the next reload this border will be lost!"; | ||||||
|  |  | ||||||
|     public static String borderEnableDisableException = |     public static final String borderEnableDisableException = | ||||||
|             ChatColor.RED + |             ChatColor.RED + | ||||||
|             "Error: Could not save border state on server. After the next reload this border state will be lost!"; |             "Error: Could not save border state on server. After the next reload this border state will be lost!"; | ||||||
|  |  | ||||||
|     public static String generationCanceled = |     public static final String generationCanceled = | ||||||
|             ChatColor.GREEN + "World generation canceled!"; |             ChatColor.GREEN + "World generation canceled!"; | ||||||
|  |  | ||||||
|     public static String generationNotCanceled = |     public static final String generationNotCanceled = | ||||||
|             ChatColor.RED + "No world generation happening. Cannot cancel!"; |             ChatColor.RED + "No world generation happening. Cannot cancel!"; | ||||||
|  |  | ||||||
|     public static String generationAlreadyInProgress = |     public static final String generationAlreadyInProgress = | ||||||
|             ChatColor.YELLOW + "World generation is already in progress. It will continue after all players are logged out."; |             ChatColor.YELLOW + | ||||||
|  |             "World generation is already in progress. It will continue after all players are logged out."; | ||||||
|  |  | ||||||
|     public static String generationStarted = |     public static final String generationStarted = | ||||||
|             ChatColor.GREEN + "World generation will start after all players left the server."; |             ChatColor.GREEN + "World generation will start after all players left the server."; | ||||||
|  |  | ||||||
|     public static String generationCouldNotBeStarted = |     public static final String generationCouldNotBeStarted = | ||||||
|             ChatColor.RED + "Could not start world generation! Is there a border?"; |             ChatColor.RED + "Could not start world generation! Is there a border?"; | ||||||
|  |  | ||||||
|     public static String updateMessage( String newVersion, String curVersion ) |  | ||||||
|     { |  | ||||||
|         return ChatColor.RED + pluginName + ": New version available!" + NEWLINE + |  | ||||||
|                ChatColor.YELLOW + "Current version: " + ChatColor.WHITE + curVersion + NEWLINE + |  | ||||||
|                ChatColor.YELLOW + "New version: " + ChatColor.WHITE + newVersion + NEWLINE + |  | ||||||
|                ChatColor.YELLOW + "Please visit:" + NEWLINE + |  | ||||||
|                ChatColor.AQUA + "http://dev.bukkit.org/bukkit-mods/craftinc-borderprotection" + NEWLINE + |  | ||||||
|                ChatColor.YELLOW + "to get the latest version!"; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     public static String noUpdateAvailable = |  | ||||||
|             ChatColor.YELLOW + "No updates available."; |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Display a message to a player and then wait for timeout seconds before displaying it again. |      * Display a message to a player and then wait for timeout seconds before displaying it again. | ||||||
|      * |      * | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -19,7 +19,10 @@ package de.craftinc.borderprotection; | |||||||
| import de.craftinc.borderprotection.borders.CircBorder; | import de.craftinc.borderprotection.borders.CircBorder; | ||||||
| import de.craftinc.borderprotection.borders.RectBorder; | import de.craftinc.borderprotection.borders.RectBorder; | ||||||
| import de.craftinc.borderprotection.commands.CommandSwitch; | import de.craftinc.borderprotection.commands.CommandSwitch; | ||||||
| import de.craftinc.borderprotection.events.*; | import de.craftinc.borderprotection.events.PlayerJoinListener; | ||||||
|  | import de.craftinc.borderprotection.events.PlayerMoveListener; | ||||||
|  | import de.craftinc.borderprotection.events.PlayerQuitListener; | ||||||
|  | import de.craftinc.borderprotection.events.PlayerTeleportListener; | ||||||
| import org.bukkit.configuration.serialization.ConfigurationSerialization; | import org.bukkit.configuration.serialization.ConfigurationSerialization; | ||||||
| import org.bukkit.plugin.PluginManager; | import org.bukkit.plugin.PluginManager; | ||||||
| import org.bukkit.plugin.java.JavaPlugin; | import org.bukkit.plugin.java.JavaPlugin; | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -32,12 +32,12 @@ public abstract class Border | |||||||
| { | { | ||||||
|     private static final String dataFileName = "borders.yml"; |     private static final String dataFileName = "borders.yml"; | ||||||
|  |  | ||||||
|     protected Boolean isActive; |     private Boolean isActive; | ||||||
|  |  | ||||||
|     protected static final String isActiveKey = "enabled"; |     private static final String isActiveKey = "enabled"; | ||||||
|     protected static final String bordersKey  = "borders"; |     private static final String bordersKey  = "borders"; | ||||||
|  |  | ||||||
|     protected static final HashMap<World, Border> borders = new HashMap<World, Border>(); |     static final HashMap<World, Border> borders = new HashMap<World, Border>(); | ||||||
|  |  | ||||||
|     private static final File              bordersFile     = new File(Plugin.instance.getDataFolder(), dataFileName); |     private static final File              bordersFile     = new File(Plugin.instance.getDataFolder(), dataFileName); | ||||||
|     private static final FileConfiguration bordersFileConf = YamlConfiguration.loadConfiguration(bordersFile); |     private static final FileConfiguration bordersFileConf = YamlConfiguration.loadConfiguration(bordersFile); | ||||||
| @@ -46,7 +46,7 @@ public abstract class Border | |||||||
|      * The buffer in blocks which applies when a player is teleported inside the border. 0 means the player |      * The buffer in blocks which applies when a player is teleported inside the border. 0 means the player | ||||||
|      * will be teleported directly to the border. |      * will be teleported directly to the border. | ||||||
|      */ |      */ | ||||||
|     public static final double buffer = 0.5; |     static final double buffer = 0.5; | ||||||
|  |  | ||||||
|     public static HashMap<World, Border> getBorders() |     public static HashMap<World, Border> getBorders() | ||||||
|     { |     { | ||||||
| @@ -79,6 +79,7 @@ public abstract class Border | |||||||
|     /** |     /** | ||||||
|      * Checks if the given location is inside or outside the border. If it is outside a new location (inside the border) |      * Checks if the given location is inside or outside the border. If it is outside a new location (inside the border) | ||||||
|      * is returned, otherwise null. Applies padding to the border. (Simulates a larger border using padding.) |      * is returned, otherwise null. Applies padding to the border. (Simulates a larger border using padding.) | ||||||
|  |      * | ||||||
|      * @param l       Location to check if inside the border |      * @param l       Location to check if inside the border | ||||||
|      * @param padding number of Blocks of padding applied to the border. |      * @param padding number of Blocks of padding applied to the border. | ||||||
|      * @return null if l is inside the border otherwise a new Location which is inside |      * @return null if l is inside the border otherwise a new Location which is inside | ||||||
| @@ -96,7 +97,7 @@ public abstract class Border | |||||||
|         return isActive; |         return isActive; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public Border( Map<String, Object> map ) |     Border( Map<String, Object> map ) | ||||||
|     { |     { | ||||||
|         try |         try | ||||||
|         { |         { | ||||||
| @@ -109,7 +110,7 @@ public abstract class Border | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public Border() |     Border() | ||||||
|     { |     { | ||||||
|         // new borders are enabled by default |         // new borders are enabled by default | ||||||
|         isActive = true; |         isActive = true; | ||||||
| @@ -137,7 +138,7 @@ public abstract class Border | |||||||
|         isActive = false; |         isActive = false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected void serialize( Map<String, Object> map ) |     void serialize( Map<String, Object> map ) | ||||||
|     { |     { | ||||||
|         map.put(isActiveKey, isActive); |         map.put(isActiveKey, isActive); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -16,8 +16,8 @@ | |||||||
| */ | */ | ||||||
| package de.craftinc.borderprotection.borders; | package de.craftinc.borderprotection.borders; | ||||||
|  |  | ||||||
| import de.craftinc.borderprotection.util.LocationSerializer2D; |  | ||||||
| import de.craftinc.borderprotection.Plugin; | import de.craftinc.borderprotection.Plugin; | ||||||
|  | import de.craftinc.borderprotection.util.LocationSerializer2D; | ||||||
| import de.craftinc.borderprotection.util.PlayerMovementUtil; | import de.craftinc.borderprotection.util.PlayerMovementUtil; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.Location; | import org.bukkit.Location; | ||||||
| @@ -31,8 +31,8 @@ public class CircBorder extends Border implements ConfigurationSerializable | |||||||
|     private Double   radius; |     private Double   radius; | ||||||
|     private Location center; |     private Location center; | ||||||
|  |  | ||||||
|     private static String centerKey = "center"; |     private static final String centerKey = "center"; | ||||||
|     private static String radiusKey = "radius"; |     private static final String radiusKey = "radius"; | ||||||
|  |  | ||||||
|     @SuppressWarnings("unchecked unused") |     @SuppressWarnings("unchecked unused") | ||||||
|     public CircBorder( Map<String, Object> map ) |     public CircBorder( Map<String, Object> map ) | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -16,8 +16,8 @@ | |||||||
| */ | */ | ||||||
| package de.craftinc.borderprotection.borders; | package de.craftinc.borderprotection.borders; | ||||||
|  |  | ||||||
| import de.craftinc.borderprotection.util.LocationSerializer2D; |  | ||||||
| import de.craftinc.borderprotection.Plugin; | import de.craftinc.borderprotection.Plugin; | ||||||
|  | import de.craftinc.borderprotection.util.LocationSerializer2D; | ||||||
| import de.craftinc.borderprotection.util.PlayerMovementUtil; | import de.craftinc.borderprotection.util.PlayerMovementUtil; | ||||||
| import org.bukkit.ChatColor; | import org.bukkit.ChatColor; | ||||||
| import org.bukkit.Location; | import org.bukkit.Location; | ||||||
| @@ -31,8 +31,8 @@ public class RectBorder extends Border implements ConfigurationSerializable | |||||||
|     private Location rectPoint1; |     private Location rectPoint1; | ||||||
|     private Location rectPoint2; |     private Location rectPoint2; | ||||||
|  |  | ||||||
|     private static String rectPoint1Name = "p1"; |     private static final String rectPoint1Name = "p1"; | ||||||
|     private static String rectPoint2Name = "p2"; |     private static final String rectPoint2Name = "p2"; | ||||||
|  |  | ||||||
|     @SuppressWarnings("unchecked unused") |     @SuppressWarnings("unchecked unused") | ||||||
|     public RectBorder( Map<String, Object> map ) |     public RectBorder( Map<String, Object> map ) | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze |     Copyright (C) 2016  Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -26,9 +26,8 @@ import org.bukkit.entity.Player; | |||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class CancelGenerateCommand  implements SubCommand | class CancelGenerateCommand implements SubCommand | ||||||
| { | { | ||||||
|     @Override |  | ||||||
|     public boolean execute( CommandSender sender, String[] parameters ) |     public boolean execute( CommandSender sender, String[] parameters ) | ||||||
|     { |     { | ||||||
|         if ( !sender.hasPermission("craftinc.borderprotection.generate") ) |         if ( !sender.hasPermission("craftinc.borderprotection.generate") ) | ||||||
| @@ -52,7 +51,6 @@ public class CancelGenerateCommand  implements SubCommand | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public List<String> commandNames() |     public List<String> commandNames() | ||||||
|     { |     { | ||||||
|         ArrayList<String> names = new ArrayList<String>(); |         ArrayList<String> names = new ArrayList<String>(); | ||||||
|   | |||||||
| @@ -1,58 +0,0 @@ | |||||||
| /*  Craft Inc. BorderProtection |  | ||||||
|     Copyright (C) 2013  Paul Schulze |  | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |  | ||||||
|     it under the terms of the GNU General Public License as published by |  | ||||||
|     the Free Software Foundation, either version 3 of the License, or |  | ||||||
|     (at your option) any later version. |  | ||||||
|  |  | ||||||
|     This program is distributed in the hope that it will be useful, |  | ||||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of |  | ||||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the |  | ||||||
|     GNU General Public License for more details. |  | ||||||
|  |  | ||||||
|     You should have received a copy of the GNU General Public License |  | ||||||
|     along with this program.  If not, see <http://www.gnu.org/licenses/>. |  | ||||||
| */ |  | ||||||
| package de.craftinc.borderprotection.commands; |  | ||||||
|  |  | ||||||
| import de.craftinc.borderprotection.Messages; |  | ||||||
| import de.craftinc.borderprotection.util.UpdateHelper; |  | ||||||
| import org.bukkit.command.CommandSender; |  | ||||||
|  |  | ||||||
| import java.util.ArrayList; |  | ||||||
| import java.util.List; |  | ||||||
|  |  | ||||||
| public class CheckVersionCommand  implements SubCommand |  | ||||||
| { |  | ||||||
|     @Override |  | ||||||
|     public boolean execute(CommandSender sender, String[] parameters) |  | ||||||
|     { |  | ||||||
|         if ( !sender.hasPermission("craftinc.borderprotection.update") ) |  | ||||||
|         { |  | ||||||
|             sender.sendMessage(Messages.noPermissionCheckversion); |  | ||||||
|             return false; |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if ( UpdateHelper.newVersionAvailable() ) |  | ||||||
|         { |  | ||||||
|             sender.sendMessage( |  | ||||||
|                     Messages.updateMessage(UpdateHelper.cachedLatestVersion, UpdateHelper.getCurrentVersion())); |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|         else |  | ||||||
|         { |  | ||||||
|             sender.sendMessage(Messages.noUpdateAvailable); |  | ||||||
|             return true; |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public List<String> commandNames() |  | ||||||
|     { |  | ||||||
|         ArrayList<String> names = new ArrayList<String>(); |  | ||||||
|         names.add("checkversion"); |  | ||||||
|  |  | ||||||
|         return names; |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -27,12 +27,11 @@ import java.util.Map; | |||||||
|  |  | ||||||
| public class CommandSwitch implements CommandExecutor | public class CommandSwitch implements CommandExecutor | ||||||
| { | { | ||||||
|     protected Map<String, SubCommand> subCommandsMap = new HashMap<String, SubCommand>(); |     private final Map<String, SubCommand> subCommandsMap = new HashMap<String, SubCommand>(); | ||||||
|  |  | ||||||
|     public CommandSwitch() |     public CommandSwitch() | ||||||
|     { |     { | ||||||
|         registerCommand(new CancelGenerateCommand()); |         registerCommand(new CancelGenerateCommand()); | ||||||
|         registerCommand(new CheckVersionCommand()); |  | ||||||
|         registerCommand(new GenerateCommand()); |         registerCommand(new GenerateCommand()); | ||||||
|         registerCommand(new GetCommand()); |         registerCommand(new GetCommand()); | ||||||
|         registerCommand(new HelpCommand()); |         registerCommand(new HelpCommand()); | ||||||
| @@ -40,7 +39,7 @@ public class CommandSwitch implements CommandExecutor | |||||||
|         registerCommand(new SetCommand()); |         registerCommand(new SetCommand()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected void registerCommand(SubCommand command) |     private void registerCommand( SubCommand command ) | ||||||
|     { |     { | ||||||
|         for ( String commandName : command.commandNames() ) |         for ( String commandName : command.commandNames() ) | ||||||
|         { |         { | ||||||
| @@ -48,7 +47,6 @@ public class CommandSwitch implements CommandExecutor | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public boolean onCommand( CommandSender sender, Command command, String label, String[] args ) |     public boolean onCommand( CommandSender sender, Command command, String label, String[] args ) | ||||||
|     { |     { | ||||||
|         // Check if command comes from a player. |         // Check if command comes from a player. | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze |     Copyright (C) 2016  Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -25,9 +25,8 @@ import org.bukkit.entity.Player; | |||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class GenerateCommand implements SubCommand | class GenerateCommand implements SubCommand | ||||||
| { | { | ||||||
|     @Override |  | ||||||
|     public boolean execute( CommandSender sender, String[] parameters ) |     public boolean execute( CommandSender sender, String[] parameters ) | ||||||
|     { |     { | ||||||
|         if ( !sender.hasPermission("craftinc.borderprotection.generate") ) |         if ( !sender.hasPermission("craftinc.borderprotection.generate") ) | ||||||
| @@ -57,7 +56,6 @@ public class GenerateCommand implements SubCommand | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public List<String> commandNames() |     public List<String> commandNames() | ||||||
|     { |     { | ||||||
|         ArrayList<String> names = new ArrayList<String>(); |         ArrayList<String> names = new ArrayList<String>(); | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze |     Copyright (C) 2016  Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -25,9 +25,8 @@ import org.bukkit.entity.Player; | |||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class GetCommand  implements SubCommand | class GetCommand implements SubCommand | ||||||
| { | { | ||||||
|     @Override |  | ||||||
|     public boolean execute( CommandSender sender, String[] parameters ) |     public boolean execute( CommandSender sender, String[] parameters ) | ||||||
|     { |     { | ||||||
|         World world = ( (Player) sender ).getWorld(); |         World world = ( (Player) sender ).getWorld(); | ||||||
| @@ -45,7 +44,6 @@ public class GetCommand  implements SubCommand | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public List<String> commandNames() |     public List<String> commandNames() | ||||||
|     { |     { | ||||||
|         ArrayList<String> names = new ArrayList<String>(); |         ArrayList<String> names = new ArrayList<String>(); | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze |     Copyright (C) 2016  Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -24,14 +24,12 @@ import java.util.List; | |||||||
|  |  | ||||||
| public class HelpCommand implements SubCommand | public class HelpCommand implements SubCommand | ||||||
| { | { | ||||||
|     @Override |  | ||||||
|     public boolean execute( CommandSender sender, String[] parameters ) |     public boolean execute( CommandSender sender, String[] parameters ) | ||||||
|     { |     { | ||||||
|         sender.sendMessage(Messages.helpGeneral); |         sender.sendMessage(Messages.helpGeneral); | ||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public List<String> commandNames() |     public List<String> commandNames() | ||||||
|     { |     { | ||||||
|         ArrayList<String> names = new ArrayList<String>(); |         ArrayList<String> names = new ArrayList<String>(); | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze |     Copyright (C) 2016  Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -27,9 +27,8 @@ import java.io.IOException; | |||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class OnOffCommand  implements SubCommand | class OnOffCommand implements SubCommand | ||||||
| { | { | ||||||
|     @Override |  | ||||||
|     public boolean execute( CommandSender sender, String[] parameters ) |     public boolean execute( CommandSender sender, String[] parameters ) | ||||||
|     { |     { | ||||||
|         if ( !sender.hasPermission("craftinc.borderprotection.set") ) |         if ( !sender.hasPermission("craftinc.borderprotection.set") ) | ||||||
| @@ -72,7 +71,6 @@ public class OnOffCommand  implements SubCommand | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public List<String> commandNames() |     public List<String> commandNames() | ||||||
|     { |     { | ||||||
|         ArrayList<String> names = new ArrayList<String>(); |         ArrayList<String> names = new ArrayList<String>(); | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze |     Copyright (C) 2016  Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -30,9 +30,8 @@ import java.io.IOException; | |||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
| public class SetCommand  implements SubCommand | class SetCommand implements SubCommand | ||||||
| { | { | ||||||
|     @Override |  | ||||||
|     public boolean execute( CommandSender sender, String[] parameters ) |     public boolean execute( CommandSender sender, String[] parameters ) | ||||||
|     { |     { | ||||||
|         if ( !( parameters.length == 3 || parameters.length == 4 ) ) |         if ( !( parameters.length == 3 || parameters.length == 4 ) ) | ||||||
| @@ -133,7 +132,6 @@ public class SetCommand  implements SubCommand | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public List<String> commandNames() |     public List<String> commandNames() | ||||||
|     { |     { | ||||||
|         ArrayList<String> names = new ArrayList<String>(); |         ArrayList<String> names = new ArrayList<String>(); | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze |     Copyright (C) 2016  Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -22,18 +22,17 @@ import org.bukkit.command.CommandSender; | |||||||
| import java.util.List; | import java.util.List; | ||||||
|  |  | ||||||
|  |  | ||||||
| public interface SubCommand | interface SubCommand | ||||||
| { | { | ||||||
|     /** |     /** | ||||||
|      * |  | ||||||
|      * @param sender     The sender (player) who executed the command. |      * @param sender     The sender (player) who executed the command. | ||||||
|      * @param parameters All parameters for executing this subcommand. Includes the subcommand name at index 0. |      * @param parameters All parameters for executing this subcommand. Includes the subcommand name at index 0. | ||||||
|      * @return Returns an boolean indicating if the subcommand got could be executed. |      * @return Returns an boolean indicating if the subcommand got could be executed. | ||||||
|      */ |      */ | ||||||
|     public boolean execute(CommandSender sender, String[] parameters); |     boolean execute( CommandSender sender, String[] parameters ); | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Returns a list of names of the command. All strings should be lowercase! |      * Returns a list of names of the command. All strings should be lowercase! | ||||||
|      */ |      */ | ||||||
|     public List<String> commandNames(); |     List<String> commandNames(); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze |     Copyright (C) 2016  Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -16,10 +16,7 @@ | |||||||
| */ | */ | ||||||
| package de.craftinc.borderprotection.events; | package de.craftinc.borderprotection.events; | ||||||
|  |  | ||||||
| import de.craftinc.borderprotection.Messages; |  | ||||||
| import de.craftinc.borderprotection.util.ChunkGenerator; | import de.craftinc.borderprotection.util.ChunkGenerator; | ||||||
| import de.craftinc.borderprotection.util.UpdateHelper; |  | ||||||
| import org.bukkit.entity.Player; |  | ||||||
| import org.bukkit.event.EventHandler; | import org.bukkit.event.EventHandler; | ||||||
| import org.bukkit.event.EventPriority; | import org.bukkit.event.EventPriority; | ||||||
| import org.bukkit.event.Listener; | import org.bukkit.event.Listener; | ||||||
| @@ -31,17 +28,6 @@ public class PlayerJoinListener implements Listener | |||||||
|     @EventHandler(priority = EventPriority.LOWEST) |     @EventHandler(priority = EventPriority.LOWEST) | ||||||
|     public void onPlayerLogin( PlayerJoinEvent e ) |     public void onPlayerLogin( PlayerJoinEvent e ) | ||||||
|     { |     { | ||||||
|         final Player player = e.getPlayer(); |  | ||||||
|  |  | ||||||
|         if ( e.getPlayer().hasPermission("craftinc.borderprotection.update") ) |  | ||||||
|         { |  | ||||||
|             if ( UpdateHelper.newVersionAvailable() ) |  | ||||||
|             { |  | ||||||
|                 String updateMessage = Messages.updateMessage(UpdateHelper.cachedLatestVersion, UpdateHelper.getCurrentVersion()); |  | ||||||
|                 e.setJoinMessage(e.getJoinMessage() + "\n" + updateMessage); |  | ||||||
|             } |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         ChunkGenerator.pause(); |         ChunkGenerator.pause(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -30,7 +30,7 @@ public class PlayerMoveListener implements Listener | |||||||
|  |  | ||||||
|  |  | ||||||
|     @SuppressWarnings("unused") |     @SuppressWarnings("unused") | ||||||
|     @EventHandler(priority = EventPriority.HIGHEST) |     @EventHandler(priority = EventPriority.LOWEST) | ||||||
|     public void onPlayerMove( PlayerMoveEvent e ) |     public void onPlayerMove( PlayerMoveEvent e ) | ||||||
|     { |     { | ||||||
|         // do nothing if the event is already cancelled |         // do nothing if the event is already cancelled | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -29,7 +29,7 @@ public class PlayerQuitListener implements Listener | |||||||
|     @EventHandler(priority = EventPriority.NORMAL) |     @EventHandler(priority = EventPriority.NORMAL) | ||||||
|     public void onPlayerQuit( PlayerQuitEvent e ) |     public void onPlayerQuit( PlayerQuitEvent e ) | ||||||
|     { |     { | ||||||
|         if (Plugin.instance.getServer().getOnlinePlayers().length == 1) |         if ( Plugin.instance.getServer().getOnlinePlayers().size() == 1 ) | ||||||
|         { |         { | ||||||
|             ChunkGenerator.resume(); |             ChunkGenerator.resume(); | ||||||
|         } |         } | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -28,7 +28,7 @@ import org.bukkit.event.player.PlayerTeleportEvent; | |||||||
| public class PlayerTeleportListener implements Listener | public class PlayerTeleportListener implements Listener | ||||||
| { | { | ||||||
|     @SuppressWarnings("unused") |     @SuppressWarnings("unused") | ||||||
|     @EventHandler(priority = EventPriority.HIGHEST) |     @EventHandler(priority = EventPriority.LOWEST) | ||||||
|     public void onPlayerTeleport( PlayerTeleportEvent e ) |     public void onPlayerTeleport( PlayerTeleportEvent e ) | ||||||
|     { |     { | ||||||
|         // do nothing if the event is already cancelled |         // do nothing if the event is already cancelled | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
| @@ -28,13 +28,13 @@ import java.util.HashMap; | |||||||
|  |  | ||||||
| public class ChunkGenerator | public class ChunkGenerator | ||||||
| { | { | ||||||
|     protected static HashMap<World, Integer[]> chunkGenerationStatus = new HashMap<World, Integer[]>(); |     private static final HashMap<World, Integer[]> chunkGenerationStatus = new HashMap<World, Integer[]>(); | ||||||
|     protected static boolean isPaused = true; |     private static       boolean                   isPaused              = true; | ||||||
|     protected static HashMap<World, Long> lastGenerationLogTime = new HashMap<World, Long>(); |     private static final HashMap<World, Long>      lastGenerationLogTime = new HashMap<World, Long>(); | ||||||
|  |  | ||||||
|     public static long waitTicks = 5; // TODO: make adjustable via config file |     private static final long waitTicks                 = 5; // TODO: make adjustable via config file | ||||||
|     public static int batchGenerationSize = 5; //TODO: make adjustable via config file |     private static final int  batchGenerationSize       = 5; //TODO: make adjustable via config file | ||||||
|     public static int paddingChunksAroundBorder = 15; // TODO: make adjustable via config file |     private static final int  paddingChunksAroundBorder = 15; // TODO: make adjustable via config file | ||||||
|  |  | ||||||
|     public static void pause() |     public static void pause() | ||||||
|     { |     { | ||||||
| @@ -76,6 +76,7 @@ public class ChunkGenerator | |||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Starts the generation of all chunks inside a border. |      * Starts the generation of all chunks inside a border. | ||||||
|  |      * | ||||||
|      * @param w The world in which chunks will be generated. Must not be 'null'. An exception will be thrown otherwise! |      * @param w The world in which chunks will be generated. Must not be 'null'. An exception will be thrown otherwise! | ||||||
|      * @return A boolean indicating if the generation was successfully started. Will return false if no border exists |      * @return A boolean indicating if the generation was successfully started. Will return false if no border exists | ||||||
|      * for a given world. Will return true if the generation was already running but will not restart the generation. |      * for a given world. Will return true if the generation was already running but will not restart the generation. | ||||||
| @@ -96,8 +97,10 @@ public class ChunkGenerator | |||||||
|  |  | ||||||
|         Location[] borderRect = border.getSurroundingRect(); |         Location[] borderRect = border.getSurroundingRect(); | ||||||
|  |  | ||||||
|         int firstChunkX = (Math.min(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4) - paddingChunksAroundBorder; |         int firstChunkX = | ||||||
|         int firstChunkZ = (Math.min(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4) - paddingChunksAroundBorder; |                 ( Math.min(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4 ) - paddingChunksAroundBorder; | ||||||
|  |         int firstChunkZ = | ||||||
|  |                 ( Math.min(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4 ) - paddingChunksAroundBorder; | ||||||
|  |  | ||||||
|         firstChunkX--; |         firstChunkX--; | ||||||
|  |  | ||||||
| @@ -107,7 +110,7 @@ public class ChunkGenerator | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected static void slowLoadNextChunk(World w) |     static void slowLoadNextChunk( World w ) | ||||||
|     { |     { | ||||||
|         if ( w == null ) |         if ( w == null ) | ||||||
|         { |         { | ||||||
| @@ -129,7 +132,7 @@ public class ChunkGenerator | |||||||
|     /** |     /** | ||||||
|      * Will only load/generate the next chunks inside the border of the given world. Will stop if no border exists. |      * Will only load/generate the next chunks inside the border of the given world. Will stop if no border exists. | ||||||
|      */ |      */ | ||||||
|     protected static void loadNextChunk(World w) |     static void loadNextChunk( World w ) | ||||||
|     { |     { | ||||||
|         if ( w == null ) |         if ( w == null ) | ||||||
|         { |         { | ||||||
| @@ -154,10 +157,14 @@ public class ChunkGenerator | |||||||
|         int chunkZ = lastGeneratedChunk[1]; |         int chunkZ = lastGeneratedChunk[1]; | ||||||
|  |  | ||||||
|         final Location[] borderRect = border.getSurroundingRect(); |         final Location[] borderRect = border.getSurroundingRect(); | ||||||
|         final int minChunkX = (Math.min(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4) - paddingChunksAroundBorder; |         final int minChunkX = | ||||||
|         final int minChunkZ = (Math.min(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4) - paddingChunksAroundBorder; |                 ( Math.min(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4 ) - paddingChunksAroundBorder; | ||||||
|         final int maxChunkX = (Math.max(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4) + paddingChunksAroundBorder; |         final int minChunkZ = | ||||||
|         final int maxChunkZ = (Math.max(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4) + paddingChunksAroundBorder; |                 ( Math.min(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4 ) - paddingChunksAroundBorder; | ||||||
|  |         final int maxChunkX = | ||||||
|  |                 ( Math.max(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4 ) + paddingChunksAroundBorder; | ||||||
|  |         final int maxChunkZ = | ||||||
|  |                 ( Math.max(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4 ) + paddingChunksAroundBorder; | ||||||
|  |  | ||||||
|         chunkX++; |         chunkX++; | ||||||
|  |  | ||||||
| @@ -179,7 +186,8 @@ public class ChunkGenerator | |||||||
|  |  | ||||||
|             Chunk chunk = w.getChunkAt(chunkX, chunkZ); |             Chunk chunk = w.getChunkAt(chunkX, chunkZ); | ||||||
|             chunk.load(true); |             chunk.load(true); | ||||||
|             loadSurroundingChunks(chunkX, chunkZ, w); // this will get the server to generate trees, … inside the new chunk |             loadSurroundingChunks(chunkX, chunkZ, | ||||||
|  |                                   w); // this will get the server to generate trees, … inside the new chunk | ||||||
|  |  | ||||||
|             logProgress(minChunkX, maxChunkX, minChunkZ, maxChunkZ, chunkX, chunkZ, w); |             logProgress(minChunkX, maxChunkX, minChunkZ, maxChunkZ, chunkX, chunkZ, w); | ||||||
|         } |         } | ||||||
| @@ -190,7 +198,7 @@ public class ChunkGenerator | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected static boolean chunkIsInsideBorder(int x, int z, World w, Border b) |     private static boolean chunkIsInsideBorder( int x, int z, World w, Border b ) | ||||||
|     { |     { | ||||||
|         double xLoc = (double) ( x << 4 ) + 8.0; |         double xLoc = (double) ( x << 4 ) + 8.0; | ||||||
|         double yLoc = 0.0; |         double yLoc = 0.0; | ||||||
| @@ -202,7 +210,7 @@ public class ChunkGenerator | |||||||
|         return b.checkBorder(l, padding) == null; |         return b.checkBorder(l, padding) == null; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected static void loadSurroundingChunks(int x, int z, World w) |     private static void loadSurroundingChunks( int x, int z, World w ) | ||||||
|     { |     { | ||||||
|         int radius = 1; |         int radius = 1; | ||||||
|  |  | ||||||
| @@ -220,12 +228,14 @@ public class ChunkGenerator | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected static void logProgress(int minChunkX, int maxChunkX, int minChunkZ, int maxChunkZ, int chunkX, int chunkZ, World world) |     private static void logProgress( int minChunkX, int maxChunkX, int minChunkZ, int maxChunkZ, int chunkX, | ||||||
|  |                                      int chunkZ, World world ) | ||||||
|     { |     { | ||||||
|         final Long now = Calendar.getInstance().getTimeInMillis(); |         final Long now = Calendar.getInstance().getTimeInMillis(); | ||||||
|         final Long lastLogTime = lastGenerationLogTime.get(world); |         final Long lastLogTime = lastGenerationLogTime.get(world); | ||||||
|  |  | ||||||
|         if (lastLogTime == null || (now - lastLogTime) > 30000) { |         if ( lastLogTime == null || ( now - lastLogTime ) > 30000 ) | ||||||
|  |         { | ||||||
|             lastGenerationLogTime.put(world, now); |             lastGenerationLogTime.put(world, now); | ||||||
|  |  | ||||||
|             final int numXChunks, offsetX; |             final int numXChunks, offsetX; | ||||||
| @@ -234,7 +244,8 @@ public class ChunkGenerator | |||||||
|                 numXChunks = minChunkX * maxChunkX; |                 numXChunks = minChunkX * maxChunkX; | ||||||
|                 offsetX = 0; |                 offsetX = 0; | ||||||
|             } |             } | ||||||
|             else { |             else | ||||||
|  |             { | ||||||
|                 numXChunks = Math.abs(minChunkX) + maxChunkX; |                 numXChunks = Math.abs(minChunkX) + maxChunkX; | ||||||
|                 offsetX = Math.abs(minChunkX); |                 offsetX = Math.abs(minChunkX); | ||||||
|             } |             } | ||||||
| @@ -245,14 +256,17 @@ public class ChunkGenerator | |||||||
|                 numZChunks = minChunkZ * maxChunkZ; |                 numZChunks = minChunkZ * maxChunkZ; | ||||||
|                 offsetZ = 0; |                 offsetZ = 0; | ||||||
|             } |             } | ||||||
|             else { |             else | ||||||
|  |             { | ||||||
|                 numZChunks = Math.abs(minChunkZ) + maxChunkZ; |                 numZChunks = Math.abs(minChunkZ) + maxChunkZ; | ||||||
|                 offsetZ = Math.abs(minChunkZ); |                 offsetZ = Math.abs(minChunkZ); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             final int totalNumChunks = numXChunks * numZChunks; |             final int totalNumChunks = numXChunks * numZChunks; | ||||||
|             final int currentChunk = ( ( offsetZ + chunkZ ) * numXChunks ) + offsetX + chunkX; |             final int currentChunk = ( ( offsetZ + chunkZ ) * numXChunks ) + offsetX + chunkX; | ||||||
|             Plugin.instance.getLogger().info("Generation progress: " + currentChunk + "/" + totalNumChunks + " Chunks in World " + world.getName()); |             Plugin.instance.getLogger() | ||||||
|  |                            .info("Generation progress: " + currentChunk + "/" + totalNumChunks + " Chunks in World " + | ||||||
|  |                                  world.getName()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -261,9 +275,8 @@ public class ChunkGenerator | |||||||
| class DelayedCall implements Runnable | class DelayedCall implements Runnable | ||||||
| { | { | ||||||
|     public World w; |     public World w; | ||||||
|     public int batchGenerationSize; |     int batchGenerationSize; | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public void run() |     public void run() | ||||||
|     { |     { | ||||||
|         for ( int i = 0; i < batchGenerationSize; i++ ) |         for ( int i = 0; i < batchGenerationSize; i++ ) | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Tobias Ottenweller, Paul Schulze |     Copyright (C) 2016  Tobias Ottenweller, Paul Schulze | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU Lesser General Public License as published |     it under the terms of the GNU Lesser General Public License as published | ||||||
| @@ -24,17 +24,14 @@ import java.util.HashMap; | |||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * NOTE: We do not care about yaw and pitch for gate locations. So we won't serialize them. |  | ||||||
|  */ |  | ||||||
| public class LocationSerializer2D | public class LocationSerializer2D | ||||||
| { | { | ||||||
|     protected static String worldKey = "world"; |     private static final String worldKey = "world"; | ||||||
|     protected static String xKey     = "x"; |     private static final String xKey     = "x"; | ||||||
|     protected static String zKey     = "z"; |     private static final String zKey     = "z"; | ||||||
|  |  | ||||||
|  |  | ||||||
|     protected static World getWorld( String name ) throws Exception |     private static World getWorld( String name ) throws Exception | ||||||
|     { |     { | ||||||
|         World world = Plugin.instance.getServer().getWorld(name); |         World world = Plugin.instance.getServer().getWorld(name); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /*  Craft Inc. BorderProtection | /*  Craft Inc. BorderProtection | ||||||
|     Copyright (C) 2013  Paul Schulze, Tobias Ottenweller |     Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |     This program is free software: you can redistribute it and/or modify | ||||||
|     it under the terms of the GNU General Public License as published by |     it under the terms of the GNU General Public License as published by | ||||||
|   | |||||||
| @@ -1,102 +0,0 @@ | |||||||
| /*  Craft Inc. BorderProtection |  | ||||||
|     Copyright (C) 2013  Paul Schulze |  | ||||||
|  |  | ||||||
|     This program is free software: you can redistribute it and/or modify |  | ||||||
|     it under the terms of the GNU General Public License as published by |  | ||||||
|     the Free Software Foundation, either version 3 of the License, or |  | ||||||
|     (at your option) any later version. |  | ||||||
|  |  | ||||||
|     This program is distributed in the hope that it will be useful, |  | ||||||
|     but WITHOUT ANY WARRANTY; without even the implied warranty of |  | ||||||
|     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the |  | ||||||
|     GNU General Public License for more details. |  | ||||||
|  |  | ||||||
|     You should have received a copy of the GNU General Public License |  | ||||||
|     along with this program.  If not, see <http://www.gnu.org/licenses/>. |  | ||||||
| */ |  | ||||||
| package de.craftinc.borderprotection.util; |  | ||||||
|  |  | ||||||
| import de.craftinc.borderprotection.Plugin; |  | ||||||
|  |  | ||||||
| import java.io.BufferedReader; |  | ||||||
| import java.io.IOException; |  | ||||||
| import java.io.InputStreamReader; |  | ||||||
| import java.net.MalformedURLException; |  | ||||||
| import java.net.URL; |  | ||||||
| import java.net.URLConnection; |  | ||||||
|  |  | ||||||
| public class UpdateHelper |  | ||||||
| { |  | ||||||
|     /** |  | ||||||
|      * The URL from which the Plugin tries to get the latest version. |  | ||||||
|      */ |  | ||||||
|     @SuppressWarnings("FieldCanBeLocal") |  | ||||||
|     private static final String updateUrl = "http://www.craftinc.de/plugins/update/craftinc-borderprotection"; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * The latest version which was seen on last check. |  | ||||||
|      */ |  | ||||||
|     public static String cachedLatestVersion = null; |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Gets the latest version from the updateURL and returns it as <code>String</code>. |  | ||||||
|      * |  | ||||||
|      * @return latest version as <code>String</code>. |  | ||||||
|      */ |  | ||||||
|     @SuppressWarnings("StringBufferMayBeStringBuilder") |  | ||||||
|     public static String getLatestVersion() |  | ||||||
|     { |  | ||||||
|         // StringBuffer is thread-safe. Don't know if this is really important here, but safe is safe :). |  | ||||||
|         StringBuffer s = new StringBuffer(); |  | ||||||
|         try |  | ||||||
|         { |  | ||||||
|             URLConnection c = new URL(updateUrl).openConnection(); |  | ||||||
|             BufferedReader br = new BufferedReader(new InputStreamReader(c.getInputStream())); |  | ||||||
|             String inputLine; |  | ||||||
|             while ( ( inputLine = br.readLine() ) != null ) |  | ||||||
|             { |  | ||||||
|                 s.append(inputLine); |  | ||||||
|             } |  | ||||||
|             br.close(); |  | ||||||
|         } |  | ||||||
|         catch ( MalformedURLException e ) |  | ||||||
|         { |  | ||||||
|             Plugin.instance.getLogger().warning("Could not check for latest version. Update URL is malformed."); |  | ||||||
|         } |  | ||||||
|         catch ( IOException e ) |  | ||||||
|         { |  | ||||||
|             Plugin.instance.getLogger().warning("Could not check for latest version. Update URL was not readable."); |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         // update cached latest version |  | ||||||
|         cachedLatestVersion = s.toString(); |  | ||||||
|  |  | ||||||
|         return s.toString(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Gets the current version of this plugin directly from the plugin.yml version entry. |  | ||||||
|      * |  | ||||||
|      * @return current version as <code>String</code>. |  | ||||||
|      */ |  | ||||||
|     public static String getCurrentVersion() |  | ||||||
|     { |  | ||||||
|         return Plugin.instance.getDescription().getVersion(); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     /** |  | ||||||
|      * Checks if a newer version is available. |  | ||||||
|      * |  | ||||||
|      * @return Boolean |  | ||||||
|      */ |  | ||||||
|     public static Boolean newVersionAvailable() |  | ||||||
|     { |  | ||||||
|         final String version = getLatestVersion(); |  | ||||||
|  |  | ||||||
|         // do not show beta or dev versions |  | ||||||
|         if (version.contains("beta") || version.contains("dev")) |  | ||||||
|             return false; |  | ||||||
|  |  | ||||||
|         return !getCurrentVersion().equals(getLatestVersion()); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| #    Craft Inc. BorderProtection | #    Craft Inc. BorderProtection | ||||||
| #    Copyright (C) 2013  Paul Schulze, Tobias Ottenweller | #    Copyright (C) 2016  Paul Schulze, Tobias Ottenweller | ||||||
| # | # | ||||||
| #    This program is free software: you can redistribute it and/or modify | #    This program is free software: you can redistribute it and/or modify | ||||||
| #    it under the terms of the GNU General Public License as published by | #    it under the terms of the GNU General Public License as published by | ||||||
| @@ -17,9 +17,9 @@ | |||||||
| name: ${project.name} | name: ${project.name} | ||||||
| main: de.craftinc.borderprotection.Plugin | main: de.craftinc.borderprotection.Plugin | ||||||
| version: ${project.version} | version: ${project.version} | ||||||
| softdepend: [Multiverse-Core] | softdepend: [] | ||||||
| authors: [ddidderr, mice_on_drugs] | authors: [ddidderr, mice_on_drugs] | ||||||
| website: http://www.craftinc.de/plugins/borderprotection | website: https://www.craftinc.de/plugins/borderprotection | ||||||
|  |  | ||||||
|  |  | ||||||
| commands: | commands: | ||||||
| @@ -33,9 +33,6 @@ permissions: | |||||||
|   craftinc.borderprotection.ignoreborders: |   craftinc.borderprotection.ignoreborders: | ||||||
|     default: false |     default: false | ||||||
|     description: Allows to be everywhere on the map (ignoring the borders). |     description: Allows to be everywhere on the map (ignoring the borders). | ||||||
|   craftinc.borderprotection.update: |  | ||||||
|     default: op |  | ||||||
|     description: Allows to get notified on login, when a new update is available. |  | ||||||
|   craftinc.borderprotection.generate: |   craftinc.borderprotection.generate: | ||||||
|     default: op |     default: op | ||||||
|     description: Allows to generate the complete world inside the border. |     description: Allows to generate the complete world inside the border. | ||||||
		Reference in New Issue
	
	Block a user
	 Paul Schulze
					Paul Schulze