mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-03 04:55:28 +02:00
Merge 2.1.44
This commit is contained in:
@@ -54,6 +54,10 @@ public final class ChimaeraWing {
|
||||
|
||||
mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Not loaded
|
||||
if(mcMMOPlayer == null)
|
||||
return;
|
||||
|
||||
if (mcMMOPlayer.getTeleportCommenceLocation() != null) {
|
||||
return;
|
||||
}
|
||||
|
@@ -120,11 +120,16 @@ public class EventUtils {
|
||||
Player player = (Player) entity;
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(mcMMOPlayer == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Check for invincibility */
|
||||
if (mcMMOPlayer.getGodMode()) {
|
||||
entityDamageEvent.setCancelled(true);
|
||||
@@ -240,6 +245,9 @@ public class EventUtils {
|
||||
public static void handlePartyTeleportEvent(Player teleportingPlayer, Player targetPlayer) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(teleportingPlayer);
|
||||
|
||||
if(mcMMOPlayer == null)
|
||||
return;
|
||||
|
||||
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(teleportingPlayer, targetPlayer, mcMMOPlayer.getParty().getName());
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@@ -298,6 +306,9 @@ public class EventUtils {
|
||||
}
|
||||
|
||||
public static boolean handleStatsLossEvent(Player player, HashMap<String, Integer> levelChanged, HashMap<String, Float> experienceChanged) {
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return true;
|
||||
|
||||
McMMOPlayerStatLossEvent event = new McMMOPlayerStatLossEvent(player, levelChanged, experienceChanged);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
@@ -344,6 +355,15 @@ public class EventUtils {
|
||||
HashMap<String, Float> experienceChangedVictim = eventVictim.getExperienceChanged();
|
||||
|
||||
McMMOPlayer killerPlayer = UserManager.getPlayer(killer);
|
||||
|
||||
//Not loaded
|
||||
if(killerPlayer == null)
|
||||
return true;
|
||||
|
||||
//Not loaded
|
||||
if(UserManager.getPlayer(victim) == null)
|
||||
return true;
|
||||
|
||||
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
||||
|
||||
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
|
||||
|
@@ -17,6 +17,9 @@ public final class HardcoreManager {
|
||||
double statLossPercentage = MainConfig.getInstance().getHardcoreDeathStatPenaltyPercentage();
|
||||
int levelThreshold = MainConfig.getInstance().getHardcoreDeathStatPenaltyLevelThreshold();
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return;
|
||||
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
int totalLevelsLost = 0;
|
||||
|
||||
@@ -59,6 +62,9 @@ public final class HardcoreManager {
|
||||
double vampirismStatLeechPercentage = MainConfig.getInstance().getHardcoreVampirismStatLeechPercentage();
|
||||
int levelThreshold = MainConfig.getInstance().getHardcoreVampirismLevelThreshold();
|
||||
|
||||
if(UserManager.getPlayer(killer) == null || UserManager.getPlayer(victim) == null)
|
||||
return;
|
||||
|
||||
PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile();
|
||||
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
||||
int totalLevelsStolen = 0;
|
||||
|
@@ -106,6 +106,11 @@ public final class Permissions {
|
||||
* PERKS
|
||||
*/
|
||||
|
||||
/* BYPASS PERKS */
|
||||
|
||||
public static boolean hasRepairEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.repairenchant"); }
|
||||
public static boolean hasSalvageEnchantBypassPerk(Permissible permissible) { return permissible.hasPermission("mcmmo.perks.bypass.salvageenchant"); }
|
||||
|
||||
public static boolean lucky(Permissible permissible, PrimarySkillType skill) { return permissible.hasPermission("mcmmo.perks.lucky." + skill.toString().toLowerCase()); }
|
||||
|
||||
/* XP PERKS */
|
||||
|
@@ -228,6 +228,9 @@ public final class CommandUtils {
|
||||
}
|
||||
|
||||
private static void printGroupedSkillData(Player inspect, CommandSender display, String header, List<PrimarySkillType> skillGroup) {
|
||||
if(UserManager.getPlayer(inspect) == null)
|
||||
return;
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(inspect).getProfile();
|
||||
|
||||
List<String> displayData = new ArrayList<>();
|
||||
|
@@ -28,7 +28,7 @@ public class NotificationManager {
|
||||
*/
|
||||
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key)
|
||||
{
|
||||
if(!UserManager.getPlayer(player).useChatNotifications())
|
||||
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
|
||||
return;
|
||||
|
||||
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
|
||||
@@ -39,6 +39,15 @@ public class NotificationManager {
|
||||
sendNotification(player, customEvent);
|
||||
}
|
||||
|
||||
|
||||
public static boolean doesPlayerUseNotifications(Player player)
|
||||
{
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return false;
|
||||
else
|
||||
return UserManager.getPlayer(player).useChatNotifications();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends players notifications from mcMMO
|
||||
* This does this by sending out an event so other plugins can cancel it
|
||||
@@ -60,7 +69,7 @@ public class NotificationManager {
|
||||
|
||||
public static void sendPlayerInformation(Player player, NotificationType notificationType, String key, String... values)
|
||||
{
|
||||
if(!UserManager.getPlayer(player).useChatNotifications())
|
||||
if(UserManager.getPlayer(player) == null || !UserManager.getPlayer(player).useChatNotifications())
|
||||
return;
|
||||
|
||||
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(notificationType) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
|
||||
@@ -108,7 +117,7 @@ public class NotificationManager {
|
||||
*/
|
||||
public static void sendPlayerLevelUpNotification(McMMOPlayer mcMMOPlayer, PrimarySkillType skillName, int levelsGained, int newLevel)
|
||||
{
|
||||
if(!UserManager.getPlayer(mcMMOPlayer.getPlayer()).useChatNotifications())
|
||||
if(!mcMMOPlayer.useChatNotifications())
|
||||
return;
|
||||
|
||||
ChatMessageType destination = AdvancedConfig.getInstance().doesNotificationUseActionBar(NotificationType.LEVEL_UP_MESSAGE) ? ChatMessageType.ACTION_BAR : ChatMessageType.SYSTEM;
|
||||
@@ -129,7 +138,7 @@ public class NotificationManager {
|
||||
|
||||
public static void sendPlayerUnlockNotification(McMMOPlayer mcMMOPlayer, SubSkillType subSkillType)
|
||||
{
|
||||
if(!UserManager.getPlayer(mcMMOPlayer.getPlayer()).useChatNotifications())
|
||||
if(!mcMMOPlayer.useChatNotifications())
|
||||
return;
|
||||
|
||||
//CHAT MESSAGE
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.gmail.nossr50.util.player;
|
||||
|
||||
import com.gmail.nossr50.api.exceptions.McMMOPlayerNotFoundException;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -95,9 +96,14 @@ public final class UserManager {
|
||||
return retrieveMcMMOPlayer(playerName, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the McMMOPlayer object for a player, this can be null if the player has not yet been loaded.
|
||||
* @param player target player
|
||||
* @return McMMOPlayer object for this player, null if Player has not been loaded
|
||||
*/
|
||||
public static McMMOPlayer getPlayer(Player player) {
|
||||
//Avoid Array Index out of bounds
|
||||
if(player.hasMetadata(mcMMO.playerDataKey))
|
||||
if(player != null && player.hasMetadata(mcMMO.playerDataKey))
|
||||
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
||||
else
|
||||
return null;
|
||||
|
@@ -204,6 +204,9 @@ public class ScoreboardWrapper {
|
||||
// TODO is there any way to do the time that looks acceptable?
|
||||
// player.sendMessage(LocaleLoader.getString("Commands.ConfigScoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F));
|
||||
|
||||
if(UserManager.getPlayer(playerName) == null)
|
||||
return;
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
if (profile.getScoreboardTipsShown() >= mcMMO.getScoreboardSettings().getTipsAmount()) {
|
||||
@@ -434,6 +437,9 @@ public class ScoreboardWrapper {
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
if(mcMMOPlayer == null)
|
||||
return;
|
||||
|
||||
switch (sidebarType) {
|
||||
|
||||
case SKILL_BOARD:
|
||||
|
@@ -629,6 +629,10 @@ public final class CombatUtils {
|
||||
if (entity instanceof Player) {
|
||||
Player defender = (Player) entity;
|
||||
|
||||
//TODO: NPC Interaction?
|
||||
if(UserManager.getPlayer(defender) == null)
|
||||
return true;
|
||||
|
||||
if (!defender.getWorld().getPVP() || defender == player || UserManager.getPlayer(defender).getGodMode()) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -172,6 +172,9 @@ public class RankUtils {
|
||||
//Get our rank map
|
||||
HashMap<Integer, Integer> rankMap = subSkillRanks.get(skillName);
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return 0;
|
||||
|
||||
//Skill level of parent skill
|
||||
int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(subSkillType.getParentSkill());
|
||||
|
||||
@@ -216,6 +219,9 @@ public class RankUtils {
|
||||
//Get our rank map
|
||||
HashMap<Integer, Integer> rankMap = subSkillRanks.get(skillName);
|
||||
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
return 0;
|
||||
|
||||
//Skill level of parent skill
|
||||
int currentSkillLevel = UserManager.getPlayer(player).getSkillLevel(abstractSubSkill.getPrimarySkill());
|
||||
|
||||
|
@@ -160,6 +160,11 @@ public class SkillUtils {
|
||||
}
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
//Not Loaded
|
||||
if(mcMMOPlayer == null)
|
||||
return;
|
||||
|
||||
PrimarySkillType skill = mcMMOPlayer.getAbilityMode(SuperAbilityType.SUPER_BREAKER) ? PrimarySkillType.MINING : PrimarySkillType.EXCAVATION;
|
||||
|
||||
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
|
||||
|
Reference in New Issue
Block a user