Skip to content
Snippets Groups Projects
Verified Commit 5416456b authored by Spotlight Deveaux's avatar Spotlight Deveaux :fox:
Browse files

cool sparkle stuff

parent 76242306
No related branches found
No related tags found
No related merge requests found
package io.github.spotlightishere.CraftAdditions; package io.github.spotlightishere.CraftAdditions;
import org.bukkit.Effect;
import org.bukkit.Particle;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
class CommandHandle implements CommandExecutor { class CommandHandle implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) { if (sender instanceof Player) {
Player p = (Player) sender; Player p = (Player) sender;
switch (cmd.getName().toLowerCase()) { switch (cmd.getName().toLowerCase()) {
case "shrug": { case "shrug": {
...@@ -15,7 +18,40 @@ class CommandHandle implements CommandExecutor { ...@@ -15,7 +18,40 @@ class CommandHandle implements CommandExecutor {
break; break;
} }
// We use a switch just in case of future events. case "sparkles": {
if (args.length == 0) {
StringBuilder usage = new StringBuilder("Usage: /sparkles <");
for (Particle meme : Particle.values()) {
usage.append(meme.toString()).append(", ");
}
usage.append(">");
p.sendMessage(usage.toString());
} else {
String wishedValue = args[0];
Particle toApply = null;
try {
toApply = Particle.valueOf(wishedValue);
} catch (IllegalArgumentException e) {
p.sendMessage("Seems that doesn't exist.. double check for typos.");
}
p.sendMessage("Alright, sprinkling you with sparkles. Log out/back in to stop.");
Particle finalToApply = toApply;
BukkitRunnable test = new BukkitRunnable() {
@Override
public void run() {
if (!p.isOnline()) {
this.cancel();
}
p.spawnParticle(finalToApply, p.getLocation(), 25, 0.75, 0.75, 0.2);
}
};
test.runTaskTimer(Main.plugin, 0, 5);
}
break;
}
default: { default: {
return false; return false;
......
package io.github.spotlightishere.CraftAdditions; package io.github.spotlightishere.CraftAdditions;
import java.util.Random; import java.util.Random;
import org.bukkit.Sound;
import org.bukkit.*;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.server.ServerListPingEvent; import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.scheduler.BukkitRunnable;
class ListenerClass class ListenerClass
implements Listener { implements Listener {
Random random = new Random(); private Random random = new Random();
@EventHandler @EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
// Combat update? More like combat downgrade.
event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(16.0); event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(16.0);
// A nice "ping" on join.
for (Player p : Main.plugin.getServer().getOnlinePlayers()) { for (Player p : Main.plugin.getServer().getOnlinePlayers()) {
try { try {
Thread.sleep(50L); Thread.sleep(50L);
} } catch (InterruptedException e) {
catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0f, 1.0f); p.playSound(p.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0f, 1.0f);
...@@ -40,5 +48,4 @@ implements Listener { ...@@ -40,5 +48,4 @@ implements Listener {
String randomMessage = DeathQuotes.QUOTES[random.nextInt(DeathQuotes.QUOTES.length)]; String randomMessage = DeathQuotes.QUOTES[random.nextInt(DeathQuotes.QUOTES.length)];
e.setDeathMessage(randomMessage + "\n" + orig); e.setDeathMessage(randomMessage + "\n" + orig);
} }
}
...@@ -27,13 +27,14 @@ public class Main extends JavaPlugin { ...@@ -27,13 +27,14 @@ public class Main extends JavaPlugin {
tagCraft.shape(" B", " C ", "C "); tagCraft.shape(" B", " C ", "C ");
tagCraft.setIngredient('B', Material.STRING); tagCraft.setIngredient('B', Material.STRING);
tagCraft.setIngredient('C', Material.PAPER); tagCraft.setIngredient('C', Material.PAPER);
this.getServer().addRecipe(elytraCraft); // this.getServer().addRecipe(elytraCraft);
this.getServer().addRecipe(tagCraft); // this.getServer().addRecipe(tagCraft);
// Handle all types of events // Handle all types of events
this.getServer().getPluginManager().registerEvents(new ListenerClass(), this); this.getServer().getPluginManager().registerEvents(new ListenerClass(), this);
this.getCommand("shrug").setExecutor(new CommandHandle()); this.getCommand("shrug").setExecutor(new CommandHandle());
this.getCommand("sparkles").setExecutor(new CommandHandle());
} }
public void onDisable() { public void onDisable() {
......
...@@ -3,4 +3,6 @@ name: CraftAdditions ...@@ -3,4 +3,6 @@ name: CraftAdditions
version: 1.0 version: 1.0
commands: commands:
shrug: shrug:
description: "Makes you shrug." description: "Makes you shrug."
\ No newline at end of file sparkles:
description: All hail the particle lord.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment