2.11.2 - Async Update

This commit is contained in:
SuperRonanCraft 2020-08-06 14:04:00 -04:00
parent 46800d4596
commit 76ab0f1630
12 changed files with 114 additions and 21 deletions

52
pom.xml
View File

@ -6,13 +6,50 @@
<groupId>me.SuperRonanCraft</groupId> <groupId>me.SuperRonanCraft</groupId>
<artifactId>BetterRTP</artifactId> <artifactId>BetterRTP</artifactId>
<version>1.0-SNAPSHOT</version> <version>2.11.2</version>
<properties> <properties>
<maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.target>1.8</maven.compiler.target>
</properties> </properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>me.SuperRonanCraft.BetterRTP.paperlib</shadedPattern> <!-- Replace this -->
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Local Server Building -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<outputDirectory>../../Java/plugins</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
@ -26,12 +63,14 @@
<id>sk89q-repo</id> <id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url> <url>http://maven.sk89q.com/repo/</url>
</repository> </repository>
<repository> <repository>
<id>jitpack.io</id> <id>jitpack.io</id>
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
<!--Spigot API--> <!--Spigot API-->
@ -72,5 +111,12 @@
<version>16.7.1</version> <version>16.7.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Paper Library for Async Chunk/Teleport -->
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.5</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -153,8 +153,8 @@ public class RTP {
return; return;
} }
// Delaying? Else, just go // Delaying? Else, just go
getPl().getCmd().rtping.put(p.getUniqueId(), true);
if (delay) { if (delay) {
getPl().getCmd().rtping.put(p.getUniqueId(), true);
new Delay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage); new Delay(sendi, pWorld, delayTime, cancelOnMove, cancelOnDamage);
} else } else
tp(sendi, pWorld); tp(sendi, pWorld);

View File

