@Test
 public void materialStaticInitialisationTest() {
   EngineFaker.setupEngine();
   try {
     new Stone("Test Stone", 87945);
     VanillaMaterials.initialize();
     for (Field field : VanillaMaterials.class.getFields()) {
       try {
         if (field == null
             || ((field.getModifiers() & (Modifier.STATIC | Modifier.PUBLIC))
                 != (Modifier.STATIC | Modifier.PUBLIC))
             || !VanillaMaterial.class.isAssignableFrom(field.getType())) {
           continue;
         }
         VanillaMaterial material = (VanillaMaterial) field.get(null);
         if (material == null) {
           fail("invalid material: VanillaMaterials field '" + field.getName() + "' is null");
         }
       } catch (NoClassDefFoundError ex) {
         staticInitFail(ex);
       } catch (Throwable t) {
         t.printStackTrace();
         fail(
             "invalid material: An exception occurred while loading/reading VanillaMaterials field '"
                 + field.getName()
                 + "'");
       }
     }
   } catch (NoClassDefFoundError t) {
     staticInitFail(t);
   }
 }
 @EventHandler
 public Message onBlockAction(BlockActionEvent event) {
   int id = VanillaMaterials.getMinecraftId(event.getMaterial());
   if (id == -1) {
     return null;
   } else {
     return new BlockActionMessage(
         event.getBlock(), (short) id, event.getData1(), event.getData2());
   }
 }
Ejemplo n.º 3
0
 public static Material popMaterial(String argName, CommandArguments args)
     throws ArgumentParseException {
   String arg = args.currentArgument(argName);
   Material mat;
   try {
     mat = VanillaMaterials.getMaterial((short) Integer.parseInt(arg));
   } catch (NumberFormatException ex) {
     mat = MaterialRegistry.get(arg);
   }
   if (mat == null) {
     throw args.failure(argName, "Unknown material: " + arg, false);
   }
   return args.success(argName, mat);
 }
Ejemplo n.º 4
0
 public void play(List<Player> players, Point position, BlockMaterial material) {
   int id = VanillaMaterials.getMinecraftId(material);
   if (id != -1) {
     this.play(players, position, id);
   }
 }