diff --git a/pom.xml b/pom.xml
index b67db22..19ccd4a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,13 +6,50 @@
me.SuperRonanCraft
BetterRTP
- 1.0-SNAPSHOT
+ 2.11.2
1.8
1.8
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 3.1.1
+
+ ${project.build.directory}/dependency-reduced-pom.xml
+
+
+ io.papermc.lib
+ me.SuperRonanCraft.BetterRTP.paperlib
+
+
+
+
+
+ package
+
+ shade
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.2.0
+
+ ../../Java/plugins
+
+
+
+
+
+
spigot-repo
@@ -26,12 +63,14 @@
sk89q-repo
http://maven.sk89q.com/repo/
-
jitpack.io
https://jitpack.io
-
+
+ papermc
+ https://papermc.io/repo/repository/maven-public/
+
@@ -72,5 +111,12 @@
16.7.1
provided
+
+
+ io.papermc
+ paperlib
+ 1.0.5
+ compile
+
\ No newline at end of file
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/RTP.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/RTP.java
index bf64cae..8eeea81 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/RTP.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/RTP.java
@@ -153,8 +153,8 @@ public class RTP {
return;
}
// Delaying? Else, just go
+ getPl().getCmd().rtping.put(p.getUniqueId(), true);
if (delay) {
- getPl().getCmd().rtping.put(p.getUniqueId(), true);
new Delay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage);
} else
tp(sendi, pWorld);
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/player/RTPTeleport.java b/src/main/java/me/SuperRonanCraft/BetterRTP/player/RTPTeleport.java
index 0c213fa..f41e604 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/RTPTeleport.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/RTPTeleport.java
@@ -1,16 +1,24 @@
package me.SuperRonanCraft.BetterRTP.player;
+import io.papermc.lib.PaperLib;
import me.SuperRonanCraft.BetterRTP.Main;
+import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+
public class RTPTeleport {
void sendPlayer(final CommandSender sendi, final Player p, final Location loc, final int price,
final int attempts) throws NullPointerException {
+ getPl().getText().getSuccessLoading(sendi); //Send loading message
+ loadChunks(loc); //Load chunks before teleporting
new BukkitRunnable(){
@Override
public void run() {
@@ -21,17 +29,43 @@ public class RTPTeleport {
if (getPl().getText().getTitleEnabled())
titles(p, loc, attempts);
try {
- //loc.getWorld().loadChunk(loc.getChunk());
- p.teleport(loc);
+ //p.teleport(loc);
+ PaperLib.teleportAsync(p, loc); //Async teleport
} catch (Exception e) {
e.printStackTrace();
}
if (getPl().getText().getSoundsEnabled())
sounds(p);
- }
+ getPl().getCmd().rtping.put(p.getUniqueId(), false); //Dont let them rtp again until current is done!
+ }
}.runTask(getPl());
}
+ private void loadChunks(Location loc) { //Async chunk loading
+ List> asyncChunks = new ArrayList<>();
+ for (int x = -5; x <= 5; x++) {
+ for (int z = -5; z <= 5; z++) {
+ Location locLoad = new Location(loc.getWorld(), loc.getX() + (x * 16), loc.getY(), loc.getZ() + (x * 16));
+ CompletableFuture chunk = PaperLib.getChunkAtAsync(locLoad, true);
+ asyncChunks.add(chunk);
+ }
+ }
+ while (!checkLoaded(asyncChunks)) {
+ try {
+ Thread.sleep(500); //Sleep and check again 0.5 seconds later
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private boolean checkLoaded(List> asyncChunks) {
+ for (CompletableFuture chunk : asyncChunks)
+ if (!chunk.isDone())
+ return false;
+ return true;
+ }
+
private void checkPH(CommandSender sendi, String player, Location loc, int price, boolean sameAsPlayer,
int attempts) {
String x = Integer.toString(loc.getBlockX());
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 1c90e2e..3e7d280 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/Commands.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/player/commands/Commands.java
@@ -140,17 +140,14 @@ public class Commands {
}
private boolean checkDelay(CommandSender sendi, Player player) {
- //Bypassing/Forced?
- if (sendi != player || pl.getPerms().getBypassCooldown(player))
- return true;
- //Currently rtp'ing?
- else if (rtping.containsKey(player.getUniqueId()))
+ if (rtping.containsKey(player.getUniqueId())) //Already rtp'ing
if (rtping.get(player.getUniqueId())) {
pl.getText().getAlready(player);
return false;
}
- //Cooling down?
- if (cooldownTimer) {
+ else if (sendi != player || pl.getPerms().getBypassCooldown(player)) //Bypassing/Forced?
+ return true;
+ else if (cooldownTimer) { //Cooling down?
Player p = (Player) sendi;
if (cooldowns.containsKey(p.getUniqueId())) {
long Left = ((cooldowns.get(p.getUniqueId()) / 1000) + cooldown) - (System.currentTimeMillis() / 1000);
diff --git a/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/Messages.java b/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/Messages.java
index aaafa1f..10f0f9f 100644
--- a/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/Messages.java
+++ b/src/main/java/me/SuperRonanCraft/BetterRTP/references/file/Messages.java
@@ -35,6 +35,10 @@ public class Messages {
("%z%", z).replaceAll("%world%", world).replaceAll("%attempts%", Integer.toString(attemtps)));
}
+ public void getSuccessLoading(CommandSender sendi) {
+ sms(sendi, getLang().getString(preM + "Success.Loading"));
+ }
+
public void getFailedNotSafe(CommandSender sendi, int attempts) {
sms(sendi, getLang().getString(preM + "Failed.NotSafe").replaceAll("%attempts%", Integer.toString(attempts)));
}
diff --git a/src/main/resources/lang/chn.yml b/src/main/resources/lang/chn.yml
index aec0d38..fe01b2f 100644
--- a/src/main/resources/lang/chn.yml
+++ b/src/main/resources/lang/chn.yml
@@ -3,6 +3,7 @@ Messages:
Success: ## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! #
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...'
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 c111ab0..a3aceef 100644
--- a/src/main/resources/lang/cht.yml
+++ b/src/main/resources/lang/cht.yml
@@ -3,6 +3,7 @@ Messages:
Success: ## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! #
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...'
Failed:
Price: '&c您的資金不夠了!&7您需要有$%price%&7才能嘗試RTP!'
NotSafe: '&c由於%attempts%次嘗試內未能找到適合的地方傳送,&7您未被傳送!'
diff --git a/src/main/resources/lang/en.yml b/src/main/resources/lang/en.yml
index 7d4a3f0..0248914 100644
--- a/src/main/resources/lang/en.yml
+++ b/src/main/resources/lang/en.yml
@@ -3,6 +3,7 @@ Messages:
Success: ## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! #
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...'
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 90a3d9a..463b74b 100644
--- a/src/main/resources/lang/fr.yml
+++ b/src/main/resources/lang/fr.yml
@@ -4,6 +4,7 @@ Messages:
Success:
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...'
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é!'
@@ -54,11 +55,11 @@ Help:
Usage:
Player: '&cUtilisation&7: /%command% player [monde]'
World: '&cUtilisation&7: /%command% world '
+ Biome: '&cUtilisation&7: /%command% biome '
Sounds:
Enabled: true
- ## Plus de sons à https://www.spigotmc.org/wiki/cc-sounds-list/
- ## Son à jouer lors de la téléportation avec délai ##
+ ## Plus de sons à https://www.spigotmc.org/wiki/cc-sounds-list/ ## Son à jouer lors de la téléportation avec délai ##
Delay: 'entity_tnt_primed'
##Son à jouer lorsque la téléportation à réussie ##
- Success: 'entity_generic_explode'
+ Success: 'entity_generic_explode'
\ No newline at end of file
diff --git a/src/main/resources/lang/ja.yml b/src/main/resources/lang/ja.yml
index 9a7b5c3..a33c8ac 100644
--- a/src/main/resources/lang/ja.yml
+++ b/src/main/resources/lang/ja.yml
@@ -3,6 +3,7 @@ Messages:
Success:
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...'
Failed:
Price: '&c資金が不十分のためRTPできませんでした! &7RTPには最低$%price%&7が必要です!'
NotSafe: '&c%attempts%回の試行で安全な場所が見つかりませんでした! &7あなたははRTPされませんでした!'
@@ -14,6 +15,7 @@ Messages:
NoPermission:
Basic: '&cごめんなさい! &7このコマンドを使う権限がありません!'
World: '&cごめんなさい! &7ワールド%world%ではrtpが許可されていません!'
+ ##
DisabledWorld: '&cワールド%world%は無効です! &7RTPできませんでした!'
Cooldown: '&cごめんなさい! &7あなたは&c%time%&7秒間RTPできません!'
Invalid: '&c無効な引数。 ''/%command% help''を試してください。'
@@ -27,11 +29,15 @@ Messages:
Titles:
Enabled: true
Delay:
+ ##
SendChatMessage: true
+ ##
Title: '&6BetterRTP by SRC'
Subtitle: '&f%time%秒でテレポート!'
Success:
+ ##
SendChatMessage: true
+ ##
Title: '&6BetterRTP by SRC &7(%attempts%)'
Subtitle: '&fx=%x% y=%y% z=%z% にテレポート'
@@ -40,8 +46,10 @@ Help:
- '&e&m------&r &6&lBetterRTP &8| &7ヘルプ&e&m------'
- ' &7- &e/%command% &7- あなたをランダムテレポートする!'
- ' &7- &e/%command% help &7- ヘルプを見る'
+ ##
Player: ' &7- &e/%command% player [world] &7- 他のプレイヤーをランダムテレポート'
World: ' &7- &e/%command% world &7- 他のワールドにランダムテレポート'
+ ##
Biome: ' &7- &e/%command% biome &7- Randomly teleport withing these biomes'
Reload: ' &7- &e/%command% reload &7- プラグインをリロード'
@@ -54,4 +62,4 @@ Sounds:
Enabled: true
## More sounds at https://www.spigotmc.org/wiki/cc-sounds-list/
Delay: 'entity_tnt_primed'
- Success: 'entity_generic_explode'
+ Success: 'entity_generic_explode'
\ No newline at end of file
diff --git a/src/main/resources/lang/ru.yml b/src/main/resources/lang/ru.yml
index 7b85bf7..6631829 100644
--- a/src/main/resources/lang/ru.yml
+++ b/src/main/resources/lang/ru.yml
@@ -1,9 +1,9 @@
Messages:
Prefix: '&7[&6BetterRTP&7] '
- ## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! #
- Success:
+ Success: ## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! #
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...'
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 c1dcd84..f93d17a 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
main: me.SuperRonanCraft.BetterRTP.Main
-version: '2.11.1-BETA'
+version: '2.11.2'
name: BetterRTP
author: SuperRonanCraft
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]