Version 1.0.2

License information updated in all files.
version number in plugin.yml now comes from maven.
This commit is contained in:
Paul Schulze
2013-02-16 17:59:05 +01:00
parent df37830bef
commit 5bc660d392
15 changed files with 939 additions and 707 deletions

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;
@ -10,75 +26,78 @@ import java.util.Map;
/**
* NOTE: We do not care about yaw and pitch for gate locations. So we won't serialize them.
*/
public class LocationSerializer
public class LocationSerializer
{
protected static String worldKey = "world";
protected static String xKey = "x";
protected static String yKey = "y";
protected static String zKey = "z";
protected static String worldKey = "world";
protected static String xKey = "x";
protected static String yKey = "y";
protected static String zKey = "z";
protected static World getWorld(String name) throws Exception
{
World world = Plugin.getPlugin().getServer().getWorld(name);
if (world == null) {
throw new Exception("World '" + name + "' does not exists anymore! Cannot get instance!");
}
return world;
}
public static Map<String, Object> serializeLocation(Location l)
{
if (l == null) {
return null;
}
Map<String, Object> serializedLocation = new HashMap<String, Object>();
serializedLocation.put(worldKey, l.getWorld().getName());
serializedLocation.put(xKey, l.getX());
serializedLocation.put(yKey, l.getY());
serializedLocation.put(zKey, l.getZ());
return serializedLocation;
}
protected static World getWorld( String name ) throws Exception
{
World world = Plugin.getPlugin().getServer().getWorld(name);
public static Location deserializeLocation(Map<String, Object> map) throws Exception
{
if (map == null) {
return null;
}
World w = getWorld((String)map.get(worldKey));
// verbose loading of coordinates (they might be Double or Integer)
Object objX = map.get(xKey);
Object objY = map.get(yKey);
Object objZ = map.get(zKey);
double x,y,z;
if (objX instanceof Integer)
x = (double)(Integer)objX;
else
x = (Double)objX;
if (objY instanceof Integer)
y = (double)(Integer)objY;
else
y = (Double)objY;
if (objZ instanceof Integer)
z = (double)(Integer)objZ;
else
z = (Double)objZ;
return new Location(w, x, y, z);
}
if ( world == null )
{
throw new Exception("World '" + name + "' does not exists anymore! Cannot get instance!");
}
return world;
}
public static Map<String, Object> serializeLocation( Location l )
{
if ( l == null )
{
return null;
}
Map<String, Object> serializedLocation = new HashMap<String, Object>();
serializedLocation.put(worldKey, l.getWorld().getName());
serializedLocation.put(xKey, l.getX());
serializedLocation.put(yKey, l.getY());
serializedLocation.put(zKey, l.getZ());
return serializedLocation;
}
public static Location deserializeLocation( Map<String, Object> map ) throws Exception
{
if ( map == null )
{
return null;
}
World w = getWorld((String) map.get(worldKey));
// verbose loading of coordinates (they might be Double or Integer)
Object objX = map.get(xKey);
Object objY = map.get(yKey);
Object objZ = map.get(zKey);
double x, y, z;
if ( objX instanceof Integer )
x = (double) (Integer) objX;
else
x = (Double) objX;
if ( objY instanceof Integer )
y = (double) (Integer) objY;
else
y = (Double) objY;
if ( objZ instanceof Integer )
z = (double) (Integer) objZ;
else
z = (Double) objZ;
return new Location(w, x, y, z);
}
}

View File

@ -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
@ -68,7 +68,8 @@ public class Messages
public static String helpGeneral =
ChatColor.GREEN + "CraftInc BorderProtection - 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>");

View File

@ -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,6 +55,7 @@ public class PlayerMoveListener implements Listener
return (double) footBlock.getY();
}
@SuppressWarnings("unused")
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerMove( PlayerMoveEvent e )
{
@ -85,6 +86,7 @@ public class PlayerMoveListener implements Listener
return;
}
// do nothing if border is disabled
if ( !border.isActive() )
{
return;

View File

@ -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,6 +32,7 @@ public class PlayerTeleportListener implements Listener
this.borderManager = borderManager;
}
@SuppressWarnings("unused")
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerMove( PlayerTeleportEvent e )
{
@ -62,6 +63,7 @@ public class PlayerTeleportListener implements Listener
return;
}
// do nothing if border is disabled
if ( !border.isActive() )
{
return;

View File

@ -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

View File

@ -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,14 @@
name: Craft Inc. BorderProtection
main: de.craftinc.borderprotection.Plugin
version: 1.0.0
author: ddidderr
version: ${project.version}
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: