From 40c805fc6f428add8172378ffd3f0ed52dd53572 Mon Sep 17 00:00:00 2001 From: B1G-FUNGUS Date: Fri, 1 Oct 2021 18:15:17 -0700 Subject: [PATCH 1/2] Sound ritual adds a ritual that plays a random sound --- .../quidproquo/rituals/SoundRitual.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java diff --git a/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java b/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java new file mode 100644 index 0000000..2dd1f97 --- /dev/null +++ b/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java @@ -0,0 +1,68 @@ +package top.penowl.quidproquo.rituals; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import java.util.Random; + +import top.penowl.quidproquo.Ritual; + +public class SoundRitual extends Ritual { + @Override + public void setup() { + addIngredient(Material.NOTE_BLOCK, 1); + addIngredient(Material.WHEAT, 4); + name = "shadow sound"; + health = 1; + } + + @Override + public void execute(Player caster, Player target, Location location) { + Sound randomSound = Sound.ENDERDRAGON_DEATH; + int randomInt = new Random().nextInt(13); + switch (randomInt) { + case 0: + randomSound = Sound.STEP_STONE; + break; + case 1: + randomSound = Sound.CLICK; + break; + case 2: + randomSound = Sound.CREEPER_HISS; + break; + case 3: + randomSound = Sound.DIG_GRAVEL; + break; + case 4: + randomSound = Sound.DIG_STONE; + break; + case 5: + randomSound = Sound.DIG_WOOD; + break; + case 6: + randomSound = Sound.EXPLODE; + break; + case 7: + randomSound = Sound.FIZZ; + break; + case 8: + randomSound = Sound.GHAST_SCREAM; + break; + case 9: + randomSound = Sound.SKELETON_HURT; + break; + case 10: + randomSound = Sound.STEP_GRAVEL; + break; + case 11: + randomSound = Sound.STEP_GRASS; + break; + case 12: + randomSound = Sound.ZOMBIE_HURT; + break; + } + target.playSound(target.getLocation(), randomSound, 1, 1); + } + +} From 4c37b62c69aa9c0c57d2df1172acd1757aa008c6 Mon Sep 17 00:00:00 2001 From: B1G-FUNGUS Date: Fri, 1 Oct 2021 19:15:49 -0700 Subject: [PATCH 2/2] DONT USE ELSE IF CHAINS!! Some minor tweaks --- .../quidproquo/rituals/FillerRitual.java | 31 ++++++++++--------- .../penowl/quidproquo/rituals/HitRitual.java | 7 ----- .../quidproquo/rituals/SoundRitual.java | 4 +-- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/main/java/top/penowl/quidproquo/rituals/FillerRitual.java b/src/main/java/top/penowl/quidproquo/rituals/FillerRitual.java index 5ee1c06..5172355 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/FillerRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/FillerRitual.java @@ -1,13 +1,11 @@ package top.penowl.quidproquo.rituals; -import java.util.ArrayList; -import java.util.List; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import java.util.Random; import top.penowl.quidproquo.Ritual; @@ -28,17 +26,22 @@ public class FillerRitual extends Ritual { int items = target.getInventory().getSize(); for (int i = 0; i < items; i++) { Material typeMaterial; - double random = Math.random(); - if (random < 0.20) { - typeMaterial = Material.WOOD_AXE; - } else if (random < 0.40) { - typeMaterial = Material.WOOD_SPADE; - } else if (random < 0.60) { - typeMaterial = Material.WOOD_SWORD; - } else if (random < 0.80) { - typeMaterial = Material.WOOD_PICKAXE; - } else { - typeMaterial = Material.WOOD_HOE; + int random = new Random().nextInt(5); + switch(random) { + case 0: + typeMaterial = Material.WOOD_AXE; + break; + case 1: + typeMaterial = Material.WOOD_SPADE; + break; + case 2: + typeMaterial = Material.WOOD_SWORD; + break; + case 3: + typeMaterial = Material.WOOD_PICKAXE; + default: + typeMaterial=Material.WOOD_HOE; + break; } ItemStack tool = new ItemStack(typeMaterial, 1); tool.setDurability((short) (Material.WOOD_PICKAXE.getMaxDurability() - 1)); diff --git a/src/main/java/top/penowl/quidproquo/rituals/HitRitual.java b/src/main/java/top/penowl/quidproquo/rituals/HitRitual.java index 2d7200b..8b5875e 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/HitRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/HitRitual.java @@ -11,10 +11,7 @@ public class HitRitual extends Ritual { @Override public void setup() { addIngredient(Material.IRON_SWORD, 1); -<<<<<<< HEAD addIngredient(Material.IRON_INGOT, 1); -======= ->>>>>>> 7f77c0dac5cb9bbd0ceaf70f710f7fdecac3e9ad addIngredient(Material.WHEAT, 9); name = "shadow hit"; health = 1; @@ -22,14 +19,10 @@ public class HitRitual extends Ritual { @Override public void execute(Player caster, Player target, Location location) { -<<<<<<< HEAD target.playSound(target.getLocation(), Sound.HURT_FLESH, 1, 1); - //target.damage(1.0); -======= for(int i = 0; i < 3; i ++) { target.playSound(target.getLocation(), Sound.SUCCESSFUL_HIT, 1, 1); } ->>>>>>> 7f77c0dac5cb9bbd0ceaf70f710f7fdecac3e9ad } } diff --git a/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java b/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java index 2dd1f97..bf460aa 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java @@ -19,7 +19,7 @@ public class SoundRitual extends Ritual { @Override public void execute(Player caster, Player target, Location location) { - Sound randomSound = Sound.ENDERDRAGON_DEATH; + Sound randomSound; int randomInt = new Random().nextInt(13); switch (randomInt) { case 0: @@ -58,7 +58,7 @@ public class SoundRitual extends Ritual { case 11: randomSound = Sound.STEP_GRASS; break; - case 12: + default: randomSound = Sound.ZOMBIE_HURT; break; }