mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
permission groups recode
This commit is contained in:
parent
c91226266d
commit
6700e0bb3f
@ -7,5 +7,6 @@ import java.util.List;
|
|||||||
public enum RTP_SETUP_TYPE {
|
public enum RTP_SETUP_TYPE {
|
||||||
DEFAULT,
|
DEFAULT,
|
||||||
CUSTOM_WORLD,
|
CUSTOM_WORLD,
|
||||||
LOCATION
|
LOCATION,
|
||||||
|
PERMISSIONGROUP
|
||||||
}
|
}
|
||||||
|
@ -34,20 +34,18 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
|||||||
infoEffects(sendi);
|
infoEffects(sendi);
|
||||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.WORLD.name())) {
|
else if (args[1].equalsIgnoreCase(CmdInfoSub.WORLD.name())) {
|
||||||
if (args.length > 2 && Bukkit.getWorld(args[2]) != null) {
|
if (args.length > 2 && Bukkit.getWorld(args[2]) != null) {
|
||||||
sendInfoWorld(sendi, infoGetWorld(sendi, Bukkit.getWorld(args[2]), false));
|
sendInfoWorld(sendi, infoGetWorld(sendi, Bukkit.getWorld(args[2]), null));
|
||||||
} else if (sendi instanceof Player) { //Personalize with permission groups
|
} else if (sendi instanceof Player) { //Personalize with permission groups
|
||||||
World world = null;
|
World world = null;
|
||||||
boolean personal = false;
|
Player player = null;
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
Player player = Bukkit.getPlayer(args[2]);
|
player = Bukkit.getPlayer(args[2]);
|
||||||
if (player != null) {
|
if (player != null)
|
||||||
world = player.getWorld();
|
world = player.getWorld();
|
||||||
personal = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (world == null)
|
if (world == null)
|
||||||
world = ((Player) sendi).getWorld();
|
world = ((Player) sendi).getWorld();
|
||||||
sendInfoWorld(sendi, infoGetWorld(sendi, world, personal));
|
sendInfoWorld(sendi, infoGetWorld(sendi, world, player));
|
||||||
} else
|
} else
|
||||||
infoWorld(sendi);
|
infoWorld(sendi);
|
||||||
}
|
}
|
||||||
@ -108,26 +106,26 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
|||||||
private void infoWorld(CommandSender sendi) { //All worlds
|
private void infoWorld(CommandSender sendi) { //All worlds
|
||||||
List<String> info = new ArrayList<>();
|
List<String> info = new ArrayList<>();
|
||||||
for (World w : Bukkit.getWorlds())
|
for (World w : Bukkit.getWorlds())
|
||||||
info.addAll(infoGetWorld(sendi, w, false));
|
info.addAll(infoGetWorld(sendi, w, null));
|
||||||
sendInfoWorld(sendi, info);
|
sendInfoWorld(sendi, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> infoGetWorld(CommandSender sendi, World w, boolean personal) { //Specific world
|
private List<String> infoGetWorld(CommandSender sendi, World w, Player player) { //Specific world
|
||||||
List<String> info = new ArrayList<>();
|
List<String> info = new ArrayList<>();
|
||||||
BetterRTP pl = BetterRTP.getInstance();
|
BetterRTP pl = BetterRTP.getInstance();
|
||||||
String _true = "&aTrue", _false = "&bFalse";
|
String _true = "&aTrue", _false = "&bFalse";
|
||||||
info.add("&eWorld Name: &7" + w.getName() + (personal ? " &7(personalized)" : ""));
|
info.add("&bRTP info for &7" + w.getName() + (player != null ? " &d(personalized)" : ""));
|
||||||
if (personal)
|
info.add("&7- &eViewing as: &b" + (player != null ? player.getName() : "ADMIN"));
|
||||||
info.add("&7- &6Allowed: " + (pl.getPerms().getAWorld(sendi, w.getName()) ? _true : _false));
|
info.add("&7- &6Allowed: " + (player != null ? pl.getPerms().getAWorld(player, w.getName()) ? _true : _false : "&cN/A"));
|
||||||
if (pl.getRTP().getDisabledWorlds().contains(w.getName())) //World disabled
|
if (pl.getRTP().getDisabledWorlds().contains(w.getName())) //World disabled
|
||||||
info.add("&7- &6Disabled: " + _true);
|
info.add("&7- &eDisabled: " + _true);
|
||||||
else {
|
else {
|
||||||
info.add("&7- &6Disabled: " + _false);
|
info.add("&7- &eDisabled: " + _false);
|
||||||
if (pl.getRTP().overriden.containsKey(w.getName())) //World Overriden
|
if (pl.getRTP().overriden.containsKey(w.getName())) //World Overriden
|
||||||
info.add("&7- &6Overriden: " + _true + " &7- target `" + pl.getRTP().overriden.get(w.getName()) + "`");
|
info.add("&7- &6Overriden: " + _true + " &7- target `" + pl.getRTP().overriden.get(w.getName()) + "`");
|
||||||
else {
|
else {
|
||||||
info.add("&7- &6Overriden&7: " + _false);
|
info.add("&7- &6Overriden&7: " + _false);
|
||||||
WorldPlayer _rtpworld = BetterRTP.getInstance().getRTP().getPlayerWorld(new RTPSetupInformation(w.getName(), sendi, null, personal));
|
WorldPlayer _rtpworld = BetterRTP.getInstance().getRTP().getPlayerWorld(new RTPSetupInformation(w.getName(), player != null ? player : sendi, player, player != null));
|
||||||
WorldDefault worldDefault = BetterRTP.getInstance().getRTP().defaultWorld;
|
WorldDefault worldDefault = BetterRTP.getInstance().getRTP().defaultWorld;
|
||||||
info.add("&7- &eSetup Type&7: " + _rtpworld.setup_type.name() + getInfo(_rtpworld, worldDefault, "setup"));
|
info.add("&7- &eSetup Type&7: " + _rtpworld.setup_type.name() + getInfo(_rtpworld, worldDefault, "setup"));
|
||||||
info.add("&7- &6Use World Border&7: " + (_rtpworld.getUseWorldborder() ? _true : _false));
|
info.add("&7- &6Use World Border&7: " + (_rtpworld.getUseWorldborder() ? _true : _false));
|
||||||
@ -141,7 +139,7 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
|||||||
info.add("&7- &6Price&7: &f" + _rtpworld.getPrice() + getInfo(_rtpworld, worldDefault, "price"));
|
info.add("&7- &6Price&7: &f" + _rtpworld.getPrice() + getInfo(_rtpworld, worldDefault, "price"));
|
||||||
info.add("&7- &eBiomes&7: &f" + _rtpworld.getBiomes().toString());
|
info.add("&7- &eBiomes&7: &f" + _rtpworld.getBiomes().toString());
|
||||||
info.add("&7- &6Shape&7: &f" + _rtpworld.getShape().toString() + getInfo(_rtpworld, worldDefault, "shape"));
|
info.add("&7- &6Shape&7: &f" + _rtpworld.getShape().toString() + getInfo(_rtpworld, worldDefault, "shape"));
|
||||||
info.add("&7- &ePermission Group&7: " + (_rtpworld.getConfig() != null ? "&e" + _rtpworld.getConfig().getGroupName() : "&cN/A"));
|
info.add("&7- &ePermission Group&7: " + (_rtpworld.getConfig() != null ? "&a" + _rtpworld.getConfig().getGroupName() : "&cN/A"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
|
@ -89,8 +89,29 @@ public class RTP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pWorld.isSetup()) {
|
if (!pWorld.isSetup()) {
|
||||||
|
WorldPermissionGroup group = null;
|
||||||
|
if (pWorld.getPlayer() != null)
|
||||||
|
for (Map.Entry<String, PermissionGroup> permissionGroup : BetterRTP.getInstance().getRTP().worldPermissionGroups.entrySet()) {
|
||||||
|
for (Map.Entry<String, WorldPermissionGroup> worldPermission : permissionGroup.getValue().getWorlds().entrySet()) {
|
||||||
|
if (pWorld.getWorld().equals(worldPermission.getValue().getWorld())) {
|
||||||
|
if (BetterRTP.getInstance().getPerms().getPermissionGroup(pWorld.getPlayer(), permissionGroup.getKey())) {
|
||||||
|
if (group != null) {
|
||||||
|
if (group.getPriority() < worldPermission.getValue().getPriority())
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
group = worldPermission.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Permission Group
|
||||||
|
if (group != null) {
|
||||||
|
pWorld.setup(null, group, setup_info.getBiomes(), setup_info.isPersonalized());
|
||||||
|
pWorld.config = group;
|
||||||
|
}
|
||||||
//Custom World
|
//Custom World
|
||||||
if (customWorlds.containsKey(setup_info.getWorld())) {
|
else if (customWorlds.containsKey(setup_info.getWorld())) {
|
||||||
RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName());
|
RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName());
|
||||||
pWorld.setup(null, cWorld, setup_info.getBiomes(), setup_info.isPersonalized());
|
pWorld.setup(null, cWorld, setup_info.getBiomes(), setup_info.isPersonalized());
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package me.SuperRonanCraft.BetterRTP.player.rtp;
|
|||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.PermissionGroup;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.*;
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -115,7 +116,7 @@ public class RTPLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadPermissionGroups(@NotNull HashMap<String, RTPWorld> permissionGroup) {
|
static void loadPermissionGroups(@NotNull HashMap<String, PermissionGroup> permissionGroup) {
|
||||||
permissionGroup.clear();
|
permissionGroup.clear();
|
||||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||||
if (!config.getBoolean("PermissionGroup.Enabled"))
|
if (!config.getBoolean("PermissionGroup.Enabled"))
|
||||||
@ -126,10 +127,10 @@ public class RTPLoader {
|
|||||||
for (Map<?, ?> m : map)
|
for (Map<?, ?> m : map)
|
||||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
String group = entry.getKey().toString();
|
String group = entry.getKey().toString();
|
||||||
permissionGroup.put(group, new WorldPermissionGroup(group));
|
permissionGroup.put(group, new PermissionGroup(entry));
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//No Custom Worlds
|
//No Permission Groups
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,45 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.references.rtpinfo;
|
package me.SuperRonanCraft.BetterRTP.references.rtpinfo;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPermissionGroup;
|
import me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds.WorldPermissionGroup;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class PermissionGroup {
|
public class PermissionGroup {
|
||||||
|
|
||||||
String groupName;
|
String groupName;
|
||||||
HashMap<String, WorldPermissionGroup> worlds = new HashMap<>();
|
@Getter private HashMap<String, WorldPermissionGroup> worlds = new HashMap<>();
|
||||||
|
|
||||||
public PermissionGroup(String group) {
|
@SuppressWarnings("rawtypes")
|
||||||
|
public PermissionGroup(Map.Entry<?, ?> fields) {
|
||||||
|
this.groupName = fields.getKey().toString();
|
||||||
|
|
||||||
|
BetterRTP.debug("- Permission Group: " + groupName);
|
||||||
|
//Find Location and cache its values
|
||||||
|
Object value = fields.getValue();
|
||||||
|
for (Object worldList : ((ArrayList) value)) {
|
||||||
|
for (Object hash : ((HashMap) worldList).entrySet()) {
|
||||||
|
Map.Entry world = (Map.Entry) hash;
|
||||||
|
BetterRTP.debug("- -- World: " + world.getKey());
|
||||||
|
WorldPermissionGroup permissionGroup = new WorldPermissionGroup(groupName, world.getKey().toString(), world);
|
||||||
|
boolean loaded = false;
|
||||||
|
for (World realWorld : Bukkit.getWorlds()) {
|
||||||
|
if (realWorld.getName().equals(permissionGroup.world)) {
|
||||||
|
this.worlds.put(world.getKey().toString(), permissionGroup);
|
||||||
|
loaded = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!loaded) {
|
||||||
|
BetterRTP.debug("- - The Permission groups '" + groupName + "'s world '" + world.getKey() + "' does not exist! World info not loaded...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,69 +17,61 @@ public class WorldPermissionGroup implements RTPWorld, RTPWorld_Defaulted {
|
|||||||
private boolean useWorldborder;
|
private boolean useWorldborder;
|
||||||
private int centerX, centerZ, maxRad, minRad, price, miny, maxy;
|
private int centerX, centerZ, maxRad, minRad, price, miny, maxy;
|
||||||
private List<String> biomes;
|
private List<String> biomes;
|
||||||
private String world;
|
public String world;
|
||||||
private RTP_SHAPE shape;
|
private RTP_SHAPE shape;
|
||||||
@Getter private int priority;
|
@Getter private int priority;
|
||||||
|
@Getter private String groupName;
|
||||||
|
|
||||||
/*public RTPPermConfiguration getGroup(CommandSender p) {
|
public WorldPermissionGroup(String group, String world, Map.Entry fields) {
|
||||||
for (RTPPermConfiguration group : groups)
|
this.groupName = group;
|
||||||
if (BetterRTP.getInstance().getPerms().getPermissionGroup(p, group.name))
|
this.world = world;
|
||||||
return group;
|
|
||||||
return null;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public WorldPermissionGroup(String group) {
|
|
||||||
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.LOCATIONS);
|
|
||||||
List<Map<?, ?>> map = config.getMapList("PermissionGroup.Groups");
|
|
||||||
|
|
||||||
setupDefaults();
|
setupDefaults();
|
||||||
|
|
||||||
this.priority = 0;
|
this.priority = 0;
|
||||||
//Find Location and cache its values
|
//Find Location and cache its values
|
||||||
for (Map<?, ?> m : map) {
|
for (Object hash2 : ((HashMap) fields.getValue()).entrySet()) {
|
||||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
Map.Entry hash3 = (Map.Entry) hash2;
|
||||||
String key = entry.getKey().toString();
|
String field = hash3.getKey().toString();
|
||||||
if (!key.equals(group))
|
if (field.equalsIgnoreCase("Priority")) {
|
||||||
continue;
|
if (hash3.getValue().getClass() == Integer.class) {
|
||||||
Map<?, ?> test = ((Map<?, ?>) m.get(key));
|
priority = Integer.parseInt((hash3.getValue()).toString());
|
||||||
if (test == null)
|
BetterRTP.debug("- - Priority: " + priority);
|
||||||
continue;
|
|
||||||
if (test.get("Priority") != null) {
|
|
||||||
if (test.get("Priority").getClass() == Integer.class)
|
|
||||||
priority = Integer.parseInt((test.get("Priority")).toString());
|
|
||||||
}
|
|
||||||
if (test.get("World") != null) {
|
|
||||||
if (test.get("World").getClass() == String.class)
|
|
||||||
world = test.get("World").toString();
|
|
||||||
} else {
|
|
||||||
BetterRTP.getInstance().getLogger().warning("Group `" + group + "` does NOT have a World specified!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (test.get("UseWorldBorder") != null) {
|
|
||||||
if (test.get("UseWorldBorder").getClass() == Boolean.class)
|
|
||||||
useWorldborder = Boolean.parseBoolean(test.get("UseWorldBorder").toString());
|
|
||||||
}
|
|
||||||
if (test.get("CenterX") != null) {
|
|
||||||
if (test.get("CenterX").getClass() == Integer.class)
|
|
||||||
centerX = Integer.parseInt((test.get("CenterX")).toString());
|
|
||||||
}
|
|
||||||
if (test.get("CenterZ") != null) {
|
|
||||||
if (test.get("CenterZ").getClass() == Integer.class) {
|
|
||||||
centerZ = Integer.parseInt((test.get("CenterZ")).toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (test.get("MaxRadius") != null) {
|
if (field.equalsIgnoreCase("UseWorldBorder")) {
|
||||||
if (test.get("MaxRadius").getClass() == Integer.class)
|
if (hash3.getValue().getClass() == Boolean.class) {
|
||||||
maxRad = Integer.parseInt((test.get("MaxRadius")).toString());
|
useWorldborder = Boolean.parseBoolean(hash3.getValue().toString());
|
||||||
|
BetterRTP.debug("- - UseWorldBorder: " + useWorldborder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (field.equalsIgnoreCase("CenterX")) {
|
||||||
|
if (hash3.getValue().getClass() == Integer.class) {
|
||||||
|
centerX = Integer.parseInt((hash3.getValue()).toString());
|
||||||
|
BetterRTP.debug("- - CenterX: " + centerX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (field.equalsIgnoreCase("CenterZ")) {
|
||||||
|
if (hash3.getValue().getClass() == Integer.class) {
|
||||||
|
centerZ = Integer.parseInt((hash3.getValue()).toString());
|
||||||
|
BetterRTP.debug("- - CenterZ: " + centerZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (field.equalsIgnoreCase("MaxRadius")) {
|
||||||
|
if (hash3.getValue().getClass() == Integer.class) {
|
||||||
|
maxRad = Integer.parseInt((hash3.getValue()).toString());
|
||||||
|
BetterRTP.debug("- - MaxRadius: " + maxRad);
|
||||||
|
}
|
||||||
if (maxRad <= 0) {
|
if (maxRad <= 0) {
|
||||||
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||||
"WARNING! Group '" + group + "' Maximum radius of '" + maxRad + "' is not allowed! Set to default value!");
|
"WARNING! Group '" + group + "' Maximum radius of '" + maxRad + "' is not allowed! Set to default value!");
|
||||||
maxRad = BetterRTP.getInstance().getRTP().defaultWorld.getMaxRadius();
|
maxRad = BetterRTP.getInstance().getRTP().defaultWorld.getMaxRadius();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (test.get("MinRadius") != null) {
|
if (field.equalsIgnoreCase("MinRadius")) {
|
||||||
if (test.get("MinRadius").getClass() == Integer.class)
|
if (hash3.getValue().getClass() == Integer.class) {
|
||||||
minRad = Integer.parseInt((test.get("MinRadius")).toString());
|
minRad = Integer.parseInt((hash3.getValue()).toString());
|
||||||
|
BetterRTP.debug("- - MinRadius: " + minRad);
|
||||||
|
}
|
||||||
if (minRad < 0 || minRad >= maxRad) {
|
if (minRad < 0 || minRad >= maxRad) {
|
||||||
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||||
"WARNING! Group '" + group + "' Minimum radius of '" + minRad + "' is not allowed! Set to default value!");
|
"WARNING! Group '" + group + "' Minimum radius of '" + minRad + "' is not allowed! Set to default value!");
|
||||||
@ -88,42 +80,41 @@ public class WorldPermissionGroup implements RTPWorld, RTPWorld_Defaulted {
|
|||||||
maxRad = BetterRTP.getInstance().getRTP().defaultWorld.getMaxRadius();
|
maxRad = BetterRTP.getInstance().getRTP().defaultWorld.getMaxRadius();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (test.get("Biomes") != null) {
|
if (field.equalsIgnoreCase("Biomes")) {
|
||||||
if (test.get("Biomes").getClass() == ArrayList.class)
|
if (hash3.getValue().getClass() == ArrayList.class) {
|
||||||
this.biomes = new ArrayList<String>((ArrayList) test.get("Biomes"));
|
this.biomes = new ArrayList<String>((ArrayList) hash3.getValue());
|
||||||
|
BetterRTP.debug("- - Biomes: " + biomes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||||
if (test.get("Price") != null) {
|
if (field.equalsIgnoreCase("Price")) {
|
||||||
if (test.get("Price").getClass() == Integer.class)
|
if (hash3.getValue().getClass() == Integer.class) {
|
||||||
this.price = Integer.parseInt(test.get("Price").toString());
|
this.price = Integer.parseInt(hash3.getValue().toString());
|
||||||
|
BetterRTP.debug("- - Price: " + price);
|
||||||
|
}
|
||||||
//else
|
//else
|
||||||
// price = worldDefault.getPrice(world);
|
// price = worldDefault.getPrice(world);
|
||||||
} //else
|
} //else
|
||||||
//price = worldDefault.getPrice(world);
|
//price = worldDefault.getPrice(world);
|
||||||
if (test.get("Shape") != null) {
|
if (field.equalsIgnoreCase("Shape")) {
|
||||||
if (test.get("Shape").getClass() == String.class) {
|
if (hash3.getValue().getClass() == String.class) {
|
||||||
try {
|
try {
|
||||||
this.shape = RTP_SHAPE.valueOf(test.get("Shape").toString().toUpperCase());
|
this.shape = RTP_SHAPE.valueOf(hash3.getValue().toString().toUpperCase());
|
||||||
|
BetterRTP.debug("- - Shape: " + shape.name());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//Invalid shape
|
//Invalid shape
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (test.get("UseWorldBorder") != null) {
|
if (field.equalsIgnoreCase("MinY"))
|
||||||
if (test.get("UseWorldBorder").getClass() == Boolean.class) {
|
if (hash3.getValue().getClass() == Integer.class) {
|
||||||
try {
|
this.miny = Integer.parseInt(hash3.getValue().toString());
|
||||||
this.useWorldborder = Boolean.parseBoolean(test.get("UseWorldBorder").toString());
|
BetterRTP.debug("- - MinY: " + miny);
|
||||||
} catch (Exception e) {
|
|
||||||
//No UseWorldBorder
|
|
||||||
}
|
}
|
||||||
}
|
if (field.equalsIgnoreCase("MaxY"))
|
||||||
}
|
if (hash3.getValue().getClass() == Integer.class) {
|
||||||
if (test.get("MinY") != null)
|
this.maxy = Integer.parseInt(hash3.getValue().toString());
|
||||||
if (test.get("MinY").getClass() == Integer.class)
|
BetterRTP.debug("- - MaxY: " + maxy);
|
||||||
this.miny = Integer.parseInt(test.get("MinY").toString());
|
|
||||||
if (test.get("MaxY") != null)
|
|
||||||
if (test.get("MaxY").getClass() == Integer.class)
|
|
||||||
this.maxy = Integer.parseInt(test.get("MaxY").toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
|
|||||||
@Getter private final Player player;
|
@Getter private final Player player;
|
||||||
private final World world;
|
private final World world;
|
||||||
private WORLD_TYPE world_type;
|
private WORLD_TYPE world_type;
|
||||||
private WorldPermissionGroup config = null;
|
public WorldPermissionGroup config = null;
|
||||||
private RTP_SHAPE shape;
|
private RTP_SHAPE shape;
|
||||||
public RTP_SETUP_TYPE setup_type = RTP_SETUP_TYPE.DEFAULT;
|
public RTP_SETUP_TYPE setup_type = RTP_SETUP_TYPE.DEFAULT;
|
||||||
public String setup_name;
|
public String setup_name;
|
||||||
@ -38,8 +38,10 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
|
|||||||
public void setup(String setup_name, RTPWorld world, List<String> biomes, boolean personal) {
|
public void setup(String setup_name, RTPWorld world, List<String> biomes, boolean personal) {
|
||||||
if (world instanceof WorldLocations) {
|
if (world instanceof WorldLocations) {
|
||||||
setup_type = RTP_SETUP_TYPE.LOCATION;
|
setup_type = RTP_SETUP_TYPE.LOCATION;
|
||||||
} else if (world instanceof WorldCustom)
|
} else if (world instanceof WorldCustom) {
|
||||||
setup_type = RTP_SETUP_TYPE.CUSTOM_WORLD;
|
setup_type = RTP_SETUP_TYPE.CUSTOM_WORLD;
|
||||||
|
} else if (world instanceof WorldPermissionGroup)
|
||||||
|
setup_type = RTP_SETUP_TYPE.PERMISSIONGROUP;
|
||||||
this.setup_name = setup_name;
|
this.setup_name = setup_name;
|
||||||
setUseWorldBorder(world.getUseWorldborder());
|
setUseWorldBorder(world.getUseWorldborder());
|
||||||
setCenterX(world.getCenterX());
|
setCenterX(world.getCenterX());
|
||||||
@ -57,8 +59,8 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
|
|||||||
list.addAll(biomes);
|
list.addAll(biomes);
|
||||||
}
|
}
|
||||||
setBiomes(list);
|
setBiomes(list);
|
||||||
if (personal)
|
//if (personal && player != null)
|
||||||
setupGroup();
|
// setupGroup();
|
||||||
//Make sure our borders will not cause an invalid integer
|
//Make sure our borders will not cause an invalid integer
|
||||||
if (getMaxRadius() <= getMinRadius()) {
|
if (getMaxRadius() <= getMinRadius()) {
|
||||||
setMinRadius(BetterRTP.getInstance().getRTP().defaultWorld.getMinRadius());
|
setMinRadius(BetterRTP.getInstance().getRTP().defaultWorld.getMinRadius());
|
||||||
@ -81,18 +83,6 @@ public class WorldPlayer implements RTPWorld, RTPWorld_Defaulted {
|
|||||||
setup = true;
|
setup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupGroup() {
|
|
||||||
for (Map.Entry<String, PermissionGroup> group : BetterRTP.getInstance().getRTP().worldPermissionGroups.entrySet())
|
|
||||||
if (BetterRTP.getInstance().getPerms().getPermissionGroup(player, group.getKey()))
|
|
||||||
if (getWorld().getName().equals(group.getValue().getWorld().getName())) {
|
|
||||||
if (this.config != null)
|
|
||||||
if (this.config.getPriority() < ((WorldPermissionGroup) group).getPriority())
|
|
||||||
continue;
|
|
||||||
this.config = (WorldPermissionGroup) group.getValue();
|
|
||||||
setAllFrom(this.config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkIsValid(Location loc) { //Will check if a previously given location is valid
|
public boolean checkIsValid(Location loc) { //Will check if a previously given location is valid
|
||||||
if (loc.getWorld() != getWorld())
|
if (loc.getWorld() != getWorld())
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user