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

@@ -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();
}
}
}
}