mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
Custom tools - modify XP gain from breaking blocks on a per tool basis.
This commit is contained in:
parent
29ee8a035b
commit
e9af0ebdc5
@ -9,11 +9,14 @@ import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.ModChecks;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
|
||||
@ -1027,6 +1030,14 @@ public class PlayerProfile {
|
||||
xp += trueBonus;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getToolModsEnabled()) {
|
||||
ItemStack item = player.getItemInHand();
|
||||
|
||||
if (ItemChecks.isCustomTool(item)) {
|
||||
xp = (int) (xp * ModChecks.getToolFromItemStack(item).getXpMultiplier());
|
||||
}
|
||||
}
|
||||
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||
lastgained = skillType;
|
||||
|
@ -381,7 +381,6 @@ public class Combat {
|
||||
damageAmount = 1;
|
||||
}
|
||||
|
||||
//TODO: Looking at this, I think it's busted. Need to test to confirm.
|
||||
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
|
||||
if (!(entity instanceof LivingEntity)) {
|
||||
continue;
|
||||
|
@ -22,4 +22,20 @@ public class ModChecks {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the custom tool associated with an item.
|
||||
*
|
||||
* @param item The item to check
|
||||
* @return the tool if it exists, null otherwise
|
||||
*/
|
||||
public static CustomTool getToolFromItemStack(ItemStack item) {
|
||||
for (CustomTool tool : LoadCustomTools.getInstance().customTools) {
|
||||
if (tool.getItemID() == item.getTypeId()) {
|
||||
return tool;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ commands:
|
||||
aliases: []
|
||||
description: Make yourself invulnerable
|
||||
mcstats:
|
||||
aliases: []
|
||||
aliases: [/stats]
|
||||
description: Shows your mcMMO stats and xp
|
||||
mcremove:
|
||||
aliases: []
|
||||
|
Loading…
Reference in New Issue
Block a user