mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 00:55:45 +00:00
2.13.0 - Regions Plugin support (worldguard, griefprevention, towny, RedProtect)
This commit is contained in:
parent
211d3609d4
commit
14c276cefb
67
pom.xml
67
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.SuperRonanCraft</groupId>
|
||||
<artifactId>BetterRTP</artifactId>
|
||||
<version>2.12.2</version>
|
||||
<version>2.13.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
@ -56,21 +56,30 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<!-- PaperMC Repo -->
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<!-- Vault Repo -->
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<!-- Worldguard Repo -->
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<!-- Github based Repos -->
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<!-- ProjectRed Repo -->
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
<id>redprotect-repo</id>
|
||||
<url>https://raw.githubusercontent.com/FabioZumbi12/RedProtect/mvn-repo/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
@ -81,30 +90,20 @@
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency> <!-- Spigot (this includes Spigot API, Bukkit API, Craftbukkit and NMS) -->
|
||||
<!-- Spigot Stuff -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Vault -->
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Paper Library for Async Chunk/Teleport -->
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
@ -118,5 +117,39 @@
|
||||
<artifactId>particle</artifactId>
|
||||
<version>1.5.1</version>
|
||||
</dependency>
|
||||
<!-- Worldguard (https://dev.bukkit.org/projects/worldguard) -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- GriefPrevention (https://www.spigotmc.org/resources/griefprevention.1884/) -->
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.15.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Towny (https://www.spigotmc.org/resources/towny.72694/) -->
|
||||
<dependency>
|
||||
<groupId>com.github.TownyAdvanced</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
<version>0.96.1.11</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- RedProtect (https://www.spigotmc.org/resources/redprotect.15841/) -->
|
||||
<dependency>
|
||||
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||
<artifactId>RedProtect-Core</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
|
||||
<artifactId>RedProtect-Spigot-1.13</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}*/
|
||||
}
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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<String, RTPWorld> customWorlds = new HashMap<>();
|
||||
public HashMap<String, String> overriden = new HashMap<>();
|
||||
public Default defaultWorld = new Default();
|
||||
private Random rn = new Random();
|
||||
private List<String> disabledWorlds, blockList;
|
||||
private int maxAttempts, delayTime;
|
||||
private boolean cancelOnMove, cancelOnDamage;
|
||||
@ -125,7 +118,6 @@ public class RTP {
|
||||
return disabledWorlds;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public List<String> 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> 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++) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -100,7 +100,7 @@ public class RTPTeleport {
|
||||
|
||||
private List<CompletableFuture<Chunk>> getChunks(Location loc) { //List all chunks in range to load
|
||||
List<CompletableFuture<Chunk>> 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));
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ public class PlayerWorld implements RTPWorld {
|
||||
private boolean useWorldborder;
|
||||
private int CenterX, CenterZ, maxBorderRad, minBorderRad, price, attempts;
|
||||
private List<String> 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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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你未被传送!'
|
||||
|
@ -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您未被傳送!'
|
||||
|
@ -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!'
|
||||
|
@ -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!'
|
||||
|
@ -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é!'
|
||||
|
@ -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されませんでした!'
|
||||
|
@ -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Вас не телепортировало!'
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user