mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
edit command added ability to edit max/min y
This commit is contained in:
parent
92b244e9d1
commit
7c46c8c31f
@ -28,7 +28,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||
switch (cmd) {
|
||||
case WORLD:
|
||||
case CUSTOMWORLD:
|
||||
if (args.length >= 5) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
if (world.getName().startsWith(args[2])) {
|
||||
@ -94,6 +94,51 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
usage(sendi, label, null);
|
||||
}
|
||||
|
||||
private void editLocation(CommandSender sendi, RTP_CMD_EDIT_SUB cmd, String location, String val) {
|
||||
Object value;
|
||||
try {
|
||||
value = cmd.getResult(val);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
BetterRTP.getInstance().getText().getEditError(sendi);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == null) {
|
||||
BetterRTP.getInstance().getText().getEditError(sendi);
|
||||
return;
|
||||
}
|
||||
|
||||
FileBasics.FILETYPE file = FileBasics.FILETYPE.LOCATIONS;
|
||||
YamlConfiguration config = file.getConfig();
|
||||
|
||||
List<Map<?, ?>> map = config.getMapList("Locations");
|
||||
boolean found = false;
|
||||
for (Map<?, ?> m : map) {
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
if (entry.getKey().toString().equals(location)) {
|
||||
found = true;
|
||||
for (Object map2 : m.values()) {
|
||||
Map<Object, Object> values = (Map<Object, Object>) map2;
|
||||
values.put(cmd.get(), value);
|
||||
BetterRTP.getInstance().getText().getEditSet(sendi, cmd.get(), val);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found) {
|
||||
config.set("Locations", map);
|
||||
try {
|
||||
config.save(file.getFile());
|
||||
BetterRTP.getInstance().getRTP().loadLocations();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void editWorld(CommandSender sendi, RTP_CMD_EDIT_SUB cmd, String world, String val) {
|
||||
Object value;
|
||||
try {
|
||||
@ -137,7 +182,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
|
||||
try {
|
||||
config.save(file.getFile());
|
||||
BetterRTP.getInstance().getRTP().loadCustomWorlds();
|
||||
BetterRTP.getInstance().getRTP().loadWorlds();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -165,7 +210,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
|
||||
try {
|
||||
config.save(file.getFile());
|
||||
BetterRTP.getInstance().getRTP().loadCustomWorlds();
|
||||
BetterRTP.getInstance().getRTP().loadWorlds();
|
||||
BetterRTP.getInstance().getText().getEditSet(sendi, cmd.get(), val);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -289,7 +334,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
switch (cmd) {
|
||||
case WORLD_TYPE:
|
||||
case OVERRIDE:
|
||||
case WORLD: //List all worlds
|
||||
case CUSTOMWORLD: //List all worlds
|
||||
for (World world : Bukkit.getWorlds())
|
||||
if (world.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||
list.add(world.getName());
|
||||
@ -307,7 +352,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||
if (cmd.name().equalsIgnoreCase(args[1]))
|
||||
switch (cmd) {
|
||||
case WORLD:
|
||||
case CUSTOMWORLD:
|
||||
list.addAll(tabCompleteSub(args, cmd)); break;
|
||||
case DEFAULT:
|
||||
if (args[2].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_X.name()))
|
||||
@ -344,7 +389,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
} else if (args.length == 5) {
|
||||
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||
if (cmd.name().equalsIgnoreCase(args[1]))
|
||||
if (cmd == RTP_CMD_EDIT.WORLD) {
|
||||
if (cmd == RTP_CMD_EDIT.CUSTOMWORLD) {
|
||||
if (args[3].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_X.name()))
|
||||
list.add(String.valueOf(((Player) sendi).getLocation().getBlockX()));
|
||||
else if (args[3].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_Z.name()))
|
||||
@ -382,7 +427,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
switch (type) {
|
||||
case DEFAULT:
|
||||
BetterRTP.getInstance().getText().getUsageEditDefault(sendi, label); break;
|
||||
case WORLD:
|
||||
case CUSTOMWORLD:
|
||||
BetterRTP.getInstance().getText().getUsageEditWorld(sendi, label); break;
|
||||
case WORLD_TYPE:
|
||||
BetterRTP.getInstance().getText().getUsageWorldtype(sendi, label); break;
|
||||
@ -401,14 +446,16 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
||||
}
|
||||
|
||||
enum RTP_CMD_EDIT {
|
||||
WORLD, DEFAULT, WORLD_TYPE, OVERRIDE, BLACKLISTEDBLOCKS
|
||||
CUSTOMWORLD, LOCATION, DEFAULT, WORLD_TYPE, OVERRIDE, BLACKLISTEDBLOCKS
|
||||
}
|
||||
|
||||
enum RTP_CMD_EDIT_SUB { //Only for World and Default
|
||||
CENTER_X("CenterX", "INT"),
|
||||
CENTER_Z("CenterZ", "INT"),
|
||||
MAX("MaxRadius", "INT"),
|
||||
MIN("MinRadius", "INT"),
|
||||
MAXRAD("MaxRadius", "INT"),
|
||||
MINRAD("MinRadius", "INT"),
|
||||
MAXY("MaxY", "INT"),
|
||||
MINY("MinY", "INT"),
|
||||
PRICE("Price", "INT"),
|
||||
SHAPE("Shape", "SHAPE"),
|
||||
//BIOME_ADD("Biomes", "STR"),
|
||||
|
@ -44,16 +44,20 @@ public class RTP {
|
||||
RTPLoader.loadOverrides(overriden);
|
||||
//WorldType
|
||||
RTPLoader.loadWorldTypes(world_type);
|
||||
//CustomWorlds
|
||||
loadCustomWorlds();
|
||||
//Worlds & CustomWorlds
|
||||
RTPLoader.loadWorlds(defaultWorld, customWorlds);
|
||||
//Locations
|
||||
RTPLoader.loadWorldLocations(worldLocations);
|
||||
RTPLoader.loadLocations(worldLocations);
|
||||
teleport.load(); //Load teleporting stuff
|
||||
permConfig.load(); //Load permission configs
|
||||
}
|
||||
|
||||
public void loadCustomWorlds() { //Keeping this here because of the edit command
|
||||
RTPLoader.loadCustomWorlds(defaultWorld, customWorlds);
|
||||
public void loadWorlds() { //Keeping this here because of the edit command
|
||||
RTPLoader.loadWorlds(defaultWorld, customWorlds);
|
||||
}
|
||||
|
||||
public void loadLocations() { //Keeping this here because of the edit command
|
||||
RTPLoader.loadLocations(worldLocations);
|
||||
}
|
||||
|
||||
public WorldPlayer getPlayerWorld(RTPSetupInformation setup_info) {
|
||||
|
@ -13,8 +13,8 @@ import java.util.Map;
|
||||
|
||||
public class RTPLoader {
|
||||
|
||||
static void loadCustomWorlds(@NotNull WorldDefault defaultWorld, @NotNull HashMap<String, RTPWorld> customWorlds) {
|
||||
defaultWorld.setup();
|
||||
static void loadWorlds(@NotNull WorldDefault defaultWorld, @NotNull HashMap<String, RTPWorld> customWorlds) {
|
||||
defaultWorld.load();
|
||||
customWorlds.clear();
|
||||
try {
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
@ -84,7 +84,7 @@ public class RTPLoader {
|
||||
}
|
||||
}
|
||||
|
||||
static void loadWorldLocations(@NotNull HashMap<String, RTPWorld> worlds) {
|
||||
static void loadLocations(@NotNull HashMap<String, RTPWorld> worlds) {
|
||||
worlds.clear();
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.LOCATIONS;
|
||||
if (!config.getBoolean("Enabled"))
|
||||
@ -95,7 +95,6 @@ public class RTPLoader {
|
||||
WorldLocations location = new WorldLocations(entry.getKey().toString());
|
||||
if (location.isValid()) {
|
||||
worlds.put(entry.getKey().toString(), location);
|
||||
if (getPl().getSettings().isDebug())
|
||||
BetterRTP.debug("- Location '" + entry.getKey() + "' registered");
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ package me.SuperRonanCraft.BetterRTP.references.rtpinfo.worlds;
|
||||
import me.SuperRonanCraft.BetterRTP.player.rtp.RTP_SHAPE;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -19,7 +18,7 @@ public class WorldDefault implements RTPWorld {
|
||||
private final HashMap<String, Integer> prices = new HashMap<>();
|
||||
private RTP_SHAPE shape;
|
||||
|
||||
public void setup() {
|
||||
public void load() {
|
||||
//Setups
|
||||
String pre = "Default";
|
||||
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
|
Loading…
x
Reference in New Issue
Block a user