mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2026-04-18 14:30:15 +00:00
particle shapes
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>me.SuperRonanCraft</groupId>
|
<groupId>me.SuperRonanCraft</groupId>
|
||||||
<artifactId>BetterRTP</artifactId>
|
<artifactId>BetterRTP</artifactId>
|
||||||
<version>2.11.3</version>
|
<version>2.12.0</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ public class RTP {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
//No World Types
|
//No World Types
|
||||||
}
|
}
|
||||||
|
teleport.load(); //Load teleporting stuff
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> disabledWorlds() {
|
public List<String> disabledWorlds() {
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package me.SuperRonanCraft.BetterRTP.player;
|
||||||
|
|
||||||
|
import me.SuperRonanCraft.BetterRTP.Main;
|
||||||
|
import me.SuperRonanCraft.BetterRTP.references.file.FileBasics;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
import xyz.xenondevs.particle.ParticleEffect;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
//Some particles act very differently and might not care how they are shaped before animating, ex: EXPLOSION_NORMAL
|
||||||
|
private String[] shapeTypes = {
|
||||||
|
"SCAN", //Body scan
|
||||||
|
"EXPLOSIVE", //Make an explosive entrance
|
||||||
|
"TELEPORT" //Startrek type of portal
|
||||||
|
};
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
FileBasics.FILETYPE config = getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG);
|
||||||
|
enabled = config.getBoolean("Settings.Particles.Enabled");
|
||||||
|
if (!enabled) return;
|
||||||
|
//Enabled? Load all this junk
|
||||||
|
String type = config.getString("Settings.Particles.Type");
|
||||||
|
try {
|
||||||
|
effect = ParticleEffect.valueOf(type.toUpperCase());
|
||||||
|
} catch (IllegalArgumentException | NullPointerException e) {
|
||||||
|
effect = ParticleEffect.ASH;
|
||||||
|
getPl().getLogger().severe("The particle '" + type + "' doesn't exist! Default particle enabled...");
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
shape = shapeTypes[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void display(Player p) {
|
||||||
|
if (!enabled) return;
|
||||||
|
try { //Incase the library errors out
|
||||||
|
switch (shape) {
|
||||||
|
case "TELEPORT": partTeleport(p); break;
|
||||||
|
case "EXPLOSIVE": partExplosion(p); break;
|
||||||
|
default: //Super redundant, but... just future proofing
|
||||||
|
case "SCAN": partScan(p); break;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void partScan(Player p) { //Particles with negative velocity
|
||||||
|
Location loc = p.getLocation().add(new Vector(0, 2, 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void partTeleport(Player p) { //Static particles in a shape
|
||||||
|
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);
|
||||||
|
Vector vec = getVecCircle(index, precision, radius).add(new Vector(0, yran, 0));
|
||||||
|
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, 0, 0));
|
||||||
|
for (int index = 1; index < precision; index++) {
|
||||||
|
Vector vec = getVecCircle(index, precision, radius);
|
||||||
|
effect.display(loc.clone().add(vec), vec, 1f, 0, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector getVecCircle(int index, int precise, int rad) {
|
||||||
|
double p1 = (index * Math.PI) / (precise / 2);
|
||||||
|
double p2 = (index - 1) * Math.PI / (precise / 2);
|
||||||
|
//Positions
|
||||||
|
double x1 = Math.cos(p1) * rad;
|
||||||
|
double x2 = Math.cos(p2) * rad;
|
||||||
|
double z1 = Math.sin(p1) * rad;
|
||||||
|
double z2 = Math.sin(p2) * rad;
|
||||||
|
return new Vector(x2 - x1, 0, z2 - z1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Main getPl() {
|
||||||
|
return Main.getInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,12 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
|
|
||||||
public class RTPTeleport {
|
public class RTPTeleport {
|
||||||
|
|
||||||
|
private RTPParticles particles = new RTPParticles();
|
||||||
|
|
||||||
|
void load() {
|
||||||
|
particles.load();
|
||||||
|
}
|
||||||
|
|
||||||
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 {
|
||||||
getPl().getText().getSuccessLoading(sendi); //Send loading message
|
getPl().getText().getSuccessLoading(sendi); //Send loading message
|
||||||
@@ -38,7 +44,7 @@ public class RTPTeleport {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (getPl().getText().getSoundsEnabled())
|
if (getPl().getText().getSoundsEnabled())
|
||||||
sounds(p);
|
sounds(p);
|
||||||
particles(p);
|
particles.display(p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -110,30 +116,6 @@ public class RTPTeleport {
|
|||||||
p.playSound(p.getLocation(), sound, 1F, 1F);
|
p.playSound(p.getLocation(), sound, 1F, 1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void particles(Player p) {
|
|
||||||
if (getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG).getBoolean("Settings.Particles.Enabled"))
|
|
||||||
try {
|
|
||||||
String type = getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG).getString("Settings.Particles.Type");
|
|
||||||
ParticleEffect effect = ParticleEffect.valueOf(type.toUpperCase());
|
|
||||||
int radius = 30;
|
|
||||||
int precision = getPl().getFiles().getType(FileBasics.FILETYPE.CONFIG).getInt("Settings.Particles.Amount");;
|
|
||||||
Location loc = p.getLocation().add(new Vector(0, 2, 0));
|
|
||||||
for (int i = 1; i < precision; i++) {
|
|
||||||
double p1 = (i * Math.PI) / (precision / 2);
|
|
||||||
double p2 = (i - 1) * Math.PI / (precision / 2);
|
|
||||||
|
|
||||||
double x1 = Math.cos(p1) * radius;
|
|
||||||
double x2 = Math.cos(p2) * radius;
|
|
||||||
double z1 = Math.sin(p1) * radius;
|
|
||||||
double z2 = Math.sin(p2) * radius;
|
|
||||||
Vector vec = new Vector(x2 - x1, 0, z2 - z1);
|
|
||||||
effect.display(loc.clone().add(vec), new Vector(0, -0.125, 0), 1f, 0, null);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Main getPl() {
|
private Main getPl() {
|
||||||
return Main.getInstance();
|
return Main.getInstance();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ Settings:
|
|||||||
Enabled: true
|
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: 'PORTAL' #list of particle types at https://github.com/ByteZ1337/ParticleLib/blob/master/src/main/java/xyz/xenondevs/particle/ParticleEffect.java
|
||||||
Amount: 180
|
Amount: 180
|
||||||
|
Shape: 'SCAN' #Types available are "Scan, Teleport and Explosive"
|
||||||
DisableUpdater: false
|
DisableUpdater: false
|
||||||
|
|
||||||
Default:
|
Default:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
main: me.SuperRonanCraft.BetterRTP.Main
|
main: me.SuperRonanCraft.BetterRTP.Main
|
||||||
version: '2.11.3'
|
version: '2.12.0'
|
||||||
name: BetterRTP
|
name: BetterRTP
|
||||||
author: SuperRonanCraft
|
author: SuperRonanCraft
|
||||||
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]
|
softdepend: [Vault, WorldGuard, GriefPrevention, Factions]
|
||||||
|
|||||||
Reference in New Issue
Block a user