mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-29 12:14:43 +02:00
Put McMMOPlayer to use where it made sense
It's basically a wrapper for anything related to players, as a consequence Users.getProfile() is now depreciated. Also removed SkillTools.xpProcessing() because of some redundancy with McMMOPlayer.addXp(). + some cleanup for consistency sake.
This commit is contained in:
@ -8,12 +8,11 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.config.TreasuresConfig;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.mods.ModChecks;
|
||||
@ -21,7 +20,6 @@ import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class Excavation {
|
||||
public static boolean requiresTool = Config.getInstance().getExcavationRequiresTool();
|
||||
@ -30,21 +28,13 @@ public class Excavation {
|
||||
* Check to see if treasures were found.
|
||||
*
|
||||
* @param block The block to check
|
||||
* @param player The player who broke the block
|
||||
* @param mcMMOPlayer The player who broke the block
|
||||
*/
|
||||
public static void excavationProcCheck(Block block, Player player) {
|
||||
Material type = block.getType();
|
||||
Location location = block.getLocation();
|
||||
|
||||
PlayerProfile profile = Users.getProfile(player);
|
||||
int skillLevel = profile.getSkillLevel(SkillType.EXCAVATION);
|
||||
ArrayList<ItemStack> is = new ArrayList<ItemStack>();
|
||||
|
||||
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
public static void excavationProcCheck(Block block, McMMOPlayer mcMMOPlayer) {
|
||||
Material material = block.getType();
|
||||
int xp;
|
||||
|
||||
switch (type) {
|
||||
switch (material) {
|
||||
case CLAY:
|
||||
xp = Config.getInstance().getExcavationClayXP();
|
||||
break;
|
||||
@ -78,8 +68,11 @@ public class Excavation {
|
||||
break;
|
||||
}
|
||||
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
|
||||
|
||||
if (Permissions.excavationTreasures(player)) {
|
||||
switch (type) {
|
||||
switch (material) {
|
||||
case DIRT:
|
||||
treasures = TreasuresConfig.getInstance().excavationFromDirt;
|
||||
break;
|
||||
@ -112,43 +105,40 @@ public class Excavation {
|
||||
break;
|
||||
}
|
||||
|
||||
Location location = block.getLocation();
|
||||
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()) {
|
||||
if (mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION) >= treasure.getDropLevel()) {
|
||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyExcavation(player));
|
||||
|
||||
if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
|
||||
xp += treasure.getXp();
|
||||
is.add(treasure.getDrop());
|
||||
Misc.dropItem(location, treasure.getDrop());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Drop items
|
||||
for (ItemStack x : is) {
|
||||
if (x != null) {
|
||||
Misc.dropItem(location, x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SkillTools.xpProcessing(player, profile, SkillType.EXCAVATION, xp);
|
||||
mcMMOPlayer.addXp(SkillType.EXCAVATION, xp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle triple drops from Giga Drill Breaker.
|
||||
*
|
||||
* @param player The player using the ability
|
||||
* @param mcMMOPlayer The player using the ability
|
||||
* @param block The block to check
|
||||
*/
|
||||
public static void gigaDrillBreaker(Player player, Block block) {
|
||||
public static void gigaDrillBreaker(McMMOPlayer mcMMOplayer, Block block) {
|
||||
Player player = mcMMOplayer.getPlayer();
|
||||
|
||||
SkillTools.abilityDurabilityLoss(player.getItemInHand(), Misc.toolDurabilityLoss);
|
||||
|
||||
if (!mcMMO.placeStore.isTrue(block) && Misc.blockBreakSimulate(block, player, true)) {
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
Excavation.excavationProcCheck(block, mcMMOplayer);
|
||||
Excavation.excavationProcCheck(block, mcMMOplayer);
|
||||
}
|
||||
|
||||
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
|
||||
|
Reference in New Issue
Block a user