Moved everything that could be moved from PlayerProfile to McMMOPlayer

PlayerProfile now only store stored (flatfile or MySQL) data
This commit is contained in:
bm01
2013-03-03 17:06:05 +01:00
parent f8b4412049
commit c0b7f8a323
24 changed files with 405 additions and 603 deletions

View File

@ -6,7 +6,6 @@ import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
@ -52,14 +51,12 @@ public class AcrobaticsManager extends SkillManager {
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
ParticleEffectUtils.playDodgeEffect(player);
PlayerProfile playerProfile = getProfile();
if (playerProfile.useChatNotifications()) {
if (mcMMOPlayer.useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
// Why do we check respawn cooldown here?
if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
if (System.currentTimeMillis() >= mcMMOPlayer.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
applyXpGain(damage * Acrobatics.dodgeXpModifier);
}

View File

@ -86,11 +86,11 @@ public class ArcheryManager extends SkillManager {
defender.teleport(dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
if (UserManager.getPlayer(defender).useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
}
if (getProfile().useChatNotifications()) {
if (mcMMOPlayer.useChatNotifications()) {
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}

View File

@ -41,11 +41,11 @@ public class AxesManager extends SkillManager {
}
public boolean canUseSkullSplitter(LivingEntity target) {
return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
return target.isValid() && mcMMOPlayer.getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
}
public boolean canActivateAbility() {
return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer());
return mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer());
}
/**
@ -118,14 +118,14 @@ public class AxesManager extends SkillManager {
ParticleEffectUtils.playGreaterImpactEffect(target);
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
if (getProfile().useChatNotifications()) {
if (mcMMOPlayer.useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
}
if (target instanceof Player) {
Player defender = (Player) target;
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
if (UserManager.getPlayer(defender).useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
}
}

View File

@ -15,7 +15,6 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
@ -30,7 +29,6 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class HerbalismManager extends SkillManager {
@ -62,15 +60,15 @@ public class HerbalismManager extends SkillManager {
}
public boolean canGreenTerraBlock(BlockState blockState) {
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState);
return mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState);
}
public boolean canActivateAbility() {
return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer());
return mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer());
}
public boolean canGreenTerraPlant() {
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
return mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA);
}
/**
@ -288,9 +286,7 @@ public class HerbalismManager extends SkillManager {
return;
}
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) {
if (mcMMOPlayer.getAbilityMode(AbilityType.GREEN_TERRA)) {
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available

View File

@ -86,7 +86,6 @@ public class MiningManager extends SkillManager{
return;
}
PlayerProfile profile = getProfile();
TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class);
SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
@ -97,8 +96,8 @@ public class MiningManager extends SkillManager{
targetBlock.setData((byte) 0x0);
targetBlock.setType(Material.AIR);
profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
profile.setAbilityInformed(AbilityType.BLAST_MINING, false);
getProfile().setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
}
/**

View File

@ -204,9 +204,9 @@ public class Repair {
* @param anvilID The item ID of the anvil block
*/
public static void placedAnvilCheck(Player player, int anvilID) {
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!profile.getPlacedAnvil()) {
if (!mcMMOPlayer.getPlacedAnvil()) {
if (mcMMO.spoutEnabled) {
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
@ -219,7 +219,7 @@ public class Repair {
}
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
profile.togglePlacedAnvil();
mcMMOPlayer.togglePlacedAnvil();
}
}

View File

@ -11,7 +11,7 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.ItemUtils;
@ -59,9 +59,9 @@ public class Salvage {
* @param anvilID The item ID of the anvil block
*/
public static void placedAnvilCheck(final Player player, final int anvilID) {
final PlayerProfile profile = UserManager.getPlayer(player).getProfile();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (!profile.getPlacedSalvageAnvil()) {
if (!mcMMOPlayer.getPlacedSalvageAnvil()) {
if (mcMMO.spoutEnabled) {
final SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
@ -74,7 +74,7 @@ public class Salvage {
}
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
profile.togglePlacedSalvageAnvil();
mcMMOPlayer.togglePlacedSalvageAnvil();
}
}

View File

@ -34,14 +34,14 @@ public class SwordsManager extends SkillManager {
BleedTimerTask.add(target, Swords.bleedBaseTicks);
}
if (getProfile().useChatNotifications()) {
if (mcMMOPlayer.useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
}
if (target instanceof Player) {
Player defender = (Player) target;
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
if (UserManager.getPlayer(defender).useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
}
}

View File

@ -108,7 +108,7 @@ public class TamingManager extends SkillManager {
* @param livingEntity The entity to examine
*/
public void beastLore(LivingEntity livingEntity) {
BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(mcMMOPlayer.getPlayer(), livingEntity);
BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(getPlayer(), livingEntity);
eventHandler.sendInspectMessage();
}
@ -119,11 +119,11 @@ public class TamingManager extends SkillManager {
* @param summonAmount The amount of material needed to summon the entity
*/
private void callOfTheWild(EntityType type, int summonAmount) {
if (!Permissions.callOfTheWild(mcMMOPlayer.getPlayer())) {
if (!Permissions.callOfTheWild(getPlayer())) {
return;
}
CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(mcMMOPlayer.getPlayer(), type, summonAmount);
CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(getPlayer(), type, summonAmount);
ItemStack inHand = eventHandler.inHand;
int inHandAmount = inHand.getAmount();