2.12.1 - Chunk async support on older servers

Reason for this change is that in previous versions on MC the spigot api would load a chunk prior to finding the tallest block in the world. So a full recode on the random location has been issued, first generating a random x/z coordinates, then loading that locations chunk, grabbing the tallest block making sure its a valid block, and then checking for griefprevention/worldguard, and then teleporting the player if its valid, else loop again until it finds a valid location, or cancel if there are too many attempts.
This commit is contained in:
SuperRonanCraft 2020-08-12 13:35:47 -04:00
parent 3b8b7b0b38
commit fd1c7c5c14
9 changed files with 244 additions and 160 deletions

View File

@ -6,7 +6,7 @@
<groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId>
<version>2.12.0</version>
<version>2.12.1</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>

View File

@ -86,14 +86,14 @@ public class CmdInfo implements RTPCommand {
else {
info.add("&7- &6WorldType: &f" + pl.getRTP().world_type.getOrDefault(w.getName(), RTP_WORLD_TYPE.NORMAL).name());
info.add("&7- &6Overriden: &cFalse");
RTPWorld _rtpworld = pl.getRTP().Default;
RTPWorld _rtpworld = pl.getRTP().defaultWorld;
for (RTPWorld __rtpworld : pl.getRTP().customWorlds.values()) {
if (__rtpworld.getWorld().equals(w.getName())) {
_rtpworld = __rtpworld;
break;
}
}
if (_rtpworld == pl.getRTP().Default)
if (_rtpworld == pl.getRTP().defaultWorld)
info.add("&7- &6Custom: &cFalse");
else
info.add("&7- &6Custom: &bTrue");

View File

@ -4,14 +4,12 @@ import com.sk89q.worldguard.bukkit.RegionContainer;
import com.sk89q.worldguard.bukkit.WGBukkit;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import io.papermc.lib.PaperLib;
import me.SuperRonanCraft.BetterRTP.Main;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import me.SuperRonanCraft.BetterRTP.references.worlds.*;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -21,6 +19,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
public class RTP {
@ -28,7 +27,7 @@ public class RTP {
//Cache
public HashMap<String, RTPWorld> customWorlds = new HashMap<>();
public HashMap<String, String> overriden = new HashMap<>();
public Default Default = new Default();
public Default defaultWorld = new Default();
private Random rn = new Random();
private List<String> disabledWorlds, blockList;
private int maxAttempts, delayTime;
@ -40,7 +39,7 @@ public class RTP {
}
public void load() {
Default.setup();
defaultWorld.setup();
FileBasics.FILETYPE config = getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG);
disabledWorlds = config.getStringList("DisabledWorlds");
maxAttempts = config.getInt("Settings.MaxAttempts");
@ -122,38 +121,42 @@ public class RTP {
return disabledWorlds;
}
public void start(Player p, CommandSender sendi, String worl, List<String> biomes, boolean delay) {
public void start(Player p, CommandSender sendi, String worldName, List<String> biomes, boolean delay) {
// Check overrides
String world = worl;
if (world == null)
world = p.getWorld().getName();
if (overriden.containsKey(world))
world = overriden.get(world);
if (worldName == null)
worldName = p.getWorld().getName();
if (overriden.containsKey(worldName))
worldName = overriden.get(worldName);
// Not forced and has 'betterrtp.world.<world>'
if (sendi == p && !getPl().getPerms().getAWorld(sendi, world)) {
if (sendi == p && !getPl().getPerms().getAWorld(sendi, worldName)) {
getPl().getCmd().cooldowns.remove(p.getUniqueId());
getPl().getText().getNoPermissionWorld(p, world);
getPl().getText().getNoPermissionWorld(p, worldName);
return;
}
// Check disabled worlds
if (disabledWorlds.contains(world)) {
getPl().getText().getDisabledWorld(sendi, world);
if (disabledWorlds.contains(worldName)) {
getPl().getText().getDisabledWorld(sendi, worldName);
getPl().getCmd().cooldowns.remove(p.getUniqueId());
return;
}
// Check if nulled
if (Bukkit.getWorld(world) == null) {
getPl().getText().getNotExist(sendi, world);
// Check if nulled or world doesnt exist
if (Bukkit.getWorld(worldName) == null) {
getPl().getText().getNotExist(sendi, worldName);
getPl().getCmd().cooldowns.remove(p.getUniqueId());
return;
}
PlayerWorld pWorld = new PlayerWorld(p, world);
PlayerWorld pWorld = new PlayerWorld(p, Bukkit.getWorld(worldName));
// Set all methods
if (customWorlds.containsKey(world)) {
RTPWorld cWorld = customWorlds.get(pWorld.getWorld());
if (customWorlds.containsKey(worldName)) {
RTPWorld cWorld = customWorlds.get(pWorld.getWorld().getName());
pWorld.setup(cWorld, cWorld.getPrice(), biomes);
} else
pWorld.setup(Default, Default.getPrice(), biomes);
pWorld.setup(defaultWorld, defaultWorld.getPrice(), biomes);
//World type
RTP_WORLD_TYPE world_type = RTP_WORLD_TYPE.NORMAL; //World rtp type
if (this.world_type.containsKey(worldName))
world_type = this.world_type.get(worldName);
pWorld.setWorldtype(world_type);
// Check world price
if (!getPl().getEco().charge(p, pWorld.getPrice())) {
getPl().getText().getFailedPrice(p, pWorld.getPrice());
@ -165,20 +168,45 @@ public class RTP {
if (getPl().getSettings().delayEnabled && delay) {
new RTPDelay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage);
} else
tp(sendi, pWorld);
findSafeLocation(sendi, pWorld);
}
void tp(CommandSender sendi, PlayerWorld pWorld) {
new BukkitRunnable(){
@Override
public void run() {
Location loc = randomLoc(pWorld);
if (loc != null)
teleport.sendPlayer(sendi, pWorld.getPlayer(), loc, pWorld.getPrice(), pWorld.getAttempts());
else
// void findSafeLocation(CommandSender sendi, PlayerWorld pWorld) {
// new BukkitRunnable(){
// @Override
// public void run() {
// f
// if (loc != null)
// teleport.sendPlayer(sendi, pWorld.getPlayer(), loc, pWorld.getPrice(), pWorld.getAttempts());
// else
// metMax(sendi, pWorld.getPlayer(), pWorld.getPrice());
// }
// }.runTaskAsynchronously(getPl());
// }
void findSafeLocation(CommandSender sendi, PlayerWorld 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, rn.nextInt(4)); //randomLoc(pWorld);
CompletableFuture<Chunk> 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);
});
}
}.runTaskAsynchronously(getPl());
}
// Compressed code for MaxAttempts being met
@ -193,82 +221,69 @@ public class RTP {
}
//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 quadrant = rn.nextInt(4);
Player p = pWorld.getPlayer();
World world = Bukkit.getWorld(pWorld.getWorld());
if (pWorld.getUseWorldborder()) {
WorldBorder border = world.getWorldBorder();
borderRad = (int) border.getSize() / 2;
CenterX = border.getCenter().getBlockX();
CenterZ = border.getCenter().getBlockZ();
}
float yaw = p.getLocation().getYaw(), pitch = p.getLocation().getPitch();
RTP_WORLD_TYPE world_type = RTP_WORLD_TYPE.NORMAL; //World rtp type
/*try {
//1.13+
normal = !world.getBiome(0, 0).equals(Biome.valueOf("NETHER")));
} catch (Exception e) {
//1.8-1.12
try {
normal = !world.getBiome(0, 0).equals(Biome.valueOf("HELL"));
} 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 = null;
if (borderRad <= minVal) {
minVal = Default.getMinRad();
if (borderRad <= minVal)
minVal = 0;
}
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;
quadrant = rn.nextInt(4);
}
return null;
}
//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;
// Will Check is CenterZ is negative or positive, then set 2 x's
// up for choosing up next
z = rn.nextInt(borderRad - minVal) + CenterZ + minVal;
z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
// Will Check is CenterZ is negative or positive, then set 2 z's
// up for choosing up next
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
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;
}
// private Location randomLoc(PlayerWorld pWorld) {
// int borderRad = pWorld.getMaxRad();
// int minVal = pWorld.getMinRad();
// int CenterX = pWorld.getCenterX();
// int CenterZ = pWorld.getCenterZ();
// int quadrant = rn.nextInt(4);
// Player p = pWorld.getPlayer();
// World world = pWorld.getWorld();
// if (pWorld.getUseWorldborder()) {
// WorldBorder border = world.getWorldBorder();
// borderRad = (int) border.getSize() / 2;
// CenterX = border.getCenter().getBlockX();
// CenterZ = border.getCenter().getBlockZ();
// }
// float yaw = p.getLocation().getYaw(), pitch = p.getLocation().getPitch();
// RTP_WORLD_TYPE world_type = pWorld.getWorldtype();
// //for (int i = 0; i <= maxAttempts; i++) {
// // Get the y-coords from up top, then check if it's SAFE!
// Location loc = null;
// if (borderRad <= minVal) {
// minVal = defaultWorld.getMinRad();
// if (borderRad <= minVal)
// minVal = 0;
// }
// 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;
// // quadrant = rn.nextInt(4);
// //}
// //return null;
// }
//
// //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;
// // Will Check is CenterZ is negative or positive, then set 2 x's
// // up for choosing up next
// z = rn.nextInt(borderRad - minVal) + CenterZ + minVal;
// z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
// // Will Check is CenterZ is negative or positive, then set 2 z's
// // up for choosing up next
// x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
// x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
// 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;
// }
private Location getLocAtNormal(int x, int z, World world, Float yaw, Float pitch, PlayerWorld pWorld) {
Block b = world.getHighestBlockAt(x, z);
@ -287,31 +302,31 @@ public class RTP {
return null;
}
//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;
// Will Check is CenterZ is negative or positive, then set 2 x's
// up for choosing up next
z = rn.nextInt((borderRad) - minVal) + CenterZ + minVal;
z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
// Will Check is CenterZ is negative or positive, then set 2 z's
// up for choosing up next
x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
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;
}
// //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;
// // Will Check is CenterZ is negative or positive, then set 2 x's
// // up for choosing up next
// z = rn.nextInt((borderRad) - minVal) + CenterZ + minVal;
// z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
// // Will Check is CenterZ is negative or positive, then set 2 z's
// // up for choosing up next
// x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
// x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
// 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) {
//System.out.println("-----------");
@ -356,14 +371,14 @@ public class RTP {
}
// Bad blocks, or bad biome
private boolean badBlock(String block, int x, int z, String world, List<String> biomes) {
private boolean badBlock(String block, int x, int z, World world, List<String> 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 = Bukkit.getWorld(world).getBiome(x, z).name();
String biomeCurrent = world.getBiome(x, z).name();
for (String biome : biomes)
if (biomeCurrent.toUpperCase().contains(biome.toUpperCase()))
return false;

View File

@ -3,7 +3,6 @@ package me.SuperRonanCraft.BetterRTP.player.rtp;
import me.SuperRonanCraft.BetterRTP.references.worlds.PlayerWorld;
import me.SuperRonanCraft.BetterRTP.Main;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -92,7 +91,7 @@ class RTPDelay implements Listener {
HandlerList.unregisterAll(cls);
if (getPl().getCmd().rtping.containsKey(pWorld.getPlayer().getUniqueId())) {
try {
getPl().getRTP().tp(sendi, pWorld);
getPl().getRTP().findSafeLocation(sendi, pWorld);
} catch (NullPointerException e) {
if (pWorld.getPrice() > 0)
getPl().getEco().unCharge(pWorld.getPlayer(), pWorld.getPrice());

View File

@ -3,6 +3,7 @@ package me.SuperRonanCraft.BetterRTP.references.worlds;
import me.SuperRonanCraft.BetterRTP.Main;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.util.ArrayList;
import java.util.List;
@ -31,34 +32,34 @@ public class Custom implements RTPWorld {
continue;
if (test.get("UseWorldBorder") != null) {
if (test.get("UseWorldBorder").getClass() == Boolean.class)
useWorldborder = Boolean.valueOf(test.get("UseWorldBorder").toString());
useWorldborder = Boolean.parseBoolean(test.get("UseWorldBorder").toString());
}
if (test.get("CenterX") != null) {
if (test.get("CenterX").getClass() == Integer.class)
CenterX = Integer.valueOf((test.get("CenterX")).toString());
CenterX = Integer.parseInt((test.get("CenterX")).toString());
}
if (test.get("CenterZ") != null) {
if (test.get("CenterZ").getClass() == Integer.class)
CenterZ = Integer.valueOf((test.get("CenterZ")).toString());
CenterZ = Integer.parseInt((test.get("CenterZ")).toString());
}
if (test.get("MaxRadius") != null) {
if (test.get("MaxRadius").getClass() == Integer.class)
maxBorderRad = Integer.valueOf((test.get("MaxRadius")).toString());
maxBorderRad = Integer.parseInt((test.get("MaxRadius")).toString());
if (maxBorderRad <= 0) {
Main.getInstance().getText().sms(Bukkit.getConsoleSender(),
"WARNING! Custom world '" + world + "' Maximum radius of '" + maxBorderRad + "' is not allowed! Set to default value!");
maxBorderRad = Main.getInstance().getRTP().Default.getMaxRad();
maxBorderRad = Main.getInstance().getRTP().defaultWorld.getMaxRad();
}
}
if (test.get("MinRadius") != null) {
if (test.get("MinRadius").getClass() == Integer.class)
minBorderRad = Integer.valueOf((test.get("MinRadius")).toString());
minBorderRad = Integer.parseInt((test.get("MinRadius")).toString());
if (minBorderRad < 0 || minBorderRad >= maxBorderRad) {
Main.getInstance().getText().sms(Bukkit.getConsoleSender(),
"WARNING! Custom world '" + world + "' Minimum radius of '" + minBorderRad + "' is not allowed! Set to default value!");
minBorderRad = Main.getInstance().getRTP().Default.getMinRad();
minBorderRad = Main.getInstance().getRTP().defaultWorld.getMinRad();
if (minBorderRad >= maxBorderRad)
maxBorderRad = Main.getInstance().getRTP().Default.getMaxRad();
maxBorderRad = Main.getInstance().getRTP().defaultWorld.getMaxRad();
}
}
if (test.get("Biomes") != null) {
@ -100,7 +101,7 @@ public class Custom implements RTPWorld {
price = Integer.valueOf((test.get("Price")).toString());
}
} else
price = Main.getInstance().getRTP().Default.getPrice();
price = Main.getInstance().getRTP().defaultWorld.getPrice();
//Other
this.Biomes = config.getStringList(pre + world + ".Biomes");
}
@ -141,7 +142,7 @@ public class Custom implements RTPWorld {
}
@Override
public String getWorld() {
return world;
public World getWorld() {
return Bukkit.getWorld(world);
}
}

View File

@ -4,6 +4,7 @@ package me.SuperRonanCraft.BetterRTP.references.worlds;
import me.SuperRonanCraft.BetterRTP.Main;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import org.bukkit.Bukkit;
import org.bukkit.World;
import java.util.HashMap;
import java.util.List;
@ -78,7 +79,7 @@ public class Default implements RTPWorld {
}
@Override
public String getWorld() {
public World getWorld() {
return null;
}
}

View File

@ -1,18 +1,23 @@
package me.SuperRonanCraft.BetterRTP.references.worlds;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class PlayerWorld implements RTPWorld {
private boolean useWorldborder;
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price, attempts;
private List<String> Biomes;
private Player p;
private String world;
private World world;
private RTP_WORLD_TYPE world_type;
public PlayerWorld(Player p, String world) {
public PlayerWorld(Player p, World world) {
this.p = p;
this.world = world;
}
@ -34,7 +39,59 @@ public class PlayerWorld implements RTPWorld {
return p;
}
public String getWorld() {
public Location generateRandomXZ(Default defaultWorld, int quadrant) {
int borderRad = getMaxRad();
int minVal = getMinRad();
int CenterX = getCenterX();
int CenterZ = getCenterZ();
//int quadrant = rn.nextInt(4);
Player p = getPlayer();
World world = getWorld();
if (getUseWorldborder()) {
WorldBorder border = world.getWorldBorder();
borderRad = (int) border.getSize() / 2;
CenterX = border.getCenter().getBlockX();
CenterZ = border.getCenter().getBlockZ();
}
float yaw = p.getLocation().getYaw(), pitch = p.getLocation().getPitch();
RTP_WORLD_TYPE world_type = this.world_type; //World rtp type
//for (int i = 0; i <= maxAttempts; i++) {
// Get the y-coords from up top, then check if it's SAFE!
if (borderRad <= minVal) {
minVal = defaultWorld.getMinRad();
if (borderRad <= minVal)
minVal = 0;
}
// Will Check is CenterZ is negative or positive, then set 2 x's
// up for choosing up next
////z = rn.nextInt(borderRad - minVal) + CenterZ + minVal;
////z2 = -(rn.nextInt(borderRad - minVal) - CenterZ - minVal);
// Will Check is CenterZ is negative or positive, then set 2 z's
// up for choosing up next
////x = rn.nextInt(borderRad - minVal) + CenterX + minVal;
////x2 = -rn.nextInt(borderRad - minVal) + CenterX - minVal;
int x = borderRad - minVal;
int z = borderRad - minVal;
switch (quadrant) {
case 0: // Positive X and Z
x = new Random().nextInt(x) + CenterX + minVal;
z = new Random().nextInt(z) + CenterZ + minVal; break;
case 1: // Negative X and Z
x = -new Random().nextInt(x) + CenterX - minVal;
z = -(new Random().nextInt(z) + CenterZ + minVal); break;
case 2: // Negative X and Positive Z
x = -new Random().nextInt(x) + CenterX - minVal;
z = new Random().nextInt(z) + CenterZ + minVal; break;
default: // Positive X and Negative Z
x = new Random().nextInt(x) + CenterX + minVal;
z = -(new Random().nextInt(z) + CenterZ + minVal); break;
}
addAttempt();
return new Location(world, x, 0, z);
}
@Override
public World getWorld() {
return world;
}
@ -104,6 +161,15 @@ public class PlayerWorld implements RTPWorld {
}
private void setBiomes(List<String> biomes) {
Biomes = biomes;
this.Biomes = biomes;
}
//Custom World type
public void setWorldtype(RTP_WORLD_TYPE type) {
this.world_type = type;
}
public RTP_WORLD_TYPE getWorldtype() {
return this.world_type;
}
}

View File

@ -1,5 +1,7 @@
package me.SuperRonanCraft.BetterRTP.references.worlds;
import org.bukkit.World;
import java.util.List;
public interface RTPWorld {
@ -18,5 +20,5 @@ public interface RTPWorld {
List<String> getBiomes();
String getWorld();
World getWorld();
}

View File

@ -1,5 +1,5 @@
main: me.SuperRonanCraft.BetterRTP.Main
version: '2.12.0'
version: '2.12.1'
name: BetterRTP
author: SuperRonanCraft
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]