diff --git a/pom.xml b/pom.xml
index ecb2810..979f4f2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
me.SuperRonanCraft
BetterRTP
- 2.12.2
+ 2.13.0
1.8
@@ -56,21 +56,30 @@
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+ papermc
+ https://papermc.io/repo/repository/maven-public/
+
+
vault-repo
http://nexus.hc.to/content/repositories/pub_releases
+
sk89q-repo
- http://maven.sk89q.com/repo/
+ https://maven.enginehub.org/repo/
+
jitpack.io
https://jitpack.io
+
- papermc
- https://papermc.io/repo/repository/maven-public/
+ redprotect-repo
+ https://raw.githubusercontent.com/FabioZumbi12/RedProtect/mvn-repo/
@@ -81,30 +90,20 @@
1.8.8-R0.1-SNAPSHOT
provided
-
+
+
org.spigotmc
spigot
1.8.8-R0.1-SNAPSHOT
provided
+
net.milkbowl.vault
VaultAPI
1.7
provided
-
- com.sk89q
- worldguard
- 6.1
- provided
-
-
- com.github.TechFortress
- GriefPrevention
- 16.7.1
- provided
-
io.papermc
@@ -118,5 +117,39 @@
particle
1.5.1
+
+
+ com.sk89q.worldguard
+ worldguard-bukkit
+ 7.0.3
+ provided
+
+
+
+ com.github.TechFortress
+ GriefPrevention
+ 16.15.0
+ provided
+
+
+
+ com.github.TownyAdvanced
+ Towny
+ 0.96.1.11
+ provided
+
+
+
+ br.net.fabiozumbi12.RedProtect
+ RedProtect-Core
+ LATEST
+ provided
+
+
+ br.net.fabiozumbi12.RedProtect
+ RedProtect-Spigot-1.13
+ LATEST
+ provided
+
\ No newline at end of file
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/Commands.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/Commands.java
index bc17119..03b0631 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/Commands.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/Commands.java
@@ -28,6 +28,7 @@ public class Commands {
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
delayTimer = config.getInt("Settings.Delay.Time");
cooldowns.load();
+ rtping.clear();
}
public void commandExecuted(CommandSender sendi, String label, String[] args) {
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 aaf0324..d6990f9 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
@@ -88,7 +88,7 @@ public class CmdInfo implements RTPCommand {
info.add("&7- &6Overriden: &cFalse");
RTPWorld _rtpworld = pl.getRTP().defaultWorld;
for (RTPWorld __rtpworld : pl.getRTP().customWorlds.values()) {
- if (__rtpworld.getWorld().equals(w.getName())) {
+ if (__rtpworld.getWorld() != null && __rtpworld.getWorld().getName().equals(w.getName())) {
_rtpworld = __rtpworld;
break;
}
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Listener.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Listener.java
index d003d16..fbff0c6 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Listener.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/Listener.java
@@ -7,13 +7,15 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.PluginManager;
public class Listener implements org.bukkit.event.Listener {
- private Join join = new Join();
- private Leave leave = new Leave();
- private Interact interact = new Interact();
- private Click click = new Click();
+ private final Join join = new Join();
+ private final Leave leave = new Leave();
+ private final Interact interact = new Interact();
+ private final Click click = new Click();
+ //private final PluginEnable pEnable = new PluginEnable();
public void registerEvents(Main pl) {
PluginManager pm = pl.getServer().getPluginManager();
@@ -53,4 +55,9 @@ public class Listener implements org.bukkit.event.Listener {
private void click(InventoryClickEvent e) {
click.click(e);
}
+
+ /*@EventHandler
+ private void enablePlugin(PluginEnableEvent e) {
+ pEnable.enabled(e);
+ }*/
}
\ No newline at end of file
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/PluginEnable.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/PluginEnable.java
new file mode 100644
index 0000000..9f12e5a
--- /dev/null
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/events/PluginEnable.java
@@ -0,0 +1,19 @@
+package me.SuperRonanCraft.BetterRTP.player.events;
+
+import me.SuperRonanCraft.BetterRTP.Main;
+import org.bukkit.event.server.PluginEnableEvent;
+
+public class PluginEnable {
+
+ //In the case SoftDependencies plugins load after us!
+ void enabled(PluginEnableEvent e) {
+ String name = e.getPlugin().getName();
+ //System.out.println(name);
+ if (name.equalsIgnoreCase("WorldGuard"))
+ Main.getInstance().getSettings().getsDepends().registerWorldguard();
+ else if (name.equalsIgnoreCase("GriefPrevention"))
+ Main.getInstance().getSettings().getsDepends().registerGriefPrevention();
+
+ }
+
+}
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 c3a25bf..2ef947e 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTP.java
@@ -1,14 +1,9 @@
package me.SuperRonanCraft.BetterRTP.player.rtp;
-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.Chunk;
import org.bukkit.Location;
@@ -20,18 +15,16 @@ import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Random;
import java.util.concurrent.CompletableFuture;
public class RTP {
private final RTPTeleport teleport = new RTPTeleport();
- private final RTPSoftDepends softDepends = new RTPSoftDepends();
+ private final RTPPluginValidation softDepends = new RTPPluginValidation();
//Cache
public HashMap customWorlds = new HashMap<>();
public HashMap overriden = new HashMap<>();
public Default defaultWorld = new Default();
- private Random rn = new Random();
private List disabledWorlds, blockList;
private int maxAttempts, delayTime;
private boolean cancelOnMove, cancelOnDamage;
@@ -125,7 +118,6 @@ public class RTP {
return disabledWorlds;
}
- @SuppressWarnings("unused")
public List getDisabledWorlds() {
return disabledWorlds;
}
@@ -180,24 +172,11 @@ public class RTP {
findSafeLocation(sendi, pWorld);
}
-// 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);
+ Location loc = pWorld.generateRandomXZ(defaultWorld); //randomLoc(pWorld);
CompletableFuture chunk = PaperLib.getChunkAtAsync(pWorld.getWorld(), loc.getBlockX(), loc.getBlockZ());
chunk.thenAccept(result -> {
Location tpLoc;
@@ -229,71 +208,6 @@ public class RTP {
getPl().getCmd().rtping.put(p.getUniqueId(), false);
}
- //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 = 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);
if (b.getType().toString().endsWith("AIR")) //1.15.1 or less
@@ -311,32 +225,6 @@ 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;
-// }
-
private Location getLocAtNether(int x, int z, World world, Float yaw, Float pitch, PlayerWorld pWorld) {
//System.out.println("-----------");
for (int y = 1; y < world.getMaxHeight(); y++) {
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPPluginValidation.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPPluginValidation.java
new file mode 100644
index 0000000..c70f2e4
--- /dev/null
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPPluginValidation.java
@@ -0,0 +1,88 @@
+package me.SuperRonanCraft.BetterRTP.player.rtp;
+
+import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
+import com.palmergames.bukkit.towny.TownyAPI;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldguard.LocalPlayer;
+import com.sk89q.worldguard.WorldGuard;
+import com.sk89q.worldguard.protection.ApplicableRegionSet;
+import com.sk89q.worldguard.protection.flags.Flags;
+import com.sk89q.worldguard.protection.regions.RegionContainer;
+import com.sk89q.worldguard.protection.regions.RegionQuery;
+import me.SuperRonanCraft.BetterRTP.Main;
+import me.ryanhamshire.GriefPrevention.GriefPrevention;
+import org.bukkit.Location;
+
+public class RTPPluginValidation { //Safe locations depending on enabled dependencies
+
+ boolean checkLocation(Location loc) {
+ boolean worldguard = getWorlguard(loc);
+ boolean griefPrevention = getGriefprevention(loc);
+ boolean towny = getTowny(loc);
+ boolean redProject = getRedProject(loc);
+ return worldguard && griefPrevention && towny && redProject;
+ }
+
+ // TESTED on v2.12.3
+ // Worldguard v7.0.4 B1, WorldEdit v7.2.0 B5
+ // https://dev.bukkit.org/projects/worldguard
+ private boolean getWorlguard(Location loc) {
+ boolean result = true;
+ if (getPl().getSettings().getsDepends().isWorldguard())
+ try {
+ RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
+ RegionQuery query = container.createQuery();
+ ApplicableRegionSet set = query.getApplicableRegions(BukkitAdapter.adapt(loc));
+ result = set.size() == 0;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ // TESTED on v2.12.3
+ // GriefPrevention v16.15.0
+ // https://www.spigotmc.org/resources/griefprevention.1884/
+ private boolean getGriefprevention(Location loc) {
+ boolean result = true;
+ if (getPl().getSettings().getsDepends().isGriefprevention())
+ try {
+ result = GriefPrevention.instance.dataStore.getClaimAt(loc, true, null) == null;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ // NOT TESTED
+ // Towny v0.96.1.11
+ // https://www.spigotmc.org/resources/towny.72694/
+ private boolean getTowny(Location loc) {
+ boolean result = true;
+ if (getPl().getSettings().getsDepends().isTowny())
+ try {
+ result = TownyAPI.getInstance().isWilderness(loc);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ // TESTED 2.12.3
+ // RedProtect v7.7.2
+ // https://www.spigotmc.org/resources/redprotect.15841/
+ private boolean getRedProject(Location loc) {
+ boolean result = true;
+ if (getPl().getSettings().getsDepends().isRedProtect())
+ try {
+ result = RedProtect.get().getAPI().getRegion(loc) == null;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return result;
+ }
+
+ private Main getPl() {
+ return Main.getInstance();
+ }
+}
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPSoftDepends.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPSoftDepends.java
deleted file mode 100644
index 169828b..0000000
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPSoftDepends.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package me.SuperRonanCraft.BetterRTP.player.rtp;
-
-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 me.SuperRonanCraft.BetterRTP.Main;
-import me.ryanhamshire.GriefPrevention.GriefPrevention;
-import org.bukkit.Location;
-
-public class RTPSoftDepends { //Safe locations depending on enabled dependencies
-
- boolean checkLocation(Location loc) {
- boolean worldguard = getWorlguard(loc);
- boolean griefPrevention = getGriefprevention(loc);
- return worldguard && griefPrevention;
- }
-
- private boolean getWorlguard(Location loc) {
- if (getPl().getSettings().getsDepends().isWorldguard())
- try {
- WorldGuardPlugin plugin = WGBukkit.getPlugin();
- RegionContainer container = plugin.getRegionContainer();
- RegionManager regions = container.get(loc.getWorld());
- // Check to make sure that "regions" is not null
- return (regions != null ? regions.getApplicableRegions(loc).size() : 0) == 0;
- } catch (NoClassDefFoundError e) {
- return true;
- }
- return true;
- }
-
- private boolean getGriefprevention(Location loc) {
- if (getPl().getSettings().getsDepends().isGriefprevention())
- try {
- return GriefPrevention.instance.dataStore.getClaimAt(loc, true, null) == null;
- } catch (NoClassDefFoundError e) {
- return true;
- }
- return true;
- }
-
- private Main getPl() {
- return Main.getInstance();
- }
-}
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPTeleport.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPTeleport.java
index 5383699..3d57134 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPTeleport.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/rtp/RTPTeleport.java
@@ -100,7 +100,7 @@ public class RTPTeleport {
private List> getChunks(Location loc) { //List all chunks in range to load
List> asyncChunks = new ArrayList<>();
- int range = Math.round(Math.min(Bukkit.getServer().getViewDistance() / 2, 5));
+ int range = Math.round(Math.max(0, Math.min(16, getPl().getSettings().preloadRadius)));
for (int x = -range; x <= range; x++) {
for (int z = -range; z <= range; z++) {
Location locLoad = new Location(loc.getWorld(), loc.getX() + (x * 16), loc.getY(), loc.getZ() + (z * 16));
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/settings/Settings.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/settings/Settings.java
index 6f05a11..97a2efc 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/settings/Settings.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/settings/Settings.java
@@ -9,16 +9,18 @@ public class Settings {
public boolean delayEnabled;
public boolean rtpOnFirstJoin;
public String rtpOnFirstJoinWorld;
+ public int preloadRadius; //Amount of chunks to load around a safe rtp location (clamped (0 - 16))
//Dependencies
- private SoftDepends depends = new SoftDepends();
+ private final SoftDepends depends = new SoftDepends();
public void load() { //Load Settings
- depends.load();
FileBasics.FILETYPE config = getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG);
debug = config.getBoolean("Settings.Debugger");
delayEnabled = config.getBoolean("Settings.Delay.Enabled");
rtpOnFirstJoin = config.getBoolean("Settings.RtpOnFirstJoin.Enabled");
rtpOnFirstJoinWorld = config.getString("Settings.RtpOnFirstJoin.World");
+ preloadRadius = config.getInt("Settings.PreloadRadius");
+ depends.load();
}
public SoftDepends getsDepends() {
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/settings/SoftDepends.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/settings/SoftDepends.java
index 4b27fd6..f04aea1 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/settings/SoftDepends.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/settings/SoftDepends.java
@@ -4,9 +4,19 @@ import me.SuperRonanCraft.BetterRTP.Main;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import org.bukkit.Bukkit;
+import java.util.logging.Level;
+
public class SoftDepends {
- private boolean worldguard = false, griefprevention = false, savagefactions = false;
+ private boolean respect_worldguard = false;
+ private boolean respect_griefprevention = false;
+ private boolean respect_towny = false;
+ private boolean respect_redProtect = false;
+ //RETURNABLES
+ private boolean worldguard = false;
+ private boolean griefprevention = false;
+ private boolean towny = false;
+ private boolean redProtect = false;
public boolean isWorldguard() {
return worldguard;
@@ -16,31 +26,48 @@ public class SoftDepends {
return griefprevention;
}
+ public boolean isTowny() {
+ return towny;
+ }
+
+ public boolean isRedProtect() {
+ return redProtect;
+ }
+
void load() {
FileBasics.FILETYPE config = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.CONFIG);
- if (config.getBoolean("Settings.RespectWorldGuard"))
- registerWorldguard();
- else if (worldguard)
- worldguard = false;
- if (config.getBoolean("Settings.RespectGriefPrevention"))
- registerGriefPrevention();
- else if (griefprevention)
- griefprevention = false;
- if (config.getBoolean("Settings.RespectSavageFactions"))
- registerSavageFactions();
- else if (savagefactions)
- savagefactions = false;
+ respect_worldguard = config.getBoolean("Settings.Respect.WorldGuard");
+ respect_griefprevention = config.getBoolean("Settings.Respect.GriefPrevention");
+ respect_towny = config.getBoolean("Settings.Respect.Towny");
+ respect_redProtect = config.getBoolean("Settings.Respect.RedProtect");
+ registerWorldguard();
+ registerGriefPrevention();
+ registerTowny();
+ registerRedProject();
}
- private void registerWorldguard() {
- worldguard = Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
+ public void registerWorldguard() {
+ worldguard = respect_worldguard && Bukkit.getPluginManager().isPluginEnabled("WorldGuard");
+ debug("Registered `WorldGuard` = " + worldguard);
}
- private void registerGriefPrevention() {
- griefprevention = Bukkit.getPluginManager().isPluginEnabled("GriefPrevention");
+ public void registerGriefPrevention() {
+ griefprevention = respect_griefprevention && Bukkit.getPluginManager().isPluginEnabled("GriefPrevention");
+ debug("Registered `GriefPrevention` = " + griefprevention);
}
- private void registerSavageFactions() {
- savagefactions = Bukkit.getPluginManager().isPluginEnabled("Factions");
+ public void registerTowny() {
+ towny = respect_towny && Bukkit.getPluginManager().isPluginEnabled("Towny");
+ debug("Registered `Towny` = " + towny);
+ }
+
+ public void registerRedProject() {
+ redProtect = respect_redProtect && Bukkit.getPluginManager().isPluginEnabled("RedProtect");
+ debug("Registered `RedProtect` = " + redProtect);
+ }
+
+ private void debug(String str) {
+ if (Main.getInstance().getSettings().debug)
+ Main.getInstance().getLogger().log(Level.INFO, str);
}
}
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/worlds/PlayerWorld.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/worlds/PlayerWorld.java
index 2004d47..3b599fb 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/worlds/PlayerWorld.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/worlds/PlayerWorld.java
@@ -13,8 +13,8 @@ public class PlayerWorld implements RTPWorld {
private boolean useWorldborder;
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price, attempts;
private List Biomes;
- private Player p;
- private World world;
+ private final Player p;
+ private final World world;
private RTP_WORLD_TYPE world_type;
public PlayerWorld(Player p, World world) {
@@ -39,13 +39,11 @@ public class PlayerWorld implements RTPWorld {
return p;
}
- public Location generateRandomXZ(Default defaultWorld, int quadrant) {
+ public Location generateRandomXZ(Default defaultWorld) {
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();
@@ -53,40 +51,36 @@ public class PlayerWorld implements RTPWorld {
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!
+
+ //Make sure our borders will not cause an invalid integer
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;
+
+ //Generate a random X and Z based off the quadrant selected
+ int max = borderRad - minVal;
+ int x, z;
+ int quadrant = new Random().nextInt(4);
switch (quadrant) {
case 0: // Positive X and Z
- x = new Random().nextInt(x) + CenterX + minVal;
- z = new Random().nextInt(z) + CenterZ + minVal; break;
+ x = new Random().nextInt(max) + minVal;
+ z = new Random().nextInt(max) + minVal; break;
case 1: // Negative X and Z
- x = -new Random().nextInt(x) + CenterX - minVal;
- z = -(new Random().nextInt(z) + CenterZ + minVal); break;
+ x = -new Random().nextInt(max) - minVal;
+ z = -(new Random().nextInt(max) + minVal); break;
case 2: // Negative X and Positive Z
- x = -new Random().nextInt(x) + CenterX - minVal;
- z = new Random().nextInt(z) + CenterZ + minVal; break;
+ x = -new Random().nextInt(max) - minVal;
+ z = new Random().nextInt(max) + minVal; break;
default: // Positive X and Negative Z
- x = new Random().nextInt(x) + CenterX + minVal;
- z = -(new Random().nextInt(z) + CenterZ + minVal); break;
+ x = new Random().nextInt(max) + minVal;
+ z = -(new Random().nextInt(max) + minVal); break;
}
+ x += CenterX;
+ z += CenterZ;
addAttempt();
+ //System.out.println(quadrant);
return new Location(world, x, 0, z);
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 35713ef..641086c 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -4,16 +4,21 @@
Language-File: 'en.yml'
Settings:
+ Respect:
+ ## Respect WorldGuard areas (https://dev.bukkit.org/projects/worldguard)
+ WorldGuard: false
+ ## Respect GriefPrevention areas (https://www.spigotmc.org/resources/griefprevention.1884/)
+ GriefPrevention: false
+ ## Respect Towny areas (https://www.spigotmc.org/resources/towny.72694/)
+ Towny: false
+ ## Respect RedProtect areas (https://www.spigotmc.org/resources/redprotect.15841/)
+ RedProtect: false
## Output to console some debugging info
Debugger: false
- ## Respect WorldGuard areas # IN-PROGRESS
- RespectWorldGuard: false
- ## Respect GriefPrevention areas # COMING SOON
- RespectGriefPrevention: false
- ## Respect Faction areas # COMING SOON
- RespectSavageFactions: false
## Must be a positive integer #
MinRadius: 25
+ ## Amount of chunks to preload around a safe location
+ PreloadRadius: 5
## Maximum amount of tries before BetterRTP gives up and sends a NotSafeMessage #
MaxAttempts: 15
RtpOnFirstJoin: # Will execute as console to override delays
diff --git a/src/main/resources/lang/chn.yml b/src/main/resources/lang/chn.yml
index fec3583..557f487 100644
--- a/src/main/resources/lang/chn.yml
+++ b/src/main/resources/lang/chn.yml
@@ -4,6 +4,7 @@ Messages:
Paid: '&a你花费了&c$%price%&7,被传送到了&7 x=%x% y=%y% z=%z%。共尝试&f%attempts%&7次!'
Bypass: '&a你被传送到了&7 x=%x% y=%y% z=%z%。共尝试&f%attempts%&7次!'
Loading: '&aSafe spot located! &7Loading chunks...'
+ Teleport: '&aTeleporting... &fplease wait while we find a safe location!'
Failed:
Price: '&c你的钱不够了,&7你至少要有$%price%&7才能随机传送!'
NotSafe: '&c由于在%attempts%次尝试内未能找到安全的位置,&7你未被传送!'
diff --git a/src/main/resources/lang/cht.yml b/src/main/resources/lang/cht.yml
index 6b62aba..80ca9ca 100644
--- a/src/main/resources/lang/cht.yml
+++ b/src/main/resources/lang/cht.yml
@@ -4,6 +4,7 @@ Messages:
Paid: '&a您花費了&c$%price%&7,被傳送到了&7 x=%x% y=%y% z=%z%。一共嘗試&f%attempts%&7次!'
Bypass: '&a您被傳送到了&7 x=%x% y=%y% z=%z%。一共嘗試&f%attempts%&7次!'
Loading: '&a已定位安全位置! &7正在讀取區塊...'
+ Teleport: '&aTeleporting... &fplease wait while we find a safe location!'
Failed:
Price: '&c您的資金不夠了!&7您需要有$%price%&7才能嘗試RTP!'
NotSafe: '&c由於%attempts%次嘗試內未能找到適合的地方傳送,&7您未被傳送!'
diff --git a/src/main/resources/lang/du.yml b/src/main/resources/lang/du.yml
index 44a49cf..1323d65 100644
--- a/src/main/resources/lang/du.yml
+++ b/src/main/resources/lang/du.yml
@@ -4,6 +4,7 @@ Messages:
Paid: '&aJe bent getp''d naar&7 x=%x% y=%y% z=%z% for &c$%price%&7 in &f%attempts% &7attempts!'
Bypass: '&aJe bent getp''d naar&7 x=%x% y=%y% z=%z%'
Loading: '&aSafe spot located! &7Loading chunks...'
+ Teleport: '&aTeleporting... &fplease wait while we find a safe location!'
Failed:
Price: '&cKan niet rtpen vanwege onvoldoende saldo! &7Je moet minstens $%price% &7hebben om te rtpen!'
NotSafe: '&cKon geen veilige plek vinden, Probeer opnieuw! &7Je bent niet ge tp''d!'
diff --git a/src/main/resources/lang/en.yml b/src/main/resources/lang/en.yml
index 57ebec4..5d79fe1 100644
--- a/src/main/resources/lang/en.yml
+++ b/src/main/resources/lang/en.yml
@@ -4,6 +4,7 @@ Messages:
Paid: '&aYou have been tp''d to&7 x=%x% y=%y% z=%z% for &c$%price%&7 in &f%attempts% &7attempts!'
Bypass: '&aYou have been tp''d to&7 x=%x% y=%y% z=%z% in &f%attempts% &7attempts'
Loading: '&aSafe spot located! &7Loading chunks...'
+ Teleport: '&aTeleporting... &fplease wait while we find a safe location!'
Failed:
Price: '&cCould not rtp because of insufficent funds! &7You must have atleast $%price% &7to rtp!'
NotSafe: '&cCould not find safe spot within %attempts% attempts! &7You were not RTP''d!'
diff --git a/src/main/resources/lang/fr.yml b/src/main/resources/lang/fr.yml
index e2c9ae8..d340fdf 100644
--- a/src/main/resources/lang/fr.yml
+++ b/src/main/resources/lang/fr.yml
@@ -5,6 +5,7 @@ Messages:
Paid: '&aTu a été téléporté à&7 x=%x% y=%y% z=%z% pour &c$%price%&7 en &f%attempts% &7tentatives!'
Bypass: '&aTu a été téléporté à&7 x=%x% y=%y% z=%z% en &f%attempts% &7tentatives!'
Loading: '&aSafe spot located! &7Loading chunks...'
+ Teleport: '&aTeleporting... &fplease wait while we find a safe location!'
Failed:
Price: '&cTu n''a pas pu être téléporté; Manque de fonds! &7Tu doit avoir au moins $%price% &7pour te téléporter!'
NotSafe: '&cImpossible de trouver un endroit sûr en %attempts% tentatives! &7Tu n''a pas été téléporté!'
diff --git a/src/main/resources/lang/ja.yml b/src/main/resources/lang/ja.yml
index 0875109..f20acd3 100644
--- a/src/main/resources/lang/ja.yml
+++ b/src/main/resources/lang/ja.yml
@@ -4,6 +4,7 @@ Messages:
Paid: '&aあなたは&c$%price%&aで&7x=%x% y=%y% z=%z% に&f%attempts%&7回の試行でTPされました!'
Bypass: '&aあなたは&7x=%x% y=%y% z=%z% に&f%attempts%&7回の試行でTPされました!'
Loading: '&aSafe spot located! &7Loading chunks...'
+ Teleport: '&aTeleporting... &fplease wait while we find a safe location!'
Failed:
Price: '&c資金が不十分のためRTPできませんでした! &7RTPには最低$%price%&7が必要です!'
NotSafe: '&c%attempts%回の試行で安全な場所が見つかりませんでした! &7あなたははRTPされませんでした!'
diff --git a/src/main/resources/lang/ru.yml b/src/main/resources/lang/ru.yml
index 5d06b82..68bd456 100644
--- a/src/main/resources/lang/ru.yml
+++ b/src/main/resources/lang/ru.yml
@@ -4,6 +4,7 @@ Messages:
Paid: '&aВас телепортировало на&7 x=%x% y=%y% z=%z% за &c$%price%&7, за &f%attempts% &7попыток!'
Bypass: '&aВас телепортировало на&7 x=%x% y=%y% z=%z% за &f%attempts% &7попыток'
Loading: '&aSafe spot located! &7Loading chunks...'
+ Teleport: '&aTeleporting... &fplease wait while we find a safe location!'
Failed:
Price: '&cУ вас недостаточно денег для телепортации! &7У вас должно быть хотябы $%price% &7для rtp!'
NotSafe: '&cНе удалось найти безопасное место за %attempts% попыток! &7Вас не телепортировало!'
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index ec745a0..e0574f1 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,8 +1,8 @@
main: me.SuperRonanCraft.BetterRTP.Main
-version: '2.12.2'
+version: '2.13.0'
name: BetterRTP
author: SuperRonanCraft
-softdepend: [Vault, WorldGuard, GriefPrevention, Factions]
+softdepend: [Vault, WorldGuard, GriefPrevention, Towny, Factions, RedProtect]
api-version: '1.13'
commands: