mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 00:55:45 +00:00
custom world price fix
This commit is contained in:
parent
17a574866b
commit
2f218707a5
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
||||
<groupId>me.SuperRonanCraft</groupId>
|
||||
<artifactId>BetterRTP</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.0.2</version>
|
||||
<version>3.0.3</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommandHelpable;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTPParticles;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.WorldDefault;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.WorldPlayer;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.WORLD_TYPE;
|
||||
@ -125,18 +126,39 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
|
||||
info.add("&7- &6WorldType: &f" + pl.getRTP().world_type.getOrDefault(w.getName(), WORLD_TYPE.NORMAL).name());
|
||||
info.add("&7- &6Overriden: " + _false);
|
||||
WorldPlayer _rtpworld = BetterRTP.getInstance().getRTP().getPlayerWorld(sendi, w.getName(), null, personal);
|
||||
WorldDefault worldDefault = BetterRTP.getInstance().getRTP().defaultWorld;
|
||||
info.add("&7- &6Custom: " + (BetterRTP.getInstance().getRTP().customWorlds.containsKey(w.getName()) ? _true : _false));
|
||||
info.add("&7- &6UseWorldBorder: " + (_rtpworld.getUseWorldborder() ? _true : _false));
|
||||
info.add("&7- &6Permission Group: " + (_rtpworld.getConfig() != null ? "&e" + _rtpworld.getConfig().name : "&cN/A"));
|
||||
info.add("&7- &6Center X: &f" + _rtpworld.getCenterX());
|
||||
info.add("&7- &6Center Z: &f" + _rtpworld.getCenterZ());
|
||||
info.add("&7- &6MaxRad: &f" + _rtpworld.getMaxRad());
|
||||
info.add("&7- &6MinRad: &f" + _rtpworld.getMinRad());
|
||||
info.add("&7- &6Center X: &f" + _rtpworld.getCenterX() + getInfo(_rtpworld, worldDefault, "centerx"));
|
||||
info.add("&7- &6Center Z: &f" + _rtpworld.getCenterZ() + getInfo(_rtpworld, worldDefault, "centerz"));
|
||||
info.add("&7- &6MaxRad: &f" + _rtpworld.getMaxRad() + getInfo(_rtpworld, worldDefault, "max"));
|
||||
info.add("&7- &6MinRad: &f" + _rtpworld.getMinRad() + getInfo(_rtpworld, worldDefault, "min"));
|
||||
info.add("&7- &6Price: &f" + _rtpworld.getPrice() + getInfo(_rtpworld, worldDefault, "price"));
|
||||
info.add("&7- &6World Type: &f" + _rtpworld.getWorldtype().name());
|
||||
info.add("&7- &6Biomes: &f" + _rtpworld.getBiomes().toString());
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
//Janky, but it works
|
||||
private String getInfo(WorldPlayer worldPlayer, WorldDefault worldDefault, String type) {
|
||||
switch (type) {
|
||||
case "centerx":
|
||||
return worldPlayer.getUseWorldborder() || worldPlayer.getCenterX() != worldDefault.getCenterX() ? worldPlayer.getUseWorldborder() ? " &8(worldborder)" : "&a*" : "";
|
||||
case "centerz":
|
||||
return worldPlayer.getUseWorldborder() || worldPlayer.getCenterX() != worldDefault.getCenterZ() ? worldPlayer.getUseWorldborder() ? " &8(worldborder)" : "&a*" : "";
|
||||
case "max":
|
||||
return worldPlayer.getUseWorldborder() || worldPlayer.getMaxRad() != worldDefault.getMaxRad() ? worldPlayer.getUseWorldborder() ? " &8(worldborder)" : "&a*" : "";
|
||||
case "min":
|
||||
return worldPlayer.getMinRad() != worldDefault.getMinRad() ? "&a*" : "";
|
||||
case "price":
|
||||
return worldPlayer.getPrice() != worldDefault.getPrice() ? "&a*" : "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//Effects
|
||||
private void infoEffects(CommandSender sendi) {
|
||||
List<String> info = new ArrayList<>();
|
||||
|
@ -123,9 +123,9 @@ public class RTP {
|
||||
// Set all methods
|
||||
if (customWorlds.containsKey(world_name)) {
|
||||
RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName());
|
||||
pWorld.setup(cWorld, cWorld.getPrice(), biomes, personal);
|
||||
pWorld.setup(cWorld, biomes, personal);
|
||||
} else
|
||||
pWorld.setup(defaultWorld, defaultWorld.getPrice(), biomes, personal);
|
||||
pWorld.setup(defaultWorld, biomes, personal);
|
||||
//World type
|
||||
WORLD_TYPE world_type = WORLD_TYPE.NORMAL; //World rtp type
|
||||
if (this.world_type.containsKey(world_name))
|
||||
|
@ -16,7 +16,7 @@ public class WorldCustom implements RTPWorld {
|
||||
private List<String> Biomes;
|
||||
|
||||
public WorldCustom(String world) {
|
||||
String pre = "CustomWorlds.";
|
||||
//String pre = "CustomWorlds.";
|
||||
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
||||
this.world = world;
|
||||
@ -75,8 +75,16 @@ public class WorldCustom implements RTPWorld {
|
||||
}
|
||||
if (test.get("Biomes") != null) {
|
||||
if (test.get("Biomes").getClass() == ArrayList.class)
|
||||
this.Biomes = new ArrayList<>((ArrayList) test.get("Biomes"));
|
||||
this.Biomes = new ArrayList<String>((ArrayList) test.get("Biomes"));
|
||||
}
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (test.get("Price") != null) {
|
||||
if (test.get("Price").getClass() == Integer.class)
|
||||
this.price = Integer.parseInt(test.get("Price").toString());
|
||||
else
|
||||
price = worldDefault.getPrice(world);
|
||||
} else
|
||||
price = worldDefault.getPrice(world);
|
||||
}
|
||||
}
|
||||
//Booleans
|
||||
@ -96,24 +104,22 @@ public class WorldCustom implements RTPWorld {
|
||||
"WARNING! Custom world '" + world + "' Minimum radius of '" + minBorderRad + "' is not allowed! Set to default value!");
|
||||
minBorderRad = BetterRTP.getInstance().getRTP().defaultWorld.getMinRad();
|
||||
}
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean(pre + "Enabled")) {
|
||||
map.clear();
|
||||
map = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getMapList("CustomWorlds");
|
||||
for (Map<?, ?> m : map)
|
||||
/*if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("CustomWorlds.Enabled")) {
|
||||
List<Map<?, ?>> world_map = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getMapList("CustomWorlds.Worlds");
|
||||
for (Map<?, ?> m : world_map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
Map<?, ?> test = ((Map<?, ?>) m.get(key));
|
||||
if (!key.equals(world))
|
||||
String _world = entry.getKey().toString();
|
||||
//System.out.println("Custom World Price " + _world + ":" + entry.getValue().toString());
|
||||
if (!_world.equals(world))
|
||||
continue;
|
||||
if (test.get("Price") != null)
|
||||
if (test.get("Price").getClass() == Integer.class)
|
||||
price = Integer.valueOf((test.get("Price")).toString());
|
||||
if (entry.getValue().getClass() == Integer.class)
|
||||
price = Integer.parseInt((entry.getValue().toString()));
|
||||
}
|
||||
} else
|
||||
price = BetterRTP.getInstance().getRTP().defaultWorld.getPrice();
|
||||
price = worldDefault.getPrice();*/
|
||||
//Other
|
||||
this.Biomes = config.getStringList(pre + world + ".Biomes");
|
||||
//this.Biomes = config.getStringList("CustomWorlds." + world + ".Biomes");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,13 +5,17 @@ import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import scala.Int;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class WorldDefault implements RTPWorld {
|
||||
private boolean useWorldborder;
|
||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price;
|
||||
private List<String> Biomes;
|
||||
private HashMap<String, Integer> prices = new HashMap<>();
|
||||
|
||||
public void setup() {
|
||||
//Setups
|
||||
@ -34,9 +38,20 @@ public class WorldDefault implements RTPWorld {
|
||||
"WARNING! Default Minimum radius of '" + minBorderRad + "' is not allowed! Set to '0'");
|
||||
minBorderRad = 0;
|
||||
}
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
prices.clear();
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled")) {
|
||||
price = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getInt("Economy.Price");
|
||||
else
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("CustomWorlds.Enabled")) {
|
||||
List<Map<?, ?>> world_map = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getMapList("CustomWorlds.Worlds");
|
||||
for (Map<?, ?> m : world_map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
String _world = entry.getKey().toString();
|
||||
//System.out.println("Custom World Price " + _world + ":" + entry.getValue().toString());
|
||||
if (entry.getValue().getClass() == Integer.class)
|
||||
prices.put(_world, Integer.parseInt((entry.getValue().toString())));
|
||||
}
|
||||
}
|
||||
} else
|
||||
price = 0;
|
||||
//Other
|
||||
this.Biomes = config.getStringList(pre + ".Biomes");
|
||||
@ -67,6 +82,10 @@ public class WorldDefault implements RTPWorld {
|
||||
return minBorderRad;
|
||||
}
|
||||
|
||||
public int getPrice(String world) {
|
||||
return prices.getOrDefault(world, getPrice());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrice() {
|
||||
return price;
|
||||
|
@ -28,13 +28,16 @@ public class WorldPlayer implements RTPWorld {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public void setup(RTPWorld world, int price, List<String> biomes, boolean personal) {
|
||||
public void setup(RTPWorld world, List<String> biomes, boolean personal) {
|
||||
setUseWorldborder(world.getUseWorldborder());
|
||||
setCenterX(world.getCenterX());
|
||||
setCenterZ(world.getCenterZ());
|
||||
setMaxRad(world.getMaxRad());
|
||||
setMinRad(world.getMinRad());
|
||||
setPrice(price);
|
||||
if (world instanceof WorldDefault)
|
||||
setPrice(((WorldDefault) world).getPrice(world.getWorld().getName()));
|
||||
else
|
||||
setPrice(world.getPrice());
|
||||
List<String> list = new ArrayList<>(world.getBiomes());
|
||||
if (biomes != null) {
|
||||
list.clear();
|
||||
|
@ -85,12 +85,13 @@ CustomWorlds:
|
||||
MinRadius: 100
|
||||
CenterX: 0
|
||||
CenterZ: 0
|
||||
Price: 75
|
||||
Price: 50
|
||||
- other_custom_world:
|
||||
MaxRadius: 100000
|
||||
MinRadius: 1000
|
||||
MaxRadius: 10000
|
||||
MinRadius: 150
|
||||
CenterX: 123
|
||||
CenterZ: -123
|
||||
Price: 0
|
||||
## Biomes are optional, but useful! More biomes: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Biome.html
|
||||
Biomes:
|
||||
- 'desert'
|
||||
|
@ -3,7 +3,7 @@ Economy:
|
||||
Enabled: false
|
||||
## Set to "0" to not charge for rtp, "Success.Bypass" message will be sent!
|
||||
## Give players the permission "betterrtp.eco.bypass" to bypass economy
|
||||
Price: 5
|
||||
Price: 500
|
||||
|
||||
Hunger: #Make rtp'ing take up hunger to avoid exploits
|
||||
Enabled: false
|
||||
@ -14,6 +14,6 @@ CustomWorlds:
|
||||
Enabled: true
|
||||
Worlds:
|
||||
## PlayerWorld will be charged "5" when typing /rtp, if they do not have "betterrtp.eco.bypass"
|
||||
world: 5
|
||||
- world: 50
|
||||
## Setting the price to "0" will make the "Success.Bypass" message show
|
||||
world_end: 0
|
||||
- world_end: 0
|
@ -1,5 +1,5 @@
|
||||
main: me.SuperRonanCraft.BetterRTP.BetterRTP
|
||||
version: '3.0.2'
|
||||
version: '3.0.3'
|
||||
name: BetterRTP
|
||||
author: SuperRonanCraft
|
||||
softdepend:
|
||||
|
Loading…
x
Reference in New Issue
Block a user