@ -1,16 +1,24 @@
package me.SuperRonanCraft.BetterRTP.player; package me.SuperRonanCraft.BetterRTP.player;
import io.papermc.lib.PaperLib;
import me.SuperRonanCraft.BetterRTP.Main; import me.SuperRonanCraft.BetterRTP.Main;
import org.bukkit.Chunk;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class RTPTeleport { public class RTPTeleport {
void sendPlayer(final CommandSender sendi, final Player p, final Location loc, final int price, void sendPlayer(final CommandSender sendi, final Player p, final Location loc, final int price,
final int attempts) throws NullPointerException { final int attempts) throws NullPointerException {
getPl().getText().getSuccessLoading(sendi); //Send loading message
loadChunks(loc); //Load chunks before teleporting
new BukkitRunnable(){ new BukkitRunnable(){
@Override @Override
public void run() { public void run() {
@ -21,17 +29,43 @@ public class RTPTeleport {
if (getPl().getText().getTitleEnabled()) if (getPl().getText().getTitleEnabled())
titles(p, loc, attempts); titles(p, loc, attempts);
try { try {
//loc.getWorld().loadChunk(loc.getChunk()); //p.teleport(loc);
p.teleport(loc); PaperLib.teleportAsync(p, loc); //Async teleport
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (getPl().getText().getSoundsEnabled()) if (getPl().getText().getSoundsEnabled())
sounds(p); sounds(p);
} getPl().getCmd().rtping.put(p.getUniqueId(), false); //Dont let them rtp again until current is done!
}
}.runTask(getPl()); }.runTask(getPl());
} }
private void loadChunks(Location loc) { //Async chunk loading
List<CompletableFuture<Chunk>> 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> 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<CompletableFuture<Chunk>> asyncChunks) {
for (CompletableFuture<Chunk> chunk : asyncChunks)
if (!chunk.isDone())
return false;
return true;
}
private void checkPH(CommandSender sendi, String player, Location loc, int price, boolean sameAsPlayer, private void checkPH(CommandSender sendi, String player, Location loc, int price, boolean sameAsPlayer,
int attempts) { int attempts) {
String x = Integer.toString(loc.getBlockX()); String x = Integer.toString(loc.getBlockX());

View File

@ -140,17 +140,14 @@ public class Commands {
} }
private boolean checkDelay(CommandSender sendi, Player player) { private boolean checkDelay(CommandSender sendi, Player player) {
//Bypassing/Forced? if (rtping.containsKey(player.getUniqueId())) //Already rtp'ing
if (sendi != player || pl.getPerms().getBypassCooldown(player))
return true;
//Currently rtp'ing?
else if (rtping.containsKey(player.getUniqueId()))
if (rtping.get(player.getUniqueId())) { if (rtping.get(player.getUniqueId())) {
pl.getText().getAlready(player); pl.getText().getAlready(player);
return false; return false;
} }
//Cooling down? else if (sendi != player || pl.getPerms().getBypassCooldown(player)) //Bypassing/Forced?
if (cooldownTimer) { return true;
else if (cooldownTimer) { //Cooling down?
Player p = (Player) sendi; Player p = (Player) sendi;
if (cooldowns.containsKey(p.getUniqueId())) { if (cooldowns.containsKey(p.getUniqueId())) {
long Left = ((cooldowns.get(p.getUniqueId()) / 1000) + cooldown) - (System.currentTimeMillis() / 1000); long Left = ((cooldowns.get(p.getUniqueId()) / 1000) + cooldown) - (System.currentTimeMillis() / 1000);

View File

@ -35,6 +35,10 @@ public class Messages {
("%z%", z).replaceAll("%world%", world).replaceAll("%attempts%", Integer.toString(attemtps))); ("%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) { public void getFailedNotSafe(CommandSender sendi, int attempts) {
sms(sendi, getLang().getString(preM + "Failed.NotSafe").replaceAll("%attempts%", Integer.toString(attempts))); sms(sendi, getLang().getString(preM + "Failed.NotSafe").replaceAll("%attempts%", Integer.toString(attempts)));
} }

View File

@ -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! # 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次' 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次' Bypass: '&a你被传送到了&7 x=%x% y=%y% z=%z%。共尝试&f%attempts%&7次'
Loading: '&aSafe spot located! &7Loading chunks...'
Failed: Failed:
Price: '&c你的钱不够了&7你至少要有$%price%&7才能随机传送' Price: '&c你的钱不够了&7你至少要有$%price%&7才能随机传送'
NotSafe: '&c由于在%attempts%次尝试内未能找到安全的位置,&7你未被传送' NotSafe: '&c由于在%attempts%次尝试内未能找到安全的位置,&7你未被传送'

View File

@ -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! # 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次' 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次' Bypass: '&a您被傳送到了&7 x=%x% y=%y% z=%z%。一共嘗試&f%attempts%&7次'
Loading: '&aSafe spot located! &7Loading chunks...'
Failed: Failed:
Price: '&c您的資金不夠了&7您需要有$%price%&7才能嘗試RTP' Price: '&c您的資金不夠了&7您需要有$%price%&7才能嘗試RTP'
NotSafe: '&c由於%attempts%次嘗試內未能找到適合的地方傳送,&7您未被傳送' NotSafe: '&c由於%attempts%次嘗試內未能找到適合的地方傳送,&7您未被傳送'

View File

@ -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! # 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!' 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' 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: Failed:
Price: '&cCould not rtp because of insufficent funds! &7You must have atleast $%price% &7to rtp!' 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!' NotSafe: '&cCould not find safe spot within %attempts% attempts! &7You were not RTP''d!'

View File

@ -4,6 +4,7 @@ Messages:
Success: Success:
Paid: '&aTu a été téléporté à&7 x=%x% y=%y% z=%z% pour &c$%price%&7 en &f%attempts% &7tentatives!' 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!' 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: 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!' 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é!' 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: Usage:
Player: '&cUtilisation&7: /%command% player <joeur> [monde]' Player: '&cUtilisation&7: /%command% player <joeur> [monde]'
World: '&cUtilisation&7: /%command% world <monde>' World: '&cUtilisation&7: /%command% world <monde>'
Biome: '&cUtilisation&7: /%command% biome <biome1, biome2...>'
Sounds: Sounds:
Enabled: true Enabled: true
## Plus de sons à https://www.spigotmc.org/wiki/cc-sounds-list/ ## Plus de sons à https://www.spigotmc.org/wiki/cc-sounds-list/ ## Son à jouer lors de la téléportation avec délai ##
## Son à jouer lors de la téléportation avec délai ##
Delay: 'entity_tnt_primed' Delay: 'entity_tnt_primed'
##Son à jouer lorsque la téléportation à réussie ## ##Son à jouer lorsque la téléportation à réussie ##
Success: 'entity_generic_explode' Success: 'entity_generic_explode'

View File

@ -3,6 +3,7 @@ Messages:
Success: Success:
Paid: '&aあなたは&c$%price%&aで&7x=%x% y=%y% z=%z% に&f%attempts%&7回の試行でTPされました' 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されました' Bypass: '&aあなたは&7x=%x% y=%y% z=%z% に&f%attempts%&7回の試行でTPされました'
Loading: '&aSafe spot located! &7Loading chunks...'
Failed: Failed:
Price: '&c資金が不十分のためRTPできませんでした &7RTPには最低$%price%&7が必要です' Price: '&c資金が不十分のためRTPできませんでした &7RTPには最低$%price%&7が必要です'
NotSafe: '&c%attempts%回の試行で安全な場所が見つかりませんでした! &7あなたははRTPされませんでした' NotSafe: '&c%attempts%回の試行で安全な場所が見つかりませんでした! &7あなたははRTPされませんでした'
@ -14,6 +15,7 @@ Messages:
NoPermission: NoPermission:
Basic: '&cごめんなさい &7このコマンドを使う権限がありません' Basic: '&cごめんなさい &7このコマンドを使う権限がありません'
World: '&cごめんなさい &7ワールド%world%ではrtpが許可されていません' World: '&cごめんなさい &7ワールド%world%ではrtpが許可されていません'
##
DisabledWorld: '&cワールド%world%は無効です! &7RTPできませんでした' DisabledWorld: '&cワールド%world%は無効です! &7RTPできませんでした'
Cooldown: '&cごめんなさい &7あなたは&c%time%&7秒間RTPできません' Cooldown: '&cごめんなさい &7あなたは&c%time%&7秒間RTPできません'
Invalid: '&c無効な引数。 ''/%command% help''を試してください。' Invalid: '&c無効な引数。 ''/%command% help''を試してください。'
@ -27,11 +29,15 @@ Messages:
Titles: Titles:
Enabled: true Enabled: true
Delay: Delay:
##
SendChatMessage: true SendChatMessage: true
##
Title: '&6BetterRTP by SRC' Title: '&6BetterRTP by SRC'
Subtitle: '&f%time%秒でテレポート!' Subtitle: '&f%time%秒でテレポート!'
Success: Success:
##
SendChatMessage: true SendChatMessage: true
##
Title: '&6BetterRTP by SRC &7(%attempts%)' Title: '&6BetterRTP by SRC &7(%attempts%)'
Subtitle: '&fx=%x% y=%y% z=%z% にテレポート' Subtitle: '&fx=%x% y=%y% z=%z% にテレポート'
@ -40,8 +46,10 @@ Help:
- '&e&m------&r &6&lBetterRTP &8| &7ヘルプ&e&m------' - '&e&m------&r &6&lBetterRTP &8| &7ヘルプ&e&m------'
- ' &7- &e/%command% &7- あなたをランダムテレポートする!' - ' &7- &e/%command% &7- あなたをランダムテレポートする!'
- ' &7- &e/%command% help &7- ヘルプを見る' - ' &7- &e/%command% help &7- ヘルプを見る'
##
Player: ' &7- &e/%command% player <player> [world] &7- 他のプレイヤーをランダムテレポート' Player: ' &7- &e/%command% player <player> [world] &7- 他のプレイヤーをランダムテレポート'
World: ' &7- &e/%command% world <world> &7- 他のワールドにランダムテレポート' World: ' &7- &e/%command% world <world> &7- 他のワールドにランダムテレポート'
##
Biome: ' &7- &e/%command% biome <biome1, biome2...> &7- Randomly teleport withing these biomes' Biome: ' &7- &e/%command% biome <biome1, biome2...> &7- Randomly teleport withing these biomes'
Reload: ' &7- &e/%command% reload &7- プラグインをリロード' Reload: ' &7- &e/%command% reload &7- プラグインをリロード'

View File

@ -1,9 +1,9 @@
Messages: Messages:
Prefix: '&7[&6BetterRTP&7] ' Prefix: '&7[&6BetterRTP&7] '
## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! # Success: ## Placeholders! %x% %y% and %z% are the x, y, and z coordinates that the player is being teleported to! #
Success:
Paid: '&aВас телепортировало на&7 x=%x% y=%y% z=%z% за &c$%price%&7, за &f%attempts% &7попыток!' 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попыток' Bypass: '&aВас телепортировало на&7 x=%x% y=%y% z=%z% за &f%attempts% &7попыток'
Loading: '&aSafe spot located! &7Loading chunks...'
Failed: Failed:
Price: '&cУ вас недостаточно денег для телепортации! &7У вас должно быть хотябы $%price% &7для rtp!' Price: '&cУ вас недостаточно денег для телепортации! &7У вас должно быть хотябы $%price% &7для rtp!'
NotSafe: '&cНе удалось найти безопасное место за %attempts% попыток! &7Вас не телепортировало!' NotSafe: '&cНе удалось найти безопасное место за %attempts% попыток! &7Вас не телепортировало!'

View File

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