Static Abuse Removal - Misc (now MiscTools)

This commit is contained in:
nossr50 2019-09-24 16:44:23 -07:00
parent 564b8ceb94
commit 3552457790
40 changed files with 133 additions and 165 deletions

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.party.PartyTeleportRecord; import com.gmail.nossr50.datatypes.party.PartyTeleportRecord;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
@ -88,7 +87,7 @@ public class PtpCommand implements TabExecutor {
int hurtCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown(); int hurtCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown();
if (hurtCooldown > 0) { if (hurtCooldown > 0) {
int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) { if (timeRemaining > 0) {
player.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining)); player.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining));
@ -109,7 +108,7 @@ public class PtpCommand implements TabExecutor {
long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse(); long ptpLastUse = mcMMOPlayer.getPartyTeleportRecord().getLastUse();
if (ptpCooldown > 0) { if (ptpCooldown > 0) {
int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(ptpLastUse * Misc.TIME_CONVERSION_FACTOR, ptpCooldown, player); int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(ptpLastUse * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR, ptpCooldown, player);
if (timeRemaining > 0) { if (timeRemaining > 0) {
player.sendMessage(pluginRef.getLocaleManager().getString("Item.Generic.Wait", timeRemaining)); player.sendMessage(pluginRef.getLocaleManager().getString("Item.Generic.Wait", timeRemaining));

View File

@ -4,6 +4,7 @@ import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.RankCommandAsyncTask; import com.gmail.nossr50.runnables.commands.RankCommandAsyncTask;
import com.gmail.nossr50.util.scoreboards.SidebarType;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -116,7 +117,7 @@ public class RankCommand implements TabExecutor {
&& (pluginRef.getScoreboardSettings().isScoreboardEnabled(SidebarType.RANK_BOARD)); && (pluginRef.getScoreboardSettings().isScoreboardEnabled(SidebarType.RANK_BOARD));
boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(SidebarType.RANK_BOARD); boolean useChat = !useBoard || pluginRef.getScoreboardSettings().isScoreboardPrinting(SidebarType.RANK_BOARD);
new RankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(pluginRef); new RankCommandAsyncTask(pluginRef, playerName, sender, useBoard, useChat).runTaskAsynchronously(pluginRef);
} }
private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) { private long getCDSeconds(McMMOPlayer mcMMOPlayer, long cooldownMillis) {

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.player.UniqueDataType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -175,7 +174,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
long lastPlayed = 0; long lastPlayed = 0;
boolean rewrite = false; boolean rewrite = false;
try { try {
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR; lastPlayed = Long.parseLong(character[37]) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR;
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -272,7 +271,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
} }
} }
Misc.profileCleanup(playerName); pluginRef.getMiscTools().profileCleanup(playerName);
return worked; return worked;
} }
@ -382,7 +381,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
writer.append(profile.getSkillLevel(PrimarySkillType.FISHING)).append(":"); writer.append(profile.getSkillLevel(PrimarySkillType.FISHING)).append(":");
writer.append(profile.getSkillXpLevel(PrimarySkillType.FISHING)).append(":"); writer.append(profile.getSkillXpLevel(PrimarySkillType.FISHING)).append(":");
writer.append((int) profile.getAbilityDATS(SuperAbilityType.BLAST_MINING)).append(":"); writer.append((int) profile.getAbilityDATS(SuperAbilityType.BLAST_MINING)).append(":");
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":"); writer.append(System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR).append(":");
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType(); MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
writer.append(mobHealthbarType == null ? pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString() : mobHealthbarType.toString()).append(":"); writer.append(mobHealthbarType == null ? pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString() : mobHealthbarType.toString()).append(":");
writer.append(profile.getSkillLevel(PrimarySkillType.ALCHEMY)).append(":"); writer.append(profile.getSkillLevel(PrimarySkillType.ALCHEMY)).append(":");
@ -462,7 +461,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
out.append(startingLevel); // Fishing out.append(startingLevel); // Fishing
out.append("0:"); // FishingXp out.append("0:"); // FishingXp
out.append("0:"); // Blast Mining out.append("0:"); // Blast Mining
out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); // LastLogin out.append(String.valueOf(System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR)).append(":"); // LastLogin
out.append(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString()).append(":"); // Mob Healthbar HUD out.append(pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString()).append(":"); // Mob Healthbar HUD
out.append(startingLevel); // Alchemy out.append(startingLevel); // Alchemy
out.append("0:"); // AlchemyXp out.append("0:"); // AlchemyXp
@ -1019,7 +1018,7 @@ public final class FlatFileDatabaseManager implements DatabaseManager {
if (character[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) { if (character[i].isEmpty() && !(i == 2 || i == 3 || i == 23 || i == 33 || i == 41)) {
corrupted = true; corrupted = true;
if (i == 37) { if (i == 37) {
character[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); character[i] = String.valueOf(System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} else if (i == 38) { } else if (i == 38) {
character[i] = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString(); character[i] = pluginRef.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString();
} else { } else {

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.player.UniqueDataType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.apache.tomcat.jdbc.pool.DataSource; import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties; import org.apache.tomcat.jdbc.pool.PoolProperties;
@ -222,7 +221,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
if(uuid != null) if(uuid != null)
cleanupUser(uuid); cleanupUser(uuid);
Misc.profileCleanup(playerName); pluginRef.getMiscTools().profileCleanup(playerName);
} }
return success; return success;

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.ShareHandler; import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -513,7 +512,7 @@ public class Party {
double range = pluginRef.getConfigManager().getConfigParty().getPartyXP().getPartyExperienceSharing().getPartyShareRange(); double range = pluginRef.getConfigManager().getConfigParty().getPartyXP().getPartyExperienceSharing().getPartyShareRange();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { if (!player.equals(member) && member.isValid() && pluginRef.getMiscTools().isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member); nearMembers.add(member);
} }
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.datatypes.party; package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class PartyTeleportRecord { public class PartyTeleportRecord {
@ -54,7 +53,7 @@ public class PartyTeleportRecord {
} }
public void actualizeLastUse() { public void actualizeLastUse() {
lastUse = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); lastUse = (int) (System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} }
public int getTimeout() { public int getTimeout() {
@ -62,6 +61,6 @@ public class PartyTeleportRecord {
} }
public void actualizeTimeout() { public void actualizeTimeout() {
timeout = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); timeout = (int) (System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} }
} }

View File

@ -30,7 +30,6 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.experience.ExperienceBarManager; import com.gmail.nossr50.util.experience.ExperienceBarManager;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -421,7 +420,7 @@ public class McMMOPlayer {
} }
public void actualizeRecentlyHurt() { public void actualizeRecentlyHurt() {
recentlyHurt = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); recentlyHurt = (int) (System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} }
/* /*
@ -433,7 +432,7 @@ public class McMMOPlayer {
} }
public void actualizeChimeraWingLastUse() { public void actualizeChimeraWingLastUse() {
profile.setChimaeraWingDATS((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)); profile.setChimaeraWingDATS((int) (System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR));
} }
public Location getTeleportCommenceLocation() { public Location getTeleportCommenceLocation() {
@ -457,7 +456,7 @@ public class McMMOPlayer {
} }
public void actualizeRespawnATS() { public void actualizeRespawnATS() {
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); respawnATS = (int) (System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} }
public long getTeleportATS() { public long getTeleportATS() {
@ -946,7 +945,7 @@ public class McMMOPlayer {
int abilityLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(this, primarySkillType, superAbility); int abilityLength = pluginRef.getSkillTools().calculateAbilityLengthPerks(this, primarySkillType, superAbility);
// Enable the ability // Enable the ability
profile.setAbilityDATS(superAbility, System.currentTimeMillis() + (abilityLength * Misc.TIME_CONVERSION_FACTOR)); profile.setAbilityDATS(superAbility, System.currentTimeMillis() + (abilityLength * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR));
setSuperAbilityMode(superAbility, true); setSuperAbilityMode(superAbility, true);
if (superAbility == SuperAbilityType.SUPER_BREAKER || superAbility == SuperAbilityType.GIGA_DRILL_BREAKER) { if (superAbility == SuperAbilityType.SUPER_BREAKER || superAbility == SuperAbilityType.GIGA_DRILL_BREAKER) {
@ -954,7 +953,7 @@ public class McMMOPlayer {
} }
setToolPreparationMode(tool, false); setToolPreparationMode(tool, false);
new AbilityDisableTask(pluginRef, this, superAbility).runTaskLater(pluginRef, abilityLength * Misc.TICK_CONVERSION_FACTOR); new AbilityDisableTask(pluginRef, this, superAbility).runTaskLater(pluginRef, abilityLength * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR);
} }
public void processAbilityActivation(PrimarySkillType primarySkillType) { public void processAbilityActivation(PrimarySkillType primarySkillType) {
@ -1001,7 +1000,7 @@ public class McMMOPlayer {
} }
setToolPreparationMode(tool, true); setToolPreparationMode(tool, true);
new ToolLowerTask(pluginRef,this, tool).runTaskLater(pluginRef, 4 * Misc.TICK_CONVERSION_FACTOR); new ToolLowerTask(pluginRef,this, tool).runTaskLater(pluginRef, 4 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR);
} }
} }
@ -1012,9 +1011,9 @@ public class McMMOPlayer {
* @return the number of seconds remaining before the cooldown expires * @return the number of seconds remaining before the cooldown expires
*/ */
public int calculateTimeRemaining(SuperAbilityType superAbilityType) { public int calculateTimeRemaining(SuperAbilityType superAbilityType) {
long deactivatedTimestamp = profile.getAbilityDATS(superAbilityType) * Misc.TIME_CONVERSION_FACTOR; long deactivatedTimestamp = profile.getAbilityDATS(superAbilityType) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR;
return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player, return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player,
pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType)) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR); pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType)) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} }
/* /*

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.meta.TrackedArrowMeta; import com.gmail.nossr50.datatypes.meta.TrackedArrowMeta;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -33,7 +32,7 @@ public class ArcheryBehaviour {
*/ */
public void arrowRetrievalCheck(LivingEntity livingEntity) { public void arrowRetrievalCheck(LivingEntity livingEntity) {
if(livingEntity.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) { if(livingEntity.hasMetadata(MetadataConstants.ARROW_TRACKER_METAKEY)) {
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY).get(0).asInt()); pluginRef.getMiscTools().dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), livingEntity.getMetadata(MetadataConstants.ARROW_TRACKER_METAKEY).get(0).asInt());
} }
} }

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -171,7 +170,7 @@ public class MiningBehaviour {
case REDSTONE_ORE: case REDSTONE_ORE:
case STONE: case STONE:
case PRISMARINE: case PRISMARINE:
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); pluginRef.getMiscTools().dropItem(pluginRef.getMiscTools().getBlockCenter(blockState), new ItemStack(blockState.getType()));
return; return;
default: default:
@ -237,7 +236,7 @@ public class MiningBehaviour {
case YELLOW_TERRACOTTA: case YELLOW_TERRACOTTA:
case STONE: case STONE:
case NETHER_QUARTZ_ORE: case NETHER_QUARTZ_ORE:
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); pluginRef.getMiscTools().dropItems(pluginRef.getMiscTools().getBlockCenter(blockState), blockState.getBlock().getDrops());
return; return;
default: default:

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.datatypes.skills.behaviours; package com.gmail.nossr50.datatypes.skills.behaviours;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
/** /**
@ -82,7 +81,7 @@ public class WoodcuttingBehaviour {
} }
else {*/ else {*/
if (pluginRef.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(blockState.getType())) { if (pluginRef.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(blockState.getType())) {
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); pluginRef.getMiscTools().dropItems(pluginRef.getMiscTools().getBlockCenter(blockState), blockState.getBlock().getDrops());
} }
//} //}
} }

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -311,7 +310,7 @@ public class EntityListener implements Listener {
} }
if (Misc.isNPCEntityExcludingVillagers(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) {
return; return;
} }
@ -321,7 +320,7 @@ public class EntityListener implements Listener {
return; return;
} }
if (Misc.isNPCEntityExcludingVillagers(attacker)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(attacker)) {
return; return;
} }
@ -484,7 +483,7 @@ public class EntityListener implements Listener {
} }
*/ */
if (Misc.isNPCEntityExcludingVillagers(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(entity) || !entity.isValid() || !(entity instanceof LivingEntity)) {
return; return;
} }
@ -614,7 +613,7 @@ public class EntityListener implements Listener {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (Misc.isNPCEntityExcludingVillagers(entity)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(entity)) {
return; return;
} }
@ -646,7 +645,7 @@ public class EntityListener implements Listener {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (Misc.isNPCEntityExcludingVillagers(entity)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(entity)) {
return; return;
} }
@ -952,7 +951,7 @@ public class EntityListener implements Listener {
LivingEntity entity = event.getEntity(); LivingEntity entity = event.getEntity();
if (!pluginRef.getUserManager().hasPlayerDataKey(player) || Misc.isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) { if (!pluginRef.getUserManager().hasPlayerDataKey(player) || pluginRef.getMiscTools().isNPCEntityExcludingVillagers(entity) || entity.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) {
return; return;
} }

View File

@ -18,7 +18,6 @@ import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.HardcoreManager; import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -834,7 +833,7 @@ public class PlayerListener implements Listener {
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Misc.isNPCEntityExcludingVillagers(player) || !pluginRef.getUserManager().hasPlayerDataKey(player)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(player) || !pluginRef.getUserManager().hasPlayerDataKey(player)) {
return; return;
} }

