titles converted to effects + Delays message touch up

This commit is contained in:
SuperRonanCraft 2020-08-11 13:02:13 -04:00
parent 5a497dfc9e
commit 375ade83b3
6 changed files with 69 additions and 45 deletions

View File

@ -12,9 +12,10 @@ public class CmdTest implements RTPCommand {
@Override
public void execute(CommandSender sendi, String label, String[] args) {
if (sendi instanceof Player)
Main.getInstance().getRTP().getTeleport().afterTeleport((Player) sendi);
else
if (sendi instanceof Player) {
Player p = (Player) sendi;
Main.getInstance().getRTP().getTeleport().afterTeleport(p, p.getLocation(), 0, 0);
} else
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
}

View File

@ -27,8 +27,8 @@ class RTPDelay implements Listener {
@SuppressWarnings("deprecation")
private void delay(CommandSender sendi, int delay) {
Main pl = Main.getInstance();
if (sendi.equals(pWorld.getPlayer()) && delay != 0 && getPl().getText().getTitleDelayChat())
getPl().getText().getDelay(sendi, String.valueOf(delay));
// if (sendi.equals(pWorld.getPlayer()) && delay != 0 && getPl().getText().getTitleDelayChat())
// getPl().getText().getDelay(sendi, String.valueOf(delay));
// if (getPl().getText().getSoundsEnabled()) {
// Sound sound = getPl().getText().getSoundsDelay();
// if (sound != null)
@ -44,8 +44,8 @@ class RTPDelay implements Listener {
// // player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
// // pWorld.getPlayer().sendTitle(title, subTitle);
// }
getPl().getRTP().getTeleport().beforeTeleport(pWorld.getPlayer());
run = Bukkit.getScheduler().scheduleSyncDelayedTask(pl, run(sendi, this), delay * 2 * 10);
getPl().getRTP().getTeleport().beforeTeleport(pWorld.getPlayer(), delay);
run = Bukkit.getScheduler().scheduleSyncDelayedTask(pl, run(sendi, this), delay * 20);
//Bukkit.getScheduler().scheduleSyncRepeatingTask(pl, run(sendi, this), 0, 10);
if (cancelOnMove || cancelOnDamage)
Bukkit.getPluginManager().registerEvents(this, Main.getInstance());

View File

@ -4,7 +4,6 @@ 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;
@ -30,7 +29,7 @@ public class RTPTeleport {
void sendPlayer(final CommandSender sendi, final Player p, final Location loc, final int price,
final int attempts) throws NullPointerException {
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
List<CompletableFuture<Chunk>> asyncChunks = getChunks(loc); //Get a list of chunks
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);
eParticles.display(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);
eTitles.showDelay(p, p.getLocation());
getPl().getText().getDelay(p, delay);
}
private List<CompletableFuture<Chunk>> getChunks(Location loc) { //List all chunks in range to load
@ -73,8 +75,8 @@ public class RTPTeleport {
return asyncChunks;
}
private void checkPH(CommandSender sendi, String player, Location loc, int price, boolean sameAsPlayer,
int attempts) {
private void sendSuccessMsg(CommandSender sendi, String player, Location loc, int price, boolean sameAsPlayer,
int attempts) {
String x = Integer.toString(loc.getBlockX());
String y = Integer.toString(loc.getBlockY());
String z = Integer.toString(loc.getBlockZ());
@ -88,21 +90,6 @@ public class RTPTeleport {
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() {
return Main.getInstance();
}

View File

@ -1,17 +1,56 @@
package me.SuperRonanCraft.BetterRTP.player.rtp;
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class RTPTitles {
private boolean enabled;
private String
titleTeleport,
titleDelay,
subTeleport,
subDelay;
void load() {
if (getPl().getText().getTitleSuccessChat())
checkPH(p, p.getDisplayName(), loc, price, true, attempts);
if (getPl().getText().getTitleEnabled())
titles(p, loc, attempts);
FileBasics.FILETYPE config = FileBasics.FILETYPE.EFFECTS;
enabled = config.getBoolean("Titles.Enabled");
if (enabled) {
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);
}
}

View File

@ -95,8 +95,8 @@ public class Messages {
sms(sendi, getLang().getString(preM + "NotOnline").replaceAll("%player%", player));
}
public void getDelay(CommandSender sendi, String time) {
sms(sendi, getLang().getString(preM + "Delay").replaceAll("%time%", time));
public void getDelay(CommandSender sendi, int time) {
sms(sendi, getLang().getString(preM + "Delay").replaceAll("%time%", String.valueOf(time)));
}
public void getSignCreated(CommandSender sendi, String cmd) {

View File

@ -5,18 +5,15 @@ Sounds:
Success: 'entity_generic_explode'
Titles:
Enabled: true
Delay:
## 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
Teleport:
## Both support %player% %x% %y% and %z% placeholders
Title: '&6Teleported!'
Subtitle: '&fx=%x% y=%y% z=%z% in %attempts% attempts'
Delay:
## Both support %player% placeholders
Title: ' '
Subtitle: '&fTeleporting in %time% seconds...'
Particles:
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