mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-31 03:25:28 +02:00
Merge branch 'master' of github.com:mcMMO-Dev/mcMMO into configurable
This commit is contained in:
@@ -123,7 +123,7 @@ public class EventUtils {
|
||||
Entity entity = entityDamageEvent.getEntity();
|
||||
|
||||
//Check to make sure the entity is not an NPC
|
||||
if (Misc.isNPCEntity(entity))
|
||||
if(Misc.isNPCEntityExcludingVillagers(entity))
|
||||
return false;
|
||||
|
||||
if (!entity.isValid() || !(entity instanceof LivingEntity)) {
|
||||
|
@@ -5,6 +5,8 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardManager;
|
||||
import com.gmail.nossr50.worldguard.WorldGuardUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -14,6 +16,13 @@ public final class HardcoreManager {
|
||||
}
|
||||
|
||||
public static void invokeStatPenalty(Player player) {
|
||||
|
||||
if(WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if(!WorldGuardManager.getInstance().hasHardcoreFlag(player)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
double statLossPercentage = mcMMO.getConfigManager().getConfigHardcore().getDeathPenalty().getPenaltyPercentage();
|
||||
int levelThreshold = mcMMO.getConfigManager().getConfigHardcore().getDeathPenalty().getLevelThreshold();
|
||||
|
||||
@@ -59,6 +68,13 @@ public final class HardcoreManager {
|
||||
}
|
||||
|
||||
public static void invokeVampirism(Player killer, Player victim) {
|
||||
|
||||
if(WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
if(!WorldGuardManager.getInstance().hasHardcoreFlag(killer) || !WorldGuardManager.getInstance().hasHardcoreFlag(victim)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
double vampirismStatLeechPercentage = mcMMO.getConfigManager().getConfigHardcore().getVampirism().getPenaltyPercentage();
|
||||
int levelThreshold = mcMMO.getConfigManager().getConfigHardcore().getVampirism().getLevelThreshold();
|
||||
|
||||
|
@@ -37,13 +37,20 @@ public final class Misc {
|
||||
private Misc() {
|
||||
}
|
||||
|
||||
public static boolean isNPCEntity(Entity entity) {
|
||||
public static boolean isNPCEntityExcludingVillagers(Entity entity) {
|
||||
return (entity == null
|
||||
|| (entity.hasMetadata("NPC") && !(entity instanceof Villager))
|
||||
|| (entity instanceof NPC && !(entity instanceof Villager))
|
||||
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
||||
}
|
||||
|
||||
public static boolean isNPCIncludingVillagers(Player entity) {
|
||||
return (entity == null
|
||||
|| (entity.hasMetadata("NPC"))
|
||||
|| (entity instanceof NPC)
|
||||
|| entity.getClass().getName().equalsIgnoreCase("cofh.entity.PlayerFake"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if two locations are near each other.
|
||||
*
|
||||
|
@@ -34,19 +34,6 @@ public final class CommandUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean inspectOffline(CommandSender sender, PlayerProfile profile, boolean hasPermission) {
|
||||
if (unloadedProfile(sender, profile)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!hasPermission && !mcMMO.getConfigManager().getConfigCommands().isAllowInspectOnOfflinePlayers()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean tooFar(CommandSender sender, Player target, boolean hasPermission) {
|
||||
if (sender instanceof Player
|
||||
&& mcMMO.getConfigManager().getConfigCommands().isLimitInspectRange()
|
||||
|
@@ -240,7 +240,7 @@ public final class CombatUtils {
|
||||
EntityType entityType = damager.getType();
|
||||
|
||||
if (target instanceof Player) {
|
||||
if (Misc.isNPCEntity(target)) {
|
||||
if (Misc.isNPCEntityExcludingVillagers(target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ public final class CombatUtils {
|
||||
if (tamer instanceof Player && PrimarySkillType.TAMING.shouldProcess(target)) {
|
||||
Player master = (Player) tamer;
|
||||
|
||||
if (!Misc.isNPCEntity(master) && PrimarySkillType.TAMING.getPermissions(master)) {
|
||||
if (!Misc.isNPCEntityExcludingVillagers(master) && PrimarySkillType.TAMING.getPermissions(master)) {
|
||||
processTamingCombat(target, master, wolf, event);
|
||||
}
|
||||
}
|
||||
@@ -336,11 +336,11 @@ public final class CombatUtils {
|
||||
if (projectileSource instanceof Player && PrimarySkillType.ARCHERY.shouldProcess(target)) {
|
||||
Player player = (Player) projectileSource;
|
||||
|
||||
if (!Misc.isNPCEntity(player) && PrimarySkillType.ARCHERY.getPermissions(player)) {
|
||||
if (!Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.ARCHERY.getPermissions(player)) {
|
||||
processArcheryCombat(target, player, event, arrow);
|
||||
}
|
||||
|
||||
if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntity(player) && PrimarySkillType.TAMING.getPermissions(player)) {
|
||||
if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.TAMING.getPermissions(player)) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
TamingManager tamingManager = mcMMOPlayer.getTamingManager();
|
||||
tamingManager.attackTarget(target);
|
||||
@@ -508,7 +508,7 @@ public final class CombatUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
|
||||
if (Misc.isNPCEntityExcludingVillagers(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -830,7 +830,7 @@ public final class CombatUtils {
|
||||
|
||||
Player player = (Player) attacker;
|
||||
|
||||
if (Misc.isNPCEntity(player) || Misc.isNPCEntity(target)) {
|
||||
if (Misc.isNPCEntityExcludingVillagers(player) || Misc.isNPCEntityExcludingVillagers(target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user