These belong in their managers, not in McMMOPlayer

This commit is contained in:
GJ 2013-10-28 16:14:52 -04:00
parent ccb7fc5886
commit 9b3ae5c729
5 changed files with 84 additions and 92 deletions

View File

@ -84,7 +84,11 @@ public class FishingCommand extends SkillCommand {
// MASTER ANGLER // MASTER ANGLER
if (canMasterAngler) { if (canMasterAngler) {
double rawBiteChance = 1.0 / (isStorming ? 300 : 500); double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
Location location = (mcMMOPlayer.getHookLocation() != null) ? mcMMOPlayer.getHookLocation() : player.getLocation(); Location location = mcMMOPlayer.getFishingManager().getHookLocation();
if (location == null) {
location = player.getLocation();
}
Biome biome = location.getBlock().getBiome(); Biome biome = location.getBlock().getBiome();

View File

@ -6,7 +6,6 @@ import java.util.Set;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -37,7 +36,6 @@ import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.fishing.FishingManager; import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager; import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager; import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.smelting.SmeltingManager; import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.swords.SwordsManager;
@ -77,14 +75,8 @@ public class McMMOPlayer {
private boolean displaySkillNotifications = true; private boolean displaySkillNotifications = true;
private boolean abilityUse = true; private boolean abilityUse = true;
private boolean placedRepairAnvil;
private int lastRepairClick;
private boolean placedSalvageAnvil;
private int lastSalvageClick;
private boolean godMode; private boolean godMode;
private Location hookLocation;
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>(); private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>(); private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
@ -434,68 +426,6 @@ public class McMMOPlayer {
databaseATS = System.currentTimeMillis(); databaseATS = System.currentTimeMillis();
} }
/*
* Repair Anvil Placement
*/
public boolean getPlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return placedRepairAnvil;
}
if (anvilType == Repair.salvageAnvilMaterial) {
return placedSalvageAnvil;
}
return true;
}
public void togglePlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
placedRepairAnvil = !placedRepairAnvil;
}
if (anvilType == Repair.salvageAnvilMaterial) {
placedSalvageAnvil = !placedSalvageAnvil;
}
}
/*
* Repair Anvil Usage
*/
public int getLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return lastRepairClick;
}
if (anvilType == Repair.salvageAnvilMaterial) {
return lastSalvageClick;
}
return 0;
}
public void setLastAnvilUse(Material anvilType, int value) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = value;
}
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = value;
}
}
public void actualizeLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
}
/* /*
* God Mode * God Mode
*/ */
@ -508,18 +438,6 @@ public class McMMOPlayer {
godMode = !godMode; godMode = !godMode;
} }
/*
* Fishing: Master Angler
*/
public Location getHookLocation() {
return hookLocation;
}
public void setHookLocation(Location hookLocation) {
this.hookLocation = hookLocation;
}
/* /*
* Skill notifications * Skill notifications
*/ */

View File

@ -465,7 +465,7 @@ public class PlayerListener implements Listener {
// Cancel repairing an enchanted item // Cancel repairing an enchanted item
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) { if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilMaterial, 0); repairManager.setLastAnvilUse(Repair.repairAnvilMaterial, 0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name"))); player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
} }
} }
@ -475,7 +475,7 @@ public class PlayerListener implements Listener {
// Cancel salvaging an enchanted item // Cancel salvaging an enchanted item
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) { if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilMaterial, 0); repairManager.setLastAnvilUse(Repair.salvageAnvilMaterial, 0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name"))); player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
} }
} }

View File

