Compare commits
No commits in common. "master" and "world-generation" have entirely different histories.
master
...
world-gene
@ -5,6 +5,6 @@ full text of GPLv3 can be found in the file "GPLv3"
|
||||
|
||||
|
||||
# LGPLv3
|
||||
* src/main/java/de/craftinc/borderprotection/util/LocationSerializer2D.java
|
||||
* src/main/java/de/craftinc/borderprotection/LocationSerializer.java
|
||||
|
||||
full text of LGPLv3 can be found in the file "LGPLv3"
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
A border protection plugin for bukkit. All players (except those with ignoreborders permission) cannot go beyond the border.
|
||||
|
||||
Read the [full user guide](https://craftinc.comff.net/border-protection/) for more information.
|
||||
Read the [full user guide](http://www.craftinc.de/border-protection/) for more information.
|
||||
|
||||
## License
|
||||
|
||||
|
42
pom.xml
42
pom.xml
@ -4,16 +4,16 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.craftinc</groupId>
|
||||
<artifactId>CraftincBorderProtection</artifactId>
|
||||
<name>CraftInc-BorderProtection</name>
|
||||
<name>Craft Inc. BorderProtection</name>
|
||||
<packaging>jar</packaging>
|
||||
<version>2.0</version>
|
||||
<version>2.0-beta</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
<finalName>${project.name} ${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
@ -42,7 +42,7 @@
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Run Test Bukkit Server</id>
|
||||
<phase>install</phase>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
@ -55,27 +55,27 @@
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<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>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<version>1.5.2-R0.1</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.5.2-R0.1</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
@ -1,202 +1,160 @@
|
||||
#!/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=$(readlink -f $(dirname "$0"))
|
||||
SERVICE='craftbukkit*.jar'
|
||||
#USERNAME="minecraft"
|
||||
CPU_COUNT=2
|
||||
BUKKIT="$SCRIPT_DIR/../target/lib/$SERVICE"
|
||||
INVOCATION="java -Xmx1000M -Xms300M -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=$CPU_COUNT -XX:+AggressiveOpts -jar $BUKKIT nogui"
|
||||
MCPATH="$SCRIPT_DIR/../bukkit-testserver"
|
||||
|
||||
|
||||
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
|
||||
if [ ! -d "$MCPATH" ]; then
|
||||
mkdir -p "$MCPATH"
|
||||
fi
|
||||
|
||||
SCREEN_NAME="$(cat "$MCPATH/screen_name" 2> /dev/null)"
|
||||
if [[ -z "$SCREEN_NAME" ]]; then
|
||||
SCREEN_NAME="minecraft.$(head -c12 /dev/urandom | xxd -p)"
|
||||
echo -n "$SCREEN_NAME" > "$MCPATH/screen_name"
|
||||
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 $?
|
||||
ME=$(whoami)
|
||||
as_user() {
|
||||
#if [ $ME == $USERNAME ] ; then
|
||||
bash -c "$1"
|
||||
#else
|
||||
#su - $USERNAME -c "$1"
|
||||
#fi
|
||||
}
|
||||
|
||||
mc_start() {
|
||||
if ! mc_status; then
|
||||
echo "Starting..."
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "Tried to start but $SERVICE was already running!"
|
||||
else
|
||||
echo "$SERVICE was not running... starting."
|
||||
cd "$MCPATH"
|
||||
screen -dmS "$SCREEN_NAME" $INVOCATION
|
||||
sleep 2
|
||||
mc_status
|
||||
as_user "cd "$MCPATH" && screen -dmS minecraft $INVOCATION"
|
||||
sleep 7
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE is now running."
|
||||
else
|
||||
echo "Could not start $SERVICE."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
mc_stop() {
|
||||
if mc_status; then
|
||||
# echo "Sending message to users..."
|
||||
# send_to_screen 'say SERVER SHUTTING DOWN IN 10 SECONDS!'
|
||||
# sleep 10
|
||||
echo "Saving..."
|
||||
send_to_screen 'save-all'
|
||||
sleep 1
|
||||
echo "Stopping..."
|
||||
send_to_screen 'stop'
|
||||
sleep 3
|
||||
mc_status
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE is running... stopping."
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-all\"\015'"
|
||||
sleep 2
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"stop\"\015'"
|
||||
sleep 6
|
||||
else
|
||||
echo "$SERVICE was not running."
|
||||
fi
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE could not be shut down... still running."
|
||||
else
|
||||
echo "$SERVICE is shut down."
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
mc_save() {
|
||||
if mc_status; then
|
||||
echo "Saving..."
|
||||
send_to_screen 'save-all'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
mc_restart_or_start() {
|
||||
if mc_service_running; then
|
||||
mc_stop
|
||||
sleep 1
|
||||
mc_start
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE is running... saving."
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"save-all\"\015'"
|
||||
else
|
||||
mc_start
|
||||
echo "$SERVICE was not running."
|
||||
fi
|
||||
}
|
||||
|
||||
mc_reset_permissions() {
|
||||
if mc_status; then
|
||||
echo "Unbanning ddidderr..."
|
||||
send_to_screen 'pardon ddidderr'
|
||||
echo "Unbanning mice_on_drugs..."
|
||||
send_to_screen 'pardon mice_on_drugs'
|
||||
echo "Unbanning Mochaccino..."
|
||||
send_to_screen 'pardon Mochaccino'
|
||||
|
||||
echo "ddidder -> admin"
|
||||
send_to_screen 'pex user ddidderr group set admin'
|
||||
echo "mice_on_drugs -> mod"
|
||||
send_to_screen 'pex user mice_on_drugs group set mod'
|
||||
echo "Mochaccino -> mod"
|
||||
send_to_screen 'pex user Mochaccino group set mod'
|
||||
|
||||
echo "Reloading permissions..."
|
||||
send_to_screen 'pex reload'
|
||||
echo "DONE"
|
||||
mc_reload() {
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE is running... reloading."
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"reload\"\015'"
|
||||
else
|
||||
echo "$SERVICE was not running."
|
||||
fi
|
||||
}
|
||||
|
||||
mc_custom_command() {
|
||||
if mc_status; then
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "You must specify a command." >&2
|
||||
exit 1
|
||||
mc_reload_or_start() {
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE was already running! Doing a reload now!"
|
||||
mc_reload
|
||||
else
|
||||
echo "$SERVICE was not running... starting."
|
||||
cd "$MCPATH"
|
||||
as_user "cd \"$MCPATH\" && screen -dmS minecraft $INVOCATION"
|
||||
sleep 7
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE is now running."
|
||||
else
|
||||
echo "Could not start $SERVICE."
|
||||
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
|
||||
mc_ddidderr_admin() {
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE is running... making ddidder to admin and reloading permissions."
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"pex user ddidderr group set admin\"\015'"
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"pex reload\"\015'"
|
||||
else
|
||||
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"
|
||||
echo "$SERVICE was not running."
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo "Starting Minecraft..."
|
||||
mc_start
|
||||
echo "DONE"
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping Minecraft..."
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER SHUTTING DOWN!\"\015'"
|
||||
mc_stop
|
||||
echo "DONE"
|
||||
;;
|
||||
restart)
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"say SERVER REBOOT IN 10 SECONDS.\"\015'"
|
||||
$0 stop
|
||||
sleep 2
|
||||
sleep 1
|
||||
$0 start
|
||||
;;
|
||||
restart_or_start)
|
||||
mc_restart_or_start
|
||||
reload)
|
||||
mc_reload
|
||||
;;
|
||||
reset_permissions)
|
||||
mc_reset_permissions
|
||||
reload_or_start)
|
||||
echo "Starting or reloading Minecraft..."
|
||||
mc_reload_or_start
|
||||
echo "DONE"
|
||||
;;
|
||||
custom)
|
||||
mc_custom_command "${*:2}"
|
||||
ddidderr_admin)
|
||||
mc_ddidderr_admin
|
||||
;;
|
||||
online)
|
||||
mc_online
|
||||
connected)
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"who\"\015'"
|
||||
sleep 2s
|
||||
tac "$MCPATH"/server.log | grep -m 1 "Connected"
|
||||
;;
|
||||
status)
|
||||
mc_status
|
||||
if ps ax | grep -v grep | grep -v -i SCREEN | grep "craftbukkit" > /dev/null
|
||||
then
|
||||
echo "$SERVICE is running."
|
||||
else
|
||||
echo "$SERVICE is not running."
|
||||
fi
|
||||
;;
|
||||
save)
|
||||
mc_save
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|save|online|status|reset_permissions}"
|
||||
echo "Usage: /etc/init.d/minecraft {start|stop|restart|connected|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -1,57 +1,29 @@
|
||||
#!/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")"
|
||||
|
||||
DEVELOPER="$(whoami)"
|
||||
DEVELOPER=$(whoami)
|
||||
|
||||
BUKKIT_DIR="$SCRIPT_DIR/../bukkit-testserver"
|
||||
PLUGIN_DIR="$SCRIPT_DIR/../bukkit-testserver/plugins"
|
||||
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"
|
||||
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"
|
||||
PLUGIN_DIR="$SCRIPT_DIR/../bukkit-testserver/plugins"
|
||||
START_STOP_SCRIPT="$SCRIPT_DIR/minecraft.sh"
|
||||
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.
|
||||
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.
|
||||
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"
|
||||
|
||||
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"
|
||||
|
||||
$START_STOP_SCRIPT restart_or_start
|
||||
$START_STOP_SCRIPT reload_or_start
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -65,21 +65,21 @@ public class Messages
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static final String borderExplanation =
|
||||
private static String borderExplanation =
|
||||
"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.";
|
||||
|
||||
public static final String borderMessage =
|
||||
public static String borderMessage =
|
||||
ChatColor.YELLOW + "Sorry Dude! " +
|
||||
ChatColor.WHITE + "This is the border... the final frontier! " + borderExplanation + NEWLINE +
|
||||
makeCmd("/cibp get", "shows the borders of the current world");
|
||||
|
||||
public static final String borderTeleportMessage =
|
||||
public static String borderTeleportMessage =
|
||||
ChatColor.YELLOW + "Sorry Dude! " +
|
||||
ChatColor.WHITE + "You cannot teleport outside the border. " + borderExplanation + NEWLINE +
|
||||
makeCmd("/cibp get", "shows the borders of the current world");
|
||||
|
||||
public static final String helpGeneral =
|
||||
public static String helpGeneral =
|
||||
ChatColor.GREEN + pluginName + " - Usage:" + NEWLINE +
|
||||
ChatColor.WHITE + "Commands are always related to the current world." + NEWLINE +
|
||||
makeCmd("help", "shows this help") +
|
||||
@ -90,14 +90,15 @@ public class Messages
|
||||
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", "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 final String borderCreationSuccessful
|
||||
public static String borderCreationSuccessful
|
||||
= ChatColor.YELLOW + "New border was set " +
|
||||
ChatColor.GREEN + "successfully" +
|
||||
ChatColor.YELLOW + "!";
|
||||
|
||||
public static final String commandIssuedByNonPlayer
|
||||
public static String commandIssuedByNonPlayer
|
||||
= ChatColor.RED + "Only a player can use " + pluginName + " commands!";
|
||||
|
||||
public static String borderInfo( String worldName, Border border )
|
||||
@ -114,40 +115,40 @@ public class Messages
|
||||
ChatColor.WHITE + "Border is " + borderEnabled + ChatColor.WHITE + ".";
|
||||
}
|
||||
|
||||
public static final String borderInfoNoBorderSet =
|
||||
public static String borderInfoNoBorderSet =
|
||||
ChatColor.YELLOW + "No border in this world.";
|
||||
|
||||
public static final String noPermissionSet =
|
||||
public static String noPermissionSet =
|
||||
ChatColor.RED + "Sorry, you don't have permission to change the border.";
|
||||
|
||||
public static final String borderEnabled =
|
||||
public static String noPermissionCheckversion =
|
||||
ChatColor.RED + "Sorry, you don't have permission to check for new versions.";
|
||||
|
||||
public static String borderEnabled =
|
||||
ChatColor.YELLOW + "Border enabled.";
|
||||
|
||||
public static final String borderDisabled =
|
||||
public static String borderDisabled =
|
||||
ChatColor.YELLOW + "Border disabled.";
|
||||
|
||||
public static final String borderSaveException =
|
||||
public static String borderSaveException =
|
||||
ChatColor.RED + "Error: Could not save border on server. After the next reload this border will be lost!";
|
||||
|
||||
public static final String borderEnableDisableException =
|
||||
public static String borderEnableDisableException =
|
||||
ChatColor.RED +
|
||||
"Error: Could not save border state on server. After the next reload this border state will be lost!";
|
||||
|
||||
public static final String generationCanceled =
|
||||
ChatColor.GREEN + "World generation canceled!";
|
||||
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 final String generationNotCanceled =
|
||||
ChatColor.RED + "No world generation happening. Cannot cancel!";
|
||||
|
||||
public static final String generationAlreadyInProgress =
|
||||
ChatColor.YELLOW +
|
||||
"World generation is already in progress. It will continue after all players are logged out.";
|
||||
|
||||
public static final String generationStarted =
|
||||
ChatColor.GREEN + "World generation will start after all players left the server.";
|
||||
|
||||
public static final String generationCouldNotBeStarted =
|
||||
ChatColor.RED + "Could not start world generation! Is there a border?";
|
||||
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.
|
||||
@ -174,8 +175,8 @@ public class Messages
|
||||
{
|
||||
lastMessage.put(player.getName(), new HashMap<String, Long>()
|
||||
{{
|
||||
put(message, now);
|
||||
}});
|
||||
put(message, now);
|
||||
}});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -19,10 +19,7 @@ package de.craftinc.borderprotection;
|
||||
import de.craftinc.borderprotection.borders.CircBorder;
|
||||
import de.craftinc.borderprotection.borders.RectBorder;
|
||||
import de.craftinc.borderprotection.commands.CommandSwitch;
|
||||
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 de.craftinc.borderprotection.events.*;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -51,7 +48,7 @@ public class Plugin extends JavaPlugin
|
||||
// create listeners
|
||||
PlayerMoveListener playerMoveListener = new PlayerMoveListener();
|
||||
PlayerTeleportListener playerTeleportListener = new PlayerTeleportListener();
|
||||
PlayerJoinListener playerJoinListener = new PlayerJoinListener();
|
||||
PlayerLoginListener playerLoginListener = new PlayerLoginListener();
|
||||
PlayerQuitListener playerQuitListener = new PlayerQuitListener();
|
||||
|
||||
// commands
|
||||
@ -62,7 +59,7 @@ public class Plugin extends JavaPlugin
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
pm.registerEvents(playerMoveListener, this);
|
||||
pm.registerEvents(playerTeleportListener, this);
|
||||
pm.registerEvents(playerJoinListener, this);
|
||||
pm.registerEvents(playerLoginListener, this);
|
||||
pm.registerEvents(playerQuitListener, this);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -32,12 +32,12 @@ public abstract class Border
|
||||
{
|
||||
private static final String dataFileName = "borders.yml";
|
||||
|
||||
private Boolean isActive;
|
||||
protected Boolean isActive;
|
||||
|
||||
private static final String isActiveKey = "enabled";
|
||||
private static final String bordersKey = "borders";
|
||||
protected static final String isActiveKey = "enabled";
|
||||
protected static final String bordersKey = "borders";
|
||||
|
||||
static final HashMap<World, Border> borders = new HashMap<World, Border>();
|
||||
protected static final HashMap<World, Border> borders = new HashMap<World, Border>();
|
||||
|
||||
private static final File bordersFile = new File(Plugin.instance.getDataFolder(), dataFileName);
|
||||
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
|
||||
* will be teleported directly to the border.
|
||||
*/
|
||||
static final double buffer = 0.5;
|
||||
public static final double buffer = 0.5;
|
||||
|
||||
public static HashMap<World, Border> getBorders()
|
||||
{
|
||||
@ -79,12 +79,11 @@ 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)
|
||||
* 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.
|
||||
* @return null if l is inside the border otherwise a new Location which is inside
|
||||
*/
|
||||
public abstract Location checkBorder( Location l, double padding );
|
||||
public abstract Location checkBorder (Location l, double padding);
|
||||
|
||||
/**
|
||||
* Returns an array of two Location objects defining a rectangle bigger or at size of the border. There are no
|
||||
@ -97,7 +96,7 @@ public abstract class Border
|
||||
return isActive;
|
||||
}
|
||||
|
||||
Border( Map<String, Object> map )
|
||||
public Border( Map<String, Object> map )
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -110,7 +109,7 @@ public abstract class Border
|
||||
}
|
||||
}
|
||||
|
||||
Border()
|
||||
public Border()
|
||||
{
|
||||
// new borders are enabled by default
|
||||
isActive = true;
|
||||
@ -138,7 +137,7 @@ public abstract class Border
|
||||
isActive = false;
|
||||
}
|
||||
|
||||
void serialize( Map<String, Object> map )
|
||||
protected void serialize( Map<String, Object> map )
|
||||
{
|
||||
map.put(isActiveKey, isActive);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -16,8 +16,8 @@
|
||||
*/
|
||||
package de.craftinc.borderprotection.borders;
|
||||
|
||||
import de.craftinc.borderprotection.Plugin;
|
||||
import de.craftinc.borderprotection.util.LocationSerializer2D;
|
||||
import de.craftinc.borderprotection.Plugin;
|
||||
import de.craftinc.borderprotection.util.PlayerMovementUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -31,8 +31,8 @@ public class CircBorder extends Border implements ConfigurationSerializable
|
||||
private Double radius;
|
||||
private Location center;
|
||||
|
||||
private static final String centerKey = "center";
|
||||
private static final String radiusKey = "radius";
|
||||
private static String centerKey = "center";
|
||||
private static String radiusKey = "radius";
|
||||
|
||||
@SuppressWarnings("unchecked unused")
|
||||
public CircBorder( Map<String, Object> map )
|
||||
@ -126,9 +126,9 @@ public class CircBorder extends Border implements ConfigurationSerializable
|
||||
@Override
|
||||
public Location[] getSurroundingRect()
|
||||
{
|
||||
Location l1 = new Location(center.getWorld(), center.getX() + radius, center.getY(), center.getX() + radius);
|
||||
Location l2 = new Location(center.getWorld(), center.getX() - radius, center.getY(), center.getX() - radius);
|
||||
Location l1 = new Location(center.getWorld(), center.getX()+radius, center.getY(), center.getX()+radius);
|
||||
Location l2 = new Location(center.getWorld(), center.getX()-radius, center.getY(), center.getX()-radius);
|
||||
|
||||
return new Location[] { l1, l2 };
|
||||
return new Location[]{ l1, l2 };
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -16,8 +16,8 @@
|
||||
*/
|
||||
package de.craftinc.borderprotection.borders;
|
||||
|
||||
import de.craftinc.borderprotection.Plugin;
|
||||
import de.craftinc.borderprotection.util.LocationSerializer2D;
|
||||
import de.craftinc.borderprotection.Plugin;
|
||||
import de.craftinc.borderprotection.util.PlayerMovementUtil;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -31,8 +31,8 @@ public class RectBorder extends Border implements ConfigurationSerializable
|
||||
private Location rectPoint1;
|
||||
private Location rectPoint2;
|
||||
|
||||
private static final String rectPoint1Name = "p1";
|
||||
private static final String rectPoint2Name = "p2";
|
||||
private static String rectPoint1Name = "p1";
|
||||
private static String rectPoint2Name = "p2";
|
||||
|
||||
@SuppressWarnings("unchecked unused")
|
||||
public RectBorder( Map<String, Object> map )
|
||||
@ -179,6 +179,6 @@ public class RectBorder extends Border implements ConfigurationSerializable
|
||||
@Override
|
||||
public Location[] getSurroundingRect()
|
||||
{
|
||||
return new Location[] { rectPoint1, rectPoint2 };
|
||||
return new Location[]{ rectPoint1, rectPoint2 };
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze
|
||||
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
|
||||
@ -26,11 +26,12 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class CancelGenerateCommand implements SubCommand
|
||||
public class CancelGenerateCommand implements SubCommand
|
||||
{
|
||||
public boolean execute( CommandSender sender, String[] parameters )
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] parameters)
|
||||
{
|
||||
if ( !sender.hasPermission("craftinc.borderprotection.generate") )
|
||||
if ( !sender.hasPermission("craftinc.borderprotection.set") ) // TODO: a new/different permission?
|
||||
{
|
||||
sender.sendMessage(Messages.noPermissionSet);
|
||||
return false;
|
||||
@ -38,19 +39,20 @@ class CancelGenerateCommand implements SubCommand
|
||||
|
||||
World world = ( (Player) sender ).getWorld();
|
||||
|
||||
if ( !ChunkGenerator.isGenerating(world) )
|
||||
if (!ChunkGenerator.isGenerating(world))
|
||||
{
|
||||
sender.sendMessage(Messages.generationNotCanceled);
|
||||
sender.sendMessage("nothing to cancel"); // TODO: put better message into Message class
|
||||
}
|
||||
else
|
||||
{
|
||||
ChunkGenerator.cancelRender(world);
|
||||
sender.sendMessage(Messages.generationCanceled);
|
||||
sender.sendMessage("generation canceled"); // TODO: put better message into Message class
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> commandNames()
|
||||
{
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
@ -0,0 +1,58 @@
|
||||
/* 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
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -27,11 +27,12 @@ import java.util.Map;
|
||||
|
||||
public class CommandSwitch implements CommandExecutor
|
||||
{
|
||||
private final Map<String, SubCommand> subCommandsMap = new HashMap<String, SubCommand>();
|
||||
protected Map<String, SubCommand> subCommandsMap = new HashMap<String, SubCommand>();
|
||||
|
||||
public CommandSwitch()
|
||||
{
|
||||
registerCommand(new CancelGenerateCommand());
|
||||
registerCommand(new CheckVersionCommand());
|
||||
registerCommand(new GenerateCommand());
|
||||
registerCommand(new GetCommand());
|
||||
registerCommand(new HelpCommand());
|
||||
@ -39,14 +40,15 @@ public class CommandSwitch implements CommandExecutor
|
||||
registerCommand(new SetCommand());
|
||||
}
|
||||
|
||||
private void registerCommand( SubCommand command )
|
||||
protected void registerCommand(SubCommand command)
|
||||
{
|
||||
for ( String commandName : command.commandNames() )
|
||||
for (String commandName : command.commandNames())
|
||||
{
|
||||
subCommandsMap.put(commandName, command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand( CommandSender sender, Command command, String label, String[] args )
|
||||
{
|
||||
// Check if command comes from a player.
|
||||
@ -61,18 +63,18 @@ public class CommandSwitch implements CommandExecutor
|
||||
// command for all actions
|
||||
if ( command.getName().equalsIgnoreCase("cibp") )
|
||||
{
|
||||
if ( args.length > 0 )
|
||||
if (args.length > 0)
|
||||
{
|
||||
String lowerCaseSubCommandName = args[0].toLowerCase();
|
||||
SubCommand subCommand = subCommandsMap.get(lowerCaseSubCommandName);
|
||||
|
||||
if ( subCommand != null )
|
||||
if (subCommand != null)
|
||||
{
|
||||
success = subCommand.execute(sender, args);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !success )
|
||||
if (!success)
|
||||
{
|
||||
subCommandsMap.get("help").execute(sender, args);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze
|
||||
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
|
||||
@ -25,11 +25,12 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class GenerateCommand implements SubCommand
|
||||
public class GenerateCommand implements SubCommand
|
||||
{
|
||||
public boolean execute( CommandSender sender, String[] parameters )
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] parameters)
|
||||
{
|
||||
if ( !sender.hasPermission("craftinc.borderprotection.generate") )
|
||||
if ( !sender.hasPermission("craftinc.borderprotection.set") ) // TODO: a new/different permission?
|
||||
{
|
||||
sender.sendMessage(Messages.noPermissionSet);
|
||||
return false;
|
||||
@ -37,25 +38,27 @@ class GenerateCommand implements SubCommand
|
||||
|
||||
World world = ( (Player) sender ).getWorld();
|
||||
|
||||
if ( ChunkGenerator.isGenerating(world) )
|
||||
if (ChunkGenerator.isGenerating(world))
|
||||
{
|
||||
sender.sendMessage(Messages.generationAlreadyInProgress);
|
||||
sender.sendMessage("already generating! will resume on logout"); // TODO: put better message into Message class
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( ChunkGenerator.generate(world) )
|
||||
if (ChunkGenerator.generate(world))
|
||||
{
|
||||
sender.sendMessage(Messages.generationStarted);
|
||||
sender.sendMessage("world marked for generation! will start on logout"); // TODO: put better message into Message class
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Messages.generationCouldNotBeStarted);
|
||||
sender.sendMessage("could not start generation. is there a border?"); // TODO: put better message into Message class
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> commandNames()
|
||||
{
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze
|
||||
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
|
||||
@ -25,9 +25,10 @@ import org.bukkit.entity.Player;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class GetCommand implements SubCommand
|
||||
public class GetCommand implements SubCommand
|
||||
{
|
||||
public boolean execute( CommandSender sender, String[] parameters )
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] parameters)
|
||||
{
|
||||
World world = ( (Player) sender ).getWorld();
|
||||
|
||||
@ -44,6 +45,7 @@ class GetCommand implements SubCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> commandNames()
|
||||
{
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze
|
||||
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
|
||||
@ -22,14 +22,16 @@ import org.bukkit.command.CommandSender;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HelpCommand implements SubCommand
|
||||
public class HelpCommand implements SubCommand
|
||||
{
|
||||
public boolean execute( CommandSender sender, String[] parameters )
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] parameters)
|
||||
{
|
||||
sender.sendMessage(Messages.helpGeneral);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> commandNames()
|
||||
{
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze
|
||||
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
|
||||
@ -27,9 +27,10 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class OnOffCommand implements SubCommand
|
||||
public class OnOffCommand implements SubCommand
|
||||
{
|
||||
public boolean execute( CommandSender sender, String[] parameters )
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] parameters)
|
||||
{
|
||||
if ( !sender.hasPermission("craftinc.borderprotection.set") )
|
||||
{
|
||||
@ -71,6 +72,7 @@ class OnOffCommand implements SubCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> commandNames()
|
||||
{
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze
|
||||
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
|
||||
@ -30,9 +30,10 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class SetCommand implements SubCommand
|
||||
public class SetCommand implements SubCommand
|
||||
{
|
||||
public boolean execute( CommandSender sender, String[] parameters )
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] parameters)
|
||||
{
|
||||
if ( !( parameters.length == 3 || parameters.length == 4 ) )
|
||||
{
|
||||
@ -59,7 +60,7 @@ class SetCommand implements SubCommand
|
||||
if ( parameters[1].equalsIgnoreCase("r") )
|
||||
{
|
||||
newBorder = new RectBorder(new Location(world, distance, 0, distance),
|
||||
new Location(world, -distance, 0, -distance));
|
||||
new Location(world, -distance, 0, -distance));
|
||||
}
|
||||
// circ border
|
||||
else if ( parameters[1].equalsIgnoreCase("c") )
|
||||
@ -95,7 +96,7 @@ class SetCommand implements SubCommand
|
||||
Double p2Z = Double.parseDouble(parameters[3].split(",")[1]);
|
||||
|
||||
newBorder = new RectBorder(new Location(world, p1X, 0, p1Z),
|
||||
new Location(world, p2X, 0, p2Z));
|
||||
new Location(world, p2X, 0, p2Z));
|
||||
}
|
||||
// circ border
|
||||
else if ( parameters[1].equalsIgnoreCase("c") )
|
||||
@ -132,6 +133,7 @@ class SetCommand implements SubCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> commandNames()
|
||||
{
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze
|
||||
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
|
||||
@ -22,17 +22,18 @@ import org.bukkit.command.CommandSender;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
interface SubCommand
|
||||
public 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.
|
||||
* @return Returns an boolean indicating if the subcommand got could be executed.
|
||||
*/
|
||||
boolean execute( CommandSender sender, String[] parameters );
|
||||
public boolean execute(CommandSender sender, String[] parameters);
|
||||
|
||||
/**
|
||||
* Returns a list of names of the command. All strings should be lowercase!
|
||||
*/
|
||||
List<String> commandNames();
|
||||
public List<String> commandNames();
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
/* 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/>.
|
||||
*/
|
||||
package de.craftinc.borderprotection.events;
|
||||
|
||||
import de.craftinc.borderprotection.util.ChunkGenerator;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerJoinListener implements Listener
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerLogin( PlayerJoinEvent e )
|
||||
{
|
||||
ChunkGenerator.pause();
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/* 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.events;
|
||||
|
||||
import de.craftinc.borderprotection.Messages;
|
||||
import de.craftinc.borderprotection.Plugin;
|
||||
import de.craftinc.borderprotection.util.ChunkGenerator;
|
||||
import de.craftinc.borderprotection.util.UpdateHelper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
public class PlayerLoginListener implements Listener
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerLogin( PlayerLoginEvent e )
|
||||
{
|
||||
final Player player = e.getPlayer();
|
||||
|
||||
if ( e.getPlayer().hasPermission("craftinc.borderprotection.update") )
|
||||
{
|
||||
if ( UpdateHelper.newVersionAvailable() )
|
||||
{
|
||||
// Schedule a task which delays 20 ticks (1 second) and then sends a message to the player
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Plugin.instance, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.sendMessage(Messages.updateMessage(UpdateHelper.cachedLatestVersion,
|
||||
UpdateHelper.getCurrentVersion()));
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("pausing generation");
|
||||
ChunkGenerator.pause();
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -30,7 +30,7 @@ public class PlayerMoveListener implements Listener
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerMove( PlayerMoveEvent e )
|
||||
{
|
||||
// do nothing if the event is already cancelled
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -29,7 +29,7 @@ public class PlayerQuitListener implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerQuit( PlayerQuitEvent e )
|
||||
{
|
||||
if ( Plugin.instance.getServer().getOnlinePlayers().size() == 1 )
|
||||
if (Plugin.instance.getServer().getOnlinePlayers().length == 1)
|
||||
{
|
||||
ChunkGenerator.resume();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -28,7 +28,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
public class PlayerTeleportListener implements Listener
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerTeleport( PlayerTeleportEvent e )
|
||||
{
|
||||
// do nothing if the event is already cancelled
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
@ -23,18 +23,16 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ChunkGenerator
|
||||
{
|
||||
private static final HashMap<World, Integer[]> chunkGenerationStatus = new HashMap<World, Integer[]>();
|
||||
private static boolean isPaused = true;
|
||||
private static final HashMap<World, Long> lastGenerationLogTime = new HashMap<World, Long>();
|
||||
protected static HashMap<World, Integer[]> chunkGenerationStatus = new HashMap<World, Integer[]>();
|
||||
protected static boolean isPaused = true;
|
||||
|
||||
private static final long waitTicks = 5; // TODO: make adjustable via config file
|
||||
private static final int batchGenerationSize = 5; //TODO: make adjustable via config file
|
||||
private static final int paddingChunksAroundBorder = 15; // TODO: make adjustable via config file
|
||||
public static long waitTicks = 5; // TODO: make adjustable via config file
|
||||
public static int batchGenerationSize = 5; //TODO: make adjustable via config file
|
||||
public static int paddingChunksAroundBorder = 15; // TODO: make adjustable via config file
|
||||
|
||||
public static void pause()
|
||||
{
|
||||
@ -43,20 +41,20 @@ public class ChunkGenerator
|
||||
|
||||
public static void resume()
|
||||
{
|
||||
if ( isPaused )
|
||||
if (isPaused)
|
||||
{
|
||||
isPaused = false;
|
||||
|
||||
for ( World w : chunkGenerationStatus.keySet() )
|
||||
for (World w : chunkGenerationStatus.keySet())
|
||||
{
|
||||
slowLoadNextChunk(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void cancelRender( World w )
|
||||
public static void cancelRender(World w)
|
||||
{
|
||||
if ( w == null )
|
||||
if (w == null)
|
||||
{
|
||||
throw new IllegalArgumentException("World 'w' must not be null!");
|
||||
}
|
||||
@ -64,9 +62,9 @@ public class ChunkGenerator
|
||||
chunkGenerationStatus.remove(w);
|
||||
}
|
||||
|
||||
public static boolean isGenerating( World w )
|
||||
public static boolean isGenerating(World w)
|
||||
{
|
||||
if ( w == null )
|
||||
if (w == null)
|
||||
{
|
||||
throw new IllegalArgumentException("World 'w' must not be null!");
|
||||
}
|
||||
@ -76,48 +74,45 @@ public class ChunkGenerator
|
||||
|
||||
/**
|
||||
* 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!
|
||||
* @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.
|
||||
*/
|
||||
public static boolean generate( World w )
|
||||
public static boolean generate(World w)
|
||||
{
|
||||
if ( w == null )
|
||||
if (w == null)
|
||||
{
|
||||
throw new IllegalArgumentException("World 'w' must not be null!");
|
||||
}
|
||||
|
||||
Border border = Border.getBorders().get(w);
|
||||
|
||||
if ( border == null )
|
||||
if (border == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Location[] borderRect = border.getSurroundingRect();
|
||||
|
||||
int firstChunkX =
|
||||
( Math.min(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4 ) - paddingChunksAroundBorder;
|
||||
int firstChunkZ =
|
||||
( Math.min(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4 ) - paddingChunksAroundBorder;
|
||||
int firstChunkX = (Math.min(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4) - paddingChunksAroundBorder;
|
||||
int firstChunkZ = (Math.min(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4) - paddingChunksAroundBorder;
|
||||
|
||||
firstChunkX--;
|
||||
|
||||
chunkGenerationStatus.put(w, new Integer[] { firstChunkX, firstChunkZ });
|
||||
chunkGenerationStatus.put(w, new Integer[]{firstChunkX, firstChunkZ});
|
||||
// the actual generation will start when resume is called!
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void slowLoadNextChunk( World w )
|
||||
protected static void slowLoadNextChunk(World w)
|
||||
{
|
||||
if ( w == null )
|
||||
if (w == null)
|
||||
{
|
||||
throw new IllegalArgumentException("World 'w' must not be null!");
|
||||
}
|
||||
|
||||
if ( isPaused )
|
||||
if (isPaused)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -132,23 +127,23 @@ public class ChunkGenerator
|
||||
/**
|
||||
* Will only load/generate the next chunks inside the border of the given world. Will stop if no border exists.
|
||||
*/
|
||||
static void loadNextChunk( World w )
|
||||
protected static void loadNextChunk(World w)
|
||||
{
|
||||
if ( w == null )
|
||||
if (w == null)
|
||||
{
|
||||
throw new IllegalArgumentException("World 'w' must not be null!");
|
||||
}
|
||||
|
||||
Border border = Border.getBorders().get(w);
|
||||
|
||||
if ( border == null )
|
||||
if (border == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Integer[] lastGeneratedChunk = chunkGenerationStatus.get(w);
|
||||
|
||||
if ( lastGeneratedChunk == null )
|
||||
if (lastGeneratedChunk == null)
|
||||
{
|
||||
return; // the generation got most likely canceled
|
||||
}
|
||||
@ -156,40 +151,35 @@ public class ChunkGenerator
|
||||
int chunkX = lastGeneratedChunk[0];
|
||||
int chunkZ = lastGeneratedChunk[1];
|
||||
|
||||
final Location[] borderRect = border.getSurroundingRect();
|
||||
final int minChunkX =
|
||||
( Math.min(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4 ) - paddingChunksAroundBorder;
|
||||
final int minChunkZ =
|
||||
( 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;
|
||||
Location[] borderRect = border.getSurroundingRect();
|
||||
int minChunkX = (Math.min(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4) - paddingChunksAroundBorder;
|
||||
int maxChunkX = (Math.max(borderRect[0].getBlockX(), borderRect[1].getBlockX()) >> 4) + paddingChunksAroundBorder;
|
||||
int maxChunkZ = (Math.max(borderRect[0].getBlockZ(), borderRect[1].getBlockZ()) >> 4) + paddingChunksAroundBorder;
|
||||
|
||||
chunkX++;
|
||||
|
||||
while ( !chunkIsInsideBorder(chunkX, chunkZ, w, border)
|
||||
&& chunkZ <= maxChunkZ )
|
||||
while (!chunkIsInsideBorder(chunkX, chunkZ, w, border)
|
||||
&& chunkZ <= maxChunkZ)
|
||||
{
|
||||
chunkX++;
|
||||
|
||||
if ( chunkX > maxChunkX )
|
||||
if (chunkX > maxChunkX)
|
||||
{
|
||||
chunkZ++;
|
||||
chunkX = minChunkX;
|
||||
}
|
||||
}
|
||||
|
||||
if ( chunkZ <= maxChunkZ )
|
||||
if (chunkZ <= maxChunkZ)
|
||||
{
|
||||
chunkGenerationStatus.put(w, new Integer[] { chunkX, chunkZ });
|
||||
chunkGenerationStatus.put(w, new Integer[]{chunkX, chunkZ});
|
||||
|
||||
// TODO: only display a message every 10s or so with a fake percentage number.
|
||||
Plugin.instance.getLogger().info("Loading/Generating Chunk ( x=" + chunkX + " z=" + chunkZ + " world=" + w.getName() + " )");
|
||||
|
||||
Chunk chunk = w.getChunkAt(chunkX, chunkZ);
|
||||
chunk.load(true);
|
||||
loadSurroundingChunks(chunkX, chunkZ,
|
||||
w); // this will get the server to generate trees, … inside the new chunk
|
||||
|
||||
logProgress(minChunkX, maxChunkX, minChunkZ, maxChunkZ, chunkX, chunkZ, w);
|
||||
loadSurroundingChunks(chunkX, chunkZ, w); // this will get the server to generate trees, … inside the new chunk
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -198,88 +188,47 @@ public class ChunkGenerator
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean chunkIsInsideBorder( int x, int z, World w, Border b )
|
||||
protected 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 zLoc = (double) ( z << 4 ) + 8.0;
|
||||
double zLoc = (double)(z << 4) + 8.0;
|
||||
|
||||
double padding = (double) ( paddingChunksAroundBorder << 4 );
|
||||
double padding = (double)(paddingChunksAroundBorder << 4);
|
||||
Location l = new Location(w, xLoc, yLoc, zLoc);
|
||||
|
||||
return b.checkBorder(l, padding) == null;
|
||||
}
|
||||
|
||||
private static void loadSurroundingChunks( int x, int z, World w )
|
||||
protected static void loadSurroundingChunks(int x, int z, World w)
|
||||
{
|
||||
int radius = 1;
|
||||
|
||||
for ( int i = -radius; i < radius; i++ )
|
||||
for (int i=-radius; i<radius; i++)
|
||||
{
|
||||
for ( int j = -radius; j < radius; j++ )
|
||||
for (int j=-radius; j<radius; j++)
|
||||
{
|
||||
if ( j == 0 && i == 0 )
|
||||
if (j == 0 && i == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
w.loadChunk(i + x, j + z, false);
|
||||
w.loadChunk(i+x, j+z, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 lastLogTime = lastGenerationLogTime.get(world);
|
||||
|
||||
if ( lastLogTime == null || ( now - lastLogTime ) > 30000 )
|
||||
{
|
||||
lastGenerationLogTime.put(world, now);
|
||||
|
||||
final int numXChunks, offsetX;
|
||||
if ( ( ( maxChunkX > 0 ) && ( minChunkX > 0 ) ) || ( ( maxChunkX < 0 ) && ( minChunkX < 0 ) ) )
|
||||
{
|
||||
numXChunks = minChunkX * maxChunkX;
|
||||
offsetX = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
numXChunks = Math.abs(minChunkX) + maxChunkX;
|
||||
offsetX = Math.abs(minChunkX);
|
||||
}
|
||||
|
||||
final int numZChunks, offsetZ;
|
||||
if ( ( ( maxChunkZ > 0 ) && ( minChunkZ > 0 ) ) || ( ( maxChunkZ < 0 ) && ( minChunkZ < 0 ) ) )
|
||||
{
|
||||
numZChunks = minChunkZ * maxChunkZ;
|
||||
offsetZ = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
numZChunks = Math.abs(minChunkZ) + maxChunkZ;
|
||||
offsetZ = Math.abs(minChunkZ);
|
||||
}
|
||||
|
||||
final int totalNumChunks = numXChunks * numZChunks;
|
||||
final int currentChunk = ( ( offsetZ + chunkZ ) * numXChunks ) + offsetX + chunkX;
|
||||
Plugin.instance.getLogger()
|
||||
.info("Generation progress: " + currentChunk + "/" + totalNumChunks + " Chunks in World " +
|
||||
world.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DelayedCall implements Runnable
|
||||
{
|
||||
public World w;
|
||||
int batchGenerationSize;
|
||||
public int batchGenerationSize;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
for ( int i = 0; i < batchGenerationSize; i++ )
|
||||
for (int i=0; i<batchGenerationSize;i++)
|
||||
{
|
||||
ChunkGenerator.loadNextChunk(w);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Tobias Ottenweller, Paul Schulze
|
||||
Copyright (C) 2013 Tobias Ottenweller, Paul Schulze
|
||||
|
||||
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
|
||||
@ -24,14 +24,17 @@ import java.util.HashMap;
|
||||
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
|
||||
{
|
||||
private static final String worldKey = "world";
|
||||
private static final String xKey = "x";
|
||||
private static final String zKey = "z";
|
||||
protected static String worldKey = "world";
|
||||
protected static String xKey = "x";
|
||||
protected static String zKey = "z";
|
||||
|
||||
|
||||
private static World getWorld( String name ) throws Exception
|
||||
protected static World getWorld( String name ) throws Exception
|
||||
{
|
||||
World world = Plugin.instance.getServer().getWorld(name);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
|
||||
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
|
||||
|
@ -0,0 +1,102 @@
|
||||
/* 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
|
||||
# Copyright (C) 2016 Paul Schulze, Tobias Ottenweller
|
||||
# Copyright (C) 2013 Paul Schulze, Tobias Ottenweller
|
||||
#
|
||||
# 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
|
||||
@ -17,9 +17,9 @@
|
||||
name: ${project.name}
|
||||
main: de.craftinc.borderprotection.Plugin
|
||||
version: ${project.version}
|
||||
softdepend: []
|
||||
softdepend: [Multiverse-Core]
|
||||
authors: [ddidderr, mice_on_drugs]
|
||||
website: https://www.craftinc.de/plugins/borderprotection
|
||||
website: http://www.craftinc.de/plugins/borderprotection
|
||||
|
||||
|
||||
commands:
|
||||
@ -33,6 +33,6 @@ permissions:
|
||||
craftinc.borderprotection.ignoreborders:
|
||||
default: false
|
||||
description: Allows to be everywhere on the map (ignoring the borders).
|
||||
craftinc.borderprotection.generate:
|
||||
craftinc.borderprotection.update:
|
||||
default: op
|
||||
description: Allows to generate the complete world inside the border.
|
||||
description: Allows to get notified on login, when a new update is available.
|
Loading…
x
Reference in New Issue
Block a user