diff --git a/pom.xml b/pom.xml
index 300579b..f5fcda5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.SuperRonanCraft
BetterRTP
- 2.14.0
+ 2.14.1
1.8
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/Main.java b/src/main/java/me/SuperRonanCraft/BetterRTP/Main.java
index 8980a99..a82b014 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/Main.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/Main.java
@@ -1,9 +1,9 @@
package me.SuperRonanCraft.BetterRTP;
import me.SuperRonanCraft.BetterRTP.player.PlayerInfo;
-import me.SuperRonanCraft.BetterRTP.player.rtp.RTP;
import me.SuperRonanCraft.BetterRTP.player.commands.Commands;
import me.SuperRonanCraft.BetterRTP.player.events.Listener;
+import me.SuperRonanCraft.BetterRTP.player.rtp.RTP;
import me.SuperRonanCraft.BetterRTP.references.depends.DepEconomy;
import me.SuperRonanCraft.BetterRTP.references.Permissions;
import me.SuperRonanCraft.BetterRTP.references.Updater;
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdEdit.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdEdit.java
index a03fc9a..b420f2d 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdEdit.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdEdit.java
@@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.*;
@@ -138,7 +139,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
list.add(cmd.name().toLowerCase());
} else if (args.length == 3) {
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
- if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase())) {
+ if (cmd.name().equalsIgnoreCase(args[1])) {
switch (cmd) {
case WORLD: //List all worlds
for (World world : Bukkit.getWorlds())
@@ -151,9 +152,26 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
}
} else if (args.length == 4) {
for (RTP_CMD_EDIT cmd : RTP_CMD_EDIT.values())
- if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase()))
- if (cmd == RTP_CMD_EDIT.WORLD)
- list.addAll(tabCompleteSub(args));
+ if (cmd.name().equalsIgnoreCase(args[1]))
+ switch (cmd) {
+ case WORLD:
+ list.addAll(tabCompleteSub(args)); break;
+ case DEFAULT:
+ if (args[2].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_X.name()))
+ list.add(String.valueOf(((Player) sendi).getLocation().getBlockX()));
+ else if (args[2].equalsIgnoreCase(RTP_CMD_EDIT_SUB.CENTER_Z.name()))
+ list.add(String.valueOf(((Player) sendi).getLocation().getBlockZ()));
+ break;
+ }
+ } 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 (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()))
+ list.add(String.valueOf(((Player) sendi).getLocation().getBlockZ()));
+ }
}
return list;
}
@@ -195,7 +213,7 @@ public class CmdEdit implements RTPCommand, RTPCommandHelpable { //Edit a worlds
enum RTP_CMD_EDIT_SUB {
CENTER_X("CenterX", "INT"),
- CENTER_Y("CenterY", "INT"),
+ CENTER_Z("CenterZ", "INT"),
MAX("MaxRadius", "INT"),
MIN("MinRadius", "INT"),
USEWORLDBORDER("UseWorldBorder", "BOL");
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdInfo.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdInfo.java
index fd9ae92..525aeb9 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdInfo.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/types/CmdInfo.java
@@ -64,9 +64,7 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
Main pl = Main.getInstance();
for (ParticleEffect eff : ParticleEffect.VALUES) {
- if (info.isEmpty()) {
- info.add("&7" + eff.name() + "&r");
- } else if (info.size() % 2 == 0) {
+ if (info.isEmpty() || info.size() % 2 == 0) {
info.add("&7" + eff.name() + "&r");
} else
info.add("&f" + eff.name() + "&r");
@@ -82,9 +80,7 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
List info = new ArrayList<>();
for (String shape : RTPParticles.shapeTypes) {
- if (info.isEmpty()) {
- info.add("&7" + shape + "&r");
- } else if (info.size() % 2 == 0) {
+ if (info.isEmpty() || info.size() % 2 == 0) {
info.add("&7" + shape + "&r");
} else
info.add("&f" + shape + "&r");
@@ -97,7 +93,7 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
//World
private void sendInfoWorld(CommandSender sendi, List list) { //Send info
- list.add(0, "&e&m-----&6 BetterRTP Info &e&m-----");
+ list.add(0, "&e&m-----&6 BetterRTP &8| Info &e&m-----");
list.forEach(str ->
list.set(list.indexOf(str), Main.getInstance().getText().color(str)));
sendi.sendMessage(list.toArray(new String[0]));
@@ -144,9 +140,7 @@ public class CmdInfo implements RTPCommand, RTPCommandHelpable {
List info = new ArrayList<>();
for (PotionEffectType effect : PotionEffectType.values()) {
- if (info.isEmpty()) {
- info.add("&7" + effect.getName() + "&r");
- } else if (info.size() % 2 == 0) {
+ if (info.isEmpty() || info.size() % 2 == 0) {
info.add("&7" + effect.getName() + "&r");
} else
info.add("&f" + effect.getName() + "&r");
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Leave.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Leave.java
index 594c074..cb92040 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Leave.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Leave.java
@@ -5,9 +5,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
class Leave {
- @SuppressWarnings("unchecked")
void event(PlayerQuitEvent e) {
- if (Main.getInstance().getCmd().rtping.containsKey(e.getPlayer().getUniqueId()))
- Main.getInstance().getCmd().rtping.remove(e.getPlayer().getUniqueId());
+ Main.getInstance().getCmd().rtping.remove(e.getPlayer().getUniqueId());
}
}
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java
index e75e6dd..a5b80a9 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java
@@ -1,34 +1,29 @@
package me.SuperRonanCraft.BetterRTP.player.rtp;
-import io.papermc.lib.PaperLib;
import me.SuperRonanCraft.BetterRTP.Main;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import me.SuperRonanCraft.BetterRTP.references.worlds.*;
import org.bukkit.Bukkit;
-import org.bukkit.Chunk;
-import org.bukkit.Location;
import org.bukkit.World;
-import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.CompletableFuture;
public class RTP {
- private final RTPTeleport teleport = new RTPTeleport();
- private final RTPPluginValidation softDepends = new RTPPluginValidation();
+ final RTPTeleport teleport = new RTPTeleport();
+ final RTPPluginValidation softDepends = new RTPPluginValidation();
public final RTPPermissionGroup permConfig = new RTPPermissionGroup();
//Cache
public HashMap customWorlds = new HashMap<>();
public HashMap overriden = new HashMap<>();
public WorldDefault defaultWorld = new WorldDefault();
- private List disabledWorlds, blockList;
- private int maxAttempts, delayTime;
- private boolean cancelOnMove, cancelOnDamage;
+ List disabledWorlds, blockList;
+ int maxAttempts, delayTime;
+ boolean cancelOnMove, cancelOnDamage;
public HashMap world_type = new HashMap<>();
public RTPTeleport getTeleport() {
@@ -137,148 +132,11 @@ public class RTP {
return pWorld;
}
- public void start(Player p, CommandSender sendi, String worldName, List biomes, boolean delay) {
- // Check overrides
- if (worldName == null)
- worldName = p.getWorld().getName();
- if (overriden.containsKey(worldName))
- worldName = overriden.get(worldName);
- // Not forced and has 'betterrtp.world.'
- if (sendi == p && !getPl().getPerms().getAWorld(sendi, worldName)) {
- //getPl().getCmd().cooldowns.remove(p.getUniqueId());
- getPl().getText().getNoPermissionWorld(p, worldName);
- return;
- }
- // Check disabled worlds
- if (disabledWorlds.contains(worldName)) {
- getPl().getText().getDisabledWorld(sendi, worldName);
- //getPl().getCmd().cooldowns.remove(p.getUniqueId());
- return;
- }
- // Check if nulled or world doesnt exist
- if (Bukkit.getWorld(worldName) == null) {
- getPl().getText().getNotExist(sendi, worldName);
- //getPl().getCmd().cooldowns.remove(p.getUniqueId());
- return;
- }
- WorldPlayer pWorld = getPlayerWorld(p, worldName, biomes, true);
- // Economy
- if (!getPl().getEco().charge(p, pWorld.getPrice())) {
- //getPl().getCmd().cooldowns.remove(p.getUniqueId());
- return;
- }
- //Cooldown
- getPl().getCmd().cooldowns.add(p.getUniqueId());
- // Delaying? Else, just go
- getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing
- if (getPl().getSettings().delayEnabled && delay) {
- new RTPDelay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage);
- } else {
- teleport.beforeTeleportInstant(p);
- findSafeLocation(sendi, pWorld);
- }
- }
-
- void findSafeLocation(CommandSender sendi, WorldPlayer pWorld) {
- if (pWorld.getAttempts() >= maxAttempts) //Cancel out, too many tried
- metMax(sendi, pWorld.getPlayer(), pWorld.getPrice());
- else { //Try again to find a safe location
- Location loc = pWorld.generateRandomXZ(defaultWorld); //randomLoc(pWorld);
- CompletableFuture chunk = PaperLib.getChunkAtAsync(pWorld.getWorld(), loc.getBlockX(), loc.getBlockZ());
- chunk.thenAccept(result -> {
- Location tpLoc;
- float yaw = pWorld.getPlayer().getLocation().getYaw();
- float pitch = pWorld.getPlayer().getLocation().getPitch();
- switch (pWorld.getWorldtype()) { //Get a Y position and check for bad blocks
- case NETHER:
- tpLoc = getLocAtNether(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld); break;
- case NORMAL:
- default:
- tpLoc = getLocAtNormal(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld);
- }
- if (tpLoc != null && checkDepends(tpLoc))
- teleport.sendPlayer(sendi, pWorld.getPlayer(), tpLoc, pWorld.getPrice(), pWorld.getAttempts());
- else
- findSafeLocation(sendi, pWorld);
- });
- }
- }
-
- // Compressed code for MaxAttempts being met
- private void metMax(CommandSender sendi, Player p, int price) {
- if (p == sendi)
- getPl().getText().getFailedNotSafe(sendi, maxAttempts);
- else
- getPl().getText().getOtherNotSafe(sendi, maxAttempts, p.getDisplayName());
- getPl().getCmd().cooldowns.remove(p.getUniqueId());
- getPl().getEco().unCharge(p, price);
- getPl().getCmd().rtping.put(p.getUniqueId(), false);
- }
-
- private Location getLocAtNormal(int x, int z, World world, Float yaw, Float pitch, WorldPlayer pWorld) {
- Block b = world.getHighestBlockAt(x, z);
- if (b.getType().toString().endsWith("AIR")) //1.15.1 or less
- b = world.getBlockAt(x, b.getY() - 1, z);
- else if (!b.getType().isSolid()) { //Water, lava, shrubs...
- if (!badBlock(b.getType().name(), x, z, pWorld.getWorld(), null)) { //Make sure it's not an invalid block (ex: water, lava...)
- //int y = world.getHighestBlockYAt(x, z);
- b = world.getBlockAt(x, b.getY() - 1, z);
- }
- }
- //System.out.println(b.getType().name());
- 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 getLocAtNether(int x, int z, World world, Float yaw, Float pitch, WorldPlayer pWorld) {
- //System.out.println("-----------");
- for (int y = 1; y < world.getMaxHeight(); y++) {
- // System.out.println("--");
- Block block_current = world.getBlockAt(x, y, z);
- //System.out.println(block_current.getType().name());
- if (block_current.getType().name().endsWith("AIR") || !block_current.getType().isSolid()) {
- //System.out.println(block_current.getType().name());
- if (!block_current.getType().name().endsWith("AIR") &&
- !block_current.getType().isSolid()) { //Block is not a solid (ex: lava, water...)
- String block_in = block_current.getType().name();
- if (badBlock(block_in, x, z, pWorld.getWorld(), null))
- continue;//return null;
- }
- //System.out.println(block_current.getType().name());
- String block = world.getBlockAt(x, y - 1, z).getType().name();
- if (block.endsWith("AIR")) //Block below is air, skip
- continue;
- if (world.getBlockAt(x, y + 1, z).getType().name().endsWith("AIR") //Head space
- && !badBlock(block, x, z, pWorld.getWorld(), pWorld.getBiomes())) //Valid block
- return new Location(world, (x + 0.5), y, (z + 0.5), yaw, pitch);
- }
- }
- return null;
- }
-
- private boolean checkDepends(Location loc) {
- return softDepends.checkLocation(loc);
- }
-
- // Bad blocks, or bad biome
- private boolean badBlock(String block, int x, int z, World world, List biomes) {
- for (String currentBlock : blockList) //Check Block
- if (currentBlock.toUpperCase().equals(block))
- return true;
- //Check Biomes
- if (biomes == null || biomes.isEmpty())
- return false;
- String biomeCurrent = world.getBiome(x, z).name();
- for (String biome : biomes)
- if (biomeCurrent.toUpperCase().contains(biome.toUpperCase()))
- return false;
- return true;
- //FALSE MEANS NO BAD BLOCKS/BIOME WHERE FOUND!
- }
-
private Main getPl() {
return Main.getInstance();
}
+
+ public void start(Player p, CommandSender sendi, String world_name, List biomes, boolean delay) {
+ new RTPPlayer(p, this).teleport(sendi, world_name, biomes, delay);
+ }
}
\ No newline at end of file
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPDelay.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPDelay.java
index 3a4b620..2286e30 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPDelay.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPDelay.java
@@ -15,11 +15,13 @@ class RTPDelay implements Listener {
private int run;
private final WorldPlayer pWorld;
private final boolean cancelOnMove, cancelOnDamage;
+ private final RTPPlayer rtp;
- RTPDelay(CommandSender sendi, WorldPlayer pWorld, int delay, boolean cancelOnMove, boolean cancelOnDamage) {
+ RTPDelay(CommandSender sendi, RTPPlayer rtp, WorldPlayer pWorld, int delay, boolean cancelOnMove, boolean cancelOnDamage) {
this.pWorld = pWorld;
this.cancelOnMove = cancelOnMove;
this.cancelOnDamage = cancelOnDamage;
+ this.rtp = rtp;
delay(sendi, delay);
}
@@ -68,17 +70,8 @@ class RTPDelay implements Listener {
private Runnable run(final CommandSender sendi, final RTPDelay cls) {
return () -> {
HandlerList.unregisterAll(cls);
- if (getPl().getCmd().rtping.containsKey(pWorld.getPlayer().getUniqueId())) {
- try {
- getPl().getRTP().findSafeLocation(sendi, pWorld);
- } catch (NullPointerException e) {
- if (pWorld.getPrice() > 0)
- getPl().getEco().unCharge(pWorld.getPlayer(), pWorld.getPrice());
- }
- getPl().getCmd().rtping.put(pWorld.getPlayer().getUniqueId(), false);
- } else if (pWorld.getPrice() > 0)
- getPl().getEco().unCharge(pWorld.getPlayer(), pWorld.getPrice());
- Bukkit.getScheduler().cancelTask(run);
+ if (getPl().getCmd().rtping.containsKey(pWorld.getPlayer().getUniqueId()))
+ rtp.findSafeLocation(sendi, pWorld);
};
}
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPPlayer.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPPlayer.java
new file mode 100644
index 0000000..5216560
--- /dev/null
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPPlayer.java
@@ -0,0 +1,171 @@
+package me.SuperRonanCraft.BetterRTP.player.rtp;
+
+import io.papermc.lib.PaperLib;
+import me.SuperRonanCraft.BetterRTP.Main;
+import me.SuperRonanCraft.BetterRTP.references.worlds.*;
+import org.bukkit.Bukkit;
+import org.bukkit.Chunk;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
+public class RTPPlayer {
+
+ private final Player p;
+ private final RTP settings;
+
+ RTPPlayer(Player p, RTP settings) {
+ this.p = p;
+ this.settings = settings;
+ }
+
+ public void teleport(CommandSender sendi, String worldName, List biomes, boolean delay) {
+ // Check overrides
+ if (worldName == null)
+ worldName = p.getWorld().getName();
+ if (settings.overriden.containsKey(worldName))
+ worldName = settings.overriden.get(worldName);
+ // Not forced and has 'betterrtp.world.'
+ if (sendi == p && !getPl().getPerms().getAWorld(sendi, worldName)) {
+ //getPl().getCmd().cooldowns.remove(p.getUniqueId());
+ getPl().getText().getNoPermissionWorld(p, worldName);
+ return;
+ }
+ // Check disabled worlds
+ if (settings.disabledWorlds.contains(worldName)) {
+ getPl().getText().getDisabledWorld(sendi, worldName);
+ //getPl().getCmd().cooldowns.remove(p.getUniqueId());
+ return;
+ }
+ // Check if nulled or world doesnt exist
+ if (Bukkit.getWorld(worldName) == null) {
+ getPl().getText().getNotExist(sendi, worldName);
+ //getPl().getCmd().cooldowns.remove(p.getUniqueId());
+ return;
+ }
+ WorldPlayer pWorld = settings.getPlayerWorld(p, worldName, biomes, true);
+ // Economy
+ if (!getPl().getEco().charge(p, pWorld.getPrice())) {
+ //getPl().getCmd().cooldowns.remove(p.getUniqueId());
+ return;
+ }
+ //Cooldown
+ getPl().getCmd().cooldowns.add(p.getUniqueId());
+ // Delaying? Else, just go
+ getPl().getCmd().rtping.put(p.getUniqueId(), true); //Cache player so they cant run '/rtp' again while rtp'ing
+ if (getPl().getSettings().delayEnabled && delay) {
+ new RTPDelay(sendi, this, pWorld, settings.delayTime, settings.cancelOnMove, settings.cancelOnDamage);
+ } else {
+ settings.teleport.beforeTeleportInstant(p);
+ findSafeLocation(sendi, pWorld);
+ }
+ }
+
+ void findSafeLocation(CommandSender sendi, WorldPlayer pWorld) {
+ if (pWorld.getAttempts() >= settings.maxAttempts) //Cancel out, too many tried
+ metMax(sendi, pWorld.getPlayer(), pWorld.getPrice());
+ else { //Try again to find a safe location
+ Location loc = pWorld.generateRandomXZ(settings.defaultWorld); //randomLoc(pWorld);
+ CompletableFuture chunk = PaperLib.getChunkAtAsync(pWorld.getWorld(), loc.getBlockX(), loc.getBlockZ());
+ chunk.thenAccept(result -> {
+ Location tpLoc;
+ float yaw = pWorld.getPlayer().getLocation().getYaw();
+ float pitch = pWorld.getPlayer().getLocation().getPitch();
+ switch (pWorld.getWorldtype()) { //Get a Y position and check for bad blocks
+ case NETHER:
+ tpLoc = getLocAtNether(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld); break;
+ case NORMAL:
+ default:
+ tpLoc = getLocAtNormal(loc.getBlockX(), loc.getBlockZ(), pWorld.getWorld(), yaw, pitch, pWorld);
+ }
+ if (tpLoc != null && checkDepends(tpLoc))
+ settings.teleport.sendPlayer(sendi, pWorld.getPlayer(), tpLoc, pWorld.getPrice(), pWorld.getAttempts());
+ else
+ findSafeLocation(sendi, pWorld);
+ });
+ }
+ }
+
+ // Compressed code for MaxAttempts being met
+ private void metMax(CommandSender sendi, Player p, int price) {
+ if (p == sendi)
+ getPl().getText().getFailedNotSafe(sendi, settings.maxAttempts);
+ else
+ getPl().getText().getOtherNotSafe(sendi, settings.maxAttempts, p.getDisplayName());
+ getPl().getCmd().cooldowns.remove(p.getUniqueId());
+ getPl().getEco().unCharge(p, price);
+ getPl().getCmd().rtping.put(p.getUniqueId(), false);
+ }
+
+ private Location getLocAtNormal(int x, int z, World world, Float yaw, Float pitch, WorldPlayer pWorld) {
+ Block b = world.getHighestBlockAt(x, z);
+ if (b.getType().toString().endsWith("AIR")) //1.15.1 or less
+ b = world.getBlockAt(x, b.getY() - 1, z);
+ else if (!b.getType().isSolid()) { //Water, lava, shrubs...
+ if (!badBlock(b.getType().name(), x, z, pWorld.getWorld(), null)) { //Make sure it's not an invalid block (ex: water, lava...)
+ //int y = world.getHighestBlockYAt(x, z);
+ b = world.getBlockAt(x, b.getY() - 1, z);
+ }
+ }
+ //System.out.println(b.getType().name());
+ 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 getLocAtNether(int x, int z, World world, Float yaw, Float pitch, WorldPlayer pWorld) {
+ //System.out.println("-----------");
+ for (int y = 1; y < world.getMaxHeight(); y++) {
+ // System.out.println("--");
+ Block block_current = world.getBlockAt(x, y, z);
+ //System.out.println(block_current.getType().name());
+ if (block_current.getType().name().endsWith("AIR") || !block_current.getType().isSolid()) {
+ //System.out.println(block_current.getType().name());
+ if (!block_current.getType().name().endsWith("AIR") &&
+ !block_current.getType().isSolid()) { //Block is not a solid (ex: lava, water...)
+ String block_in = block_current.getType().name();
+ if (badBlock(block_in, x, z, pWorld.getWorld(), null))
+ continue;//return null;
+ }
+ //System.out.println(block_current.getType().name());
+ String block = world.getBlockAt(x, y - 1, z).getType().name();
+ if (block.endsWith("AIR")) //Block below is air, skip
+ continue;
+ if (world.getBlockAt(x, y + 1, z).getType().name().endsWith("AIR") //Head space
+ && !badBlock(block, x, z, pWorld.getWorld(), pWorld.getBiomes())) //Valid block
+ return new Location(world, (x + 0.5), y, (z + 0.5), yaw, pitch);
+ }
+ }
+ return null;
+ }
+
+ private boolean checkDepends(Location loc) {
+ return settings.softDepends.checkLocation(loc);
+ }
+
+ // Bad blocks, or bad biome
+ private boolean badBlock(String block, int x, int z, World world, List biomes) {
+ for (String currentBlock : settings.blockList) //Check Block
+ if (currentBlock.toUpperCase().equals(block))
+ return true;
+ //Check Biomes
+ if (biomes == null || biomes.isEmpty())
+ return false;
+ String biomeCurrent = world.getBiome(x, z).name();
+ for (String biome : biomes)
+ if (biomeCurrent.toUpperCase().contains(biome.toUpperCase()))
+ return false;
+ return true;
+ //FALSE MEANS NO BAD BLOCKS/BIOME WHERE FOUND!
+ }
+
+ private Main getPl() {
+ return Main.getInstance();
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 6f47a3d..8724b62 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
main: me.SuperRonanCraft.BetterRTP.Main
-version: '2.14.0'
+version: '2.14.1'
name: BetterRTP
author: SuperRonanCraft
softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect]