mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-02-16 02:21:06 +00:00
better info command + removal of thread.sleep + economy bug fix on reload
This commit is contained in:
@@ -19,17 +19,17 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import java.util.List;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
private Permissions perms = new Permissions();
|
||||
private Messages text = new Messages(this);
|
||||
private DepEconomy eco = new DepEconomy();
|
||||
private Commands cmd = new Commands(this);
|
||||
private RTP rtp = new RTP();
|
||||
private Listener listener = new Listener();
|
||||
private final Permissions perms = new Permissions();
|
||||
private final Messages text = new Messages(this);
|
||||
private final DepEconomy eco = new DepEconomy();
|
||||
private final Commands cmd = new Commands(this);
|
||||
private final RTP rtp = new RTP();
|
||||
private final Listener listener = new Listener();
|
||||
private static Main instance;
|
||||
private Files files = new Files();
|
||||
private RTPInventories invs = new RTPInventories();
|
||||
private PlayerInfo pInfo = new PlayerInfo();
|
||||
private Settings settings = new Settings();
|
||||
private final Files files = new Files();
|
||||
private final RTPInventories invs = new RTPInventories();
|
||||
private final PlayerInfo pInfo = new PlayerInfo();
|
||||
private final Settings settings = new Settings();
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
@@ -16,9 +16,10 @@ public class RTPParticles {
|
||||
private ParticleEffect effect;
|
||||
private String shape;
|
||||
private int radius = 30, precision = 180; //Vector weirdness if allowed to be editable
|
||||
private double pHeight = 1.75;
|
||||
|
||||
//Some particles act very differently and might not care how they are shaped before animating, ex: EXPLOSION_NORMAL
|
||||
private String[] shapeTypes = {
|
||||
public static String[] shapeTypes = {
|
||||
"SCAN", //Body scan
|
||||
"EXPLOSIVE", //Make an explosive entrance
|
||||
"TELEPORT" //Startrek type of portal
|
||||
@@ -59,7 +60,7 @@ public class RTPParticles {
|
||||
}
|
||||
|
||||
private void partScan(Player p) { //Particles with negative velocity
|
||||
Location loc = p.getLocation().add(new Vector(0, 2, 0));
|
||||
Location loc = p.getLocation().add(new Vector(0, pHeight, 0));
|
||||
for (int index = 1; index < precision; index++) {
|
||||
Vector vec = getVecCircle(index, precision, radius);
|
||||
effect.display(loc.clone().add(vec), new Vector(0, -0.125, 0), 1f, 0, null);
|
||||
@@ -70,7 +71,7 @@ public class RTPParticles {
|
||||
Random ran = new Random();
|
||||
Location loc = p.getLocation().add(new Vector(0, 0, 0));
|
||||
for (int index = 1; index < precision; index++) {
|
||||
double yran = ran.nextInt(2);
|
||||
double yran = ran.nextGaussian() * pHeight;
|
||||
Vector vec = getVecCircle(index, precision, radius).add(new Vector(0, yran, 0));
|
||||
effect.display(loc.clone().add(vec));
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class RTPTeleport {
|
||||
|
||||
private RTPParticles particles = new RTPParticles();
|
||||
private final RTPParticles particles = new RTPParticles();
|
||||
|
||||
void load() {
|
||||
particles.load();
|
||||
@@ -64,13 +64,9 @@ public class RTPTeleport {
|
||||
asyncChunks.add(chunk);
|
||||
}
|
||||
}
|
||||
while (!checkLoaded(asyncChunks)) {
|
||||
try {
|
||||
Thread.sleep(500); //Sleep and check again 0.5 seconds later
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
boolean loaded = false;
|
||||
while (!loaded)
|
||||
loaded = checkLoaded(asyncChunks);
|
||||
}
|
||||
|
||||
private boolean checkLoaded(List<CompletableFuture<Chunk>> asyncChunks) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package me.SuperRonanCraft.BetterRTP.player.commands.types;
|
||||
|
||||
import me.SuperRonanCraft.BetterRTP.Main;
|
||||
import me.SuperRonanCraft.BetterRTP.player.RTPParticles;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.CommandTypes;
|
||||
import me.SuperRonanCraft.BetterRTP.player.commands.RTPCommand;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.RTPWorld;
|
||||
import me.SuperRonanCraft.BetterRTP.references.worlds.RTP_WORLD_TYPE;
|
||||
@@ -8,13 +10,70 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import xyz.xenondevs.particle.ParticleEffect;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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
|
||||
infoWorlds(sendi);
|
||||
} else
|
||||
infoWorlds(sendi);
|
||||
}
|
||||
|
||||
enum CmdInfoSub { //Sub commands, future expansions
|
||||
PARTICLES, SHAPES
|
||||
}
|
||||
|
||||
private void infoParticles(CommandSender sendi) {
|
||||
List<String> info = new ArrayList<>();
|
||||
Main pl = Main.getInstance();
|
||||
|
||||
for (ParticleEffect eff : ParticleEffect.VALUES) {
|
||||
if (info.isEmpty()) {
|
||||
info.add("&7" + eff.name() + "&r");
|
||||
} else if (info.size() % 2 == 0) {
|
||||
info.add("&7" + eff.name() + "&r");
|
||||
} else
|
||||
info.add("&f" + eff.name() + "&r");
|
||||
}
|
||||
|
||||
info.forEach(str ->
|
||||
info.set(info.indexOf(str), pl.getText().color(str)));
|
||||
sendi.sendMessage(info.toString());
|
||||
}
|
||||
|
||||
private void infoShapes(CommandSender sendi) {
|
||||
List<String> info = new ArrayList<>();
|
||||
Main pl = Main.getInstance();
|
||||
|
||||
for (String shape : RTPParticles.shapeTypes) {
|
||||
if (info.isEmpty()) {
|
||||
info.add("&7" + shape + "&r");
|
||||
} else if (info.size() % 2 == 0) {
|
||||
info.add("&7" + shape + "&r");
|
||||
} else
|
||||
info.add("&f" + shape + "&r");
|
||||
}
|
||||
|
||||
info.forEach(str ->
|
||||
info.set(info.indexOf(str), pl.getText().color(str)));
|
||||
sendi.sendMessage(info.toString());
|
||||
}
|
||||
|
||||
private void infoWorlds(CommandSender sendi) {
|
||||
List<String> info = new ArrayList<>();
|
||||
info.add("&e&m-----&6 BetterRTP Info &e&m-----");
|
||||
Main pl = Main.getInstance();
|
||||
@@ -62,7 +121,13 @@ public class CmdInfo implements RTPCommand {
|
||||
}
|
||||
|
||||
public List<String> tabComplete(CommandSender sendi, String[] args) {
|
||||
return null;
|
||||
List<String> info = new ArrayList<>();
|
||||
if (args.length == 2) {
|
||||
for (CmdInfoSub cmd : CmdInfoSub.values())
|
||||
if (cmd.name().toLowerCase().startsWith(args[1].toLowerCase()))
|
||||
info.add(cmd.name().toLowerCase());
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
public boolean permission(CommandSender sendi) {
|
||||
|
||||
@@ -36,6 +36,8 @@ public class Default implements RTPWorld {
|
||||
}
|
||||
if (Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getBoolean("Economy.Enabled"))
|
||||
price = Main.getInstance().getFiles().getType(FileBasics.FILETYPE.ECO).getInt("Economy.Price");
|
||||
else
|
||||
price = 0;
|
||||
//Other
|
||||
this.Biomes = config.getStringList(pre + ".Biomes");
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ Settings:
|
||||
CancelOnMove: true
|
||||
Particles:
|
||||
Enabled: true
|
||||
Type: '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
|
||||
Amount: 180
|
||||
Shape: 'SCAN' #Types available are "Scan, Teleport and Explosive"
|
||||
DisableUpdater: false
|
||||
|
||||
Reference in New Issue
Block a user