New rituals and better commands

This commit is contained in:
Edith Boles 2021-10-03 17:27:11 -07:00
parent 1f57e57f44
commit 44adf70358
22 changed files with 168 additions and 13 deletions

View File

@ -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<EntityType, Integer> 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<EntityType, Integer> 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");

View File

@ -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());
}

View File

@ -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) {

View File

@ -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<ItemStack> extra) {}
// add an ingredient to the recipe (type and count)
public void addIngredient(Material material, int count) {
ingredients.put(material, count);

View File

@ -19,6 +19,7 @@ public class AnvilRitual extends Ritual {
name = "anviling";
health = 5;
backfire = 0.5;
notify = false;
}
@Override

View File

@ -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);
}
}

View File

@ -16,6 +16,7 @@ public class CreeperHissRitual extends Ritual {
addIngredient(Material.WHEAT, 16);
name = "creeper hissing";
health = 1;
notify = false;
}
@Override

View File

@ -17,6 +17,7 @@ public class CrystalizationRtiual extends Ritual {
addIngredient(Material.WHEAT, 32);
name = "crystalization";
health = 2;
notify = false;
}
@Override

View File

@ -21,6 +21,7 @@ public class DragonRitual extends Ritual {
addIngredient(Material.DIAMOND_BLOCK, 1);
name = "dragon summoning";
health = 3;
lightning = true;
}
@Override

View File

@ -21,6 +21,7 @@ public class FakePlayerRitual extends Ritual {
addIngredient(Material.WHEAT, 32);
addIngredient(Material.LEAVES, 32);
name = "player illusion";
notify = false;
}
@Override

View File

@ -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);
}

View File

@ -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);
}
}
}
}
}

View File

@ -17,6 +17,7 @@ public class GetLuckyRitual extends Ritual {
health = 3;
lightning = true;
name = "daring";
notify = false;
}
@Override

View File

@ -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));
}
}

View File

@ -15,6 +15,7 @@ public class HitRitual extends Ritual {
addIngredient(Material.WHEAT, 9);
name = "shadow hit";
health = 1;
notify = false;
}
@Override

View File

@ -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<Material>) null, 7);
if (block != null) {
block.setType(Material.GOLD_BLOCK);
}
}
}

View File

@ -17,6 +17,7 @@ public class RotateRitual extends Ritual {
health = 4;
backfire = 0.05;
name = "rotation";
notify = false;
}
@Override

View File

@ -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

View File

@ -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);
}
}

View File

@ -18,6 +18,8 @@ public class WitherRitual extends Ritual {
addIngredient(Material.SAND, 1);
name = "wither summoning";
health = 2;
notify = false;
lightning = true;
}
@Override

View File

@ -17,6 +17,7 @@ public class WoolingRitual extends Ritual {
name = "wooling";
health = 2;
byproducts.add(new ItemStack(Material.WOOL, 100));
notify = false;
}
@Override

View File

@ -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 /&lt;permission&gt;
usage: |
§3/ritual list [page] - List all available rituals.