Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
e20a2c9084 | |||
bb32466902 | |||
bbbe256718 | |||
53c29aa9a8 | |||
094b2f6dca | |||
62e7d558e6 | |||
8fd26b513a | |||
a83c0fbab0 | |||
6a218f97f0 | |||
46d19fa35e | |||
785dc10644 | |||
c671f04f65 | |||
0176ec3a3a | |||
5bc660d392 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ lib/
|
||||
target/
|
||||
*.iml
|
||||
.idea/
|
||||
bukkit-testserver/
|
||||
|
Binary file not shown.
165
LGPLv3
Normal file
165
LGPLv3
Normal file
@ -0,0 +1,165 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
|
||||
d) Do one of the following:
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
|
||||
5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
19
LICENSE.md
Normal file
19
LICENSE.md
Normal file
@ -0,0 +1,19 @@
|
||||
# GPLv3
|
||||
* src/main/java/de/craftinc/borderprotection/Border.java
|
||||
* src/main/java/de/craftinc/borderprotection/BorderManager.java
|
||||
* src/main/java/de/craftinc/borderprotection/Commands.java
|
||||
* src/main/java/de/craftinc/borderprotection/Messages.java
|
||||
* src/main/java/de/craftinc/borderprotection/PlayerLoginListener.java
|
||||
* src/main/java/de/craftinc/borderprotection/PlayerMoveListener.java
|
||||
* src/main/java/de/craftinc/borderprotection/PlayerTeleportListener.java
|
||||
* src/main/java/de/craftinc/borderprotection/Plugin.java
|
||||
* src/main/java/de/craftinc/borderprotection/UpdateHelper.java
|
||||
* src/main/resources/plugin.yml
|
||||
|
||||
full text of GPLv3 can be found in the file "GPLv3"
|
||||
|
||||
|
||||
# LGPLv3
|
||||
* src/main/java/de/craftinc/borderprotection/LocationSerializer.java
|
||||
|
||||
full text of LGPLv3 can be found in the file "LGPLv3"
|
@ -1,8 +1,9 @@
|
||||
craftinc-borderprotection
|
||||
=========================
|
||||
# Craft Inc. BorderProtection
|
||||
|
||||
A border protection plugin for bukkit. All players (except those with ignoreborders permission) cannot go beyond the border.
|
||||
|
||||
Full user guide can be found here: http://www.craftinc.de/border-protection/
|
||||
Read the [full user guide](http://www.craftinc.de/border-protection/) for more information.
|
||||
|
||||
This project is licensed under the GPLv3, see LICENSE
|
||||
## License
|
||||
|
||||
This project is licensed under GPLv3 and some files are LGPLv3. For exact information see LICENSE.
|
||||
|
53
pom.xml
53
pom.xml
@ -5,17 +5,66 @@
|
||||
<groupId>de.craftinc</groupId>
|
||||
<artifactId>CraftincBorderProtection</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0.1</version>
|
||||
<version>1.1.1</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>Run Test Bukkit Server</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>${basedir}/scripts/test-deployment.sh</executable>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>RELEASE</version>
|
||||
<version>1.5-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.5-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
160
scripts/minecraft.sh
Executable file
160
scripts/minecraft.sh
Executable file
@ -0,0 +1,160 @@
|
||||
#!/bin/bash
|
||||
|
||||
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"
|
||||
|
||||
if [ ! -d "$MCPATH" ]; then
|
||||
mkdir -p "$MCPATH"
|
||||
fi
|
||||
|
||||
ME=$(whoami)
|
||||
as_user() {
|
||||
#if [ $ME == $USERNAME ] ; then
|
||||
bash -c "$1"
|
||||
#else
|
||||
#su - $USERNAME -c "$1"
|
||||
#fi
|
||||
}
|
||||
|
||||
mc_start() {
|
||||
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"
|
||||
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 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 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
|
||||
echo "$SERVICE was not running."
|
||||
fi
|
||||
}
|
||||
|
||||
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_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
|
||||
fi
|
||||
}
|
||||
|
||||
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 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 1
|
||||
$0 start
|
||||
;;
|
||||
reload)
|
||||
mc_reload
|
||||
;;
|
||||
reload_or_start)
|
||||
echo "Starting or reloading Minecraft..."
|
||||
mc_reload_or_start
|
||||
echo "DONE"
|
||||
;;
|
||||
ddidderr_admin)
|
||||
mc_ddidderr_admin
|
||||
;;
|
||||
connected)
|
||||
as_user "screen -p 0 -S minecraft -X eval 'stuff \"who\"\015'"
|
||||
sleep 2s
|
||||
tac "$MCPATH"/server.log | grep -m 1 "Connected"
|
||||
;;
|
||||
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: /etc/init.d/minecraft {start|stop|restart|connected|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
21
scripts/test-deployment.sh
Executable file
21
scripts/test-deployment.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "$0"))
|
||||
|
||||
BUKKIT_DIR="$SCRIPT_DIR/../bukkit-testserver"
|
||||
PLUGIN_DIR="$SCRIPT_DIR/../bukkit-testserver/plugins"
|
||||
|
||||
# TODO: This is a bad solution! Maven should write necessary information into an extra file.
|
||||
ARTIFACT_ID="$(grep -C3 '<groupId>de.craftinc' "$SCRIPT_DIR/../pom.xml" | grep '<artifactId>' | sed 's/\s*<artifactId>//g' | sed 's/<\/artifactId>\s*//g')"
|
||||
|
||||
# TODO: This is a bad solution! Maven should write necessary information into an extra file.
|
||||
VERSION="$(grep -C3 '<groupId>de.craftinc' "$SCRIPT_DIR/../pom.xml" | grep '<version>' | sed 's/\s*<version>//g' | sed 's/<\/version>\s*//g')"
|
||||
|
||||
|
||||
mkdir -p "$PLUGIN_DIR"
|
||||
|
||||
cp "$SCRIPT_DIR/../target/$ARTIFACT_ID-$VERSION".jar "$PLUGIN_DIR/$ARTIFACT_ID".jar
|
||||
|
||||
echo -e "ddidderr\nmice_on_drugs\nMochaccino" > "$BUKKIT_DIR/ops.txt"
|
||||
|
||||
"$SCRIPT_DIR/minecraft.sh" reload_or_start
|
@ -1,3 +1,19 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
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
|
||||
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;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -106,8 +122,6 @@ public class Border implements ConfigurationSerializable
|
||||
map.put(rectPoint2Name, LocationSerializer.serializeLocation(rectPoint2));
|
||||
map.put(isActiveKey, isActive);
|
||||
|
||||
System.out.println(map);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* CraftInc BorderProtection
|
||||
Copyright (C) 2012 Paul Schulze
|
||||
/* Craft Inc. BorderProtection
|
||||
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
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* CraftInc BorderProtection
|
||||
Copyright (C) 2012 Paul Schulze
|
||||
/* Craft Inc. BorderProtection
|
||||
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
|
||||
@ -53,6 +53,29 @@ public class Commands implements CommandExecutor
|
||||
return true;
|
||||
}
|
||||
|
||||
// checkversion
|
||||
if ( args.length > 0 && args[0].equalsIgnoreCase("checkversion") )
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// set
|
||||
if ( ( args.length == 2 || args.length == 3 ) && args[0].equalsIgnoreCase("set") )
|
||||
{
|
||||
@ -71,7 +94,7 @@ public class Commands implements CommandExecutor
|
||||
borderManager.setBorder(( (Player) sender ).getWorld(), Double.parseDouble(args[1]));
|
||||
Border border = Border.getBorders().get(world);
|
||||
sender.sendMessage(Messages.borderCreationSuccessful);
|
||||
sender.sendMessage(Messages.borderInfo(world.getName(), border.toString()));
|
||||
sender.sendMessage(Messages.borderInfo(world.getName(), border.toString(), border.isActive()));
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
@ -86,7 +109,7 @@ public class Commands implements CommandExecutor
|
||||
borderManager.setBorder(( (Player) sender ).getWorld(), args[1], args[2]);
|
||||
Border border = Border.getBorders().get(world);
|
||||
sender.sendMessage(Messages.borderCreationSuccessful);
|
||||
sender.sendMessage(Messages.borderInfo(world.getName(), border.toString()));
|
||||
sender.sendMessage(Messages.borderInfo(world.getName(), border.toString(), border.isActive()));
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
@ -120,21 +143,39 @@ public class Commands implements CommandExecutor
|
||||
|
||||
Border border = Border.getBorders().get(world);
|
||||
|
||||
sender.sendMessage(Messages.borderInfo(world.getName(), border.toString()));
|
||||
sender.sendMessage(Messages.borderInfo(world.getName(), border.toString(), border.isActive()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// on
|
||||
if ( args.length == 1 && ( args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off") ) )
|
||||
{
|
||||
if ( !sender.hasPermission("craftinc.borderprotection.set") )
|
||||
{
|
||||
sender.sendMessage(Messages.noPermissionSet);
|
||||
return false;
|
||||
}
|
||||
|
||||
World world = ( (Player) sender ).getWorld();
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
Border.getBorders().get(world).enable();
|
||||
Border border = Border.getBorders().get(world);
|
||||
|
||||
if ( border != null )
|
||||
{
|
||||
if ( args[0].equalsIgnoreCase("on") )
|
||||
{
|
||||
border.enable();
|
||||
sender.sendMessage(Messages.borderEnabled);
|
||||
} else {
|
||||
Border.getBorders().get(world).disable();
|
||||
}
|
||||
else
|
||||
{
|
||||
border.disable();
|
||||
sender.sendMessage(Messages.borderDisabled);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Messages.borderInfoNoBorderSet);
|
||||
}
|
||||
|
||||
// save the new border
|
||||
try
|
||||
|
@ -1,3 +1,19 @@
|
||||
/* Craft Inc. BorderProtection
|
||||
Copyright (C) 2013 Tobias Ottenweller
|
||||
|
||||
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
|
||||
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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program (LGPLv3). If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.craftinc.borderprotection;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -22,7 +38,8 @@ public class LocationSerializer
|
||||
{
|
||||
World world = Plugin.getPlugin().getServer().getWorld(name);
|
||||
|
||||
if (world == null) {
|
||||
if ( world == null )
|
||||
{
|
||||
throw new Exception("World '" + name + "' does not exists anymore! Cannot get instance!");
|
||||
}
|
||||
|
||||
@ -32,7 +49,8 @@ public class LocationSerializer
|
||||
|
||||
public static Map<String, Object> serializeLocation( Location l )
|
||||
{
|
||||
if (l == null) {
|
||||
if ( l == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -49,7 +67,8 @@ public class LocationSerializer
|
||||
|
||||
public static Location deserializeLocation( Map<String, Object> map ) throws Exception
|
||||
{
|
||||
if (map == null) {
|
||||
if ( map == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* CraftInc BorderProtection
|
||||
Copyright (C) 2012 Paul Schulze
|
||||
/* Craft Inc. BorderProtection
|
||||
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
|
||||
@ -22,6 +22,8 @@ public class Messages
|
||||
{
|
||||
private static final String NEWLINE = "\n";
|
||||
|
||||
private static final String pluginName = Plugin.getPlugin().getDescription().getName();
|
||||
|
||||
private static String makeCmd( String command, String explanation, String... args )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -66,12 +68,14 @@ public class Messages
|
||||
makeCmd("/cibp get", "shows the borders of the current world");
|
||||
|
||||
public static String helpGeneral =
|
||||
ChatColor.GREEN + "CraftInc BorderProtection - Usage:" + NEWLINE +
|
||||
ChatColor.GREEN + pluginName + " - Usage:" + NEWLINE +
|
||||
makeCmd("help", "shows this help") +
|
||||
makeCmd("get | info", "shows the borders of the current world") +
|
||||
makeCmd("get | info", "shows the border of the current world") +
|
||||
makeCmd("on | off", "enables/disables the border of the current world") +
|
||||
makeCmd("set", "Border rectangle edges will be this far away from point of origin.", "<integer>") +
|
||||
makeCmd("set", "Border rectangle is defined by the two points. A point is specified as: x,z",
|
||||
"<point1>", "<point2>");
|
||||
"<point1>", "<point2>") +
|
||||
makeCmd("checkversion", "Checks for a newer version.");
|
||||
|
||||
public static String borderCreationSuccessful
|
||||
= ChatColor.YELLOW + "New border was set " +
|
||||
@ -79,22 +83,33 @@ public class Messages
|
||||
ChatColor.YELLOW + "!";
|
||||
|
||||
public static String commandIssuedByNonPlayer
|
||||
= ChatColor.RED + "Only a player can use CraftInc BorderProtection commands!";
|
||||
= ChatColor.RED + "Only a player can use " + pluginName + " commands!";
|
||||
|
||||
public static String borderInfo( String worldName, String borderDef )
|
||||
public static String borderInfo( String worldName, String borderDef, Boolean isBorderEnabled )
|
||||
{
|
||||
String borderEnabled;
|
||||
if (isBorderEnabled)
|
||||
{
|
||||
borderEnabled = ChatColor.GREEN + "enabled";
|
||||
} else {
|
||||
borderEnabled = ChatColor.RED + "disabled";
|
||||
}
|
||||
|
||||
return ChatColor.WHITE + "Borders of world " +
|
||||
ChatColor.YELLOW + worldName +
|
||||
ChatColor.WHITE + ": " +
|
||||
ChatColor.YELLOW + borderDef;
|
||||
ChatColor.YELLOW + borderDef + ChatColor.WHITE + "." + NEWLINE +
|
||||
ChatColor.WHITE + "Border is " + borderEnabled + ChatColor.WHITE + ".";
|
||||
}
|
||||
|
||||
public static String borderInfoNoBorderSet =
|
||||
ChatColor.YELLOW + "No border here.";
|
||||
ChatColor.YELLOW + "No border in this world.";
|
||||
|
||||
public static String noPermissionSet =
|
||||
ChatColor.RED + "Sorry, you don't have permission to set the border.";
|
||||
ChatColor.RED + "Sorry, you don't have permission to change the border.";
|
||||
|
||||
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.";
|
||||
@ -107,4 +122,17 @@ public class Messages
|
||||
|
||||
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 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/server-mods/craftinc-borderprotection" + NEWLINE +
|
||||
ChatColor.YELLOW + "to get the latest version!";
|
||||
}
|
||||
|
||||
public static String noUpdateAvailable =
|
||||
ChatColor.YELLOW + "No updates available.";
|
||||
}
|
||||
|
@ -0,0 +1,51 @@
|
||||
/* 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;
|
||||
|
||||
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.getPlugin(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
player.sendMessage(Messages.updateMessage(UpdateHelper.cachedLatestVersion,
|
||||
UpdateHelper.getCurrentVersion()));
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/* CraftInc BorderProtection
|
||||
Copyright (C) 2012 Paul Schulze
|
||||
/* Craft Inc. BorderProtection
|
||||
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
|
||||
@ -55,9 +55,16 @@ public class PlayerMoveListener implements Listener
|
||||
return (double) footBlock.getY();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerMove( PlayerMoveEvent e )
|
||||
{
|
||||
// do nothing if the event is already cancelled
|
||||
if (e.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// do nothing if player has the ignoreborders permission
|
||||
if ( e.getPlayer().hasPermission("craftinc.borderprotection.ignoreborders") )
|
||||
{
|
||||
@ -85,6 +92,7 @@ public class PlayerMoveListener implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
// do nothing if border is disabled
|
||||
if ( !border.isActive() )
|
||||
{
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* CraftInc BorderProtection
|
||||
Copyright (C) 2012 Paul Schulze
|
||||
/* Craft Inc. BorderProtection
|
||||
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,9 +32,16 @@ public class PlayerTeleportListener implements Listener
|
||||
this.borderManager = borderManager;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerMove( PlayerTeleportEvent e )
|
||||
{
|
||||
// do nothing if the event is already cancelled
|
||||
if (e.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// do nothing if player has the ignoreborders permission
|
||||
if ( e.getPlayer().hasPermission("craftinc.borderprotection.ignoreborders") )
|
||||
{
|
||||
@ -62,6 +69,7 @@ public class PlayerTeleportListener implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
// do nothing if border is disabled
|
||||
if ( !border.isActive() )
|
||||
{
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* CraftInc BorderProtection
|
||||
Copyright (C) 2012 Paul Schulze
|
||||
/* Craft Inc. BorderProtection
|
||||
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
|
||||
@ -46,16 +46,20 @@ public class Plugin extends JavaPlugin
|
||||
Plugin.cibpPlugin = this;
|
||||
|
||||
BorderManager borderManager = new BorderManager();
|
||||
|
||||
// create listeners
|
||||
PlayerMoveListener playerMoveListener = new PlayerMoveListener(borderManager);
|
||||
PlayerTeleportListener playerTeleportListener = new PlayerTeleportListener(borderManager);
|
||||
PlayerLoginListener playerLoginListener = new PlayerLoginListener();
|
||||
|
||||
// commands
|
||||
Commands commandExecutor = new Commands(borderManager);
|
||||
getCommand("cibp").setExecutor(commandExecutor);
|
||||
|
||||
// listeners
|
||||
// register listeners
|
||||
PluginManager pm = this.getServer().getPluginManager();
|
||||
pm.registerEvents(playerMoveListener, this);
|
||||
pm.registerEvents(playerTeleportListener, this);
|
||||
pm.registerEvents(playerLoginListener, this);
|
||||
}
|
||||
}
|
||||
|
98
src/main/java/de/craftinc/borderprotection/UpdateHelper.java
Normal file
98
src/main/java/de/craftinc/borderprotection/UpdateHelper.java
Normal file
@ -0,0 +1,98 @@
|
||||
/* 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;
|
||||
|
||||
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.getPlugin().getLogger().warning("Could not check for latest version. Update URL is malformed.");
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
Plugin.getPlugin().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.getPlugin().getDescription().getVersion();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a newer version is available.
|
||||
*
|
||||
* @return Boolean
|
||||
*/
|
||||
public static Boolean newVersionAvailable()
|
||||
{
|
||||
return !getCurrentVersion().equals(getLatestVersion());
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
# CraftInc BorderProtection
|
||||
# Copyright (C) 2012 Paul Schulze
|
||||
# Craft Inc. BorderProtection
|
||||
# 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,14 +16,15 @@
|
||||
|
||||
name: Craft Inc. BorderProtection
|
||||
main: de.craftinc.borderprotection.Plugin
|
||||
version: 1.0.0
|
||||
author: ddidderr
|
||||
version: ${project.version}
|
||||
softdepend: [Multiverse-Core]
|
||||
authors: [ddidderr, mice_on_drugs]
|
||||
website: http://www.craftinc.de/plugins/borderprotection
|
||||
|
||||
|
||||
commands:
|
||||
cibp:
|
||||
description: Shows help for CraftInc BorderProtection
|
||||
description: Shows help for Craft Inc. BorderProtection
|
||||
|
||||
permissions:
|
||||
craftinc.borderprotection.set:
|
||||
@ -32,3 +33,6 @@ permissions:
|
||||
craftinc.borderprotection.ignoreborders:
|
||||
default: op
|
||||
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.
|
Reference in New Issue
Block a user