diff --git a/src/main/java/top/penowl/quidproquo/Commands.java b/src/main/java/top/penowl/quidproquo/Commands.java index 227a911..a355c08 100644 --- a/src/main/java/top/penowl/quidproquo/Commands.java +++ b/src/main/java/top/penowl/quidproquo/Commands.java @@ -65,12 +65,14 @@ public class Commands implements CommandExecutor { builder.append(": " + ChatColor.AQUA + entry.getValue().toString()); builder.append("\n"); } - builder.append(" \n" + ChatColor.RED + "" + ChatColor.BOLD + "Sacrifices:\n"); - for (Map.Entry entry : ritual.sacrifices.entrySet()) { - builder.append(ChatColor.GOLD); - builder.append(WordUtils.capitalizeFully(entry.getKey().toString().replace('_', ' ').toLowerCase())); - builder.append(": " + ChatColor.AQUA + entry.getValue().toString()); - builder.append("\n"); + if (ritual.sacrifices.size() > 0) { + builder.append(" \n" + ChatColor.RED + "" + ChatColor.BOLD + "Sacrifices:\n"); + for (Map.Entry entry : ritual.sacrifices.entrySet()) { + builder.append(ChatColor.GOLD); + builder.append(WordUtils.capitalizeFully(entry.getKey().toString().replace('_', ' ').toLowerCase())); + builder.append(": " + ChatColor.AQUA + entry.getValue().toString()); + builder.append("\n"); + } } builder.append(" \n" + ChatColor.YELLOW + "" + ChatColor.BOLD + "Blood: " + ChatColor.RESET + "" + ChatColor.AQUA + String.valueOf(ritual.health / 2.0) + ChatColor.RED + " ♥\n"); builder.append(ChatColor.YELLOW + "" + ChatColor.BOLD + "Backfire: " + ChatColor.RESET + "" + ChatColor.AQUA + String.valueOf(Math.round(ritual.backfire * 100)) + "%\n"); diff --git a/src/main/java/top/penowl/quidproquo/Events.java b/src/main/java/top/penowl/quidproquo/Events.java index 128015f..913043b 100644 --- a/src/main/java/top/penowl/quidproquo/Events.java +++ b/src/main/java/top/penowl/quidproquo/Events.java @@ -204,8 +204,17 @@ public final class Events implements Listener { // backfire check, if succeeds then the ritual gets reversed if(new Random().nextDouble() >= ritual.backfire) { + if (ritual.notify && otherPlayer.getUniqueId() != player.getUniqueId()) { + otherPlayer.sendMessage(ChatColor.YELLOW + "You were hit by a " + ritual.name + " ritual!"); + } ritual.execute(player, otherPlayer, block.getLocation()); } else { + if (ritual.notify) { + if (otherPlayer.getUniqueId() != player.getUniqueId()) { + otherPlayer.sendMessage(ChatColor.YELLOW + "Someone tried to enact a " + ritual.name + " ritual on you but it backfired!"); + } + player.sendMessage(ChatColor.YELLOW + "The ritual backfired on you!"); + } ritual.execute(otherPlayer, player, block.getLocation()); } diff --git a/src/main/java/top/penowl/quidproquo/QuidProQuo.java b/src/main/java/top/penowl/quidproquo/QuidProQuo.java index fad7858..4966c73 100644 --- a/src/main/java/top/penowl/quidproquo/QuidProQuo.java +++ b/src/main/java/top/penowl/quidproquo/QuidProQuo.java @@ -56,6 +56,9 @@ public class QuidProQuo extends JavaPlugin { rituals.add(new SoundRitual()); rituals.add(new WitherRitual()); rituals.add(new WoolingRitual()); + rituals.add(new MidasRitual()); + rituals.add(new SummoningRitual()); + rituals.add(new GBJRitual()); // run ritual setup scripts for (Ritual ritual : rituals) { diff --git a/src/main/java/top/penowl/quidproquo/Ritual.java b/src/main/java/top/penowl/quidproquo/Ritual.java index b26a7d5..bcf993e 100644 --- a/src/main/java/top/penowl/quidproquo/Ritual.java +++ b/src/main/java/top/penowl/quidproquo/Ritual.java @@ -32,9 +32,14 @@ public abstract class Ritual { // whether you want a lightning effect public Boolean lightning = false; + // whether the target is notified + public Boolean notify = true; + // the actual effect that gets triggered public abstract void execute(Player caster, Player target, Location location); + public void handleByproducts(ArrayList extra) {} + // add an ingredient to the recipe (type and count) public void addIngredient(Material material, int count) { ingredients.put(material, count); diff --git a/src/main/java/top/penowl/quidproquo/rituals/AnvilRitual.java b/src/main/java/top/penowl/quidproquo/rituals/AnvilRitual.java index badc2a1..76db828 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/AnvilRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/AnvilRitual.java @@ -19,6 +19,7 @@ public class AnvilRitual extends Ritual { name = "anviling"; health = 5; backfire = 0.5; + notify = false; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/ChickenSpewRitual.java b/src/main/java/top/penowl/quidproquo/rituals/ChickenSpewRitual.java index 6025a80..cfb1936 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/ChickenSpewRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/ChickenSpewRitual.java @@ -13,6 +13,7 @@ public class ChickenSpewRitual extends Ritual { public void setup() { addIngredient(Material.WHEAT, 64); addIngredient(Material.DIAMOND_HOE, 1); + addSacrifice(EntityType.CHICKEN, 1); health = 3; name = "chicken spew"; backfire = 0.1; @@ -21,7 +22,7 @@ public class ChickenSpewRitual extends Ritual { @Override public void execute(Player caster, Player target, Location location) { for (int i = 0; i < 20; i++) { - target.getWorld().spawnEntity(target.getLocation(), EntityType.CHICKEN); + target.getLocation().getWorld().spawnEntity(target.getLocation(), EntityType.CHICKEN); } } diff --git a/src/main/java/top/penowl/quidproquo/rituals/CreeperHissRitual.java b/src/main/java/top/penowl/quidproquo/rituals/CreeperHissRitual.java index 5441bcb..4b81f0e 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/CreeperHissRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/CreeperHissRitual.java @@ -16,6 +16,7 @@ public class CreeperHissRitual extends Ritual { addIngredient(Material.WHEAT, 16); name = "creeper hissing"; health = 1; + notify = false; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/CrystalizationRtiual.java b/src/main/java/top/penowl/quidproquo/rituals/CrystalizationRtiual.java index 224d955..6adeaab 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/CrystalizationRtiual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/CrystalizationRtiual.java @@ -17,6 +17,7 @@ public class CrystalizationRtiual extends Ritual { addIngredient(Material.WHEAT, 32); name = "crystalization"; health = 2; + notify = false; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/DragonRitual.java b/src/main/java/top/penowl/quidproquo/rituals/DragonRitual.java index 4c9c2f7..473a87a 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/DragonRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/DragonRitual.java @@ -21,6 +21,7 @@ public class DragonRitual extends Ritual { addIngredient(Material.DIAMOND_BLOCK, 1); name = "dragon summoning"; health = 3; + lightning = true; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/FakePlayerRitual.java b/src/main/java/top/penowl/quidproquo/rituals/FakePlayerRitual.java index 6291bb5..27fcdad 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/FakePlayerRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/FakePlayerRitual.java @@ -21,6 +21,7 @@ public class FakePlayerRitual extends Ritual { addIngredient(Material.WHEAT, 32); addIngredient(Material.LEAVES, 32); name = "player illusion"; + notify = false; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/FeedingRitual.java b/src/main/java/top/penowl/quidproquo/rituals/FeedingRitual.java index ad4c19f..30ac10d 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/FeedingRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/FeedingRitual.java @@ -18,6 +18,7 @@ public class FeedingRitual extends Ritual { @Override public void execute(Player caster, Player target, Location location) { + target.setFoodLevel(20); caster.setFoodLevel(20); } diff --git a/src/main/java/top/penowl/quidproquo/rituals/GBJRitual.java b/src/main/java/top/penowl/quidproquo/rituals/GBJRitual.java new file mode 100644 index 0000000..57d8827 --- /dev/null +++ b/src/main/java/top/penowl/quidproquo/rituals/GBJRitual.java @@ -0,0 +1,57 @@ +package top.penowl.quidproquo.rituals; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import top.penowl.quidproquo.Ritual; + +public class GBJRitual extends Ritual { + + @Override + public void setup() { + addIngredient(Material.IRON_INGOT, 6); + addIngredient(Material.STONE, 1); + addIngredient(Material.WHEAT, 272); + name = "caging"; + health = 5; + backfire = 0.2; + } + + @Override + public void execute(Player caster, Player target, Location location) { + Location targetLocation = target.getLocation(); + fillBlocks(targetLocation.clone().add(-1, -1, -1), 3, 1, 3, Material.OBSIDIAN); + fillEmptyBlocks(targetLocation.clone().add(-1, 3, -1), 3, 1, 3, Material.OBSIDIAN); + fillEmptyBlocks(targetLocation.clone().add(-1, 0, -1), 3, 3, 3, Material.IRON_FENCE); + fillBlocks(targetLocation, 1, 3, 1, Material.AIR); + } + + public void fillEmptyBlocks(Location location, int offsetx, int offsety, int offsetz, Material material) { + Block block = location.getBlock(); + for (int x = 0; x < offsetx; x++ ) { + for (int y = 0; y < offsety; y++ ) { + for (int z = 0; z < offsetz; z++ ) { + Block targetBlock = block.getRelative(x, y, z); + if (targetBlock.getType() == Material.AIR) { + targetBlock.setType(material); + } + } + } + } + } + + public void fillBlocks(Location location, int offsetx, int offsety, int offsetz, Material material) { + Block block = location.getBlock(); + for (int x = 0; x < offsetx; x++ ) { + for (int y = 0; y < offsety; y++ ) { + for (int z = 0; z < offsetz; z++ ) { + Block targetBlock = block.getRelative(x, y, z); + targetBlock.setType(material); + } + } + } + } + +} diff --git a/src/main/java/top/penowl/quidproquo/rituals/GetLuckyRitual.java b/src/main/java/top/penowl/quidproquo/rituals/GetLuckyRitual.java index 68ab2f2..5b1d098 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/GetLuckyRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/GetLuckyRitual.java @@ -17,6 +17,7 @@ public class GetLuckyRitual extends Ritual { health = 3; lightning = true; name = "daring"; + notify = false; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/HealRitual.java b/src/main/java/top/penowl/quidproquo/rituals/HealRitual.java index 522dc99..761cc3b 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/HealRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/HealRitual.java @@ -18,7 +18,8 @@ public class HealRitual extends Ritual { @Override public void execute(Player caster, Player target, Location location) { - caster.setHealth(Math.min(caster.getMaxHealth(), caster.getHealth()+8.0)); + caster.setHealth(Math.min(caster.getMaxHealth(), caster.getHealth()+4.0)); + target.setHealth(Math.min(caster.getMaxHealth(), caster.getHealth()+4.0)); } } diff --git a/src/main/java/top/penowl/quidproquo/rituals/HitRitual.java b/src/main/java/top/penowl/quidproquo/rituals/HitRitual.java index 00b7407..23ce8d5 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/HitRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/HitRitual.java @@ -15,6 +15,7 @@ public class HitRitual extends Ritual { addIngredient(Material.WHEAT, 9); name = "shadow hit"; health = 1; + notify = false; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/MidasRitual.java b/src/main/java/top/penowl/quidproquo/rituals/MidasRitual.java new file mode 100644 index 0000000..199e462 --- /dev/null +++ b/src/main/java/top/penowl/quidproquo/rituals/MidasRitual.java @@ -0,0 +1,33 @@ +package top.penowl.quidproquo.rituals; + +import java.util.Set; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +import top.penowl.quidproquo.Ritual; + +public class MidasRitual extends Ritual { + + @Override + public void setup() { + addIngredient(Material.GOLDEN_CARROT, 1); + addIngredient(Material.GOLD_BLOCK, 1); + addIngredient(Material.GOLDEN_APPLE, 1); + addIngredient(Material.GLASS_BOTTLE, 1); + addIngredient(Material.WHEAT, 64*3); + name = "midas"; + health = 5; + } + + @Override + public void execute(Player caster, Player target, Location location) { + Block block = target.getTargetBlock((Set) null, 7); + if (block != null) { + block.setType(Material.GOLD_BLOCK); + } + } + +} diff --git a/src/main/java/top/penowl/quidproquo/rituals/RotateRitual.java b/src/main/java/top/penowl/quidproquo/rituals/RotateRitual.java index 7a8b44d..44c6b36 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/RotateRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/RotateRitual.java @@ -17,6 +17,7 @@ public class RotateRitual extends Ritual { health = 4; backfire = 0.05; name = "rotation"; + notify = false; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java b/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java index bf460aa..a5c459c 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/SoundRitual.java @@ -11,10 +11,11 @@ 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; + addIngredient(Material.NOTE_BLOCK, 1); + addIngredient(Material.WHEAT, 4); + name = "shadow sound"; + health = 1; + notify = false; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/SummoningRitual.java b/src/main/java/top/penowl/quidproquo/rituals/SummoningRitual.java new file mode 100644 index 0000000..ff7ab67 --- /dev/null +++ b/src/main/java/top/penowl/quidproquo/rituals/SummoningRitual.java @@ -0,0 +1,31 @@ +package top.penowl.quidproquo.rituals; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import top.penowl.quidproquo.Ritual; + +public class SummoningRitual extends Ritual { + + @Override + public void setup() { + addIngredient(Material.ENDER_PEARL, 1); + addIngredient(Material.COMPASS, 1); + addIngredient(Material.WHEAT, 64+32); + health = 6; + name = "summoning"; + backfire = 0.04; + } + + @Override + public void execute(Player caster, Player target, Location location) { + target.teleport(location.clone().add(0, 1, 0)); + target.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 10, 255)); + location.getWorld().createExplosion(location, 5F); + } + +} diff --git a/src/main/java/top/penowl/quidproquo/rituals/WitherRitual.java b/src/main/java/top/penowl/quidproquo/rituals/WitherRitual.java index 4d63f69..306945a 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/WitherRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/WitherRitual.java @@ -18,6 +18,8 @@ public class WitherRitual extends Ritual { addIngredient(Material.SAND, 1); name = "wither summoning"; health = 2; + notify = false; + lightning = true; } @Override diff --git a/src/main/java/top/penowl/quidproquo/rituals/WoolingRitual.java b/src/main/java/top/penowl/quidproquo/rituals/WoolingRitual.java index 0712215..529eecf 100644 --- a/src/main/java/top/penowl/quidproquo/rituals/WoolingRitual.java +++ b/src/main/java/top/penowl/quidproquo/rituals/WoolingRitual.java @@ -17,6 +17,7 @@ public class WoolingRitual extends Ritual { name = "wooling"; health = 2; byproducts.add(new ItemStack(Material.WOOL, 100)); + notify = false; } @Override diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index f35cf59..20e393e 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,7 +5,7 @@ commands: ritual: description: Check ritual information. aliases: [quidproquo, rt] - permission: quidproquo.command + # permission: quidproquo.command permission-message: You do not have /<permission> usage: | §3/ritual list [page] - List all available rituals.