mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Assorted cleanup.
This commit is contained in:
@ -498,11 +498,7 @@ public final class ItemUtils {
|
||||
}
|
||||
|
||||
public static boolean isSmeltable(ItemStack item) {
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return MaterialUtils.isOre(item.getData());
|
||||
return item != null && MaterialUtils.isOre(item.getData());
|
||||
}
|
||||
|
||||
public static boolean isSmelted(ItemStack item) {
|
||||
|
@ -64,11 +64,7 @@ public final class Misc {
|
||||
* @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise
|
||||
*/
|
||||
public static boolean isNear(Location first, Location second, double maxDistance) {
|
||||
if (first.getWorld() != second.getWorld()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0;
|
||||
return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0);
|
||||
}
|
||||
|
||||
public static void dropItems(Location location, Collection<ItemStack> drops) {
|
||||
@ -90,41 +86,6 @@ public final class Misc {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly drop an item at a given location.
|
||||
*
|
||||
* @param location The location to drop the items at
|
||||
* @param is The item to drop
|
||||
* @param chance The percentage chance for the item to drop
|
||||
*/
|
||||
public static void randomDropItem(Location location, ItemStack is, double chance) {
|
||||
if (random.nextInt(100) < chance) {
|
||||
dropItem(location, is);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop items with random quantity at a given location.
|
||||
*
|
||||
* @param location The location to drop the items at
|
||||
* @param is The item to drop
|
||||
* @param quantity The amount of items to drop
|
||||
*/
|
||||
public static void randomDropItems(Location location, ItemStack is, int quantity) {
|
||||
int dropCount = random.nextInt(quantity + 1);
|
||||
|
||||
if (dropCount > 0) {
|
||||
is.setAmount(dropCount);
|
||||
dropItem(location, is);
|
||||
}
|
||||
}
|
||||
|
||||
public static void randomDropItems(Location location, Collection<ItemStack> drops, double chance) {
|
||||
for (ItemStack item : drops) {
|
||||
randomDropItem(location, item, chance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop an item at a given location.
|
||||
*
|
||||
|
@ -90,28 +90,16 @@ public final class UserManager {
|
||||
return retrieveMcMMOPlayer(playerName, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the McMMOPlayer of a player.
|
||||
*
|
||||
* @param player The player whose McMMOPlayer to retrieve
|
||||
* @return the player's McMMOPlayer object
|
||||
*/
|
||||
public static McMMOPlayer getPlayer(OfflinePlayer player) {
|
||||
public static McMMOPlayer getOfflinePlayer(OfflinePlayer player) {
|
||||
if (player instanceof Player) {
|
||||
return getPlayer((Player) player);
|
||||
}
|
||||
return retrieveMcMMOPlayer(player.getName(), false);
|
||||
|
||||
return retrieveMcMMOPlayer(player.getName(), true);
|
||||
}
|
||||
|
||||
public static McMMOPlayer getPlayer(OfflinePlayer player, boolean offlineValid) {
|
||||
if (player instanceof Player) {
|
||||
return getPlayer((Player) player);
|
||||
}
|
||||
return retrieveMcMMOPlayer(player.getName(), offlineValid);
|
||||
}
|
||||
|
||||
public static McMMOPlayer getPlayer(String playerName, boolean offlineValid) {
|
||||
return retrieveMcMMOPlayer(playerName, offlineValid);
|
||||
public static McMMOPlayer getOfflinePlayer(String playerName) {
|
||||
return retrieveMcMMOPlayer(playerName, true);
|
||||
}
|
||||
|
||||
public static McMMOPlayer getPlayer(Player player) {
|
||||
@ -133,10 +121,6 @@ public final class UserManager {
|
||||
}
|
||||
|
||||
public static boolean hasPlayerDataKey(Entity entity) {
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return entity.hasMetadata(mcMMO.playerDataKey);
|
||||
return entity != null && entity.hasMetadata(mcMMO.playerDataKey);
|
||||
}
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ public class ScoreboardManager {
|
||||
}
|
||||
|
||||
for (String playerName : dirtyPowerLevels) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getOfflinePlayer(playerName);
|
||||
|
||||
if (mcMMOPlayer == null) {
|
||||
continue;
|
||||
|
Reference in New Issue
Block a user