Merge remote-tracking branch 'upstream/master'

This commit is contained in:
OverCrave 2019-03-30 17:57:14 +01:00
commit 629d882831
13 changed files with 134 additions and 68 deletions

View File

@ -7,6 +7,23 @@ Key:
! Change
- Removal
Version 2.1.30
Fixed double drops behaving oddly
Double_Drop config table has been renamed to Bonus_Drops, this is to jankily auto-update everyones config
DoubleDrop config tables now must contain all things that can possibly be doubled, such as the Ore block, the ore itself, etc.
Added the following items to the Bonus_Drops tables for Mining: Coal, Diamond, Emerald, Glowstone_Dust, Iron_Ingot, Lapis_Lazuli, Nether_Quartz, Redstone, Cobblestone
Added the following items to the Bonus_Drops tables for Herbalism: Beetroot, Carrot, Cocoa_Beans, Melon_Slice, Potatoe
Added the following items to the Bonus_Drops tables for Woodcutting: Birch_Wood, Spruce_Wood, Jungle_Wood, Dark_Oak_Wood, Oak_Wood, Acacia_Wood
NOTE: You don't need to update your configs for this one unless you had custom entries in the Double_Drop tables, the renaming of the key will auto-insert default values and give everyone correct defaults
NOTE: I'm gonna have to blame Bukkit on this one, several API methods I used are actually unfinished and kind of janky. So I hacked something together to make them work.
Version 2.1.29
Fixed a bug where double drops and triple drops were not activating
Version 2.1.28
Fixed a bug where Archery could not gain XP
Version 2.1.27
Fixed an exploit that allowed players to duplicate torches, and rails

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.27</version>
<version>2.1.30</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>

View File

