mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
Permission based world configs added + UseWorldBorder slightly ignores maxRadius
This commit is contained in:
parent
82cba7cef6
commit
c8a00751fa
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.SuperRonanCraft</groupId>
|
<groupId>me.SuperRonanCraft</groupId>
|
||||||
<artifactId>BetterRTP</artifactId>
|
<artifactId>BetterRTP</artifactId>
|
||||||
<version>2.13.1</version>
|
<version>2.13.2</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
@ -116,4 +116,9 @@ public class Main extends JavaPlugin {
|
|||||||
eco.load();
|
eco.load();
|
||||||
perms.register();
|
perms.register();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void debug(String str) {
|
||||||
|
if (getInstance().getSettings().debug)
|
||||||
|
getInstance().getLogger().info(str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +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();
|
||||||
//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<>();
|
||||||
@ -83,15 +84,15 @@ public class RTP {
|
|||||||
}
|
}
|
||||||
if (getPl().getSettings().debug)
|
if (getPl().getSettings().debug)
|
||||||
for (String world : world_type.keySet())
|
for (String world : world_type.keySet())
|
||||||
getPl().getLogger().info("- World Type for '" + world + "' set to '" + world_type.get(world) + "'");
|
Main.debug("- World Type for '" + world + "' set to '" + world_type.get(world) + "'");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
//No World Types
|
//No World Types
|
||||||
}
|
}
|
||||||
|
|
||||||
loadWorldSettings();
|
loadWorldSettings();
|
||||||
|
|
||||||
teleport.load(); //Load teleporting stuff
|
teleport.load(); //Load teleporting stuff
|
||||||
|
permConfig.load(); //Load permission configs
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadWorldSettings() {
|
public void loadWorldSettings() {
|
||||||
@ -105,7 +106,7 @@ public class RTP {
|
|||||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
customWorlds.put(entry.getKey().toString(), new WorldCustom(entry.getKey().toString()));
|
customWorlds.put(entry.getKey().toString(), new WorldCustom(entry.getKey().toString()));
|
||||||
if (getPl().getSettings().debug)
|
if (getPl().getSettings().debug)
|
||||||
getPl().getLogger().info("- Custom World '" + entry.getKey() + "' registered");
|
Main.debug("- Custom World '" + entry.getKey() + "' registered");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//No Custom Worlds
|
//No Custom Worlds
|
||||||
@ -161,6 +162,20 @@ public class RTP {
|
|||||||
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
getPl().getCmd().cooldowns.remove(p.getUniqueId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// Permission Configs
|
||||||
|
RTPPermConfigs.RTPPermConfiguration config = permConfig.getGroup(p);
|
||||||
|
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) {
|
||||||
|
@ -1,12 +1,108 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.sun.org.apache.xerces.internal.xs.StringList;
|
||||||
import java.util.List;
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public class RTPPermConfigs {
|
public class RTPPermConfigs {
|
||||||
private List<String> groups = new ArrayList<>();
|
private List<RTPPermConfiguration> groups = new ArrayList<>();
|
||||||
|
|
||||||
|
public RTPPermConfiguration getGroup(Player p) {
|
||||||
|
for (RTPPermConfiguration group : groups)
|
||||||
|
if (Main.getInstance().getPerms().getConfig(p, group.name))
|
||||||
|
return group;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
|
for (RTPPermConfiguration group : groups)
|
||||||
|
group.worlds.clear();
|
||||||
|
groups.clear();
|
||||||
|
YamlConfiguration config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG).getConfig();
|
||||||
|
List<Map<?, ?>> list = config.getMapList("PermissionConfigs");
|
||||||
|
for (Map<?, ?> m : list)
|
||||||
|
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||||
|
RTPPermConfiguration group = new RTPPermConfiguration(entry);
|
||||||
|
if (group.isValid()) {
|
||||||
|
groups.add(group);
|
||||||
|
Main.debug("- Group " + group.name + " has " + group.worlds.size() + " worlds setup, permission: 'betterrtp.config." + group.name + "'");
|
||||||
|
for (RTPPermConfigurationWorld world : group.worlds) {
|
||||||
|
Main.debug(" - World '" + world.name + "' MaxRad = " + world.maxRad + ", MinRad = " + world.minRad);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Main.debug("ERROR! Group " + group.name + " was not setup correctly!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RTPPermConfiguration {
|
||||||
|
|
||||||
|
boolean valid;
|
||||||
|
String name;
|
||||||
|
List<RTPPermConfigurationWorld> worlds = new ArrayList<>();
|
||||||
|
|
||||||
|
RTPPermConfiguration(Map.Entry<?, ?> fields) {
|
||||||
|
String group = fields.getKey().toString();
|
||||||
|
Object value = fields.getValue();
|
||||||
|
for (Object worlds : ((ArrayList) value)) {
|
||||||
|
for (Object hash : ((HashMap) worlds).entrySet()) {
|
||||||
|
RTPPermConfigurationWorld worldConfig = new RTPPermConfigurationWorld(hash, group);
|
||||||
|
if (worldConfig.isValid())
|
||||||
|
this.worlds.add(worldConfig);
|
||||||
|
else
|
||||||
|
Main.debug("ERROR! Group " + group + " world " + worldConfig.name + " was not setup correctly!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.name = group;
|
||||||
|
valid = worlds.size() > 0 && group != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class RTPPermConfigurationWorld {
|
||||||
|
|
||||||
|
boolean valid = true;
|
||||||
|
|
||||||
|
int maxRad = -1;
|
||||||
|
int minRad = -1;
|
||||||
|
int price = -1;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
RTPPermConfigurationWorld(Object hash, String group) {
|
||||||
|
Map.Entry world = (Map.Entry) hash;
|
||||||
|
this.name = world.getKey().toString();
|
||||||
|
//Main.getInstance().getLogger().info("World added to '" + group +"': '" + world.getKey() + "'");
|
||||||
|
for (Object hash2 : ((HashMap) world.getValue()).entrySet()) {
|
||||||
|
Map.Entry hash3 = (Map.Entry) hash2;
|
||||||
|
String field = hash3.getKey().toString();
|
||||||
|
if (field.equalsIgnoreCase("MaxRadius")) { //MaxRadius
|
||||||
|
maxRad = getInt(hash3.getValue().toString());
|
||||||
|
} else if (field.equalsIgnoreCase("MinRadius")) { //MinRadius
|
||||||
|
minRad = getInt(hash3.getValue().toString());
|
||||||
|
} else if (field.equalsIgnoreCase("Price")) { //MinRadius
|
||||||
|
price = getInt(hash3.getValue().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Main.getInstance().getLogger().info("World MaxRad '" + world.getKey() + "' is " + maxRad);
|
||||||
|
//Main.getInstance().getLogger().info("World MinRad '" + world.getKey() + "' is " + minRad);
|
||||||
|
valid = this.name != null && (minRad != -1 || maxRad != -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getInt(String input) {
|
||||||
|
return Integer.parseInt(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isValid() {
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,10 @@ public class Permissions {
|
|||||||
return perm(pre + "edit", sendi);
|
return perm(pre + "edit", sendi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getConfig(CommandSender sendi, String group) {
|
||||||
|
return perm(pre + "config." + group, sendi);
|
||||||
|
}
|
||||||
|
|
||||||
private boolean perm(String str, CommandSender sendi) {
|
private boolean perm(String str, CommandSender sendi) {
|
||||||
return depPerms.hasPerm(str, sendi);
|
return depPerms.hasPerm(str, sendi);
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,9 @@ public class WorldPlayer implements RTPWorld {
|
|||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
if (getUseWorldborder()) {
|
if (getUseWorldborder()) {
|
||||||
WorldBorder border = world.getWorldBorder();
|
WorldBorder border = world.getWorldBorder();
|
||||||
borderRad = (int) border.getSize() / 2;
|
int _borderRad = (int) border.getSize() / 2;
|
||||||
|
if (borderRad > _borderRad)
|
||||||
|
borderRad = _borderRad;
|
||||||
CenterX = border.getCenter().getBlockX();
|
CenterX = border.getCenter().getBlockX();
|
||||||
CenterZ = border.getCenter().getBlockZ();
|
CenterZ = border.getCenter().getBlockZ();
|
||||||
}
|
}
|
||||||
@ -138,15 +140,16 @@ public class WorldPlayer implements RTPWorld {
|
|||||||
CenterZ = z;
|
CenterZ = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMaxRad(int max) {
|
//Modifiable
|
||||||
|
public void setMaxRad(int max) {
|
||||||
maxBorderRad = max;
|
maxBorderRad = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMinRad(int min) {
|
public void setMinRad(int min) {
|
||||||
minBorderRad = min;
|
minBorderRad = min;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPrice(int price) {
|
public void setPrice(int price) {
|
||||||
this.price = price;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,6 +157,7 @@ public class WorldPlayer implements RTPWorld {
|
|||||||
this.attempts++;
|
this.attempts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
private void setBiomes(List<String> biomes) {
|
private void setBiomes(List<String> biomes) {
|
||||||
this.Biomes = biomes;
|
this.Biomes = biomes;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ Default:
|
|||||||
Biomes: []
|
Biomes: []
|
||||||
MaxRadius: 1000
|
MaxRadius: 1000
|
||||||
MinRadius: 10
|
MinRadius: 10
|
||||||
## If "UseWorldBorder" is set to true above, these values WILL be ignored! Except Biomes! #
|
## If "UseWorldBorder" is set to true above, Center X and Z will be ignored! #
|
||||||
CenterX: 0
|
CenterX: 0
|
||||||
CenterZ: 0
|
CenterZ: 0
|
||||||
|
|
||||||
@ -102,13 +102,17 @@ PermissionConfigs: #Player requires "betterrtp.config.<world_name>" to trigger t
|
|||||||
- Build_World: #World named "Build_World"
|
- Build_World: #World named "Build_World"
|
||||||
MaxRadius: 10000
|
MaxRadius: 10000
|
||||||
MinRadius: 1000
|
MinRadius: 1000
|
||||||
|
Price: 100
|
||||||
- Survival_World:
|
- Survival_World:
|
||||||
MaxRadius: 5000
|
MaxRadius: 5000
|
||||||
MinRadius: 1000
|
MinRadius: 1000
|
||||||
|
Price: 10
|
||||||
- vip2:
|
- vip2:
|
||||||
- Build_World:
|
- Build_World:
|
||||||
MaxRadius: 25000
|
MaxRadius: 25000
|
||||||
MinRadius: 10000
|
MinRadius: 10000
|
||||||
|
Price: 15
|
||||||
- Survival_World:
|
- Survival_World:
|
||||||
MaxRadius: 15000
|
MaxRadius: 15000
|
||||||
MinRadius: 1000
|
MinRadius: 1000
|
||||||
|
Price: 20
|
@ -1,5 +1,5 @@
|
|||||||
main: me.SuperRonanCraft.BetterRTP.Main
|
main: me.SuperRonanCraft.BetterRTP.Main
|
||||||
version: '2.13.1'
|
version: '2.13.2'
|
||||||
name: BetterRTP
|
name: BetterRTP
|
||||||
author: SuperRonanCraft
|
author: SuperRonanCraft
|
||||||
softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect]
|
softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user