use of org.spongepowered.api.data.property.block.UnbreakableProperty in project LanternServer by LanternPowered.
the class LanternWorld method getBlockDigTimeWith.
public int getBlockDigTimeWith(int x, int y, int z, @Nullable GameProfile profile, @Nullable ItemStack itemStack) {
// Check if the user has the creative game mode
if (profile != null) {
final Optional<User> optUser = Lantern.getGame().getUserStorageService().get(profile);
if (optUser.isPresent()) {
final User user = optUser.get();
if (user.get(Keys.GAME_MODE).orElse(GameModes.NOT_SET) == GameModes.CREATIVE) {
return 0;
}
}
}
final Optional<UnbreakableProperty> optUnbreakableProperty = getProperty(x, y, z, UnbreakableProperty.class);
if (optUnbreakableProperty.isPresent() && optUnbreakableProperty.get().getValue() == Boolean.TRUE) {
return -1;
}
final Optional<HardnessProperty> optHardnessProperty = getProperty(x, y, z, HardnessProperty.class);
if (optHardnessProperty.isPresent()) {
final Double value = optHardnessProperty.get().getValue();
double hardness = value == null ? 0 : value;
// TODO: Calculate the duration
return hardness <= 0 ? 0 : 1;
}
return 0;
}
Aggregations