mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 17:15:47 +00:00
test command rtp type + multi particle support
This commit is contained in:
parent
231ab44da4
commit
713ce65db6
@ -72,9 +72,13 @@ public class AddonFlashback implements Addon, Listener {
|
||||
|
||||
@EventHandler
|
||||
void onTeleport(RTP_TeleportPostEvent e) { //Create a timer to teleport player back
|
||||
if (e.getType() != RTP_TYPE.ADDON_PORTAL)
|
||||
if (e.getType() != RTP_TYPE.ADDON_PORTAL &&
|
||||
e.getType() != RTP_TYPE.JOIN &&
|
||||
e.getType() != RTP_TYPE.TEST) {
|
||||
cancelPlayer(e.getPlayer());
|
||||
players.add(new FlashbackPlayer(this, e.getPlayer(), e.getOldLocation(), time, warnings));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onJoin(PlayerJoinEvent e) {
|
||||
@ -83,8 +87,12 @@ public class AddonFlashback implements Addon, Listener {
|
||||
|
||||
@EventHandler
|
||||
void onLeave(PlayerQuitEvent e) {
|
||||
cancelPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
private void cancelPlayer(Player p) {
|
||||
for (FlashbackPlayer fbp : players)
|
||||
if (fbp.p == e.getPlayer())
|
||||
if (fbp.p == p)
|
||||
fbp.cancel();
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ public class CmdTest implements RTPCommand, RTPCommandHelpable {
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
if (sendi instanceof Player) {
|
||||
Player p = (Player) sendi;
|
||||
BetterRTP.getInstance().getRTP().getTeleport().afterTeleport(p, p.getLocation(), 0, 0, p.getLocation(), RTP_TYPE.COMMAND);
|
||||
BetterRTP.getInstance().getRTP().getTeleport().afterTeleport(p, p.getLocation(), 0, 0, p.getLocation(), RTP_TYPE.TEST);
|
||||
} else
|
||||
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import xyz.xenondevs.particle.ParticleEffect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
//---
|
||||
@ -19,7 +21,7 @@ import java.util.Random;
|
||||
public class RTPParticles {
|
||||
|
||||
private boolean enabled;
|
||||
private ParticleEffect effect;
|
||||
private List<ParticleEffect> effects = new ArrayList<>();
|
||||
private String shape;
|
||||
private final int
|
||||
radius = 30,
|
||||
@ -38,12 +40,23 @@ public class RTPParticles {
|
||||
enabled = config.getBoolean("Particles.Enabled");
|
||||
if (!enabled) return;
|
||||
//Enabled? Load all this junk
|
||||
String type = config.getString("Particles.Type");
|
||||
List<String> types;
|
||||
if (config.isList("Particles.Type"))
|
||||
types = config.getStringList("Particles.Type");
|
||||
else {
|
||||
types = new ArrayList<>();
|
||||
types.add(config.getString("Particles.Type"));
|
||||
}
|
||||
String typeTrying = null;
|
||||
try {
|
||||
effect = ParticleEffect.valueOf(type.toUpperCase());
|
||||
for (String type : types) {
|
||||
typeTrying = type;
|
||||
effects.add(ParticleEffect.valueOf(type.toUpperCase()));
|
||||
}
|
||||
} catch (IllegalArgumentException | NullPointerException e) {
|
||||
effect = ParticleEffect.ASH;
|
||||
getPl().getLogger().severe("The particle '" + type + "' doesn't exist! Default particle enabled... " +
|
||||
effects.clear();
|
||||
effects.add(ParticleEffect.ASH);
|
||||
getPl().getLogger().severe("The particle '" + typeTrying + "' doesn't exist! Default particle enabled... " +
|
||||
"Try using '/rtp info particles' to get a list of available particles");
|
||||
}
|
||||
shape = config.getString("Particles.Shape").toUpperCase();
|
||||
@ -72,9 +85,11 @@ public class RTPParticles {
|
||||
Location loc = p.getLocation().add(new Vector(0, pHeight, 0));
|
||||
for (int index = 1; index < precision; index++) {
|
||||
Vector vec = getVecCircle(index, precision, radius);
|
||||
for (ParticleEffect effect : effects) {
|
||||
effect.display(loc.clone().add(vec), new Vector(0, -0.125, 0), 1f, 0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void partTeleport(Player p) { //Static particles in a shape
|
||||
Random ran = new Random();
|
||||
@ -82,17 +97,21 @@ public class RTPParticles {
|
||||
for (int index = 1; index < precision; index++) {
|
||||
double yran = ran.nextGaussian() * pHeight;
|
||||
Vector vec = getVecCircle(index, precision, radius).add(new Vector(0, yran, 0));
|
||||
for (ParticleEffect effect : effects) {
|
||||
effect.display(loc.clone().add(vec));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void partExplosion(Player p) { //Particles with a shape and forward velocity
|
||||
Location loc = p.getLocation().add(new Vector(0, 1, 0));
|
||||
for (int index = 1; index < precision; index++) {
|
||||
Vector vec = getVecCircle(index, precision, radius);
|
||||
for (ParticleEffect effect : effects) {
|
||||
effect.display(loc.clone().add(vec), vec, 1.5f, 0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector getVecCircle(int index, int precise, int rad) {
|
||||
double p1 = (index * Math.PI) / (precise / 2);
|
||||
|
@ -4,6 +4,7 @@ public enum RTP_TYPE {
|
||||
COMMAND, //Player executed command
|
||||
FORCED, //Player was forced to rtp (/rtp player <player>)
|
||||
JOIN, //Player joined and was rtp'd automatically
|
||||
TEST, //Player was just testing out effects
|
||||
ADDON, //Player RTP'd from the external addons plugin
|
||||
ADDON_PORTAL, //Player RTP'd from the external addons (Portals)
|
||||
ADDON_MAGICSTICK, //Player RTP'd from the external addons (MagicStick)
|
||||
|
@ -32,7 +32,9 @@ Titles:
|
||||
SendMessage: true
|
||||
Particles: #Use `rtp info particles` for a list of particles
|
||||
Enabled: true
|
||||
Type: 'EXPLOSION_NORMAL' #list of particle types at https://github.com/ByteZ1337/ParticleLib/blob/master/src/main/java/xyz/xenondevs/particle/ParticleEffect.java
|
||||
Type: #list of particle types at https://github.com/ByteZ1337/ParticleLib/blob/master/src/main/java/xyz/xenondevs/particle/ParticleEffect.java
|
||||
- 'EXPLOSION_NORMAL'
|
||||
- 'CRIT'
|
||||
Shape: 'EXPLODE' #Types available are "Scan, Teleport and Explode", or use `/rtp info shapes` for a list of shapes
|
||||
Invincible: #Amount of time a player should not take damage for
|
||||
Enabled: true
|
||||
|
Loading…
x
Reference in New Issue
Block a user