@ -67,6 +67,7 @@ public class FishingManager extends SkillManager {
private long fishingTimestamp = 0L; private long fishingTimestamp = 0L;
private Location fishingTarget; private Location fishingTarget;
private Item fishingCatch; private Item fishingCatch;
private Location hookLocation;
public FishingManager(McMMOPlayer mcMMOPlayer) { public FishingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.FISHING); super(mcMMOPlayer, SkillType.FISHING);
@ -281,7 +282,7 @@ public class FishingManager extends SkillManager {
Biome biome = location.getBlock().getBiome(); Biome biome = location.getBlock().getBiome();
double biteChance = hook.getBiteChance(); double biteChance = hook.getBiteChance();
mcMMOPlayer.setHookLocation(location); hookLocation = location;
if (biome == Biome.RIVER || biome == Biome.OCEAN) { if (biome == Biome.RIVER || biome == Biome.OCEAN) {
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier(); biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
@ -362,6 +363,10 @@ public class FishingManager extends SkillManager {
return experience * getVanillaXpMultiplier(); return experience * getVanillaXpMultiplier();
} }
public Location getHookLocation() {
return hookLocation;
}
/** /**
* Handle the Shake ability * Handle the Shake ability
* *

View File

@ -25,10 +25,14 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
public class RepairManager extends SkillManager { public class RepairManager extends SkillManager {
private boolean placedRepairAnvil;
private int lastRepairClick;
private boolean placedSalvageAnvil;
private int lastSalvageClick;
public RepairManager(McMMOPlayer mcMMOPlayer) { public RepairManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.REPAIR); super(mcMMOPlayer, SkillType.REPAIR);
} }
@ -41,14 +45,14 @@ public class RepairManager extends SkillManager {
public void placedAnvilCheck(Material anvilType) { public void placedAnvilCheck(Material anvilType) {
Player player = getPlayer(); Player player = getPlayer();
if (mcMMOPlayer.getPlacedAnvil(anvilType)) { if (getPlacedAnvil(anvilType)) {
return; return;
} }
player.sendMessage(Repair.getAnvilMessage(anvilType)); player.sendMessage(Repair.getAnvilMessage(anvilType));
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH); player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
mcMMOPlayer.togglePlacedAnvil(anvilType); togglePlacedAnvil(anvilType);
} }
public void handleRepair(ItemStack item) { public void handleRepair(ItemStack item) {
@ -176,8 +180,7 @@ public class RepairManager extends SkillManager {
*/ */
public boolean checkConfirmation(Material anvilType, boolean actualize) { public boolean checkConfirmation(Material anvilType, boolean actualize) {
Player player = getPlayer(); Player player = getPlayer();
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); long lastUse = getLastAnvilUse(anvilType);
long lastUse = mcMMOPlayer.getLastAnvilUse(anvilType);
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getRepairConfirmRequired()) { if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getRepairConfirmRequired()) {
return true; return true;
@ -187,7 +190,7 @@ public class RepairManager extends SkillManager {
return false; return false;
} }
mcMMOPlayer.actualizeLastAnvilUse(anvilType); actualizeLastAnvilUse(anvilType);
if (anvilType == Repair.repairAnvilMaterial) { if (anvilType == Repair.repairAnvilMaterial) {
player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Repair.Pretty.Name"))); player.sendMessage(LocaleLoader.getString("Skills.ConfirmOrCancel", LocaleLoader.getString("Repair.Pretty.Name")));
@ -348,4 +351,66 @@ public class RepairManager extends SkillManager {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect")); player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
} }
} }
/*
* Repair Anvil Placement
*/
public boolean getPlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return placedRepairAnvil;
}
if (anvilType == Repair.salvageAnvilMaterial) {
return placedSalvageAnvil;
}
return true;
}
public void togglePlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
placedRepairAnvil = !placedRepairAnvil;
}
if (anvilType == Repair.salvageAnvilMaterial) {
placedSalvageAnvil = !placedSalvageAnvil;
}
}
/*
* Repair Anvil Usage
*/
public int getLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return lastRepairClick;
}
if (anvilType == Repair.salvageAnvilMaterial) {
return lastSalvageClick;
}
return 0;
}
public void setLastAnvilUse(Material anvilType, int value) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = value;
}
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = value;
}
}
public void actualizeLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
}
} }