diff --git a/pom.xml b/pom.xml
index 6cfa89f..1fcbfbb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,6 +24,11 @@
1.8.8-R0.1-SNAPSHOT
provided
+
+ org.reflections
+ reflections
+ 0.9.9-RC1
+
${project.basedir}/src/main/java
diff --git a/src/main/java/top/penowl/quidproquo/QuidProQuo.java b/src/main/java/top/penowl/quidproquo/QuidProQuo.java
index 24a082d..84cb2d8 100644
--- a/src/main/java/top/penowl/quidproquo/QuidProQuo.java
+++ b/src/main/java/top/penowl/quidproquo/QuidProQuo.java
@@ -1,10 +1,13 @@
package top.penowl.quidproquo;
+import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Set;
import java.util.UUID;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
+import org.reflections.Reflections;
import top.penowl.quidproquo.rituals.*;
@@ -30,38 +33,50 @@ public class QuidProQuo extends JavaPlugin {
getLogger().info("Loading rituals...");
getServer().getPluginManager().registerEvents(new Events(), this);
+ Set> subClasses = (new Reflections()).getSubTypesOf(Ritual.class);
+
+ for (Class extends Ritual> ritualClass : subClasses) {
+ Class>[] params = {};
+ try {
+ Constructor extends Ritual> constructor = ritualClass.getConstructor(params);
+ Object[] args = {};
+ rituals.add(constructor.newInstance(args));
+ } catch (Exception e) {
+ }
+ }
+
// register all rituals
- rituals.add(new AnvilRitual());
- rituals.add(new BatSpewRitual());
- rituals.add(new BlockShiftRitual());
- rituals.add(new ChickenSpewRitual());
- rituals.add(new ChugJugRitual());
- rituals.add(new CreeperHissRitual());
- rituals.add(new CrystalizationRtiual());
- rituals.add(new DragonRitual());
- rituals.add(new FakePlayerRitual());
- rituals.add(new FeedingRitual());
- rituals.add(new FillerRitual());
- rituals.add(new GBJRitual());
- rituals.add(new GetLuckyRitual());
- rituals.add(new HardPenorRitual());
- rituals.add(new HealRitual());
- rituals.add(new HerobrineRitual());
- rituals.add(new HitRitual());
- rituals.add(new LavaRitual());
- rituals.add(new LightQuicktimeRitual());
- rituals.add(new LightningRitual());
- rituals.add(new MidasRitual());
- rituals.add(new QuicktimeRitual());
- rituals.add(new RotateRitual());
- rituals.add(new SnowmanRitual());
- rituals.add(new SoftPenorRitual());
- rituals.add(new SoundRitual());
- rituals.add(new SummoningRitual());
- rituals.add(new WitherRitual());
- rituals.add(new WoolingRitual());
- rituals.add(new RandomItemRitual());
- rituals.add(new KickingRitual());
+ // rituals.add(new AnvilRitual());
+ // rituals.add(new BatSpewRitual());
+ // rituals.add(new BlockShiftRitual());
+ // rituals.add(new ChickenSpewRitual());
+ // rituals.add(new ChugJugRitual());
+ // rituals.add(new CreeperHissRitual());
+ // rituals.add(new CrystalizationRtiual());
+ // rituals.add(new DragonRitual());
+ // rituals.add(new FakePlayerRitual());
+ // rituals.add(new FeedingRitual());
+ // rituals.add(new FillerRitual());
+ // rituals.add(new GBJRitual());
+ // rituals.add(new GetLuckyRitual());
+ // rituals.add(new HardPenorRitual());
+ // rituals.add(new HealRitual());
+ // rituals.add(new HerobrineRitual());
+ // rituals.add(new HitRitual());
+ // rituals.add(new LavaRitual());
+ // rituals.add(new LightQuicktimeRitual());
+ // rituals.add(new LightningRitual());
+ // rituals.add(new MidasRitual());
+ // rituals.add(new QuicktimeRitual());
+ // rituals.add(new RotateRitual());
+ // rituals.add(new SnowmanRitual());
+ // rituals.add(new SoftPenorRitual());
+ // rituals.add(new SoundRitual());
+ // rituals.add(new SummoningRitual());
+ // rituals.add(new WitherRitual());
+ // rituals.add(new WoolingRitual());
+ // rituals.add(new RandomItemRitual());
+ // rituals.add(new KickingRitual());
// run ritual setup scripts
for (Ritual ritual : rituals) {
diff --git a/src/main/java/top/penowl/quidproquo/rituals/RandomItemRitual.java b/src/main/java/top/penowl/quidproquo/rituals/RandomItemRitual.java
index b3c0c69..84db681 100644
--- a/src/main/java/top/penowl/quidproquo/rituals/RandomItemRitual.java
+++ b/src/main/java/top/penowl/quidproquo/rituals/RandomItemRitual.java
@@ -3,6 +3,7 @@ package top.penowl.quidproquo.rituals;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
import top.penowl.quidproquo.Ritual;
@@ -13,7 +14,7 @@ public class RandomItemRitual extends Ritual {
addIngredient(Material.DIRT, 6);
addIngredient(Material.STONE, 5);
addIngredient(Material.IRON_INGOT, 4);
- addIngredient(Material.GOLD_INGOT, 3;
+ addIngredient(Material.GOLD_INGOT, 3);
addIngredient(Material.REDSTONE, 2);
addIngredient(Material.DIAMOND, 1);
addIngredient(Material.WHEAT, 16);
@@ -23,12 +24,9 @@ public class RandomItemRitual extends Ritual {
@Override
public void execute(Player caster, Player target, Location location) {
- Random r = new Random();
- int i = r.nextInt(440);
- while(Material.getValue(i) == null){
- i = r.nextInt(440);
- }
- location.getWorld().dropItemNaturally(location.clone().add(0, 1, 0), ItemStack(Material.getValue(i));
+ Material[] materials = Material.values();
+ Material item = materials[(int)(materials.length*Math.random())];
+ location.getWorld().dropItemNaturally(location.clone().add(0, 1, 0), new ItemStack(item, 1));
}
}