Java Code Examples for org.bukkit.Particle#valueOf()

The following examples show how to use org.bukkit.Particle#valueOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckConfig.java    From WildernessTp with MIT License 6 votes vote down vote up
public boolean checkParticle(){
    if(wild.getConfig().getBoolean("DoParticle")) {
        try {
            String[] tmp = Bukkit.getVersion().split("MC: ");
            String version = tmp[tmp.length - 1].substring(0, 3);
            if (version.equals("1.9") || version.equals("1.1"))
                Particle.valueOf(wild.getConfig().getString("Particle").toUpperCase());
            else
                Effect.valueOf(wild.getConfig().getString("Particle").toUpperCase());
        } catch (IllegalArgumentException e) {
            return false;
        }
    }else
        return true;
    return true;
}
 
Example 2
Source File: ParticleHandler.java    From ClaimChunk with MIT License 5 votes vote down vote up
private static void spawn(Location loc, Player[] players, Particles particle) {
    final Particle bukkitParticle = Particle.valueOf(particle.name());
    //noinspection ConstantConditions
    if (bukkitParticle == null) {
        Utils.err("Invalid particle: %s", particle.name());
        return;
    }
    for (Player p : players) p.spawnParticle(bukkitParticle, loc, 1, 0.0d, 0.0d, 0.0d, 0.0d, null);
}
 
Example 3
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
public boolean isValueParticle(String string) {
	try {
		Particle.valueOf(string);
	} catch (IllegalArgumentException e) {
		return false;
	}
	return true;
}
 
Example 4
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 5 votes vote down vote up
public boolean isValueParticle(String string) {
	try {
		Particle.valueOf(string);
	} catch (IllegalArgumentException e) {
		return false;
	}
	return true;
}
 
Example 5
Source File: EffParticlesV1_13.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    double hx = 0;
    double hy = 0;
    double hz = 0;
    //float id = 0;
    //int[] array = new int[0];
    if (xoffset != null) {
        hx = xoffset.getSingle(evt).doubleValue();
    }
    if (yoffset != null) {
        hy = yoffset.getSingle(evt).doubleValue();
    }
    if (zoffset != null) {
        hz = zoffset.getSingle(evt).doubleValue();
    }
    String core = type.getSingle(evt);
/*
if (core.toUpperCase().replace(" ", "_").contains("BLOCK_CRACK")
    || core.toUpperCase().replace(" ", "_").contains("BLOCK_DUST")) {
  int index = type.getSingle(evt).lastIndexOf("_");
  try {
    id = Integer.parseInt(type.getSingle(evt).substring(index + 1));
  } catch (Exception exception) {
    Skript.error("Could not parse datavalue!");
    id = 0;
  }
  core = core.substring(0, index);
  array = new int[1];
}*/
    Particle particle;
    try {
        particle = Particle.valueOf(core);
    } catch (Exception e) {
        Skript.error("Could not parse particle value!");
        return;
    }
    player.getSingle(evt).spawnParticle(particle, location.getSingle(evt),
            partNum.getSingle(evt).intValue(), hx, hy, hz);
}
 
Example 6
Source File: EffParticlesV1_14.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    double hx = 0;
    double hy = 0;
    double hz = 0;
    //float id = 0;
    //int[] array = new int[0];
    if (xoffset != null) {
        hx = xoffset.getSingle(evt).doubleValue();
    }
    if (yoffset != null) {
        hy = yoffset.getSingle(evt).doubleValue();
    }
    if (zoffset != null) {
        hz = zoffset.getSingle(evt).doubleValue();
    }
    String core = type.getSingle(evt);
/*
if (core.toUpperCase().replace(" ", "_").contains("BLOCK_CRACK")
    || core.toUpperCase().replace(" ", "_").contains("BLOCK_DUST")) {
  int index = type.getSingle(evt).lastIndexOf("_");
  try {
    id = Integer.parseInt(type.getSingle(evt).substring(index + 1));
  } catch (Exception exception) {
    Skript.error("Could not parse datavalue!");
    id = 0;
  }
  core = core.substring(0, index);
  array = new int[1];
}*/
    Particle particle;
    try {
        particle = Particle.valueOf(core);
    } catch (Exception e) {
        Skript.error("Could not parse particle value!");
        return;
    }
    player.getSingle(evt).spawnParticle(particle, location.getSingle(evt),
            partNum.getSingle(evt).intValue(), hx, hy, hz);
}
 
Example 7
Source File: EffParticlesV1_13_1.java    From skRayFall with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void execute(Event evt) {
    double hx = 0;
    double hy = 0;
    double hz = 0;
    //float id = 0;
    //int[] array = new int[0];
    if (xoffset != null) {
        hx = xoffset.getSingle(evt).doubleValue();
    }
    if (yoffset != null) {
        hy = yoffset.getSingle(evt).doubleValue();
    }
    if (zoffset != null) {
        hz = zoffset.getSingle(evt).doubleValue();
    }
    String core = type.getSingle(evt);
/*
if (core.toUpperCase().replace(" ", "_").contains("BLOCK_CRACK")
    || core.toUpperCase().replace(" ", "_").contains("BLOCK_DUST")) {
  int index = type.getSingle(evt).lastIndexOf("_");
  try {
    id = Integer.parseInt(type.getSingle(evt).substring(index + 1));
  } catch (Exception exception) {
    Skript.error("Could not parse datavalue!");
    id = 0;
  }
  core = core.substring(0, index);
  array = new int[1];
}*/
    Particle particle;
    try {
        particle = Particle.valueOf(core);
    } catch (Exception e) {
        Skript.error("Could not parse particle value!");
        return;
    }
    player.getSingle(evt).spawnParticle(particle, location.getSingle(evt),
            partNum.getSingle(evt).intValue(), hx, hy, hz);
}
 
Example 8
Source File: ParticleDisplay.java    From EffectLib with MIT License 5 votes vote down vote up
public static ParticleDisplay newInstance() {
    ParticleDisplay display;
    try {
       Particle.valueOf("SQUID_INK");
       display = new ParticleDisplay_13();
    } catch (Throwable not13) {
       display = new ParticleDisplay_12();
    }
    return display;
}
 
Example 9
Source File: CraftParticle.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public static Particle toBukkit(EnumParticleTypes nms) {
    return Particle.valueOf(nms.name());
}
 
Example 10
Source File: NMSHandler.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
public void sendParticles(World world, String type, float x, float y, float z, float offsetX, float offsetY, float offsetZ, float data, int amount) {
	Particle particle = Particle.valueOf(type);
    for (Player player: world.getPlayers()) {
	    player.spawnParticle(particle, x, y, z, amount, offsetX, offsetY, offsetZ, data);
	}
}