View File

@ -103,6 +103,7 @@ public class mcMMO extends JavaPlugin {
private PermissionTools permissionTools; private PermissionTools permissionTools;
private WorldGuardUtils worldGuardUtils; private WorldGuardUtils worldGuardUtils;
private MessageOfTheDayUtils messageOfTheDayUtils; private MessageOfTheDayUtils messageOfTheDayUtils;
private MiscTools miscTools;
private ZipLibrary zipLibrary; private ZipLibrary zipLibrary;
/* Never-Ending tasks */ /* Never-Ending tasks */
@ -289,6 +290,9 @@ public class mcMMO extends JavaPlugin {
//Init Sound Manager //Init Sound Manager
soundManager = new SoundManager(this); soundManager = new SoundManager(this);
//Misc Tools Init
miscTools = new MiscTools(this);
} }
@Override @Override
@ -656,13 +660,13 @@ public class mcMMO extends JavaPlugin {
// Bleed timer (Runs every 0.5 seconds) // Bleed timer (Runs every 0.5 seconds)
bleedTimerTask = new BleedTimerTask(this); bleedTimerTask = new BleedTimerTask(this);
bleedTimerTask.runTaskTimer(this, Misc.TICK_CONVERSION_FACTOR, (Misc.TICK_CONVERSION_FACTOR / 2)); bleedTimerTask.runTaskTimer(this, miscTools.TICK_CONVERSION_FACTOR, (miscTools.TICK_CONVERSION_FACTOR / 2));
// Old & Powerless User remover // Old & Powerless User remover
long purgeIntervalTicks = getConfigManager().getConfigDatabase().getConfigSectionCleaning().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; long purgeIntervalTicks = getConfigManager().getConfigDatabase().getConfigSectionCleaning().getPurgeInterval() * 60L * 60L * miscTools.TICK_CONVERSION_FACTOR;
if (getDatabaseCleaningSettings().isOnlyPurgeAtStartup()) { if (getDatabaseCleaningSettings().isOnlyPurgeAtStartup()) {
new UserPurgeTask(this).runTaskLaterAsynchronously(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. new UserPurgeTask(this).runTaskLaterAsynchronously(this, 2 * miscTools.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
} else if (purgeIntervalTicks > 0) { } else if (purgeIntervalTicks > 0) {
new UserPurgeTask(this).runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks); new UserPurgeTask(this).runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks);
} }
@ -670,17 +674,17 @@ public class mcMMO extends JavaPlugin {
//Party System Stuff //Party System Stuff
if (configManager.getConfigParty().isPartySystemEnabled()) { if (configManager.getConfigParty().isPartySystemEnabled()) {
// Automatically remove old members from parties // Automatically remove old members from parties
long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * miscTools.TICK_CONVERSION_FACTOR;
if (kickIntervalTicks == 0) { if (kickIntervalTicks == 0) {
new PartyAutoKickTask(this).runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. new PartyAutoKickTask(this).runTaskLater(this, 2 * miscTools.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
} else if (kickIntervalTicks > 0) { } else if (kickIntervalTicks > 0) {
new PartyAutoKickTask(this).runTaskTimer(this, kickIntervalTicks, kickIntervalTicks); new PartyAutoKickTask(this).runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
} }
} }
// Update power level tag scoreboards // Update power level tag scoreboards
new PowerLevelUpdatingTask(this).runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR); new PowerLevelUpdatingTask(this).runTaskTimer(this, 2 * miscTools.TICK_CONVERSION_FACTOR, 2 * miscTools.TICK_CONVERSION_FACTOR);
// Clear the registered XP data so players can earn XP again // Clear the registered XP data so players can earn XP again
if (getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) { if (getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) {
@ -833,4 +837,8 @@ public class mcMMO extends JavaPlugin {
public ChunkManagerFactory getChunkManagerFactory() { public ChunkManagerFactory getChunkManagerFactory() {
return chunkManagerFactory; return chunkManagerFactory;
} }
public MiscTools getMiscTools() {
return miscTools;
}
} }

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.items.TeleportationWarmup; import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -228,7 +227,7 @@ public final class PartyManager {
double range = pluginRef.getPartyXPShareSettings().getPartyShareRange(); double range = pluginRef.getPartyXPShareSettings().getPartyShareRange();
for (Player member : party.getOnlineMembers()) { for (Player member : party.getOnlineMembers()) {
if (!player.equals(member) && member.isValid() && Misc.isNear(player.getLocation(), member.getLocation(), range)) { if (!player.equals(member) && member.isValid() && pluginRef.getMiscTools().isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member); nearMembers.add(member);
} }
} }
@ -248,7 +247,7 @@ public final class PartyManager {
for (Player member : party.getVisibleMembers(player)) { for (Player member : party.getVisibleMembers(player)) {
if (!player.equals(member) if (!player.equals(member)
&& member.isValid() && member.isValid()
&& Misc.isNear(player.getLocation(), member.getLocation(), range)) { && pluginRef.getMiscTools().isNear(player.getLocation(), member.getLocation(), range)) {
nearMembers.add(member); nearMembers.add(member);
} }
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.party.ShareMode;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -120,7 +119,7 @@ public final class ShareHandler {
} }
int itemShareModifier = mcMMOMember.getItemShareModifier(); int itemShareModifier = mcMMOMember.getItemShareModifier();
int diceRoll = Misc.getRandom().nextInt(itemShareModifier); int diceRoll = pluginRef.getMiscTools().getRandom().nextInt(itemShareModifier);
if (diceRoll <= highestRoll) { if (diceRoll <= highestRoll) {
mcMMOMember.setItemShareModifier(itemShareModifier + itemWeight); mcMMOMember.setItemShareModifier(itemShareModifier + itemWeight);
@ -146,7 +145,7 @@ public final class ShareHandler {
case RANDOM: case RANDOM:
for (int i = 0; i < itemStack.getAmount(); i++) { for (int i = 0; i < itemStack.getAmount(); i++) {
winningPlayer = nearMembers.get(Misc.getRandom().nextInt(partySize)); winningPlayer = nearMembers.get(pluginRef.getMiscTools().getRandom().nextInt(partySize));
awardDrop(winningPlayer, newStack); awardDrop(winningPlayer, newStack);
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.runnables.items;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.ChimaeraWing; import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -45,7 +44,7 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
int hurtCooldown = pluginRef.getConfigManager().getConfigItems().getRecentlyHurtCooldown(); int hurtCooldown = pluginRef.getConfigManager().getConfigItems().getRecentlyHurtCooldown();
if (hurtCooldown > 0) { if (hurtCooldown > 0) {
int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) { if (timeRemaining > 0) {
player.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining)); player.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining));

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.runnables.items;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -41,7 +40,7 @@ public class TeleportationWarmup extends BukkitRunnable {
int hurtCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown(); int hurtCooldown = pluginRef.getConfigManager().getConfigParty().getPTP().getPtpRecentlyHurtCooldown();
if (hurtCooldown > 0) { if (hurtCooldown > 0) {
int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer); int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR, hurtCooldown, teleportingPlayer);
if (timeRemaining > 0) { if (timeRemaining > 0) {
teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining)); teleportingPlayer.sendMessage(pluginRef.getLocaleManager().getString("Item.Injured.Wait", timeRemaining));

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.ScoreboardKeepTask; import com.gmail.nossr50.runnables.commands.ScoreboardKeepTask;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -30,7 +29,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
if (Misc.isNPCIncludingVillagers(player)) { if (pluginRef.getMiscTools().isNPCIncludingVillagers(player)) {
return; return;
} }
@ -91,7 +90,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) { if (pluginRef.getScoreboardSettings().getShowStatsAfterLogin()) {
pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player); pluginRef.getScoreboardManager().enablePlayerStatsScoreboard(player);
new ScoreboardKeepTask(pluginRef, player).runTaskLater(pluginRef, Misc.TICK_CONVERSION_FACTOR); new ScoreboardKeepTask(pluginRef, player).runTaskLater(pluginRef, pluginRef.getMiscTools().TICK_CONVERSION_FACTOR);
} }
} }

View File

@ -4,7 +4,6 @@ import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.PerksUtils; import com.gmail.nossr50.util.skills.PerksUtils;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.World; import org.bukkit.World;
@ -60,7 +59,7 @@ public class AbilityDisableTask extends BukkitRunnable {
pluginRef.getSkillTools().getSuperAbilityOtherPlayerDeactivationStr(superAbilityType)); pluginRef.getSkillTools().getSuperAbilityOtherPlayerDeactivationStr(superAbilityType));
new AbilityCooldownTask(pluginRef, mcMMOPlayer, superAbilityType).runTaskLater(pluginRef, new AbilityCooldownTask(pluginRef, mcMMOPlayer, superAbilityType).runTaskLater(pluginRef,
PerksUtils.handleCooldownPerks(player, PerksUtils.handleCooldownPerks(player,
pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType) * Misc.TICK_CONVERSION_FACTOR)); pluginRef.getSkillTools().getSuperAbilityCooldown(superAbilityType) * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR));
} }
private void resendChunkRadiusAt(Player player) { private void resendChunkRadiusAt(Player player) {

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.behaviours.AcrobaticsBehaviour; import com.gmail.nossr50.datatypes.skills.behaviours.AcrobaticsBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
@ -94,7 +93,7 @@ public class AcrobaticsManager extends SkillManager {
//Check respawn to prevent abuse //Check respawn to prevent abuse
if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse()) if (!pluginRef.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitAcrobatics().isPreventAcrobaticsAbuse())
applyXpGain((float) (damage * acrobaticsBehaviour.getDodgeXpModifier()), XPGainReason.PVP); applyXpGain((float) (damage * acrobaticsBehaviour.getDodgeXpModifier()), XPGainReason.PVP);
else if (pluginRef.getSkillTools().cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) else if (pluginRef.getSkillTools().cooldownExpired(mcMMOPlayer.getRespawnATS(), pluginRef.getMiscTools().PLAYER_RESPAWN_COOLDOWN_SECONDS)
&& mcMMOPlayer.getTeleportATS() < System.currentTimeMillis()) { && mcMMOPlayer.getTeleportATS() < System.currentTimeMillis()) {
applyXpGain((float) (damage * acrobaticsBehaviour.getDodgeXpModifier()), XPGainReason.PVP); applyXpGain((float) (damage * acrobaticsBehaviour.getDodgeXpModifier()), XPGainReason.PVP);
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.behaviours.ArcheryBehaviour; import com.gmail.nossr50.datatypes.skills.behaviours.ArcheryBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -94,7 +93,7 @@ public class ArcheryManager extends SkillManager {
} }
Location dazedLocation = defender.getLocation(); Location dazedLocation = defender.getLocation();
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181)); dazedLocation.setPitch(90 - pluginRef.getMiscTools().getRandom().nextInt(181));
defender.teleport(dazedLocation); defender.teleport(dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10)); defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));

