diff --git a/src/main/java/io/github/spotlightishere/CraftAdditions/CommandHandle.java b/src/main/java/io/github/spotlightishere/CraftAdditions/CommandHandle.java index ca0f4c358a7f47924592cf313247dc39b0fb13df..5c1b12739d25b260a352ccfadd2ace8ec96c6d5a 100644 --- a/src/main/java/io/github/spotlightishere/CraftAdditions/CommandHandle.java +++ b/src/main/java/io/github/spotlightishere/CraftAdditions/CommandHandle.java @@ -1,13 +1,16 @@ package io.github.spotlightishere.CraftAdditions; +import org.bukkit.Effect; +import org.bukkit.Particle; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.scheduler.BukkitRunnable; class CommandHandle implements CommandExecutor { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { - if (!(sender instanceof Player)) { + if (sender instanceof Player) { Player p = (Player) sender; switch (cmd.getName().toLowerCase()) { case "shrug": { @@ -15,7 +18,40 @@ class CommandHandle implements CommandExecutor { 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: { return false; diff --git a/src/main/java/io/github/spotlightishere/CraftAdditions/ListenerClass.java b/src/main/java/io/github/spotlightishere/CraftAdditions/ListenerClass.java index 21f9d509c8df3fea30ed6479b4c53ced85573ec4..7c29e09dfb707a5c189d888c5fa51e7d26795dd3 100644 --- a/src/main/java/io/github/spotlightishere/CraftAdditions/ListenerClass.java +++ b/src/main/java/io/github/spotlightishere/CraftAdditions/ListenerClass.java @@ -1,27 +1,35 @@ package io.github.spotlightishere.CraftAdditions; import java.util.Random; -import org.bukkit.Sound; + +import org.bukkit.*; import org.bukkit.attribute.Attribute; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Boat; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; +import org.bukkit.event.block.Action; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.server.ServerListPingEvent; +import org.bukkit.scheduler.BukkitRunnable; class ListenerClass implements Listener { - Random random = new Random(); + private Random random = new Random(); @EventHandler public void onPlayerJoin(PlayerJoinEvent event) { + // Combat update? More like combat downgrade. event.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED).setBaseValue(16.0); + + // A nice "ping" on join. for (Player p : Main.plugin.getServer().getOnlinePlayers()) { try { Thread.sleep(50L); - } - catch (InterruptedException e) { + } catch (InterruptedException e) { e.printStackTrace(); } p.playSound(p.getLocation(), Sound.BLOCK_NOTE_PLING, 1.0f, 1.0f); @@ -40,5 +48,4 @@ implements Listener { String randomMessage = DeathQuotes.QUOTES[random.nextInt(DeathQuotes.QUOTES.length)]; e.setDeathMessage(randomMessage + "\n" + orig); } -} diff --git a/src/main/java/io/github/spotlightishere/CraftAdditions/Main.java b/src/main/java/io/github/spotlightishere/CraftAdditions/Main.java index 75012014f90d487d714bb117fb1836f47088712f..51a7abee9cbd6c4c0328541dbb5568ce969f3e82 100644 --- a/src/main/java/io/github/spotlightishere/CraftAdditions/Main.java +++ b/src/main/java/io/github/spotlightishere/CraftAdditions/Main.java @@ -27,13 +27,14 @@ public class Main extends JavaPlugin { tagCraft.shape(" B", " C ", "C "); tagCraft.setIngredient('B', Material.STRING); tagCraft.setIngredient('C', Material.PAPER); - this.getServer().addRecipe(elytraCraft); - this.getServer().addRecipe(tagCraft); +// this.getServer().addRecipe(elytraCraft); +// this.getServer().addRecipe(tagCraft); // Handle all types of events this.getServer().getPluginManager().registerEvents(new ListenerClass(), this); this.getCommand("shrug").setExecutor(new CommandHandle()); + this.getCommand("sparkles").setExecutor(new CommandHandle()); } public void onDisable() { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0f84b694dbf5a7b71d7e7d7ce058d59d0d85119b..9cf26e4557dc142b853b03e58de018ff8e468b07 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,4 +3,6 @@ name: CraftAdditions version: 1.0 commands: shrug: - description: "Makes you shrug." \ No newline at end of file + description: "Makes you shrug." + sparkles: + description: All hail the particle lord. \ No newline at end of file