Yikes that was a lot of merge conflicts.

This commit is contained in:
nossr50
2019-06-12 05:26:45 -07:00
25 changed files with 285 additions and 215 deletions

View File

@ -0,0 +1,33 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO;
import java.util.UUID;
public class DatabaseAPI {
/**
* Checks if a player exists in the mcMMO Database
* @param uuid player UUID
* @return true if the player exists in the DB, false if they do not
*/
public boolean doesPlayerExistInDB(String uuid) {
return doesPlayerExistInDB(UUID.fromString(uuid));
}
/**
* Checks if a player exists in the mcMMO Database
* @param uuid player UUID
* @return true if the player exists in the DB, false if they do not
*/
public boolean doesPlayerExistInDB(UUID uuid) {
PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
if(playerProfile.isLoaded())
return true;
else
return false;
}
}

View File

@ -15,7 +15,7 @@ import java.util.ArrayList;
import java.util.List;
public class SalvageCommand extends SkillCommand {
private boolean canAdvancedSalvage;
private boolean canScrapCollector;
private boolean canArcaneSalvage;
public SalvageCommand() {
@ -30,7 +30,7 @@ public class SalvageCommand extends SkillCommand {
@Override
protected void permissionsCheck(Player player) {
canAdvancedSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ADVANCED_SALVAGE);
canScrapCollector = canUseSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR);
canArcaneSalvage = canUseSubskill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE);
}
@ -39,9 +39,11 @@ public class SalvageCommand extends SkillCommand {
List<String> messages = new ArrayList<>();
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
if (canAdvancedSalvage) {
messages.add(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Salvage.Ability.Bonus.0"),
LocaleLoader.getString("Salvage.Ability.Bonus.1", salvageManager.getSalvageableAmount())));
if (canScrapCollector) {
messages.add(getStatMessage(false, true,
SubSkillType.SALVAGE_SCRAP_COLLECTOR,
String.valueOf(RankUtils.getRank(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)),
RankUtils.getHighestRankStr(SubSkillType.SALVAGE_SCRAP_COLLECTOR)));
}
if (canArcaneSalvage) {

View File

@ -264,6 +264,7 @@ public class MaterialMapStore {
abilityBlackList.add("light_gray_shulker_box");
abilityBlackList.add("white_shulker_box");
abilityBlackList.add("yellow_shulker_box");
abilityBlackList.add("shulker_box");
abilityBlackList.add("wall_sign"); //1.13 and lower?
abilityBlackList.add("sign"); //1.13 and lower?
}
@ -353,6 +354,7 @@ public class MaterialMapStore {
toolBlackList.add("light_gray_shulker_box");
toolBlackList.add("white_shulker_box");
toolBlackList.add("yellow_shulker_box");
toolBlackList.add("shulker_box");
toolBlackList.add("acacia_sign");
toolBlackList.add("acacia_wall_sign");
toolBlackList.add("birch_sign");
@ -389,6 +391,8 @@ public class MaterialMapStore {
toolBlackList.add("oak_wood");
toolBlackList.add("spruce_log");
toolBlackList.add("spruce_wood");
toolBlackList.add("iron_block");
toolBlackList.add("gold_block");
}
private void addToHashSet(String string, HashSet<String> stringHashSet) {

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.core;
import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.config.hocon.HOCONUtil;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel;
@ -84,19 +83,24 @@ public class SkillPropertiesManager {
CommentedConfigurationNode childNode = it.next();
Object lastObjectInPath = childNode.getPath()[childNode.getPath().length + 1];
Object lastObjectInPath = childNode.getPath()[childNode.getPath().length - 1];
String nodeName = lastObjectInPath.toString();
if(nodeName.equalsIgnoreCase(ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME)) {
attemptRegisterMaxBonusLevel(subSkillType, childNode);
} else if(nodeName.equalsIgnoreCase(ConfigConstants.MAX_CHANCE_FIELD_NAME)) {
attemptRegisterMaxChance(subSkillType, childNode);
} else if(nodeName.equalsIgnoreCase(ConfigConstants.STATIC_ACTIVATION_FIELD_NAME)) {
attemptRegisterStaticChance(subSkillType, childNode);
} else if(nodeName.equalsIgnoreCase(ConfigConstants.MAX_BONUS_PERCENTAGE_FIELD_NAME)) {
attemptRegisterMaxBonusPercentage(subSkillType, childNode);
switch(nodeName) {
case ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME:
attemptRegisterMaxBonusLevel(subSkillType, childNode);
break;
case ConfigConstants.MAX_CHANCE_FIELD_NAME:
attemptRegisterMaxChance(subSkillType, childNode);
break;
case ConfigConstants.STATIC_ACTIVATION_FIELD_NAME:
attemptRegisterStaticChance(subSkillType, childNode);
break;
case ConfigConstants.MAX_BONUS_PERCENTAGE_FIELD_NAME:
attemptRegisterMaxBonusPercentage(subSkillType, childNode);
break;
}
}
}
}

View File

@ -20,6 +20,7 @@ public enum NotificationType {
SUPER_ABILITY("SuperAbilityInteraction"),
SUPER_ABILITY_ALERT_OTHERS("SuperAbilityAlertOthers"),
ITEM_MESSAGE("ItemMessage"),
CHAT_ONLY("ChatOnly"),
PARTY_MESSAGE("PartyMessage");
final String niceName;

View File

@ -51,7 +51,7 @@ public enum PrimarySkillType {
REPAIR(RepairManager.class, Color.SILVER,
ImmutableList.of(SubSkillType.REPAIR_ARCANE_FORGING, SubSkillType.REPAIR_REPAIR_MASTERY, SubSkillType.REPAIR_SUPER_REPAIR), "Repair"),
SALVAGE(SalvageManager.class, Color.ORANGE,
ImmutableList.of(SubSkillType.SALVAGE_ADVANCED_SALVAGE, SubSkillType.SALVAGE_ARCANE_SALVAGE), "Salvage"),
ImmutableList.of(SubSkillType.SALVAGE_SCRAP_COLLECTOR, SubSkillType.SALVAGE_ARCANE_SALVAGE), "Salvage"),
SMELTING(SmeltingManager.class, Color.YELLOW,
ImmutableList.of(SubSkillType.SMELTING_UNDERSTANDING_THE_ART, /*SubSkillType.SMELTING_FLUX_MINING,*/ SubSkillType.SMELTING_FUEL_EFFICIENCY, SubSkillType.SMELTING_SECOND_SMELT), "Smelting"),
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), SuperAbilityType.SERRATED_STRIKES, ToolType.SWORD,

View File

@ -61,7 +61,7 @@ public enum SubSkillType {
REPAIR_SUPER_REPAIR(1),
/* Salvage */
SALVAGE_ADVANCED_SALVAGE(1),
SALVAGE_SCRAP_COLLECTOR(8),
SALVAGE_ARCANE_SALVAGE(8),
/* Smelting */

View File

@ -1,102 +0,0 @@
package com.gmail.nossr50.dumpster.mods;
/*
public class CustomToolConfig extends Config {
//TODO: Disabled until modded servers come back
public List<Material> customAxes = new ArrayList<Material>();
public List<Material> customBows = new ArrayList<Material>();
public List<Material> customHoes = new ArrayList<Material>();
public List<Material> customPickaxes = new ArrayList<Material>();
public List<Material> customShovels = new ArrayList<Material>();
public List<Material> customSwords = new ArrayList<Material>();
public HashMap<Material, CustomTool> customToolMap = new HashMap<Material, CustomTool>();
public List<Repairable> repairables = new ArrayList<Repairable>();
private boolean needsUpdate = false;
protected CustomToolConfig(String fileName) {
//super(McmmoCore.getDataFolderPath().getPath() + "mods", fileName, false);
super(mcMMO.p.getDataFolder().getPath() + "mods", fileName, false);
loadKeys();
}
@Override
protected void loadKeys() {
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadTool(String toolType, List<Material> materialList) {
if (needsUpdate) {
return;
}
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
if (toolSection == null) {
return;
}
Set<String> toolConfigSet = toolSection.getKeys(false);
for (String toolName : toolConfigSet) {
if (config.contains(toolType + "." + toolName + "." + ".ID")) {
needsUpdate = true;
return;
}
Material toolMaterial = Material.matchMaterial(toolName);
if (toolMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + toolName);
continue;
}
boolean repairable = getBooleanValue(toolType + "." + toolName + ".Repairable");
Material repairMaterial = Material.matchMaterial(getStringValue(toolType + "." + toolName + ".Repair_Material", ""));
if (repairable && (repairMaterial == null)) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable. - " + toolName);
repairable = false;
}
if (repairable) {
byte repairData = (byte) getIntValue(toolType + "." + toolName + ".Repair_Material_Data_Value", -1);
int repairQuantity = SkillUtils.getRepairAndSalvageQuantities(new ItemStack(toolMaterial), repairMaterial, repairData);
if (repairQuantity == 0) {
repairQuantity = getIntValue(toolType + "." + toolName + ".Repair_Material_Quantity", 2);
}
String repairItemName = getStringValue(toolType + "." + toolName + ".Repair_Material_Pretty_Name");
int repairMinimumLevel = getIntValue(toolType + "." + toolName + ".Repair_MinimumLevel", 0);
double repairXpMultiplier = getDoubleValue(toolType + "." + toolName + ".Repair_XpMultiplier", 1);
short durability = toolMaterial.getMaxDurability();
if (durability == 0) {
durability = (short) getIntValue(toolType + "." + toolName + ".Durability", 60);
}
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, repairItemName, repairMinimumLevel, repairQuantity, durability, ItemType.TOOL, ItemMaterialCategory.OTHER, repairXpMultiplier));
}
double multiplier = getDoubleValue(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = getBooleanValue(toolType + "." + toolName + ".Ability_Enabled", true);
int tier = getIntValue(toolType + "." + toolName + ".Tier", 1);
CustomTool tool = new CustomTool(tier, abilityEnabled, multiplier);
materialList.add(toolMaterial);
customToolMap.put(toolMaterial, tool);
}
}
}*/

View File

@ -72,10 +72,11 @@ public class BlockListener implements Listener {
for (int i = 0; i < bonusCount; i++) {
event.getBlock().getWorld().dropItemNaturally(event.getBlockState().getLocation(), is);
}
event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, plugin);
}
}
if(event.getBlock().hasMetadata(MetadataConstants.BONUS_DROPS_METAKEY))
event.getBlock().removeMetadata(MetadataConstants.BONUS_DROPS_METAKEY, plugin);
}
/*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)

View File

@ -15,12 +15,7 @@ public class InteractionManager {
private static HashMap<String, AbstractSubSkill> subSkillNameMap; //Used for mmoinfo optimization
private static ArrayList<AbstractSubSkill> subSkillList;
/**
* Registers subskills with the Interaction registration
*
* @param abstractSubSkill the target subskill to register
*/
public static void registerSubSkill(AbstractSubSkill abstractSubSkill) {
public static void initMaps() {
/* INIT MAPS */
if (interactRegister == null)
interactRegister = new HashMap<>();
@ -30,7 +25,14 @@ public class InteractionManager {
if (subSkillNameMap == null)
subSkillNameMap = new HashMap<>();
}
/**
* Registers subskills with the Interaction registration
* @param abstractSubSkill the target subskill to register
*/
public static void registerSubSkill(AbstractSubSkill abstractSubSkill)
{
//Store a unique copy of each subskill
if (!subSkillList.contains(abstractSubSkill))
subSkillList.add(abstractSubSkill);
@ -70,8 +72,13 @@ public class InteractionManager {
* @param plugin instance of mcMMO plugin
* @param curInteractType the associated interaction type
*/
public static void processEvent(Event event, mcMMO plugin, InteractType curInteractType) {
for (Interaction interaction : interactRegister.get(curInteractType)) {
public static void processEvent(Event event, mcMMO plugin, InteractType curInteractType)
{
if(interactRegister.get(curInteractType) == null)
return;
for(Interaction interaction : interactRegister.get(curInteractType))
{
interaction.doInteraction(event, plugin);
}
}

View File

@ -26,6 +26,7 @@ import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType;
@ -599,27 +600,34 @@ public class PlayerListener implements Listener {
if (!mcMMO.getConfigManager().getConfigSuperAbilities().isMustSneakToActivate() || player.isSneaking()) {
/* REPAIR CHECKS */
if (type == Repair.getInstance().getAnvilMaterial() && PrimarySkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
if (type == Repair.getInstance().getAnvilMaterial()
&& PrimarySkillType.REPAIR.getPermissions(player)
&& mcMMO.getRepairableManager().isRepairable(heldItem)
&& heldItem.getAmount() <= 1) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to repair an enchanted item
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(true)) {
if (repairManager.checkConfirmation(true)) {
repairManager.handleRepair(heldItem);
player.updateInventory();
}
}
/* SALVAGE CHECKS */
else if (type == Salvage.anvilMaterial && PrimarySkillType.SALVAGE.getPermissions(player) && mcMMO.getSalvageableManager().isSalvageable(heldItem)) {
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
event.setCancelled(true);
else if (type == Salvage.anvilMaterial
&& PrimarySkillType.SALVAGE.getPermissions(player)
&& RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_SCRAP_COLLECTOR)
&& mcMMO.getSalvageableManager().isSalvageable(heldItem)
&& heldItem.getAmount() <= 1) {
SalvageManager salvageManager = UserManager.getPlayer(player).getSalvageManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to salvage an enchanted item
if (!(heldItem.getEnchantments().size() > 0) || salvageManager.checkConfirmation(true)) {
SkillUtils.handleAbilitySpeedDecrease(player);
salvageManager.handleSalvage(block.getLocation(), heldItem);
player.updateInventory();
}
// Make sure the player knows what he's doing when trying to salvage an enchanted item
if (salvageManager.checkConfirmation(true)) {
SkillUtils.handleAbilitySpeedDecrease(player);
salvageManager.handleSalvage(block.getLocation(), heldItem);
player.updateInventory();
}
}
}
/* BLAST MINING CHECK */

View File

@ -503,6 +503,8 @@ public class mcMMO extends JavaPlugin {
*/
if (mcMMO.getConfigManager().getConfigCoreSkills().isAcrobaticsEnabled()) {
InteractionManager.initMaps(); //Init maps
System.out.println("[mcMMO]" + " enabling Acrobatics Skills");
//TODO: Should do this differently

View File

@ -114,9 +114,8 @@ public class RepairManager extends SkillManager {
return;
}
//byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
ItemStack toRemove = new ItemStack(repairMaterial);
toRemove.setAmount(1);
short startDurability = item.getDurability();
@ -126,26 +125,6 @@ public class RepairManager extends SkillManager {
return;
}
// Check if they have the proper material to repair with
/*if (!inventory.contains(repairMaterial)) {
String prettyName = repairable.getRepairMaterialPrettyName() == null ? StringUtils.getPrettyItemString(repairMaterial) : repairable.getRepairMaterialPrettyName();
String materialsNeeded = "";
if (repairMaterialMetadata != (byte) -1 && !inventory.containsAtLeast(toRemove, 1)) {
materialsNeeded += ":" + repairMaterialMetadata;
}
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Skills.NeedMore.Extra", prettyName, materialsNeeded);
return;
}*/
// Do not repair stacked items
if (item.getAmount() != 1) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Repair.Skills.StackedItems");
return;
}
// Clear ability buffs before trying to repair.
SkillUtils.removeAbilityBuff(item);
@ -165,11 +144,6 @@ public class RepairManager extends SkillManager {
}
// Remove the item
/*if (repairMaterialMetadata == -1) {
toRemove = inventory.getItem(inventory.first(repairMaterial)).clone();
toRemove.setAmount(1);
}*/
inventory.removeItem(toRemove);
// Give out XP like candy

View File

@ -8,7 +8,6 @@ import org.bukkit.Material;
import java.util.Collections;
import java.util.List;
public class Repairable {
private final Material itemMaterial;
private final List<Material> repairMaterials;

View File

@ -89,16 +89,12 @@ public class SalvageManager extends SkillManager {
return;
}
if (item.getDurability() != 0 && (!RankUtils.hasUnlockedSubskill(player, SubSkillType.SALVAGE_ADVANCED_SALVAGE) || !Permissions.advancedSalvage(player))) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.Adept.Damaged");
return;
}
int maxAmountSalvageable = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity());
int salvageableAmount = Salvage.calculateSalvageableAmount(item.getDurability(), salvageable.getMaximumDurability(), salvageable.getMaximumQuantity());
int salvageableAmount = maxAmountSalvageable;
if (salvageableAmount == 0) {
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE_FAILED, "Salvage.Skills.TooDamaged");
player.sendMessage(LocaleLoader.getString("Salvage.Skills.TooDamaged"));
return;
}
@ -114,7 +110,30 @@ public class SalvageManager extends SkillManager {
enchantBook = arcaneSalvageCheck(enchants);
}
ItemStack salvageResults = new ItemStack(salvageable.getSalvagedItemMaterial(), salvageableAmount);
//Lottery on Salvageable Amount
int lotteryResults = 1;
int chanceOfSuccess = 80;
for(int x = 1; x < salvageableAmount-1; x++) {
if(RandomChanceUtil.rollDice(chanceOfSuccess, 100)) {
chanceOfSuccess-=20;
Math.max(chanceOfSuccess, 33);
lotteryResults+=1;
}
}
if(lotteryResults == salvageableAmount) {
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Perfect", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
} else if(RankUtils.isPlayerMaxRankInSubSkill(player, SubSkillType.SALVAGE_ARCANE_SALVAGE)) {
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Normal", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
} else {
NotificationManager.sendPlayerInformationChatOnly(player, "Salvage.Skills.Lottery.Untrained", String.valueOf(lotteryResults), StringUtils.getPrettyItemString(item.getType()));
}
ItemStack salvageResults = new ItemStack(salvageable.getSalvagedItemMaterial(), lotteryResults);
//Call event
if (EventUtils.callSalvageCheckEvent(player, item, salvageResults, enchantBook).isCancelled()) {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.json.McMMOUrl;
import com.gmail.nossr50.datatypes.json.McMMOWebLinks;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -26,18 +25,19 @@ public class TextComponentFactory {
/**
* Makes a text component using strings from a locale and supports passing an undefined number of variables to the LocaleLoader
*
* @param localeKey target locale string address
* @param notificationType type of notification
* @param values vars to be passed to the locale loader
* @param localeKey target locale string address
* @param values vars to be passed to the locale loader
* @return
*/
public static TextComponent getNotificationMultipleValues(String localeKey, NotificationType notificationType, String... values) {
public static TextComponent getNotificationMultipleValues(String localeKey, String... values)
{
String preColoredString = LocaleLoader.getString(localeKey, (Object[]) values);
TextComponent msg = new TextComponent(preColoredString);
return new TextComponent(msg);
}
public static TextComponent getNotificationTextComponentFromLocale(String localeKey, NotificationType notificationType) {
public static TextComponent getNotificationTextComponentFromLocale(String localeKey)
{
return getNotificationTextComponent(LocaleLoader.getString(localeKey));
}

View File

@ -37,7 +37,7 @@ public class NotificationManager {
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key, notificationType);
TextComponent message = TextComponentFactory.getNotificationTextComponentFromLocale(key);
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message);
sendNotification(player, customEvent);
@ -65,13 +65,23 @@ public class NotificationManager {
sendPlayerInformation(targetPlayer, notificationType, key, values);
}
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values) {
if (UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
public static void sendPlayerInformationChatOnly(Player player, String key, String... values)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
return;
String preColoredString = LocaleLoader.getString(key, (Object[]) values);
player.sendMessage(preColoredString);
}
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
{
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
return;
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
TextComponent message = TextComponentFactory.getNotificationMultipleValues(key, notificationType, values);
TextComponent message = TextComponentFactory.getNotificationMultipleValues(key, values);
McMMOPlayerNotificationEvent customEvent = checkNotificationEvent(player, notificationType, destination, message);
sendNotification(player, customEvent);

View File

@ -68,6 +68,9 @@ public final class UserManager {
* Save all users ON THIS THREAD.
*/
public static void saveAll() {
if(playerDataSet == null)
return;
ImmutableList<McMMOPlayer> trackedSyncData = ImmutableList.copyOf(playerDataSet);
mcMMO.p.getLogger().info("Saving mcMMOPlayers... (" + trackedSyncData.size() + ")");

View File

@ -397,4 +397,10 @@ public class RankUtils {
return mcMMO.getConfigManager().getConfigLeveling().getLevelCap(subSkillType.getParentSkill());
}
public static boolean isPlayerMaxRankInSubSkill(Player player, SubSkillType subSkillType) {
int playerRank = getRank(player, subSkillType);
int highestRank = getHighestRank(subSkillType);
return playerRank == highestRank;
}
}

View File

@ -13,6 +13,7 @@ import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.NotificationManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@ -24,6 +25,7 @@ import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class SkillUtils {
@ -268,33 +270,33 @@ public class SkillUtils {
}
public static int getRepairAndSalvageQuantities(ItemStack item) {
return getRepairAndSalvageQuantities(item, getRepairAndSalvageItem(item), (byte) -1);
return getRepairAndSalvageQuantities(item.getType(), getRepairAndSalvageItem(item));
}
public static int getRepairAndSalvageQuantities(ItemStack item, Material repairMaterial, byte repairMetadata) {
// Workaround for Bukkit bug where damaged items would not return any recipes
item = item.clone();
item.setDurability((short) 0);
public static int getRepairAndSalvageQuantities(Material itemMaterial, Material recipeMaterial) {
int quantity = 0;
List<Recipe> recipes = mcMMO.p.getServer().getRecipesFor(item);
if (recipes.isEmpty()) {
return quantity;
}
for(Iterator<? extends Recipe> recipeIterator = Bukkit.getServer().recipeIterator(); recipeIterator.hasNext();) {
Recipe bukkitRecipe = recipeIterator.next();
Recipe recipe = recipes.get(0);
if(bukkitRecipe.getResult().getType() != itemMaterial)
continue;
if (recipe instanceof ShapelessRecipe) {
for (ItemStack ingredient : ((ShapelessRecipe) recipe).getIngredientList()) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairMaterial))) {
quantity += ingredient.getAmount();
if(bukkitRecipe instanceof ShapelessRecipe) {
for (ItemStack ingredient : ((ShapelessRecipe) bukkitRecipe).getIngredientList()) {
if (ingredient != null
&& (recipeMaterial == null || ingredient.getType() == recipeMaterial)
&& (ingredient.getType() == recipeMaterial)) {
quantity += ingredient.getAmount();
}
}
}
} else if (recipe instanceof ShapedRecipe) {
for (ItemStack ingredient : ((ShapedRecipe) recipe).getIngredientMap().values()) {
if (ingredient != null && (repairMaterial == null || ingredient.getType() == repairMaterial) && (repairMetadata == -1 || ingredient.getType().equals(repairMaterial))) {
quantity += ingredient.getAmount();
} else if(bukkitRecipe instanceof ShapedRecipe) {
for (ItemStack ingredient : ((ShapedRecipe) bukkitRecipe).getIngredientMap().values()) {
if (ingredient != null
&& (recipeMaterial == null || ingredient.getType() == recipeMaterial)
&& (ingredient.getType() == recipeMaterial)) {
quantity += ingredient.getAmount();
}
}
}
}