Update code style

This commit is contained in:
nossr50
2019-04-24 22:52:53 -07:00
parent dc758a6dfc
commit 02a69cbb05
334 changed files with 4660 additions and 5158 deletions

View File

@@ -38,10 +38,8 @@ public final class BlockUtils {
* @param blockState the blockstate
* @return true if the player succeeded in the check
*/
public static boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType)
{
if(mcMMO.getConfigManager().isBonusDropsEnabled(blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType))
{
public static boolean checkDoubleDrops(Player player, BlockState blockState, SubSkillType subSkillType) {
if (mcMMO.getConfigManager().isBonusDropsEnabled(blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
return RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true));
}
@@ -125,10 +123,8 @@ public final class BlockUtils {
return isMineable(blockState);
}
public static boolean isMineable(BlockState blockState)
{
switch (blockState.getType())
{
public static boolean isMineable(BlockState blockState) {
switch (blockState.getType()) {
case COAL_ORE:
case DIAMOND_ORE:
case EMERALD_ORE:
@@ -163,7 +159,7 @@ public final class BlockUtils {
* otherwise
*/
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
if(mcMMO.getConfigManager().getExperienceMapManager().hasExcavationXp(blockState.getType()))
if (mcMMO.getConfigManager().getExperienceMapManager().hasExcavationXp(blockState.getType()))
return true;
return isDiggable(blockState);
@@ -171,13 +167,12 @@ public final class BlockUtils {
/**
* Returns true if a shovel is used for digging this block
*
* @param blockState target blockstate
* @return true if a shovel is typically used for digging this block
*/
public static boolean isDiggable(BlockState blockState)
{
switch(blockState.getType())
{
public static boolean isDiggable(BlockState blockState) {
switch (blockState.getType()) {
case CLAY:
case FARMLAND:
case GRASS_BLOCK:
@@ -205,7 +200,7 @@ public final class BlockUtils {
* @return true if the block is a log, false otherwise
*/
public static boolean isLog(BlockState blockState) {
if(mcMMO.getConfigManager().getExperienceMapManager().hasWoodcuttingXp(blockState.getType()))
if (mcMMO.getConfigManager().getExperienceMapManager().hasWoodcuttingXp(blockState.getType()))
return true;
return isLoggingRelated(blockState);
@@ -214,13 +209,12 @@ public final class BlockUtils {
/**
* Determines if this particular block is typically gathered using an Axe
*
* @param blockState target blockstate
* @return true if the block is gathered via axe
*/
public static boolean isLoggingRelated(BlockState blockState)
{
switch(blockState.getType())
{
public static boolean isLoggingRelated(BlockState blockState) {
switch (blockState.getType()) {
case ACACIA_LOG:
case BIRCH_LOG:
case DARK_OAK_LOG:
@@ -275,7 +269,7 @@ public final class BlockUtils {
default:
return false;
//return mcMMO.getModManager().isCustomLeaf(blockState);
//return mcMMO.getModManager().isCustomLeaf(blockState);
}
}

View File

@@ -29,7 +29,8 @@ public final class ChimaeraWing {
private static McMMOPlayer mcMMOPlayer;
private static Location location;
private ChimaeraWing() {}
private ChimaeraWing() {
}
/**
* Check for item usage.
@@ -55,7 +56,7 @@ public final class ChimaeraWing {
mcMMOPlayer = UserManager.getPlayer(player);
//Not loaded
if(mcMMOPlayer == null)
if (mcMMOPlayer == null)
return;
if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
@@ -65,7 +66,7 @@ public final class ChimaeraWing {
int amount = inHand.getAmount();
if (amount < MainConfig.getInstance().getChimaeraUseCost()) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.NotEnough",String.valueOf(MainConfig.getInstance().getChimaeraUseCost() - amount), "Item.ChimaeraWing.Name");
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.NotEnough", String.valueOf(MainConfig.getInstance().getChimaeraUseCost() - amount), "Item.ChimaeraWing.Name");
return;
}
@@ -114,8 +115,7 @@ public final class ChimaeraWing {
if (warmup > 0) {
NotificationManager.sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Teleport.Commencing", String.valueOf(warmup));
new ChimaeraWingWarmup(mcMMOPlayer).runTaskLater(mcMMO.p, 20 * warmup);
}
else {
} else {
chimaeraExecuteTeleport();
}
}
@@ -125,13 +125,11 @@ public final class ChimaeraWing {
if (MainConfig.getInstance().getChimaeraUseBedSpawn() && player.getBedSpawnLocation() != null) {
player.teleport(player.getBedSpawnLocation());
}
else {
} else {
Location spawnLocation = player.getWorld().getSpawnLocation();
if (spawnLocation.getBlock().getType() == Material.AIR) {
player.teleport(spawnLocation);
}
else {
} else {
player.teleport(player.getWorld().getHighestBlockAt(spawnLocation).getLocation());
}
}

View File

@@ -40,7 +40,6 @@ public class EnchantmentUtils {
* Method to get an {@link Enchantment} using it's Vanilla Minecraft name or Bukkit enum name
*
* @param enchantmentName Vanilla or Bukkit name of enchantment
*
* @return Enchantment or null if no enchantment was found
*/
public static Enchantment getByName(String enchantmentName) {

View File

@@ -55,6 +55,7 @@ public class EventUtils {
/*
* Quality of Life methods
*/
/**
* Checks to see if damage is from natural sources
* This cannot be used to determine if damage is from vanilla MC, it just checks to see if the damage is from a complex behaviour in mcMMO such as bleed.
@@ -71,19 +72,19 @@ public class EventUtils {
/**
* This little method is just to make the code more readable
*
* @param entity target entity
* @return the associated McMMOPlayer for this entity
*/
public static McMMOPlayer getMcMMOPlayer(Entity entity)
{
return UserManager.getPlayer((Player)entity);
public static McMMOPlayer getMcMMOPlayer(Entity entity) {
return UserManager.getPlayer((Player) entity);
}
/**
* Checks to see if a Player was damaged in this EntityDamageEvent
*
* <p>
* This method checks for the following things and if they are all true it returns true
*
* <p>
* 1) The player is real and not an NPC
* 2) The player is not in god mode
* 3) The damage dealt is above 0 (if a player has Absorption, check if damage and final damage are above 0)
@@ -92,8 +93,7 @@ public class EventUtils {
* @param entityDamageEvent
* @return
*/
public static boolean isRealPlayerDamaged(EntityDamageEvent entityDamageEvent)
{
public static boolean isRealPlayerDamaged(EntityDamageEvent entityDamageEvent) {
//Make sure the damage is above 0
double damage = entityDamageEvent.getDamage();
double finalDamage = entityDamageEvent.getFinalDamage();
@@ -119,7 +119,7 @@ public class EventUtils {
Entity entity = entityDamageEvent.getEntity();
//Check to make sure the entity is not an NPC
if(Misc.isNPCEntity(entity))
if (Misc.isNPCEntity(entity))
return false;
if (!entity.isValid() || !(entity instanceof LivingEntity)) {
@@ -141,8 +141,7 @@ public class EventUtils {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if(mcMMOPlayer == null)
{
if (mcMMOPlayer == null) {
return true;
}
@@ -171,7 +170,8 @@ public class EventUtils {
/**
* Calls a new SubSkillEvent for this SubSkill and then returns it
* @param player target player
*
* @param player target player
* @param subSkillType target subskill
* @return the event after it has been fired
*/
@@ -185,7 +185,8 @@ public class EventUtils {
/**
* Calls a new SubSkillEvent for this SubSkill and then returns it
* @param player target player
*
* @param player target player
* @param abstractSubSkill target subskill
* @return the event after it has been fired
*/
@@ -236,8 +237,8 @@ public class EventUtils {
/**
* Simulate a block break event.
*
* @param block The block to break
* @param player The player breaking the block
* @param block The block to break
* @param player The player breaking the block
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
* @return true if the event wasn't cancelled, false otherwise
*/
@@ -261,7 +262,7 @@ public class EventUtils {
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
if(mcMMOPlayer == null)
if (mcMMOPlayer == null)
return;
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
@@ -322,7 +323,7 @@ public class EventUtils {
}
public static boolean handleStatsLossEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Float> experienceChanged) {
if(UserManager.getPlayer(player) == null)
if (UserManager.getPlayer(player) == null)
return true;
McMMOPlayerStatLossEvent event = new McMMOPlayerStatLossEvent(player, levelChanged, experienceChanged);
@@ -373,11 +374,11 @@ public class EventUtils {
McMMOPlayer killerPlayer = UserManager.getPlayer(killer);
//Not loaded
if(killerPlayer == null)
if (killerPlayer == null)
return true;
//Not loaded
if(UserManager.getPlayer(victim) == null)
if (UserManager.getPlayer(victim) == null)
return true;
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();

View File

@@ -11,13 +11,14 @@ import org.bukkit.entity.Player;
import java.util.HashMap;
public final class HardcoreManager {
private HardcoreManager() {}
private HardcoreManager() {
}
public static void invokeStatPenalty(Player player) {
double statLossPercentage = MainConfig.getInstance().getHardcoreDeathStatPenaltyPercentage();
int levelThreshold = MainConfig.getInstance().getHardcoreDeathStatPenaltyLevelThreshold();
if(UserManager.getPlayer(player) == null)
if (UserManager.getPlayer(player) == null)
return;
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
@@ -62,7 +63,7 @@ public final class HardcoreManager {
double vampirismStatLeechPercentage = MainConfig.getInstance().getHardcoreVampirismStatLeechPercentage();
int levelThreshold = MainConfig.getInstance().getHardcoreVampirismLevelThreshold();
if(UserManager.getPlayer(killer) == null || UserManager.getPlayer(victim) == null)
if (UserManager.getPlayer(killer) == null || UserManager.getPlayer(victim) == null)
return;
PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile();
@@ -106,8 +107,7 @@ public final class HardcoreManager {
if (totalLevelsStolen > 0) {
NotificationManager.sendPlayerInformation(killer, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Killer.Success", String.valueOf(totalLevelsStolen), victim.getName());
NotificationManager.sendPlayerInformation(victim, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Victim.Success", killer.getName(), String.valueOf(totalLevelsStolen));
}
else {
} else {
NotificationManager.sendPlayerInformation(killer, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Killer.Failure", victim.getName());
NotificationManager.sendPlayerInformation(victim, NotificationType.HARDCORE_MODE, "Hardcore.Vampirism.Victim.Failure", killer.getName());
}

View File

@@ -16,26 +16,23 @@ import java.util.ArrayList;
import java.util.List;
public final class ItemUtils {
private ItemUtils() {}
private ItemUtils() {
}
public static ArrayList<String> getRepairItemMaterials(List<Material> repairItemList)
{
public static ArrayList<String> getRepairItemMaterials(List<Material> repairItemList) {
ArrayList<String> repairMaterialList = new ArrayList<>();
for(Material m : repairItemList)
{
for (Material m : repairItemList) {
repairMaterialList.add(m.getKey().toString());
}
return repairMaterialList;
}
public static ArrayList<Material> matchMaterials(List<String> ItemBlockRegistryKeyList)
{
public static ArrayList<Material> matchMaterials(List<String> ItemBlockRegistryKeyList) {
ArrayList<Material> matchedMaterials = new ArrayList<>();
for(String s : ItemBlockRegistryKeyList)
{
for (String s : ItemBlockRegistryKeyList) {
matchedMaterials.add(Material.matchMaterial(s));
}
@@ -44,15 +41,14 @@ public final class ItemUtils {
/**
* Determines the item type, currently used for repairables/salvageables
*
* @param material target material
* @return the matching ItemType returns OTHER if no match
*/
public static ItemType determineItemType(Material material)
{
public static ItemType determineItemType(Material material) {
if (ItemUtils.isMinecraftTool(new ItemStack(material))) {
return ItemType.TOOL;
}
else if (ItemUtils.isArmor(new ItemStack((material)))) {
} else if (ItemUtils.isArmor(new ItemStack((material)))) {
return ItemType.ARMOR;
} else {
return ItemType.OTHER;
@@ -61,6 +57,7 @@ public final class ItemUtils {
/**
* Determines the material category, currently used for repairables/salvageables
*
* @param material target material
* @return the matching ItemMaterialCategory, return OTHER if no match
*/
@@ -112,7 +109,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomBow(type);
//return mcMMO.getModManager().isCustomBow(type);
}
}
@@ -135,7 +132,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomSword(type);
//return mcMMO.getModManager().isCustomSword(type);
}
}
@@ -158,7 +155,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomHoe(type);
//return mcMMO.getModManager().isCustomHoe(type);
}
}
@@ -181,7 +178,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomShovel(type);
//return mcMMO.getModManager().isCustomShovel(type);
}
}
@@ -204,7 +201,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomAxe(type);
//return mcMMO.getModManager().isCustomAxe(type);
}
}
@@ -227,7 +224,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomPickaxe(type);
//return mcMMO.getModManager().isCustomPickaxe(type);
}
}
@@ -264,7 +261,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomHelmet(type);
//return mcMMO.getModManager().isCustomHelmet(type);
}
}
@@ -287,7 +284,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomChestplate(type);
//return mcMMO.getModManager().isCustomChestplate(type);
}
}
@@ -310,7 +307,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomLeggings(type);
//return mcMMO.getModManager().isCustomLeggings(type);
}
}
@@ -333,7 +330,7 @@ public final class ItemUtils {
default:
return false;
//return mcMMO.getModManager().isCustomBoots(type);
//return mcMMO.getModManager().isCustomBoots(type);
}
}

View File

@@ -7,9 +7,8 @@ import java.util.HashSet;
/**
* Stores hash tables for item and block names
* This allows for better support across multiple versions of Minecraft
*
* <p>
* This is a temporary class, mcMMO is spaghetti and I'l clean it up later
*
*/
public class MaterialMapStore {
@@ -21,8 +20,7 @@ public class MaterialMapStore {
private HashSet<String> blockCrackerWhiteList;
private HashSet<String> canMakeShroomyWhiteList;
public MaterialMapStore()
{
public MaterialMapStore() {
abilityBlackList = new HashSet<>();
toolBlackList = new HashSet<>();
mossyWhiteList = new HashSet<>();
@@ -34,43 +32,35 @@ public class MaterialMapStore {
fillHardcodedHashSets();
}
public boolean isAbilityActivationBlackListed(Material material)
{
public boolean isAbilityActivationBlackListed(Material material) {
return abilityBlackList.contains(material.getKey().getKey());
}
public boolean isToolActivationBlackListed(Material material)
{
public boolean isToolActivationBlackListed(Material material) {
return toolBlackList.contains(material.getKey().getKey());
}
public boolean isMossyWhiteListed(Material material)
{
public boolean isMossyWhiteListed(Material material) {
return mossyWhiteList.contains(material.getKey().getKey());
}
public boolean isLeavesWhiteListed(Material material)
{
public boolean isLeavesWhiteListed(Material material) {
return leavesWhiteList.contains(material.getKey().getKey());
}
public boolean isHerbalismAbilityWhiteListed(Material material)
{
public boolean isHerbalismAbilityWhiteListed(Material material) {
return herbalismAbilityBlackList.contains(material.getKey().getKey());
}
public boolean isBlockCrackerWhiteListed(Material material)
{
public boolean isBlockCrackerWhiteListed(Material material) {
return blockCrackerWhiteList.contains(material.getKey().getKey());
}
public boolean isShroomyWhiteListed(Material material)
{
public boolean isShroomyWhiteListed(Material material) {
return canMakeShroomyWhiteList.contains(material.getKey().getKey());
}
private void fillHardcodedHashSets()
{
private void fillHardcodedHashSets() {
fillAbilityBlackList();
filltoolBlackList();
fillMossyWhiteList();
@@ -80,28 +70,24 @@ public class MaterialMapStore {
fillShroomyWhiteList();
}
private void fillShroomyWhiteList()
{
private void fillShroomyWhiteList() {
canMakeShroomyWhiteList.add("dirt");
canMakeShroomyWhiteList.add("grass");
canMakeShroomyWhiteList.add("grass_path");
}
private void fillBlockCrackerWhiteList()
{
private void fillBlockCrackerWhiteList() {
blockCrackerWhiteList.add("stone_bricks");
}
private void fillHerbalismAbilityBlackList()
{
private void fillHerbalismAbilityBlackList() {
herbalismAbilityBlackList.add("dirt");
herbalismAbilityBlackList.add("grass");
herbalismAbilityBlackList.add("grass_path");
herbalismAbilityBlackList.add("farmland");
}
private void fillLeavesWhiteList()
{
private void fillLeavesWhiteList() {
leavesWhiteList.add("oak_leaves");
leavesWhiteList.add("acacia_leaves");
leavesWhiteList.add("birch_leaves");
@@ -110,8 +96,7 @@ public class MaterialMapStore {
leavesWhiteList.add("spruce_leaves");
}
private void fillMossyWhiteList()
{
private void fillMossyWhiteList() {
mossyWhiteList.add("cobblestone");
mossyWhiteList.add("dirt");
mossyWhiteList.add("grass_path");
@@ -119,8 +104,7 @@ public class MaterialMapStore {
mossyWhiteList.add("cobblestone_wall");
}
private void fillAbilityBlackList()
{
private void fillAbilityBlackList() {
abilityBlackList.add("black_bed");
abilityBlackList.add("blue_bed");
abilityBlackList.add("brown_bed");
@@ -219,9 +203,8 @@ public class MaterialMapStore {
abilityBlackList.add("wall_sign"); //1.13 and lower?
abilityBlackList.add("sign"); //1.13 and lower?
}
private void filltoolBlackList()
{
private void filltoolBlackList() {
//TODO: Add anvils / missing logs
toolBlackList.add("black_bed");
toolBlackList.add("blue_bed");
@@ -344,8 +327,7 @@ public class MaterialMapStore {
toolBlackList.add("spruce_wood");
}
private void addToHashSet(String string, HashSet<String> stringHashSet)
{
private void addToHashSet(String string, HashSet<String> stringHashSet) {
stringHashSet.add(string.toLowerCase());
}
}

View File

@@ -3,7 +3,8 @@ package com.gmail.nossr50.util;
import org.bukkit.Material;
public final class MaterialUtils {
private MaterialUtils() {}
private MaterialUtils() {
}
protected static boolean isOre(Material data) {
switch (data) {

View File

@@ -16,13 +16,11 @@ import java.util.Random;
import java.util.Set;
public final class Misc {
private static Random random = new Random();
public static final int TIME_CONVERSION_FACTOR = 1000;
public static final int TICK_CONVERSION_FACTOR = 20;
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
public static final Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION");
// Sound Pitches & Volumes from CB
/* public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
@@ -34,10 +32,10 @@ public final class Misc {
public static final float GHAST_VOLUME = 1.0F * MainConfig.getInstance().getMasterVolume();
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
public static final float LEVELUP_VOLUME = 0.75F * MainConfig.getInstance().getMasterVolume(); // Use max volume always*/
private static Random random = new Random();
public static final Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION");
private Misc() {}
private Misc() {
}
public static boolean isNPCEntity(Entity entity) {
return (entity == null
@@ -49,8 +47,8 @@ public final class Misc {
/**
* Determine if two locations are near each other.
*
* @param first The first location
* @param second The second location
* @param first The first location
* @param second The second location
* @param maxDistance The max distance apart
* @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise
*/
@@ -60,7 +58,7 @@ public final class Misc {
/**
* Get the center of the given block.
*
*
* @param blockState The {@link BlockState} of the block
* @return A {@link Location} lying at the center of the block
*/
@@ -78,7 +76,7 @@ public final class Misc {
* Drop items at a given location.
*
* @param location The location to drop the items at
* @param is The items to drop
* @param is The items to drop
* @param quantity The amount of items to drop
*/
public static void dropItems(Location location, ItemStack is, int quantity) {
@@ -90,7 +88,7 @@ public final class Misc {
/**
* Drop an item at a given location.
*
* @param location The location to drop the item at
* @param location The location to drop the item at
* @param itemStack The item to drop
* @return Dropped Item entity or null if invalid or cancelled
*/

View File

@@ -12,13 +12,14 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.metadata.FixedMetadataValue;
public final class MobHealthbarUtils {
private MobHealthbarUtils() {}
private MobHealthbarUtils() {
}
/**
* Fix issues with death messages caused by the mob healthbars.
*
* @param deathMessage The original death message
* @param player The player who died
* @param player The player who died
* @return the fixed death message
*/
public static String fixDeathMessage(String deathMessage, Player player) {
@@ -30,7 +31,8 @@ public final class MobHealthbarUtils {
/**
* Handle the creation of mob healthbars.
* @param target the targetted entity
*
* @param target the targetted entity
* @param damage damage done by the attack triggering this
*/
public static void handleMobHealthbars(LivingEntity target, double damage, mcMMO plugin) {
@@ -48,7 +50,7 @@ public final class MobHealthbarUtils {
/*
* Store the name in metadata
*/
if(target.getMetadata("mcMMO_oldName").size() <= 0 && originalName != null)
if (target.getMetadata("mcMMO_oldName").size() <= 0 && originalName != null)
target.setMetadata("mcMMO_oldName", new OldName(originalName, plugin));
if (oldName == null) {
@@ -69,8 +71,7 @@ public final class MobHealthbarUtils {
if (updateName) {
target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, oldName));
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, oldNameVisible));
}
else if (!target.hasMetadata(mcMMO.customNameKey)) {
} else if (!target.hasMetadata(mcMMO.customNameKey)) {
target.setMetadata(mcMMO.customNameKey, new FixedMetadataValue(mcMMO.p, ""));
target.setMetadata(mcMMO.customVisibleKey, new FixedMetadataValue(mcMMO.p, false));
}
@@ -100,20 +101,15 @@ public final class MobHealthbarUtils {
if (healthPercentage >= 85) {
color = ChatColor.DARK_GREEN;
}
else if (healthPercentage >= 70) {
} else if (healthPercentage >= 70) {
color = ChatColor.GREEN;
}
else if (healthPercentage >= 55) {
} else if (healthPercentage >= 55) {
color = ChatColor.GOLD;
}
else if (healthPercentage >= 40) {
} else if (healthPercentage >= 40) {
color = ChatColor.YELLOW;
}
else if (healthPercentage >= 25) {
} else if (healthPercentage >= 25) {
color = ChatColor.RED;
}
else if (healthPercentage >= 0) {
} else if (healthPercentage >= 0) {
color = ChatColor.DARK_RED;
}

View File

@@ -14,7 +14,8 @@ public final class Motd {
public static final String PERK_PREFIX = LocaleLoader.getString("MOTD.PerksPrefix") + " ";
private static final PluginDescriptionFile pluginDescription = mcMMO.p.getDescription();
private Motd() {}
private Motd() {
}
public static void displayAll(Player player) {
displayVersion(player, pluginDescription.getVersion());

View File

@@ -17,86 +17,217 @@ import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager;
public final class Permissions {
private Permissions() {}
private Permissions() {
}
/*
* GENERAL
*/
public static boolean motd(Permissible permissible) { return permissible.hasPermission("mcmmo.motd"); }
public static boolean mobHealthDisplay(Permissible permissible) { return permissible.hasPermission("mcmmo.mobhealthdisplay"); }
public static boolean updateNotifications(Permissible permissible) {return permissible.hasPermission("mcmmo.tools.updatecheck"); }
public static boolean chimaeraWing(Permissible permissible) { return permissible.hasPermission("mcmmo.item.chimaerawing"); }
public static boolean showversion(Permissible permissible) { return permissible.hasPermission("mcmmo.showversion"); }
public static boolean motd(Permissible permissible) {
return permissible.hasPermission("mcmmo.motd");
}
public static boolean mobHealthDisplay(Permissible permissible) {
return permissible.hasPermission("mcmmo.mobhealthdisplay");
}
public static boolean updateNotifications(Permissible permissible) {
return permissible.hasPermission("mcmmo.tools.updatecheck");
}
public static boolean chimaeraWing(Permissible permissible) {
return permissible.hasPermission("mcmmo.item.chimaerawing");
}
public static boolean showversion(Permissible permissible) {
return permissible.hasPermission("mcmmo.showversion");
}
/* BYPASS */
public static boolean hardcoreBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.hardcoremode"); }
public static boolean arcaneBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.arcanebypass"); }
public static boolean trapsBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.fishingtraps"); }
public static boolean hardcoreBypass(Permissible permissible) {
return permissible.hasPermission("mcmmo.bypass.hardcoremode");
}
public static boolean arcaneBypass(Permissible permissible) {
return permissible.hasPermission("mcmmo.bypass.arcanebypass");
}
public static boolean trapsBypass(Permissible permissible) {
return permissible.hasPermission("mcmmo.bypass.fishingtraps");
}
/* CHAT */
public static boolean partyChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.partychat"); }
public static boolean adminChat(Permissible permissible) { return permissible.hasPermission("mcmmo.chat.adminchat"); }
public static boolean partyChat(Permissible permissible) {
return permissible.hasPermission("mcmmo.chat.partychat");
}
public static boolean adminChat(Permissible permissible) {
return permissible.hasPermission("mcmmo.chat.adminchat");
}
/*
* COMMANDS
*/
public static boolean mmoinfo(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoinfo"); }
public static boolean addlevels(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.addlevels"); }
public static boolean addlevelsOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.addlevels.others"); }
public static boolean mmoinfo(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoinfo");
}
public static boolean addxp(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.addxp"); }
public static boolean addxpOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.addxp.others"); }
public static boolean addlevels(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.addlevels");
}
public static boolean hardcoreModify(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.hardcore.modify"); }
public static boolean hardcoreToggle(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.hardcore.toggle"); }
public static boolean addlevelsOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.addlevels.others");
}
public static boolean inspect(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect")); }
public static boolean inspectFar(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.far")); }
public static boolean inspectHidden(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.hidden")); }
public static boolean inspectOffline(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.inspect.offline")); }
public static boolean addxp(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.addxp");
}
public static boolean mcability(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability")); }
public static boolean mcabilityOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcability.others")); }
public static boolean addxpOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.addxp.others");
}
public static boolean adminChatSpy(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcchatspy");}
public static boolean adminChatSpyOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcchatspy.others");}
public static boolean hardcoreModify(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.hardcore.modify");
}
public static boolean mcgod(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcgod"); }
public static boolean mcgodOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcgod.others"); }
public static boolean hardcoreToggle(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.hardcore.toggle");
}
public static boolean mcmmoDescription(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcmmo.description"); }
public static boolean mcmmoHelp(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcmmo.help"); }
public static boolean inspect(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.inspect"));
}
public static boolean mcrank(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcrank")); }
public static boolean mcrankOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcrank.others")); }
public static boolean mcrankFar(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcrank.others.far")); }
public static boolean mcrankOffline(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcrank.others.offline")); }
public static boolean inspectFar(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.inspect.far"));
}
public static boolean mcrefresh(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcrefresh")); }
public static boolean mcrefreshOthers(Permissible permissible) { return (permissible.hasPermission("mcmmo.commands.mcrefresh.others")); }
public static boolean inspectHidden(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.inspect.hidden"));
}
public static boolean mctop(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.commands.mctop." + skill.toString().toLowerCase()); }
public static boolean inspectOffline(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.inspect.offline"));
}
public static boolean mmoedit(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoedit"); }
public static boolean mmoeditOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoedit.others"); }
public static boolean mcability(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcability"));
}
public static boolean skillreset(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.skillreset"); }
public static boolean skillreset(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.commands.skillreset." + skill.toString().toLowerCase()); }
public static boolean skillresetOthers(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.skillreset.others"); }
public static boolean skillresetOthers(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.commands.skillreset.others." + skill.toString().toLowerCase()); }
public static boolean mcabilityOthers(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcability.others"));
}
public static boolean xplock(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.commands.xplock." + skill.toString().toLowerCase()); }
public static boolean adminChatSpy(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcchatspy");
}
public static boolean xprateSet(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.xprate.set"); }
public static boolean xprateReset(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.xprate.reset"); }
public static boolean adminChatSpyOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcchatspy.others");
}
public static boolean vampirismModify(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.vampirism.modify"); }
public static boolean vampirismToggle(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.vampirism.toggle"); }
public static boolean mcgod(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcgod");
}
public static boolean mcpurge(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcpurge"); }
public static boolean mcremove(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mcremove"); }
public static boolean mmoupdate(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.mmoupdate"); }
public static boolean mcgodOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcgod.others");
}
public static boolean mcmmoDescription(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcmmo.description");
}
public static boolean mcmmoHelp(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcmmo.help");
}
public static boolean mcrank(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrank"));
}
public static boolean mcrankOthers(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrank.others"));
}
public static boolean mcrankFar(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrank.others.far"));
}
public static boolean mcrankOffline(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrank.others.offline"));
}
public static boolean mcrefresh(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrefresh"));
}
public static boolean mcrefreshOthers(Permissible permissible) {
return (permissible.hasPermission("mcmmo.commands.mcrefresh.others"));
}
public static boolean mctop(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.commands.mctop." + skill.toString().toLowerCase());
}
public static boolean mmoedit(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoedit");
}
public static boolean mmoeditOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoedit.others");
}
public static boolean skillreset(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.skillreset");
}
public static boolean skillreset(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.commands.skillreset." + skill.toString().toLowerCase());
}
public static boolean skillresetOthers(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.skillreset.others");
}
public static boolean skillresetOthers(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.commands.skillreset.others." + skill.toString().toLowerCase());
}
public static boolean xplock(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.commands.xplock." + skill.toString().toLowerCase());
}
public static boolean xprateSet(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.xprate.set");
}
public static boolean xprateReset(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.xprate.reset");
}
public static boolean vampirismModify(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.vampirism.modify");
}
public static boolean vampirismToggle(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.vampirism.toggle");
}
public static boolean mcpurge(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcpurge");
}
public static boolean mcremove(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mcremove");
}
public static boolean mmoupdate(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.mmoupdate");
}
/*
* PERKS
@@ -104,114 +235,270 @@ public final class Permissions {
/* BYPASS PERKS */
public static boolean hasRepairEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.repairenchant"); }
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant"); }
public static boolean hasRepairEnchantBypassPerk(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.bypass.repairenchant");
}
public static boolean lucky(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase()); }
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant");
}
public static boolean lucky(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase());
}
/* XP PERKS */
public static boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.quadruple." + skill.toString().toLowerCase()); }
public static boolean tripleXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.triple." + skill.toString().toLowerCase()); }
public static boolean doubleAndOneHalfXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.150percentboost." + skill.toString().toLowerCase()); }
public static boolean doubleXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.double." + skill.toString().toLowerCase()); }
public static boolean oneAndOneHalfXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.50percentboost." + skill.toString().toLowerCase()); }
public static boolean oneAndOneTenthXp(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.10percentboost." + skill.toString().toLowerCase()); }
public static boolean customXpBoost(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.xp.customboost." + skill.toString().toLowerCase()); }
public static boolean quadrupleXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.quadruple." + skill.toString().toLowerCase());
}
public static boolean tripleXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.triple." + skill.toString().toLowerCase());
}
public static boolean doubleAndOneHalfXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.150percentboost." + skill.toString().toLowerCase());
}
public static boolean doubleXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.double." + skill.toString().toLowerCase());
}
public static boolean oneAndOneHalfXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.50percentboost." + skill.toString().toLowerCase());
}
public static boolean oneAndOneTenthXp(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.10percentboost." + skill.toString().toLowerCase());
}
public static boolean customXpBoost(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.perks.xp.customboost." + skill.toString().toLowerCase());
}
/* ACTIVATION PERKS */
public static boolean twelveSecondActivationBoost(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.activationtime.twelveseconds"); }
public static boolean eightSecondActivationBoost(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.activationtime.eightseconds"); }
public static boolean fourSecondActivationBoost(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.activationtime.fourseconds"); }
public static boolean twelveSecondActivationBoost(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.activationtime.twelveseconds");
}
public static boolean eightSecondActivationBoost(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.activationtime.eightseconds");
}
public static boolean fourSecondActivationBoost(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.activationtime.fourseconds");
}
/* COOLDOWN PERKS */
public static boolean halvedCooldowns(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.cooldowns.halved"); }
public static boolean thirdedCooldowns(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.cooldowns.thirded"); }
public static boolean quarteredCooldowns(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.cooldowns.quartered"); }
public static boolean halvedCooldowns(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.cooldowns.halved");
}
public static boolean thirdedCooldowns(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.cooldowns.thirded");
}
public static boolean quarteredCooldowns(Permissible permissible) {
return permissible.hasPermission("mcmmo.perks.cooldowns.quartered");
}
/*
* SKILLS
*/
public static boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase()); }
public static boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".vanillaxpboost"); }
public static boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) { return permissible.hasPermission(subSkillType.getPermissionNodeAddress()); }
public static boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) { return permissible.hasPermission(abstractSubSkill.getPermissionNode()); }
public static boolean bonusDamage(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".bonusdamage"); }
public static boolean skillEnabled(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.skills." + skill.toString().toLowerCase());
}
public static boolean vanillaXpBoost(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".vanillaxpboost");
}
public static boolean isSubSkillEnabled(Permissible permissible, SubSkillType subSkillType) {
return permissible.hasPermission(subSkillType.getPermissionNodeAddress());
}
public static boolean isSubSkillEnabled(Permissible permissible, AbstractSubSkill abstractSubSkill) {
return permissible.hasPermission(abstractSubSkill.getPermissionNode());
}
public static boolean bonusDamage(Permissible permissible, PrimarySkillType skill) {
return permissible.hasPermission("mcmmo.ability." + skill.toString().toLowerCase() + ".bonusdamage");
}
/* ACROBATICS */
public static boolean dodge(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.acrobatics.dodge"); }
public static boolean gracefulRoll(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.acrobatics.gracefulroll"); }
public static boolean roll(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.acrobatics.roll"); }
public static boolean dodge(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.acrobatics.dodge");
}
public static boolean gracefulRoll(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.acrobatics.gracefulroll");
}
public static boolean roll(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.acrobatics.roll");
}
/* ALCHEMY */
public static boolean catalysis(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.alchemy.catalysis"); }
public static boolean concoctions(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.alchemy.concoctions"); }
public static boolean catalysis(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.alchemy.catalysis");
}
public static boolean concoctions(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.alchemy.concoctions");
}
/* ARCHERY */
public static boolean arrowRetrieval(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.archery.trackarrows"); }
public static boolean daze(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.archery.daze"); }
public static boolean arrowRetrieval(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.archery.trackarrows");
}
public static boolean daze(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.archery.daze");
}
/* AXES */
public static boolean skullSplitter(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.axes.skullsplitter"); }
public static boolean skullSplitter(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.axes.skullsplitter");
}
/* EXCAVATION */
public static boolean gigaDrillBreaker(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.excavation.gigadrillbreaker"); }
public static boolean gigaDrillBreaker(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.excavation.gigadrillbreaker");
}
/* HERBALISM */
public static boolean greenTerra(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.herbalism.greenterra"); }
public static boolean greenThumbBlock(Permissible permissible, Material material) { return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.blocks." + material.toString().replace("_", "").toLowerCase()); }
public static boolean greenThumbPlant(Permissible permissible, Material material) { return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.plants." + material.toString().replace("_", "").toLowerCase()); }
public static boolean greenTerra(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.herbalism.greenterra");
}
public static boolean greenThumbBlock(Permissible permissible, Material material) {
return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.blocks." + material.toString().replace("_", "").toLowerCase());
}
public static boolean greenThumbPlant(Permissible permissible, Material material) {
return permissible.hasPermission("mcmmo.ability.herbalism.greenthumb.plants." + material.toString().replace("_", "").toLowerCase());
}
/* MINING */
public static boolean biggerBombs(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs"); }
public static boolean demolitionsExpertise(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.mining.blastmining.demolitionsexpertise"); }
public static boolean remoteDetonation(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.mining.blastmining.detonate"); }
public static boolean superBreaker(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.mining.superbreaker"); }
public static boolean biggerBombs(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.biggerbombs");
}
public static boolean demolitionsExpertise(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.demolitionsexpertise");
}
public static boolean remoteDetonation(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.blastmining.detonate");
}
public static boolean superBreaker(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.mining.superbreaker");
}
/* REPAIR */
public static boolean repairItemType(Permissible permissible, ItemType repairItemType) { return permissible.hasPermission("mcmmo.ability.repair." + repairItemType.toString().toLowerCase() + "repair"); }
public static boolean repairMaterialType(Permissible permissible, ItemMaterialCategory repairItemMaterialCategory) { return permissible.hasPermission("mcmmo.ability.repair." + repairItemMaterialCategory.toString().toLowerCase() + "repair"); }
public static boolean repairItemType(Permissible permissible, ItemType repairItemType) {
return permissible.hasPermission("mcmmo.ability.repair." + repairItemType.toString().toLowerCase() + "repair");
}
public static boolean repairMaterialType(Permissible permissible, ItemMaterialCategory repairItemMaterialCategory) {
return permissible.hasPermission("mcmmo.ability.repair." + repairItemMaterialCategory.toString().toLowerCase() + "repair");
}
/* SALVAGE */
public static boolean advancedSalvage(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.salvage.advancedsalvage"); }
public static boolean arcaneSalvage(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.salvage.arcanesalvage"); }
public static boolean advancedSalvage(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.salvage.advancedsalvage");
}
public static boolean salvageItemType(Permissible permissible, ItemType salvageItemType) { return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemType.toString().toLowerCase() + "salvage"); }
public static boolean salvageMaterialType(Permissible permissible, ItemMaterialCategory salvageItemMaterialCategory) { return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemMaterialCategory.toString().toLowerCase() + "salvage"); }
public static boolean arcaneSalvage(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.salvage.arcanesalvage");
}
public static boolean salvageItemType(Permissible permissible, ItemType salvageItemType) {
return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemType.toString().toLowerCase() + "salvage");
}
public static boolean salvageMaterialType(Permissible permissible, ItemMaterialCategory salvageItemMaterialCategory) {
return permissible.hasPermission("mcmmo.ability.salvage." + salvageItemMaterialCategory.toString().toLowerCase() + "salvage");
}
/* SMELTING */
public static boolean fluxMining(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.smelting.fluxmining"); }
public static boolean fuelEfficiency(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.smelting.fuelefficiency"); }
public static boolean fluxMining(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.smelting.fluxmining");
}
public static boolean fuelEfficiency(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.smelting.fuelefficiency");
}
/* SWORDS */
public static boolean serratedStrikes(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.swords.serratedstrikes"); }
public static boolean serratedStrikes(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.swords.serratedstrikes");
}
/* TAMING */
public static boolean callOfTheWild(Permissible permissible, EntityType type) { return permissible.hasPermission("mcmmo.ability.taming.callofthewild." + type.toString().toLowerCase()); }
public static boolean renamePets(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.taming.callofthewild.renamepets"); }
public static boolean callOfTheWild(Permissible permissible, EntityType type) {
return permissible.hasPermission("mcmmo.ability.taming.callofthewild." + type.toString().toLowerCase());
}
public static boolean renamePets(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.taming.callofthewild.renamepets");
}
/* UNARMED */
public static boolean berserk(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.unarmed.berserk"); }
public static boolean berserk(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.unarmed.berserk");
}
/* WOODCUTTING */
public static boolean treeFeller(Permissible permissible) { return permissible.hasPermission("mcmmo.ability.woodcutting.treefeller"); }
public static boolean treeFeller(Permissible permissible) {
return permissible.hasPermission("mcmmo.ability.woodcutting.treefeller");
}
/*
* PARTY
*/
public static boolean partySizeBypass(Permissible permissible) { return permissible.hasPermission("mcmmo.bypass.partylimit" ); }
public static boolean party(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.party"); }
public static boolean partySubcommand(Permissible permissible, PartySubcommandType subcommand) { return permissible.hasPermission("mcmmo.commands.party." + subcommand.toString().toLowerCase()); }
public static boolean friendlyFire(Permissible permissible) { return permissible.hasPermission("mcmmo.party.friendlyfire"); }
public static boolean partySizeBypass(Permissible permissible) {
return permissible.hasPermission("mcmmo.bypass.partylimit");
}
public static boolean party(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.party");
}
public static boolean partySubcommand(Permissible permissible, PartySubcommandType subcommand) {
return permissible.hasPermission("mcmmo.commands.party." + subcommand.toString().toLowerCase());
}
public static boolean friendlyFire(Permissible permissible) {
return permissible.hasPermission("mcmmo.party.friendlyfire");
}
/* TELEPORT */
public static boolean partyTeleportSend(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.send"); }
public static boolean partyTeleportAccept(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.accept"); }
public static boolean partyTeleportAcceptAll(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.acceptall"); }
public static boolean partyTeleportToggle(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.toggle"); }
public static boolean partyTeleportSend(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.send");
}
public static boolean partyTeleportAllWorlds(Permissible permissible) { return permissible.hasPermission("mcmmo.commands.ptp.world.all"); }
public static boolean partyTeleportWorld(Permissible permissible, World world) { return permissible.hasPermission("mcmmo.commands.ptp.world." + world.getName()); }
public static boolean partyTeleportAccept(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.accept");
}
public static boolean partyTeleportAcceptAll(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.acceptall");
}
public static boolean partyTeleportToggle(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.toggle");
}
public static boolean partyTeleportAllWorlds(Permissible permissible) {
return permissible.hasPermission("mcmmo.commands.ptp.world.all");
}
public static boolean partyTeleportWorld(Permissible permissible, World world) {
return permissible.hasPermission("mcmmo.commands.ptp.world." + world.getName());
}
public static void generateWorldTeleportPermissions() {
Server server = mcMMO.p.getServer();

View File

@@ -12,8 +12,7 @@ public class StringUtils {
/**
* Gets a capitalized version of the target string.
*
* @param target
* String to capitalize
* @param target String to capitalize
* @return the capitalized string
*/
public static String getCapitalized(String target) {
@@ -22,11 +21,11 @@ public class StringUtils {
/**
* Gets the name of the entity that the config file is expecting
*
* @param entityType target entity type
* @return the config friendly entity type string
*/
public static String getEntityConfigName(EntityType entityType)
{
public static String getEntityConfigName(EntityType entityType) {
return getCapitalized(entityType.toString());
}
@@ -41,7 +40,7 @@ public class StringUtils {
public static String getPrettyAbilityString(SuperAbilityType ability) {
return createPrettyString(ability.toString());
}
public static String getWildcardConfigBlockDataString(BlockData data) {
return getWildcardConfigMaterialString(data.getMaterial());
}
@@ -51,7 +50,7 @@ public class StringUtils {
}
public static String getFriendlyConfigBlockDataString(BlockData data) {
switch(data.getMaterial()){
switch (data.getMaterial()) {
case CHORUS_FLOWER:
case COCOA:
case WHEAT:
@@ -108,8 +107,7 @@ public class StringUtils {
/**
* Determine if a string represents an Integer
*
* @param string
* String to check
* @param string String to check
* @return true if the string is an Integer, false otherwise
*/
public static boolean isInt(String string) {
@@ -124,8 +122,7 @@ public class StringUtils {
/**
* Determine if a string represents a Double
*
* @param string
* String to check
* @param string String to check
* @return true if the string is a Double, false otherwise
*/
public static boolean isDouble(String string) {

View File

@@ -26,38 +26,34 @@ public class TextComponentFactory {
/**
* Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleLoader
* @param localeKey target locale string address
*
* @param localeKey target locale string address
* @param notificationType type of notification
* @param values vars to be passed to the locale loader
* @param values vars to be passed to the locale loader
* @return
*/
public static TextComponent getNotificationMultipleValues(String localeKey, NotificationType notificationType, String... values)
{
public static TextComponent getNotificationMultipleValues(String localeKey, NotificationType notificationType, String... values) {
String preColoredString = LocaleLoader.getString(localeKey, (Object[]) values);
TextComponent msg = new TextComponent(preColoredString);
return new TextComponent(msg);
}
public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType)
{
public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType) {
return getNotificationTextComponent(LocaleLoader.getString(localeKey));
}
public static TextComponent getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel)
{
TextComponent textComponent = new TextComponent(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name."+StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
public static TextComponent getNotificationLevelUpTextComponent(PrimarySkillType skill, int levelsGained, int currentLevel) {
TextComponent textComponent = new TextComponent(LocaleLoader.getString("Overhaul.Levelup", LocaleLoader.getString("Overhaul.Name." + StringUtils.getCapitalized(skill.toString())), levelsGained, currentLevel));
return textComponent;
}
private static TextComponent getNotificationTextComponent(String text)
{
private static TextComponent getNotificationTextComponent(String text) {
//textComponent.setColor(getNotificationColor(notificationType));
return new TextComponent(text);
}
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted)
{
if(!mcMMO.getConfigManager().getConfigAds().isShowWebsiteLinks())
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) {
if (!mcMMO.getConfigManager().getConfigAds().isShowWebsiteLinks())
return;
Player.Spigot spigotPlayer = player.spigot();
@@ -65,7 +61,7 @@ public class TextComponentFactory {
TextComponent wikiLinkComponent = new TextComponent(LocaleLoader.getString("Overhaul.mcMMO.MmoInfo.Wiki"));
wikiLinkComponent.setUnderlined(true);
String wikiUrl = "https://mcmmo.org/wiki/"+subskillformatted;
String wikiUrl = "https://mcmmo.org/wiki/" + subskillformatted;
wikiLinkComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, wikiUrl));
@@ -81,13 +77,12 @@ public class TextComponentFactory {
TextComponent prefix = new TextComponent(LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Prefix") + " ");
/*prefix.setColor(ChatColor.DARK_AQUA);*/
TextComponent suffix = new TextComponent(" "+LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix"));
TextComponent suffix = new TextComponent(" " + LocaleLoader.getString("Overhaul.mcMMO.Url.Wrap.Suffix"));
/*suffix.setColor(ChatColor.DARK_AQUA);*/
TextComponent emptySpace = new TextComponent(" ");
if(mcMMO.getConfigManager().getConfigAds().isShowPatreonInfo())
{
if (mcMMO.getConfigManager().getConfigAds().isShowPatreonInfo()) {
BaseComponent[] baseComponents = {new TextComponent(prefix),
getWebLinkTextComponent(McMMOWebLinks.WEBSITE),
emptySpace,
@@ -120,8 +115,7 @@ public class TextComponentFactory {
}
}
public static void sendPlayerSubSkillList(Player player, List<TextComponent> textComponents)
{
public static void sendPlayerSubSkillList(Player player, List<TextComponent> textComponents) {
TextComponent emptySpace = new TextComponent(" ");
ArrayList<BaseComponent> bulkMessage = new ArrayList<>();
@@ -129,8 +123,7 @@ public class TextComponentFactory {
for (TextComponent textComponent : textComponents) {
//Don't send more than 3 subskills per line to avoid MOST wordwrap problems
if(newLineCount > 2)
{
if (newLineCount > 2) {
TextComponent[] bulkArray = new TextComponent[bulkMessage.size()];
bulkArray = bulkMessage.toArray(bulkArray);
@@ -144,10 +137,10 @@ public class TextComponentFactory {
TextComponent stylizedText = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolSkills"));
addChild(stylizedText, originalTxt);
if(textComponent.getHoverEvent() != null)
if (textComponent.getHoverEvent() != null)
stylizedText.setHoverEvent(textComponent.getHoverEvent());
if(textComponent.getClickEvent() != null)
if (textComponent.getClickEvent() != null)
stylizedText.setClickEvent(textComponent.getClickEvent());
bulkMessage.add(stylizedText);
@@ -165,12 +158,10 @@ public class TextComponentFactory {
player.spigot().sendMessage(bulkArray);
}
private static TextComponent getWebLinkTextComponent(McMMOWebLinks webLinks)
{
private static TextComponent getWebLinkTextComponent(McMMOWebLinks webLinks) {
TextComponent webTextComponent;
switch(webLinks)
{
switch (webLinks) {
case WEBSITE:
webTextComponent = new TextComponent(LocaleLoader.getString("JSON.Hover.AtSymbolURL"));
addChild(webTextComponent, "Web");
@@ -217,12 +208,10 @@ public class TextComponentFactory {
webTextComponent.addExtra(childComponent);
}
private static BaseComponent[] getUrlHoverEvent(McMMOWebLinks webLinks)
{
private static BaseComponent[] getUrlHoverEvent(McMMOWebLinks webLinks) {
ComponentBuilder componentBuilder = new ComponentBuilder(webLinks.getNiceTitle());
switch(webLinks)
{
switch (webLinks) {
case WEBSITE:
addUrlHeaderHover(webLinks, componentBuilder);
componentBuilder.append("\n\n").italic(false);
@@ -271,13 +260,11 @@ public class TextComponentFactory {
componentBuilder.append(webLinks.getUrl()).color(ChatColor.GRAY).italic(true);
}
private static ClickEvent getUrlClickEvent(String url)
{
private static ClickEvent getUrlClickEvent(String url) {
return new ClickEvent(ClickEvent.Action.OPEN_URL, url);
}
private static TextComponent getSubSkillTextComponent(Player player, SubSkillType subSkillType)
{
private static TextComponent getSubSkillTextComponent(Player player, SubSkillType subSkillType) {
//Get skill name
String skillName = subSkillType.getLocaleName();
@@ -298,8 +285,7 @@ public class TextComponentFactory {
textComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, baseComponent));
}
private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill)
{
private static TextComponent getSubSkillTextComponent(Player player, AbstractSubSkill abstractSubSkill) {
//String key = abstractSubSkill.getConfigKeyName();
String skillName = abstractSubSkill.getNiceName();
@@ -338,47 +324,44 @@ public class TextComponentFactory {
return textComponent;
}
private static BaseComponent[] getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill)
{
private static BaseComponent[] getSubSkillHoverComponent(Player player, AbstractSubSkill abstractSubSkill) {
return getSubSkillHoverEventJSON(abstractSubSkill, player);
}
private static BaseComponent[] getSubSkillHoverComponent(Player player, SubSkillType subSkillType)
{
private static BaseComponent[] getSubSkillHoverComponent(Player player, SubSkillType subSkillType) {
return getSubSkillHoverEventJSON(subSkillType, player);
}
/**
* Used for the skill in the new skill system (Deriving from AbstractSubSkill)
*
* @param abstractSubSkill this subskill
* @param player the player who owns this subskill
* @param player the player who owns this subskill
* @return the hover basecomponent object for this subskill
*/
private static BaseComponent[] getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player)
{
private static BaseComponent[] getSubSkillHoverEventJSON(AbstractSubSkill abstractSubSkill, Player player) {
String skillName = abstractSubSkill.getNiceName();
/*
* Hover Event BaseComponent color table
*/
ChatColor ccSubSkillHeader = ChatColor.GOLD;
ChatColor ccRank = ChatColor.BLUE;
ChatColor ccCurRank = ChatColor.GREEN;
ChatColor ccPossessive = ChatColor.WHITE;
ChatColor ccNumRanks = ccCurRank;
ChatColor ccSubSkillHeader = ChatColor.GOLD;
ChatColor ccRank = ChatColor.BLUE;
ChatColor ccCurRank = ChatColor.GREEN;
ChatColor ccPossessive = ChatColor.WHITE;
ChatColor ccNumRanks = ccCurRank;
//ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE;
//ChatColor ccDescription = ChatColor.WHITE;
ChatColor ccLocked = ChatColor.DARK_GRAY;
ChatColor ccLevelRequirement = ChatColor.BLUE;
ChatColor ccLevelRequired = ChatColor.RED;
ChatColor ccLocked = ChatColor.DARK_GRAY;
ChatColor ccLevelRequirement = ChatColor.BLUE;
ChatColor ccLevelRequired = ChatColor.RED;
SubSkillType subSkillType = abstractSubSkill.getSubSkillType();
//SubSkillType Name
ComponentBuilder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, abstractSubSkill));
if(!RankUtils.hasUnlockedSubskill(player, abstractSubSkill))
{
if (!RankUtils.hasUnlockedSubskill(player, abstractSubSkill)) {
//Skill is not unlocked yet
addLocked(abstractSubSkill, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
} else {
@@ -388,9 +371,8 @@ public class TextComponentFactory {
int curRank = RankUtils.getRank(player, abstractSubSkill);
int nextRank = 0;
if(curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0)
{
nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank+1);
if (curRank < abstractSubSkill.getNumRanks() && abstractSubSkill.getNumRanks() > 0) {
nextRank = RankUtils.getRankUnlockLevel(abstractSubSkill, curRank + 1);
}
addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, abstractSubSkill.getNumRanks(), RankUtils.getRank(player, abstractSubSkill), nextRank);
@@ -435,7 +417,7 @@ public class TextComponentFactory {
.bold(false).italic(false).strikethrough(false).underlined(false);
//Next Rank: x
if(nextRank > rank)
if (nextRank > rank)
componentBuilder.append(LocaleLoader.getString("JSON.Hover.NextRank", String.valueOf(nextRank))).append("\n")
.bold(false).italic(false).strikethrough(false).underlined(false);
@@ -463,43 +445,39 @@ public class TextComponentFactory {
}
@Deprecated
private static BaseComponent[] getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player)
{
private static BaseComponent[] getSubSkillHoverEventJSON(SubSkillType subSkillType, Player player) {
String skillName = subSkillType.getLocaleName();
/*
* Hover Event BaseComponent color table
*/
ChatColor ccSubSkillHeader = ChatColor.GOLD;
ChatColor ccRank = ChatColor.BLUE;
ChatColor ccCurRank = ChatColor.GREEN;
ChatColor ccPossessive = ChatColor.WHITE;
ChatColor ccNumRanks = ccCurRank;
ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE;
ChatColor ccDescription = ChatColor.DARK_GRAY;
ChatColor ccLocked = ChatColor.DARK_GRAY;
ChatColor ccLevelRequirement = ChatColor.BLUE;
ChatColor ccLevelRequired = ChatColor.RED;
ChatColor ccSubSkillHeader = ChatColor.GOLD;
ChatColor ccRank = ChatColor.BLUE;
ChatColor ccCurRank = ChatColor.GREEN;
ChatColor ccPossessive = ChatColor.WHITE;
ChatColor ccNumRanks = ccCurRank;
ChatColor ccDescriptionHeader = ChatColor.DARK_PURPLE;
ChatColor ccDescription = ChatColor.DARK_GRAY;
ChatColor ccLocked = ChatColor.DARK_GRAY;
ChatColor ccLevelRequirement = ChatColor.BLUE;
ChatColor ccLevelRequired = ChatColor.RED;
//SubSkillType Name
ComponentBuilder componentBuilder = setupSkillComponentNameStyle(player, skillName, subSkillType, RankUtils.hasUnlockedSubskill(player, subSkillType));
if(!RankUtils.hasUnlockedSubskill(player, subSkillType))
{
if (!RankUtils.hasUnlockedSubskill(player, subSkillType)) {
//Skill is not unlocked yet
addLocked(subSkillType, ccLocked, ccLevelRequirement, ccLevelRequired, componentBuilder);
} else {
//addSubSkillTypeToHoverEventJSON(subSkillType, componentBuilder);
//RANK
if(subSkillType.getNumRanks() > 0)
{
if (subSkillType.getNumRanks() > 0) {
int curRank = RankUtils.getRank(player, subSkillType);
int nextRank = 0;
if(curRank < subSkillType.getNumRanks() && subSkillType.getNumRanks() > 0)
{
nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank+1);
if (curRank < subSkillType.getNumRanks() && subSkillType.getNumRanks() > 0) {
nextRank = RankUtils.getRankUnlockLevel(subSkillType, curRank + 1);
}
addRanked(ccRank, ccCurRank, ccPossessive, ccNumRanks, componentBuilder, subSkillType.getNumRanks(), RankUtils.getRank(player, subSkillType), nextRank);
@@ -517,14 +495,11 @@ public class TextComponentFactory {
return componentBuilder.create();
}
private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill, ComponentBuilder componentBuilder)
{
if(abstractSubSkill.isSuperAbility())
{
private static void addSubSkillTypeToHoverEventJSON(AbstractSubSkill abstractSubSkill, ComponentBuilder componentBuilder) {
if (abstractSubSkill.isSuperAbility()) {
componentBuilder.append(LocaleLoader.getString("JSON.Type.SuperAbility")).color(ChatColor.LIGHT_PURPLE);
componentBuilder.bold(true);
} else if(abstractSubSkill.isActiveUse())
{
} else if (abstractSubSkill.isActiveUse()) {
componentBuilder.append(LocaleLoader.getString("JSON.Type.Active")).color(ChatColor.DARK_RED);
componentBuilder.bold(true);
} else {
@@ -536,35 +511,29 @@ public class TextComponentFactory {
}
public static void getSubSkillTextComponents(Player player, List<TextComponent> textComponents, PrimarySkillType parentSkill) {
for(SubSkillType subSkillType : SubSkillType.values())
{
if(subSkillType.getParentSkill() == parentSkill)
{
if(Permissions.isSubSkillEnabled(player, subSkillType))
{
if(!InteractionManager.hasSubSkill(subSkillType))
for (SubSkillType subSkillType : SubSkillType.values()) {
if (subSkillType.getParentSkill() == parentSkill) {
if (Permissions.isSubSkillEnabled(player, subSkillType)) {
if (!InteractionManager.hasSubSkill(subSkillType))
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, subSkillType));
}
}
}
/* NEW SKILL SYSTEM */
for(AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList())
{
if(abstractSubSkill.getPrimarySkill() == parentSkill)
{
if(Permissions.isSubSkillEnabled(player, abstractSubSkill))
for (AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList()) {
if (abstractSubSkill.getPrimarySkill() == parentSkill) {
if (Permissions.isSubSkillEnabled(player, abstractSubSkill))
textComponents.add(TextComponentFactory.getSubSkillTextComponent(player, abstractSubSkill));
}
}
}
public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType)
{
public static TextComponent getSubSkillUnlockedNotificationComponents(Player player, SubSkillType subSkillType) {
TextComponent unlockMessage = new TextComponent("");
unlockMessage.setText(LocaleLoader.getString("JSON.SkillUnlockMessage", subSkillType.getLocaleName(), RankUtils.getRank(player, subSkillType)));
unlockMessage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, getSubSkillHoverComponent(player, subSkillType)));
unlockMessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/"+subSkillType.getParentSkill().toString().toLowerCase()));
unlockMessage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + subSkillType.getParentSkill().toString().toLowerCase()));
return unlockMessage;
}
}

View File

@@ -7,7 +7,7 @@ import java.util.*;
public class BiomeAdapter {
public static final Set<Biome> WATER_BIOMES;
public static final Set<Biome> ICE_BIOMES;
static {
List<Biome> allBiomes = Arrays.asList(Biome.values());
List<Biome> waterBiomes = new ArrayList<>();
@@ -26,6 +26,7 @@ public class BiomeAdapter {
private static boolean isWater(String name) {
return name.contains("RIVER") || name.contains("OCEAN");
}
private static boolean isCold(String name) {
return (name.contains("COLD") || name.contains("ICE") || name.contains("FROZEN") || name.contains("TAIGA")) && !(name.contains("WARM"));
}

View File

@@ -7,9 +7,9 @@ public interface ChunkletManager {
/**
* Loads a specific chunklet
*
* @param cx Chunklet X coordinate that needs to be loaded
* @param cy Chunklet Y coordinate that needs to be loaded
* @param cz Chunklet Z coordinate that needs to be loaded
* @param cx Chunklet X coordinate that needs to be loaded
* @param cy Chunklet Y coordinate that needs to be loaded
* @param cz Chunklet Z coordinate that needs to be loaded
* @param world World that the chunklet needs to be loaded in
*/
void loadChunklet(int cx, int cy, int cz, World world);
@@ -17,9 +17,9 @@ public interface ChunkletManager {
/**
* Unload a specific chunklet
*
* @param cx Chunklet X coordinate that needs to be unloaded
* @param cy Chunklet Y coordinate that needs to be unloaded
* @param cz Chunklet Z coordinate that needs to be unloaded
* @param cx Chunklet X coordinate that needs to be unloaded
* @param cy Chunklet Y coordinate that needs to be unloaded
* @param cz Chunklet Z coordinate that needs to be unloaded
* @param world World that the chunklet needs to be unloaded from
*/
void unloadChunklet(int cx, int cy, int cz, World world);
@@ -27,8 +27,8 @@ public interface ChunkletManager {
/**
* Load a given Chunk's Chunklet data
*
* @param cx Chunk X coordinate that is to be loaded
* @param cz Chunk Z coordinate that is to be loaded
* @param cx Chunk X coordinate that is to be loaded
* @param cz Chunk Z coordinate that is to be loaded
* @param world World that the Chunk is in
*/
void loadChunk(int cx, int cz, World world);
@@ -36,8 +36,8 @@ public interface ChunkletManager {
/**
* Unload a given Chunk's Chunklet data
*
* @param cx Chunk X coordinate that is to be unloaded
* @param cz Chunk Z coordinate that is to be unloaded
* @param cx Chunk X coordinate that is to be unloaded
* @param cz Chunk Z coordinate that is to be unloaded
* @param world World that the Chunk is in
*/
void unloadChunk(int cx, int cz, World world);
@@ -45,8 +45,8 @@ public interface ChunkletManager {
/**
* Informs the ChunkletManager a chunk is loaded
*
* @param cx Chunk X coordinate that is loaded
* @param cz Chunk Z coordinate that is loaded
* @param cx Chunk X coordinate that is loaded
* @param cz Chunk Z coordinate that is loaded
* @param world World that the chunk was loaded in
*/
void chunkLoaded(int cx, int cz, World world);
@@ -54,8 +54,8 @@ public interface ChunkletManager {
/**
* Informs the ChunkletManager a chunk is unloaded
*
* @param cx Chunk X coordinate that is unloaded
* @param cz Chunk Z coordinate that is unloaded
* @param cx Chunk X coordinate that is unloaded
* @param cz Chunk Z coordinate that is unloaded
* @param world World that the chunk was unloaded in
*/
void chunkUnloaded(int cx, int cz, World world);
@@ -94,9 +94,9 @@ public interface ChunkletManager {
/**
* Check to see if a given location is set to true
*
* @param x X coordinate to check
* @param y Y coordinate to check
* @param z Z coordinate to check
* @param x X coordinate to check
* @param y Y coordinate to check
* @param z Z coordinate to check
* @param world World to check in
* @return true if the given location is set to true, false if otherwise
*/
@@ -113,9 +113,9 @@ public interface ChunkletManager {
/**
* Set a given location to true, should create stores as necessary if the location does not exist
*
* @param x X coordinate to set
* @param y Y coordinate to set
* @param z Z coordinate to set
* @param x X coordinate to set
* @param y Y coordinate to set
* @param z Z coordinate to set
* @param world World to set in
*/
void setTrue(int x, int y, int z, World world);
@@ -130,9 +130,9 @@ public interface ChunkletManager {
/**
* Set a given location to false, should not create stores if one does not exist for the given location
*
* @param x X coordinate to set
* @param y Y coordinate to set
* @param z Z coordinate to set
* @param x X coordinate to set
* @param y Y coordinate to set
* @param z Z coordinate to set
* @param world World to set in
*/
void setFalse(int x, int y, int z, World world);

View File

@@ -295,7 +295,7 @@ public class HashChunkletManager implements ChunkletManager {
}
/**
* @param cStore ChunkletStore to save
* @param cStore ChunkletStore to save
* @param location Where on the disk to put it
*/
private void serializeChunkletStore(ChunkletStore cStore, File location) {
@@ -309,17 +309,14 @@ public class HashChunkletManager implements ChunkletManager {
fileOut = new FileOutputStream(location);
objOut = new ObjectOutputStream(fileOut);
objOut.writeObject(cStore);
}
catch (IOException ex) {
} catch (IOException ex) {
ex.printStackTrace();
}
finally {
} finally {
if (objOut != null) {
try {
objOut.flush();
objOut.close();
}
catch (IOException ex) {
} catch (IOException ex) {
ex.printStackTrace();
}
}
@@ -327,8 +324,7 @@ public class HashChunkletManager implements ChunkletManager {
if (fileOut != null) {
try {
fileOut.close();
}
catch (IOException ex) {
} catch (IOException ex) {
ex.printStackTrace();
}
}
@@ -348,35 +344,29 @@ public class HashChunkletManager implements ChunkletManager {
fileIn = new FileInputStream(location);
objIn = new ObjectInputStream(fileIn);
storeIn = (ChunkletStore) objIn.readObject();
}
catch (IOException ex) {
} catch (IOException ex) {
if (ex instanceof EOFException) {
// EOF should only happen on Chunklets that somehow have been corrupted.
//mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " could not be read due to an EOFException, data in this area will be lost.");
return ChunkletStoreFactory.getChunkletStore();
}
else if (ex instanceof StreamCorruptedException) {
} else if (ex instanceof StreamCorruptedException) {
// StreamCorrupted happens when the Chunklet is no good.
//mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " is corrupted, data in this area will be lost.");
return ChunkletStoreFactory.getChunkletStore();
}
else if (ex instanceof UTFDataFormatException) {
} else if (ex instanceof UTFDataFormatException) {
// UTF happens when the Chunklet cannot be read or is corrupted
//mcMMO.p.getLogger().severe("Chunklet data at " + location.toString() + " could not be read due to an UTFDataFormatException, data in this area will be lost.");
return ChunkletStoreFactory.getChunkletStore();
}
ex.printStackTrace();
}
catch (ClassNotFoundException ex) {
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
}
finally {
} finally {
if (objIn != null) {
try {
objIn.close();
}
catch (IOException ex) {
} catch (IOException ex) {
ex.printStackTrace();
}
}
@@ -384,8 +374,7 @@ public class HashChunkletManager implements ChunkletManager {
if (fileIn != null) {
try {
fileIn.close();
}
catch (IOException ex) {
} catch (IOException ex) {
ex.printStackTrace();
}
}

View File

@@ -5,7 +5,7 @@ import org.bukkit.block.Block;
/**
* A ChunkletManager implementation that does nothing and returns false for all checks.
*
* <p>
* Useful for turning off Chunklets without actually doing much work
*/
public class NullChunkletManager implements ChunkletManager {

View File

@@ -3,7 +3,9 @@ package com.gmail.nossr50.util.blockmeta;
public class PrimitiveChunkletStore implements ChunkletStore {
private static final long serialVersionUID = -3453078050608607478L;
/** X, Z, Y */
/**
* X, Z, Y
*/
public boolean[][][] store = new boolean[16][16][64];
@Override

View File

@@ -8,9 +8,42 @@ import java.io.ObjectOutput;
public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
private static final long serialVersionUID = 8603603827094383873L;
/** X, Z, Y */
/**
* X, Z, Y
*/
public boolean[][][] store = new boolean[16][16][64];
/*
* The address byte: A single byte which contains x and z values which correspond to the x and z Chunklet-coordinates
*
* In Chunklet-coordinates, the only valid values are 0-15, so we can fit both into a single byte.
*
* The top 4 bits of the address byte are for the x value
* The bottom 4 bits of the address byte are for the z value
*
* Examples:
* An address byte with a value 00000001 would be split like so:
* - x = 0000 = 0
* - z = 0001 = 1
* => Chunklet coordinates (0, 1)
*
* 01011111
* - x = 0101 = 5
* - z = 1111 = 15
* => Chunklet coordinates (5, 15)
*/
protected static byte makeAddressByte(int x, int z) {
return (byte) ((x << 4) + z);
}
protected static int addressByteX(byte address) {
return (address & 0xF0) >>> 4;
}
protected static int addressByteZ(byte address) {
return address & 0x0F;
}
@Override
public boolean isTrue(int x, int y, int z) {
return store[x][z][y];
@@ -146,35 +179,4 @@ public class PrimitiveExChunkletStore implements ChunkletStore, Externalizable {
return column;
}
/*
* The address byte: A single byte which contains x and z values which correspond to the x and z Chunklet-coordinates
*
* In Chunklet-coordinates, the only valid values are 0-15, so we can fit both into a single byte.
*
* The top 4 bits of the address byte are for the x value
* The bottom 4 bits of the address byte are for the z value
*
* Examples:
* An address byte with a value 00000001 would be split like so:
* - x = 0000 = 0
* - z = 0001 = 1
* => Chunklet coordinates (0, 1)
*
* 01011111
* - x = 0101 = 5
* - z = 1111 = 15
* => Chunklet coordinates (5, 15)
*/
protected static byte makeAddressByte(int x, int z) {
return (byte) ((x << 4) + z);
}
protected static int addressByteX(byte address) {
return (address & 0xF0) >>> 4;
}
protected static int addressByteZ(byte address) {
return address & 0x0F;
}
}

View File

@@ -19,9 +19,9 @@ public interface ChunkManager {
/**
* Loads a specific chunklet
*
* @param cx Chunklet X coordinate that needs to be loaded
* @param cy Chunklet Y coordinate that needs to be loaded
* @param cz Chunklet Z coordinate that needs to be loaded
* @param cx Chunklet X coordinate that needs to be loaded
* @param cy Chunklet Y coordinate that needs to be loaded
* @param cz Chunklet Z coordinate that needs to be loaded
* @param world World that the chunklet needs to be loaded in
*/
void loadChunklet(int cx, int cy, int cz, World world);
@@ -29,9 +29,9 @@ public interface ChunkManager {
/**
* Unload a specific chunklet
*
* @param cx Chunklet X coordinate that needs to be unloaded
* @param cy Chunklet Y coordinate that needs to be unloaded
* @param cz Chunklet Z coordinate that needs to be unloaded
* @param cx Chunklet X coordinate that needs to be unloaded
* @param cy Chunklet Y coordinate that needs to be unloaded
* @param cz Chunklet Z coordinate that needs to be unloaded
* @param world World that the chunklet needs to be unloaded from
*/
void unloadChunklet(int cx, int cy, int cz, World world);
@@ -39,8 +39,8 @@ public interface ChunkManager {
/**
* Load a given Chunk's Chunklet data
*
* @param cx Chunk X coordinate that is to be loaded
* @param cz Chunk Z coordinate that is to be loaded
* @param cx Chunk X coordinate that is to be loaded
* @param cz Chunk Z coordinate that is to be loaded
* @param world World that the Chunk is in
*/
void loadChunk(int cx, int cz, World world, Entity[] entities);
@@ -48,8 +48,8 @@ public interface ChunkManager {
/**
* Unload a given Chunk's Chunklet data
*
* @param cx Chunk X coordinate that is to be unloaded
* @param cz Chunk Z coordinate that is to be unloaded
* @param cx Chunk X coordinate that is to be unloaded
* @param cz Chunk Z coordinate that is to be unloaded
* @param world World that the Chunk is in
*/
void unloadChunk(int cx, int cz, World world);
@@ -57,8 +57,8 @@ public interface ChunkManager {
/**
* Saves a given Chunk's Chunklet data
*
* @param cx Chunk X coordinate that is to be saved
* @param cz Chunk Z coordinate that is to be saved
* @param cx Chunk X coordinate that is to be saved
* @param cz Chunk Z coordinate that is to be saved
* @param world World that the Chunk is in
*/
void saveChunk(int cx, int cz, World world);
@@ -68,8 +68,8 @@ public interface ChunkManager {
/**
* Informs the ChunkletManager a chunk is loaded
*
* @param cx Chunk X coordinate that is loaded
* @param cz Chunk Z coordinate that is loaded
* @param cx Chunk X coordinate that is loaded
* @param cz Chunk Z coordinate that is loaded
* @param world World that the chunk was loaded in
*/
void chunkLoaded(int cx, int cz, World world);
@@ -77,8 +77,8 @@ public interface ChunkManager {
/**
* Informs the ChunkletManager a chunk is unloaded
*
* @param cx Chunk X coordinate that is unloaded
* @param cz Chunk Z coordinate that is unloaded
* @param cx Chunk X coordinate that is unloaded
* @param cz Chunk Z coordinate that is unloaded
* @param world World that the chunk was unloaded in
*/
void chunkUnloaded(int cx, int cz, World world);
@@ -117,9 +117,9 @@ public interface ChunkManager {
/**
* Check to see if a given location is set to true
*
* @param x X coordinate to check
* @param y Y coordinate to check
* @param z Z coordinate to check
* @param x X coordinate to check
* @param y Y coordinate to check
* @param z Z coordinate to check
* @param world World to check in
* @return true if the given location is set to true, false if otherwise
*/
@@ -144,9 +144,9 @@ public interface ChunkManager {
/**
* Set a given location to true, should create stores as necessary if the location does not exist
*
* @param x X coordinate to set
* @param y Y coordinate to set
* @param z Z coordinate to set
* @param x X coordinate to set
* @param y Y coordinate to set
* @param z Z coordinate to set
* @param world World to set in
*/
void setTrue(int x, int y, int z, World world);
@@ -168,9 +168,9 @@ public interface ChunkManager {
/**
* Set a given location to false, should not create stores if one does not exist for the given location
*
* @param x X coordinate to set
* @param y Y coordinate to set
* @param z Z coordinate to set
* @param x X coordinate to set
* @param y Y coordinate to set
* @param z Z coordinate to set
* @param world World to set in
*/
void setFalse(int x, int y, int z, World world);

View File

@@ -11,9 +11,9 @@ import java.io.*;
import java.util.*;
public class HashChunkManager implements ChunkManager {
private HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>> regionFiles = new HashMap<>();
public HashMap<String, ChunkStore> store = new HashMap<>();
public ArrayList<BlockStoreConversionZDirectory> converters = new ArrayList<>();
private HashMap<UUID, HashMap<Long, McMMOSimpleRegionFile>> regionFiles = new HashMap<>();
private HashMap<UUID, Boolean> oldData = new HashMap<>();
@Override
@@ -65,8 +65,7 @@ public class HashChunkManager implements ChunkManager {
objectStream.flush();
objectStream.close();
data.setDirty(false);
}
catch (IOException e) {
} catch (IOException e) {
throw new RuntimeException("Unable to write chunk meta data for " + x + ", " + z, e);
}
}
@@ -129,8 +128,7 @@ public class HashChunkManager implements ChunkManager {
if (!oldData.containsKey(key)) {
oldData.put(key, (new File(world.getWorldFolder(), "mcmmo_data")).exists());
}
else if (oldData.get(key)) {
} else if (oldData.get(key)) {
if (convertChunk(new File(world.getWorldFolder(), "mcmmo_data"), cx, cz, world, true)) {
return;
}
@@ -140,8 +138,9 @@ public class HashChunkManager implements ChunkManager {
try {
chunkStore = readChunkStore(world, cx, cz);
} catch (Exception e) {
e.printStackTrace();
}
catch (Exception e) { e.printStackTrace(); }
if (chunkStore == null) {
return;
@@ -187,7 +186,8 @@ public class HashChunkManager implements ChunkManager {
}
@Override
public synchronized void chunkLoaded(int cx, int cz, World world) {}
public synchronized void chunkLoaded(int cx, int cz, World world) {
}
@Override
public synchronized void chunkUnloaded(int cx, int cz, World world) {
@@ -213,8 +213,7 @@ public class HashChunkManager implements ChunkManager {
if (worldName.equals(info[0])) {
try {
saveChunk(Integer.parseInt(info[1]), Integer.parseInt(info[2]), world);
}
catch (Exception e) {
} catch (Exception e) {
// Ignore
}
}
@@ -236,8 +235,7 @@ public class HashChunkManager implements ChunkManager {
if (worldName.equals(info[0])) {
try {
unloadChunk(Integer.parseInt(info[1]), Integer.parseInt(info[2]), world);
}
catch (Exception e) {
} catch (Exception e) {
// Ignore
}
}
@@ -245,7 +243,8 @@ public class HashChunkManager implements ChunkManager {
}
@Override
public synchronized void loadWorld(World world) {}
public synchronized void loadWorld(World world) {
}
@Override
public synchronized void saveAll() {
@@ -401,7 +400,8 @@ public class HashChunkManager implements ChunkManager {
}
@Override
public synchronized void cleanUp() {}
public synchronized void cleanUp() {
}
public synchronized void convertChunk(File dataDir, int cx, int cz, World world) {
convertChunk(dataDir, cx, cz, world, false);

View File

@@ -25,21 +25,21 @@ import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
public class McMMOSimpleRegionFile {
private RandomAccessFile file;
@SuppressWarnings("unused")
private static long TIMEOUT_TIME = 300000; // 5 min
private final int[] dataStart = new int[1024];
private final int[] dataActualLength = new int[1024];
private final int[] dataLength = new int[1024];
private final ArrayList<Boolean> inuse = new ArrayList<>();
private int segmentSize;
private int segmentMask;
private final int rx;
private final int rz;
private final int defaultSegmentSize;
private final File parent;
private RandomAccessFile file;
private int segmentSize;
private int segmentMask;
@SuppressWarnings("unused")
private long lastAccessTime = System.currentTimeMillis();
@SuppressWarnings("unused")
private static long TIMEOUT_TIME = 300000; // 5 min
public McMMOSimpleRegionFile(File f, int rx, int rz) {
this(f, rx, rz, 10);
@@ -91,8 +91,7 @@ public class McMMOSimpleRegionFile {
}
extendFile();
}
catch (IOException fnfe) {
} catch (IOException fnfe) {
throw new RuntimeException(fnfe);
}
}
@@ -139,16 +138,15 @@ public class McMMOSimpleRegionFile {
}
extendFile();
}
catch (IOException fnfe) {
} catch (IOException fnfe) {
throw new RuntimeException(fnfe);
}
}
return file;
}
/* public synchronized boolean testCloseTimeout() {
*//*
/* public synchronized boolean testCloseTimeout() {
*//*
if (System.currentTimeMillis() - TIMEOUT_TIME > lastAccessTime) {
close();
return true;
@@ -197,8 +195,7 @@ public class McMMOSimpleRegionFile {
}
file = null;
}
catch (IOException ioe) {
} catch (IOException ioe) {
throw new RuntimeException("Unable to close file", ioe);
}
}
@@ -261,8 +258,7 @@ public class McMMOSimpleRegionFile {
if (inuse.get(end)) {
end++;
start = end;
}
else {
} else {
end++;
}

View File

@@ -8,7 +8,8 @@ import org.bukkit.entity.Entity;
public class NullChunkManager implements ChunkManager {
@Override
public void closeAll() {}
public void closeAll() {
}
@Override
public ChunkStore readChunkStore(World world, int x, int z) {
@@ -16,25 +17,32 @@ public class NullChunkManager implements ChunkManager {
}
@Override
public void writeChunkStore(World world, int x, int z, ChunkStore data) {}
public void writeChunkStore(World world, int x, int z, ChunkStore data) {
}
@Override
public void closeChunkStore(World world, int x, int z) {}
public void closeChunkStore(World world, int x, int z) {
}
@Override
public void loadChunklet(int cx, int cy, int cz, World world) {}
public void loadChunklet(int cx, int cy, int cz, World world) {
}
@Override
public void unloadChunklet(int cx, int cy, int cz, World world) {}
public void unloadChunklet(int cx, int cy, int cz, World world) {
}
@Override
public void loadChunk(int cx, int cz, World world, Entity[] entities) {}
public void loadChunk(int cx, int cz, World world, Entity[] entities) {
}
@Override
public void unloadChunk(int cx, int cz, World world) {}
public void unloadChunk(int cx, int cz, World world) {
}
@Override
public void saveChunk(int cx, int cz, World world) {}
public void saveChunk(int cx, int cz, World world) {
}
@Override
public boolean isChunkLoaded(int cx, int cz, World world) {
@@ -42,25 +50,32 @@ public class NullChunkManager implements ChunkManager {
}
@Override
public void chunkLoaded(int cx, int cz, World world) {}
public void chunkLoaded(int cx, int cz, World world) {
}
@Override
public void chunkUnloaded(int cx, int cz, World world) {}
public void chunkUnloaded(int cx, int cz, World world) {
}
@Override
public void saveWorld(World world) {}
public void saveWorld(World world) {
}
@Override
public void unloadWorld(World world) {}
public void unloadWorld(World world) {
}
@Override
public void loadWorld(World world) {}
public void loadWorld(World world) {
}
@Override
public void saveAll() {}
public void saveAll() {
}
@Override
public void unloadAll() {}
public void unloadAll() {
}
@Override
public boolean isTrue(int x, int y, int z, World world) {
@@ -78,23 +93,30 @@ public class NullChunkManager implements ChunkManager {
}
@Override
public void setTrue(int x, int y, int z, World world) {}
public void setTrue(int x, int y, int z, World world) {
}
@Override
public void setTrue(Block block) {}
public void setTrue(Block block) {
}
@Override
public void setTrue(BlockState blockState) {}
public void setTrue(BlockState blockState) {
}
@Override
public void setFalse(int x, int y, int z, World world) {}
public void setFalse(int x, int y, int z, World world) {
}
@Override
public void setFalse(Block block) {}
public void setFalse(Block block) {
}
@Override
public void setFalse(BlockState blockState) {}
public void setFalse(BlockState blockState) {
}
@Override
public void cleanUp() {}
public void cleanUp() {
}
}

View File

@@ -11,11 +11,13 @@ import java.util.UUID;
public class PrimitiveChunkStore implements ChunkStore {
private static final long serialVersionUID = -1L;
transient private boolean dirty = false;
/** X, Z, Y */
public boolean[][][] store;
private static final int CURRENT_VERSION = 7;
private static final int MAGIC_NUMBER = 0xEA5EDEBB;
/**
* X, Z, Y
*/
public boolean[][][] store;
transient private boolean dirty = false;
private int cx;
private int cz;
private UUID worldUid;
@@ -138,8 +140,9 @@ public class PrimitiveChunkStore implements ChunkStore {
for (int y = 0; y < store[0][0].length; y++) {
try {
store[x][z][y] = temp[x][y][z];
} catch (Exception e) {
e.printStackTrace();
}
catch (Exception e) { e.printStackTrace(); }
}
}
}

View File

@@ -7,12 +7,12 @@ import org.bukkit.scheduler.BukkitScheduler;
import java.io.File;
public class BlockStoreConversionMain implements Runnable {
private int taskID;
private org.bukkit.World world;
BukkitScheduler scheduler;
File dataDir;
File[] xDirs;
BlockStoreConversionXDirectory[] converters;
private int taskID;
private org.bukkit.World world;
public BlockStoreConversionMain(org.bukkit.World world) {
this.taskID = -1;

View File

@@ -7,12 +7,12 @@ import org.bukkit.scheduler.BukkitScheduler;
import java.io.File;
public class BlockStoreConversionXDirectory implements Runnable {
private int taskID;
private org.bukkit.World world;
BukkitScheduler scheduler;
File dataDir;
File[] zDirs;
BlockStoreConversionZDirectory[] converters;
private int taskID;
private org.bukkit.World world;
public BlockStoreConversionXDirectory() {
this.taskID = -1;

View File

@@ -70,8 +70,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
try {
this.cx = Integer.parseInt(this.cxs);
this.cz = Integer.parseInt(this.czs);
}
catch (Exception e) {
} catch (Exception e) {
this.dataDir.delete();
stop();
return;
@@ -85,8 +84,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
if (this.tempChunklet instanceof PrimitiveChunkletStore) {
this.primitiveChunklet = (PrimitiveChunkletStore) this.tempChunklet;
}
else if (this.tempChunklet instanceof PrimitiveExChunkletStore) {
} else if (this.tempChunklet instanceof PrimitiveExChunkletStore) {
this.primitiveExChunklet = (PrimitiveExChunkletStore) this.tempChunklet;
}
@@ -113,8 +111,9 @@ public class BlockStoreConversionZDirectory implements Runnable {
}
this.newManager.setTrue(this.cxPos, this.y2, this.czPos, this.world);
} catch (Exception e) {
e.printStackTrace();
}
catch (Exception e) { e.printStackTrace(); }
}
}
}
@@ -132,8 +131,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
if (this.primitiveExChunklet != null) {
oldArray = this.primitiveExChunklet.store[x][z];
}
else {
} else {
return;
}
@@ -141,8 +139,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
if (oldArray.length < 64) {
return;
}
else if (newArray.length < ((this.y * 64) + 64)) {
} else if (newArray.length < ((this.y * 64) + 64)) {
return;
}

View File

@@ -25,10 +25,11 @@ import java.util.ArrayList;
import java.util.List;
public final class CommandRegistrationManager {
private CommandRegistrationManager() {}
private static String permissionsMessage = LocaleLoader.getString("mcMMO.NoPermission");
private CommandRegistrationManager() {
}
private static void registerSkillCommands() {
for (PrimarySkillType skill : PrimarySkillType.values()) {
String commandName = skill.toString().toLowerCase();
@@ -323,9 +324,9 @@ public final class CommandRegistrationManager {
PluginCommand command = mcMMO.p.getCommand("party");
command.setDescription(LocaleLoader.getString("Commands.Description.party"));
command.setPermission("mcmmo.commands.party;mcmmo.commands.party.accept;mcmmo.commands.party.create;mcmmo.commands.party.disband;" +
"mcmmo.commands.party.xpshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" +
"mcmmo.commands.party.kick;mcmmo.commands.party.lock;mcmmo.commands.party.owner;mcmmo.commands.party.password;" +
"mcmmo.commands.party.quit;mcmmo.commands.party.rename;mcmmo.commands.party.unlock");
"mcmmo.commands.party.xpshare;mcmmo.commands.party.invite;mcmmo.commands.party.itemshare;mcmmo.commands.party.join;" +
"mcmmo.commands.party.kick;mcmmo.commands.party.lock;mcmmo.commands.party.owner;mcmmo.commands.party.password;" +
"mcmmo.commands.party.quit;mcmmo.commands.party.rename;mcmmo.commands.party.unlock");
command.setPermissionMessage(permissionsMessage);
command.setExecutor(new PartyCommand());
}
@@ -368,7 +369,7 @@ public final class CommandRegistrationManager {
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcnotify"));
command.setExecutor(new McnotifyCommand());
}
private static void registerMHDCommand() {
PluginCommand command = mcMMO.p.getCommand("mhd");
command.setDescription("Resets all mob health bar settings for all players to the default"); //TODO: Localize

View File

@@ -22,7 +22,8 @@ public final class CommandUtils {
public static final List<String> TRUE_FALSE_OPTIONS = ImmutableList.of("on", "off", "true", "false", "enabled", "disabled");
public static final List<String> RESET_OPTIONS = ImmutableList.of("clear", "reset");
private CommandUtils() {}
private CommandUtils() {
}
public static boolean isChildSkill(CommandSender sender, PrimarySkillType skill) {
if (skill == null || !skill.isChildSkill()) {
@@ -51,8 +52,8 @@ public final class CommandUtils {
&& mcMMO.getConfigManager().getConfigCommands().isLimitInspectRange()
&& !hasPermission
&& !Misc.isNear(((Player) sender).getLocation(),
target.getLocation(),
mcMMO.getConfigManager().getConfigCommands().getInspectCommandMaxDistance())) {
target.getLocation(),
mcMMO.getConfigManager().getConfigCommands().getInspectCommandMaxDistance())) {
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
return true;
}
@@ -85,10 +86,9 @@ public final class CommandUtils {
/**
* Checks if there is a valid mcMMOPlayer object.
*
* @param sender CommandSender who used the command
* @param playerName name of the target player
* @param sender CommandSender who used the command
* @param playerName name of the target player
* @param mcMMOPlayer mcMMOPlayer object of the target player
*
* @return true if the player is online and a valid mcMMOPlayer object was found
*/
public static boolean checkPlayerExistence(CommandSender sender, String playerName, McMMOPlayer mcMMOPlayer) {
@@ -228,7 +228,7 @@ public final class CommandUtils {
}
private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
if(UserManager.getPlayer(inspect) == null)
if (UserManager.getPlayer(inspect) == null)
return;
PlayerProfile profile = UserManager.getPlayer(inspect).getProfile();
@@ -266,7 +266,6 @@ public final class CommandUtils {
* Get a matched player name if one was found in the database.
*
* @param partialName Name to match
*
* @return Matched name or {@code partialName} if no match was found
*/
public static String getMatchedPlayerName(String partialName) {
@@ -276,8 +275,7 @@ public final class CommandUtils {
if (matches.size() == 1) {
partialName = matches.get(0);
}
}
else {
} else {
Player player = mcMMO.p.getServer().getPlayer(partialName);
if (player != null) {
@@ -290,7 +288,7 @@ public final class CommandUtils {
/**
* Attempts to match any player names with the given name, and returns a list of all possibly matches.
*
* <p>
* This list is not sorted in any particular order.
* If an exact match is found, the returned list will only contain a single result.
*
@@ -302,10 +300,10 @@ public final class CommandUtils {
for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) {
String playerName = offlinePlayer.getName();
if (playerName == null) { //Do null checking here to detect corrupted data before sending it throuogh .equals
System.err.println("[McMMO] Player data file with UIID " + offlinePlayer.getUniqueId() + " is missing a player name. This may be a legacy file from before bukkit.lastKnownName. This should be okay to ignore.");
continue; //Don't let an error here interrupt the loop
System.err.println("[McMMO] Player data file with UIID " + offlinePlayer.getUniqueId() + " is missing a player name. This may be a legacy file from before bukkit.lastKnownName. This should be okay to ignore.");
continue; //Don't let an error here interrupt the loop
}
if (partialName.equalsIgnoreCase(playerName)) {

View File

@@ -13,13 +13,11 @@ import java.util.HashMap;
* Each ExperienceBarManager only manages a single player
*/
public class ExperienceBarManager {
private McMMOPlayer mcMMOPlayer;
HashMap<PrimarySkillType, ExperienceBarWrapper> experienceBars;
HashMap<PrimarySkillType, ExperienceBarHideTask> experienceBarHideTaskHashMap;
private McMMOPlayer mcMMOPlayer;
public ExperienceBarManager(McMMOPlayer mcMMOPlayer)
{
public ExperienceBarManager(McMMOPlayer mcMMOPlayer) {
//Init map
experienceBars = new HashMap<>();
experienceBarHideTaskHashMap = new HashMap<>();
@@ -27,13 +25,12 @@ public class ExperienceBarManager {
this.mcMMOPlayer = mcMMOPlayer;
}
public void updateExperienceBar(PrimarySkillType primarySkillType, Plugin plugin)
{
if(!ExperienceConfig.getInstance().isExperienceBarsEnabled() || !ExperienceConfig.getInstance().isExperienceBarEnabled(primarySkillType))
public void updateExperienceBar(PrimarySkillType primarySkillType, Plugin plugin) {
if (!ExperienceConfig.getInstance().isExperienceBarsEnabled() || !ExperienceConfig.getInstance().isExperienceBarEnabled(primarySkillType))
return;
//Init Bar
if(experienceBars.get(primarySkillType) == null)
if (experienceBars.get(primarySkillType) == null)
experienceBars.put(primarySkillType, new ExperienceBarWrapper(primarySkillType, mcMMOPlayer));
//Get Bar
@@ -46,8 +43,7 @@ public class ExperienceBarManager {
experienceBarWrapper.showExperienceBar();
//Setup Hide Bar Task
if(experienceBarHideTaskHashMap.get(primarySkillType) != null)
{
if (experienceBarHideTaskHashMap.get(primarySkillType) != null) {
experienceBarHideTaskHashMap.get(primarySkillType).cancel();
scheduleHideTask(primarySkillType, plugin);
} else {
@@ -57,17 +53,15 @@ public class ExperienceBarManager {
private void scheduleHideTask(PrimarySkillType primarySkillType, Plugin plugin) {
ExperienceBarHideTask experienceBarHideTask = new ExperienceBarHideTask(this, mcMMOPlayer, primarySkillType);
experienceBarHideTask.runTaskLater(plugin, 20*2);
experienceBarHideTask.runTaskLater(plugin, 20 * 2);
experienceBarHideTaskHashMap.put(primarySkillType, experienceBarHideTask);
}
public void hideExperienceBar(PrimarySkillType primarySkillType)
{
public void hideExperienceBar(PrimarySkillType primarySkillType) {
experienceBars.get(primarySkillType).hideExperienceBar();
}
public void clearTask(PrimarySkillType primarySkillType)
{
public void clearTask(PrimarySkillType primarySkillType) {
experienceBarHideTaskHashMap.remove(primarySkillType);
}
}

View File

@@ -18,20 +18,18 @@ import java.util.List;
*/
public class ExperienceBarWrapper {
private final PrimarySkillType primarySkillType; //Primary Skill
private BossBar bossBar;
private final Server server;
protected final McMMOPlayer mcMMOPlayer;
private int lastLevelUpdated;
private final PrimarySkillType primarySkillType; //Primary Skill
private final Server server;
/*
* This is stored to help optimize updating the title
*/
protected String niceSkillName;
protected String title;
private BossBar bossBar;
private int lastLevelUpdated;
public ExperienceBarWrapper(PrimarySkillType primarySkillType, McMMOPlayer mcMMOPlayer)
{
public ExperienceBarWrapper(PrimarySkillType primarySkillType, McMMOPlayer mcMMOPlayer) {
this.mcMMOPlayer = mcMMOPlayer;
this.server = mcMMOPlayer.getPlayer().getServer(); //Might not be good for bungee to do this
this.primarySkillType = primarySkillType;
@@ -45,8 +43,7 @@ public class ExperienceBarWrapper {
initBar();
}
private void initBar()
{
private void initBar() {
title = getTitleTemplate();
createBossBar();
}
@@ -58,19 +55,31 @@ public class ExperienceBarWrapper {
private String getTitleTemplate() {
//If they are using extra details
if(ExperienceConfig.getInstance().getAddExtraDetails())
return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar."+niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
if (ExperienceConfig.getInstance().getAddExtraDetails())
return LocaleLoader.getString("XPBar.Complex.Template", LocaleLoader.getString("XPBar." + niceSkillName, getLevel()), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
return LocaleLoader.getString("XPBar."+niceSkillName, getLevel(), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
return LocaleLoader.getString("XPBar." + niceSkillName, getLevel(), getCurrentXP(), getMaxXP(), getPowerLevel(), getPercentageOfLevel());
}
private int getLevel() {
return mcMMOPlayer.getSkillLevel(primarySkillType);
}
private int getCurrentXP() { return mcMMOPlayer.getSkillXpLevel(primarySkillType); }
private int getMaxXP() { return mcMMOPlayer.getXpToLevel(primarySkillType); }
private int getPowerLevel() { return mcMMOPlayer.getPowerLevel(); }
private int getPercentageOfLevel() { return (int) (mcMMOPlayer.getProgressInCurrentSkillLevel(primarySkillType) * 100); }
private int getCurrentXP() {
return mcMMOPlayer.getSkillXpLevel(primarySkillType);
}
private int getMaxXP() {
return mcMMOPlayer.getXpToLevel(primarySkillType);
}
private int getPowerLevel() {
return mcMMOPlayer.getPowerLevel();
}
private int getPercentageOfLevel() {
return (int) (mcMMOPlayer.getProgressInCurrentSkillLevel(primarySkillType) * 100);
}
public String getTitle() {
return bossBar.getTitle();
@@ -96,28 +105,27 @@ public class ExperienceBarWrapper {
bossBar.setStyle(barStyle);
}
public double getProgress() {
return bossBar.getProgress();
}
public void setProgress(double v) {
//Clamp Values
if(v < 0)
if (v < 0)
bossBar.setProgress(0.0D);
else if(v > 1)
else if (v > 1)
bossBar.setProgress(1.0D);
else
bossBar.setProgress(v);
//Every time progress updates we need to check for a title update
if(getLevel() != lastLevelUpdated || ExperienceConfig.getInstance().getDoExperienceBarsAlwaysUpdateTitle())
{
if (getLevel() != lastLevelUpdated || ExperienceConfig.getInstance().getDoExperienceBarsAlwaysUpdateTitle()) {
updateTitle();
lastLevelUpdated = getLevel();
}
}
public double getProgress() {
return bossBar.getProgress();
}
public List<Player> getPlayers() {
return bossBar.getPlayers();
}
@@ -126,13 +134,11 @@ public class ExperienceBarWrapper {
return bossBar.isVisible();
}
public void hideExperienceBar()
{
public void hideExperienceBar() {
bossBar.setVisible(false);
}
public void showExperienceBar()
{
public void showExperienceBar() {
bossBar.setVisible(true);
}
@@ -141,8 +147,7 @@ public class ExperienceBarWrapper {
return bossBar
}*/
private void createBossBar()
{
private void createBossBar() {
bossBar = mcMMOPlayer.getPlayer().getServer().createBossBar(title, ExperienceConfig.getInstance().getExperienceBarColor(primarySkillType), ExperienceConfig.getInstance().getExperienceBarStyle(primarySkillType));
bossBar.addPlayer(mcMMOPlayer.getPlayer());
}

View File

@@ -15,8 +15,7 @@ public class ExperienceMapManager implements Unload {
public HashMap<Material, Integer> woodcuttingXpMap;
public HashMap<Material, Integer> excavationXpMap;
public ExperienceMapManager()
{
public ExperienceMapManager() {
miningXpMap = new HashMap<>();
herbalismXpMap = new HashMap<>();
woodcuttingXpMap = new HashMap<>();
@@ -28,81 +27,81 @@ public class ExperienceMapManager implements Unload {
/**
* Determines whether or not a block has Mining XP
*
* @param material target block material type
* @return true if the block has valid xp registers
*/
public boolean hasMiningXp(Material material)
{
public boolean hasMiningXp(Material material) {
return miningXpMap.get(material) != null;
}
/**
* Determines whether or not a block has Herbalism XP
*
* @param material target block material type
* @return true if the block has valid xp registers
*/
public boolean hasHerbalismXp(Material material)
{
public boolean hasHerbalismXp(Material material) {
return herbalismXpMap.get(material) != null;
}
/**
* Determines whether or not a block has Woodcutting XP
*
* @param material target block material type
* @return true if the block has valid xp registers
*/
public boolean hasWoodcuttingXp(Material material)
{
public boolean hasWoodcuttingXp(Material material) {
return woodcuttingXpMap.get(material) != null;
}
/**
* Determines whether or not a block has Excavation XP
*
* @param material target block material type
* @return true if the block has valid xp registers
*/
public boolean hasExcavationXp(Material material)
{
public boolean hasExcavationXp(Material material) {
return excavationXpMap.get(material) != null;
}
/**
* Gets the XP value for breaking this block from the xp map
*
* @param material the target block material
* @return the raw XP value before any modifiers are applied
*/
public int getMiningXp(Material material)
{
public int getMiningXp(Material material) {
return miningXpMap.get(material);
}
/**
* Gets the XP value for breaking this block from the xp map
*
* @param material the target block material
* @return the raw XP value before any modifiers are applied
*/
public int getHerbalismXp(Material material)
{
public int getHerbalismXp(Material material) {
return herbalismXpMap.get(material);
}
/**
* Gets the XP value for breaking this block from the xp map
*
* @param material the target block material
* @return the raw XP value before any modifiers are applied
*/
public int getWoodcuttingXp(Material material)
{
public int getWoodcuttingXp(Material material) {
return woodcuttingXpMap.get(material);
}
/**
* Gets the XP value for breaking this block from the xp map
*
* @param material the target block material
* @return the raw XP value before any modifiers are applied
*/
public int getExcavationXp(Material material)
{
public int getExcavationXp(Material material) {
return excavationXpMap.get(material);
}

View File

@@ -50,7 +50,7 @@ public class FormulaManager {
* the amount of levels and experience, using the previously
* used formula type.
*
* @param skillLevel Amount of levels
* @param skillLevel Amount of levels
* @param skillXPLevel Amount of experience
* @return The total amount of experience
*/
@@ -71,8 +71,8 @@ public class FormulaManager {
* the new formula type.
*
* @param primarySkillType skill where new levels and experience are calculated for
* @param experience total amount of experience
* @param formulaType The new {@link FormulaType}
* @param experience total amount of experience
* @param formulaType The new {@link FormulaType}
* @return the amount of levels and experience
*/
public int[] calculateNewLevel(PrimarySkillType primarySkillType, int experience, FormulaType formulaType) {
@@ -82,15 +82,14 @@ public class FormulaManager {
while (experience > 0 && newLevel < Integer.MAX_VALUE) {
//Level Cap
if(mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(primarySkillType))
{
if (mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(primarySkillType)) {
//Break the loop if we're at the cap
if(newLevel+1 > mcMMO.getPlayerLevelingSettings().getLevelCap(primarySkillType))
if (newLevel + 1 > mcMMO.getPlayerLevelingSettings().getLevelCap(primarySkillType))
break;
//If the maximum level is at or below our starting level, then the player can't level up anymore
if(maxLevel <= mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel())
return new int[]{ newLevel, remainder };
if (maxLevel <= mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel())
return new int[]{newLevel, remainder};
}
int experienceToNextLevel = getCachedXpToLevel(newLevel, formulaType);
@@ -104,7 +103,7 @@ public class FormulaManager {
experience -= experienceToNextLevel;
}
return new int[]{ newLevel, remainder };
return new int[]{newLevel, remainder};
}
/**
@@ -112,7 +111,7 @@ public class FormulaManager {
* if cache doesn't contain the given value it is calculated and added
* to the cached data.
*
* @param level level to check
* @param level level to check
* @param formulaType The {@link FormulaType} used
* @return amount of experience needed to reach next level
*/
@@ -136,7 +135,7 @@ public class FormulaManager {
switch (formulaType) {
case LINEAR:
if (!experienceNeededLinear.containsKey(level)) {
experience = (int) Math.floor( xpNeededMultiplier * (base + level * multiplier));
experience = (int) Math.floor(xpNeededMultiplier * (base + level * multiplier));
experienceNeededLinear.put(level, experience);
}
@@ -144,7 +143,7 @@ public class FormulaManager {
case EXPONENTIAL:
if (!experienceNeededExponential.containsKey(level)) {
experience = (int) Math.floor( xpNeededMultiplier * (multiplier * Math.pow(level, exponent) + base));
experience = (int) Math.floor(xpNeededMultiplier * (multiplier * Math.pow(level, exponent) + base));
experienceNeededExponential.put(level, experience);
}
@@ -159,7 +158,7 @@ public class FormulaManager {
* Get the cached amount of experience needed to reach the next party level,
* if cache doesn't contain the given value it is calculated and added
* to the cached data.
*
* <p>
* Parties use the exponential leveling formula
*
* @param level level to check
@@ -207,8 +206,7 @@ public class FormulaManager {
try {
formulasFile.save(formulaFile);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}

View File

@@ -22,13 +22,13 @@ public class NotificationManager {
/**
* Sends players notifications from mcMMO
* This does this by sending out an event so other plugins can cancel it
* @param player target player
*
* @param player target player
* @param notificationType notifications defined type
* @param key the locale key for the notifications defined message
* @param key the locale key for the notifications defined message
*/
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key) {
if (UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
return;
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
@@ -40,9 +40,8 @@ public class NotificationManager {
}
public static boolean doesPlayerUseNotifications(Player player)
{
if(UserManager.getPlayer(player) == null)
public static boolean doesPlayerUseNotifications(Player player) {
if (UserManager.getPlayer(player) == null)
return false;
else
return UserManager.getPlayer(player).useChatNotifications();
@@ -52,13 +51,13 @@ public class NotificationManager {
* Sends players notifications from mcMMO
* This does this by sending out an event so other plugins can cancel it
* This event in particular is provided with a source player, and players near the source player are sent the information
* @param source the source player for this event
*
* @param source the source player for this event
* @param notificationType type of notification
* @param key Locale Key for the string to use with this event
* @param values values to be injected into the locale string
* @param key Locale Key for the string to use with this event
* @param values values to be injected into the locale string
*/
public static void sendNearbyPlayersInformation(Player source, NotificationType notificationType, String key, String... values)
{
public static void sendNearbyPlayersInformation(Player source, NotificationType notificationType, String key, String... values) {
Location location = source.getLocation();
for (Player otherPlayer : source.getWorld().getPlayers()) {
if (otherPlayer != source && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
@@ -67,9 +66,8 @@ public class NotificationManager {
}
}
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) {
if (UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
return;
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
@@ -85,12 +83,10 @@ public class NotificationManager {
return;
//If the message is being sent to the action bar we need to check if the copy if a copy is sent to the chat system
if(customEvent.getChatMessageType() == ChatMessageType.ACTION_BAR)
{
if (customEvent.getChatMessageType() == ChatMessageType.ACTION_BAR) {
player.spigot().sendMessage(customEvent.getChatMessageType(), customEvent.getNotificationTextComponent());
if(customEvent.isMessageAlsoBeingSentToChat())
{
if (customEvent.isMessageAlsoBeingSentToChat()) {
//Send copy to chat system
player.spigot().sendMessage(ChatMessageType.SYSTEM, customEvent.getNotificationTextComponent());
}
@@ -111,13 +107,13 @@ public class NotificationManager {
/**
* Handles sending level up notifications to a mcMMOPlayer
*
* @param mcMMOPlayer target mcMMOPlayer
* @param skillName skill that leveled up
* @param newLevel new level of that skill
* @param skillName skill that leveled up
* @param newLevel new level of that skill
*/
public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkillType skillName, int levelsGained, int newLevel)
{
if(!mcMMOPlayer.useChatNotifications())
public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkillType skillName, int levelsGained, int newLevel) {
if (!mcMMOPlayer.useChatNotifications())
return;
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
@@ -128,17 +124,14 @@ public class NotificationManager {
sendNotification(mcMMOPlayer.getPlayer(), customEvent);
}
public static void broadcastTitle(Server server, String title, String subtitle, int i1, int i2, int i3)
{
for(Player player : server.getOnlinePlayers())
{
public static void broadcastTitle(Server server, String title, String subtitle, int i1, int i2, int i3) {
for (Player player : server.getOnlinePlayers()) {
player.sendTitle(title, subtitle, i1, i2, i3);
}
}
public static void sendPlayerUnlockNotification(McMMOPlayer mcMMOPlayer, SubSkillType subSkillType)
{
if(!mcMMOPlayer.useChatNotifications())
public static void sendPlayerUnlockNotification(McMMOPlayer mcMMOPlayer, SubSkillType subSkillType) {
if (!mcMMOPlayer.useChatNotifications())
return;
//CHAT MESSAGE

View File

@@ -13,7 +13,8 @@ import java.util.Collection;
public final class UserManager {
private UserManager() {}
private UserManager() {
}
/**
* Track a new user.
@@ -50,12 +51,9 @@ public final class UserManager {
mcMMO.p.debug("Saving mcMMOPlayers... (" + onlinePlayers.size() + ")");
for (Player player : onlinePlayers) {
try
{
try {
getPlayer(player).getProfile().save();
}
catch (Exception e)
{
} catch (Exception e) {
mcMMO.p.getLogger().warning("Could not save mcMMO player data for player: " + player.getName());
}
}
@@ -97,12 +95,13 @@ public final class UserManager {
/**
* Gets the McMMOPlayer object for a player, this can be null if the player has not yet been loaded.
*
* @param player target player
* @return McMMOPlayer object for this player, null if Player has not been loaded
*/
public static McMMOPlayer getPlayer(Player player) {
//Avoid Array Index out of bounds
if(player != null && player.hasMetadata(mcMMO.playerDataKey))
if (player != null && player.hasMetadata(mcMMO.playerDataKey))
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
else
return null;

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.util.random;
public interface RandomChanceExecution {
/**
* Gets the XPos used in the formula for success
*
* @return value of x for our success probability graph
*/
double getXPos();
@@ -10,6 +11,7 @@ public interface RandomChanceExecution {
/**
* The maximum odds for this RandomChanceExecution
* For example, if this value is 10, then 10% odds would be the maximum and would be achieved only when xPos equaled the LinearCurvePeak
*
* @return maximum probability odds from 0.00 (no chance of ever happened) to 100.0 (probability can be guaranteed)
*/
double getProbabilityCap();

View File

@@ -15,26 +15,24 @@ public class RandomChanceSkill implements RandomChanceExecution {
protected final boolean isLucky;
private int skillLevel;
public RandomChanceSkill(Player player, SubSkillType subSkillType)
{
public RandomChanceSkill(Player player, SubSkillType subSkillType) {
this.primarySkillType = subSkillType.getParentSkill();
this.subSkillType = subSkillType;
this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR;
if(player != null)
if (player != null)
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(primarySkillType);
else
this.skillLevel = 0;
if(player != null)
if (player != null)
isLucky = Permissions.lucky(player, primarySkillType);
else
isLucky = false;
}
public RandomChanceSkill(Player player, SubSkillType subSkillType, boolean hasCap)
{
if(hasCap)
public RandomChanceSkill(Player player, SubSkillType subSkillType, boolean hasCap) {
if (hasCap)
this.probabilityCap = mcMMO.getConfigManager().getSkillMaxChance(subSkillType);
else
this.probabilityCap = RandomChanceUtil.LINEAR_CURVE_VAR;
@@ -42,12 +40,12 @@ public class RandomChanceSkill implements RandomChanceExecution {
this.primarySkillType = subSkillType.getParentSkill();
this.subSkillType = subSkillType;
if(player != null)
if (player != null)
this.skillLevel = UserManager.getPlayer(player).getSkillLevel(primarySkillType);
else
this.skillLevel = 0;
if(player != null)
if (player != null)
isLucky = Permissions.lucky(player, primarySkillType);
else
isLucky = false;
@@ -55,6 +53,7 @@ public class RandomChanceSkill implements RandomChanceExecution {
/**
* The subskill corresponding to this RandomChanceSkill
*
* @return this subskill
*/
public SubSkillType getSubSkill() {
@@ -63,15 +62,16 @@ public class RandomChanceSkill implements RandomChanceExecution {
/**
* Gets the skill level of the player who owns this RandomChanceSkill
*
* @return the current skill level relating to this RandomChanceSkill
*/
public int getSkillLevel()
{
public int getSkillLevel() {
return skillLevel;
}
/**
* Modify the skill level used for this skill's RNG calculations
*
* @param newSkillLevel new skill level
*/
public void setSkillLevel(int newSkillLevel) {

View File

@@ -6,8 +6,7 @@ import org.bukkit.entity.Player;
public class RandomChanceSkillStatic extends RandomChanceSkill {
private final double xPos;
public RandomChanceSkillStatic(double xPos, Player player, SubSkillType subSkillType)
{
public RandomChanceSkillStatic(double xPos, Player player, SubSkillType subSkillType) {
super(player, subSkillType);
this.xPos = xPos;

View File

@@ -5,8 +5,7 @@ public class RandomChanceStatic implements RandomChanceExecution {
private final double probabilityCap;
private final boolean isLucky;
public RandomChanceStatic(double xPos, boolean isLucky)
{
public RandomChanceStatic(double xPos, boolean isLucky) {
this.xPos = xPos;
this.probabilityCap = xPos;
this.isLucky = isLucky;

View File

@@ -14,8 +14,7 @@ import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.Random;
public class RandomChanceUtil
{
public class RandomChanceUtil {
public static final DecimalFormat percent = new DecimalFormat("##0.00%");
//public static final DecimalFormat decimal = new DecimalFormat("##0.00");
public static final double LINEAR_CURVE_VAR = 100.0D;
@@ -26,14 +25,12 @@ public class RandomChanceUtil
* non-RNG skills just fire the cancellable event and succeed if they go uncancelled
*
* @param skillActivationType this value represents what kind of activation procedures this sub-skill uses
* @param subSkillType The identifier for this specific sub-skill
* @param player The owner of this sub-skill
* @param subSkillType The identifier for this specific sub-skill
* @param player The owner of this sub-skill
* @return returns true if all conditions are met and they event is not cancelled
*/
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player)
{
switch(skillActivationType)
{
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player) {
switch (skillActivationType) {
case RANDOM_LINEAR_100_SCALE_WITH_CAP:
return checkRandomChanceExecutionSuccess(player, subSkillType, true);
case RANDOM_STATIC_CHANCE:
@@ -46,10 +43,8 @@ public class RandomChanceUtil
}
}
public static double getActivationChance(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player)
{
switch(skillActivationType)
{
public static double getActivationChance(SkillActivationType skillActivationType, SubSkillType subSkillType, Player player) {
switch (skillActivationType) {
case RANDOM_LINEAR_100_SCALE_WITH_CAP:
return getRandomChanceExecutionSuccess(player, subSkillType, true);
case RANDOM_STATIC_CHANCE:
@@ -61,10 +56,10 @@ public class RandomChanceUtil
/**
* Checks whether or not the random chance succeeds
*
* @return true if the random chance succeeds
*/
public static boolean checkRandomChanceExecutionSuccess(Player player, PrimarySkillType primarySkillType, double chance)
{
public static boolean checkRandomChanceExecutionSuccess(Player player, PrimarySkillType primarySkillType, double chance) {
//Check the odds
chance *= 100;
@@ -88,19 +83,18 @@ public class RandomChanceUtil
/**
* Used for stuff like Excavation, Fishing, etc...
*
* @param randomChance
* @return
*/
public static boolean checkRandomChanceExecutionSuccess(RandomChanceSkillStatic randomChance)
{
public static boolean checkRandomChanceExecutionSuccess(RandomChanceSkillStatic randomChance) {
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
//Check the odds
return rollDice(chanceOfSuccess, 100);
}
public static boolean checkRandomChanceExecutionSuccess(RandomChanceSkill randomChance)
{
public static boolean checkRandomChanceExecutionSuccess(RandomChanceSkill randomChance) {
double chanceOfSuccess = calculateChanceOfSuccess(randomChance);
Random random = new Random();
@@ -118,6 +112,7 @@ public class RandomChanceUtil
/**
* Gets the Static Chance for something to activate
*
* @param randomChance
* @return
*/
@@ -176,27 +171,23 @@ public class RandomChanceUtil
*
* @return the chance of success from 0-100 (100 = guaranteed)
*/
private static int getChanceOfSuccess(double skillLevel, double maxProbability, double maxLevel)
{
private static int getChanceOfSuccess(double skillLevel, double maxProbability, double maxLevel) {
//return (int) (x / (y / LINEAR_CURVE_VAR));
return (int) (maxProbability * (skillLevel/maxLevel));
return (int) (maxProbability * (skillLevel / maxLevel));
// max probability * (weight/maxlevel) = chance of success
}
private static int getChanceOfSuccess(double x, double y)
{
private static int getChanceOfSuccess(double x, double y) {
return (int) (x / (y / LINEAR_CURVE_VAR));
// max probability * (weight/maxlevel) = chance of success
}
public static double getRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType, boolean hasCap)
{
public static double getRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType, boolean hasCap) {
RandomChanceSkill rcs = new RandomChanceSkill(player, subSkillType, hasCap);
return calculateChanceOfSuccess(rcs);
}
public static double getRandomStaticChanceExecutionSuccess(Player player, SubSkillType subSkillType)
{
public static double getRandomStaticChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
try {
return getRandomChanceExecutionChance(new RandomChanceSkillStatic(getStaticRandomChance(subSkillType), player, subSkillType));
} catch (InvalidStaticChance invalidStaticChance) {
@@ -207,18 +198,15 @@ public class RandomChanceUtil
return 0.1337; //Puts on shades
}
public static boolean checkRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType, boolean hasCap)
{
public static boolean checkRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType, boolean hasCap) {
return checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, hasCap));
}
public static boolean checkRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType)
{
public static boolean checkRandomChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
return checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType));
}
public static boolean checkRandomStaticChanceExecutionSuccess(Player player, SubSkillType subSkillType)
{
public static boolean checkRandomStaticChanceExecutionSuccess(Player player, SubSkillType subSkillType) {
try {
return checkRandomChanceExecutionSuccess(new RandomChanceSkillStatic(getStaticRandomChance(subSkillType), player, subSkillType));
} catch (InvalidStaticChance invalidStaticChance) {
@@ -231,14 +219,13 @@ public class RandomChanceUtil
/**
* Grabs static activation rolls for Secondary Abilities
*
* @param subSkillType The secondary ability to grab properties of
* @throws InvalidStaticChance if the skill has no defined static chance this exception will be thrown and you should know you're a naughty boy
* @return The static activation roll involved in the RNG calculation
* @throws InvalidStaticChance if the skill has no defined static chance this exception will be thrown and you should know you're a naughty boy
*/
public static double getStaticRandomChance(SubSkillType subSkillType) throws InvalidStaticChance
{
switch(subSkillType)
{
public static double getStaticRandomChance(SubSkillType subSkillType) throws InvalidStaticChance {
switch (subSkillType) {
case AXES_ARMOR_IMPACT:
return AdvancedConfig.getInstance().getImpactChance();
case AXES_GREATER_IMPACT:
@@ -250,8 +237,7 @@ public class RandomChanceUtil
}
}
public static boolean sendSkillEvent(Player player, SubSkillType subSkillType, double activationChance)
{
public static boolean sendSkillEvent(Player player, SubSkillType subSkillType, double activationChance) {
SubSkillRandomCheckEvent event = new SubSkillRandomCheckEvent(player, subSkillType, activationChance);
return !event.isCancelled();
}
@@ -262,8 +248,7 @@ public class RandomChanceUtil
return (event.getChance() * activationChance) > (Misc.getRandom().nextDouble() * activationChance) && !event.isCancelled();
}*/
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, AbstractSubSkill abstractSubSkill, Player player)
{
public static boolean isActivationSuccessful(SkillActivationType skillActivationType, AbstractSubSkill abstractSubSkill, Player player) {
return isActivationSuccessful(skillActivationType, abstractSubSkill.getSubSkillType(), player);
}
@@ -311,17 +296,15 @@ public class RandomChanceUtil
return displayValues;
}
public static double addLuck(Player player, PrimarySkillType primarySkillType, double chance)
{
if(Permissions.lucky(player, primarySkillType))
public static double addLuck(Player player, PrimarySkillType primarySkillType, double chance) {
if (Permissions.lucky(player, primarySkillType))
return chance * 1.333D;
else
return chance;
}
public static double addLuck(boolean isLucky, double chance)
{
if(isLucky)
public static double addLuck(boolean isLucky, double chance) {
if (isLucky)
return chance * 1.333D;
else
return chance;

View File

@@ -43,9 +43,10 @@ public class ScoreboardManager {
static final String LABEL_ABILITY_COOLDOWN = LocaleLoader.getString("Scoreboard.Misc.Cooldown");
static final String LABEL_OVERALL = LocaleLoader.getString("Scoreboard.Misc.Overall");
static final Map<PrimarySkillType, String> skillLabels;
static final Map<PrimarySkillType, String> skillLabels;
static final Map<SuperAbilityType, String> abilityLabelsColored;
static final Map<SuperAbilityType, String> abilityLabelsSkill;
private static List<String> dirtyPowerLevels = new ArrayList<>();
/*
* Initializes the static properties of this class
@@ -128,17 +129,6 @@ public class ScoreboardManager {
abilityLabelsSkill = abilityLabelSkillBuilder.build();
}
private static List<String> dirtyPowerLevels = new ArrayList<>();
public enum SidebarType {
NONE,
SKILL_BOARD,
STATS_BOARD,
COOLDOWNS_BOARD,
RANK_BOARD,
TOP_BOARD
}
private static String formatAbility(String abilityName) {
return formatAbility(ChatColor.AQUA, abilityName);
}
@@ -146,8 +136,7 @@ public class ScoreboardManager {
private static String formatAbility(ChatColor color, String abilityName) {
if (mcMMO.getScoreboardSettings().getUseAbilityNamesOverGenerics()) {
return getShortenedName(color + abilityName);
}
else {
} else {
return color + LocaleLoader.getString("Scoreboard.Misc.Ability");
}
}
@@ -164,14 +153,14 @@ public class ScoreboardManager {
return name;
}
// **** Listener call-ins **** //
// Called by PlayerJoinEvent listener
public static void setupPlayer(Player player) {
PLAYER_SCOREBOARDS.put(player.getName(), ScoreboardWrapper.create(player));
dirtyPowerLevels.add(player.getName());
}
// **** Listener call-ins **** //
// Called by PlayerQuitEvent listener
public static void teardownPlayer(Player player) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.remove(player.getName());
@@ -246,8 +235,6 @@ public class ScoreboardManager {
}
}
// **** Setup methods **** //
public static void enablePlayerSkillScoreboard(Player player, PrimarySkillType skill) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
@@ -257,6 +244,8 @@ public class ScoreboardManager {
changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.SKILL_BOARD));
}
// **** Setup methods **** //
public static void enablePlayerSkillLevelUpScoreboard(Player player, PrimarySkillType skill) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
@@ -338,8 +327,6 @@ public class ScoreboardManager {
changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD));
}
// **** Helper methods **** //
/**
* @return false if power levels are disabled
*/
@@ -371,6 +358,8 @@ public class ScoreboardManager {
return true;
}
// **** Helper methods **** //
/**
* Gets or creates the power level objective on the main targetBoard.
* <p/>
@@ -405,8 +394,7 @@ public class ScoreboardManager {
private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
if (displayTime == -1) {
wrapper.showBoardWithNoRevert();
}
else {
} else {
wrapper.showBoardAndScheduleRevert(displayTime * Misc.TICK_CONVERSION_FACTOR);
}
}
@@ -426,4 +414,13 @@ public class ScoreboardManager {
public static void setRevertTimer(String playerName, int seconds) {
PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert(seconds * Misc.TICK_CONVERSION_FACTOR);
}
public enum SidebarType {
NONE,
SKILL_BOARD,
STATS_BOARD,
COOLDOWNS_BOARD,
RANK_BOARD,
TOP_BOARD
}
}

View File

@@ -30,20 +30,21 @@ public class ScoreboardWrapper {
public final String playerName;
public final Player player;
private final Scoreboard scoreboard;
public String targetPlayer = null;
public PrimarySkillType targetSkill = null;
public int leaderboardPage = -1;
public BukkitTask updateTask = null;
public BukkitTask revertTask = null;
public BukkitTask cooldownTask = null;
private boolean tippedKeep = false;
private boolean tippedClear = false;
// Internal usage variables (should exist)
private SidebarType sidebarType;
private Objective sidebarObjective;
private Objective powerObjective;
// Parameter variables (May be null / invalid)
private Scoreboard oldBoard = null;
public String targetPlayer = null;
public PrimarySkillType targetSkill = null;
private PlayerProfile targetProfile = null;
public int leaderboardPage = -1;
private ScoreboardWrapper(Player player, Scoreboard scoreboard) {
this.player = player;
@@ -71,42 +72,6 @@ public class ScoreboardWrapper {
return new ScoreboardWrapper(event.getTargetPlayer(), event.getTargetBoard());
}
public BukkitTask updateTask = null;
private class ScoreboardQuickUpdate extends BukkitRunnable {
@Override
public void run() {
updateSidebar();
updateTask = null;
}
}
public BukkitTask revertTask = null;
private class ScoreboardChangeTask extends BukkitRunnable {
@Override
public void run() {
tryRevertBoard();
revertTask = null;
}
}
public BukkitTask cooldownTask = null;
private class ScoreboardCooldownTask extends BukkitRunnable {
@Override
public void run() {
// Stop updating if it's no longer something displaying cooldowns
if (isBoardShown() && (isSkillScoreboard() || isCooldownScoreboard())) {
doSidebarUpdateSoon();
}
else {
stopCooldownUpdating();
}
}
}
public void doSidebarUpdateSoon() {
if (updateTask == null) {
// To avoid spamming the scheduler, store the instance and run 2 ticks later
@@ -126,8 +91,7 @@ public class ScoreboardWrapper {
if (cooldownTask != null) {
try {
cooldownTask.cancel();
}
catch (Throwable ignored) {
} catch (Throwable ignored) {
}
cooldownTask = null;
@@ -164,8 +128,7 @@ public class ScoreboardWrapper {
// (Shouldn't happen) Use failsafe value - we're already displaying our board, but we don't have the one we should revert to
this.oldBoard = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard();
}
}
else {
} else {
this.oldBoard = oldBoard;
}
}
@@ -204,7 +167,7 @@ public class ScoreboardWrapper {
// TODO is there any way to do the time that looks acceptable?
// player.sendMessage(LocaleLoader.getString("Commands.ConfigScoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F));
if(UserManager.getPlayer(playerName) == null)
if (UserManager.getPlayer(playerName) == null)
return;
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
@@ -216,8 +179,7 @@ public class ScoreboardWrapper {
if (!tippedKeep) {
tippedKeep = true;
player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Keep"));
}
else if (!tippedClear) {
} else if (!tippedClear) {
tippedClear = true;
player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Clear"));
profile.increaseTipsShown();
@@ -242,8 +204,7 @@ public class ScoreboardWrapper {
//Modify the player based on the event
event.getTargetPlayer().setScoreboard(event.getTargetBoard());
oldBoard = null;
}
else {
} else {
mcMMO.p.debug("Not reverting targetBoard for " + playerName + " - targetBoard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)");
}
}
@@ -277,8 +238,6 @@ public class ScoreboardWrapper {
revertTask = null;
}
// Board Type Changing 'API' methods
public void setTypeNone() {
this.sidebarType = SidebarType.NONE;
@@ -312,6 +271,8 @@ public class ScoreboardWrapper {
loadObjective(ScoreboardManager.HEADER_STATS);
}
// Board Type Changing 'API' methods
public void setTypeInspectStats(PlayerProfile profile) {
this.sidebarType = SidebarType.STATS_BOARD;
targetPlayer = profile.getPlayerName();
@@ -386,13 +347,13 @@ public class ScoreboardWrapper {
protected void loadObjective(String displayName) {
//Unregister objective
McMMOScoreboardObjectiveEvent unregisterEvent = callObjectiveEvent(ScoreboardObjectiveEventReason.UNREGISTER_THIS_OBJECTIVE);
if(!unregisterEvent.isCancelled()) {
if (!unregisterEvent.isCancelled()) {
sidebarObjective.unregister();
}
//Register objective
McMMOScoreboardObjectiveEvent registerEvent = callObjectiveEvent(ScoreboardObjectiveEventReason.REGISTER_NEW_OBJECTIVE);
if(!registerEvent.isCancelled())
if (!registerEvent.isCancelled())
sidebarObjective = registerEvent.getTargetBoard().registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
if (displayName.length() > 32) {
@@ -418,8 +379,7 @@ public class ScoreboardWrapper {
private void updateSidebar() {
try {
updateTask.cancel();
}
catch (Throwable ignored) {
} catch (Throwable ignored) {
} // catch NullPointerException and IllegalStateException and any Error; don't care
updateTask = null;
@@ -437,7 +397,7 @@ public class ScoreboardWrapper {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if(mcMMOPlayer == null)
if (mcMMOPlayer == null)
return;
switch (sidebarType) {
@@ -450,8 +410,7 @@ public class ScoreboardWrapper {
sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(mcMMOPlayer.getXpToLevel(targetSkill) - currentXP);
}
else {
} else {
for (PrimarySkillType parentSkill : FamilyTree.getParents(targetSkill)) {
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(mcMMOPlayer.getSkillLevel(parentSkill));
}
@@ -473,8 +432,7 @@ public class ScoreboardWrapper {
cooldownBM.setScore(secondsBM);
stopUpdating = (secondsSB == 0 && secondsBM == 0);
}
else {
} else {
SuperAbilityType ability = targetSkill.getAbility();
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
int seconds = Math.max(mcMMOPlayer.calculateTimeRemaining(ability), 0);
@@ -486,8 +444,7 @@ public class ScoreboardWrapper {
if (stopUpdating) {
stopCooldownUpdating();
}
else {
} else {
startCooldownUpdating();
}
}
@@ -508,8 +465,7 @@ public class ScoreboardWrapper {
if (anyCooldownsActive) {
startCooldownUpdating();
}
else {
} else {
stopCooldownUpdating();
}
break;
@@ -520,11 +476,9 @@ public class ScoreboardWrapper {
if (targetProfile != null) {
newProfile = targetProfile; // offline
}
else if (targetPlayer == null) {
} else if (targetPlayer == null) {
newProfile = mcMMOPlayer.getProfile(); // self
}
else {
} else {
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
}
@@ -548,10 +502,10 @@ public class ScoreboardWrapper {
case RANK_BOARD:
case TOP_BOARD:
/*
* @see #acceptRankData(Map<PrimarySkillType, Integer> rank)
* @see #acceptLeaderboardData(List<PlayerStat> stats)
*/
/*
* @see #acceptRankData(Map<PrimarySkillType, Integer> rank)
* @see #acceptLeaderboardData(List<PlayerStat> stats)
*/
break;
default:
@@ -597,4 +551,32 @@ public class ScoreboardWrapper {
public void updatePowerLevel(Player player, int newPowerLevel) {
powerObjective.getScore(player.getName()).setScore(newPowerLevel);
}
private class ScoreboardQuickUpdate extends BukkitRunnable {
@Override
public void run() {
updateSidebar();
updateTask = null;
}
}
private class ScoreboardChangeTask extends BukkitRunnable {
@Override
public void run() {
tryRevertBoard();
revertTask = null;
}
}
private class ScoreboardCooldownTask extends BukkitRunnable {
@Override
public void run() {
// Stop updating if it's no longer something displaying cooldowns
if (isBoardShown() && (isSkillScoreboard() || isCooldownScoreboard())) {
doSidebarUpdateSoon();
} else {
stopCooldownUpdating();
}
}
}
}

View File

@@ -37,13 +37,14 @@ import java.util.HashMap;
import java.util.Map;
public final class CombatUtils {
private CombatUtils() {}
private CombatUtils() {
}
private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
double initialDamage = event.getDamage();
@@ -55,26 +56,23 @@ public final class CombatUtils {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.SWORDS);
}
if(target.getHealth() - event.getFinalDamage() >= 1)
{
if (target.getHealth() - event.getFinalDamage() >= 1) {
if (swordsManager.canUseRupture()) {
swordsManager.ruptureCheck(target);
}
}
//Add Stab Damage
if(swordsManager.canUseStab())
{
finalDamage+=swordsManager.getStabDamage();
if (swordsManager.canUseStab()) {
finalDamage += swordsManager.getStabDamage();
}
if (swordsManager.canUseSerratedStrike()) {
swordsManager.serratedStrikes(target, initialDamage, modifiers);
}
if(canUseLimitBreak(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK))
{
finalDamage+=getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK);
if (canUseLimitBreak(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK)) {
finalDamage += getLimitBreakDamage(player, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK);
}
applyScaledModifiers(initialDamage, finalDamage, event);
@@ -85,7 +83,7 @@ public final class CombatUtils {
if (event.getCause() == DamageCause.THORNS) {
return;
}
double initialDamage = event.getDamage();
double finalDamage = initialDamage;
Map<DamageModifier, Double> modifiers = getModifiers(event);
@@ -98,14 +96,13 @@ public final class CombatUtils {
}
if (axesManager.canUseAxeMastery()) {
finalDamage+=axesManager.axeMastery();
finalDamage += axesManager.axeMastery();
}
if (axesManager.canImpact(target)) {
axesManager.impactCheck(target);
}
else if (axesManager.canGreaterImpact(target)) {
finalDamage+=axesManager.greaterImpact(target);
} else if (axesManager.canGreaterImpact(target)) {
finalDamage += axesManager.greaterImpact(target);
}
if (axesManager.canUseSkullSplitter(target)) {
@@ -113,12 +110,11 @@ public final class CombatUtils {
}
if (axesManager.canCriticalHit(target)) {
finalDamage+=axesManager.criticalHit(target, finalDamage);
finalDamage += axesManager.criticalHit(target, finalDamage);
}
if(canUseLimitBreak(player, SubSkillType.AXES_AXES_LIMIT_BREAK))
{
finalDamage+=getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK);
if (canUseLimitBreak(player, SubSkillType.AXES_AXES_LIMIT_BREAK)) {
finalDamage += getLimitBreakDamage(player, SubSkillType.AXES_AXES_LIMIT_BREAK);
}
applyScaledModifiers(initialDamage, finalDamage, event);
@@ -140,24 +136,22 @@ public final class CombatUtils {
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.UNARMED);
}
if(unarmedManager.isPunchingCooldownOver())
{
if (unarmedManager.isPunchingCooldownOver()) {
//Only execute bonuses if the player is not spamming
if (unarmedManager.canUseIronArm()) {
finalDamage+=unarmedManager.ironArm();
finalDamage += unarmedManager.ironArm();
}
if (unarmedManager.canUseBerserk()) {
finalDamage+=unarmedManager.berserkDamage(finalDamage);
finalDamage += unarmedManager.berserkDamage(finalDamage);
}
if (unarmedManager.canDisarm(target)) {
unarmedManager.disarmCheck((Player) target);
}
if(canUseLimitBreak(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK))
{
finalDamage+=getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK);
if (canUseLimitBreak(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK)) {
finalDamage += getLimitBreakDamage(player, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK);
}
}
@@ -180,11 +174,11 @@ public final class CombatUtils {
tamingManager.pummel(target, wolf);
if (tamingManager.canUseSharpenedClaws()) {
finalDamage+=tamingManager.getSharpenedClawsDamage();
finalDamage += tamingManager.getSharpenedClawsDamage();
}
if (tamingManager.canUseGore()) {
finalDamage+=tamingManager.gore(target, initialDamage);
finalDamage += tamingManager.gore(target, initialDamage);
}
applyScaledModifiers(initialDamage, finalDamage, event);
@@ -196,7 +190,7 @@ public final class CombatUtils {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
double finalDamage = event.getDamage();
if (target instanceof Player && PrimarySkillType.UNARMED.getPVPEnabled()) {
@@ -212,20 +206,19 @@ public final class CombatUtils {
}
if (archeryManager.canSkillShot()) {
finalDamage+=archeryManager.skillShot(initialDamage);
finalDamage += archeryManager.skillShot(initialDamage);
}
if (archeryManager.canDaze(target)) {
finalDamage+=archeryManager.daze((Player) target);
finalDamage += archeryManager.daze((Player) target);
}
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) {
archeryManager.retrieveArrows(target);
}
if(canUseLimitBreak(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK))
{
finalDamage+=getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
if (canUseLimitBreak(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) {
finalDamage += getLimitBreakDamage(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
}
double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
@@ -305,8 +298,7 @@ public final class CombatUtils {
if (PrimarySkillType.SWORDS.getPermissions(player)) {
processSwordCombat(target, player, event);
}
}
else if (ItemUtils.isAxe(heldItem)) {
} else if (ItemUtils.isAxe(heldItem)) {
if (!PrimarySkillType.AXES.shouldProcess(target)) {
return;
}
@@ -314,8 +306,7 @@ public final class CombatUtils {
if (PrimarySkillType.AXES.getPermissions(player)) {
processAxeCombat(target, player, event);
}
}
else if (ItemUtils.isUnarmed(heldItem)) {
} else if (ItemUtils.isUnarmed(heldItem)) {
if (!PrimarySkillType.UNARMED.shouldProcess(target)) {
return;
}
@@ -324,9 +315,7 @@ public final class CombatUtils {
processUnarmedCombat(target, player, event);
}
}
}
else if (entityType == EntityType.WOLF) {
} else if (entityType == EntityType.WOLF) {
Wolf wolf = (Wolf) damager;
AnimalTamer tamer = wolf.getOwner();
@@ -337,8 +326,7 @@ public final class CombatUtils {
processTamingCombat(target, master, wolf, event);
}
}
}
else if (entityType == EntityType.ARROW) {
} else if (entityType == EntityType.ARROW) {
Arrow arrow = (Arrow) damager;
ProjectileSource projectileSource = arrow.getShooter();
@@ -364,6 +352,7 @@ public final class CombatUtils {
/**
* Checks if player has access to their weapons limit break
*
* @param player target player
* @return true if the player has access to the limit break
*/
@@ -386,8 +375,8 @@ public final class CombatUtils {
/**
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
*
* @param target LivingEntity which to attempt to damage
* @param damage Amount of damage to attempt to do
* @param target LivingEntity which to attempt to damage
* @param damage Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
@Deprecated
@@ -398,8 +387,8 @@ public final class CombatUtils {
/**
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
*
* @param target LivingEntity which to attempt to damage
* @param damage Amount of damage to attempt to do
* @param target LivingEntity which to attempt to damage
* @param damage Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
public static void dealDamage(LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, LivingEntity attacker) {
@@ -414,8 +403,8 @@ public final class CombatUtils {
/**
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
*
* @param target LivingEntity which to attempt to damage
* @param damage Amount of damage to attempt to do
* @param target LivingEntity which to attempt to damage
* @param damage Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
@Deprecated
@@ -424,7 +413,7 @@ public final class CombatUtils {
return;
}
if(canDamage(attacker, target, cause, damage))
if (canDamage(attacker, target, cause, damage))
target.damage(damage);
}
@@ -437,11 +426,9 @@ public final class CombatUtils {
double newHealth = Math.max(0, target.getHealth() - incDmg);
if(newHealth == 0)
{
if (newHealth == 0) {
target.damage(9999, attacker);
}
else
} else
target.setHealth(newHealth);
}
@@ -487,9 +474,9 @@ public final class CombatUtils {
* Apply Area-of-Effect ability actions.
*
* @param attacker The attacking player
* @param target The defending entity
* @param damage The initial damage amount
* @param type The type of skill being used
* @param target The defending entity
* @param damage The initial damage amount
* @param type The type of skill being used
*/
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, PrimarySkillType type) {
int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit
@@ -510,7 +497,7 @@ public final class CombatUtils {
switch (type) {
case SWORDS:
if (entity instanceof Player) {
NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
NotificationManager.sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
}
UserManager.getPlayer(attacker).getSwordsManager().ruptureCheck(target);
@@ -518,7 +505,7 @@ public final class CombatUtils {
case AXES:
if (entity instanceof Player) {
NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.SS.Struck");
NotificationManager.sendPlayerInformation((Player) entity, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.SS.Struck");
}
break;
@@ -539,8 +526,8 @@ public final class CombatUtils {
/**
* Start the task that gives combat XP.
*
* @param mcMMOPlayer The attacking player
* @param target The defending entity
* @param mcMMOPlayer The attacking player
* @param target The defending entity
* @param primarySkillType The skill being used
*/
private static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, PrimarySkillType primarySkillType, double multiplier) {
@@ -558,8 +545,7 @@ public final class CombatUtils {
if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
baseXP = 20 * ExperienceConfig.getInstance().getPlayerVersusPlayerXP();
}
}
else {
} else {
/*if (mcMMO.getModManager().isCustomEntity(target)) {
baseXP = mcMMO.getModManager().getEntity(target).getXpMultiplier();
}*/
@@ -567,29 +553,21 @@ public final class CombatUtils {
if (target instanceof Animals) {
EntityType type = target.getType();
baseXP = ExperienceConfig.getInstance().getAnimalsXP(type);
}
else if (target instanceof Monster)
{
} else if (target instanceof Monster) {
EntityType type = target.getType();
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
else {
} else {
EntityType type = target.getType();
if (ExperienceConfig.getInstance().hasCombatXP(type)) {
if (type == EntityType.IRON_GOLEM)
{
if (type == EntityType.IRON_GOLEM) {
if (!((IronGolem) target).isPlayerCreated()) {
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
}
else
{
} else {
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
}
else
{
} else {
baseXP = 1.0;
//mcMMO.getModManager().addCustomEntity(target);
}
@@ -627,7 +605,7 @@ public final class CombatUtils {
Player defender = (Player) entity;
//TODO: NPC Interaction?
if(UserManager.getPlayer(defender) == null)
if (UserManager.getPlayer(defender) == null)
return true;
if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getGodMode()) {
@@ -642,7 +620,7 @@ public final class CombatUtils {
if (!player.canSee(defender)) {
return false;
}
// Spectators should not be affected
if (defender.getGameMode() == GameMode.SPECTATOR) {
return false;
@@ -652,8 +630,7 @@ public final class CombatUtils {
if (getFakeDamageFinalResult(player, entity, 1.0) == 0) {
return false;
}
}
else if (entity instanceof Tameable) {
} else if (entity instanceof Tameable) {
if (isFriendlyPet(player, (Tameable) entity)) {
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
// So we can make some assumptions here, about our casting and our check
@@ -670,7 +647,7 @@ public final class CombatUtils {
/**
* Checks to see if an entity is currently invincible.
*
* @param entity The {@link LivingEntity} to check
* @param entity The {@link LivingEntity} to check
* @param eventDamage The damage from the event the entity is involved in
* @return true if the entity is invincible, false otherwise
*/
@@ -686,7 +663,7 @@ public final class CombatUtils {
* Checks to see if an entity is currently friendly toward a given player.
*
* @param attacker The player to check.
* @param pet The entity to check.
* @param pet The entity to check.
* @return true if the entity is friendly, false otherwise
*/
public static boolean isFriendlyPet(Player attacker, Tameable pet) {
@@ -810,17 +787,13 @@ public final class CombatUtils {
if (ItemUtils.isWoodTool(inHand)) {
tier = 1;
}
else if (ItemUtils.isStoneTool(inHand)) {
} else if (ItemUtils.isStoneTool(inHand)) {
tier = 2;
}
else if (ItemUtils.isIronTool(inHand)) {
} else if (ItemUtils.isIronTool(inHand)) {
tier = 3;
}
else if (ItemUtils.isGoldTool(inHand)) {
} else if (ItemUtils.isGoldTool(inHand)) {
tier = 1;
}
else if (ItemUtils.isDiamondTool(inHand)) {
} else if (ItemUtils.isDiamondTool(inHand)) {
tier = 4;
}
/*else if (mcMMO.getModManager().isCustomTool(inHand)) {

View File

@@ -12,7 +12,8 @@ import org.bukkit.entity.Player;
public final class ParticleEffectUtils {
private ParticleEffectUtils() {}
private ParticleEffectUtils() {
}
public static void playBleedEffect(LivingEntity livingEntity) {
if (!MainConfig.getInstance().getBleedEffectEnabled()) {

View File

@@ -9,16 +9,15 @@ public final class PerksUtils {
private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
private PerksUtils() {}
private PerksUtils() {
}
public static int handleCooldownPerks(Player player, int cooldown) {
if (Permissions.halvedCooldowns(player)) {
cooldown *= 0.5;
}
else if (Permissions.thirdedCooldowns(player)) {
} else if (Permissions.thirdedCooldowns(player)) {
cooldown *= (2.0 / 3.0);
}
else if (Permissions.quarteredCooldowns(player)) {
} else if (Permissions.quarteredCooldowns(player)) {
cooldown *= 0.75;
}
@@ -32,11 +31,9 @@ public final class PerksUtils {
if (Permissions.twelveSecondActivationBoost(player)) {
ticks += 12;
}
else if (Permissions.eightSecondActivationBoost(player)) {
} else if (Permissions.eightSecondActivationBoost(player)) {
ticks += 8;
}
else if (Permissions.fourSecondActivationBoost(player)) {
} else if (Permissions.fourSecondActivationBoost(player)) {
ticks += 4;
}
@@ -46,23 +43,17 @@ public final class PerksUtils {
public static float handleXpPerks(Player player, float xp, PrimarySkillType skill) {
if (Permissions.customXpBoost(player, skill)) {
xp *= ExperienceConfig.getInstance().getCustomXpPerkBoost();
}
else if (Permissions.quadrupleXp(player, skill)) {
} else if (Permissions.quadrupleXp(player, skill)) {
xp *= 4;
}
else if (Permissions.tripleXp(player, skill)) {
} else if (Permissions.tripleXp(player, skill)) {
xp *= 3;
}
else if (Permissions.doubleAndOneHalfXp(player, skill)) {
} else if (Permissions.doubleAndOneHalfXp(player, skill)) {
xp *= 2.5;
}
else if (Permissions.doubleXp(player, skill)) {
} else if (Permissions.doubleXp(player, skill)) {
xp *= 2;
}
else if (Permissions.oneAndOneHalfXp(player, skill)) {
} else if (Permissions.oneAndOneHalfXp(player, skill)) {
xp *= 1.5;
}
else if (Permissions.oneAndOneTenthXp(player, skill)) {
} else if (Permissions.oneAndOneTenthXp(player, skill)) {
xp *= 1.1;
}
@@ -73,7 +64,7 @@ public final class PerksUtils {
* Calculate activation chance for a skill.
*
* @param player Player to check the activation chance for
* @param skill PrimarySkillType to check the activation chance of
* @param skill PrimarySkillType to check the activation chance of
* @return the activation chance with "lucky perk" accounted for
*/
public static int handleLuckyPerks(Player player, PrimarySkillType skill) {

View File

@@ -19,27 +19,23 @@ public class RankUtils {
private static int count = 0;
/**
*
* @param plugin plugin instance ref
* @param mcMMOPlayer target player
* @param plugin plugin instance ref
* @param mcMMOPlayer target player
* @param primarySkillType
* @param newLevel the new level of this skill
* @param newLevel the new level of this skill
*/
public static void executeSkillUnlockNotifications(Plugin plugin, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, int newLevel)
{
for(SubSkillType subSkillType : primarySkillType.getSkillAbilities())
{
public static void executeSkillUnlockNotifications(Plugin plugin, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType, int newLevel) {
for (SubSkillType subSkillType : primarySkillType.getSkillAbilities()) {
int playerRankInSkill = getRank(mcMMOPlayer.getPlayer(), subSkillType);
HashMap<Integer, Integer> innerMap = subSkillRanks.get(subSkillType.toString());
//If the skill doesn't have registered ranks gtfo
if(innerMap == null || innerMap.get(playerRankInSkill) == null)
if (innerMap == null || innerMap.get(playerRankInSkill) == null)
continue;
//The players level is the exact level requirement for this skill
if(newLevel == innerMap.get(playerRankInSkill))
{
if (newLevel == innerMap.get(playerRankInSkill)) {
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel);
skillUnlockNotificationTask.runTaskLater(plugin, (count * 100));
@@ -49,32 +45,27 @@ public class RankUtils {
}
}
public static void resetUnlockDelayTimer()
{
public static void resetUnlockDelayTimer() {
count = 0;
}
/* NEW SYSTEM */
private static void addRanks(AbstractSubSkill abstractSubSkill)
{
private static void addRanks(AbstractSubSkill abstractSubSkill) {
//Fill out the rank array
for(int i = 0; i < abstractSubSkill.getNumRanks(); i++)
{
for (int i = 0; i < abstractSubSkill.getNumRanks(); i++) {
//This adds the highest ranks first
addRank(abstractSubSkill, abstractSubSkill.getNumRanks()-i);
addRank(abstractSubSkill, abstractSubSkill.getNumRanks() - i);
//TODO: Remove debug code
/*System.out.println("DEBUG: Adding rank "+(numRanks-i)+" to "+subSkillType.toString());*/
}
}
private static void addRanks(SubSkillType subSkillType)
{
private static void addRanks(SubSkillType subSkillType) {
//Fill out the rank array
for(int i = 0; i < subSkillType.getNumRanks(); i++)
{
for (int i = 0; i < subSkillType.getNumRanks(); i++) {
//This adds the highest ranks first
addRank(subSkillType, subSkillType.getNumRanks()-i);
addRank(subSkillType, subSkillType.getNumRanks() - i);
//TODO: Remove debug code
/*System.out.println("DEBUG: Adding rank "+(numRanks-i)+" to "+subSkillType.toString());*/
@@ -84,27 +75,24 @@ public class RankUtils {
/**
* Populates the ranks for every skill we know about
*/
public static void populateRanks()
{
for(SubSkillType subSkillType : SubSkillType.values())
{
public static void populateRanks() {
for (SubSkillType subSkillType : SubSkillType.values()) {
addRanks(subSkillType);
}
for(AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList())
{
for (AbstractSubSkill abstractSubSkill : InteractionManager.getSubSkillList()) {
addRanks(abstractSubSkill);
}
}
/**
* Returns whether or not the player has unlocked the first rank in target subskill
* @param player the player
*
* @param player the player
* @param subSkillType the target subskill
* @return true if the player has at least one rank in the skill
*/
public static boolean hasUnlockedSubskill(Player player, SubSkillType subSkillType)
{
public static boolean hasUnlockedSubskill(Player player, SubSkillType subSkillType) {
int curRank = getRank(player, subSkillType);
//-1 means the skill has no unlockable levels and is therefor unlocked
@@ -113,12 +101,12 @@ public class RankUtils {
/**
* Returns whether or not the player has unlocked the first rank in target subskill
* @param player the player
*
* @param player the player
* @param abstractSubSkill the target subskill
* @return true if the player has at least one rank in the skill
*/
public static boolean hasUnlockedSubskill(Player player, AbstractSubSkill abstractSubSkill)
{
public static boolean hasUnlockedSubskill(Player player, AbstractSubSkill abstractSubSkill) {
int curRank = getRank(player, abstractSubSkill);
//-1 means the skill has no unlockable levels and is therefor unlocked
@@ -127,69 +115,68 @@ public class RankUtils {
/**
* Returns whether or not the player has reached the specified rank in target subskill
* @param rank the target rank
* @param player the player
*
* @param rank the target rank
* @param player the player
* @param subSkillType the target subskill
* @return true if the player is at least that rank in this subskill
*/
public static boolean hasReachedRank(int rank, Player player, SubSkillType subSkillType)
{
public static boolean hasReachedRank(int rank, Player player, SubSkillType subSkillType) {
return getRank(player, subSkillType) >= rank;
}
/**
* Returns whether or not the player has reached the specified rank in target subskill
* @param rank the target rank
* @param player the player
*
* @param rank the target rank
* @param player the player
* @param abstractSubSkill the target subskill
* @return true if the player is at least that rank in this subskill
*/
public static boolean hasReachedRank(int rank, Player player, AbstractSubSkill abstractSubSkill)
{
public static boolean hasReachedRank(int rank, Player player, AbstractSubSkill abstractSubSkill) {
return getRank(player, abstractSubSkill) >= rank;
}
/**
* Gets the current rank of the subskill for the player
* @param player The player in question
*
* @param player The player in question
* @param subSkillType Target subskill
* @return The rank the player currently has achieved in this skill. -1 for skills without ranks.
*/
public static int getRank(Player player, SubSkillType subSkillType)
{
public static int getRank(Player player, SubSkillType subSkillType) {
String skillName = subSkillType.toString();
int numRanks = subSkillType.getNumRanks();
if(subSkillRanks == null)
if (subSkillRanks == null)
subSkillRanks = new HashMap<>();
if(numRanks == 0)
if (numRanks == 0)
return -1; //-1 Means the skill doesn't have ranks
if(subSkillRanks.get(skillName) == null && numRanks > 0)
if (subSkillRanks.get(skillName) == null && numRanks > 0)
addRanks(subSkillType);
//Get our rank map
HashMap<Integer, Integer> rankMap = subSkillRanks.get(skillName);
if(UserManager.getPlayer(player) == null)
if (UserManager.getPlayer(player) == null)
return 0;
//Skill level of parent skill
int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(subSkillType.getParentSkill());
for(int i = 0; i < numRanks; i++)
{
for (int i = 0; i < numRanks; i++) {
//Compare against the highest to lowest rank in that order
int rank = numRanks-i;
int rank = numRanks - i;
int unlockLevel = getRankUnlockLevel(subSkillType, rank);
//If we check all ranks and still cannot unlock the skill, we return rank 0
if(rank == 0)
if (rank == 0)
return 0;
//True if our skill level can unlock the current rank
if(currentSkillLevel >= unlockLevel)
if (currentSkillLevel >= unlockLevel)
return rank;
}
@@ -198,45 +185,44 @@ public class RankUtils {
/**
* Gets the current rank of the subskill for the player
* @param player The player in question
*
* @param player The player in question
* @param abstractSubSkill Target subskill
* @return The rank the player currently has achieved in this skill. -1 for skills without ranks.
*/
public static int getRank(Player player, AbstractSubSkill abstractSubSkill)
{
public static int getRank(Player player, AbstractSubSkill abstractSubSkill) {
String skillName = abstractSubSkill.getConfigKeyName();
int numRanks = abstractSubSkill.getNumRanks();
if(subSkillRanks == null)
if (subSkillRanks == null)
subSkillRanks = new HashMap<>();
if(numRanks == 0)
if (numRanks == 0)
return -1; //-1 Means the skill doesn't have ranks
if(subSkillRanks.get(skillName) == null && numRanks > 0)
if (subSkillRanks.get(skillName) == null && numRanks > 0)
addRanks(abstractSubSkill);
//Get our rank map
HashMap<Integer, Integer> rankMap = subSkillRanks.get(skillName);
if(UserManager.getPlayer(player) == null)
if (UserManager.getPlayer(player) == null)
return 0;
//Skill level of parent skill
int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(abstractSubSkill.getPrimarySkill());
for(int i = 0; i < numRanks; i++)
{
for (int i = 0; i < numRanks; i++) {
//Compare against the highest to lowest rank in that order
int rank = numRanks-i;
int rank = numRanks - i;
int unlockLevel = getRankUnlockLevel(abstractSubSkill, rank);
//If we check all ranks and still cannot unlock the skill, we return rank 0
if(rank == 0)
if (rank == 0)
return 0;
//True if our skill level can unlock the current rank
if(currentSkillLevel >= unlockLevel)
if (currentSkillLevel >= unlockLevel)
return rank;
}
@@ -245,11 +231,11 @@ public class RankUtils {
/**
* Adds ranks to our map
*
* @param abstractSubSkill The subskill to add ranks for
* @param rank The rank to add
* @param rank The rank to add
*/
private static void addRank(AbstractSubSkill abstractSubSkill, int rank)
{
private static void addRank(AbstractSubSkill abstractSubSkill, int rank) {
initMaps(abstractSubSkill.getConfigKeyName());
HashMap<Integer, Integer> rankMap = subSkillRanks.get(abstractSubSkill.getConfigKeyName());
@@ -258,8 +244,7 @@ public class RankUtils {
}
@Deprecated
private static void addRank(SubSkillType subSkillType, int rank)
{
private static void addRank(SubSkillType subSkillType, int rank) {
initMaps(subSkillType.toString());
HashMap<Integer, Integer> rankMap = subSkillRanks.get(subSkillType.toString());
@@ -293,68 +278,65 @@ public class RankUtils {
/**
* Gets the unlock level for a specific rank in a subskill
*
* @param subSkillType The target subskill
* @param rank The target rank
* @param rank The target rank
* @return The level at which this rank unlocks
*/
@Deprecated
public static int getRankUnlockLevel(SubSkillType subSkillType, int rank)
{
public static int getRankUnlockLevel(SubSkillType subSkillType, int rank) {
return RankConfig.getInstance().getSubSkillUnlockLevel(subSkillType, rank);
}
public static int getRankUnlockLevel(AbstractSubSkill abstractSubSkill, int rank)
{
public static int getRankUnlockLevel(AbstractSubSkill abstractSubSkill, int rank) {
return RankConfig.getInstance().getSubSkillUnlockLevel(abstractSubSkill, rank);
}
/**
* Get the level at which a skill is unlocked for a player (this is the first rank of a skill)
*
* @param subSkillType target subskill
* @return The unlock requirements for rank 1 in this skill
*/
public static int getUnlockLevel(SubSkillType subSkillType)
{
public static int getUnlockLevel(SubSkillType subSkillType) {
return RankConfig.getInstance().getSubSkillUnlockLevel(subSkillType, 1);
}
/**
* Get the level at which a skill is unlocked for a player (this is the first rank of a skill)
*
* @param abstractSubSkill target subskill
* @return The unlock requirements for rank 1 in this skill
*/
public static int getUnlockLevel(AbstractSubSkill abstractSubSkill)
{
public static int getUnlockLevel(AbstractSubSkill abstractSubSkill) {
return RankConfig.getInstance().getSubSkillUnlockLevel(abstractSubSkill, 1);
}
/**
* Get the highest rank of a subskill
*
* @param subSkillType target subskill
* @return the last rank of a subskill
*/
public static int getHighestRank(SubSkillType subSkillType)
{
public static int getHighestRank(SubSkillType subSkillType) {
return subSkillType.getNumRanks();
}
public static String getHighestRankStr(SubSkillType subSkillType)
{
public static String getHighestRankStr(SubSkillType subSkillType) {
return String.valueOf(subSkillType.getNumRanks());
}
/**
* Get the highest rank of a subskill
*
* @param abstractSubSkill target subskill
* @return the last rank of a subskill
*/
public static int getHighestRank(AbstractSubSkill abstractSubSkill)
{
public static int getHighestRank(AbstractSubSkill abstractSubSkill) {
return abstractSubSkill.getNumRanks();
}
public static int getSuperAbilityUnlockRequirement(SuperAbilityType superAbilityType)
{
public static int getSuperAbilityUnlockRequirement(SuperAbilityType superAbilityType) {
return getRankUnlockLevel(superAbilityType.getSubSkillTypeDefinition(), 1);
}
}

View File

@@ -47,9 +47,8 @@ public class SkillUtils {
int length;
if(abilityLengthCap > 0)
{
length = (int) Math.min(abilityLengthCap, 2 + (skillValue / abilityLengthVar));
if (abilityLengthCap > 0) {
length = (int) Math.min(abilityLengthCap, 2 + (skillValue / abilityLengthVar));
} else {
length = 2 + (int) (skillValue / abilityLengthVar);
}
@@ -60,7 +59,7 @@ public class SkillUtils {
length = Math.min(length, maxLength);
}
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
return new String[]{String.valueOf(length), String.valueOf(enduranceLength)};
}
/*
@@ -73,7 +72,7 @@ public class SkillUtils {
int currentFoodLevel = player.getFoodLevel();
int foodChange = eventFoodLevel - currentFoodLevel;
foodChange+=curRank;
foodChange += curRank;
return currentFoodLevel + foodChange;
}
@@ -82,9 +81,8 @@ public class SkillUtils {
* Calculate the time remaining until the cooldown expires.
*
* @param deactivatedTimeStamp Time of deactivation
* @param cooldown The length of the cooldown
* @param player The Player to check for cooldown perks
*
* @param cooldown The length of the cooldown
* @param player The Player to check for cooldown perks
* @return the number of seconds remaining before the cooldown expires
*/
public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
@@ -96,8 +94,7 @@ public class SkillUtils {
* This does NOT account for cooldown perks!
*
* @param deactivatedTimeStamp Time of deactivation in seconds
* @param cooldown The length of the cooldown in seconds
*
* @param cooldown The length of the cooldown in seconds
* @return true if the cooldown is expired
*/
public static boolean cooldownExpired(long deactivatedTimeStamp, int cooldown) {
@@ -207,8 +204,7 @@ public class SkillUtils {
if (efficiencyLevel <= AdvancedConfig.getInstance().getEnchantBuff()) {
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
}
else {
} else {
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - AdvancedConfig.getInstance().getEnchantBuff(), true);
}
@@ -225,9 +221,9 @@ public class SkillUtils {
/**
* Modify the durability of an ItemStack.
*
* @param itemStack The ItemStack which durability should be modified
* @param itemStack The ItemStack which durability should be modified
* @param durabilityModifier the amount to modify the durability by
* @param maxDamageModifier the amount to adjust the max damage by
* @param maxDamageModifier the amount to adjust the max damage by
*/
public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier, double maxDamageModifier) {
if (itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) {
@@ -254,26 +250,19 @@ public class SkillUtils {
protected static Material getRepairAndSalvageItem(ItemStack inHand) {
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
return Material.DIAMOND;
}
else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) {
} else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) {
return Material.GOLD_INGOT;
}
else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) {
} else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) {
return Material.IRON_INGOT;
}
else if (ItemUtils.isStoneTool(inHand)) {
} else if (ItemUtils.isStoneTool(inHand)) {
return Material.COBBLESTONE;
}
else if (ItemUtils.isWoodTool(inHand)) {
} else if (ItemUtils.isWoodTool(inHand)) {
return Material.OAK_WOOD;
}
else if (ItemUtils.isLeatherArmor(inHand)) {
} else if (ItemUtils.isLeatherArmor(inHand)) {
return Material.LEATHER;
}
else if (ItemUtils.isStringTool(inHand)) {
} else if (ItemUtils.isStringTool(inHand)) {
return Material.STRING;
}
else {
} else {
return null;
}
}
@@ -302,8 +291,7 @@ public class SkillUtils {
quantity += ingredient.getAmount();
}
}
}
else if (recipe instanceof ShapedRecipe) {
} else if (recipe instanceof ShapedRecipe) {
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairMaterial))) {
quantity += ingredient.getAmount();

View File

@@ -11,47 +11,43 @@ import org.bukkit.entity.Player;
public class SoundManager {
/**
* Sends a sound to the player
*
* @param soundType the type of sound
*/
public static void sendSound(Player player, Location location, SoundType soundType)
{
if(SoundConfig.getInstance().getIsEnabled(soundType))
public static void sendSound(Player player, Location location, SoundType soundType) {
if (SoundConfig.getInstance().getIsEnabled(soundType))
player.playSound(location, getSound(soundType), SoundCategory.MASTER, getVolume(soundType), getPitch(soundType));
}
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory)
{
if(SoundConfig.getInstance().getIsEnabled(soundType))
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory) {
if (SoundConfig.getInstance().getIsEnabled(soundType))
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), getPitch(soundType));
}
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier)
{
public static void sendCategorizedSound(Player player, Location location, SoundType soundType, SoundCategory soundCategory, float pitchModifier) {
float totalPitch = Math.min(2.0F, (getPitch(soundType) + pitchModifier));
if(SoundConfig.getInstance().getIsEnabled(soundType))
if (SoundConfig.getInstance().getIsEnabled(soundType))
player.playSound(location, getSound(soundType), soundCategory, getVolume(soundType), totalPitch);
}
public static void worldSendSound(World world, Location location, SoundType soundType)
{
if(SoundConfig.getInstance().getIsEnabled(soundType))
public static void worldSendSound(World world, Location location, SoundType soundType) {
if (SoundConfig.getInstance().getIsEnabled(soundType))
world.playSound(location, getSound(soundType), getVolume(soundType), getPitch(soundType));
}
/**
* All volume is multiplied by the master volume to get its final value
*
* @param soundType target soundtype
* @return the volume for this soundtype
*/
private static float getVolume(SoundType soundType)
{
private static float getVolume(SoundType soundType) {
return SoundConfig.getInstance().getVolume(soundType) * SoundConfig.getInstance().getMasterVolume();
}
private static float getPitch(SoundType soundType)
{
if(soundType == SoundType.FIZZ)
private static float getPitch(SoundType soundType) {
if (soundType == SoundType.FIZZ)
return getFizzPitch();
else if (soundType == SoundType.POP)
return getPopPitch();
@@ -59,10 +55,8 @@ public class SoundManager {
return SoundConfig.getInstance().getPitch(soundType);
}
private static Sound getSound(SoundType soundType)
{
switch(soundType)
{
private static Sound getSound(SoundType soundType) {
switch (soundType) {
case ANVIL:
return Sound.BLOCK_ANVIL_PLACE;
case ITEM_BREAK:

View File

@@ -16,9 +16,8 @@ public enum SoundType {
BLEED,
TIRED;
public boolean usesCustomPitch()
{
switch(this){
public boolean usesCustomPitch() {
switch (this) {
case POP:
case FIZZ:
return true;

View File

@@ -28,37 +28,6 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
this(names, true);
}
public Map<String, UUID> call() throws Exception {
Map<String, UUID> uuidMap = new HashMap<>();
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) {
HttpURLConnection connection = createConnection();
List<String> nameSubList = names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()));
JsonArray array = new JsonArray();
for(String name : nameSubList)
{
JsonPrimitive element = new JsonPrimitive(name);
array.add(element);
}
String body = array.getAsString();
writeBody(connection, body);
for (Object profile : array) {
JsonObject jsonProfile = (JsonObject) profile;
String id = jsonProfile.get("id").getAsString();
String name = jsonProfile.get("name").getAsString();
UUID uuid = UUIDFetcher.getUUID(id);
uuidMap.put(name, uuid);
}
if (rateLimiting && i != requests - 1) {
Thread.sleep(RATE_LIMIT);
}
}
return uuidMap;
}
private static void writeBody(HttpURLConnection connection, String body) throws Exception {
OutputStream stream = connection.getOutputStream();
stream.write(body.getBytes());
@@ -101,4 +70,34 @@ public class UUIDFetcher implements Callable<Map<String, UUID>> {
public static UUID getUUIDOf(String name) throws Exception {
return new UUIDFetcher(Collections.singletonList(name)).call().get(name);
}
public Map<String, UUID> call() throws Exception {
Map<String, UUID> uuidMap = new HashMap<>();
int requests = (int) Math.ceil(names.size() / PROFILES_PER_REQUEST);
for (int i = 0; i < requests; i++) {
HttpURLConnection connection = createConnection();
List<String> nameSubList = names.subList(i * PROFILES_PER_REQUEST, Math.min((i + 1) * PROFILES_PER_REQUEST, names.size()));
JsonArray array = new JsonArray();
for (String name : nameSubList) {
JsonPrimitive element = new JsonPrimitive(name);
array.add(element);
}
String body = array.getAsString();
writeBody(connection, body);
for (Object profile : array) {
JsonObject jsonProfile = (JsonObject) profile;
String id = jsonProfile.get("id").getAsString();
String name = jsonProfile.get("name").getAsString();
UUID uuid = UUIDFetcher.getUUID(id);
uuidMap.put(name, uuid);
}
if (rateLimiting && i != requests - 1) {
Thread.sleep(RATE_LIMIT);
}
}
return uuidMap;
}
}