mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
Permission config (framework)
This commit is contained in:
parent
afcb76bfd7
commit
82cba7cef6
@ -4,7 +4,7 @@ import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPParticles;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.RTPWorld;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.RTP_WORLD_TYPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.WORLD_TYPE;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
@ -103,7 +103,7 @@ public class CmdInfo implements RTPCommand {
|
||||
if (pl.getRTP().overriden.containsKey(w.getName()))
|
||||
info.add("&7- &6Overriden: &bTrue");
|
||||
else {
|
||||
info.add("&7- &6WorldType: &f" + pl.getRTP().world_type.getOrDefault(w.getName(), RTP_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");
|
||||
RTPWorld _rtpworld = pl.getRTP().defaultWorld;
|
||||
for (RTPWorld __rtpworld : pl.getRTP().customWorlds.values()) {
|
||||
|
@ -24,11 +24,11 @@ public class RTP {
|
||||
//Cache
|
||||
public HashMap<String, RTPWorld> customWorlds = new HashMap<>();
|
||||
public HashMap<String, String> overriden = new HashMap<>();
|
||||
public Default defaultWorld = new Default();
|
||||
public WorldDefault defaultWorld = new WorldDefault();
|
||||
private List<String> disabledWorlds, blockList;
|
||||
private int maxAttempts, delayTime;
|
||||
private boolean cancelOnMove, cancelOnDamage;
|
||||
public HashMap<String, RTP_WORLD_TYPE> world_type = new HashMap<>();
|
||||
public HashMap<String, WORLD_TYPE> world_type = new HashMap<>();
|
||||
|
||||
public RTPTeleport getTeleport() {
|
||||
return teleport;
|
||||
@ -59,17 +59,17 @@ public class RTP {
|
||||
try {
|
||||
world_type.clear();
|
||||
for (World world : Bukkit.getWorlds())
|
||||
world_type.put(world.getName(), RTP_WORLD_TYPE.NORMAL);
|
||||
world_type.put(world.getName(), WORLD_TYPE.NORMAL);
|
||||
List<Map<?, ?>> world_map = config.getMapList("WorldType");
|
||||
for (Map<?, ?> m : world_map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
if (world_type.containsKey(entry.getKey())) {
|
||||
try {
|
||||
RTP_WORLD_TYPE type = RTP_WORLD_TYPE.valueOf(entry.getValue().toString().toUpperCase());
|
||||
WORLD_TYPE type = WORLD_TYPE.valueOf(entry.getValue().toString().toUpperCase());
|
||||
world_type.put(entry.getKey().toString(), type);
|
||||
} catch(IllegalArgumentException e) {
|
||||
StringBuilder valids = new StringBuilder();
|
||||
for (RTP_WORLD_TYPE type : RTP_WORLD_TYPE.values())
|
||||
for (WORLD_TYPE type : WORLD_TYPE.values())
|
||||
valids.append(type.name()).append(", ");
|
||||
valids.replace(valids.length() - 2, valids.length(), "");
|
||||
getPl().getLogger().severe("World Type for '" + entry.getKey() + "' is INVALID '" + entry.getValue() +
|
||||
@ -103,7 +103,7 @@ public class RTP {
|
||||
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
||||
for (Map<?, ?> m : map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
customWorlds.put(entry.getKey().toString(), new Custom(entry.getKey().toString()));
|
||||
customWorlds.put(entry.getKey().toString(), new WorldCustom(entry.getKey().toString()));
|
||||
if (getPl().getSettings().debug)
|
||||
getPl().getLogger().info("- Custom World '" + entry.getKey() + "' registered");
|
||||
}
|
||||
@ -144,7 +144,7 @@ public class RTP {
|
||||
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
||||
return;
|
||||
}
|
||||
PlayerWorld pWorld = new PlayerWorld(p, Bukkit.getWorld(worldName));
|
||||
WorldPlayer pWorld = new WorldPlayer(p, Bukkit.getWorld(worldName));
|
||||
// Set all methods
|
||||
if (customWorlds.containsKey(worldName)) {
|
||||
RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName());
|
||||
@ -152,7 +152,7 @@ public class RTP {
|
||||
} else
|
||||
pWorld.setup(defaultWorld, defaultWorld.getPrice(), biomes);
|
||||
//World type
|
||||
RTP_WORLD_TYPE world_type = RTP_WORLD_TYPE.NORMAL; //World rtp 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);
|
||||
@ -171,7 +171,7 @@ public class RTP {
|
||||
}
|
||||
}
|
||||
|
||||
void findSafeLocation(CommandSender sendi, PlayerWorld pWorld) {
|
||||
void findSafeLocation(CommandSender sendi, WorldPlayer pWorld) {
|
||||
if (pWorld.getAttempts() >= maxAttempts) //Cancel out, too many tried
|
||||
metMax(sendi, pWorld.getPlayer(), pWorld.getPrice());
|
||||
else { //Try again to find a safe location
|
||||
@ -207,7 +207,7 @@ public class RTP {
|
||||
getPl().getCmd().rtping.put(p.getUniqueId(), false);
|
||||
}
|
||||
|
||||
private Location getLocAtNormal(int x, int z, World world, Float yaw, Float pitch, PlayerWorld pWorld) {
|
||||
private Location getLocAtNormal(int x, int z, World world, Float yaw, Float pitch, WorldPlayer pWorld) {
|
||||
Block b = world.getHighestBlockAt(x, z);
|
||||
if (b.getType().toString().endsWith("AIR")) //1.15.1 or less
|
||||
b = world.getBlockAt(x, b.getY() - 1, z);
|
||||
@ -224,7 +224,7 @@ public class RTP {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location getLocAtNether(int x, int z, World world, Float yaw, Float pitch, PlayerWorld pWorld) {
|
||||
private Location getLocAtNether(int x, int z, World world, Float yaw, Float pitch, WorldPlayer pWorld) {
|
||||
//System.out.println("-----------");
|
||||
for (int y = 1; y < world.getMaxHeight(); y++) {
|
||||
// System.out.println("--");
|
||||
|
@ -1,6 +1,6 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.PlayerWorld;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.WorldPlayer;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -13,10 +13,10 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
class RTPDelay implements Listener {
|
||||
private int run;
|
||||
private final PlayerWorld pWorld;
|
||||
private final WorldPlayer pWorld;
|
||||
private final boolean cancelOnMove, cancelOnDamage;
|
||||
|
||||
RTPDelay(CommandSender sendi, PlayerWorld pWorld, int delay, boolean cancelOnMove, boolean cancelOnDamage) {
|
||||
RTPDelay(CommandSender sendi, WorldPlayer pWorld, int delay, boolean cancelOnMove, boolean cancelOnDamage) {
|
||||
this.pWorld = pWorld;
|
||||
this.cancelOnMove = cancelOnMove;
|
||||
this.cancelOnDamage = cancelOnDamage;
|
||||
|
@ -0,0 +1,12 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class RTPPermConfigs {
|
||||
private List<String> groups = new ArrayList<>();
|
||||
|
||||
public void load() {
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.worlds;
|
||||
|
||||
public enum RTP_WORLD_TYPE {
|
||||
public enum WORLD_TYPE {
|
||||
NORMAL, //Normal world type finds the tallest safe block
|
||||
NETHER //Nether world types finds the lowest safe block
|
||||
}
|
@ -9,13 +9,13 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Custom implements RTPWorld {
|
||||
public String world, world_type;
|
||||
public class WorldCustom implements RTPWorld {
|
||||
public String world;
|
||||
private boolean useWorldborder = false;
|
||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price;
|
||||
private List<String> Biomes;
|
||||
|
||||
public Custom(String world) {
|
||||
public WorldCustom(String world) {
|
||||
String pre = "CustomWorlds.";
|
||||
FileBasics.FILETYPE config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
@ -9,7 +9,7 @@ import org.bukkit.World;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Default implements RTPWorld {
|
||||
public class WorldDefault implements RTPWorld {
|
||||
private boolean useWorldborder;
|
||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price;
|
||||
private List<String> Biomes;
|
@ -9,15 +9,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class PlayerWorld implements RTPWorld {
|
||||
public class WorldPlayer implements RTPWorld {
|
||||
private boolean useWorldborder;
|
||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price, attempts;
|
||||
private List<String> Biomes;
|
||||
private final Player p;
|
||||
private final World world;
|
||||
private RTP_WORLD_TYPE world_type;
|
||||
private WORLD_TYPE world_type;
|
||||
|
||||
public PlayerWorld(Player p, World world) {
|
||||
public WorldPlayer(Player p, World world) {
|
||||
this.p = p;
|
||||
this.world = world;
|
||||
}
|
||||
@ -39,7 +39,7 @@ public class PlayerWorld implements RTPWorld {
|
||||
return p;
|
||||
}
|
||||
|
||||
public Location generateRandomXZ(Default defaultWorld) {
|
||||
public Location generateRandomXZ(WorldDefault defaultWorld) {
|
||||
int borderRad = getMaxRad();
|
||||
int minVal = getMinRad();
|
||||
int CenterX = getCenterX();
|
||||
@ -159,11 +159,11 @@ public class PlayerWorld implements RTPWorld {
|
||||
}
|
||||
|
||||
//Custom World type
|
||||
public void setWorldtype(RTP_WORLD_TYPE type) {
|
||||
public void setWorldtype(WORLD_TYPE type) {
|
||||
this.world_type = type;
|
||||
}
|
||||
|
||||
public RTP_WORLD_TYPE getWorldtype() {
|
||||
public WORLD_TYPE getWorldtype() {
|
||||
return this.world_type;
|
||||
}
|
||||
}
|
@ -97,18 +97,18 @@ WorldType: # Available types are NORMAL, NETHER
|
||||
- world_nether: NETHER
|
||||
- world_the_end: NORMAL
|
||||
|
||||
#PermissionConfigs: #Player requires "betterrtp.config.<world_name>" to trigger these configs
|
||||
#- vip: #betterrtp.config.vip
|
||||
# - Build_World: #World named "Build_World"
|
||||
# MaxRadius: 10000
|
||||
# MinRadius: 1000
|
||||
# - Survival_World:
|
||||
# MaxRadius: 5000
|
||||
# MinRadius: 1000
|
||||
#- vip2:
|
||||
# - Build_World:
|
||||
# MaxRadius: 25000
|
||||
# MinRadius: 10000
|
||||
# - Survival_World:
|
||||
# MaxRadius: 15000
|
||||
# MinRadius: 1000
|
||||
PermissionConfigs: #Player requires "betterrtp.config.<world_name>" to trigger these configs
|
||||
- vip: #betterrtp.config.vip
|
||||
- Build_World: #World named "Build_World"
|
||||
MaxRadius: 10000
|
||||
MinRadius: 1000
|
||||
- Survival_World:
|
||||
MaxRadius: 5000
|
||||
MinRadius: 1000
|
||||
- vip2:
|
||||
- Build_World:
|
||||
MaxRadius: 25000
|
||||
MinRadius: 10000
|
||||
- Survival_World:
|
||||
MaxRadius: 15000
|
||||
MinRadius: 1000
|
Loading…
x
Reference in New Issue
Block a user