mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-08-17 09:05:47 +00:00
Added Effects and invincibility
- If delays are disabled, cooldown will not add delay time to cooldown - Added potion effects and invincibility upon rtp'ing - While in debugger mode, be able to execute '/rtp test' to test potion effects and particles - Fixed an issue with explode particle shape
This commit is contained in:
parent
2ffe2b5cb3
commit
fe12cb802b
@ -8,16 +8,27 @@ public enum CommandTypes {
|
||||
INFO(new CmdInfo()),
|
||||
PLAYER(new CmdPlayer()),
|
||||
RELOAD(new CmdReload()),
|
||||
//SETTINGS(new CmdSettings()),
|
||||
//SETTINGS(new CmdSettings(), true),
|
||||
VERSION(new CmdVersion()),
|
||||
WORLD(new CmdWorld());
|
||||
WORLD(new CmdWorld()),
|
||||
TEST(new CmdTest(), true); //Only gets added if debugger enabled
|
||||
|
||||
private RTPCommand cmd;
|
||||
private final RTPCommand cmd;
|
||||
private boolean debugOnly = false;
|
||||
|
||||
CommandTypes(RTPCommand cmd) {
|
||||
this.cmd = cmd;
|
||||
}
|
||||
|
||||
CommandTypes(RTPCommand cmd, boolean debugOnly) {
|
||||
this.cmd = cmd;
|
||||
this.debugOnly = debugOnly;
|
||||
}
|
||||
|
||||
public boolean isDebugOnly() {
|
||||
return debugOnly;
|
||||
}
|
||||
|
||||
public RTPCommand getCmd() {
|
||||
return cmd;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public class Commands {
|
||||
if (args != null && args.length > 0) {
|
||||
for (CommandTypes cmd : CommandTypes.values()) {
|
||||
if (cmd.name().equalsIgnoreCase(args[0])) {
|
||||
if (!cmd.isDebugOnly() || pl.getSettings().debug) { //Debug only?
|
||||
if (cmd.getCmd().permission(sendi))
|
||||
cmd.getCmd().execute(sendi, label, args);
|
||||
else
|
||||
@ -42,6 +43,7 @@ public class Commands {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
invalid(sendi, label);
|
||||
} else
|
||||
rtp(sendi, label, null, null);
|
||||
@ -57,12 +59,16 @@ public class Commands {
|
||||
List<String> list = new ArrayList<>();
|
||||
if (args.length == 1) {
|
||||
for (CommandTypes cmd : CommandTypes.values()) {
|
||||
if (cmd.name().toLowerCase().startsWith(args[0].toLowerCase()) && cmd.getCmd().permission(sendi))
|
||||
if (cmd.name().toLowerCase().startsWith(args[0].toLowerCase()))
|
||||
if (!cmd.isDebugOnly() || pl.getSettings().debug) //Debug only?
|
||||
if (cmd.getCmd().permission(sendi))
|
||||
list.add(cmd.name().toLowerCase());
|
||||
}
|
||||
} else if (args.length > 1) {
|
||||
for (CommandTypes cmd : CommandTypes.values()) {
|
||||
if (cmd.name().equalsIgnoreCase(args[0]) && cmd.getCmd().permission(sendi)) {
|
||||
if (cmd.name().equalsIgnoreCase(args[0]))
|
||||
if (!cmd.isDebugOnly() || pl.getSettings().debug) //Debug only?
|
||||
if (cmd.getCmd().permission(sendi)) {
|
||||
List<String> _cmdlist = cmd.getCmd().tabComplete(sendi, args);
|
||||
if (_cmdlist != null)
|
||||
list.addAll(_cmdlist);
|
||||
@ -117,13 +123,12 @@ public class Commands {
|
||||
}
|
||||
|
||||
public void tp(Player player, CommandSender sendi, String world, List<String> biomes) {
|
||||
if (checkDelay(sendi, player)) {
|
||||
if (checkDelay(sendi, player)) { //Cooling down or rtp'ing
|
||||
boolean delay = false;
|
||||
if (!pl.getPerms().getBypassDelay(player))
|
||||
if (delayTimer > 0)
|
||||
if (sendi == player)
|
||||
if (sendi == player) //Forced?
|
||||
if (pl.getSettings().delayEnabled && delayTimer > 0) //Delay enabled?
|
||||
if (!pl.getPerms().getBypassDelay(player)) //Can bypass?
|
||||
delay = true;
|
||||
//pl.getRTP().start(player, sendi, world, biomes, delay);
|
||||
pl.getRTP().start(player, sendi, world, biomes, delay);
|
||||
}
|
||||
}
|
||||
@ -138,12 +143,12 @@ public class Commands {
|
||||
Player p = (Player) sendi;
|
||||
UUID id = p.getUniqueId();
|
||||
if (cooldowns.exists(id)) {
|
||||
if (cooldowns.locked(id)) { //Infinite cooldown
|
||||
if (cooldowns.locked(id)) { //Infinite cooldown (locked)
|
||||
pl.getText().getNoPermission(sendi);
|
||||
return false;
|
||||
} else { //Normal cooldown
|
||||
long Left = cooldowns.timeLeft(id);
|
||||
if (!pl.getPerms().getBypassDelay(p))
|
||||
if (pl.getSettings().delayEnabled && !pl.getPerms().getBypassDelay(p))
|
||||
Left = Left + delayTimer;
|
||||
if (Left > 0) {
|
||||
//Still cooling down
|
||||
|
@ -9,6 +9,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import xyz.xenondevs.particle.ParticleEffect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -16,16 +17,14 @@ import java.util.List;
|
||||
|
||||
public class CmdInfo implements RTPCommand {
|
||||
|
||||
private String[] subCmds = {
|
||||
"Particles" //Give a list of particles
|
||||
};
|
||||
|
||||
public void execute(CommandSender sendi, String label, String[] args) {
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase(CmdInfoSub.PARTICLES.name()))
|
||||
infoParticles(sendi);
|
||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.SHAPES.name()))
|
||||
infoShapes(sendi);
|
||||
else if (args[1].equalsIgnoreCase(CmdInfoSub.POTION_EFFECTS.name()))
|
||||
infoEffects(sendi);
|
||||
else
|
||||
infoWorlds(sendi);
|
||||
} else
|
||||
@ -33,7 +32,7 @@ public class CmdInfo implements RTPCommand {
|
||||
}
|
||||
|
||||
enum CmdInfoSub { //Sub commands, future expansions
|
||||
PARTICLES, SHAPES
|
||||
PARTICLES, SHAPES, POTION_EFFECTS
|
||||
}
|
||||
|
||||
private void infoParticles(CommandSender sendi) {
|
||||
@ -119,6 +118,24 @@ public class CmdInfo implements RTPCommand {
|
||||
sendi.sendMessage(info.toArray(new String[0]));
|
||||
}
|
||||
|
||||
void infoEffects(CommandSender sendi) {
|
||||
List<String> info = new ArrayList<>();
|
||||
Main pl = Main.getInstance();
|
||||
|
||||
for (PotionEffectType effect : PotionEffectType.values()) {
|
||||
if (info.isEmpty()) {
|
||||
info.add("&7" + effect.getName() + "&r");
|
||||
} else if (info.size() % 2 == 0) {
|
||||
info.add("&7" + effect.getName() + "&r");
|
||||
} else
|
||||
info.add("&f" + effect.getName() + "&r");
|
||||
}
|
||||
|
||||
info.forEach(str ->
|
||||
info.set(info.indexOf(str), pl.getText().color(str)));
|
||||
sendi.sendMessage(info.toString());
|
||||
}
|
||||
|
||||
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||
List<String> info = new ArrayList<>();
|
||||
if (args.length == 2) {
|
||||
|
@ -0,0 +1,31 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
//Meant to just test particles and effects without actually rtp'ing around the world
|
||||
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
|
||||
sendi.sendMessage("Console is not able to execute this command! Try '/rtp help'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permission(CommandSender sendi) {
|
||||
return Main.getInstance().getPerms().getTest(sendi);
|
||||
}
|
||||
|
||||
}
|
@ -35,6 +35,10 @@ public class RTP {
|
||||
private boolean cancelOnMove, cancelOnDamage;
|
||||
public HashMap<String, RTP_WORLD_TYPE> world_type = new HashMap<>();
|
||||
|
||||
public RTPTeleport getTeleport() {
|
||||
return teleport;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
Default.setup();
|
||||
FileBasics.FILETYPE config = getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||
|
@ -47,7 +47,6 @@ public class RTPCooldown {
|
||||
}
|
||||
|
||||
public boolean exists(UUID id) {
|
||||
System.out.println("Exists " + id + " " + cooldowns.containsKey(id));
|
||||
return cooldowns.containsKey(id);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,59 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.rtp;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class RTPEffects {
|
||||
|
||||
private boolean potionEnabled;
|
||||
private final HashMap<PotionEffectType, Integer> potionEffects = new HashMap<>();
|
||||
private boolean invincibleEnabled;
|
||||
private int invincibleTime;
|
||||
|
||||
void load() {
|
||||
potionEffects.clear();
|
||||
FileBasics.FILETYPE config = FileBasics.FILETYPE.CONFIG;
|
||||
String pre = "Settings.Effects.";
|
||||
potionEnabled = config.getBoolean(pre + "Potions.Enabled");
|
||||
invincibleEnabled = config.getBoolean(pre + "Invincible.Enabled");
|
||||
if (invincibleEnabled)
|
||||
invincibleTime = config.getInt(pre + "Invincible.Seconds");
|
||||
if (potionEnabled) {
|
||||
List<String> list = config.getStringList(pre + "Potions.Types");
|
||||
for (String p : list) {
|
||||
String[] ary = p.split(":");
|
||||
String type = ary[0];
|
||||
PotionEffectType effect = PotionEffectType.getByName(type);
|
||||
if (effect != null) {
|
||||
try {
|
||||
int time = ary.length >= 2 ? Integer.parseInt(ary[1]) : 3;
|
||||
potionEffects.put(effect, time);
|
||||
} catch (NumberFormatException e) {
|
||||
Main.getInstance().getLogger().info("The potion duration `" + ary[1] + "` is not an integer! Effect removed!");
|
||||
}
|
||||
} else
|
||||
Main.getInstance().getLogger().info("The potion effect `" + type + "` does not exist! " +
|
||||
"Please fix or remove this potion effect! Try '/rtp info potion_effects'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void giveEffects(Player p) {
|
||||
if (invincibleEnabled)
|
||||
p.setNoDamageTicks(invincibleTime);
|
||||
if (potionEnabled) {
|
||||
List<PotionEffect> effects = new ArrayList<>();
|
||||
for (PotionEffectType e : potionEffects.keySet())
|
||||
effects.add(new PotionEffect(e, potionEffects.get(e), 1, false, false));
|
||||
p.addPotionEffects(effects);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -15,13 +15,15 @@ public class RTPParticles {
|
||||
private boolean enabled;
|
||||
private ParticleEffect effect;
|
||||
private String shape;
|
||||
private int radius = 30, precision = 180; //Vector weirdness if allowed to be editable
|
||||
private double pHeight = 1.75;
|
||||
private final int
|
||||
radius = 30,
|
||||
precision = 180; //Vector weirdness if allowed to be editable
|
||||
private final double pHeight = 1.75;
|
||||
|
||||
//Some particles act very differently and might not care how they are shaped before animating, ex: EXPLOSION_NORMAL
|
||||
public static String[] shapeTypes = {
|
||||
"SCAN", //Body scan
|
||||
"EXPLOSIVE", //Make an explosive entrance
|
||||
"EXPLODE", //Make an explosive entrance
|
||||
"TELEPORT" //Startrek type of portal
|
||||
};
|
||||
|
||||
@ -35,12 +37,13 @@ public class RTPParticles {
|
||||
effect = ParticleEffect.valueOf(type.toUpperCase());
|
||||
} catch (IllegalArgumentException | NullPointerException e) {
|
||||
effect = ParticleEffect.ASH;
|
||||
getPl().getLogger().severe("The particle '" + type + "' doesn't exist! Default particle enabled...");
|
||||
getPl().getLogger().severe("The particle '" + type + "' doesn't exist! Default particle enabled... " +
|
||||
"Try using '/rtp info particles' to get a list of available particles");
|
||||
}
|
||||
shape = config.getString("Settings.Particles.Shape").toUpperCase();
|
||||
if (!Arrays.asList(shapeTypes).contains(shape)) {
|
||||
getPl().getLogger().severe("The particle shape '" + shape + "' doesn't exist! Default particle shape enabled...");
|
||||
getPl().getLogger().severe("Try using one of the following: " + Arrays.asList(shapeTypes).toString());
|
||||
getPl().getLogger().severe("Try using '/rtp info shapes' to get a list of shapes, or: " + Arrays.asList(shapeTypes).toString());
|
||||
shape = shapeTypes[0];
|
||||
}
|
||||
}
|
||||
@ -50,7 +53,7 @@ public class RTPParticles {
|
||||
try { //Incase the library errors out
|
||||
switch (shape) {
|
||||
case "TELEPORT": partTeleport(p); break;
|
||||
case "EXPLOSIVE": partExplosion(p); break;
|
||||
case "EXPLODE": partExplosion(p); break;
|
||||
default: //Super redundant, but... just future proofing
|
||||
case "SCAN": partScan(p); break;
|
||||
}
|
||||
@ -78,10 +81,10 @@ public class RTPParticles {
|
||||
}
|
||||
|
||||
private void partExplosion(Player p) { //Particles with a shape and forward velocity
|
||||
Location loc = p.getLocation().add(new Vector(0, 0, 0));
|
||||
Location loc = p.getLocation().add(new Vector(0, 1, 0));
|
||||
for (int index = 1; index < precision; index++) {
|
||||
Vector vec = getVecCircle(index, precision, radius);
|
||||
effect.display(loc.clone().add(vec), vec, 1f, 0, null);
|
||||
effect.display(loc.clone().add(vec), vec, 1.5f, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,18 +7,23 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class RTPTeleport {
|
||||
|
||||
private final RTPParticles particles = new RTPParticles();
|
||||
private final RTPEffects effects = new RTPEffects();
|
||||
|
||||
void load() {
|
||||
particles.load();
|
||||
effects.load();
|
||||
}
|
||||
|
||||
void sendPlayer(final CommandSender sendi, final Player p, final Location loc, final int price,
|
||||
@ -39,9 +44,7 @@ public class RTPTeleport {
|
||||
PaperLib.teleportAsync(p, loc).thenRun(new BukkitRunnable() { //Async teleport
|
||||
@Override
|
||||
public void run() {
|
||||
if (getPl().getText().getSoundsEnabled())
|
||||
sounds(p);
|
||||
particles.display(p);
|
||||
afterTeleport(p);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
@ -52,6 +55,13 @@ public class RTPTeleport {
|
||||
}.runTask(getPl());
|
||||
}
|
||||
|
||||
public void afterTeleport(Player p) {
|
||||
if (getPl().getText().getSoundsEnabled())
|
||||
sounds(p);
|
||||
particles.display(p);
|
||||
effects.giveEffects(p);
|
||||
}
|
||||
|
||||
private void loadChunks(Location loc) { //Async chunk loading
|
||||
List<CompletableFuture<Chunk>> asyncChunks = new ArrayList<>();
|
||||
for (int x = -5; x <= 5; x++) {
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
public class Permissions {
|
||||
|
||||
private DepPerms depPerms = new DepPerms();
|
||||
private final DepPerms depPerms = new DepPerms();
|
||||
|
||||
public void register() {
|
||||
depPerms.register();
|
||||
@ -52,15 +52,19 @@ public class Permissions {
|
||||
}
|
||||
|
||||
public boolean getBiome(CommandSender sendi) {
|
||||
return (perm(pre + "biome", sendi));
|
||||
return perm(pre + "biome", sendi);
|
||||
}
|
||||
|
||||
public boolean getWorld(CommandSender sendi) {
|
||||
return (perm(pre + "world", sendi));
|
||||
return perm(pre + "world", sendi);
|
||||
}
|
||||
|
||||
public boolean getSignCreate(CommandSender sendi) {
|
||||
return (perm(pre + "sign", sendi));
|
||||
return perm(pre + "sign", sendi);
|
||||
}
|
||||
|
||||
public boolean getTest(CommandSender sendi) {
|
||||
return perm(pre + "test", sendi);
|
||||
}
|
||||
|
||||
public boolean getAWorld(CommandSender sendi, String world) {
|
||||
|
@ -33,6 +33,15 @@ Settings:
|
||||
Type: 'REVERSE_PORTAL' #list of particle types at https://github.com/ByteZ1337/ParticleLib/blob/master/src/main/java/xyz/xenondevs/particle/ParticleEffect.java
|
||||
Amount: 180
|
||||
Shape: 'SCAN' #Types available are "Scan, Teleport and Explosive"
|
||||
Effects:
|
||||
Invincible: #Amount of time a player should not take damage for
|
||||
Enabled: true
|
||||
Seconds: 5
|
||||
Potions:
|
||||
Enabled: true
|
||||
Types:
|
||||
- 'Blindness:60'
|
||||
- 'Invisibility:60'
|
||||
DisableUpdater: false
|
||||
|
||||
Default:
|
||||
|
@ -40,3 +40,6 @@ permissions:
|
||||
betterrtp.updater:
|
||||
description: Get notification on new updates
|
||||
default: op
|
||||
betterrtp.test:
|
||||
description: While debugger enabled, be able to test particles, potion effects and sounds
|
||||
default: op
|
@ -53,3 +53,6 @@ permissions:
|
||||
betterrtp.info:
|
||||
description: View info about all worlds rtp will work in
|
||||
default: op
|
||||
betterrtp.test:
|
||||
description: While debugger enabled, be able to test particles, potion effects and sounds
|
||||
default: op
|
Loading…
x
Reference in New Issue
Block a user