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())
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase())) {
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case WORLD:
|
case CUSTOMWORLD:
|
||||||
if (args.length >= 5) {
|
if (args.length >= 5) {
|
||||||
for (World world : Bukkit.getWorlds()) {
|
for (World world : Bukkit.getWorlds()) {
|
||||||
if (world.getName().startsWith(args[2])) {
|
if (world.getName().startsWith(args[2])) {
|
||||||
@ -94,6 +94,51 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
|||||||
usage(sendi, label, null);
|
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) {
|
private void editWorld(CommandSender sendi, RTP_CMD_EDIT_SUB cmd, String world, String val) {
|
||||||
Object value;
|
Object value;
|
||||||
try {
|
try {
|
||||||
@ -137,7 +182,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
config.save(file.getFile());
|
config.save(file.getFile());
|
||||||
BetterRTP.getInstance().getRTP().loadCustomWorlds();
|
BetterRTP.getInstance().getRTP().loadWorlds();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -165,7 +210,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
config.save(file.getFile());
|
config.save(file.getFile());
|
||||||
BetterRTP.getInstance().getRTP().loadCustomWorlds();
|
BetterRTP.getInstance().getRTP().loadWorlds();
|
||||||
BetterRTP.getInstance().getText().getEditSet(sendi, cmd.get(), val);
|
BetterRTP.getInstance().getText().getEditSet(sendi, cmd.get(), val);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -289,7 +334,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
|||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case WORLD_TYPE:
|
case WORLD_TYPE:
|
||||||
case OVERRIDE:
|
case OVERRIDE:
|
||||||
case WORLD: //List all worlds
|
case CUSTOMWORLD: //List all worlds
|
||||||
for (World world : Bukkit.getWorlds())
|
for (World world : Bukkit.getWorlds())
|
||||||
if (world.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
if (world.getName().toLowerCase().startsWith(args[2].toLowerCase()))
|
||||||
list.add(world.getName());
|
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())
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
if (cmd.name().equalsIgnoreCase(args[1]))
|
if (cmd.name().equalsIgnoreCase(args[1]))
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case WORLD:
|
case CUSTOMWORLD:
|
||||||
list.addAll(tabCompleteSub(args, cmd)); break;
|
list.addAll(tabCompleteSub(args, cmd)); break;
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
if (args[2].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_X.name()))
|
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) {
|
} else if (args.length == 5) {
|
||||||
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
|
||||||
if (cmd.name().equalsIgnoreCase(args[1]))
|
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()))
|
if (args[3].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_X.name()))
|
||||||
list.add(String.valueOf(((Player) sendi).getLocation().getBlockX()));
|
list.add(String.valueOf(((Player) sendi).getLocation().getBlockX()));
|
||||||
else if (args[3].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_Z.name()))
|
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) {
|
switch (type) {
|
||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
BetterRTP.getInstance().getText().getUsageEditDefault(sendi, label); break;
|
BetterRTP.getInstance().getText().getUsageEditDefault(sendi, label); break;
|
||||||
case WORLD:
|
case CUSTOMWORLD:
|
||||||
BetterRTP.getInstance().getText().getUsageEditWorld(sendi, label); break;
|
BetterRTP.getInstance().getText().getUsageEditWorld(sendi, label); break;
|
||||||
case WORLD_TYPE:
|
case WORLD_TYPE:
|
||||||
BetterRTP.getInstance().getText().getUsageWorldtype(sendi, label); break;
|
BetterRTP.getInstance().getText().getUsageWorldtype(sendi, label); break;
|
||||||
@ -401,14 +446,16 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
|
|||||||
}
|
}
|
||||||
|
|
||||||
enum RTP_CMD_EDIT {
|
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
|
enum RTP_CMD_EDIT_SUB { //Only for World and Default
|
||||||
CENTER_X("CenterX", "INT"),
|
CENTER_X("CenterX", "INT"),
|
||||||
CENTER_Z("CenterZ", "INT"),
|
CENTER_Z("CenterZ", "INT"),
|
||||||
MAX("MaxRadius", "INT"),
|
MAXRAD("MaxRadius", "INT"),
|
||||||
MIN("MinRadius", "INT"),
|
MINRAD("MinRadius", "INT"),
|
||||||
|
MAXY("MaxY", "INT"),
|
||||||
|
MINY("MinY", "INT"),
|
||||||
PRICE("Price", "INT"),
|
PRICE("Price", "INT"),
|
||||||
SHAPE("Shape", "SHAPE"),
|
SHAPE("Shape", "SHAPE"),
|
||||||
//BIOME_ADD("Biomes", "STR"),
|
//BIOME_ADD("Biomes", "STR"),
|
||||||
|
@ -44,16 +44,20 @@ public class RTP {
|
|||||||
RTPLoader.loadOverrides(overriden);
|
RTPLoader.loadOverrides(overriden);
|
||||||
//WorldType
|
//WorldType
|
||||||
RTPLoader.loadWorldTypes(world_type);
|
RTPLoader.loadWorldTypes(world_type);
|
||||||
//CustomWorlds
|
//Worlds & CustomWorlds
|
||||||
loadCustomWorlds();
|
RTPLoader.loadWorlds(defaultWorld, customWorlds);
|
||||||
//Locations
|
//Locations
|
||||||
RTPLoader.loadWorldLocations(worldLocations);
|
RTPLoader.loadLocations(worldLocations);
|
||||||
teleport.load(); //Load teleporting stuff
|
teleport.load(); //Load teleporting stuff
|
||||||
permConfig.load(); //Load permission configs
|
permConfig.load(); //Load permission configs
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadCustomWorlds() { //Keeping this here because of the edit command
|
public void loadWorlds() { //Keeping this here because of the edit command
|
||||||
RTPLoader.loadCustomWorlds(defaultWorld, customWorlds);
|
RTPLoader.loadWorlds(defaultWorld, customWorlds);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadLocations() { //Keeping this here because of the edit command
|
||||||
|
RTPLoader.loadLocations(worldLocations);
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldPlayer getPlayerWorld(RTPSetupInformation setup_info) {
|
public WorldPlayer getPlayerWorld(RTPSetupInformation setup_info) {
|
||||||
|
@ -13,8 +13,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class RTPLoader {
|
public class RTPLoader {
|
||||||
|
|
||||||
static void loadCustomWorlds(@NotNull WorldDefault defaultWorld, @NotNull HashMap<String, RTPWorld> customWorlds) {
|
static void loadWorlds(@NotNull WorldDefault defaultWorld, @NotNull HashMap<String, RTPWorld> customWorlds) {
|
||||||
defaultWorld.setup();
|
defaultWorld.load();
|
||||||
customWorlds.clear();
|
customWorlds.clear();
|
||||||
try {
|
try {
|
||||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
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();
|
worlds.clear();
|
||||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.LOCATIONS;
|
FileBasics.FILETYPE config = FileBasics.FILETYPE.LOCATIONS;
|
||||||
if (!config.getBoolean("Enabled"))
|
if (!config.getBoolean("Enabled"))
|
||||||
@ -95,8 +95,7 @@ public class RTPLoader {
|
|||||||
WorldLocations location = new WorldLocations(entry.getKey().toString());
|
WorldLocations location = new WorldLocations(entry.getKey().toString());
|
||||||
if (location.isValid()) {
|
if (location.isValid()) {
|
||||||
worlds.put(entry.getKey().toString(), location);
|
worlds.put(entry.getKey().toString(), location);
|
||||||
if (getPl().getSettings().isDebug())
|
BetterRTP.debug("- Location '" + entry.getKey() + "' registered");
|
||||||
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.player.rtp.RTP_SHAPE;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -19,7 +18,7 @@ public class WorldDefault implements RTPWorld {
|
|||||||
private final HashMap<String, Integer> prices = new HashMap<>();
|
private final HashMap<String, Integer> prices = new HashMap<>();
|
||||||
private RTP_SHAPE shape;
|
private RTP_SHAPE shape;
|
||||||
|
|
||||||
public void setup() {
|
public void load() {
|
||||||
//Setups
|
//Setups
|
||||||
String pre = "Default";
|
String pre = "Default";
|
||||||
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
FileBasics.FILETYPE config = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user