mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 09:05:47 +00:00
Permission Groups added + '/rtp info world <player>' personalizes info page
This commit is contained in:
parent
c8a00751fa
commit
c5d7705d54
@ -157,12 +157,12 @@ public class Commands {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
//Reset timer, but allow them to tp
|
//Reset timer, but allow them to tp
|
||||||
cooldowns.add(id);
|
//cooldowns.add(id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} //else
|
||||||
cooldowns.add(id);
|
//cooldowns.add(id);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import me.SuperRonanCraft.BetterRTP.player.rtp.RTPParticles;
|
|||||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.worlds.RTPWorld;
|
import me.SuperRonanCraft.BetterRTP.references.worlds.RTPWorld;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.worlds.WORLD_TYPE;
|
import me.SuperRonanCraft.BetterRTP.references.worlds.WORLD_TYPE;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.worlds.WorldPlayer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldBorder;
|
import org.bukkit.WorldBorder;
|
||||||
@ -27,8 +28,19 @@ public class CmdInfo implements RTPCommand {
|
|||||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.POTION_EFFECTS.name()))
|
else if (args[1].equalsIgnoreCase(CmdInfoSub.POTION_EFFECTS.name()))
|
||||||
infoEffects(sendi);
|
infoEffects(sendi);
|
||||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.WORLD.name())) {
|
else if (args[1].equalsIgnoreCase(CmdInfoSub.WORLD.name())) {
|
||||||
if (sendi instanceof Player) {
|
if (sendi instanceof Player) { //Personalize with permission groups
|
||||||
sendInfoWorld(sendi, infoGetWorld(((Player) sendi).getWorld()));
|
World world = null;
|
||||||
|
boolean personal = false;
|
||||||
|
if (args.length > 2) {
|
||||||
|
Player player = Bukkit.getPlayer(args[2]);
|
||||||
|
if (player != null) {
|
||||||
|
world = player.getWorld();
|
||||||
|
personal = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (world == null)
|
||||||
|
world = ((Player) sendi).getWorld();
|
||||||
|
sendInfoWorld(sendi, infoGetWorld(sendi, world, personal));
|
||||||
} else
|
} else
|
||||||
infoWorld(sendi);
|
infoWorld(sendi);
|
||||||
}
|
}
|
||||||
@ -88,47 +100,34 @@ public class CmdInfo implements RTPCommand {
|
|||||||
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(w));
|
info.addAll(infoGetWorld(sendi, w, false));
|
||||||
sendInfoWorld(sendi, info);
|
sendInfoWorld(sendi, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> infoGetWorld(World w) { //Specific world
|
private List<String> infoGetWorld(CommandSender sendi, World w, boolean personal) { //Specific world
|
||||||
List<String> info = new ArrayList<>();
|
List<String> info = new ArrayList<>();
|
||||||
Main pl = Main.getInstance();
|
Main pl = Main.getInstance();
|
||||||
info.add("&aWorld: &7" + w.getName());
|
String _true = "&aTrue", _false = "&bFalse";
|
||||||
|
info.add("&eWorld: &7" + w.getName() + (personal ? " &7(personalized)" : ""));
|
||||||
|
if (personal)
|
||||||
|
info.add("&7- &6Allowed: " + (pl.getPerms().getAWorld(sendi, w.getName()) ? _true : _false));
|
||||||
if (pl.getRTP().getDisabledWorlds().contains(w.getName())) //DISABLED
|
if (pl.getRTP().getDisabledWorlds().contains(w.getName())) //DISABLED
|
||||||
info.add("&7- &6Disabled: &bTrue");
|
info.add("&7- &6Disabled: " + _true);
|
||||||
else {
|
else {
|
||||||
info.add("&7- &6Disabled: &cFalse");
|
info.add("&7- &6Disabled: " + _false);
|
||||||
if (pl.getRTP().overriden.containsKey(w.getName()))
|
if (pl.getRTP().overriden.containsKey(w.getName()))
|
||||||
info.add("&7- &6Overriden: &bTrue");
|
info.add("&7- &6Overriden: " + _true);
|
||||||
else {
|
else {
|
||||||
info.add("&7- &6WorldType: &f" + pl.getRTP().world_type.getOrDefault(w.getName(), WORLD_TYPE.NORMAL).name());
|
info.add("&7- &6WorldType: &f" + pl.getRTP().world_type.getOrDefault(w.getName(), WORLD_TYPE.NORMAL).name());
|
||||||
info.add("&7- &6Overriden: &cFalse");
|
info.add("&7- &6Overriden: " + _false);
|
||||||
RTPWorld _rtpworld = pl.getRTP().defaultWorld;
|
WorldPlayer _rtpworld = Main.getInstance().getRTP().getPlayerWorld(sendi, w.getName(), null, personal);
|
||||||
for (RTPWorld __rtpworld : pl.getRTP().customWorlds.values()) {
|
info.add("&7- &6Custom: " + (Main.getInstance().getRTP().customWorlds.containsKey(w.getName()) ? _true : _false));
|
||||||
if (__rtpworld.getWorld() != null && __rtpworld.getWorld().getName().equals(w.getName())) {
|
info.add("&7- &6UseWorldBorder: " + (_rtpworld.getUseWorldborder() ? _true : _false));
|
||||||
_rtpworld = __rtpworld;
|
info.add("&7- &6Permission Group: " + (_rtpworld.getConfig() != null ? "&e" + _rtpworld.getConfig().name : "&cN/A"));
|
||||||
break;
|
info.add("&7- &6Center X: &f" + _rtpworld.getCenterX());
|
||||||
}
|
info.add("&7- &6Center Z: &f" + _rtpworld.getCenterZ());
|
||||||
}
|
info.add("&7- &6MaxRad: &f" + _rtpworld.getMaxRad());
|
||||||
if (_rtpworld == pl.getRTP().defaultWorld)
|
info.add("&7- &6MinRad: &f" + _rtpworld.getMinRad());
|
||||||
info.add("&7- &6Custom: &cFalse");
|
|
||||||
else
|
|
||||||
info.add("&7- &6Custom: &bTrue");
|
|
||||||
if (_rtpworld.getUseWorldborder()) {
|
|
||||||
info.add("&7- &6UseWorldborder: &bTrue");
|
|
||||||
WorldBorder border = w.getWorldBorder();
|
|
||||||
info.add("&7- &6Center X: &7" + border.getCenter().getBlockX());
|
|
||||||
info.add("&7- &6Center Z: &7" + border.getCenter().getBlockZ());
|
|
||||||
info.add("&7- &6MaxRad: &7" + (border.getSize() / 2));
|
|
||||||
} else {
|
|
||||||
info.add("&7- &6UseWorldborder: &cFalse");
|
|
||||||
info.add("&7- &6Center X: &7" + _rtpworld.getCenterX());
|
|
||||||
info.add("&7- &6Center Z: &7" + _rtpworld.getCenterZ());
|
|
||||||
info.add("&7- &6MaxRad: &7" + _rtpworld.getMaxRad());
|
|
||||||
}
|
|
||||||
info.add("&7- &6MinRad: &7" + _rtpworld.getMinRad());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
@ -158,6 +157,13 @@ public class CmdInfo implements RTPCommand {
|
|||||||
for (CmdInfoSub cmd : CmdInfoSub.values())
|
for (CmdInfoSub cmd : CmdInfoSub.values())
|
||||||
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase()))
|
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase()))
|
||||||
info.add(cmd.name().toLowerCase());
|
info.add(cmd.name().toLowerCase());
|
||||||
|
} else if (args.length == 3) {
|
||||||
|
if (CmdInfoSub.WORLD.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (p.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
|
info.add(p.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class RTP {
|
|||||||
|
|
||||||
private final RTPTeleport teleport = new RTPTeleport();
|
private final RTPTeleport teleport = new RTPTeleport();
|
||||||
private final RTPPluginValidation softDepends = new RTPPluginValidation();
|
private final RTPPluginValidation softDepends = new RTPPluginValidation();
|
||||||
private final RTPPermConfigs permConfig = new RTPPermConfigs();
|
public final RTPPermissionGroup permConfig = new RTPPermissionGroup();
|
||||||
//Cache
|
//Cache
|
||||||
public HashMap<String, RTPWorld> customWorlds = new HashMap<>();
|
public HashMap<String, RTPWorld> customWorlds = new HashMap<>();
|
||||||
public HashMap<String, String> overriden = new HashMap<>();
|
public HashMap<String, String> overriden = new HashMap<>();
|
||||||
@ -121,6 +121,22 @@ public class RTP {
|
|||||||
return disabledWorlds;
|
return disabledWorlds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WorldPlayer getPlayerWorld(CommandSender p, String worldName, List<String> biomes, boolean personal) {
|
||||||
|
WorldPlayer pWorld = new WorldPlayer(p, Bukkit.getWorld(worldName));
|
||||||
|
// Set all methods
|
||||||
|
if (customWorlds.containsKey(worldName)) {
|
||||||
|
RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName());
|
||||||
|
pWorld.setup(cWorld, cWorld.getPrice(), biomes, personal);
|
||||||
|
} else
|
||||||
|
pWorld.setup(defaultWorld, defaultWorld.getPrice(), biomes, personal);
|
||||||
|
//World type
|
||||||
|
WORLD_TYPE world_type = WORLD_TYPE.NORMAL; //World rtp type
|
||||||
|
if (this.world_type.containsKey(worldName))
|
||||||
|
world_type = this.world_type.get(worldName);
|
||||||
|
pWorld.setWorldtype(world_type);
|
||||||
|
return pWorld;
|
||||||
|
}
|
||||||
|
|
||||||
public void start(Player p, CommandSender sendi, String worldName, List<String> biomes, boolean delay) {
|
public void start(Player p, CommandSender sendi, String worldName, List<String> biomes, boolean delay) {
|
||||||
// Check overrides
|
// Check overrides
|
||||||
if (worldName == null)
|
if (worldName == null)
|
||||||
@ -129,53 +145,30 @@ public class RTP {
|
|||||||
worldName = overriden.get(worldName);
|
worldName = overriden.get(worldName);
|
||||||
// Not forced and has 'betterrtp.world.<world>'
|
// Not forced and has 'betterrtp.world.<world>'
|
||||||
if (sendi == p && !getPl().getPerms().getAWorld(sendi, worldName)) {
|
if (sendi == p && !getPl().getPerms().getAWorld(sendi, worldName)) {
|
||||||
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
||||||
getPl().getText().getNoPermissionWorld(p, worldName);
|
getPl().getText().getNoPermissionWorld(p, worldName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check disabled worlds
|
// Check disabled worlds
|
||||||
if (disabledWorlds.contains(worldName)) {
|
if (disabledWorlds.contains(worldName)) {
|
||||||
getPl().getText().getDisabledWorld(sendi, worldName);
|
getPl().getText().getDisabledWorld(sendi, worldName);
|
||||||
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check if nulled or world doesnt exist
|
// Check if nulled or world doesnt exist
|
||||||
if (Bukkit.getWorld(worldName) == null) {
|
if (Bukkit.getWorld(worldName) == null) {
|
||||||
getPl().getText().getNotExist(sendi, worldName);
|
getPl().getText().getNotExist(sendi, worldName);
|
||||||
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WorldPlayer pWorld = new WorldPlayer(p, Bukkit.getWorld(worldName));
|
WorldPlayer pWorld = getPlayerWorld(p, worldName, biomes, true);
|
||||||
// Set all methods
|
|
||||||
if (customWorlds.containsKey(worldName)) {
|
|
||||||
RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName());
|
|
||||||
pWorld.setup(cWorld, cWorld.getPrice(), biomes);
|
|
||||||
} else
|
|
||||||
pWorld.setup(defaultWorld, defaultWorld.getPrice(), biomes);
|
|
||||||
//World type
|
|
||||||
WORLD_TYPE world_type = WORLD_TYPE.NORMAL; //World rtp type
|
|
||||||
if (this.world_type.containsKey(worldName))
|
|
||||||
world_type = this.world_type.get(worldName);
|
|
||||||
pWorld.setWorldtype(world_type);
|
|
||||||
// Economy
|
// Economy
|
||||||
if (!getPl().getEco().charge(p, pWorld.getPrice())) {
|
if (!getPl().getEco().charge(p, pWorld.getPrice())) {
|
||||||
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
//getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Permission Configs
|
//Cooldown
|
||||||
RTPPermConfigs.RTPPermConfiguration config = permConfig.getGroup(p);
|
getPl().getCmd().cooldowns.add(p.getUniqueId());
|
||||||
if (config != null) {
|
|
||||||
for (RTPPermConfigs.RTPPermConfigurationWorld world : config.worlds) {
|
|
||||||
if (pWorld.getWorld().getName().equals(world.name)) {
|
|
||||||
if (world.maxRad != -1)
|
|
||||||
pWorld.setMinRad(world.maxRad);
|
|
||||||
if (world.minRad != -1)
|
|
||||||
pWorld.setMinRad(world.minRad);
|
|
||||||
if (world.price != -1)
|
|
||||||
pWorld.setPrice(world.price);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Delaying? Else, just go
|
// Delaying? Else, just go
|
||||||
getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing
|
getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing
|
||||||
if (getPl().getSettings().delayEnabled && delay) {
|
if (getPl().getSettings().delayEnabled && delay) {
|
||||||
|
@ -12,7 +12,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class RTPCooldown {
|
public class RTPCooldown {
|
||||||
|
|
||||||
private HashMap<UUID, Long> cooldowns = new HashMap<>(); //Cooldown timer for each player
|
private final HashMap<UUID, Long> cooldowns = new HashMap<>(); //Cooldown timer for each player
|
||||||
private HashMap<UUID, Integer> locked = null; //Players locked from rtp'ing ever again
|
private HashMap<UUID, Integer> locked = null; //Players locked from rtp'ing ever again
|
||||||
public boolean enabled;
|
public boolean enabled;
|
||||||
private int
|
private int
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
import com.sun.org.apache.xerces.internal.xs.StringList;
|
|
||||||
import me.SuperRonanCraft.BetterRTP.Main;
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public class RTPPermConfigs {
|
public class RTPPermissionGroup {
|
||||||
private List<RTPPermConfiguration> groups = new ArrayList<>();
|
private final List<RTPPermConfiguration> groups = new ArrayList<>();
|
||||||
|
|
||||||
public RTPPermConfiguration getGroup(Player p) {
|
public RTPPermConfiguration getGroup(CommandSender p) {
|
||||||
for (RTPPermConfiguration group : groups)
|
for (RTPPermConfiguration group : groups)
|
||||||
if (Main.getInstance().getPerms().getConfig(p, group.name))
|
if (Main.getInstance().getPerms().getPermissionGroup(p, group.name))
|
||||||
return group;
|
return group;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -25,13 +24,14 @@ public class RTPPermConfigs {
|
|||||||
group.worlds.clear();
|
group.worlds.clear();
|
||||||
groups.clear();
|
groups.clear();
|
||||||
YamlConfiguration config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG).getConfig();
|
YamlConfiguration config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG).getConfig();
|
||||||
List<Map<?, ?>> list = config.getMapList("PermissionConfigs");
|
if (!config.getBoolean("PermissionGroup.Enabled")) return;
|
||||||
|
List<Map<?, ?>> list = config.getMapList("PermissionGroup.Groups");
|
||||||
for (Map<?, ?> m : list)
|
for (Map<?, ?> m : list)
|
||||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
RTPPermConfiguration group = new RTPPermConfiguration(entry);
|
RTPPermConfiguration group = new RTPPermConfiguration(entry);
|
||||||
if (group.isValid()) {
|
if (group.isValid()) {
|
||||||
groups.add(group);
|
groups.add(group);
|
||||||
Main.debug("- Group " + group.name + " has " + group.worlds.size() + " worlds setup, permission: 'betterrtp.config." + group.name + "'");
|
Main.debug("- Group " + group.name + " has " + group.worlds.size() + " worlds setup, permission: 'betterrtp.group." + group.name + "'");
|
||||||
for (RTPPermConfigurationWorld world : group.worlds) {
|
for (RTPPermConfigurationWorld world : group.worlds) {
|
||||||
Main.debug(" - World '" + world.name + "' MaxRad = " + world.maxRad + ", MinRad = " + world.minRad);
|
Main.debug(" - World '" + world.name + "' MaxRad = " + world.maxRad + ", MinRad = " + world.minRad);
|
||||||
}
|
}
|
||||||
@ -44,8 +44,8 @@ public class RTPPermConfigs {
|
|||||||
public static class RTPPermConfiguration {
|
public static class RTPPermConfiguration {
|
||||||
|
|
||||||
boolean valid;
|
boolean valid;
|
||||||
String name;
|
public String name;
|
||||||
List<RTPPermConfigurationWorld> worlds = new ArrayList<>();
|
public List<RTPPermConfigurationWorld> worlds = new ArrayList<>();
|
||||||
|
|
||||||
RTPPermConfiguration(Map.Entry<?, ?> fields) {
|
RTPPermConfiguration(Map.Entry<?, ?> fields) {
|
||||||
String group = fields.getKey().toString();
|
String group = fields.getKey().toString();
|
||||||
@ -70,12 +70,16 @@ public class RTPPermConfigs {
|
|||||||
|
|
||||||
public static class RTPPermConfigurationWorld {
|
public static class RTPPermConfigurationWorld {
|
||||||
|
|
||||||
boolean valid = true;
|
boolean valid;
|
||||||
|
|
||||||
int maxRad = -1;
|
public int maxRad = -1;
|
||||||
int minRad = -1;
|
public int minRad = -1;
|
||||||
int price = -1;
|
public int price = -1;
|
||||||
String name;
|
public int centerx = -1;
|
||||||
|
public int centerz = -1;
|
||||||
|
public Object useworldborder = null;
|
||||||
|
|
||||||
|
public String name;
|
||||||
|
|
||||||
RTPPermConfigurationWorld(Object hash, String group) {
|
RTPPermConfigurationWorld(Object hash, String group) {
|
||||||
Map.Entry world = (Map.Entry) hash;
|
Map.Entry world = (Map.Entry) hash;
|
||||||
@ -90,6 +94,12 @@ public class RTPPermConfigs {
|
|||||||
minRad = getInt(hash3.getValue().toString());
|
minRad = getInt(hash3.getValue().toString());
|
||||||
} else if (field.equalsIgnoreCase("Price")) { //MinRadius
|
} else if (field.equalsIgnoreCase("Price")) { //MinRadius
|
||||||
price = getInt(hash3.getValue().toString());
|
price = getInt(hash3.getValue().toString());
|
||||||
|
} else if (field.equalsIgnoreCase("UseWorldBorder")) { //UseWorldBorder
|
||||||
|
useworldborder = Boolean.valueOf(hash3.getValue().toString());
|
||||||
|
} else if (field.equalsIgnoreCase("CenterX")) { //Center X
|
||||||
|
centerx = getInt(hash3.getValue().toString());
|
||||||
|
} else if (field.equalsIgnoreCase("CenterZ")) { //Center Z
|
||||||
|
centerz = getInt(hash3.getValue().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Main.getInstance().getLogger().info("World MaxRad '" + world.getKey() + "' is " + maxRad);
|
//Main.getInstance().getLogger().info("World MaxRad '" + world.getKey() + "' is " + maxRad);
|
@ -87,8 +87,8 @@ public class Permissions {
|
|||||||
return perm(pre + "edit", sendi);
|
return perm(pre + "edit", sendi);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getConfig(CommandSender sendi, String group) {
|
public boolean getPermissionGroup(CommandSender sendi, String group) {
|
||||||
return perm(pre + "config." + group, sendi);
|
return perm(pre + "group." + group, sendi);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean perm(String str, CommandSender sendi) {
|
private boolean perm(String str, CommandSender sendi) {
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.references.worlds;
|
package me.SuperRonanCraft.BetterRTP.references.worlds;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPPermissionGroup;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldBorder;
|
import org.bukkit.WorldBorder;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -13,16 +16,17 @@ public class WorldPlayer implements RTPWorld {
|
|||||||
private boolean useWorldborder;
|
private boolean useWorldborder;
|
||||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price, attempts;
|
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price, attempts;
|
||||||
private List<String> Biomes;
|
private List<String> Biomes;
|
||||||
private final Player p;
|
private final CommandSender p;
|
||||||
private final World world;
|
private final World world;
|
||||||
private WORLD_TYPE world_type;
|
private WORLD_TYPE world_type;
|
||||||
|
private RTPPermissionGroup.RTPPermConfiguration config = null;
|
||||||
|
|
||||||
public WorldPlayer(Player p, World world) {
|
public WorldPlayer(CommandSender p, World world) {
|
||||||
this.p = p;
|
this.p = p;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setup(RTPWorld world, int price, List<String> biomes) {
|
public void setup(RTPWorld world, int price, List<String> biomes, boolean personal) {
|
||||||
setUseWorldborder(world.getUseWorldborder());
|
setUseWorldborder(world.getUseWorldborder());
|
||||||
setCenterX(world.getCenterX());
|
setCenterX(world.getCenterX());
|
||||||
setCenterZ(world.getCenterZ());
|
setCenterZ(world.getCenterZ());
|
||||||
@ -33,33 +37,56 @@ public class WorldPlayer implements RTPWorld {
|
|||||||
if (biomes != null)
|
if (biomes != null)
|
||||||
list.addAll(biomes);
|
list.addAll(biomes);
|
||||||
setBiomes(list);
|
setBiomes(list);
|
||||||
|
if (personal)
|
||||||
|
setupGroup(Main.getInstance().getRTP().permConfig);
|
||||||
|
//Make sure our borders will not cause an invalid integer
|
||||||
|
if (getMaxRad() <= getMinRad()) {
|
||||||
|
setMinRad(Main.getInstance().getRTP().defaultWorld.getMinRad());
|
||||||
|
if (getMaxRad() <= getMinRad())
|
||||||
|
setMinRad(0);
|
||||||
|
}
|
||||||
|
//World border protection
|
||||||
|
if (getUseWorldborder()) {
|
||||||
|
WorldBorder border = getWorld().getWorldBorder();
|
||||||
|
int _borderRad = (int) border.getSize() / 2;
|
||||||
|
if (getMaxRad() > _borderRad)
|
||||||
|
setMaxRad(_borderRad);
|
||||||
|
setCenterX(border.getCenter().getBlockX());
|
||||||
|
setCenterZ(border.getCenter().getBlockZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupGroup(RTPPermissionGroup permConfig) {
|
||||||
|
RTPPermissionGroup.RTPPermConfiguration config = permConfig.getGroup(p);
|
||||||
|
if (config != null) {
|
||||||
|
for (RTPPermissionGroup.RTPPermConfigurationWorld world : config.worlds) {
|
||||||
|
if (getWorld().getName().equals(world.name)) {
|
||||||
|
if (world.maxRad != -1)
|
||||||
|
setMaxRad(world.maxRad);
|
||||||
|
if (world.minRad != -1)
|
||||||
|
setMinRad(world.minRad);
|
||||||
|
if (world.price != -1)
|
||||||
|
setPrice(world.price);
|
||||||
|
if (world.centerx != -1)
|
||||||
|
setCenterX(world.centerx);
|
||||||
|
if (world.centerz != -1)
|
||||||
|
setCenterZ(world.centerz);
|
||||||
|
if (world.useworldborder != null)
|
||||||
|
setUseWorldborder((Boolean) world.useworldborder);
|
||||||
|
this.config = config;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return p;
|
return (Player) p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location generateRandomXZ(WorldDefault defaultWorld) {
|
public Location generateRandomXZ(WorldDefault defaultWorld) {
|
||||||
int borderRad = getMaxRad();
|
int borderRad = getMaxRad();
|
||||||
int minVal = getMinRad();
|
int minVal = getMinRad();
|
||||||
int CenterX = getCenterX();
|
|
||||||
int CenterZ = getCenterZ();
|
|
||||||
World world = getWorld();
|
|
||||||
if (getUseWorldborder()) {
|
|
||||||
WorldBorder border = world.getWorldBorder();
|
|
||||||
int _borderRad = (int) border.getSize() / 2;
|
|
||||||
if (borderRad > _borderRad)
|
|
||||||
borderRad = _borderRad;
|
|
||||||
CenterX = border.getCenter().getBlockX();
|
|
||||||
CenterZ = border.getCenter().getBlockZ();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Make sure our borders will not cause an invalid integer
|
|
||||||
if (borderRad <= minVal) {
|
|
||||||
minVal = defaultWorld.getMinRad();
|
|
||||||
if (borderRad <= minVal)
|
|
||||||
minVal = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Generate a random X and Z based off the quadrant selected
|
//Generate a random X and Z based off the quadrant selected
|
||||||
int max = borderRad - minVal;
|
int max = borderRad - minVal;
|
||||||
@ -79,11 +106,11 @@ public class WorldPlayer implements RTPWorld {
|
|||||||
x = new Random().nextInt(max) + minVal;
|
x = new Random().nextInt(max) + minVal;
|
||||||
z = -(new Random().nextInt(max) + minVal); break;
|
z = -(new Random().nextInt(max) + minVal); break;
|
||||||
}
|
}
|
||||||
x += CenterX;
|
x += getCenterX();
|
||||||
z += CenterZ;
|
z += getCenterZ();
|
||||||
addAttempt();
|
addAttempt();
|
||||||
//System.out.println(quadrant);
|
//System.out.println(quadrant);
|
||||||
return new Location(world, x, 0, z);
|
return new Location(getWorld(), x, 0, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -141,15 +168,15 @@ public class WorldPlayer implements RTPWorld {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Modifiable
|
//Modifiable
|
||||||
public void setMaxRad(int max) {
|
private void setMaxRad(int max) {
|
||||||
maxBorderRad = max;
|
maxBorderRad = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinRad(int min) {
|
private void setMinRad(int min) {
|
||||||
minBorderRad = min;
|
minBorderRad = min;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrice(int price) {
|
private void setPrice(int price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,6 +194,10 @@ public class WorldPlayer implements RTPWorld {
|
|||||||
this.world_type = type;
|
this.world_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public RTPPermissionGroup.RTPPermConfiguration getConfig() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
public WORLD_TYPE getWorldtype() {
|
public WORLD_TYPE getWorldtype() {
|
||||||
return this.world_type;
|
return this.world_type;
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ CustomWorlds:
|
|||||||
MinRadius: 100
|
MinRadius: 100
|
||||||
CenterX: 0
|
CenterX: 0
|
||||||
CenterZ: 0
|
CenterZ: 0
|
||||||
|
Price: 75
|
||||||
- other_custom_world:
|
- other_custom_world:
|
||||||
MaxRadius: 100000
|
MaxRadius: 100000
|
||||||
MinRadius: 1000
|
MinRadius: 1000
|
||||||
@ -97,22 +98,23 @@ WorldType: # Available types are NORMAL, NETHER
|
|||||||
- world_nether: NETHER
|
- world_nether: NETHER
|
||||||
- world_the_end: NORMAL
|
- world_the_end: NORMAL
|
||||||
|
|
||||||
PermissionConfigs: #Player requires "betterrtp.config.<world_name>" to trigger these configs
|
PermissionGroup: #Player requires "betterrtp.group.<world_name>" to trigger these configs
|
||||||
|
Enabled: false
|
||||||
|
Groups:
|
||||||
- vip: #betterrtp.config.vip
|
- vip: #betterrtp.config.vip
|
||||||
- Build_World: #World named "Build_World"
|
- Build_World: #World named "Build_World"
|
||||||
MaxRadius: 10000
|
MaxRadius: 10000
|
||||||
MinRadius: 1000
|
MinRadius: 1000
|
||||||
Price: 100
|
Price: 100
|
||||||
- Survival_World:
|
- Survival_World:
|
||||||
|
UseWorldBorder: false
|
||||||
MaxRadius: 5000
|
MaxRadius: 5000
|
||||||
MinRadius: 1000
|
MinRadius: 1000
|
||||||
|
CenterX: 10
|
||||||
|
CenterZ: 10
|
||||||
Price: 10
|
Price: 10
|
||||||
- vip2:
|
- vip2:
|
||||||
- Build_World:
|
- Build_World:
|
||||||
MaxRadius: 25000
|
MaxRadius: 25000
|
||||||
MinRadius: 10000
|
MinRadius: 10000
|
||||||
Price: 15
|
Price: 15
|
||||||
- Survival_World:
|
|
||||||
MaxRadius: 15000
|
|
||||||
MinRadius: 1000
|
|
||||||
Price: 20
|
|
@ -36,6 +36,8 @@ permissions:
|
|||||||
description: RTP another player
|
description: RTP another player
|
||||||
betterrtp.biome:
|
betterrtp.biome:
|
||||||
description: RTP to specific biomes
|
description: RTP to specific biomes
|
||||||
|
betterrtp.group.*:
|
||||||
|
description: Use a permission group to rtp with different restrictions
|
||||||
betterrtp.sign:
|
betterrtp.sign:
|
||||||
description: Ability to create an RTP sign
|
description: Ability to create an RTP sign
|
||||||
betterrtp.bypass.cooldown:
|
betterrtp.bypass.cooldown:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user