Faction admins can now mark already claimed areas as owned by specific faction members. Ownership can include multiple members. New command /f owner *[player name], to set/remove ownership. This command is only available to the faction admin and optionally the faction moderators. If no player name is specified, it will either set ownership to the player running the command (if no owner is currently set) or completely clear ownership of the territory. New command /f ownerlist, to view a list of owners for the current area. Only works inside your own faction's territory. New conf.json options "ownedAreasEnabled", "ownedAreasModeratorsCanSet", "ownedAreaModeratorsBypass", "ownedAreaDenyBuild", "ownedAreaProtectMaterials", and "ownedAreaDenyUseage" (all defaulting to true) to determine whether faction moderators can set or bypass ownership (faction admin always can), and what sort of protection these owned areas have against normal members of the faction (members other than the owner(s), faction admin, and probably faction moderators). New conf.json option "ownedAreasLimitPerFaction" to limit how many owned areas can be set. New permission node "factions.ownershipBypass" which allows a player to bypass ownership protection, but only within the person's own faction.
various little tweaks and improvements to other code
moderate speed boost to FLocation code
made commandDisable permissions work for any command alias of a command, instead of just the first one
2011-07-31 03:17:00 +02:00
|
|
|
package com.massivecraft.factions.util;
|
2011-03-23 17:39:56 +01:00
|
|
|
|
|
|
|
import java.lang.reflect.Type;
|
2011-04-04 19:26:48 +02:00
|
|
|
import java.util.logging.Level;
|
2011-03-23 17:39:56 +01:00
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.World;
|
2011-07-18 22:06:02 +02:00
|
|
|
|
2011-07-27 22:56:45 +02:00
|
|
|
import com.google.gson.JsonDeserializationContext;
|
|
|
|
import com.google.gson.JsonDeserializer;
|
|
|
|
import com.google.gson.JsonElement;
|
|
|
|
import com.google.gson.JsonObject;
|
|
|
|
import com.google.gson.JsonParseException;
|
|
|
|
import com.google.gson.JsonSerializationContext;
|
|
|
|
import com.google.gson.JsonSerializer;
|
2011-10-08 22:03:44 +02:00
|
|
|
import com.massivecraft.factions.P;
|
2011-03-23 17:39:56 +01:00
|
|
|
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public class MyLocationTypeAdapter implements JsonDeserializer<Location>, JsonSerializer<Location>
|
|
|
|
{
|
2011-03-23 17:39:56 +01:00
|
|
|
private static final String WORLD = "world";
|
|
|
|
private static final String X = "x";
|
|
|
|
private static final String Y = "y";
|
|
|
|
private static final String Z = "z";
|
|
|
|
private static final String YAW = "yaw";
|
|
|
|
private static final String PITCH = "pitch";
|
|
|
|
|
|
|
|
@Override
|
2011-10-08 22:03:44 +02:00
|
|
|
public Location deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2011-04-04 19:26:48 +02:00
|
|
|
JsonObject obj = json.getAsJsonObject();
|
2011-04-04 14:16:53 +02:00
|
|
|
|
2011-04-06 11:08:08 +02:00
|
|
|
String worldname = obj.get(WORLD).getAsString();
|
2011-10-08 22:03:44 +02:00
|
|
|
World world = P.p.getServer().getWorld(worldname);
|
2011-04-06 11:08:08 +02:00
|
|
|
if (world == null) {
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log(Level.WARNING, "Stored location's world \"" + worldname + "\" not found on server; dropping the location.");
|
2011-04-06 11:08:08 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2011-04-04 19:26:48 +02:00
|
|
|
double x = obj.get(X).getAsDouble();
|
|
|
|
double y = obj.get(Y).getAsDouble();
|
|
|
|
double z = obj.get(Z).getAsDouble();
|
|
|
|
float yaw = obj.get(YAW).getAsFloat();
|
|
|
|
float pitch = obj.get(PITCH).getAsFloat();
|
|
|
|
|
|
|
|
return new Location(world, x, y, z, yaw, pitch);
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2011-04-06 11:08:08 +02:00
|
|
|
ex.printStackTrace();
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log(Level.WARNING, "Error encountered while deserializing a location.");
|
2011-04-04 14:16:53 +02:00
|
|
|
return null;
|
2011-04-04 19:26:48 +02:00
|
|
|
}
|
2011-03-23 17:39:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public JsonElement serialize(Location src, Type typeOfSrc, JsonSerializationContext context) {
|
|
|
|
JsonObject obj = new JsonObject();
|
2011-03-28 21:38:07 +02:00
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
try
|
|
|
|
{
|
2011-04-06 11:08:08 +02:00
|
|
|
if (src.getWorld() == null)
|
2011-04-04 19:26:48 +02:00
|
|
|
{
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log(Level.WARNING, "Passed location's world was not found on the server. Dropping the location.");
|
2011-04-04 19:26:48 +02:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj.addProperty(WORLD, src.getWorld().getName());
|
|
|
|
obj.addProperty(X, src.getX());
|
|
|
|
obj.addProperty(Y, src.getY());
|
|
|
|
obj.addProperty(Z, src.getZ());
|
|
|
|
obj.addProperty(YAW, src.getYaw());
|
|
|
|
obj.addProperty(PITCH, src.getPitch());
|
|
|
|
|
2011-03-28 21:38:07 +02:00
|
|
|
return obj;
|
2011-04-04 19:26:48 +02:00
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2011-04-06 11:08:08 +02:00
|
|
|
ex.printStackTrace();
|
2011-10-08 22:03:44 +02:00
|
|
|
P.p.log(Level.WARNING, "Error encountered while serializing a location.");
|
2011-03-28 21:38:07 +02:00
|
|
|
return obj;
|
|
|
|
}
|
2011-03-23 17:39:56 +01:00
|
|
|
}
|
|
|
|
}
|