Fix compiler errors

This commit is contained in:
nossr50 2019-05-18 16:25:52 -07:00
parent 04b4a8e069
commit 04fb4c30fe
21 changed files with 79 additions and 433 deletions

View File

@ -42,8 +42,7 @@ public class XprateCommand implements TabExecutor {
10, 10 * 20, 20); 10, 10 * 20, 20);
} }
if(mcMMO.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) if (mcMMO.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) {
{
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
} }
@ -84,16 +83,14 @@ public class XprateCommand implements TabExecutor {
mcMMO.getDynamicSettingsManager().getExperienceManager().setGlobalXpMult(newXpRate); mcMMO.getDynamicSettingsManager().getExperienceManager().setGlobalXpMult(newXpRate);
if(mcMMO.getConfigManager().getConfigEvent().isSendTitleMessages()) if (mcMMO.getConfigManager().getConfigEvent().isSendTitleMessages()) {
{
NotificationManager.broadcastTitle(mcMMO.p.getServer(), NotificationManager.broadcastTitle(mcMMO.p.getServer(),
LocaleLoader.getString("Commands.Event.Start"), LocaleLoader.getString("Commands.Event.Start"),
LocaleLoader.getString("Commands.Event.XP", newXpRate), LocaleLoader.getString("Commands.Event.XP", newXpRate),
10, 10 * 20, 20); 10, 10 * 20, 20);
} }
if(mcMMO.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) if (mcMMO.getConfigManager().getConfigEvent().isBroadcastXPRateEventMessages()) {
{
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start")); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate)); mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));
} }

View File

@ -1,337 +0,0 @@
package com.gmail.nossr50.config.experience;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class ExperienceConfig extends AutoUpdateConfigLoader {
private static ExperienceConfig instance;
private ExperienceConfig() {
super("experience.yml");
validate();
}
public static ExperienceConfig getInstance() {
if (instance == null) {
instance = new ExperienceConfig();
}
return instance;
}
@Override
protected void loadKeys() {}
@Override
protected boolean validateKeys() {
List<String> reason = new ArrayList<String>();
/*
* FORMULA SETTINGS
*/
/* Curve values */
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.multiplier should be greater than 0!");
}
if (getMultiplier(FormulaType.LINEAR) <= 0) {
reason.add("Experience_Formula.Linear_Values.multiplier should be greater than 0!");
}
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
reason.add("Experience_Formula.Exponential_Values.exponent should be greater than 0!");
}
/* Global modifier */
if (getExperienceGainsGlobalMultiplier() <= 0) {
reason.add("Experience_Formula.Multiplier.Global should be greater than 0!");
}
/* PVP modifier */
if (getPlayerVersusPlayerXP() < 0) {
reason.add("Experience_Formula.Multiplier.PVP should be at least 0!");
}
/* Spawned Mob modifier */
if (getSpawnedMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Mobspawners.Multiplier should be at least 0!");
}
/* Bred Mob modifier */
if (getBredMobXpMultiplier() < 0) {
reason.add("Experience_Formula.Breeding.Multiplier should be at least 0!");
}
/* Conversion */
if (getExpModifier() <= 0) {
reason.add("Conversion.Exp_Modifier should be greater than 0!");
}
/*
* XP SETTINGS
*/
/* Alchemy */
for (PotionStage potionStage : PotionStage.values()) {
if (getPotionXP(potionStage) < 0) {
reason.add("Experience_Values.Alchemy.Potion_Stage_" + potionStage.toNumerical() + " should be at least 0!");
}
}
/* Archery */
if (getArcheryDistanceMultiplier() < 0) {
reason.add("Experience_Values.Archery.Distance_Multiplier should be at least 0!");
}
/* Combat XP Multipliers */
if (getAnimalsXP() < 0) {
reason.add("Experience_Values.Combat.Multiplier.Animals should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
if (getRollXPModifier() < 0) {
reason.add("Skills.Acrobatics.Roll_XP_Modifier should be at least 0!");
}
if (getFallXPModifier() < 0) {
reason.add("Skills.Acrobatics.Fall_XP_Modifier should be at least 0!");
}
/* Fishing */
// TODO: Add validation for each fish type once enum is available.
if (getFishingShakeXP() <= 0) {
reason.add("Experience_Values.Fishing.Shake should be greater than 0!");
}
/* Repair */
if (getRepairXPBase() <= 0) {
reason.add("Experience_Values.Repair.Base should be greater than 0!");
}
/* Taming */
if (getTamingXP(EntityType.WOLF) <= 0) {
reason.add("Experience_Values.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXP(EntityType.OCELOT) <= 0) {
reason.add("Experience_Values.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
return noErrorsInConfig(reason);
}
public boolean isEarlyGameBoostEnabled() { return config.getBoolean("EarlyGameBoost.Enabled", true); }
public double getEarlyGameBoostMultiplier() { return config.getDouble("EarlyGameBoost.MaxLevelMultiplier", 0.05D); }
/*
* FORMULA SETTINGS
*/
/* EXPLOIT TOGGLES */
public boolean isEndermanEndermiteFarmingPrevented() { return config.getBoolean("ExploitFix.EndermanEndermiteFarms", true); }
public boolean isPistonExploitPrevented() { return config.getBoolean("ExploitFix.Pistons", false); }
public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }
/* Curve settings */
public FormulaType getFormulaType() { return FormulaType.getFormulaType(config.getString("Experience_Formula.Curve")); }
public boolean getCumulativeCurveEnabled() { return config.getBoolean("Experience_Formula.Cumulative_Curve", false); }
/* Curve values */
public double getMultiplier(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.multiplier"); }
public int getBase(FormulaType type) { return config.getInt("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.base"); }
public double getExponent(FormulaType type) { return config.getDouble("Experience_Formula." + StringUtils.getCapitalized(type.toString()) + "_Values.exponent"); }
/* Global modifier */
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience_Formula.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience_Formula.Multiplier.Global", value); }
/* PVP modifier */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience_Formula.Multiplier.PVP", 1.0); }
/* Spawned Mob modifier */
public double getSpawnedMobXpMultiplier() { return config.getDouble("Experience_Formula.Mobspawners.Multiplier", 0.0); }
public double getBredMobXpMultiplier() { return config.getDouble("Experience_Formula.Breeding.Multiplier", 1.0); }
/* Skill modifiers */
public double getFormulaSkillModifier(PrimarySkillType skill) { return config.getDouble("Experience_Formula.Modifier." + StringUtils.getCapitalized(skill.toString())); }
/* Custom XP perk */
public double getCustomXpPerkBoost() { return config.getDouble("Experience_Formula.Custom_XP_Perk.Boost", 1.25); }
/* Diminished Returns */
public float getDiminishedReturnsCap() { return (float) config.getDouble("Dimished_Returns.Guaranteed_Minimum_Percentage", 0.05D); }
public boolean getDiminishedReturnsEnabled() { return config.getBoolean("Diminished_Returns.Enabled", false); }
public int getDiminishedReturnsThreshold(PrimarySkillType skill) { return config.getInt("Diminished_Returns.Threshold." + StringUtils.getCapitalized(skill.toString()), 20000); }
public int getDiminishedReturnsTimeInterval() { return config.getInt("Diminished_Returns.Time_Interval", 10); }
/* Conversion */
public double getExpModifier() { return config.getDouble("Conversion.Exp_Modifier", 1); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience_Values.PVP.Rewards", true); }
/* Combat XP Multipliers */
public double getCombatXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
public double getAnimalsXP() { return config.getDouble("Experience_Values.Combat.Multiplier.Animals", 1.0); }
public boolean hasCombatXP(EntityType entity) {return config.contains("Experience_Values.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
/* Materials */
public int getXp(PrimarySkillType skill, Material data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
/* Materials */
public int getXp(PrimarySkillType skill, BlockData data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, Material data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
return config.contains(wildcardString);
}
public boolean doesBlockGiveSkillXP(PrimarySkillType skill, BlockData data)
{
String baseString = "Experience_Values." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
return config.contains(wildcardString);
}
/*
* Experience Bar Stuff
*/
public boolean isPartyExperienceBarsEnabled()
{
return config.getBoolean("Experience_Bars.Update.Party", true);
}
public boolean isPassiveGainsExperienceBarsEnabled()
{
return config.getBoolean("Experience_Bars.Update.Passive", true);
}
public boolean getDoExperienceBarsAlwaysUpdateTitle()
{
return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.Enable", false) || getAddExtraDetails();
}
public boolean getAddExtraDetails() { return config.getBoolean("Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained.ExtraDetails", false);}
public boolean isExperienceBarsEnabled() { return config.getBoolean("Experience_Bars.Enable", true); }
public boolean isExperienceBarEnabled(PrimarySkillType primarySkillType) { return config.getBoolean("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Enable", true);}
public BarColor getExperienceBarColor(PrimarySkillType primarySkillType)
{
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".Color");
for(BarColor barColor : BarColor.values())
{
if(barColor.toString().equalsIgnoreCase(colorValueFromConfig))
return barColor;
}
//In case the value is invalid
return BarColor.WHITE;
}
public BarStyle getExperienceBarStyle(PrimarySkillType primarySkillType)
{
String colorValueFromConfig = config.getString("Experience_Bars."+StringUtils.getCapitalized(primarySkillType.toString())+".BarStyle");
for(BarStyle barStyle : BarStyle.values())
{
if(barStyle.toString().equalsIgnoreCase(colorValueFromConfig))
return barStyle;
}
//In case the value is invalid
return BarStyle.SOLID;
}
/* Acrobatics */
public int getDodgeXPModifier() { return config.getInt("Experience_Values.Acrobatics.Dodge", 120); }
public int getRollXPModifier() { return config.getInt("Experience_Values.Acrobatics.Roll", 80); }
public int getFallXPModifier() { return config.getInt("Experience_Values.Acrobatics.Fall", 120); }
public double getFeatherFallXPModifier() { return config.getDouble("Experience_Values.Acrobatics.FeatherFall_Multiplier", 2.0); }
/* Alchemy */
public double getPotionXP(PotionStage stage) { return config.getDouble("Experience_Values.Alchemy.Potion_Stage_" + stage.toNumerical(), 10D); }
/* Archery */
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience_Values.Archery.Distance_Multiplier", 0.025); }
public int getFishingShakeXP() { return config.getInt("Experience_Values.Fishing.Shake", 50); }
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience_Values.Repair.Base", 1000.0); }
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience_Values.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
/* Taming */
public int getTamingXP(EntityType type)
{
return config.getInt("Experience_Values.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
}
public boolean preventStoneLavaFarming() { return config.getBoolean("ExploitFix.LavaStoneAndCobbleFarming", true);}
}

View File

@ -18,7 +18,7 @@ import java.util.HashMap;
* The DSM (Dynamic Settings Manager) is responsible for * The DSM (Dynamic Settings Manager) is responsible for
* 1) Inits managers which convert platform generic settings from the configs (specifically pulling from ConfigManager) into usable data for this platform * 1) Inits managers which convert platform generic settings from the configs (specifically pulling from ConfigManager) into usable data for this platform
* 2) Retrieving or Setting variables for core systems in mcMMO without permanent change (WIP) * 2) Retrieving or Setting variables for core systems in mcMMO without permanent change (WIP)
* * <p>
* This class is a WIP, expect API breakages in the future * This class is a WIP, expect API breakages in the future
* Currently implementation of this class will only be friendly to Bukkit, this will change in the near future * Currently implementation of this class will only be friendly to Bukkit, this will change in the near future
*/ */

View File

@ -2,7 +2,6 @@ package com.gmail.nossr50.listeners;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.meta.BonusDropMeta; import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -167,16 +166,13 @@ public class BlockListener implements Listener {
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockFormEvent(BlockFormEvent event) public void onBlockFormEvent(BlockFormEvent event) {
{
/* WORLD BLACKLIST CHECK */ /* WORLD BLACKLIST CHECK */
if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getBlock().getWorld()))
return; return;
if(mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitSkills().isPreventCobblestoneStoneGeneratorXP()) if (mcMMO.getConfigManager().getConfigExploitPrevention().getConfigSectionExploitSkills().isPreventCobblestoneStoneGeneratorXP()) {
{ if (event.getNewState().getType() != Material.OBSIDIAN && BlockUtils.shouldBeWatched(event.getNewState())) {
if(event.getNewState().getType() != Material.OBSIDIAN && BlockUtils.shouldBeWatched(event.getNewState()))
{
mcMMO.getPlaceStore().setTrue(event.getNewState()); mcMMO.getPlaceStore().setTrue(event.getNewState());
} }
} }

View File

@ -64,8 +64,7 @@ public class EntityListener implements Listener {
return; return;
//It's rare but targets can be null sometimes //It's rare but targets can be null sometimes
if(event.getTarget() == null) if (event.getTarget() == null) {
{
return; return;
} }
@ -365,10 +364,8 @@ public class EntityListener implements Listener {
/** /**
* This sets entity names back to whatever they are supposed to be * This sets entity names back to whatever they are supposed to be
*/ */
if(event.getFinalDamage() >= target.getHealth()) if (event.getFinalDamage() >= target.getHealth()) {
{ if (attacker instanceof LivingEntity) {
if(attacker instanceof LivingEntity)
{
CombatUtils.fixNames((LivingEntity) attacker); CombatUtils.fixNames((LivingEntity) attacker);
} }

View File

@ -5,7 +5,6 @@ import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.PartyChatManager; import com.gmail.nossr50.chat.PartyChatManager;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist; import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.core.MetadataConstants; import com.gmail.nossr50.core.MetadataConstants;
import com.gmail.nossr50.datatypes.chat.ChatMode; import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.datatypes.party.Party;
@ -49,7 +48,6 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import sun.security.krb5.Config;
public class PlayerListener implements Listener { public class PlayerListener implements Listener {
private final mcMMO plugin; private final mcMMO plugin;
@ -531,7 +529,7 @@ public class PlayerListener implements Listener {
} }
if (plugin.isXPEventEnabled() && mcMMO.getConfigManager().getConfigEvent().isShowXPRateInfoOnPlayerJoin()) { if (plugin.isXPEventEnabled() && mcMMO.getConfigManager().getConfigEvent().isShowXPRateInfoOnPlayerJoin()) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier())); player.sendMessage(LocaleLoader.getString("XPRate.Event", mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()));
} }
} }

View File

@ -510,8 +510,7 @@ public class mcMMO extends JavaPlugin {
System.out.println("[mcMMO]" + " enabling Acrobatics Skills"); System.out.println("[mcMMO]" + " enabling Acrobatics Skills");
//TODO: Should do this differently //TODO: Should do this differently
if(mcMMO.getConfigManager().getConfigCoreSkills().isRollEnabled()) if (mcMMO.getConfigManager().getConfigCoreSkills().isRollEnabled()) {
{
InteractionManager.registerSubSkill(new Roll()); InteractionManager.registerSubSkill(new Roll());
} }
} }

View File

@ -97,8 +97,7 @@ public class Herbalism {
} }
} else { } else {
//Check the block itself first //Check the block itself first
if(!mcMMO.getPlaceStore().isTrue(block)) if (!mcMMO.getPlaceStore().isTrue(block)) {
{
dropAmount++; dropAmount++;
if (herbalismManager.checkDoubleDrop(blockState)) if (herbalismManager.checkDoubleDrop(blockState))

View File

@ -249,11 +249,9 @@ public class TamingManager extends SkillManager {
} }
public void attackTarget(LivingEntity target) { public void attackTarget(LivingEntity target) {
if(target instanceof Tameable) if (target instanceof Tameable) {
{
Tameable tameable = (Tameable) target; Tameable tameable = (Tameable) target;
if(tameable.getOwner() == getPlayer()) if (tameable.getOwner() == getPlayer()) {
{
return; return;
} }
} }

View File

@ -37,6 +37,7 @@ public final class BlockUtils {
/** /**
* Marks a block to drop extra copies of items * Marks a block to drop extra copies of items
*
* @param blockState target blockstate * @param blockState target blockstate
* @param amount amount of extra items to drop * @param amount amount of extra items to drop
*/ */

View File

@ -43,8 +43,7 @@ public class ExperienceManager {
tamingExperienceMap = new HashMap<>(); tamingExperienceMap = new HashMap<>();
} }
private void registerDefaultValues() private void registerDefaultValues() {
{
fillCombatXPMultiplierMap(mcMMO.getConfigManager().getConfigExperience().getCombatExperienceMap()); fillCombatXPMultiplierMap(mcMMO.getConfigManager().getConfigExperience().getCombatExperienceMap());
registerSpecialCombatXPMultiplierMap(mcMMO.getConfigManager().getConfigExperience().getSpecialCombatExperienceMap()); registerSpecialCombatXPMultiplierMap(mcMMO.getConfigManager().getConfigExperience().getSpecialCombatExperienceMap());
buildBlockXPMaps(); buildBlockXPMaps();
@ -55,21 +54,18 @@ public class ExperienceManager {
* Fills the combat XP multiplier map with values from a platform generic map * Fills the combat XP multiplier map with values from a platform generic map
* Platform safe map, is just a map which uses strings to define target entities/etc * Platform safe map, is just a map which uses strings to define target entities/etc
* Platform safe maps are converted to ENUMs for the platform for convenience * Platform safe maps are converted to ENUMs for the platform for convenience
*
* @param platformSafeMap the platform safe map * @param platformSafeMap the platform safe map
*/ */
public void fillCombatXPMultiplierMap(HashMap<String, Float> platformSafeMap) { public void fillCombatXPMultiplierMap(HashMap<String, Float> platformSafeMap) {
mcMMO.p.getLogger().info("Registering combat XP values..."); mcMMO.p.getLogger().info("Registering combat XP values...");
for(String entityString : platformSafeMap.keySet()) for (String entityString : platformSafeMap.keySet()) {
{
//Iterate over all EntityType(s) //Iterate over all EntityType(s)
for(EntityType type : EntityType.values()) for (EntityType type : EntityType.values()) {
{
//Match ignoring case //Match ignoring case
if(entityString.equalsIgnoreCase(entityString)) if (entityString.equalsIgnoreCase(entityString)) {
{
//Check for duplicates and warn the admin //Check for duplicates and warn the admin
if(combatXPMultiplierMap.containsKey(entityString)) if (combatXPMultiplierMap.containsKey(entityString)) {
{
mcMMO.p.getLogger().severe("Entity named " + entityString + " has multiple values in the combat experience config!"); mcMMO.p.getLogger().severe("Entity named " + entityString + " has multiple values in the combat experience config!");
} }
//Match found //Match found
@ -84,10 +80,10 @@ public class ExperienceManager {
/** /**
* Registers the map values for special combat XP to the specified map * Registers the map values for special combat XP to the specified map
*
* @param map target map * @param map target map
*/ */
public void registerSpecialCombatXPMultiplierMap(HashMap<SpecialXPKey, Float> map) public void registerSpecialCombatXPMultiplierMap(HashMap<SpecialXPKey, Float> map) {
{
mcMMO.p.getLogger().info("Registering special combat XP values..."); mcMMO.p.getLogger().info("Registering special combat XP values...");
specialCombatXPMultiplierMap = map; specialCombatXPMultiplierMap = map;
} }
@ -190,6 +186,7 @@ public class ExperienceManager {
/** /**
* Set the mining block XP map to the provided one * Set the mining block XP map to the provided one
*
* @param miningFullyQualifiedBlockXpMap the XP map to change to * @param miningFullyQualifiedBlockXpMap the XP map to change to
*/ */
public void setMiningFullyQualifiedBlockXpMap(HashMap<String, Integer> miningFullyQualifiedBlockXpMap) { public void setMiningFullyQualifiedBlockXpMap(HashMap<String, Integer> miningFullyQualifiedBlockXpMap) {
@ -199,6 +196,7 @@ public class ExperienceManager {
/** /**
* Set the mining block XP map to the provided one * Set the mining block XP map to the provided one
*
* @param herbalismFullyQualifiedBlockXpMap the XP map to change to * @param herbalismFullyQualifiedBlockXpMap the XP map to change to
*/ */
public void setHerbalismFullyQualifiedBlockXpMap(HashMap<String, Integer> herbalismFullyQualifiedBlockXpMap) { public void setHerbalismFullyQualifiedBlockXpMap(HashMap<String, Integer> herbalismFullyQualifiedBlockXpMap) {
@ -208,6 +206,7 @@ public class ExperienceManager {
/** /**
* Set the mining block XP map to the provided one * Set the mining block XP map to the provided one
*
* @param woodcuttingFullyQualifiedBlockXpMap the XP map to change to * @param woodcuttingFullyQualifiedBlockXpMap the XP map to change to
*/ */
public void setWoodcuttingFullyQualifiedBlockXpMap(HashMap<String, Integer> woodcuttingFullyQualifiedBlockXpMap) { public void setWoodcuttingFullyQualifiedBlockXpMap(HashMap<String, Integer> woodcuttingFullyQualifiedBlockXpMap) {
@ -217,6 +216,7 @@ public class ExperienceManager {
/** /**
* Set the mining block XP map to the provided one * Set the mining block XP map to the provided one
*
* @param excavationFullyQualifiedBlockXpMap the XP map to change to * @param excavationFullyQualifiedBlockXpMap the XP map to change to
*/ */
public void setExcavationFullyQualifiedBlockXpMap(HashMap<String, Integer> excavationFullyQualifiedBlockXpMap) { public void setExcavationFullyQualifiedBlockXpMap(HashMap<String, Integer> excavationFullyQualifiedBlockXpMap) {
@ -372,31 +372,31 @@ public class ExperienceManager {
/** /**
* Get the XP multiplier value for a special XP group * Get the XP multiplier value for a special XP group
*
* @param specialXPKey target special XP group * @param specialXPKey target special XP group
* @return XP multiplier for target special XP group * @return XP multiplier for target special XP group
*/ */
public float getSpecialCombatXP(SpecialXPKey specialXPKey) public float getSpecialCombatXP(SpecialXPKey specialXPKey) {
{
return specialCombatXPMultiplierMap.get(specialXPKey); return specialCombatXPMultiplierMap.get(specialXPKey);
} }
/** /**
* Gets the combat XP multiplier for this entity type * Gets the combat XP multiplier for this entity type
*
* @param entityType target entity type * @param entityType target entity type
* @return the combat XP multiplier for this entity * @return the combat XP multiplier for this entity
*/ */
public float getCombatXPMultiplier(EntityType entityType) public float getCombatXPMultiplier(EntityType entityType) {
{
return combatXPMultiplierMap.get(entityType); return combatXPMultiplierMap.get(entityType);
} }
/** /**
* Returns true/false if a EntityType has a defined XP multiplier (from the config typically) * Returns true/false if a EntityType has a defined XP multiplier (from the config typically)
*
* @param entityType target entity type * @param entityType target entity type
* @return true if entity type has XP * @return true if entity type has XP
*/ */
public boolean hasCombatXP(EntityType entityType) public boolean hasCombatXP(EntityType entityType) {
{
return combatXPMultiplierMap.get(entityType) != null; return combatXPMultiplierMap.get(entityType) != null;
} }
} }

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.util.player; package com.gmail.nossr50.util.player;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.interactions.NotificationType; import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType; import com.gmail.nossr50.datatypes.notifications.SensitiveCommandType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -154,6 +153,7 @@ public class NotificationManager {
/** /**
* Sends a message to all admins with the admin notification formatting from the locale * Sends a message to all admins with the admin notification formatting from the locale
* Admins are currently players with either Operator status or Admin Chat permission * Admins are currently players with either Operator status or Admin Chat permission
*
* @param msg message fetched from locale * @param msg message fetched from locale
*/ */
private static void sendAdminNotification(String msg) { private static void sendAdminNotification(String msg) {
@ -161,10 +161,8 @@ public class NotificationManager {
if (!mcMMO.getConfigManager().getConfigAdmin().isSendAdminNotifications()) if (!mcMMO.getConfigManager().getConfigAdmin().isSendAdminNotifications())
return; return;
for(Player player : Bukkit.getServer().getOnlinePlayers()) for (Player player : Bukkit.getServer().getOnlinePlayers()) {
{ if (player.isOp() || Permissions.adminChat(player)) {
if(player.isOp() || Permissions.adminChat(player))
{
player.sendMessage(LocaleLoader.getString("Notifications.Admin.Format.Others", msg)); player.sendMessage(LocaleLoader.getString("Notifications.Admin.Format.Others", msg));
} }
} }
@ -175,6 +173,7 @@ public class NotificationManager {
/** /**
* Sends a confirmation message to the CommandSender who just executed an admin command * Sends a confirmation message to the CommandSender who just executed an admin command
*
* @param commandSender target command sender * @param commandSender target command sender
* @param msg message fetched from locale * @param msg message fetched from locale
*/ */
@ -184,6 +183,7 @@ public class NotificationManager {
/** /**
* Convenience method to report info about a command sender using a sensitive command * Convenience method to report info about a command sender using a sensitive command
*
* @param commandSender the command user * @param commandSender the command user
* @param sensitiveCommandType type of command issued * @param sensitiveCommandType type of command issued
*/ */
@ -193,14 +193,12 @@ public class NotificationManager {
*/ */
String senderName = LocaleLoader.getString("Server.ConsoleName"); String senderName = LocaleLoader.getString("Server.ConsoleName");
if(commandSender instanceof Player) if (commandSender instanceof Player) {
{
senderName = ((Player) commandSender).getDisplayName() + ChatColor.RESET + "-" + ((Player) commandSender).getUniqueId(); senderName = ((Player) commandSender).getDisplayName() + ChatColor.RESET + "-" + ((Player) commandSender).getUniqueId();
} }
//Send the notification //Send the notification
switch(sensitiveCommandType) switch (sensitiveCommandType) {
{
case XPRATE_MODIFY: case XPRATE_MODIFY:
sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others", addItemToFirstPositionOfArray(senderName, args))); sendAdminNotification(LocaleLoader.getString("Notifications.Admin.XPRate.Start.Others", addItemToFirstPositionOfArray(senderName, args)));
sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", args)); sendAdminCommandConfirmation(commandSender, LocaleLoader.getString("Notifications.Admin.XPRate.Start.Self", args));
@ -215,6 +213,7 @@ public class NotificationManager {
/** /**
* Takes an array and an object, makes a new array with object in the first position of the new array, * Takes an array and an object, makes a new array with object in the first position of the new array,
* and the following elements in this new array being a copy of the existing array retaining their order * and the following elements in this new array being a copy of the existing array retaining their order
*
* @param itemToAdd the string to put at the beginning of the new array * @param itemToAdd the string to put at the beginning of the new array
* @param existingArray the existing array to be copied to the new array at position [0]+1 relative to their original index * @param existingArray the existing array to be copied to the new array at position [0]+1 relative to their original index
* @return the new array combining itemToAdd at the start and existing array elements following while retaining their order * @return the new array combining itemToAdd at the start and existing array elements following while retaining their order

View File

@ -352,17 +352,16 @@ public final class CombatUtils {
/** /**
* This cleans up names from displaying in chat as hearts * This cleans up names from displaying in chat as hearts
*
* @param entity target entity * @param entity target entity
*/ */
public static void fixNames(LivingEntity entity) public static void fixNames(LivingEntity entity) {
{
List<MetadataValue> metadataValue = entity.getMetadata("mcMMO_oldName"); List<MetadataValue> metadataValue = entity.getMetadata("mcMMO_oldName");
if (metadataValue.size() <= 0) if (metadataValue.size() <= 0)
return; return;
if(metadataValue != null) if (metadataValue != null) {
{
OldName oldName = (OldName) metadataValue.get(0); OldName oldName = (OldName) metadataValue.get(0);
entity.setCustomName(oldName.asString()); entity.setCustomName(oldName.asString());
entity.setCustomNameVisible(false); entity.setCustomNameVisible(false);