mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-02 12:35:27 +02:00
Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into configurable
This commit is contained in:
@@ -53,6 +53,10 @@ public class ArcheryManager extends SkillManager {
|
||||
* @param damager The {@link Entity} who shot the arrow
|
||||
*/
|
||||
public double distanceXpBonusMultiplier(LivingEntity target, Entity damager) {
|
||||
//Hacky Fix - some plugins spawn arrows and assign them to players after the ProjectileLaunchEvent fires
|
||||
if(!damager.hasMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY))
|
||||
return damager.getLocation().distance(target.getLocation());
|
||||
|
||||
Location firedLocation = (Location) damager.getMetadata(MetadataConstants.ARROW_DISTANCE_METAKEY).get(0).value();
|
||||
Location targetLocation = target.getLocation();
|
||||
|
||||
|
@@ -10,9 +10,12 @@ import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@@ -40,6 +43,13 @@ public class ExcavationManager extends SkillManager {
|
||||
for (ExcavationTreasure treasure : treasures) {
|
||||
if (skillLevel >= treasure.getDropLevel()
|
||||
&& RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), PrimarySkillType.EXCAVATION, treasure.getDropChance())) {
|
||||
|
||||
//Spawn Vanilla XP orbs if a dice roll succeeds
|
||||
if(RandomChanceUtil.rollDice(getArchaelogyExperienceOrbChance(), 100)) {
|
||||
ExperienceOrb experienceOrb = (ExperienceOrb) getPlayer().getWorld().spawnEntity(location, EntityType.EXPERIENCE_ORB);
|
||||
experienceOrb.setExperience(getExperienceOrbsReward());
|
||||
}
|
||||
|
||||
xp += treasure.getXp();
|
||||
Misc.dropItem(location, treasure.getDrop());
|
||||
}
|
||||
@@ -50,7 +60,20 @@ public class ExcavationManager extends SkillManager {
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
}
|
||||
|
||||
public void printExcavationDebug(Player player, BlockState blockState) {
|
||||
public int getExperienceOrbsReward() {
|
||||
return 1 * getArchaeologyRank();
|
||||
}
|
||||
|
||||
public double getArchaelogyExperienceOrbChance() {
|
||||
return getArchaeologyRank() * 2;
|
||||
}
|
||||
|
||||
public int getArchaeologyRank() {
|
||||
return RankUtils.getRank(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY);
|
||||
}
|
||||
|
||||
public void printExcavationDebug(Player player, BlockState blockState)
|
||||
{
|
||||
if (Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.EXCAVATION_ARCHAEOLOGY)) {
|
||||
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
|
||||
|
||||
|
@@ -72,6 +72,10 @@ public class MiningManager extends SkillManager {
|
||||
return getSkillLevel() >= BlastMining.getBiggerBombsUnlockLevel() && Permissions.biggerBombs(getPlayer());
|
||||
}
|
||||
|
||||
public boolean canDoubleDrop() {
|
||||
return RankUtils.hasUnlockedSubskill(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS) && Permissions.isSubSkillEnabled(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process double drops & XP gain for Mining.
|
||||
*
|
||||
@@ -82,16 +86,11 @@ public class MiningManager extends SkillManager {
|
||||
|
||||
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE);
|
||||
|
||||
if (!Permissions.isSubSkillEnabled(player, SubSkillType.MINING_DOUBLE_DROPS)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mcMMOPlayer.getAbilityMode(skill.getSuperAbility())) {
|
||||
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), mcMMO.getConfigManager().getConfigSuperAbilities().getSuperAbilityLimits().getToolDurabilityDamage());
|
||||
}
|
||||
|
||||
//if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || !MainConfig.getInstance().getDoubleDropsEnabled(skill, material)) {
|
||||
if (!mcMMO.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(blockState.getType()))
|
||||
if (!canDoubleDrop() || !mcMMO.getDynamicSettingsManager().getBonusDropManager().isBonusDropWhitelisted(blockState.getType()))
|
||||
return;
|
||||
|
||||
boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH);
|
||||
|
@@ -136,17 +136,28 @@ public class SalvageManager extends SkillManager {
|
||||
return;
|
||||
}
|
||||
|
||||
Location anvilLoc = location.clone();
|
||||
Location playerLoc = player.getLocation().clone();
|
||||
double distance = anvilLoc.distance(playerLoc);
|
||||
|
||||
double speedLimit = .6;
|
||||
double minSpeed = .3;
|
||||
|
||||
//Clamp the speed and vary it by distance
|
||||
double vectorSpeed = Math.min(speedLimit, Math.max(minSpeed, distance * .2));
|
||||
|
||||
//Add a very small amount of height
|
||||
anvilLoc.add(0, .1, 0);
|
||||
|
||||
if (enchantBook != null) {
|
||||
Misc.dropItem(location, enchantBook);
|
||||
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), enchantBook, vectorSpeed);
|
||||
}
|
||||
|
||||
Misc.spawnItemTowardsLocation(location, player.getLocation().add(0, 0.25, 0), salvageResults);
|
||||
Misc.spawnItemTowardsLocation(anvilLoc.clone(), playerLoc.clone(), salvageResults, vectorSpeed);
|
||||
|
||||
// BWONG BWONG BWONG - CLUNK!
|
||||
if (mcMMO.getConfigManager().getConfigSalvage().getGeneral().isAnvilUseSounds()) {
|
||||
SoundManager.sendSound(player, player.getLocation(), SoundType.ITEM_BREAK);
|
||||
|
||||
//player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Salvage.Skills.Success");
|
||||
|
@@ -7,7 +7,6 @@ import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -29,23 +28,44 @@ public final class Woodcutting {
|
||||
protected static boolean treeFellerReachedThreshold = false;
|
||||
|
||||
private Woodcutting() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the experience reward from a log
|
||||
*
|
||||
* @param blockState Log being broken
|
||||
* @param experienceGainMethod How the log is being broken
|
||||
* @param blockState Log being broken
|
||||
* @return Amount of experience
|
||||
*/
|
||||
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
|
||||
/*if (mcMMO.getModManager().isCustomLog(blockState)) {
|
||||
return mcMMO.getModManager().getBlock(blockState).getXpGain();
|
||||
}*/
|
||||
|
||||
protected static int getExperienceFromLog(BlockState blockState) {
|
||||
return mcMMO.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the experience reward from logging via Tree Feller
|
||||
* Experience is reduced per log processed so far
|
||||
* Experience is only reduced if the config option to reduce Tree Feller XP is set
|
||||
* Experience per log will not fall below 1 unless the experience for that log is set to 0 in the config
|
||||
*
|
||||
* @param blockState Log being broken
|
||||
* @param woodCount how many logs have given out XP for this tree feller so far
|
||||
* @return Amount of experience
|
||||
*/
|
||||
protected static int processTreeFellerXPGains(BlockState blockState, int woodCount) {
|
||||
int rawXP = mcMMO.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType());
|
||||
|
||||
if(rawXP <= 0)
|
||||
return 0;
|
||||
|
||||
if(mcMMO.getConfigManager().getConfigExperience().getExperienceWoodcutting().isReduceTreeFellerXP()) {
|
||||
int reducedXP = 1 + (woodCount * 5);
|
||||
rawXP = Math.max(1, rawXP - reducedXP);
|
||||
return rawXP;
|
||||
} else {
|
||||
return mcMMO.getDynamicSettingsManager().getExperienceManager().getWoodcuttingXp(blockState.getType());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for double drops
|
||||
*
|
||||
@@ -136,9 +156,8 @@ public final class Woodcutting {
|
||||
* @return True if the tool can sustain the durability loss
|
||||
*/
|
||||
protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) {
|
||||
|
||||
if((inHand.getItemMeta().getEnchants().get(Enchantment.DURABILITY) != null && inHand.getItemMeta().getEnchants().get(Enchantment.DURABILITY) >= 1)
|
||||
|| (inHand.getItemMeta() != null && inHand.getItemMeta().isUnbreakable())) {
|
||||
//Treat the NBT tag for unbreakable and the durability enchant differently
|
||||
if(inHand.getItemMeta() != null && inHand.getItemMeta().isUnbreakable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.SkillManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||
@@ -52,7 +51,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
* @param blockState Block being broken
|
||||
*/
|
||||
public void woodcuttingBlockCheck(BlockState blockState) {
|
||||
int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
|
||||
int xp = Woodcutting.getExperienceFromLog(blockState);
|
||||
|
||||
switch (blockState.getType()) {
|
||||
case BROWN_MUSHROOM_BLOCK:
|
||||
@@ -114,6 +113,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
private void dropBlocks(Set<BlockState> treeFellerBlocks) {
|
||||
Player player = getPlayer();
|
||||
int xp = 0;
|
||||
int processedLogCount = 0;
|
||||
|
||||
for (BlockState blockState : treeFellerBlocks) {
|
||||
Block block = blockState.getBlock();
|
||||
@@ -124,30 +124,16 @@ public class WoodcuttingManager extends SkillManager {
|
||||
|
||||
Material material = blockState.getType();
|
||||
|
||||
//TODO: Update this to drop the correct items/blocks via NMS
|
||||
if (material == Material.BROWN_MUSHROOM_BLOCK || material == Material.RED_MUSHROOM_BLOCK) {
|
||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||
xp += Woodcutting.processTreeFellerXPGains(blockState, processedLogCount);
|
||||
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||
}
|
||||
/*else if (mcMMO.getModManager().isCustomLog(blockState)) {
|
||||
if (canGetDoubleDrops()) {
|
||||
Woodcutting.checkForDoubleDrop(blockState);
|
||||
}
|
||||
|
||||
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
|
||||
xp = customBlock.getXpGain();
|
||||
|
||||
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||
}
|
||||
else if (mcMMO.getModManager().isCustomLeaf(blockState)) {
|
||||
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||
}*/
|
||||
else {
|
||||
|
||||
} else {
|
||||
if (BlockUtils.isLog(blockState)) {
|
||||
if (canGetDoubleDrops()) {
|
||||
Woodcutting.checkForDoubleDrop(blockState);
|
||||
}
|
||||
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
|
||||
xp += Woodcutting.processTreeFellerXPGains(blockState, processedLogCount);
|
||||
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
|
||||
}
|
||||
if (BlockUtils.isLeaves(blockState)) {
|
||||
@@ -157,6 +143,7 @@ public class WoodcuttingManager extends SkillManager {
|
||||
|
||||
blockState.setType(Material.AIR);
|
||||
blockState.update(true);
|
||||
processedLogCount+=1;
|
||||
}
|
||||
|
||||
applyXpGain(xp, XPGainReason.PVE);
|
||||
|
Reference in New Issue
Block a user