mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-18 09:35:50 +00:00
titles converted to effects + Delays message touch up
This commit is contained in:
parent
5a497dfc9e
commit
375ade83b3
@ -12,9 +12,10 @@ public class CmdTest implements RTPCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sendi, String label, String[] args) {
|
public void execute(CommandSender sendi, String label, String[] args) {
|
||||||
if (sendi instanceof Player)
|
if (sendi instanceof Player) {
|
||||||
Main.getInstance().getRTP().getTeleport().afterTeleport((Player) sendi);
|
Player p = (Player) sendi;
|
||||||
else
|
Main.getInstance().getRTP().getTeleport().afterTeleport(p, p.getLocation(), 0, 0);
|
||||||
|
} else
|
||||||
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
|
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ class RTPDelay implements Listener {
|
|||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void delay(CommandSender sendi, int delay) {
|
private void delay(CommandSender sendi, int delay) {
|
||||||
Main pl = Main.getInstance();
|
Main pl = Main.getInstance();
|
||||||
if (sendi.equals(pWorld.getPlayer()) && delay != 0 && getPl().getText().getTitleDelayChat())
|
// if (sendi.equals(pWorld.getPlayer()) && delay != 0 && getPl().getText().getTitleDelayChat())
|
||||||
getPl().getText().getDelay(sendi, String.valueOf(delay));
|
// getPl().getText().getDelay(sendi, String.valueOf(delay));
|
||||||
// if (getPl().getText().getSoundsEnabled()) {
|
// if (getPl().getText().getSoundsEnabled()) {
|
||||||
// Sound sound = getPl().getText().getSoundsDelay();
|
// Sound sound = getPl().getText().getSoundsDelay();
|
||||||
// if (sound != null)
|
// if (sound != null)
|
||||||
@ -44,8 +44,8 @@ class RTPDelay implements Listener {
|
|||||||
// // player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
// // player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
||||||
// // pWorld.getPlayer().sendTitle(title, subTitle);
|
// // pWorld.getPlayer().sendTitle(title, subTitle);
|
||||||
// }
|
// }
|
||||||
getPl().getRTP().getTeleport().beforeTeleport(pWorld.getPlayer());
|
getPl().getRTP().getTeleport().beforeTeleport(pWorld.getPlayer(), delay);
|
||||||
run = Bukkit.getScheduler().scheduleSyncDelayedTask(pl, run(sendi, this), delay * 2 * 10);
|
run = Bukkit.getScheduler().scheduleSyncDelayedTask(pl, run(sendi, this), delay * 20);
|
||||||
//Bukkit.getScheduler().scheduleSyncRepeatingTask(pl, run(sendi, this), 0, 10);
|
//Bukkit.getScheduler().scheduleSyncRepeatingTask(pl, run(sendi, this), 0, 10);
|
||||||
if (cancelOnMove || cancelOnDamage)
|
if (cancelOnMove || cancelOnDamage)
|
||||||
Bukkit.getPluginManager().registerEvents(this, Main.getInstance());
|
Bukkit.getPluginManager().registerEvents(this, Main.getInstance());
|
||||||
|
@ -4,7 +4,6 @@ import io.papermc.lib.PaperLib;
|
|||||||
import me.SuperRonanCraft.BetterRTP.Main;
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
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;
|
||||||
@ -30,7 +29,7 @@ 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 {
|
||||||
if (sendi != p) //Tell sendi that the player will/is being rtp'd
|
if (sendi != p) //Tell sendi that the player will/is being rtp'd
|
||||||
checkPH(sendi, p.getDisplayName(), loc, price, false, attempts);
|
sendSuccessMsg(sendi, p.getDisplayName(), loc, price, false, attempts);
|
||||||
getPl().getText().getSuccessLoading(sendi); //Send loading message
|
getPl().getText().getSuccessLoading(sendi); //Send loading message
|
||||||
List<CompletableFuture<Chunk>> asyncChunks = getChunks(loc); //Get a list of chunks
|
List<CompletableFuture<Chunk>> asyncChunks = getChunks(loc); //Get a list of chunks
|
||||||
CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).thenRun(() -> { //Async chunk load
|
CompletableFuture.allOf(asyncChunks.toArray(new CompletableFuture[] {})).thenRun(() -> { //Async chunk load
|
||||||
@ -49,15 +48,18 @@ public class RTPTeleport {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void afterTeleport(Player p, Location loc, int price, int attempts) {
|
public void afterTeleport(Player p, Location loc, int price, int attempts) { //Only a successful rtp should run this OR '/rtp test'
|
||||||
eSounds.playTeleport(p);
|
eSounds.playTeleport(p);
|
||||||
eParticles.display(p);
|
eParticles.display(p);
|
||||||
ePotions.giveEffects(p);
|
ePotions.giveEffects(p);
|
||||||
eTitles.show(p);
|
eTitles.showTeleport(p, loc, attempts);
|
||||||
|
sendSuccessMsg(p, p.getDisplayName(), loc, price, true, attempts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beforeTeleport(Player p) {
|
public void beforeTeleport(Player p, int delay) { //Only Delays should call this
|
||||||
eSounds.playDelay(p);
|
eSounds.playDelay(p);
|
||||||
|
eTitles.showDelay(p, p.getLocation());
|
||||||
|
getPl().getText().getDelay(p, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -73,8 +75,8 @@ public class RTPTeleport {
|
|||||||
return asyncChunks;
|
return asyncChunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkPH(CommandSender sendi, String player, Location loc, int price, boolean sameAsPlayer,
|
private void sendSuccessMsg(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());
|
||||||
String y = Integer.toString(loc.getBlockY());
|
String y = Integer.toString(loc.getBlockY());
|
||||||
String z = Integer.toString(loc.getBlockZ());
|
String z = Integer.toString(loc.getBlockZ());
|
||||||
@ -88,21 +90,6 @@ public class RTPTeleport {
|
|||||||
getPl().getText().getOtherSuccess(sendi, player, x, y, z, world, attempts);
|
getPl().getText().getOtherSuccess(sendi, player, x, y, z, world, attempts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"deprecation"})
|
|
||||||
private void titles(Player p, Location loc, int attempts) {
|
|
||||||
// int fadeIn = getPl().text.getFadeIn();
|
|
||||||
// int stay = text.getStay();
|
|
||||||
// int fadeOut = text.getFadeOut();
|
|
||||||
String x = String.valueOf(loc.getBlockX());
|
|
||||||
String y = String.valueOf(loc.getBlockY());
|
|
||||||
String z = String.valueOf(loc.getBlockZ());
|
|
||||||
String title = getPl().getText().getTitleSuccess(p.getName(), x, y, z, attempts);
|
|
||||||
String subTitle = getPl().getText().getSubTitleSuccess(p.getName(), x, y, z, attempts);
|
|
||||||
// player.sendMessage(Bukkit.getServer().getVersion());
|
|
||||||
// player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
|
||||||
p.sendTitle(title, subTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Main getPl() {
|
private Main getPl() {
|
||||||
return Main.getInstance();
|
return Main.getInstance();
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,56 @@
|
|||||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class RTPTitles {
|
public class RTPTitles {
|
||||||
|
|
||||||
|
private boolean enabled;
|
||||||
|
private String
|
||||||
|
titleTeleport,
|
||||||
|
titleDelay,
|
||||||
|
subTeleport,
|
||||||
|
subDelay;
|
||||||
|
|
||||||
void load() {
|
void load() {
|
||||||
if (getPl().getText().getTitleSuccessChat())
|
FileBasics.FILETYPE config = FileBasics.FILETYPE.EFFECTS;
|
||||||
checkPH(p, p.getDisplayName(), loc, price, true, attempts);
|
enabled = config.getBoolean("Titles.Enabled");
|
||||||
if (getPl().getText().getTitleEnabled())
|
if (enabled) {
|
||||||
titles(p, loc, attempts);
|
titleTeleport = config.getString("Titles.Teleport.Title");
|
||||||
|
titleDelay = config.getString("Titles.Teleport.Title");
|
||||||
|
subTeleport = config.getString("Titles.Teleport.Title");
|
||||||
|
subDelay = config.getString("Titles.Teleport.Title");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void show(Player p) {
|
void showTeleport(Player p, Location loc, int attempts) {
|
||||||
|
if (!enabled) return;
|
||||||
|
String title = getPlaceholders(titleTeleport, p, loc, attempts);
|
||||||
|
String subTitle = getPlaceholders(subTeleport, p, loc, attempts);
|
||||||
|
show(p, title, subTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void showDelay(Player p, Location loc) {
|
||||||
|
if (!enabled) return;
|
||||||
|
String title = getPlaceholders(titleDelay, p, loc, 0);
|
||||||
|
String subTitle = getPlaceholders(subDelay, p, loc, 0);
|
||||||
|
show(p, title, subTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getPlaceholders(String str, Player p, Location loc, int attempts) {
|
||||||
|
return str.replace("%player%", p.getName())
|
||||||
|
.replace("%x%", String.valueOf(loc.getBlockX()))
|
||||||
|
.replace("%y%", String.valueOf(loc.getBlockY()))
|
||||||
|
.replace("%z%", String.valueOf(loc.getBlockZ()))
|
||||||
|
.replace("%attempts%", String.valueOf(attempts));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void show(Player p, String title, String sub) {
|
||||||
|
// int fadeIn = getPl().text.getFadeIn();
|
||||||
|
// int stay = text.getStay();
|
||||||
|
// int fadeOut = text.getFadeOut();
|
||||||
|
p.sendTitle(title, sub);
|
||||||
|
// player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,8 @@ public class Messages {
|
|||||||
sms(sendi, getLang().getString(preM + "NotOnline").replaceAll("%player%", player));
|
sms(sendi, getLang().getString(preM + "NotOnline").replaceAll("%player%", player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getDelay(CommandSender sendi, String time) {
|
public void getDelay(CommandSender sendi, int time) {
|
||||||
sms(sendi, getLang().getString(preM + "Delay").replaceAll("%time%", time));
|
sms(sendi, getLang().getString(preM + "Delay").replaceAll("%time%", String.valueOf(time)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getSignCreated(CommandSender sendi, String cmd) {
|
public void getSignCreated(CommandSender sendi, String cmd) {
|
||||||
|
@ -5,18 +5,15 @@ Sounds:
|
|||||||
Success: 'entity_generic_explode'
|
Success: 'entity_generic_explode'
|
||||||
Titles:
|
Titles:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Delay:
|
Teleport:
|
||||||
## Setting to also send the chat message, ignores the Enabled setting
|
|
||||||
SendChatMessage: true
|
|
||||||
## Both support %player% placeholders
|
|
||||||
Title: ' '
|
|
||||||
Subtitle: '&fTeleporting in %time% seconds...'
|
|
||||||
Success:
|
|
||||||
## Setting to also send the chat message, ignores the Enabled setting
|
|
||||||
SendChatMessage: true
|
|
||||||
## Both support %player% %x% %y% and %z% placeholders
|
## Both support %player% %x% %y% and %z% placeholders
|
||||||
Title: '&6Teleported!'
|
Title: '&6Teleported!'
|
||||||
Subtitle: '&fx=%x% y=%y% z=%z% in %attempts% attempts'
|
Subtitle: '&fx=%x% y=%y% z=%z% in %attempts% attempts'
|
||||||
|
Delay:
|
||||||
|
## Both support %player% placeholders
|
||||||
|
Title: ' '
|
||||||
|
Subtitle: '&fTeleporting in %time% seconds...'
|
||||||
|
|
||||||
Particles:
|
Particles:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Type: 'REVERSE_PORTAL' #list of particle types at https://github.com/ByteZ1337/ParticleLib/blob/master/src/main/java/xyz/xenondevs/particle/ParticleEffect.java
|
Type: 'REVERSE_PORTAL' #list of particle types at https://github.com/ByteZ1337/ParticleLib/blob/master/src/main/java/xyz/xenondevs/particle/ParticleEffect.java
|
||||||
|
Loading…
x
Reference in New Issue
Block a user