@ -463,18 +463,18 @@ public class Config extends AutoUpdateConfigLoader {
/*
* SKILL SETTINGS
*/
public boolean getDoubleDropsEnabled(PrimarySkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public boolean getDoubleDropsEnabled(PrimarySkillType skill, Material material) { return config.getBoolean("Bonus_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public boolean getDoubleDropsDisabled(PrimarySkillType skill) {
String skillName = StringUtils.getCapitalized(skill.toString());
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
ConfigurationSection section = config.getConfigurationSection("Bonus_Drops." + skillName);
if (section == null)
return false;
Set<String> keys = section.getKeys(false);
boolean disabled = true;
for (String key : keys) {
if (config.getBoolean("Double_Drops." + skillName + "." + key)) {
if (config.getBoolean("Bonus_Drops." + skillName + "." + key)) {
disabled = false;
break;
}
@ -540,7 +540,7 @@ public class Config extends AutoUpdateConfigLoader {
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
/* Woodcutting */
public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); }
public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Bonus_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); }
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
public int getWoodcuttingGate() { return config.getInt("Skills.Woodcutting.Ability_Activation_Level_Gate", 10); }

View File

@ -62,34 +62,66 @@ public class BlockListener implements Listener {
{
ItemStack is = new ItemStack(item.getItemStack());
if(!event.getBlock().getDrops().contains(is))
continue;
if(is.getAmount() <= 0)
continue;
if(event.getBlock().getState().getMetadata(mcMMO.doubleDropKey).size() > 0)
{
//Extra Protection
if(event.getBlock().getState() instanceof Container)
return;
if(!Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.MINING, is.getType())
&& !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.HERBALISM, is.getType())
&& !Config.getInstance().getDoubleDropsEnabled(PrimarySkillType.WOODCUTTING, is.getType()))
continue;
event.getBlock().getState().removeMetadata(mcMMO.doubleDropKey, plugin);
if(event.getBlock().getState().getMetadata(mcMMO.doubleDrops).size() > 0)
{
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
event.getBlock().getState().removeMetadata(mcMMO.doubleDrops, plugin);
}
else if(event.getBlock().getState().getMetadata(mcMMO.tripleDropKey).size() > 0)
else if(event.getBlock().getState().getMetadata(mcMMO.tripleDrops).size() > 0)
{
//Extra Protection
if(event.getBlock().getState() instanceof Container)
return;
event.getBlock().getState().removeMetadata(mcMMO.tripleDropKey, plugin);
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
event.getBlock().getState().removeMetadata(mcMMO.tripleDrops, plugin);
}
}
}
/*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDropItemEvent(BlockDropItemEvent event)
{
for(Item item : event.getItems())
{
ItemStack is = new ItemStack(item.getItemStack());
if(event.getBlock().getMetadata(mcMMO.doubleDrops).size() > 0)
{
List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.doubleDrops);
BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0);
Collection<ItemStack> potentialDrops = (Collection<ItemStack>) bonusDrops.value();
if(potentialDrops.contains(is))
{
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
}
event.getBlock().removeMetadata(mcMMO.doubleDrops, plugin);
} else {
if(event.getBlock().getMetadata(mcMMO.tripleDrops).size() > 0) {
List<MetadataValue> metadataValue = event.getBlock().getMetadata(mcMMO.tripleDrops);
BonusDrops bonusDrops = (BonusDrops) metadataValue.get(0);
Collection<ItemStack> potentialDrops = (Collection<ItemStack>) bonusDrops.value();
if (potentialDrops.contains(is)) {
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
event.getBlock().getState().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
}
event.getBlock().removeMetadata(mcMMO.tripleDrops, plugin);
}
}
}
}*/
/**
* Monitor BlockPistonExtend events.
*

View File

@ -25,8 +25,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.gmail.nossr50.worldguard.WorldGuardUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;

View File

@ -110,12 +110,12 @@ public class mcMMO extends JavaPlugin {
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
public final static String bowForceKey = "mcMMO: Bow Force";
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
public final static String doubleDrops = "mcMMO: Double Drops";
public final static String tripleDrops = "mcMMO: Triple Drops";
//public final static String customDamageKey = "mcMMO: Custom Damage";
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
public final static String playerDataKey = "mcMMO: Player Data";
public final static String greenThumbDataKey = "mcMMO: Green Thumb";
public final static String doubleDropKey = "mcMMO: Double Drop";
public final static String tripleDropKey = "mcMMO: Triple Drop";
public final static String databaseCommandKey = "mcMMO: Processing Database Command";
public final static String bredMetadataKey = "mcMMO: Bred Animal";

View File

@ -9,8 +9,6 @@ import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

View File

@ -67,7 +67,7 @@ public class Herbalism {
dropAmount++;
if(herbalismManager.checkDoubleDrop(target.getState()))
BlockUtils.markBlocksForBonusDrops(target.getState(), triple);
BlockUtils.markDropsAsBonus(target.getState(), triple);
}
for (BlockFace blockFace : new BlockFace[] { BlockFace.UP, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST ,BlockFace.WEST})
@ -110,7 +110,7 @@ public class Herbalism {
dropAmount++;
if(herbalismManager.checkDoubleDrop(relativeBlock.getState()))
BlockUtils.markBlocksForBonusDrops(relativeBlock.getState(), triple);
BlockUtils.markDropsAsBonus(relativeBlock.getState(), triple);
}
}
}
@ -142,7 +142,7 @@ public class Herbalism {
amount += 1;
if(herbalismManager.checkDoubleDrop(relativeUpBlock.getState()))
BlockUtils.markBlocksForBonusDrops(relativeUpBlock.getState(), triple);
BlockUtils.markDropsAsBonus(relativeUpBlock.getState(), triple);
}

View File

@ -147,7 +147,7 @@ public class HerbalismManager extends SkillManager {
if (Permissions.isSubSkillEnabled(player, SubSkillType.HERBALISM_DOUBLE_DROPS) && customBlock.isDoubleDropEnabled()) {
if(checkDoubleDrop(blockState))
BlockUtils.markBlocksForBonusDrops(blockState, greenTerra);
BlockUtils.markDropsAsBonus(blockState, greenTerra);
}
}
else {
@ -165,7 +165,7 @@ public class HerbalismManager extends SkillManager {
} else {
/* MARK SINGLE BLOCK CROP FOR DOUBLE DROP */
if(checkDoubleDrop(blockState))
BlockUtils.markBlocksForBonusDrops(blockState, greenTerra);
BlockUtils.markDropsAsBonus(blockState, greenTerra);
}
if (Permissions.greenThumbPlant(player, material)) {

View File

@ -91,7 +91,7 @@ public class MiningManager extends SkillManager {
//TODO: Make this readable
if (RandomChanceUtil.checkRandomChanceExecutionSuccess(getPlayer(), SubSkillType.MINING_DOUBLE_DROPS, true)) {
BlockUtils.markBlocksForBonusDrops(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility()));
BlockUtils.markDropsAsBonus(blockState, mcMMOPlayer.getAbilityMode(skill.getAbility()));
}
}

View File

@ -26,12 +26,12 @@ public final class BlockUtils {
* @param blockState target blockstate
* @param triple marks the block to give triple drops
*/
public static void markBlocksForBonusDrops(BlockState blockState, boolean triple)
public static void markDropsAsBonus(BlockState blockState, boolean triple)
{
if(triple)
blockState.setMetadata(mcMMO.tripleDropKey, mcMMO.metadataValue);
blockState.setMetadata(mcMMO.tripleDrops, mcMMO.metadataValue);
else
blockState.setMetadata(mcMMO.doubleDropKey, mcMMO.metadataValue);
blockState.setMetadata(mcMMO.doubleDrops, mcMMO.metadataValue);
}
/**

View File

@ -240,7 +240,37 @@ public final class CombatUtils {
* @param event The event to run the combat checks on.
*/
public static void processCombatAttack(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) {
EntityType entityType = attacker.getType();
Entity damager = event.getDamager();
EntityType entityType = damager.getType();
if (target instanceof Player) {
if (Misc.isNPCEntity(target)) {
return;
}
Player player = (Player) target;
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (acrobaticsManager.canDodge(target)) {
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
}
if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) {
if (!PrimarySkillType.SWORDS.shouldProcess(target)) {
return;
}
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
if (swordsManager.canUseCounterAttack(damager)) {
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
}
}
}
if (attacker instanceof Player && entityType == EntityType.PLAYER) {
Player player = (Player) attacker;
@ -297,7 +327,7 @@ public final class CombatUtils {
}
else if (entityType == EntityType.WOLF) {
Wolf wolf = (Wolf) attacker;
Wolf wolf = (Wolf) damager;
AnimalTamer tamer = wolf.getOwner();
if (tamer != null && tamer instanceof Player && PrimarySkillType.TAMING.shouldProcess(target)) {
@ -309,7 +339,7 @@ public final class CombatUtils {
}
}
else if (entityType == EntityType.ARROW) {
Arrow arrow = (Arrow) attacker;
Arrow arrow = (Arrow) damager;
ProjectileSource projectileSource = arrow.getShooter();
if (projectileSource != null && projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) {
@ -326,35 +356,6 @@ public final class CombatUtils {
}
}
}
if (target instanceof Player) {
if (Misc.isNPCEntity(target)) {
return;
}
Player player = (Player) target;
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
AcrobaticsManager acrobaticsManager = mcMMOPlayer.getAcrobaticsManager();
if (acrobaticsManager.canDodge(target)) {
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
}
if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) {
if (!PrimarySkillType.SWORDS.shouldProcess(target)) {
return;
}
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
if (swordsManager.canUseCounterAttack(attacker)) {
swordsManager.counterAttackChecks((LivingEntity) attacker, event.getDamage());
}
}
}
}
public static int getLimitBreakDamage(Player player, SubSkillType subSkillType) {

View File

@ -426,17 +426,22 @@ Skills:
#
# Settings for Double Drops
###
Double_Drops:
Bonus_Drops:
Herbalism:
Beetroots: true
Beetroot: true
Brown_Mushroom: true
Cactus: true
Carrots: true
Carrot: true
Cocoa: true
Cocoa_Beans: true
Wheat: true
Melon: true
Melon_Slice: true
Nether_Wart: true
Potatoes: true
Potatoe: true
Pumpkin: true
Red_Mushroom: true
Sugar_Cane: true
@ -461,26 +466,41 @@ Double_Drops:
Diorite: true
Granite: true
Coal_Ore: true
Coal: true
Diamond_Ore: true
Diamond: true
Emerald_Ore: true
Emerald: true
End_Stone: true
Glowstone: true
Glowstone_Dust: true
Gold_Ore: true
Iron_Ore: true
Iron_Ingot: true
Lapis_Ore: true
Lapis_Lazuli: true
Mossy_Cobblestone: true
Netherrack: true
Obsidian: true
Nether_Quartz_Ore: true
Nether_Quartz: true
Redstone_Ore: true
Redstone: true
Sandstone: true
Stone: true
Cobblestone: true
Woodcutting:
Acacia_Wood: true
Acacia_Log: true
Birch_Wood: true
Birch_Log: true
Dark_Oak_Wood: true
Dark_Oak_Log: true
Oak_Wood: true
Oak_Log: true
Jungle_Wood: true
Jungle_Log: true
Spruce_Wood: true
Spruce_Log: true
#