mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 18:47:44 +01:00
location flags are now supported in FlagInfo class
This commit is contained in:
parent
40238a9d25
commit
dcd379bce7
@ -80,68 +80,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
FlagInfo nfo = FlagInfo.getFlagInfo(nameStr, subnameStr);
|
FlagInfo nfo = FlagInfo.getFlagInfo(nameStr, subnameStr);
|
||||||
|
|
||||||
if (nfo == null) {
|
if (nfo == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Unknown flag specified.");
|
||||||
if (!(sender instanceof Player)) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "Unknown flag, or not supported in console mode.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
if (nameStr.equals("spawn")) {
|
|
||||||
if (valueStr.equals("set")) {
|
|
||||||
Location l = player.getLocation();
|
|
||||||
if (region.contains(BukkitUtil.toVector(l))) {
|
|
||||||
AreaFlags flags = region.getFlags();
|
|
||||||
flags.setFlag("spawn", "x", l.getX());
|
|
||||||
flags.setFlag("spawn", "y", l.getY());
|
|
||||||
flags.setFlag("spawn", "z", l.getZ());
|
|
||||||
flags.setFlag("spawn", "yaw", l.getYaw());
|
|
||||||
flags.setFlag("spawn", "pitch", l.getPitch());
|
|
||||||
flags.setFlag("spawn", "world", l.getWorld().getName());
|
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn set to current location");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "You must set the teleport location inside the region it belongs to.");
|
|
||||||
}
|
|
||||||
} else if (valueStr.equals("delete")) {
|
|
||||||
AreaFlags flags = region.getFlags();
|
|
||||||
flags.setFlag("spawn", "x", (String) null);
|
|
||||||
flags.setFlag("spawn", "y", (String) null);
|
|
||||||
flags.setFlag("spawn", "z", (String) null);
|
|
||||||
flags.setFlag("spawn", "yaw", (String) null);
|
|
||||||
flags.setFlag("spawn", "pitch", (String) null);
|
|
||||||
flags.setFlag("spawn", "world", (String) null);
|
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn removed.");
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> spawn <set|delete>");
|
|
||||||
}
|
|
||||||
} else if (nameStr.equals("teleport")) {
|
|
||||||
if (valueStr.equals("set")) {
|
|
||||||
Location l = player.getLocation();
|
|
||||||
if (region.contains(BukkitUtil.toVector(l))) {
|
|
||||||
AreaFlags flags = region.getFlags();
|
|
||||||
flags.setFlag("teleport", "x", l.getX());
|
|
||||||
flags.setFlag("teleport", "y", l.getY());
|
|
||||||
flags.setFlag("teleport", "z", l.getZ());
|
|
||||||
flags.setFlag("teleport", "world", l.getWorld().getName());
|
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag teleport set to current location");
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "You must set the teleport location inside the region it belongs to.");
|
|
||||||
}
|
|
||||||
} else if (valueStr.equals("delete")) {
|
|
||||||
AreaFlags flags = region.getFlags();
|
|
||||||
flags.setFlag("teleport", "x", (String) null);
|
|
||||||
flags.setFlag("teleport", "y", (String) null);
|
|
||||||
flags.setFlag("teleport", "z", (String) null);
|
|
||||||
flags.setFlag("teleport", "world", (String) null);
|
|
||||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag teleport removed.");
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> teleport <set|delete>");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
player.sendMessage(ChatColor.RED + "Unknown flag specified.");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean validValue = false;
|
boolean validValue = false;
|
||||||
@ -201,6 +140,40 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case LOCATION: {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Flag not supported in console mode.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
Location l = player.getLocation();
|
||||||
|
|
||||||
|
if (valueStr.equals("set")) {
|
||||||
|
|
||||||
|
if (region.contains(BukkitUtil.toVector(l))) {
|
||||||
|
region.getFlags().setLocationFlag("spawn", l);
|
||||||
|
validValue = true;
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag " + nameStr + " set to current location");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + "You must set the " + nameStr + " location inside the region it belongs to.");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (valueStr.equals("delete")) {
|
||||||
|
region.getFlags().setLocationFlag("spawn", null);
|
||||||
|
validValue = true;
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag " + nameStr + " removed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (validValue) {
|
||||||
|
mgr.save();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
validValue = false;
|
validValue = false;
|
||||||
break;
|
break;
|
||||||
|
@ -6,13 +6,11 @@
|
|||||||
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
import com.sk89q.worldguard.bukkit.WorldGuardConfiguration;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.AreaFlags;
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,22 +39,14 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
|||||||
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
RegionManager mgr = cfg.getWorldGuardPlugin().getGlobalRegionManager().getRegionManager(player.getWorld().getName());
|
||||||
ProtectedRegion region = mgr.getRegion(id);
|
ProtectedRegion region = mgr.getRegion(id);
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
AreaFlags flags = region.getFlags();
|
Location location = null;
|
||||||
Double x, y, z;
|
|
||||||
World world;
|
|
||||||
if (spawn) {
|
if (spawn) {
|
||||||
x = flags.getDoubleFlag("spawn", "x");
|
location = region.getFlags().getLocationFlag(cfg.getWorldGuardPlugin().getServer(), "spawn");
|
||||||
y = flags.getDoubleFlag("spawn", "y");
|
|
||||||
z = flags.getDoubleFlag("spawn", "z");
|
|
||||||
world = cfg.getWorldGuardPlugin().getServer().getWorld(flags.getFlag("teleport", "world"));
|
|
||||||
} else {
|
} else {
|
||||||
x = flags.getDoubleFlag("teleport", "x");
|
location = region.getFlags().getLocationFlag(cfg.getWorldGuardPlugin().getServer(), "teleport");
|
||||||
y = flags.getDoubleFlag("teleport", "y");
|
|
||||||
z = flags.getDoubleFlag("teleport", "z");
|
|
||||||
world = cfg.getWorldGuardPlugin().getServer().getWorld(flags.getFlag("teleport", "world"));
|
|
||||||
}
|
}
|
||||||
if (x != null && y != null && z != null && world != null) {
|
if (location != null) {
|
||||||
Location location = new Location(world, x, y, z);
|
|
||||||
player.teleportTo(location);
|
player.teleportTo(location);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
public class FlagInfo {
|
public class FlagInfo {
|
||||||
|
|
||||||
public static enum FlagValueType { STRING, BOOLEAN, INT, FLOAT, DOUBLE, STATE };
|
public static enum FlagValueType { STRING, BOOLEAN, INT, FLOAT, DOUBLE, STATE, LOCATION };
|
||||||
|
|
||||||
public String name;
|
public String name;
|
||||||
public String subName;
|
public String subName;
|
||||||
@ -58,6 +58,8 @@ public static enum FlagValueType { STRING, BOOLEAN, INT, FLOAT, DOUBLE, STATE };
|
|||||||
flagList.add(new FlagInfo("waterflow", null, FlagValueType.STATE, "states", "waterflow"));
|
flagList.add(new FlagInfo("waterflow", null, FlagValueType.STATE, "states", "waterflow"));
|
||||||
flagList.add(new FlagInfo("iconomy", "buyable", FlagValueType.BOOLEAN, "iconomy", "buyable"));
|
flagList.add(new FlagInfo("iconomy", "buyable", FlagValueType.BOOLEAN, "iconomy", "buyable"));
|
||||||
flagList.add(new FlagInfo("iconomy", "price", FlagValueType.INT, "iconomy", "price"));
|
flagList.add(new FlagInfo("iconomy", "price", FlagValueType.INT, "iconomy", "price"));
|
||||||
|
flagList.add(new FlagInfo("spawn", "", FlagValueType.LOCATION, "spawn", ""));
|
||||||
|
flagList.add(new FlagInfo("teleport", "", FlagValueType.LOCATION, "teleport", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FlagInfo getFlagInfo(String name, String subName) {
|
public static FlagInfo getFlagInfo(String name, String subName) {
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
import com.sk89q.worldguard.protection.regions.AreaFlags.State;
|
import com.sk89q.worldguard.protection.regions.AreaFlags.State;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a set of regions and their rules as applied to one point.
|
* Represents a set of regions and their rules as applied to one point.
|
||||||
@ -328,6 +330,40 @@ public Double getDoubleAreaFlag(String name, String subname, double defaultValue
|
|||||||
return data != null ? Double.valueOf(data) : defaultValue;
|
return data != null ? Double.valueOf(data) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Location getLocationFlag(String name, Server server, Boolean inherit, LocalPlayer player) {
|
||||||
|
|
||||||
|
ProtectedRegion childRegion = getChildRegion();
|
||||||
|
if(childRegion == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != null && !childRegion.isMember(player)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!inherit)
|
||||||
|
{
|
||||||
|
return childRegion.getFlags().getLocationFlag(server, name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Location value;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
value = childRegion.getFlags().getLocationFlag(server, name);
|
||||||
|
childRegion = childRegion.getParent();
|
||||||
|
|
||||||
|
} while(value == null && childRegion != null);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear a region's parents for isFlagAllowed().
|
* Clear a region's parents for isFlagAllowed().
|
||||||
*
|
*
|
||||||
|
@ -16,12 +16,13 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldguard.protection.regions;
|
package com.sk89q.worldguard.protection.regions;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the flags for a region.
|
* Holds the flags for a region.
|
||||||
@ -29,12 +30,13 @@
|
|||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class AreaFlags {
|
public class AreaFlags {
|
||||||
|
|
||||||
public enum State {
|
public enum State {
|
||||||
|
|
||||||
NONE,
|
NONE,
|
||||||
ALLOW,
|
ALLOW,
|
||||||
DENY,
|
DENY,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final String FLAG_PASSTHROUGH = "z";
|
public static final String FLAG_PASSTHROUGH = "z";
|
||||||
public static final String FLAG_BUILD = "b";
|
public static final String FLAG_BUILD = "b";
|
||||||
public static final String FLAG_PVP = "p";
|
public static final String FLAG_PVP = "p";
|
||||||
@ -115,15 +117,11 @@ public static String fromAlias(String name) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Map<String, String>> flags = new HashMap<String, Map<String, String>>();
|
private Map<String, Map<String, String>> flags = new HashMap<String, Map<String, String>>();
|
||||||
|
|
||||||
|
private Map<String, String> getFlagData(String name) {
|
||||||
private Map<String, String> getFlagData(String name)
|
|
||||||
{
|
|
||||||
Map<String, String> ret = flags.get(name);
|
Map<String, String> ret = flags.get(name);
|
||||||
if(ret == null)
|
if (ret == null) {
|
||||||
{
|
|
||||||
ret = new HashMap<String, String>();
|
ret = new HashMap<String, String>();
|
||||||
flags.put(name, ret);
|
flags.put(name, ret);
|
||||||
}
|
}
|
||||||
@ -139,8 +137,7 @@ private Map<String, String> getFlagData(String name)
|
|||||||
*/
|
*/
|
||||||
public State get(String flag) {
|
public State get(String flag) {
|
||||||
String value = getFlagData("states").get(flag);
|
String value = getFlagData("states").get(flag);
|
||||||
if(value == null)
|
if (value == null) {
|
||||||
{
|
|
||||||
return State.NONE;
|
return State.NONE;
|
||||||
}
|
}
|
||||||
State state = State.valueOf(value);
|
State state = State.valueOf(value);
|
||||||
@ -168,8 +165,7 @@ public Set<Map.Entry<String, State>> entrySet() {
|
|||||||
|
|
||||||
Map<String, State> ret = new HashMap<String, State>();
|
Map<String, State> ret = new HashMap<String, State>();
|
||||||
|
|
||||||
for(Map.Entry<String, String> entry : getFlagData("states").entrySet())
|
for (Map.Entry<String, String> entry : getFlagData("states").entrySet()) {
|
||||||
{
|
|
||||||
ret.put(entry.getKey(), State.valueOf(entry.getValue()));
|
ret.put(entry.getKey(), State.valueOf(entry.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,9 +189,7 @@ public int hashCode() {
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFlag(String name, String subname, String value) {
|
||||||
public void setFlag(String name, String subname, String value)
|
|
||||||
{
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
getFlagData(name).remove(subname);
|
getFlagData(name).remove(subname);
|
||||||
} else {
|
} else {
|
||||||
@ -203,8 +197,7 @@ public void setFlag(String name, String subname, String value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlag(String name, String subname, Boolean value)
|
public void setFlag(String name, String subname, Boolean value) {
|
||||||
{
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
getFlagData(name).remove(subname);
|
getFlagData(name).remove(subname);
|
||||||
} else {
|
} else {
|
||||||
@ -212,8 +205,7 @@ public void setFlag(String name, String subname, Boolean value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlag(String name, String subname, Integer value)
|
public void setFlag(String name, String subname, Integer value) {
|
||||||
{
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
getFlagData(name).remove(subname);
|
getFlagData(name).remove(subname);
|
||||||
} else {
|
} else {
|
||||||
@ -221,8 +213,7 @@ public void setFlag(String name, String subname, Integer value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlag(String name, String subname, Float value)
|
public void setFlag(String name, String subname, Float value) {
|
||||||
{
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
getFlagData(name).remove(subname);
|
getFlagData(name).remove(subname);
|
||||||
} else {
|
} else {
|
||||||
@ -230,8 +221,7 @@ public void setFlag(String name, String subname, Float value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlag(String name, String subname, Double value)
|
public void setFlag(String name, String subname, Double value) {
|
||||||
{
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
getFlagData(name).remove(subname);
|
getFlagData(name).remove(subname);
|
||||||
} else {
|
} else {
|
||||||
@ -239,49 +229,41 @@ public void setFlag(String name, String subname, Double value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlag(String name, String subname)
|
public String getFlag(String name, String subname) {
|
||||||
{
|
|
||||||
return getFlagData(name).get(subname);
|
return getFlagData(name).get(subname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFlag(String name, String subname, String defaultValue)
|
public String getFlag(String name, String subname, String defaultValue) {
|
||||||
{
|
|
||||||
String data = getFlagData(name).get(subname);
|
String data = getFlagData(name).get(subname);
|
||||||
return data != null ? data : defaultValue;
|
return data != null ? data : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getBooleanFlag(String name, String subname)
|
public Boolean getBooleanFlag(String name, String subname) {
|
||||||
{
|
|
||||||
String data = getFlagData(name).get(subname);
|
String data = getFlagData(name).get(subname);
|
||||||
return data != null ? Boolean.valueOf(data) : null;
|
return data != null ? Boolean.valueOf(data) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getBooleanFlag(String name, String subname, boolean defaultValue)
|
public Boolean getBooleanFlag(String name, String subname, boolean defaultValue) {
|
||||||
{
|
|
||||||
String data = getFlagData(name).get(subname);
|
String data = getFlagData(name).get(subname);
|
||||||
return data != null ? Boolean.valueOf(data) : defaultValue;
|
return data != null ? Boolean.valueOf(data) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getIntFlag(String name, String subname)
|
public Integer getIntFlag(String name, String subname) {
|
||||||
{
|
|
||||||
String data = getFlagData(name).get(subname);
|
String data = getFlagData(name).get(subname);
|
||||||
return data != null ? Integer.valueOf(data) : null;
|
return data != null ? Integer.valueOf(data) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getIntFlag(String name, String subname, int defaultValue)
|
public Integer getIntFlag(String name, String subname, int defaultValue) {
|
||||||
{
|
|
||||||
String data = getFlagData(name).get(subname);
|
String data = getFlagData(name).get(subname);
|
||||||
return data != null ? Integer.valueOf(data) : defaultValue;
|
return data != null ? Integer.valueOf(data) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getFloatFlag(String name, String subname)
|
public Float getFloatFlag(String name, String subname) {
|
||||||
{
|
|
||||||
String data = getFlagData(name).get(subname);
|
String data = getFlagData(name).get(subname);
|
||||||
return data != null ? Float.valueOf(data) : null;
|
return data != null ? Float.valueOf(data) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getFloatFlag(String name, String subname, float defaultValue)
|
public Float getFloatFlag(String name, String subname, float defaultValue) {
|
||||||
{
|
|
||||||
String data = getFlagData(name).get(subname);
|
String data = getFlagData(name).get(subname);
|
||||||
return data != null ? Float.valueOf(data) : defaultValue;
|
return data != null ? Float.valueOf(data) : defaultValue;
|
||||||
}
|
}
|
||||||
@ -296,4 +278,37 @@ public Double getDoubleFlag(String name, String subname, double defaultValue) {
|
|||||||
return data != null ? Double.valueOf(data) : defaultValue;
|
return data != null ? Double.valueOf(data) : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getLocationFlag(Server server, String name) {
|
||||||
|
try {
|
||||||
|
Double x = Double.valueOf(getFlagData(name).get("x"));
|
||||||
|
Double y = Double.valueOf(getFlagData(name).get("y"));
|
||||||
|
Double z = Double.valueOf(getFlagData(name).get("z"));
|
||||||
|
Float yaw = Float.valueOf(getFlagData(name).get("yaw"));
|
||||||
|
Float pitch = Float.valueOf(getFlagData(name).get("pitch"));
|
||||||
|
String worldName = getFlagData(name).get("world");
|
||||||
|
|
||||||
|
Location l = new Location(server.getWorld(worldName), x, y, z, yaw, pitch);
|
||||||
|
return l;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocationFlag(String name, Location l) {
|
||||||
|
if (l != null) {
|
||||||
|
getFlagData(name).put("x", new Double(l.getX()).toString());
|
||||||
|
getFlagData(name).put("y", new Double(l.getY()).toString());
|
||||||
|
getFlagData(name).put("z", new Double(l.getZ()).toString());
|
||||||
|
getFlagData(name).put("yaw", new Float(l.getYaw()).toString());
|
||||||
|
getFlagData(name).put("pitch", new Float(l.getPitch()).toString());
|
||||||
|
getFlagData(name).put("world", l.getWorld().getName());
|
||||||
|
} else {
|
||||||
|
getFlagData(name).put("x", null);
|
||||||
|
getFlagData(name).put("y", null);
|
||||||
|
getFlagData(name).put("z", null);
|
||||||
|
getFlagData(name).put("yaw", null);
|
||||||
|
getFlagData(name).put("pitch", null);
|
||||||
|
getFlagData(name).put("world", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user