Commits
Doc authored and md_5 committed 0d109e865c9
466 466 | return getHandle().getXpNeededForNextLevel(); |
467 467 | } |
468 468 | |
469 469 | |
470 470 | public float getAttackCooldown() { |
471 471 | return getHandle().getAttackStrengthScale(0.5f); |
472 472 | } |
473 473 | |
474 474 | |
475 475 | public boolean hasCooldown(Material material) { |
476 - | Preconditions.checkArgument(material != null, "material"); |
476 + | Preconditions.checkArgument(material != null, "Material cannot be null"); |
477 + | Preconditions.checkArgument(material.isItem(), "Material %s is not an item", material); |
477 478 | |
478 479 | return getHandle().getCooldowns().isOnCooldown(CraftMagicNumbers.getItem(material)); |
479 480 | } |
480 481 | |
481 482 | |
482 483 | public int getCooldown(Material material) { |
483 - | Preconditions.checkArgument(material != null, "material"); |
484 + | Preconditions.checkArgument(material != null, "Material cannot be null"); |
485 + | Preconditions.checkArgument(material.isItem(), "Material %s is not an item", material); |
484 486 | |
485 487 | ItemCooldown.Info cooldown = getHandle().getCooldowns().cooldowns.get(CraftMagicNumbers.getItem(material)); |
486 488 | return (cooldown == null) ? 0 : Math.max(0, cooldown.endTime - getHandle().getCooldowns().tickCount); |
487 489 | } |
488 490 | |
489 491 | |
490 492 | public void setCooldown(Material material, int ticks) { |
491 - | Preconditions.checkArgument(material != null, "material"); |
493 + | Preconditions.checkArgument(material != null, "Material cannot be null"); |
494 + | Preconditions.checkArgument(material.isItem(), "Material %s is not an item", material); |
492 495 | Preconditions.checkArgument(ticks >= 0, "Cannot have negative cooldown"); |
493 496 | |
494 497 | getHandle().getCooldowns().addCooldown(CraftMagicNumbers.getItem(material), ticks); |
495 498 | } |
496 499 | |
497 500 | |
498 501 | public boolean discoverRecipe(NamespacedKey recipe) { |
499 502 | return discoverRecipes(Arrays.asList(recipe)) != 0; |
500 503 | } |
501 504 | |