Пример #1
0
 static {
   //noinspection ConstantConditions
   COAL_MAP =
       ImmutableBiMap.<CoalType, Integer>builder()
           .put(CoalTypes.COAL, 0)
           .put(CoalTypes.CHARCOAL, 1)
           .build();
   //noinspection ConstantConditions
   COOKED_FISH_MAP =
       ImmutableBiMap.<CookedFish, Integer>builder()
           .put(CookedFishes.COD, 0)
           .put(CookedFishes.SALMON, 1)
           .build();
   //noinspection deprecation, ConstantConditions
   DYE_MAP =
       ImmutableBiMap.<DyeColor, Integer>builder()
           .put(DyeColors.BLACK, (int) org.bukkit.DyeColor.BLACK.getDyeData())
           .put(DyeColors.RED, (int) org.bukkit.DyeColor.RED.getDyeData())
           .put(DyeColors.GREEN, (int) org.bukkit.DyeColor.GREEN.getDyeData())
           .put(DyeColors.BROWN, (int) org.bukkit.DyeColor.BROWN.getDyeData())
           .put(DyeColors.BLUE, (int) org.bukkit.DyeColor.BLUE.getDyeData())
           .put(DyeColors.PURPLE, (int) org.bukkit.DyeColor.PURPLE.getDyeData())
           .put(DyeColors.CYAN, (int) org.bukkit.DyeColor.CYAN.getDyeData())
           .put(DyeColors.SILVER, (int) org.bukkit.DyeColor.SILVER.getDyeData())
           .put(DyeColors.GRAY, (int) org.bukkit.DyeColor.GRAY.getDyeData())
           .put(DyeColors.PINK, (int) org.bukkit.DyeColor.PINK.getDyeData())
           .put(DyeColors.LIME, (int) org.bukkit.DyeColor.LIME.getDyeData())
           .put(DyeColors.YELLOW, (int) org.bukkit.DyeColor.YELLOW.getDyeData())
           .put(DyeColors.LIGHT_BLUE, (int) org.bukkit.DyeColor.LIGHT_BLUE.getDyeData())
           .put(DyeColors.MAGENTA, (int) org.bukkit.DyeColor.MAGENTA.getDyeData())
           .put(DyeColors.ORANGE, (int) org.bukkit.DyeColor.ORANGE.getDyeData())
           .put(DyeColors.WHITE, (int) org.bukkit.DyeColor.WHITE.getDyeData())
           .build();
   //noinspection ConstantConditions
   FISH_MAP =
       ImmutableBiMap.<Fish, Integer>builder()
           .put(Fishes.COD, 0)
           .put(Fishes.SALMON, 1)
           .put(Fishes.CLOWNFISH, 2)
           .put(Fishes.PUFFERFISH, 3)
           .build();
   //noinspection ConstantConditions
   GOLDEN_APPLE_MAP =
       ImmutableBiMap.<GoldenApple, Integer>builder()
           .put(GoldenApples.GOLDEN_APPLE, 0)
           .put(GoldenApples.ENCHANTED_GOLDEN_APPLE, 1)
           .build();
 }
 @SuppressWarnings("deprecation")
 private byte getSaturationData(Block b) {
   long now = System.currentTimeMillis();
   long delta = (now - SoilSaturation.getLastWatered(b)) / 1000;
   int saturation = SoilSaturation.getSaturationLevel(b);
   saturation = Math.max(0, saturation - (int) delta);
   if (saturation < 10) {
     return DyeColor.YELLOW.getWoolData();
   } else if (saturation < 30) {
     return DyeColor.BROWN.getWoolData();
   } else if (saturation < 50) {
     return DyeColor.GREEN.getWoolData();
   } else if (saturation < 70) {
     return DyeColor.LIGHT_BLUE.getWoolData();
   } else if (saturation < 90) {
     return DyeColor.CYAN.getWoolData();
   } else {
     return DyeColor.BLUE.getWoolData();
   }
 }