mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
Full Cave support - 2.11.0
This commit is contained in:
parent
75b4e5d32e
commit
bf62655925
@ -25,12 +25,12 @@ public class RTP {
|
||||
//Cache
|
||||
public HashMap<String, RTPWorld> customWorlds = new HashMap<>();
|
||||
public HashMap<String, String> overriden = new HashMap<>();
|
||||
public me.SuperRonanCraft.BetterRTP.references.worlds.Default Default = new Default();
|
||||
public Default Default = new Default();
|
||||
private Random rn = new Random();
|
||||
private List<String> disabledWorlds, blockList;
|
||||
private int maxAttempts, delayTime;
|
||||
private boolean cancelOnMove;
|
||||
private HashMap<String, RTP_WORLD_TYPE> world_type = new HashMap<>();
|
||||
public HashMap<String, RTP_WORLD_TYPE> world_type = new HashMap<>();
|
||||
|
||||
public RTP(Main pl) {
|
||||
this.pl = pl;
|
||||
@ -44,26 +44,66 @@ public class RTP {
|
||||
delayTime = config.getInt("Settings.Delay.Time");
|
||||
cancelOnMove = config.getBoolean("Settings.Delay.CancelOnMove");
|
||||
blockList = config.getStringList("BlacklistedBlocks");
|
||||
//OVER-RIDES
|
||||
try {
|
||||
for (String s : config.getConfigurationSection("Override").getKeys(false))
|
||||
overriden.put(s, config.getString("Override." + s));
|
||||
overriden.clear();
|
||||
List<Map<?, ?>> override_map = config.getMapList("Overrides");
|
||||
for (Map<?, ?> m : override_map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
overriden.put(entry.getKey().toString(), entry.getValue().toString());
|
||||
if (pl.getSettings().debug)
|
||||
pl.getLogger().info("- Override '" + entry.getKey() + "' -> '" + entry.getValue() + "' added");
|
||||
}
|
||||
//for (String s : config.getConfigurationSection("Override").getKeys(false))
|
||||
// overriden.put(s, config.getString("Override." + s));
|
||||
} catch (Exception e) {
|
||||
//No Overrides
|
||||
}
|
||||
customWorlds.clear();
|
||||
|
||||
List<Map<?, ?>> map = config.getMapList("CustomWorlds");
|
||||
|
||||
//Find Custom World and cache values
|
||||
for (Map<?, ?> m : map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet())
|
||||
customWorlds.put(entry.getKey().toString(), new Custom(entry.getKey().toString()));
|
||||
//CUSTOM WORLDS
|
||||
try {
|
||||
customWorlds.clear();
|
||||
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()));
|
||||
if (pl.getSettings().debug)
|
||||
pl.getLogger().info("- Custom World '" + entry.getKey() + "' registered");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//No Custom Worlds
|
||||
}
|
||||
|
||||
try {
|
||||
world_type.clear();
|
||||
for (World world : Bukkit.getWorlds())
|
||||
world_type.put(world.getName(), RTP_WORLD_TYPE.NORMAL);
|
||||
List<Map<?, ?>> world_map = config.getMapList("WorldType");
|
||||
for (Map<?, ?> m : world_map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet())
|
||||
world_type.put(entry.getKey().toString(), RTP_WORLD_TYPE.valueOf(entry.getKey().toString()));
|
||||
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.put(entry.getKey().toString(), type);
|
||||
} catch(IllegalArgumentException e) {
|
||||
StringBuilder valids = new StringBuilder();
|
||||
for (RTP_WORLD_TYPE type : RTP_WORLD_TYPE.values())
|
||||
valids.append(type.name()).append(", ");
|
||||
valids.replace(valids.length() - 2, valids.length(), "");
|
||||
pl.getLogger().severe("World Type for '" + entry.getKey() + "' is INVALID '" + entry.getValue() +
|
||||
"'. Valid ID's are: " + valids.toString());
|
||||
//Wrong rtp world type
|
||||
}
|
||||
}/* else {
|
||||
if (pl.getSettings().debug)
|
||||
pl.getLogger().info("- World Type failed for '" + entry.getKey() + "' is it loaded?");
|
||||
}*/
|
||||
}
|
||||
if (pl.getSettings().debug)
|
||||
for (String world : world_type.keySet())
|
||||
pl.getLogger().info("- World Type for '" + world + "' set to '" + world_type.get(world) + "'");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//No World Types
|
||||
}
|
||||
}
|
||||
@ -184,7 +224,7 @@ public class RTP {
|
||||
p.playSound(p.getLocation(), sound, 1F, 1F);
|
||||
}
|
||||
|
||||
// Compressed code for MaxAttempts being meet
|
||||
// Compressed code for MaxAttempts being met
|
||||
private void metMax(CommandSender sendi, Player p, int price) {
|
||||
if (p == sendi)
|
||||
pl.getText().getFailedNotSafe(sendi, maxAttempts);
|
||||
@ -194,12 +234,13 @@ public class RTP {
|
||||
pl.getEco().unCharge(p, price);
|
||||
}
|
||||
|
||||
//Get a random location depending the world type
|
||||
private Location randomLoc(PlayerWorld pWorld) {
|
||||
int borderRad = pWorld.getMaxRad();
|
||||
int minVal = pWorld.getMinRad();
|
||||
int CenterX = pWorld.getCenterX();
|
||||
int CenterZ = pWorld.getCenterZ();
|
||||
int posOrNeg = rn.nextInt(4);
|
||||
int quadrant = rn.nextInt(4);
|
||||
Player p = pWorld.getPlayer();
|
||||
World world = Bukkit.getWorld(pWorld.getWorld());
|
||||
if (pWorld.getUseWorldborder()) {
|
||||
@ -209,10 +250,10 @@ public class RTP {
|
||||
CenterZ = border.getCenter().getBlockZ();
|
||||
}
|
||||
float yaw = p.getLocation().getYaw(), pitch = p.getLocation().getPitch();
|
||||
boolean normal;
|
||||
try {
|
||||
RTP_WORLD_TYPE world_type = RTP_WORLD_TYPE.NORMAL; //World rtp type
|
||||
/*try {
|
||||
//1.13+
|
||||
normal = !world.getBiome(0, 0).equals(Biome.valueOf("NETHER"));
|
||||
normal = !world.getBiome(0, 0).equals(Biome.valueOf("NETHER")));
|
||||
} catch (Exception e) {
|
||||
//1.8-1.12
|
||||
try {
|
||||
@ -220,28 +261,33 @@ public class RTP {
|
||||
} catch (Exception e1) {
|
||||
normal = true;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if (this.world_type.containsKey(world.getName()))
|
||||
world_type = this.world_type.get(world.getName());
|
||||
for (int i = 0; i <= maxAttempts; i++) {
|
||||
// Get the y-coords from up top, then check if it's SAFE!
|
||||
Location loc;
|
||||
Location loc = null;
|
||||
if (borderRad <= minVal) {
|
||||
minVal = Default.getMinRad();
|
||||
if (borderRad <= minVal)
|
||||
minVal = 0;
|
||||
}
|
||||
if (normal)
|
||||
loc = normal(borderRad, minVal, CenterX, CenterZ, posOrNeg, world, pWorld, yaw, pitch);
|
||||
else
|
||||
loc = nether(borderRad, minVal, CenterX, CenterZ, posOrNeg, world, pWorld, yaw, pitch);
|
||||
switch (world_type) {
|
||||
case NETHER:
|
||||
loc = nether(borderRad, minVal, CenterX, CenterZ, quadrant, world, pWorld, yaw, pitch); break;
|
||||
default:
|
||||
loc = normal(borderRad, minVal, CenterX, CenterZ, quadrant, world, pWorld, yaw, pitch);
|
||||
}
|
||||
pWorld.addAttempt();
|
||||
if (loc != null && checkDepends(loc))
|
||||
return loc;
|
||||
posOrNeg = rn.nextInt(4);
|
||||
quadrant = rn.nextInt(4);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location normal(int borderRad, int minVal, int CenterX, int CenterZ, int posOrNeg, World world,
|
||||
//NORMAL
|
||||
private Location normal(int borderRad, int minVal, int CenterX, int CenterZ, int quadrant, World world,
|
||||
PlayerWorld pWorld, Float yaw, Float pitch) {
|
||||
int x, x2, z, z2;
|
||||
Location loc;
|
||||
@ -253,18 +299,16 @@ public class RTP {
|
||||
// up for choosing up next
|
||||
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
|
||||
x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
|
||||
if (posOrNeg == 0)
|
||||
// Positive X and Z
|
||||
loc = getLocAtNormal(x, z, world, yaw, pitch, pWorld);
|
||||
else if (posOrNeg == 1)
|
||||
// Negative X and Z
|
||||
loc = getLocAtNormal(x2, z2, world, yaw, pitch, pWorld);
|
||||
else if (posOrNeg == 2)
|
||||
// Negative X and Positive Z
|
||||
loc = getLocAtNormal(x2, z, world, yaw, pitch, pWorld);
|
||||
else
|
||||
// Positive X and Negative Z
|
||||
switch (quadrant) {
|
||||
case 0: // Positive X and Z
|
||||
loc = getLocAtNormal(x, z, world, yaw, pitch, pWorld); break;
|
||||
case 1: // Negative X and Z
|
||||
loc = getLocAtNormal(x2, z2, world, yaw, pitch, pWorld); break;
|
||||
case 2: // Negative X and Positive Z
|
||||
loc = getLocAtNormal(x2, z, world, yaw, pitch, pWorld); break;
|
||||
default: // Positive X and Negative Z
|
||||
loc = getLocAtNormal(x, z2, world, yaw, pitch, pWorld);
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
@ -277,12 +321,13 @@ public class RTP {
|
||||
b = world.getBlockAt(x, y - 1, z);
|
||||
}
|
||||
//System.out.println(b.getType().isSolid() + " " + b.getType().name());
|
||||
if (!badBlock(b.getType().name(), x, z, pWorld.getWorld(), pWorld.getBiomes()))
|
||||
if (b.getY() > 0 && !badBlock(b.getType().name(), x, z, pWorld.getWorld(), pWorld.getBiomes()))
|
||||
return new Location(world, (x + 0.5), b.getY() + 1, (z + 0.5), yaw, pitch);
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location nether(int borderRad, int minVal, int CenterX, int CenterZ, int posOrNeg, World world,
|
||||
//NETHER
|
||||
private Location nether(int borderRad, int minVal, int CenterX, int CenterZ, int quadrant, World world,
|
||||
PlayerWorld pWorld, Float yaw, Float pitch) {
|
||||
int x, x2, z, z2;
|
||||
Location loc;
|
||||
@ -294,28 +339,33 @@ public class RTP {
|
||||
// up for choosing up next
|
||||
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
|
||||
x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
|
||||
if (posOrNeg == 0)
|
||||
// Positive X and Z
|
||||
loc = getLocAtNether(x, z, world, yaw, pitch, pWorld);
|
||||
else if (posOrNeg == 1)
|
||||
// Negative X and Z
|
||||
loc = getLocAtNether(x2, z2, world, yaw, pitch, pWorld);
|
||||
else if (posOrNeg == 2)
|
||||
// Negative X and Positive Z
|
||||
loc = getLocAtNether(x2, z, world, yaw, pitch, pWorld);
|
||||
else
|
||||
// Positive X and Negative Z
|
||||
switch (quadrant) {
|
||||
case 0: // Positive X and Z
|
||||
loc = getLocAtNether(x, z, world, yaw, pitch, pWorld); break;
|
||||
case 1: // Negative X and Z
|
||||
loc = getLocAtNether(x2, z2, world, yaw, pitch, pWorld); break;
|
||||
case 2: // Negative X and Positive Z
|
||||
loc = getLocAtNether(x2, z, world, yaw, pitch, pWorld); break;
|
||||
default: // Positive X and Negative Z
|
||||
loc = getLocAtNether(x, z2, world, yaw, pitch, pWorld);
|
||||
}
|
||||
return loc;
|
||||
}
|
||||
|
||||
private Location getLocAtNether(int x, int z, World world, Float yaw, Float pitch, PlayerWorld pWorld) {
|
||||
for (int y = 0; y < world.getMaxHeight(); y++)
|
||||
if (world.getBlockAt(x, y, z).getType().equals(Material.AIR)) {
|
||||
for (int y = 0; y < world.getMaxHeight(); y++) {
|
||||
Block b = world.getBlockAt(x, y, z);
|
||||
if (b.getType().equals(Material.AIR) || !b.getType().isSolid()) {
|
||||
String block = world.getBlockAt(x, y - 1, z).getType().name();
|
||||
if (!b.getType().isSolid()) { //Block is not a solid (ex: lava, water...)
|
||||
String block_in = b.getType().name();
|
||||
if (badBlock(block_in, x, z, pWorld.getWorld(), pWorld.getBiomes()))
|
||||
return null;
|
||||
}
|
||||
if (!badBlock(block, x, z, pWorld.getWorld(), pWorld.getBiomes()))
|
||||
return new Location(world, (x + 0.5), y, (z + 0.5), yaw, pitch);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@ public class CmdHelp implements RTPCommand {
|
||||
pl.getText().getHelpWorld(sendi, label);
|
||||
if (pl.getPerms().getReload(sendi))
|
||||
pl.getText().getHelpReload(sendi, label);
|
||||
//if (pl.getPerms().getInfo(sendi))
|
||||
// pl.getText().getHelpInfo(sendi);
|
||||
}
|
||||
|
||||
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||
|
@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.RTPWorld;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.RTP_WORLD_TYPE;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
@ -15,25 +16,27 @@ public class CmdInfo implements RTPCommand {
|
||||
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
List<String> info = new ArrayList<>();
|
||||
info.add("&6BetterRTP Info");
|
||||
info.add("&e&m-----&6 BetterRTP Info &e&m-----");
|
||||
Main pl = Main.getInstance();
|
||||
for (World w : Bukkit.getWorlds()) {
|
||||
info.add("&aWorld: &7" + w.getName());
|
||||
if (Main.getInstance().getRTP().getDisabledWorlds().contains(w.getName())) //DISABLED
|
||||
if (pl.getRTP().getDisabledWorlds().contains(w.getName())) //DISABLED
|
||||
info.add("&7- &6Disabled: &bTrue");
|
||||
else {
|
||||
info.add("&7- &6Disabled: &cFalse");
|
||||
if (Main.getInstance().getRTP().overriden.containsKey(w.getName()))
|
||||
if (pl.getRTP().overriden.containsKey(w.getName()))
|
||||
info.add("&7- &6Overriden: &bTrue");
|
||||
else {
|
||||
info.add("&7- &7WorldType: " + pl.getRTP().world_type.getOrDefault(w.getName(), RTP_WORLD_TYPE.NORMAL).name());
|
||||
info.add("&7- &6Overriden: &cFalse");
|
||||
RTPWorld _rtpworld = Main.getInstance().getRTP().Default;
|
||||
for (RTPWorld __rtpworld : Main.getInstance().getRTP().customWorlds.values()) {
|
||||
RTPWorld _rtpworld = pl.getRTP().Default;
|
||||
for (RTPWorld __rtpworld : pl.getRTP().customWorlds.values()) {
|
||||
if (__rtpworld.getWorld().equals(w.getName())) {
|
||||
_rtpworld = __rtpworld;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_rtpworld == Main.getInstance().getRTP().Default)
|
||||
if (_rtpworld == pl.getRTP().Default)
|
||||
info.add("&7- &6Custom: &cFalse");
|
||||
else
|
||||
info.add("&7- &6Custom: &bTrue");
|
||||
@ -54,7 +57,7 @@ public class CmdInfo implements RTPCommand {
|
||||
}
|
||||
}
|
||||
info.forEach(str ->
|
||||
info.set(info.indexOf(str), Main.getInstance().getText().color(str)));
|
||||
info.set(info.indexOf(str), pl.getText().color(str)));
|
||||
sendi.sendMessage(info.toArray(new String[0]));
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,17 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.settings;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
|
||||
public class Settings {
|
||||
|
||||
public boolean debug = false;
|
||||
|
||||
private SoftDepends depends = new SoftDepends();
|
||||
|
||||
public void load() { //Load Settings
|
||||
depends.load();
|
||||
debug = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG).getBoolean("Settings.Debugger");
|
||||
}
|
||||
|
||||
public SoftDepends getsDepends() {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package me.SuperRonanCraft.BetterRTP.references.worlds;
|
||||
|
||||
public enum RTP_WORLD_TYPE {
|
||||
NORMAL, //Default
|
||||
NETHER, //Nether world has different conditions
|
||||
//END //End world type, not supported yet
|
||||
NORMAL, //Normal world type finds the tallest safe block
|
||||
NETHER //Nether world types finds the lowest safe block
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
Language-File: 'en.yml'
|
||||
|
||||
Settings:
|
||||
## Output to console some debugging info
|
||||
Debugger: false
|
||||
## Respect WorldGuard areas # IN-PROGRESS
|
||||
RespectWorldGuard: false
|
||||
## Respect GriefPrevention areas # COMING SOON
|
||||
@ -24,9 +26,10 @@ Settings:
|
||||
CancelOnMove: true
|
||||
DisableUpdater: false
|
||||
|
||||
WorldType: # Available types are NETHER, NORMAL
|
||||
WorldType: # Available types are NORMAL, NETHER and END
|
||||
- world: NORMAL
|
||||
- world_nether: NETHER
|
||||
- world_the_end: NORMAL
|
||||
|
||||
Default:
|
||||
UseWorldBorder: true
|
||||
@ -44,7 +47,9 @@ BlacklistedBlocks:
|
||||
- stationary_water
|
||||
- stationary_lava
|
||||
- water
|
||||
- flowing_water
|
||||
- lava
|
||||
- flowing_lava
|
||||
- cactus
|
||||
- leaves
|
||||
- leaves_2
|
||||
@ -77,7 +82,7 @@ CustomWorlds:
|
||||
- 'forest'
|
||||
|
||||
## Override a world and rtp a player executing the command in one world, to another
|
||||
Override:
|
||||
Overrides:
|
||||
#FORMAT <CURRENT>:<OTHER>
|
||||
- world_nether: 'world'
|
||||
- creative: 'world'
|
||||
|
@ -1,9 +1,9 @@
|
||||
main: me.SuperRonanCraft.BetterRTP.Main
|
||||
version: 2.10.0
|
||||
version: 2.11.0
|
||||
name: BetterRTP
|
||||
author: SuperRonanCraft
|
||||
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]
|
||||
api-version: 1.13
|
||||
api-version: '1.13'
|
||||
|
||||
commands:
|
||||
betterrtp:
|
||||
|
Loading…
x
Reference in New Issue
Block a user