mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-27 11:07:44 +01:00
These belong in their managers, not in McMMOPlayer
This commit is contained in:
parent
ccb7fc5886
commit
9b3ae5c729
@ -84,7 +84,11 @@ public class FishingCommand extends SkillCommand {
|
||||
// MASTER ANGLER
|
||||
if (canMasterAngler) {
|
||||
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();
|
||||
|
||||
|
@ -6,7 +6,6 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Sound;
|
||||
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.herbalism.HerbalismManager;
|
||||
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.smelting.SmeltingManager;
|
||||
import com.gmail.nossr50.skills.swords.SwordsManager;
|
||||
@ -77,14 +75,8 @@ public class McMMOPlayer {
|
||||
private boolean displaySkillNotifications = true;
|
||||
|
||||
private boolean abilityUse = true;
|
||||
private boolean placedRepairAnvil;
|
||||
private int lastRepairClick;
|
||||
private boolean placedSalvageAnvil;
|
||||
private int lastSalvageClick;
|
||||
private boolean godMode;
|
||||
|
||||
private Location hookLocation;
|
||||
|
||||
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
|
||||
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
|
||||
|
||||
@ -434,68 +426,6 @@ public class McMMOPlayer {
|
||||
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
|
||||
*/
|
||||
@ -508,18 +438,6 @@ public class McMMOPlayer {
|
||||
godMode = !godMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fishing: Master Angler
|
||||
*/
|
||||
|
||||
public Location getHookLocation() {
|
||||
return hookLocation;
|
||||
}
|
||||
|
||||
public void setHookLocation(Location hookLocation) {
|
||||
this.hookLocation = hookLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
* Skill notifications
|
||||
*/
|
||||
|
@ -465,7 +465,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
// Cancel repairing an enchanted item
|
||||
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")));
|
||||
}
|
||||
}
|
||||
@ -475,7 +475,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
// Cancel salvaging an enchanted item
|
||||
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")));
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,7 @@ public class FishingManager extends SkillManager {
|
||||
private long fishingTimestamp = 0L;
|
||||
private Location fishingTarget;
|
||||
private Item fishingCatch;
|
||||
private Location hookLocation;
|
||||
|
||||
public FishingManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.FISHING);
|
||||
@ -281,7 +282,7 @@ public class FishingManager extends SkillManager {
|
||||
Biome biome = location.getBlock().getBiome();
|
||||
double biteChance = hook.getBiteChance();
|
||||
|
||||
mcMMOPlayer.setHookLocation(location);
|
||||
hookLocation = location;
|
||||
|
||||
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
|
||||
biteChance = biteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
|
||||
@ -362,6 +363,10 @@ public class FishingManager extends SkillManager {
|
||||
return experience * getVanillaXpMultiplier();
|
||||
}
|
||||
|
||||
public Location getHookLocation() {
|
||||
return hookLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Shake ability
|
||||
*
|
||||
|
@ -25,10 +25,14 @@ import com.gmail.nossr50.util.EventUtils;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
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 RepairManager extends SkillManager {
|
||||
private boolean placedRepairAnvil;
|
||||
private int lastRepairClick;
|
||||
private boolean placedSalvageAnvil;
|
||||
private int lastSalvageClick;
|
||||
|
||||
public RepairManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, SkillType.REPAIR);
|
||||
}
|
||||
@ -41,14 +45,14 @@ public class RepairManager extends SkillManager {
|
||||
public void placedAnvilCheck(Material anvilType) {
|
||||
Player player = getPlayer();
|
||||
|
||||
if (mcMMOPlayer.getPlacedAnvil(anvilType)) {
|
||||
if (getPlacedAnvil(anvilType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(Repair.getAnvilMessage(anvilType));
|
||||
|
||||
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) {
|
||||
@ -176,8 +180,7 @@ public class RepairManager extends SkillManager {
|
||||
*/
|
||||
public boolean checkConfirmation(Material anvilType, boolean actualize) {
|
||||
Player player = getPlayer();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
long lastUse = mcMMOPlayer.getLastAnvilUse(anvilType);
|
||||
long lastUse = getLastAnvilUse(anvilType);
|
||||
|
||||
if (!SkillUtils.cooldownExpired(lastUse, 3) || !Config.getInstance().getRepairConfirmRequired()) {
|
||||
return true;
|
||||
@ -187,7 +190,7 @@ public class RepairManager extends SkillManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
mcMMOPlayer.actualizeLastAnvilUse(anvilType);
|
||||
actualizeLastAnvilUse(anvilType);
|
||||
|
||||
if (anvilType == Repair.repairAnvilMaterial) {
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user