View File

@ -15,7 +15,6 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.DelayedHerbalismXPCheckTask; import com.gmail.nossr50.runnables.skills.DelayedHerbalismXPCheckTask;
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask; import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
@ -685,7 +684,7 @@ public class HerbalismManager extends SkillManager {
private boolean processGrowingPlants(BlockState blockState, boolean greenTerra) { private boolean processGrowingPlants(BlockState blockState, boolean greenTerra) {
int greenThumbStage = getGreenThumbStage(); int greenThumbStage = getGreenThumbStage();
blockState.setMetadata(MetadataConstants.GREEN_THUMB_METAKEY, new FixedMetadataValue(pluginRef, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR))); blockState.setMetadata(MetadataConstants.GREEN_THUMB_METAKEY, new FixedMetadataValue(pluginRef, (int) (System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR)));
Ageable crops = (Ageable) blockState.getBlockData(); Ageable crops = (Ageable) blockState.getBlockData();
switch (blockState.getType()) { switch (blockState.getType()) {

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.datatypes.skills.behaviours.MiningBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask; import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -129,7 +128,7 @@ public class MiningManager extends SkillManager {
mcMMOPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis()); mcMMOPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
mcMMOPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false); mcMMOPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false);
new AbilityCooldownTask(pluginRef, mcMMOPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(pluginRef, SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR); new AbilityCooldownTask(pluginRef, mcMMOPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(pluginRef, SuperAbilityType.BLAST_MINING.getCooldown() * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR);
} }
/** /**
@ -160,12 +159,12 @@ public class MiningManager extends SkillManager {
} }
for (BlockState blockState : ores) { for (BlockState blockState : ores) {
if (Misc.getRandom().nextFloat() < (yield + oreBonus)) { if (pluginRef.getMiscTools().getRandom().nextFloat() < (yield + oreBonus)) {
if (!pluginRef.getPlaceStore().isTrue(blockState)) { if (!pluginRef.getPlaceStore().isTrue(blockState)) {
xp += miningBehaviour.getBlockXp(blockState); xp += miningBehaviour.getBlockXp(blockState);
} }
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped pluginRef.getMiscTools().dropItem(pluginRef.getMiscTools().getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped
if (!pluginRef.getPlaceStore().isTrue(blockState)) { if (!pluginRef.getPlaceStore().isTrue(blockState)) {
for (int i = 1; i < dropMultiplier; i++) { for (int i = 1; i < dropMultiplier; i++) {
@ -177,8 +176,8 @@ public class MiningManager extends SkillManager {
if (debrisYield > 0) { if (debrisYield > 0) {
for (BlockState blockState : debris) { for (BlockState blockState : debris) {
if (Misc.getRandom().nextFloat() < debrisYield) { if (pluginRef.getMiscTools().getRandom().nextFloat() < debrisYield) {
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops()); pluginRef.getMiscTools().dropItems(pluginRef.getMiscTools().getBlockCenter(blockState), blockState.getBlock().getDrops());
} }
} }
} }

View File

@ -6,7 +6,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -362,6 +361,6 @@ public class RepairManager extends SkillManager {
} }
public void actualizeLastAnvilUse() { public void actualizeLastAnvilUse() {
lastClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); lastClick = (int) (System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} }
} }

View File

@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.behaviours.SalvageBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable; import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
@ -146,10 +145,10 @@ public class SalvageManager extends SkillManager {
anvilLoc.add(0, .1, 0); anvilLoc.add(0, .1, 0);
if (enchantBook != null) { if (enchantBook != null) {
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), enchantBook, vectorSpeed); pluginRef.getMiscTools().spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), enchantBook, vectorSpeed);
} }
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed); pluginRef.getMiscTools().spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed);
// BWONG BWONG BWONG - CLUNK! // BWONG BWONG BWONG - CLUNK!
if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilUseSounds()) { if (pluginRef.getConfigManager().getConfigSalvage().getGeneral().isAnvilUseSounds()) {
@ -318,6 +317,6 @@ public class SalvageManager extends SkillManager {
} }
public void actualizeLastAnvilUse() { public void actualizeLastAnvilUse() {
lastClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR); lastClick = (int) (System.currentTimeMillis() / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} }
} }

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon; import com.gmail.nossr50.datatypes.skills.subskills.taming.TamingSummon;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.random.RandomChanceSkillStatic; import com.gmail.nossr50.util.random.RandomChanceSkillStatic;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
@ -269,7 +268,7 @@ public class TamingManager extends SkillManager {
//Check to see if players have the correct amount of the item required to summon //Check to see if players have the correct amount of the item required to summon
if(itemInMainHand.getAmount() >= tamingSummon.getItemAmountRequired()) { if(itemInMainHand.getAmount() >= tamingSummon.getItemAmountRequired()) {
//Initial Spawn location //Initial Spawn location
Location spawnLocation = Misc.getLocationOffset(player.getLocation(), 1); Location spawnLocation = pluginRef.getMiscTools().getLocationOffset(player.getLocation(), 1);
//COTW can summon multiple entities per usage //COTW can summon multiple entities per usage
for (int i = 0; i < tamingSummon.getEntitiesSummoned(); i++) { for (int i = 0; i < tamingSummon.getEntitiesSummoned(); i++) {
@ -281,7 +280,7 @@ public class TamingManager extends SkillManager {
break; break;
} }
spawnLocation = Misc.getLocationOffset(spawnLocation, 1); spawnLocation = pluginRef.getMiscTools().getLocationOffset(spawnLocation, 1);
spawnCOTWEntity(callOfTheWildType, spawnLocation, tamingSummon.getEntityType()); spawnCOTWEntity(callOfTheWildType, spawnLocation, tamingSummon.getEntityType());
//Inform the player about what they have just done //Inform the player about what they have just done
@ -360,11 +359,11 @@ public class TamingManager extends SkillManager {
//Randomize the cat //Randomize the cat
if(callOfWildEntity instanceof Ocelot) { if(callOfWildEntity instanceof Ocelot) {
int numberOfTypes = Ocelot.Type.values().length; int numberOfTypes = Ocelot.Type.values().length;
((Ocelot) callOfWildEntity).setCatType(Ocelot.Type.values()[Misc.getRandom().nextInt(numberOfTypes)]); ((Ocelot) callOfWildEntity).setCatType(Ocelot.Type.values()[pluginRef.getMiscTools().getRandom().nextInt(numberOfTypes)]);
((Ocelot) callOfWildEntity).setAdult(); ((Ocelot) callOfWildEntity).setAdult();
} else if(callOfWildEntity instanceof Cat) { } else if(callOfWildEntity instanceof Cat) {
int numberOfTypes = Cat.Type.values().length; int numberOfTypes = Cat.Type.values().length;
((Cat) callOfWildEntity).setCatType(Cat.Type.values()[Misc.getRandom().nextInt(numberOfTypes)]); ((Cat) callOfWildEntity).setCatType(Cat.Type.values()[pluginRef.getMiscTools().getRandom().nextInt(numberOfTypes)]);
((Cat) callOfWildEntity).setAdult(); ((Cat) callOfWildEntity).setAdult();
} }
@ -385,12 +384,12 @@ public class TamingManager extends SkillManager {
//Randomize Horse //Randomize Horse
Horse horse = (Horse) callOfWildEntity; Horse horse = (Horse) callOfWildEntity;
callOfWildEntity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15)); callOfWildEntity.setMaxHealth(15.0 + (pluginRef.getMiscTools().getRandom().nextDouble() * 15));
callOfWildEntity.setHealth(callOfWildEntity.getMaxHealth()); callOfWildEntity.setHealth(callOfWildEntity.getMaxHealth());
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]); horse.setColor(Horse.Color.values()[pluginRef.getMiscTools().getRandom().nextInt(Horse.Color.values().length)]);
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]); horse.setStyle(Horse.Style.values()[pluginRef.getMiscTools().getRandom().nextInt(Horse.Style.values().length)]);
horse.setJumpStrength(Math.max(pluginRef.getConfigManager().getConfigTaming().getMinHorseJumpStrength(), horse.setJumpStrength(Math.max(pluginRef.getConfigManager().getConfigTaming().getMinHorseJumpStrength(),
Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, pluginRef.getConfigManager().getConfigTaming().getMaxHorseJumpStrength()))); Math.min(Math.min(pluginRef.getMiscTools().getRandom().nextDouble(), pluginRef.getMiscTools().getRandom().nextDouble()) * 2, pluginRef.getConfigManager().getConfigTaming().getMaxHorseJumpStrength())));
horse.setAdult(); horse.setAdult();
//TODO: setSpeed, once available //TODO: setSpeed, once available

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType; import com.gmail.nossr50.datatypes.skills.subskills.taming.CallOfTheWildType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
@ -30,7 +29,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
int tamingCOTWLength = pluginRef.getConfigManager().getConfigTaming().getSubSkills().getCallOfTheWild().getCOTWSummon(callOfTheWildType).getSummonLifespan(); int tamingCOTWLength = pluginRef.getConfigManager().getConfigTaming().getSubSkills().getCallOfTheWild().getCOTWSummon(callOfTheWildType).getSummonLifespan();
if (tamingCOTWLength > 0) { if (tamingCOTWLength > 0) {
this.length = tamingCOTWLength * Misc.TICK_CONVERSION_FACTOR; this.length = tamingCOTWLength * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR;
this.runTaskLater(pluginRef, length); this.runTaskLater(pluginRef, length);
} }
} }

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -107,7 +106,7 @@ public class UnarmedManager extends SkillManager {
if (pluginRef.getUserManager().getPlayer(defender) == null) if (pluginRef.getUserManager().getPlayer(defender) == null)
return; return;
Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand()); Item item = pluginRef.getMiscTools().dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand());
if (item != null && pluginRef.getConfigManager().getConfigUnarmed().doesDisarmPreventTheft()) { if (item != null && pluginRef.getConfigManager().getConfigUnarmed().doesDisarmPreventTheft()) {
item.setMetadata(MetadataConstants.DISARMED_ITEM_METAKEY, pluginRef.getUserManager().getPlayer(defender).getPlayerMetadata()); item.setMetadata(MetadataConstants.DISARMED_ITEM_METAKEY, pluginRef.getUserManager().getPlayer(defender).getPlayerMetadata());
@ -173,7 +172,7 @@ public class UnarmedManager extends SkillManager {
* @return true if the defender was not disarmed, false otherwise * @return true if the defender was not disarmed, false otherwise
*/ */
private boolean hasIronGrip(Player defender) { private boolean hasIronGrip(Player defender) {
if (!Misc.isNPCEntityExcludingVillagers(defender) if (!pluginRef.getMiscTools().isNPCEntityExcludingVillagers(defender)
&& pluginRef.getPermissionTools().isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP) && pluginRef.getPermissionTools().isSubSkillEnabled(defender, SubSkillType.UNARMED_IRON_GRIP)
&& pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_IRON_GRIP, defender)) { && pluginRef.getRandomChanceTools().isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.UNARMED_IRON_GRIP, defender)) {
pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender"); pluginRef.getNotificationManager().sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Unarmed.Ability.IronGrip.Defender");

View File

@ -9,7 +9,6 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.behaviours.WoodcuttingBehaviour; import com.gmail.nossr50.datatypes.skills.behaviours.WoodcuttingBehaviour;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.util.skills.SkillActivationType;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@ -101,7 +100,7 @@ public class WoodcuttingManager extends SkillManager {
double health = player.getHealth(); double health = player.getHealth();
if (health > 1) { if (health > 1) {
pluginRef.getCombatTools().dealDamage(player, Misc.getRandom().nextInt((int) (health - 1))); pluginRef.getCombatTools().dealDamage(player, pluginRef.getMiscTools().getRandom().nextInt((int) (health - 1)));
} }
return; return;
@ -263,17 +262,17 @@ public class WoodcuttingManager extends SkillManager {
//TODO: Update this to drop the correct items/blocks via NMS //TODO: Update this to drop the correct items/blocks via NMS
if (material == Material.BROWN_MUSHROOM_BLOCK || material == Material.RED_MUSHROOM_BLOCK) { if (material == Material.BROWN_MUSHROOM_BLOCK || material == Material.RED_MUSHROOM_BLOCK) {
xp += woodcuttingBehaviour.processTreeFellerXPGains(blockState, processedLogCount); xp += woodcuttingBehaviour.processTreeFellerXPGains(blockState, processedLogCount);
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); pluginRef.getMiscTools().dropItems(pluginRef.getMiscTools().getBlockCenter(blockState), block.getDrops());
} else { } else {
if (pluginRef.getBlockTools().isLog(blockState)) { if (pluginRef.getBlockTools().isLog(blockState)) {
if (canGetDoubleDrops()) { if (canGetDoubleDrops()) {
woodcuttingBehaviour.checkForDoubleDrop(blockState); woodcuttingBehaviour.checkForDoubleDrop(blockState);
} }
xp += woodcuttingBehaviour.processTreeFellerXPGains(blockState, processedLogCount); xp += woodcuttingBehaviour.processTreeFellerXPGains(blockState, processedLogCount);
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); pluginRef.getMiscTools().dropItems(pluginRef.getMiscTools().getBlockCenter(blockState), block.getDrops());
} }
if (pluginRef.getBlockTools().isLeaves(blockState)) { if (pluginRef.getBlockTools().isLeaves(blockState)) {
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops()); pluginRef.getMiscTools().dropItems(pluginRef.getMiscTools().getBlockCenter(blockState), block.getDrops());
} }
} }

View File

@ -56,7 +56,7 @@ public final class ChimaeraWing {
int cooldown = pluginRef.getConfigManager().getConfigItems().getCooldown(); int cooldown = pluginRef.getConfigManager().getConfigItems().getCooldown();
if (cooldown > 0) { if (cooldown > 0) {
int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(lastTeleport * Misc.TIME_CONVERSION_FACTOR, cooldown, player); int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(lastTeleport * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR, cooldown, player);
if (timeRemaining > 0) { if (timeRemaining > 0) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Item.Generic.Wait", String.valueOf(timeRemaining)); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ABILITY_COOLDOWN, "Item.Generic.Wait", String.valueOf(timeRemaining));
@ -68,7 +68,7 @@ public final class ChimaeraWing {
int hurtCooldown = pluginRef.getConfigManager().getConfigItems().getRecentlyHurtCooldown(); int hurtCooldown = pluginRef.getConfigManager().getConfigItems().getRecentlyHurtCooldown();
if (hurtCooldown > 0) { if (hurtCooldown > 0) {
int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * Misc.TIME_CONVERSION_FACTOR, hurtCooldown, player); int timeRemaining = pluginRef.getSkillTools().calculateTimeLeft(recentlyHurt * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR, hurtCooldown, player);
if (timeRemaining > 0) { if (timeRemaining > 0) {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.Injured.Wait", String.valueOf(timeRemaining)); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.ITEM_MESSAGE, "Item.Injured.Wait", String.valueOf(timeRemaining));
@ -82,7 +82,7 @@ public final class ChimaeraWing {
pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail"); pluginRef.getNotificationManager().sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Item.ChimaeraWing.Fail");
player.updateInventory(); player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0)); player.setVelocity(new Vector(0, 0.5D, 0));
pluginRef.getCombatTools().dealDamage(player, Misc.getRandom().nextInt((int) (player.getHealth() - 10))); pluginRef.getCombatTools().dealDamage(player, pluginRef.getMiscTools().getRandom().nextInt((int) (player.getHealth() - 10)));
mcMMOPlayer.actualizeChimeraWingLastUse(); mcMMOPlayer.actualizeChimeraWingLastUse();
return; return;
} }

View File

@ -123,7 +123,7 @@ public class EventManager {
Entity entity = entityDamageEvent.getEntity(); Entity entity = entityDamageEvent.getEntity();
//Check to make sure the entity is not an NPC //Check to make sure the entity is not an NPC
if(Misc.isNPCEntityExcludingVillagers(entity)) if(pluginRef.getMiscTools().isNPCEntityExcludingVillagers(entity))
return false; return false;
if (!entity.isValid() || !(entity instanceof LivingEntity)) { if (!entity.isValid() || !(entity instanceof LivingEntity)) {

View File

@ -1,6 +1,7 @@
package com.gmail.nossr50.util; package com.gmail.nossr50.util;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent; import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask; import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.bukkit.Location; import org.bukkit.Location;
@ -14,26 +15,18 @@ import java.util.Collection;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
public final class Misc { public final class MiscTools {
public static final int TIME_CONVERSION_FACTOR = 1000; public final int TIME_CONVERSION_FACTOR = 1000;
public static final int TICK_CONVERSION_FACTOR = 20; public final int TICK_CONVERSION_FACTOR = 20;
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5; public final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0; public 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"); public 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 final mcMMO pluginRef;
// Sound Pitches & Volumes from CB private Random random = new Random();
/* public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
public static final float ANVIL_USE_VOLUME = 1.0F * MainConfig.getInstance().getMasterVolume(); // Not in CB directly, I went off the place sound values
public static final float FIZZ_VOLUME = 0.5F * MainConfig.getInstance().getMasterVolume();
public static final float POP_VOLUME = 0.2F * MainConfig.getInstance().getMasterVolume();
public static final float BAT_VOLUME = 1.0F * MainConfig.getInstance().getMasterVolume();
public static final float BAT_PITCH = 0.6F;
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();
private Misc() { public MiscTools(mcMMO pluginRef) {
this.pluginRef = pluginRef;
} }
/** /**
@ -45,30 +38,30 @@ public final class Misc {
* 2) The entity can be considered an NPC * 2) The entity can be considered an NPC
* *
* In this context, an NPC is a bit hard to define. Various plugins determine what an NPC is in different ways. * In this context, an NPC is a bit hard to define. Various plugins determine what an NPC is in different ways.
* @see Misc::isNPCIncludingVillagers * @see MiscTools ::isNPCIncludingVillagers
* @param entity target entity * @param entity target entity
* @return true if the entity is not a Villager and is not a "NPC" * @return true if the entity is not a Villager and is not a "NPC"
*/ */
public static boolean isNPCEntityExcludingVillagers(Entity entity) { public boolean isNPCEntityExcludingVillagers(Entity entity) {
return (!isVillager(entity) return (!isVillager(entity)
&& isNPCIncludingVillagers(entity)); //Compatibility with some mod.. && isNPCIncludingVillagers(entity)); //Compatibility with some mod..
} }
public static boolean isNPCClassType(Entity entity) { public boolean isNPCClassType(Entity entity) {
return entity instanceof NPC; return entity instanceof NPC;
} }
public static boolean hasNPCMetadataTag(Entity entity) { public boolean hasNPCMetadataTag(Entity entity) {
return entity.hasMetadata("NPC"); return entity.hasMetadata("NPC");
} }
public static boolean isVillager(Entity entity) { public boolean isVillager(Entity entity) {
String entityType = entity.getType().toString(); String entityType = entity.getType().toString();
//This weird code is for 1.13 & 1.14 compatibility //This weird code is for 1.13 & 1.14 compatibility
return entityType.equalsIgnoreCase("wandering_trader") || entity instanceof Villager; return entityType.equalsIgnoreCase("wandering_trader") || entity instanceof Villager;
} }
public static boolean isNPCIncludingVillagers(Entity entity) { public boolean isNPCIncludingVillagers(Entity entity) {
return (entity == null return (entity == null
|| (hasNPCMetadataTag(entity)) || (hasNPCMetadataTag(entity))
|| (isNPCClassType(entity)) || (isNPCClassType(entity))
@ -83,7 +76,7 @@ public final class Misc {
* @param maxDistance The max distance apart * @param maxDistance The max distance apart
* @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise * @return true if the distance between {@code first} and {@code second} is less than {@code maxDistance}, false otherwise
*/ */
public static boolean isNear(Location first, Location second, double maxDistance) { public boolean isNear(Location first, Location second, double maxDistance) {
return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0); return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0);
} }
@ -93,11 +86,11 @@ public final class Misc {
* @param blockState The {@link BlockState} of the block * @param blockState The {@link BlockState} of the block
* @return A {@link Location} lying at the center of the block * @return A {@link Location} lying at the center of the block
*/ */
public static Location getBlockCenter(BlockState blockState) { public Location getBlockCenter(BlockState blockState) {
return blockState.getLocation().add(0.5, 0.5, 0.5); return blockState.getLocation().add(0.5, 0.5, 0.5);
} }
public static void dropItems(Location location, Collection<ItemStack> drops) { public void dropItems(Location location, Collection<ItemStack> drops) {
for (ItemStack drop : drops) { for (ItemStack drop : drops) {
dropItem(location, drop); dropItem(location, drop);
} }
@ -110,7 +103,7 @@ public final class Misc {
* @param is The items to drop * @param is The items to drop
* @param quantity The amount of items to drop * @param quantity The amount of items to drop
*/ */
public static void dropItems(Location location, ItemStack is, int quantity) { public void dropItems(Location location, ItemStack is, int quantity) {
for (int i = 0; i < quantity; i++) { for (int i = 0; i < quantity; i++) {
dropItem(location, is); dropItem(location, is);
} }
@ -123,7 +116,7 @@ public final class Misc {
* @param itemStack The item to drop * @param itemStack The item to drop
* @return Dropped Item entity or null if invalid or cancelled * @return Dropped Item entity or null if invalid or cancelled
*/ */
public static Item dropItem(Location location, ItemStack itemStack) { public Item dropItem(Location location, ItemStack itemStack) {
if (itemStack.getType() == Material.AIR) { if (itemStack.getType() == Material.AIR) {
return null; return null;
} }
@ -147,7 +140,7 @@ public final class Misc {
* @param speed the speed that the item should travel * @param speed the speed that the item should travel
* @param quantity The amount of items to drop * @param quantity The amount of items to drop
*/ */
public static void spawnItemsTowardsLocation(Location fromLocation, Location toLocation, ItemStack is, int quantity, double speed) { public void spawnItemsTowardsLocation(Location fromLocation, Location toLocation, ItemStack is, int quantity, double speed) {
for (int i = 0; i < quantity; i++) { for (int i = 0; i < quantity; i++) {
spawnItemTowardsLocation(fromLocation, toLocation, is, speed); spawnItemTowardsLocation(fromLocation, toLocation, is, speed);
} }
@ -163,7 +156,7 @@ public final class Misc {
* @param speed the speed that the item should travel * @param speed the speed that the item should travel
* @return Dropped Item entity or null if invalid or cancelled * @return Dropped Item entity or null if invalid or cancelled
*/ */
public static Item spawnItemTowardsLocation(Location fromLocation, Location toLocation, ItemStack itemToSpawn, double speed) { public Item spawnItemTowardsLocation(Location fromLocation, Location toLocation, ItemStack itemToSpawn, double speed) {
if (itemToSpawn.getType() == Material.AIR) { if (itemToSpawn.getType() == Material.AIR) {
return null; return null;
} }
@ -196,16 +189,16 @@ public final class Misc {
return spawnedItem; return spawnedItem;
} }
public static void profileCleanup(String playerName) { public void profileCleanup(String playerName) {
Player player = pluginRef.getServer().getPlayerExact(playerName); Player player = pluginRef.getServer().getPlayerExact(playerName);
if (player != null) { if (player != null) {
pluginRef.getUserManager().remove(player); pluginRef.getUserManager().remove(player);
new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading new PlayerProfileLoadingTask(pluginRef, player).runTaskLaterAsynchronously(pluginRef, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading
} }
} }
public static String getModName(String materialName) { public String getModName(String materialName) {
for (String mod : modNames) { for (String mod : modNames) {
if (materialName.contains(mod)) { if (materialName.contains(mod)) {
return mod; return mod;
@ -224,7 +217,7 @@ public final class Misc {
/** /**
* Gets a random location near the specified location * Gets a random location near the specified location
*/ */
public static Location getLocationOffset(Location location, double strength) { public Location getLocationOffset(Location location, double strength) {
double blockX = location.getBlockX(); double blockX = location.getBlockX();
double blockZ = location.getBlockZ(); double blockZ = location.getBlockZ();
@ -238,7 +231,7 @@ public final class Misc {
return new Location(location.getWorld(), blockX, location.getY(), blockZ); return new Location(location.getWorld(), blockX, location.getY(), blockZ);
} }
public static Random getRandom() { public Random getRandom() {
return random; return random;
} }
} }

View File

@ -80,7 +80,7 @@ public final class MobHealthBarManager {
target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(pluginRef, false)); target.setMetadata(MetadataConstants.NAME_VISIBILITY_METAKEY, new FixedMetadataValue(pluginRef, false));
} }
new MobHealthDisplayUpdaterTask(target).runTaskLater(pluginRef, displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds new MobHealthDisplayUpdaterTask(target).runTaskLater(pluginRef, displayTime * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
} }
} }

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -36,7 +35,7 @@ public final class CommandTools {
return true; return true;
} else if (pluginRef.getConfigManager().getConfigCommands().isLimitInspectRange() } else if (pluginRef.getConfigManager().getConfigCommands().isLimitInspectRange()
&& sender instanceof Player && sender instanceof Player
&& !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), && !pluginRef.getMiscTools().isNear(((Player) sender).getLocation(), target.getLocation(),
pluginRef.getConfigManager().getConfigCommands().getInspectCommandMaxDistance()) pluginRef.getConfigManager().getConfigCommands().getInspectCommandMaxDistance())
&& !hasPermission) { && !hasPermission) {
sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.TooFar")); sender.sendMessage(pluginRef.getLocaleManager().getString("Inspect.TooFar"));

View File

@ -7,7 +7,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.events.scoreboard.McMMOScoreboardMakeboardEvent; import com.gmail.nossr50.events.scoreboard.McMMOScoreboardMakeboardEvent;
import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason; import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot; import org.bukkit.scoreboard.DisplaySlot;
@ -291,7 +290,7 @@ public class ScoreboardManager {
if (displayTime == -1) { if (displayTime == -1) {
wrapper.showBoardWithNoRevert(); wrapper.showBoardWithNoRevert();
} else { } else {
wrapper.showBoardAndScheduleRevert(displayTime * Misc.TICK_CONVERSION_FACTOR); wrapper.showBoardAndScheduleRevert(displayTime * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR);
} }
} }
@ -308,7 +307,7 @@ public class ScoreboardManager {
} }
public void setRevertTimer(String playerName, int seconds) { public void setRevertTimer(String playerName, int seconds) {
PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert(seconds * Misc.TICK_CONVERSION_FACTOR); PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert(seconds * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR);
} }
public List<String> getDirtyPowerLevels() { public List<String> getDirtyPowerLevels() {

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.util.scoreboards;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -94,7 +93,7 @@ public class ScoreboardStrings {
ChatColor.DARK_GREEN, ChatColor.DARK_GREEN,
ChatColor.DARK_BLUE); ChatColor.DARK_BLUE);
Collections.shuffle(colors, Misc.getRandom()); Collections.shuffle(colors, pluginRef.getMiscTools().getRandom());
int i = 0; int i = 0;
for (PrimarySkillType primarySkillType : PrimarySkillType.values()) { for (PrimarySkillType primarySkillType : PrimarySkillType.values()) {

View File

@ -11,7 +11,6 @@ import com.gmail.nossr50.events.scoreboard.ScoreboardEventReason;
import com.gmail.nossr50.events.scoreboard.ScoreboardObjectiveEventReason; import com.gmail.nossr50.events.scoreboard.ScoreboardObjectiveEventReason;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Misc;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -82,7 +81,7 @@ public class ScoreboardWrapper {
if (cooldownTask == null) { if (cooldownTask == null) {
// Repeat every 5 seconds. // Repeat every 5 seconds.
// Cancels once all cooldowns are done, using stopCooldownUpdating(). // Cancels once all cooldowns are done, using stopCooldownUpdating().
cooldownTask = new ScoreboardCooldownTask().runTaskTimer(pluginRef, 5 * Misc.TICK_CONVERSION_FACTOR, 5 * Misc.TICK_CONVERSION_FACTOR); cooldownTask = new ScoreboardCooldownTask().runTaskTimer(pluginRef, 5 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR, 5 * pluginRef.getMiscTools().TICK_CONVERSION_FACTOR);
} }
} }

View File

@ -18,7 +18,6 @@ import com.gmail.nossr50.skills.axes.AxesManager;
import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.Misc;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
@ -263,7 +262,7 @@ public final class CombatTools {
EntityType entityType = damager.getType(); EntityType entityType = damager.getType();
if (target instanceof Player) { if (target instanceof Player) {
if (Misc.isNPCEntityExcludingVillagers(target)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(target)) {
return; return;
} }
@ -348,7 +347,7 @@ public final class CombatTools {
if (tamer instanceof Player && pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TAMING, target)) { if (tamer instanceof Player && pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TAMING, target)) {
Player master = (Player) tamer; Player master = (Player) tamer;
if (!Misc.isNPCEntityExcludingVillagers(master) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.TAMING, master)) { if (!pluginRef.getMiscTools().isNPCEntityExcludingVillagers(master) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.TAMING, master)) {
processTamingCombat(target, master, wolf, event); processTamingCombat(target, master, wolf, event);
} }
} }
@ -359,11 +358,11 @@ public final class CombatTools {
if (projectileSource instanceof Player && pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ARCHERY, target)) { if (projectileSource instanceof Player && pluginRef.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ARCHERY, target)) {
Player player = (Player) projectileSource; Player player = (Player) projectileSource;
if (!Misc.isNPCEntityExcludingVillagers(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.ARCHERY, player)) { if (!pluginRef.getMiscTools().isNPCEntityExcludingVillagers(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.ARCHERY, player)) {
processArcheryCombat(target, player, event, arrow); processArcheryCombat(target, player, event, arrow);
} }
if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.TAMING, player)) { if (target.getType() != EntityType.CREEPER && !pluginRef.getMiscTools().isNPCEntityExcludingVillagers(player) && pluginRef.getSkillTools().doesPlayerHaveSkillPermission(PrimarySkillType.TAMING, player)) {
McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player); McMMOPlayer mcMMOPlayer = pluginRef.getUserManager().getPlayer(player);
TamingManager tamingManager = mcMMOPlayer.getTamingManager(); TamingManager tamingManager = mcMMOPlayer.getTamingManager();
tamingManager.attackTarget(target); tamingManager.attackTarget(target);
@ -564,7 +563,7 @@ public final class CombatTools {
break; break;
} }
if (Misc.isNPCEntityExcludingVillagers(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
continue; continue;
} }
@ -619,7 +618,7 @@ public final class CombatTools {
xpGainReason = XPGainReason.PVP; xpGainReason = XPGainReason.PVP;
Player defender = (Player) target; Player defender = (Player) target;
if (defender.isOnline() && pluginRef.getSkillTools().cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) { if (defender.isOnline() && pluginRef.getSkillTools().cooldownExpired(mcMMOPlayer.getRespawnATS(), pluginRef.getMiscTools().PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
baseXPMultiplier = 20 * pluginRef.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PVP); baseXPMultiplier = 20 * pluginRef.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PVP);
} }
} else { } else {
@ -886,7 +885,7 @@ public final class CombatTools {
Player player = (Player) attacker; Player player = (Player) attacker;
if (Misc.isNPCEntityExcludingVillagers(player) || Misc.isNPCEntityExcludingVillagers(target)) { if (pluginRef.getMiscTools().isNPCEntityExcludingVillagers(player) || pluginRef.getMiscTools().isNPCEntityExcludingVillagers(target)) {
return; return;
} }

View File

@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.datatypes.skills.ToolType; import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -316,7 +315,7 @@ public class SkillTools {
* @return the number of seconds remaining before the cooldown expires * @return the number of seconds remaining before the cooldown expires
*/ */
public int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) { public int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR); return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / pluginRef.getMiscTools().TIME_CONVERSION_FACTOR);
} }
/** /**
@ -328,7 +327,7 @@ public class SkillTools {
* @return true if the cooldown is expired * @return true if the cooldown is expired
*/ */
public boolean cooldownExpired(long deactivatedTimeStamp, int cooldown) { public boolean cooldownExpired(long deactivatedTimeStamp, int cooldown) {
return System.currentTimeMillis() >= (deactivatedTimeStamp + cooldown) * Misc.TIME_CONVERSION_FACTOR; return System.currentTimeMillis() >= (deactivatedTimeStamp + cooldown) * pluginRef.getMiscTools().TIME_CONVERSION_FACTOR;
} }
/** /**
@ -345,7 +344,7 @@ public class SkillTools {
Location location = player.getLocation(); Location location = player.getLocation();
for (Player otherPlayer : player.getWorld().getPlayers()) { for (Player otherPlayer : player.getWorld().getPlayers()) {
if (otherPlayer != player && Misc.isNear(location, otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) { if (otherPlayer != player && pluginRef.getMiscTools().isNear(location, otherPlayer.getLocation(), pluginRef.getMiscTools().SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
pluginRef.getNotificationManager().sendNearbyPlayersInformation(otherPlayer, notificationType, key, player.getName()); pluginRef.getNotificationManager().sendNearbyPlayersInformation(otherPlayer, notificationType, key, player.getName());
} }
} }

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.util.sounds;
import com.gmail.nossr50.config.hocon.sound.SoundSetting; import com.gmail.nossr50.config.hocon.sound.SoundSetting;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.SoundCategory; import org.bukkit.SoundCategory;
@ -100,10 +99,10 @@ public class SoundManager {
} }
public float getFizzPitch() { public float getFizzPitch() {
return 2.6F + (Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.8F; return 2.6F + (pluginRef.getMiscTools().getRandom().nextFloat() - pluginRef.getMiscTools().getRandom().nextFloat()) * 0.8F;
} }
public float getPopPitch() { public float getPopPitch() {
return ((Misc.getRandom().nextFloat() - Misc.getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F; return ((pluginRef.getMiscTools().getRandom().nextFloat() - pluginRef.getMiscTools().getRandom().nextFloat()) * 0.7F + 1.0F) * 2.0F;
} }
} }