Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
Effects won't spawn if the player is in vanish
  • Loading branch information
poqdavid committed Feb 10, 2022
1 parent 4d48e4c commit 9cee903
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 51 deletions.
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ m_description=A plugin for crazy cool effects

## Version
m_major=1
m_minor=1
m_minor=2
m_api=S7.4
m_suffix=STABLE

## Dependencies
spongeapi=7.4.+
spongemixin=0.8.5-SNAPSHOT
nucleus=2.4.0
minecraft_version=1.12.2
forge_rundir=run/forge
forgeVersion=1.12.2-14.23.5.2860
Expand Down
102 changes: 52 additions & 50 deletions src/main/java/io/github/poqdavid/nyx/nyxeffect/Tasks/EffectTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.github.poqdavid.nyx.nyxeffect.Utils.Data.ParticleDataList;
import io.github.poqdavid.nyx.nyxeffect.Utils.Tools;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.effect.particle.ParticleEffect;
import org.spongepowered.api.effect.particle.ParticleOptions;
import org.spongepowered.api.entity.living.player.Player;
Expand Down Expand Up @@ -120,79 +121,80 @@ private void Run(Player player, List<ParticleDataList> pdslist) {
}

private void spawnEffects(Player player, String effecttype, String effectdata, Vector3d loc, long cleartime) {
if (!player.get(Keys.VANISH).filter(value -> value).isPresent()) {
if (effecttype.equalsIgnoreCase("timer")) {
try {
if (effectdata.contains("delay:")) {
final String[] data = effectdata.replace(" ", "").split(":");
Thread.sleep(Integer.parseInt(data[1]));
}

if (effecttype.equalsIgnoreCase("timer")) {
try {
if (effectdata.contains("delay:")) {
final String[] data = effectdata.replace(" ", "").split(":");
Thread.sleep(Integer.parseInt(data[1]));
} catch (InterruptedException e) {
e.printStackTrace();
}

} catch (InterruptedException e) {
e.printStackTrace();
}
}

if (effecttype.equalsIgnoreCase("particle")) {
if (loc != null) {
final String data = effectdata;
String id = "NONE";
if (data.contains(";")) {
final String[] datas = data.replace(" ", "").split(";");

String[] colorData = new String[3];
colorData[0] = "NONE";
Color colors = Color.BLACK;
for (String datax : datas) {
if (datax.contains("minecraft:")) {
id = datax;
}
if (effecttype.equalsIgnoreCase("particle")) {
if (loc != null) {
final String data = effectdata;
String id = "NONE";
if (data.contains(";")) {
final String[] datas = data.replace(" ", "").split(";");

String[] colorData = new String[3];
colorData[0] = "NONE";
Color colors = Color.BLACK;
for (String datax : datas) {
if (datax.contains("minecraft:")) {
id = datax;
}

if (datax.contains("Color")) {
colorData = datax.replace("Color{", "").replace("}", "").replace("red=", "").replace("green=", "").replace("blue=", "").split(",").clone();
if (datax.contains("Color")) {
colorData = datax.replace("Color{", "").replace("}", "").replace("red=", "").replace("green=", "").replace("blue=", "").split(",").clone();

final int red = Integer.parseInt(colorData[0]);
final int green = Integer.parseInt(colorData[1]);
final int blue = Integer.parseInt(colorData[2]);
colors = Color.ofRgb(red, green, blue);
}

final int red = Integer.parseInt(colorData[0]);
final int green = Integer.parseInt(colorData[1]);
final int blue = Integer.parseInt(colorData[2]);
colors = Color.ofRgb(red, green, blue);
}

}
if (!colorData[0].equals("NONE")) {

if (!colorData[0].equals("NONE")) {
player.getWorld().spawnParticles(ParticleEffect.builder().type(CoreTools.GetParticleType(id)).option(ParticleOptions.COLOR, colors).build(), loc);
} else {
player.getWorld().spawnParticles(ParticleEffect.builder().type(CoreTools.GetParticleType(id)).build(), loc);
}

player.getWorld().spawnParticles(ParticleEffect.builder().type(CoreTools.GetParticleType(id)).option(ParticleOptions.COLOR, colors).build(), loc);
} else {
id = data;
player.getWorld().spawnParticles(ParticleEffect.builder().type(CoreTools.GetParticleType(id)).build(), loc);
}

} else {
id = data;
player.getWorld().spawnParticles(ParticleEffect.builder().type(CoreTools.GetParticleType(id)).build(), loc);
}
}
}

if (effecttype.equalsIgnoreCase("block")) {
if (player.isOnGround()) {
try {
Location<World> locs = new Location<World>(player.getLocation().getExtent(), new Vector3d(loc.getX(), player.getLocation().getY(), loc.getZ()));
if (locs != null) {
Location<World> blockOn = Tools.getLocBelow(player, locs);
if (blockOn != null) { //blockOn.getBlockType() != BlockTypes.AIR && blockOn.getBlockType() != BlockTypes.WATER
if (!NyxEffect.getInstance().restricted_blocks.contains(blockOn.getBlockType())) {
final Vector3i loci = new Vector3i(blockOn.getX(), blockOn.getY(), blockOn.getZ());
if (effecttype.equalsIgnoreCase("block")) {
if (player.isOnGround()) {
try {
Location<World> locs = new Location<World>(player.getLocation().getExtent(), new Vector3d(loc.getX(), player.getLocation().getY(), loc.getZ()));
if (locs != null) {
Location<World> blockOn = Tools.getLocBelow(player, locs);
if (blockOn != null) { //blockOn.getBlockType() != BlockTypes.AIR && blockOn.getBlockType() != BlockTypes.WATER
if (!NyxEffect.getInstance().restricted_blocks.contains(blockOn.getBlockType())) {
final Vector3i loci = new Vector3i(blockOn.getX(), blockOn.getY(), blockOn.getZ());

player.getWorld().sendBlockChange(loci, BlockState.builder().from(CoreTools.GetBlock(effectdata)).build());
Tools.ClearBlockTask(player, loci, cleartime);
player.getWorld().sendBlockChange(loci, BlockState.builder().from(CoreTools.GetBlock(effectdata)).build());
Tools.ClearBlockTask(player, loci, cleartime);

}
}
}
} catch (Exception e) {
}
} catch (Exception e) {
}


}
}
}
}
Expand Down

0 comments on commit 9cee903

Please sign in to comment.