-
-
Save deathcap/03fbcc7be391b539c65a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package particletest; | |
import org.apache.commons.lang.StringUtils; | |
import org.bukkit.Location; | |
import org.bukkit.Material; | |
import org.bukkit.Effect; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.entity.Player; | |
import org.bukkit.material.MaterialData; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import org.bukkit.scheduler.BukkitRunnable; | |
/** | |
* Simple test plugin for particles PR. | |
*/ | |
public class ParticleTestPlugin extends JavaPlugin { | |
@Override | |
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | |
if (args.length < 1) { | |
return false; | |
} | |
if (!(sender instanceof Player)) { | |
sender.sendMessage("Must be player"); | |
return true; | |
} | |
String subcmd = args[0]; | |
Player player = (Player) sender; | |
if (subcmd.equalsIgnoreCase("list")) { | |
Effect[] vals = Effect.values(); | |
player.sendMessage("Available particles (" + vals.length + "): " + StringUtils.join(vals, ", ")); | |
} else if (subcmd.equalsIgnoreCase("all")) { | |
int i = 0; | |
for (Effect particle : Effect.values()) { | |
if (particle.getData() == null && particle.getType() == Effect.Type.PARTICLE) { | |
new DoThings(player, particle).runTaskLater(this, i * 40); | |
++i; | |
} | |
} | |
} else { | |
Effect particle; | |
try { | |
particle = Effect.valueOf(subcmd); | |
} catch (IllegalArgumentException e) { | |
player.sendMessage("No such particle " + subcmd + ", try \"list\""); | |
return true; | |
} | |
MaterialData data = null; | |
if (particle.getData() != null) { | |
if (args.length < 2) { | |
player.sendMessage("Must provide material"); | |
return true; | |
} | |
data = new MaterialData(Material.matchMaterial(args[1])); | |
} | |
if (particle.getData() != null && args.length < 3) { | |
if (args.length < 3) { | |
player.sendMessage("Must provide data"); | |
return true; | |
} | |
assert data != null; | |
data.setData(Byte.valueOf(args[2])); | |
} | |
Location loc = player.getLocation().add(0, 3, 0); | |
getServer().broadcastMessage("Showing particle: " + particle + " with spread 0.3, speed 0.2, count 20, data " + data); | |
player.getWorld().spigot().playEffect(loc, particle, particle.getId(), data.getItemTypeId(), 0.3f, 0.3f, 0.3f, 0.2f, 20, 48); | |
} | |
return true; | |
} | |
private class DoThings extends BukkitRunnable { | |
private final Player player; | |
private final Effect particle; | |
public DoThings(Player player, Effect particle) { | |
this.player = player; | |
this.particle = particle; | |
} | |
public void run() { | |
player.sendMessage("Showing particle: " + particle + " with spread 0.3, speed 0.2, count 20"); | |
player.getWorld().spigot().playEffect(player.getLocation().add(0, 3, 0), particle, particle.getId(), 0, 0.3f, 0.3f, 0.3f, 0.2f, 20, 48); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ParticleTest | |
main: particletest.ParticleTestPlugin | |
author: SpaceManiac | |
version: 1.0 | |
# commands | |
commands: | |
particles: | |
aliases: [ perms, perm ] | |
description: Commands for manipulating permissions. | |
usage: | | |
/<command> all - perform test sequence | |
/<command> list - show list of particles | |
/<command> PARTICLE_NAME - play one particle with specified values |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>ParticleTest</groupId> | |
<artifactId>ParticleTest</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<repositories> | |
<repository> | |
<id>bukkit</id> | |
<name>Bukkit Artifactory</name> | |
<layout>default</layout> | |
<url>http://repo.bukkit.org/content/groups/public/</url> | |
</repository> | |
</repositories> | |
<dependencies> | |
<dependency> | |
<groupId>org.bukkit</groupId> | |
<artifactId>bukkit</artifactId> | |
<version>1.7.2-R0.3-SNAPSHOT</version> | |
<type>jar</type> | |
<scope>compile</scope> | |
</dependency> | |
</dependencies> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment