Skip to content

Commit

Permalink
Update particle handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Spazzinq committed Sep 20, 2024
1 parent 0807f02 commit 51d69c9
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void loadTrail() {

if (trailEnabled) {
pl.getParticle().setParticle(conf.getString("trail.particle"));
pl.getParticle().setAmount(conf.getInt("trail.amount"));
pl.getParticle().setCount(conf.getInt("trail.amount"));
String offset = conf.getString("trail.rgb");
if (offset != null && (offset = offset.replaceAll("\\s+", "")).split(",").length == 3) {
String[] xyz = offset.split(",");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface FlightParticle {

void setParticle(String s);

void setAmount(int amount);
void setCount(int count);

void setRBG(int r, int g, int b);
}
4 changes: 2 additions & 2 deletions VersionCurrent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dependencies {
implementation project(':API')
implementation project(':Multiversion')

compileOnly ('org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT') { exclude(group: "*") }
compileOnly ('com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT') { exclude(group: "*") }
compileOnly ('org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT') { exclude(group: "*") }
compileOnly ('com.sk89q.worldedit:worldedit-bukkit:7.4.0-SNAPSHOT') { exclude(group: "*") }
compileOnly ('com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT') {
exclude group: 'com.google.code.gson', module: 'gson'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@

public class ParticleNewAPI implements FlightParticle {
private Particle particle = Particle.CLOUD;
private Particle.DustOptions o;
private int amount = 4;
private double extra, x, y, z;
private Object data;
private int count = 4;

public void spawn(Location loc) {
if (loc.getWorld() != null) {
loc.getWorld().spawnParticle(particle, particle == Particle.CLOUD ? loc.clone().subtract(0, .3, 0) : loc,
amount, x, y, z, extra, o, true);
count, data);
}
}

Expand All @@ -28,35 +27,22 @@ public void setParticle(String s) {
particle = Particle.valueOf(s);
} catch (Exception ignored) {
}

switch (particle) {
case REDSTONE, SPELL_MOB, SPELL_MOB_AMBIENT, NOTE -> extra = 1;
default -> extra = 0;
}
}

public void setAmount(int amount) {
this.amount = amount;
public void setCount(int count) {
this.count = count;
}

public void setRBG(int r, int g, int b) {
x = 0;
y = 0;
z = 0;
o = null;
data = null;
switch (particle) {
case REDSTONE:
o = new Particle.DustOptions(Color.fromRGB(r, g, b), amount);
case DUST:
data = new Particle.DustOptions(Color.fromRGB(r, g, b), count);
break;
case SPELL_MOB, SPELL_MOB_AMBIENT: {
x = r / 255d;
y = g / 255d;
z = b / 255d;
case ENTITY_EFFECT: {
data = Color.fromRGB(r, g, b);
break;
}
case NOTE:
x = r / 24.0;
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion VersionOld/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dependencies {
implementation project(':API')
implementation project(':Multiversion')

compileOnly('org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT') { exclude(group: "*") }
compileOnly('org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT') { exclude(group: "*") }
compileOnly ('com.sk89q.worldguard:worldguard-legacy:6.1.3-SNAPSHOT') {
exclude group: 'com.google.code.gson'
exclude group: 'com.google.guava'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,60 @@

package org.spazzinq.flightcontrol.multiversion.legacy;

import org.bukkit.Effect;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.spazzinq.flightcontrol.multiversion.FlightParticle;

public class ParticleOldAPI implements FlightParticle {
private Effect effect = Effect.CLOUD;
private float r = 0, g = 0, b = 0, speed = 0F;
private int amount = 4, data = 0;
private Particle particle = Particle.CLOUD;
private Particle.DustOptions o;
private int amount = 4;
private double extra, x, y, z;

public void spawn(Location l) {
// playEffect(to, effect, 0, data, r, g, b, speed, amount, 0);
l.getWorld().spigot().playEffect(l, effect, 0, data, r, g, b, speed, amount, 160);
public void spawn(Location loc) {
if (loc.getWorld() != null) {
loc.getWorld().spawnParticle(particle, particle == Particle.CLOUD ? loc.clone().subtract(0, .3, 0) : loc,
amount, x, y, z, extra, o, true);
}
}

public void setParticle(String s) {
try {
Effect.valueOf(s);
} catch (Exception e) {
return;
}
if (Effect.valueOf(s).getType() == Effect.Type.PARTICLE) {
effect = Effect.valueOf(s);
particle = Particle.valueOf(s);
} catch (Exception ignored) {
}
if (effect == Effect.COLOURED_DUST) {
speed = 1;
data = 1;
} else {
speed = 0;
data = 0;

switch (particle) {
case REDSTONE, SPELL_MOB, SPELL_MOB_AMBIENT, NOTE -> extra = 1;
default -> extra = 0;
}
}

public void setAmount(int amount) { this.amount = amount; }
public void setCount(int amount) {
this.amount = amount;
}

public void setRBG(int r, int g, int b) {
if ((r == 0 && g == 0 && b == 0)) {
this.r = 0;
this.g = 0;
this.b = 0;
} else {
this.r = (r / 255F) - 1;
this.g = g / 255F;
this.b = b / 255F;
x = 0;
y = 0;
z = 0;
o = null;
switch (particle) {
case REDSTONE:
o = new Particle.DustOptions(Color.fromRGB(r, g, b), amount);
break;
case SPELL_MOB, SPELL_MOB_AMBIENT: {
x = r / 255d;
y = g / 255d;
z = b / 255d;
break;
}
case NOTE:
x = r / 24.0;
break;
default:
break;
}
}
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
allprojects {
group = 'org.spazzinq'
version = '5.0.0-BETA'
version = '5.0.1-BETA'
}

subprojects {
Expand Down

0 comments on commit 51d69c9

Please sign in to comment.