mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-02-16 02:21:06 +00:00
cooldown fix + chunk loading performance
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -7,7 +7,7 @@
|
||||
<groupId>me.SuperRonanCraft</groupId>
|
||||
<artifactId>BetterRTP</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>3.4.2-2</version>
|
||||
<version>3.4.3</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
||||
@@ -42,6 +42,7 @@ public class BetterRTP extends JavaPlugin {
|
||||
@Getter private final DatabaseHandler databaseHandler = new DatabaseHandler();
|
||||
@Getter private final WarningHandler warningHandler = new WarningHandler();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
new Updater(this);
|
||||
|
||||
@@ -49,11 +49,11 @@ public class RTP {
|
||||
//WorldType
|
||||
RTPLoader.loadWorldTypes(world_type);
|
||||
//Worlds & CustomWorlds
|
||||
RTPLoader.loadWorlds(RTPdefaultWorld, RTPcustomWorld);
|
||||
loadWorlds();
|
||||
//Locations
|
||||
RTPLoader.loadLocations(RTPworldLocations);
|
||||
loadLocations();
|
||||
//Permissions
|
||||
RTPLoader.loadPermissionGroups(permissionGroups);
|
||||
loadPermissionGroups();
|
||||
teleport.load(); //Load teleporting stuff
|
||||
//permConfig.load(); //Load permission configs
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class RTPLoader {
|
||||
exists.set(true);
|
||||
});
|
||||
if (exists.get()) {
|
||||
BetterRTP.debug("- Custom World '" + world + "' registered:");
|
||||
BetterRTP.debug("Custom World '" + world + "' registered:");
|
||||
customWorlds.put(world, new WorldCustom(Bukkit.getWorld(world)));
|
||||
} else
|
||||
BetterRTP.debug("[WARN] - Custom World '" + world + "' was not registered because world does NOT exist");
|
||||
|
||||
@@ -48,12 +48,12 @@ public class RTPTeleport {
|
||||
final int attempts, RTP_TYPE type, WORLD_TYPE worldType) throws NullPointerException {
|
||||
Location oldLoc = p.getLocation();
|
||||
loadingTeleport(p, sendi); //Send loading message to player who requested
|
||||
List<CompletableFuture<Chunk>> asyncChunks = getChunks(location); //Get a list of chunks
|
||||
//List<CompletableFuture<Chunk>> asyncChunks = getChunks(location); //Get a list of chunks
|
||||
//playerLoads.put(p, asyncChunks);
|
||||
CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).thenRun(() -> { //Async chunk load
|
||||
/*CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).thenRun(() -> { //Async chunk load
|
||||
new BukkitRunnable() { //Run synchronously
|
||||
@Override
|
||||
public void run() {
|
||||
public void run() {*/
|
||||
try {
|
||||
RTP_TeleportEvent event = new RTP_TeleportEvent(p, location, worldType);
|
||||
getPl().getServer().getPluginManager().callEvent(event);
|
||||
@@ -75,9 +75,9 @@ public class RTPTeleport {
|
||||
getPl().getpInfo().getRtping().remove(p); //No longer rtp'ing (errored)
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}.runTask(getPl());
|
||||
});
|
||||
// }
|
||||
// }.runTask(getPl());
|
||||
//});
|
||||
}
|
||||
|
||||
//Effects
|
||||
@@ -130,7 +130,7 @@ public class RTPTeleport {
|
||||
|
||||
//Processing
|
||||
|
||||
private List<CompletableFuture<Chunk>> getChunks(Location loc) { //List all chunks in range to load
|
||||
/*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.max(0, Math.min(16, getPl().getSettings().getPreloadRadius())));
|
||||
for (int x = -range; x <= range; x++)
|
||||
@@ -140,7 +140,7 @@ public class RTPTeleport {
|
||||
asyncChunks.add(chunk);
|
||||
}
|
||||
return asyncChunks;
|
||||
}
|
||||
}*/
|
||||
|
||||
private void sendSuccessMsg(CommandSender sendi, String player, Location loc, int price, boolean sameAsPlayer,
|
||||
int attempts) {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class QueueHandler implements Listener { //Randomly queues up some safe l
|
||||
//Rare cases where a rtp world didnt have a location generated (Permission Groups?)
|
||||
if (rtpWorld != null) {
|
||||
List<QueueData> applicable = getApplicable(rtpWorld);
|
||||
String type = "superCustom_" + (rtpWorld.getID() != null ? rtpWorld.getID() : rtpWorld.getWorld().getName());
|
||||
String type = "rtp_" + (rtpWorld.getID() != null ? rtpWorld.getID() : rtpWorld.getWorld().getName());
|
||||
int newCount = lastType.equalsIgnoreCase(type) ? lastCount : applicable.size();
|
||||
int attempt = lastType.equalsIgnoreCase(type) ? attempts : 0;
|
||||
if (newCount < queueMin && applicable.size() < queueMax) {
|
||||
|
||||
@@ -39,20 +39,28 @@ public class WorldCustom implements RTPWorld, RTPWorld_Defaulted {
|
||||
if (test == null)
|
||||
continue;
|
||||
if (test.get("UseWorldBorder") != null) {
|
||||
if (test.get("UseWorldBorder").getClass() == Boolean.class)
|
||||
if (test.get("UseWorldBorder").getClass() == Boolean.class) {
|
||||
useWorldborder = Boolean.parseBoolean(test.get("UseWorldBorder").toString());
|
||||
BetterRTP.debug("- UseWorldBorder: " + this.useWorldborder);
|
||||
}
|
||||
}
|
||||
if (test.get("CenterX") != null) {
|
||||
if (test.get("CenterX").getClass() == Integer.class)
|
||||
if (test.get("CenterX").getClass() == Integer.class) {
|
||||
centerX = Integer.parseInt((test.get("CenterX")).toString());
|
||||
BetterRTP.debug("- CenterX: " + this.centerX);
|
||||
}
|
||||
}
|
||||
if (test.get("CenterZ") != null) {
|
||||
if (test.get("CenterZ").getClass() == Integer.class)
|
||||
if (test.get("CenterZ").getClass() == Integer.class) {
|
||||
centerZ = Integer.parseInt((test.get("CenterZ")).toString());
|
||||
BetterRTP.debug("- CenterZ: " + this.centerZ);
|
||||
}
|
||||
}
|
||||
if (test.get("MaxRadius") != null) {
|
||||
if (test.get("MaxRadius").getClass() == Integer.class)
|
||||
if (test.get("MaxRadius").getClass() == Integer.class) {
|
||||
maxRad = Integer.parseInt((test.get("MaxRadius")).toString());
|
||||
BetterRTP.debug("- MaxRadius: " + this.maxRad);
|
||||
}
|
||||
if (maxRad <= 0) {
|
||||
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Custom world '" + world + "' Maximum radius of '" + maxRad + "' is not allowed! Set to default value!");
|
||||
@@ -60,8 +68,10 @@ public class WorldCustom implements RTPWorld, RTPWorld_Defaulted {
|
||||
}
|
||||
}
|
||||
if (test.get("MinRadius") != null) {
|
||||
if (test.get("MinRadius").getClass() == Integer.class)
|
||||
if (test.get("MinRadius").getClass() == Integer.class) {
|
||||
minRad = Integer.parseInt((test.get("MinRadius")).toString());
|
||||
BetterRTP.debug("- MinRadius: " + this.minRad);
|
||||
}
|
||||
if (minRad < 0 || minRad >= maxRad) {
|
||||
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Custom world '" + world + "' Minimum radius of '" + minRad + "' is not allowed! Set to default value!");
|
||||
@@ -71,86 +81,59 @@ public class WorldCustom implements RTPWorld, RTPWorld_Defaulted {
|
||||
}
|
||||
}
|
||||
if (test.get("Biomes") != null) {
|
||||
if (test.get("Biomes").getClass() == ArrayList.class)
|
||||
if (test.get("Biomes").getClass() == ArrayList.class) {
|
||||
this.biomes = new ArrayList<String>((ArrayList) test.get("Biomes"));
|
||||
BetterRTP.debug("- Biomes: " + this.biomes);
|
||||
}
|
||||
}
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (test.get("Price") != null) {
|
||||
if (test.get("Price").getClass() == Integer.class)
|
||||
this.price = Integer.parseInt(test.get("Price").toString());
|
||||
//else
|
||||
//price = worldDefault.getPrice(world);
|
||||
} //else
|
||||
//price = worldDefault.getPrice(world);
|
||||
BetterRTP.debug("- Price: " + this.price);
|
||||
}
|
||||
if (test.get("Shape") != null) {
|
||||
if (test.get("Shape").getClass() == String.class) {
|
||||
try {
|
||||
this.shape = RTP_SHAPE.valueOf(test.get("Shape").toString().toUpperCase());
|
||||
BetterRTP.debug("- Shape: " + this.shape);
|
||||
} catch (Exception e) {
|
||||
//Invalid shape
|
||||
}
|
||||
}
|
||||
}
|
||||
if (test.get("MinY") != null) {
|
||||
if (test.get("MinY").getClass() == Integer.class)
|
||||
if (test.get("MinY").getClass() == Integer.class) {
|
||||
this.miny = Integer.parseInt((test.get("MinY")).toString());
|
||||
BetterRTP.debug("- MinY: " + this.miny);
|
||||
}
|
||||
}
|
||||
if (test.get("MaxY") != null) {
|
||||
if (test.get("MaxY").getClass() == Integer.class)
|
||||
if (test.get("MaxY").getClass() == Integer.class) {
|
||||
this.maxy = Integer.parseInt((test.get("MaxY")).toString());
|
||||
BetterRTP.debug("- MaxY: " + this.maxy);
|
||||
}
|
||||
}
|
||||
if (test.get("Cooldown") != null) {
|
||||
if (test.get("Cooldown").getClass() == Long.class)
|
||||
if (test.get("Cooldown").getClass() == Integer.class || test.get("Cooldown").getClass() == Long.class) {
|
||||
this.cooldown = Long.parseLong((test.get("Cooldown")).toString());
|
||||
BetterRTP.debug("- Cooldown: " + this.cooldown);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Booleans
|
||||
/*useWorldborder = config.getBoolean(pre + world + ".UseWorldBorder");
|
||||
//Integers
|
||||
CenterX = config.getInt(pre + world + ".CenterX");
|
||||
CenterZ = config.getInt(pre + world + ".CenterZ");
|
||||
maxBorderRad = config.getInt(pre + world + ".MaxRadius");*/
|
||||
}
|
||||
|
||||
if (maxRad <= 0) {
|
||||
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Custom world '" + world + "' Maximum radius of '" + maxRad + "' is not allowed! Set to default value!");
|
||||
maxRad = BetterRTP.getInstance().getRTP().RTPdefaultWorld.getMaxRadius();
|
||||
}
|
||||
//minBorderRad = config.getInt(pre + world + ".MinRadius");
|
||||
|
||||
if (minRad < 0 || minRad >= maxRad) {
|
||||
BetterRTP.getInstance().getText().sms(Bukkit.getConsoleSender(),
|
||||
"WARNING! Custom world '" + world + "' Minimum radius of '" + minRad + "' is not allowed! Set to default value!");
|
||||
minRad = BetterRTP.getInstance().getRTP().RTPdefaultWorld.getMinRadius();
|
||||
}
|
||||
/*if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
if (BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("CustomWorlds.Enabled")) {
|
||||
List<Map<?, ?>> world_map = BetterRTP.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getMapList("CustomWorlds.Worlds");
|
||||
for (Map<?, ?> m : world_map)
|
||||
for (Map.Entry<?, ?> entry : m.entrySet()) {
|
||||
String _world = entry.getKey().toString();
|
||||
//System.out.println("Custom World Price " + _world + ":" + entry.getValue().toString());
|
||||
if (!_world.equals(world))
|
||||
continue;
|
||||
if (entry.getValue().getClass() == Integer.class)
|
||||
price = Integer.parseInt((entry.getValue().toString()));
|
||||
}
|
||||
} else
|
||||
price = worldDefault.getPrice();*/
|
||||
//Other
|
||||
//this.Biomes = config.getStringList("CustomWorlds." + world + ".Biomes");
|
||||
|
||||
if (BetterRTP.getInstance().getSettings().isDebug()) {
|
||||
Logger log = BetterRTP.getInstance().getLogger();
|
||||
log.info("- -World: " + this.world.getName());
|
||||
log.info("- UseWorldBorder: " + this.useWorldborder);
|
||||
log.info("- CenterX: " + this.centerX);
|
||||
log.info("- CenterZ: " + this.centerZ);
|
||||
log.info("- MaxRadius: " + this.maxRad);
|
||||
log.info("- MinRadius: " + this.minRad);
|
||||
log.info("- Price: " + this.price);
|
||||
log.info("- MinY: " + this.miny);
|
||||
log.info("- MaxY: " + this.maxy);
|
||||
}
|
||||
}
|
||||
|
||||
public WorldCustom(World world, RTPWorld rtpWorld) {
|
||||
|
||||
@@ -82,6 +82,7 @@ public class WorldDefault implements RTPWorld {
|
||||
log.info("- Price: " + this.price);
|
||||
log.info("- MinY: " + this.miny);
|
||||
log.info("- MaxY: " + this.maxy);
|
||||
log.info("- Cooldown (default): " + getCooldown());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ public class WorldLocations implements RTPWorld, RTPWorld_Defaulted {
|
||||
if (test.get("MaxY").getClass() == Integer.class)
|
||||
this.maxy = Integer.parseInt(test.get("MaxY").toString());
|
||||
if (test.get("Cooldown") != null)
|
||||
if (test.get("Cooldown").getClass() == Long.class)
|
||||
if (test.get("Cooldown").getClass() == Integer.class || test.get("Cooldown").getClass() == Long.class)
|
||||
this.cooldown = Long.parseLong(test.get("Cooldown").toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,9 +118,9 @@ public class WorldPermissionGroup implements RTPWorld, RTPWorld_Defaulted {
|
||||
BetterRTP.debug("- - MaxY: " + maxy);
|
||||
}
|
||||
if (field.equalsIgnoreCase("Cooldown"))
|
||||
if (hash3.getValue().getClass() == Long.class) {
|
||||
if (hash3.getValue().getClass() == Integer.class || hash3.getValue().getClass() == Long.class) {
|
||||
this.cooldown = Long.parseLong(hash3.getValue().toString());
|
||||
BetterRTP.debug("- - Custom Cooldown: " + cooldown);
|
||||
BetterRTP.debug("- - Cooldown: " + cooldown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user