mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 13:16:45 +01:00
mcMMO will no longer use the DamageModifier API (potentially fix immortal player bug)
This commit is contained in:
parent
8066f7f7f2
commit
5ab55c1653
@ -23,8 +23,7 @@ public class SamePartyPredicate<T extends CommandSender> implements Predicate<T>
|
||||
if(t instanceof ConsoleCommandSender) {
|
||||
return false; //Party audiences are special, we exclude console from them to avoid double messaging since we send a more verbose version to consoles
|
||||
} else {
|
||||
if(t instanceof Player) {
|
||||
Player player = (Player) t;
|
||||
if(t instanceof Player player) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
if(mcMMOPlayer != null) {
|
||||
return mcMMOPlayer.getParty() == party;
|
||||
|
@ -27,12 +27,11 @@ public class MmoInfoCommand implements TabExecutor {
|
||||
/*
|
||||
* Only allow players to use this command
|
||||
*/
|
||||
if(commandSender instanceof Player)
|
||||
if(commandSender instanceof Player player)
|
||||
{
|
||||
if(args.length < 1)
|
||||
return false;
|
||||
|
||||
Player player = (Player) commandSender;
|
||||
if(Permissions.mmoinfo(player))
|
||||
{
|
||||
if(args == null || args[0] == null)
|
||||
|
@ -25,7 +25,7 @@ import java.util.logging.Logger;
|
||||
public final class FlatFileDatabaseManager implements DatabaseManager {
|
||||
public static final String IGNORED = "IGNORED";
|
||||
public static final String LEGACY_INVALID_OLD_USERNAME = "_INVALID_OLD_USERNAME_'";
|
||||
private final @NotNull EnumMap<PrimarySkillType, List<PlayerStat>> playerStatHash = new EnumMap<PrimarySkillType, List<PlayerStat>>(PrimarySkillType.class);
|
||||
private final @NotNull EnumMap<PrimarySkillType, List<PlayerStat>> playerStatHash = new EnumMap<>(PrimarySkillType.class);
|
||||
private final @NotNull List<PlayerStat> powerLevels = new ArrayList<>();
|
||||
private long lastUpdate = 0;
|
||||
private final @NotNull String usersFilePath;
|
||||
|
@ -1122,8 +1122,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
|
||||
private PlayerProfile loadFromResult(String playerName, ResultSet result) throws SQLException {
|
||||
Map<PrimarySkillType, Integer> skills = new EnumMap<PrimarySkillType, Integer>(PrimarySkillType.class); // Skill & Level
|
||||
Map<PrimarySkillType, Float> skillsXp = new EnumMap<PrimarySkillType, Float>(PrimarySkillType.class); // Skill & XP
|
||||
Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level
|
||||
Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
|
||||
Map<SuperAbilityType, Integer> skillsDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
|
||||
Map<UniqueDataType, Integer> uniqueData = new EnumMap<>(UniqueDataType.class); //Chimaera wing cooldown and other misc info
|
||||
MobHealthbarType mobHealthbarType;
|
||||
|
@ -29,8 +29,7 @@ public class FlatFileDataUtil {
|
||||
/*
|
||||
* First fix the bad data values if they exist
|
||||
*/
|
||||
if(dataContainer instanceof BadCategorizedFlatFileData) {
|
||||
BadCategorizedFlatFileData badData = (BadCategorizedFlatFileData) dataContainer;
|
||||
if(dataContainer instanceof BadCategorizedFlatFileData badData) {
|
||||
splitData = repairBadData(dataContainer.getSplitData(), badData.getBadDataIndexes());
|
||||
} else {
|
||||
splitData = dataContainer.getSplitData();
|
||||
|
@ -37,8 +37,7 @@ public class LevelUpBroadcastPredicate<T extends CommandSender> implements Predi
|
||||
return false;
|
||||
}
|
||||
|
||||
if(t instanceof Player) {
|
||||
Player listeningPlayer = (Player) t;
|
||||
if(t instanceof Player listeningPlayer) {
|
||||
|
||||
//Party Member Check
|
||||
if(mcMMO.p.getGeneralConfig().isLevelUpBroadcastsPartyMembersOnly()) {
|
||||
|
@ -37,8 +37,7 @@ public class PowerLevelUpBroadcastPredicate<T extends CommandSender> implements
|
||||
return false;
|
||||
}
|
||||
|
||||
if(t instanceof Player) {
|
||||
Player listeningPlayer = (Player) t;
|
||||
if(t instanceof Player listeningPlayer) {
|
||||
|
||||
//Party Member Check
|
||||
if(mcMMO.p.getGeneralConfig().isPowerLevelUpBroadcastsPartyMembersOnly()) {
|
||||
|
@ -5,7 +5,7 @@ public class McMMOUrl {
|
||||
public static final String urlDiscord = "https://discord.gg/bJ7pFS9";
|
||||
public static final String urlPatreon = "https://www.patreon.com/nossr50";
|
||||
public static final String urlWiki = "https://www.mcmmo.org/wiki/";
|
||||
public static final String urlSpigot = "http://spigot.mcmmo.org";
|
||||
public static final String urlSpigot = "https://spigot.mcmmo.org";
|
||||
public static final String urlTranslate = "https://translate.mcmmo.org/";
|
||||
|
||||
public static String getUrl(McMMOWebLinks webLinks)
|
||||
|
@ -403,12 +403,10 @@ public class Party {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(obj instanceof Party)) {
|
||||
if (!(obj instanceof Party other)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Party other = (Party) obj;
|
||||
|
||||
if ((this.getName() == null) || (other.getName() == null)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public class McMMOPlayer implements Identified {
|
||||
private final Player player;
|
||||
private final PlayerProfile profile;
|
||||
|
||||
private final Map<PrimarySkillType, SkillManager> skillManagers = new EnumMap<PrimarySkillType, SkillManager>(PrimarySkillType.class);
|
||||
private final Map<PrimarySkillType, SkillManager> skillManagers = new EnumMap<>(PrimarySkillType.class);
|
||||
private final ExperienceBarManager experienceBarManager;
|
||||
|
||||
private Party party;
|
||||
@ -98,10 +98,10 @@ public class McMMOPlayer implements Identified {
|
||||
|
||||
private ChatChannel chatChannel;
|
||||
|
||||
private final Map<SuperAbilityType, Boolean> abilityMode = new EnumMap<SuperAbilityType, Boolean>(SuperAbilityType.class);
|
||||
private final Map<SuperAbilityType, Boolean> abilityInformed = new EnumMap<SuperAbilityType, Boolean>(SuperAbilityType.class);
|
||||
private final Map<SuperAbilityType, Boolean> abilityMode = new EnumMap<>(SuperAbilityType.class);
|
||||
private final Map<SuperAbilityType, Boolean> abilityInformed = new EnumMap<>(SuperAbilityType.class);
|
||||
|
||||
private final Map<ToolType, Boolean> toolMode = new EnumMap<ToolType, Boolean>(ToolType.class);
|
||||
private final Map<ToolType, Boolean> toolMode = new EnumMap<>(ToolType.class);
|
||||
|
||||
private int recentlyHurt;
|
||||
private int respawnATS;
|
||||
@ -943,7 +943,7 @@ public class McMMOPlayer implements Identified {
|
||||
SkillUtils.removeAbilityBuff(player.getInventory().getItemInMainHand());
|
||||
|
||||
// Enable the ability
|
||||
profile.setAbilityDATS(superAbilityType, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
profile.setAbilityDATS(superAbilityType, System.currentTimeMillis() + ((long) ticks * Misc.TIME_CONVERSION_FACTOR));
|
||||
setAbilityMode(superAbilityType, true);
|
||||
|
||||
if (superAbilityType == SuperAbilityType.SUPER_BREAKER || superAbilityType == SuperAbilityType.GIGA_DRILL_BREAKER) {
|
||||
@ -951,7 +951,7 @@ public class McMMOPlayer implements Identified {
|
||||
}
|
||||
|
||||
setToolPreparationMode(tool, false);
|
||||
new AbilityDisableTask(this, superAbilityType).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||
new AbilityDisableTask(this, superAbilityType).runTaskLater(mcMMO.p, (long) ticks * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
public void processAbilityActivation(@NotNull PrimarySkillType primarySkillType) {
|
||||
|
@ -14,10 +14,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.DelayQueue;
|
||||
|
||||
public class PlayerProfile {
|
||||
@ -35,12 +32,12 @@ public class PlayerProfile {
|
||||
/* Skill Data */
|
||||
private final Map<PrimarySkillType, Integer> skills = new EnumMap<>(PrimarySkillType.class); // Skill & Level
|
||||
private final Map<PrimarySkillType, Float> skillsXp = new EnumMap<>(PrimarySkillType.class); // Skill & XP
|
||||
private final Map<SuperAbilityType, Integer> abilityDATS = new EnumMap<SuperAbilityType, Integer>(SuperAbilityType.class); // Ability & Cooldown
|
||||
private final Map<UniqueDataType, Integer> uniquePlayerData = new EnumMap<UniqueDataType, Integer>(UniqueDataType.class); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
private final Map<SuperAbilityType, Integer> abilityDATS = new EnumMap<>(SuperAbilityType.class); // Ability & Cooldown
|
||||
private final Map<UniqueDataType, Integer> uniquePlayerData = new EnumMap<>(UniqueDataType.class); //Misc data that doesn't fit into other categories (chimaera wing, etc..)
|
||||
|
||||
// Store previous XP gains for diminished returns
|
||||
private final DelayQueue<SkillXpGain> gainedSkillsXp = new DelayQueue<>();
|
||||
private final Map<PrimarySkillType, Float> rollingSkillsXp = new EnumMap<PrimarySkillType, Float>(PrimarySkillType.class);
|
||||
private final Map<PrimarySkillType, Float> rollingSkillsXp = new EnumMap<>(PrimarySkillType.class);
|
||||
|
||||
@Deprecated
|
||||
public PlayerProfile(String playerName) {
|
||||
@ -160,14 +157,10 @@ public class PlayerProfile {
|
||||
/**
|
||||
* Get this users last login, will return current java.lang.System#currentTimeMillis() if it doesn't exist
|
||||
* @return the last login
|
||||
* @deprecated This is only function for FlatFileDB atm and its only here for unit testing right now
|
||||
* @deprecated This is only function for FlatFileDB atm, and it's only here for unit testing right now
|
||||
*/
|
||||
@Deprecated
|
||||
public @NotNull Long getLastLogin() {
|
||||
if(lastLogin == null)
|
||||
return -1L;
|
||||
else
|
||||
return lastLogin;
|
||||
return Objects.requireNonNullElse(lastLogin, -1L);
|
||||
}
|
||||
|
||||
public void updateLastLogin() {
|
||||
|
@ -1,35 +1,14 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Called when mcMMO applies damage from an entity due to special abilities.
|
||||
*/
|
||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent implements FakeEvent {
|
||||
|
||||
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, @NotNull final Map<DamageModifier, Double> modifiers) {
|
||||
super(damager, damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, double damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(@NotNull Map<DamageModifier, Double> modifiers) {
|
||||
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
|
||||
|
||||
for (DamageModifier modifier : modifiers.keySet()) {
|
||||
modifierFunctions.put(modifier, (o -> -0.0));
|
||||
}
|
||||
|
||||
return modifierFunctions;
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +1,14 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Called when mcMMO applies damage due to special abilities.
|
||||
*/
|
||||
public class FakeEntityDamageEvent extends EntityDamageEvent implements FakeEvent {
|
||||
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, final Map<DamageModifier, Double> modifiers) {
|
||||
super(damagee, cause, modifiers, getFunctionModifiers(modifiers));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FakeEntityDamageEvent(Entity damagee, DamageCause cause, double damage) {
|
||||
super(damagee, cause, damage);
|
||||
}
|
||||
|
||||
public static EnumMap<DamageModifier, Function<? super Double, Double>> getFunctionModifiers(Map<DamageModifier, Double> modifiers) {
|
||||
EnumMap<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<>(DamageModifier.class);
|
||||
Function<? super Double, Double> ZERO = Functions.constant(-0.0);
|
||||
|
||||
for (DamageModifier modifier : modifiers.keySet()) {
|
||||
modifierFunctions.put(modifier, ZERO);
|
||||
}
|
||||
|
||||
return modifierFunctions;
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
package com.gmail.nossr50.events.skills.rupture;
|
||||
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.EnumMap;
|
||||
|
||||
public class McMMOEntityDamageByRuptureEvent extends EntityDamageByEntityEvent {
|
||||
private final McMMOPlayer mcMMODamager;
|
||||
|
||||
public McMMOEntityDamageByRuptureEvent(@NotNull McMMOPlayer damager, @NotNull Entity damagee, double damage) {
|
||||
super(damager.getPlayer(), damagee, DamageCause.CUSTOM, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, (o -> -0.0))));
|
||||
super(damager.getPlayer(), damagee, DamageCause.CUSTOM, damage);
|
||||
this.mcMMODamager = damager;
|
||||
}
|
||||
|
||||
|
@ -696,9 +696,8 @@ public class BlockListener implements Listener {
|
||||
player.sendMessage("[mcMMO DEBUG] World Guard xp flag is not permitted for this player in this region");
|
||||
}
|
||||
|
||||
if(blockState instanceof Furnace)
|
||||
if(blockState instanceof Furnace furnace)
|
||||
{
|
||||
Furnace furnace = (Furnace) blockState;
|
||||
if(mcMMO.getSmeltingTracker().isFurnaceOwned(furnace))
|
||||
{
|
||||
player.sendMessage("[mcMMO DEBUG] This furnace has a registered owner");
|
||||
|
@ -92,14 +92,12 @@ public class EntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onEntityTransform(EntityTransformEvent event) {
|
||||
if(event.getEntity() instanceof LivingEntity) {
|
||||
LivingEntity livingEntity = (LivingEntity) event.getEntity();
|
||||
if(event.getEntity() instanceof LivingEntity livingEntity) {
|
||||
|
||||
//Transfer metadata keys from mob-spawned mobs to new mobs
|
||||
if(mobMetadataService.hasMobFlags(livingEntity)) {
|
||||
for(Entity entity : event.getTransformedEntities()) {
|
||||
if(entity instanceof LivingEntity) {
|
||||
LivingEntity transformedEntity = (LivingEntity) entity;
|
||||
if(entity instanceof LivingEntity transformedEntity) {
|
||||
mobMetadataService.addMobFlags(livingEntity, transformedEntity);
|
||||
}
|
||||
}
|
||||
@ -121,8 +119,7 @@ public class EntityListener implements Listener {
|
||||
//Prevent entities from giving XP if they target endermite
|
||||
if(event.getTarget() instanceof Endermite)
|
||||
{
|
||||
if(event.getEntity() instanceof Enderman) {
|
||||
Enderman enderman = (Enderman) event.getEntity();
|
||||
if(event.getEntity() instanceof Enderman enderman) {
|
||||
|
||||
if(!mobMetadataService.hasMobFlag(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman)) {
|
||||
mobMetadataService.flagMetadata(MobMetaFlagType.EXPLOITED_ENDERMEN, enderman);
|
||||
@ -137,9 +134,8 @@ public class EntityListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
if(event.getEntity() instanceof Player player)
|
||||
{
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
@ -175,9 +171,8 @@ public class EntityListener implements Listener {
|
||||
if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
if(event.getEntity().getShooter() instanceof Player)
|
||||
if(event.getEntity().getShooter() instanceof Player player)
|
||||
{
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded()) {
|
||||
@ -267,19 +262,15 @@ public class EntityListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityCombustByEntityEvent(EntityCombustByEntityEvent event) {
|
||||
//Prevent players from setting fire to each other if they are in the same party
|
||||
if(event.getEntity() instanceof Player) {
|
||||
Player defender = (Player) event.getEntity();
|
||||
if(event.getEntity() instanceof Player defender) {
|
||||
|
||||
if(event.getCombuster() instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) event.getCombuster();
|
||||
if(projectile.getShooter() instanceof Player) {
|
||||
Player attacker = (Player) projectile.getShooter();
|
||||
if(event.getCombuster() instanceof Projectile projectile) {
|
||||
if(projectile.getShooter() instanceof Player attacker) {
|
||||
if(checkParties(event, defender, attacker)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if(event.getCombuster() instanceof Player) {
|
||||
Player attacker = (Player) event.getCombuster();
|
||||
} else if(event.getCombuster() instanceof Player attacker) {
|
||||
if(checkParties(event, defender, attacker)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -311,9 +302,7 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
} else if(attacker instanceof Projectile) {
|
||||
|
||||
Projectile projectile = (Projectile) attacker;
|
||||
} else if(attacker instanceof Projectile projectile) {
|
||||
|
||||
if(projectile.getShooter() instanceof Player) {
|
||||
if(!WorldGuardManager.getInstance().hasMainFlag((Player) projectile.getShooter())) {
|
||||
@ -342,12 +331,10 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(defender)) || !defender.isValid() || !(defender instanceof LivingEntity)) {
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(defender)) || !defender.isValid() || !(defender instanceof LivingEntity target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity target = (LivingEntity) defender;
|
||||
|
||||
if (CombatUtils.isInvincible(target, damage)) {
|
||||
return;
|
||||
}
|
||||
@ -374,14 +361,12 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
|
||||
//Friendly fire checks
|
||||
if (defender instanceof Player) {
|
||||
Player defendingPlayer = (Player) defender;
|
||||
if (defender instanceof Player defendingPlayer) {
|
||||
Player attackingPlayer;
|
||||
|
||||
//If the attacker is a Player or a projectile belonging to a player
|
||||
if(attacker instanceof Projectile || attacker instanceof Player) {
|
||||
if(attacker instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) attacker;
|
||||
if(attacker instanceof Projectile projectile) {
|
||||
if(((Projectile) attacker).getShooter() instanceof Player) {
|
||||
attackingPlayer = (Player) projectile.getShooter();
|
||||
|
||||
@ -443,8 +428,7 @@ public class EntityListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
|
||||
public void onEntityDamageMonitor(EntityDamageByEntityEvent entityDamageEvent) {
|
||||
if(entityDamageEvent.getEntity() instanceof LivingEntity) {
|
||||
LivingEntity livingEntity = (LivingEntity) entityDamageEvent.getEntity();
|
||||
if(entityDamageEvent.getEntity() instanceof LivingEntity livingEntity) {
|
||||
|
||||
if(entityDamageEvent.getFinalDamage() >= livingEntity.getHealth()) {
|
||||
//This sets entity names back to whatever they are supposed to be
|
||||
@ -564,9 +548,8 @@ public class EntityListener implements Listener {
|
||||
event.getEntity().removeMetadata(MetadataConstants.METADATA_KEY_EXPLOSION_FROM_RUPTURE, mcMMO.p);
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
if(event.getEntity() instanceof Player player)
|
||||
{
|
||||
Player player = (Player) event.getEntity();
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
@ -605,12 +588,10 @@ public class EntityListener implements Listener {
|
||||
}
|
||||
*/
|
||||
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity)) || !entity.isValid() || !(entity instanceof LivingEntity)) {
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity)) || !entity.isValid() || !(entity instanceof LivingEntity livingEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
|
||||
if (CombatUtils.isInvincible(livingEntity, damage)) {
|
||||
return;
|
||||
}
|
||||
@ -642,13 +623,11 @@ public class EntityListener implements Listener {
|
||||
|
||||
}
|
||||
|
||||
else if (livingEntity instanceof Tameable) {
|
||||
Tameable pet = (Tameable) livingEntity;
|
||||
else if (livingEntity instanceof Tameable pet) {
|
||||
AnimalTamer owner = pet.getOwner();
|
||||
|
||||
if(owner instanceof Player)
|
||||
if(owner instanceof Player player)
|
||||
{
|
||||
Player player = (Player) owner;
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
@ -821,8 +800,7 @@ public class EntityListener implements Listener {
|
||||
father.setLoveModeTicks(0);
|
||||
|
||||
//Inform the player
|
||||
if(event.getBreeder() instanceof Player) {
|
||||
Player player = (Player) event.getBreeder();
|
||||
if(event.getBreeder() instanceof Player player) {
|
||||
NotificationManager.sendPlayerInformationChatOnly(player, "Taming.Summon.COTW.BreedingDisallowed");
|
||||
}
|
||||
}
|
||||
@ -936,12 +914,10 @@ public class EntityListener implements Listener {
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
if (!(entity instanceof Player)) {
|
||||
if (!(entity instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) entity;
|
||||
|
||||
//Profile not loaded
|
||||
if(UserManager.getPlayer(player) == null)
|
||||
{
|
||||
@ -1108,12 +1084,10 @@ public class EntityListener implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
Entity target = event.getTarget();
|
||||
|
||||
if (!(entity instanceof Tameable) || !(target instanceof Player)) {
|
||||
if (!(entity instanceof Tameable tameable) || !(target instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) target;
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
{
|
||||
@ -1121,8 +1095,6 @@ public class EntityListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Tameable tameable = (Tameable) entity;
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player) || !CombatUtils.isFriendlyPet(player, tameable)) {
|
||||
return;
|
||||
}
|
||||
|
@ -105,8 +105,7 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(blockState instanceof Furnace) {
|
||||
Furnace furnace = (Furnace) blockState;
|
||||
if(blockState instanceof Furnace furnace) {
|
||||
OfflinePlayer offlinePlayer = mcMMO.getSmeltingTracker().getFurnaceOwner(furnace);
|
||||
|
||||
if(offlinePlayer != null) {
|
||||
@ -191,7 +190,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
InventoryHolder holder = inventory.getHolder();
|
||||
|
||||
if (!(holder instanceof BrewingStand)) {
|
||||
if (!(holder instanceof BrewingStand stand)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -208,7 +207,6 @@ public class InventoryListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
BrewingStand stand = (BrewingStand) holder;
|
||||
ItemStack clicked = event.getCurrentItem();
|
||||
ItemStack cursor = event.getCursor();
|
||||
|
||||
|
@ -119,9 +119,8 @@ public class PlayerListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntityHighest(EntityDamageByEntityEvent event) {
|
||||
// we only care about players as this is for fixing player death messages
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
if (!(event.getEntity() instanceof Player player))
|
||||
return;
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
// get the attacker
|
||||
LivingEntity attacker;
|
||||
@ -413,9 +412,8 @@ public class PlayerListener implements Listener {
|
||||
{
|
||||
event.setExpToDrop(0);
|
||||
|
||||
if(caught instanceof Item)
|
||||
if(caught instanceof Item caughtItem)
|
||||
{
|
||||
Item caughtItem = (Item) caught;
|
||||
caughtItem.remove();
|
||||
}
|
||||
|
||||
@ -489,9 +487,8 @@ public class PlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getEntity() instanceof Player)
|
||||
if(event.getEntity() instanceof Player player)
|
||||
{
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
/* WORLD GUARD MAIN FLAG CHECK */
|
||||
if(WorldGuardUtils.isWorldGuardLoaded())
|
||||
@ -1013,8 +1010,7 @@ public class PlayerListener implements Listener {
|
||||
* We can check for an instance instead of EntityType here, so we are
|
||||
* ready for the infamous "Glow Item Frame" in 1.17 too!
|
||||
*/
|
||||
if (event.getRightClicked() instanceof ItemFrame) {
|
||||
ItemFrame frame = (ItemFrame) event.getRightClicked();
|
||||
if (event.getRightClicked() instanceof ItemFrame frame) {
|
||||
|
||||
// Check for existing items (ignore rotations)
|
||||
if (frame.getItem().getType() != Material.AIR) {
|
||||
|
@ -256,45 +256,49 @@ public final class LocaleLoader {
|
||||
|
||||
@NotNull
|
||||
private static String getExamples() {
|
||||
return "This.Is.An.Example.Put.Locale.Keys.Here.One=&aExample text using hex color codes\n" +
|
||||
"This.Is.An.Example.Put.Locale.Keys.Here.Two=[[DARK_AQUA]]Example text using our own color codes\n" +
|
||||
"This.Is.An.Example.Put.Locale.Keys.Here.Three=Example text with no colors\n";
|
||||
return """
|
||||
This.Is.An.Example.Put.Locale.Keys.Here.One=&aExample text using hex color codes
|
||||
This.Is.An.Example.Put.Locale.Keys.Here.Two=[[DARK_AQUA]]Example text using our own color codes
|
||||
This.Is.An.Example.Put.Locale.Keys.Here.Three=Example text with no colors
|
||||
""";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getLocaleHelpTextWithoutExamples() {
|
||||
String localeExplanation =
|
||||
"# -- Are you looking to change the language of mcMMO but without editing it yourself? --\n" +
|
||||
"\n" +
|
||||
"# mcMMO has quite a few built in translations, you can choose which translation by editing config.yml with the appropriate locale code. The setting is `General.Locale` in config.yml\n" +
|
||||
"# Odds are, if you speak a popular language on earth we already have a translation for it.\n" +
|
||||
"# However our translations are done by the community, and update infrequently. (Please help us out <3)\n" +
|
||||
"# We would love more people to help update our locales, submit any updated translation file to our GitHub or email it to me at business@neetgames.com\n" +
|
||||
"# For a list of built in translations, view this link: https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# -- Using a built in translation -- \n" +
|
||||
"# Assuming you read the above section, edit config.yml's General.Locale from en_US to the locale code that we support (see the above link), then reboot your server\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# -- Do you want to change the text in mcMMO? Including adding colors? ( Locale Override ) -- \n" +
|
||||
"# First, a brief explanation.\n" +
|
||||
"# Locales are the language files used by mcMMO, they also contain color codes and most of the styling used by mcMMO.\n" +
|
||||
"# You can customize a locale outside of the JAR in version 2.1.51 and up.\n" +
|
||||
"#\n" +
|
||||
"# Locales can be overridden by editing this file\n" +
|
||||
"# You can find the up to date current locale files here https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale\n" +
|
||||
"# The master file is en_US, if a translation is missing entries (as they often are) it will pull from the en_US file https://github.com/mcMMO-Dev/mcMMO/blob/master/src/main/resources/locale/locale_en_US.properties\n" +
|
||||
"#\n" +
|
||||
"# To override a locale, add entries to this file and copy ** only ** the strings you want to replace, otherwise you will not see any updated strings when mcMMO updates and will have to manually change them and read patch notes carefully.\n" +
|
||||
"# If you wish to replace every line in some way, feel free to copy the entire contents of this file, just be advised that you will need to be on top of locale updates in mcMMO and follow our changelog closely.\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
"# WARNING: Locales only support ASCII and UTF16 characters at the moment, so you'll need to run special characters through a UTF16 converter (google it) to get them to work. This will be fixed in the future!\n" +
|
||||
"# FIND KEYS HERE: On our github repo (en_US is our master file and has ALL the keys) -> https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale\n" +
|
||||
"# WARNING: Some keys in our master file are unused, make gratuitous use of Ctrl+F\n" +
|
||||
"# HOW TO APPLY: You can either restart the server for these changes to take effect or run /mcreloadlocale.\n" +
|
||||
"# -- Add Keys Below --\n";
|
||||
"""
|
||||
# -- Are you looking to change the language of mcMMO but without editing it yourself? --
|
||||
|
||||
# mcMMO has quite a few built in translations, you can choose which translation by editing config.yml with the appropriate locale code. The setting is `General.Locale` in config.yml
|
||||
# Odds are, if you speak a popular language on earth we already have a translation for it.
|
||||
# However our translations are done by the community, and update infrequently. (Please help us out <3)
|
||||
# We would love more people to help update our locales, submit any updated translation file to our GitHub or email it to me at business@neetgames.com
|
||||
# For a list of built in translations, view this link: https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale
|
||||
|
||||
|
||||
# -- Using a built in translation --\s
|
||||
# Assuming you read the above section, edit config.yml's General.Locale from en_US to the locale code that we support (see the above link), then reboot your server
|
||||
|
||||
|
||||
# -- Do you want to change the text in mcMMO? Including adding colors? ( Locale Override ) --\s
|
||||
# First, a brief explanation.
|
||||
# Locales are the language files used by mcMMO, they also contain color codes and most of the styling used by mcMMO.
|
||||
# You can customize a locale outside of the JAR in version 2.1.51 and up.
|
||||
#
|
||||
# Locales can be overridden by editing this file
|
||||
# You can find the up to date current locale files here https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale
|
||||
# The master file is en_US, if a translation is missing entries (as they often are) it will pull from the en_US file https://github.com/mcMMO-Dev/mcMMO/blob/master/src/main/resources/locale/locale_en_US.properties
|
||||
#
|
||||
# To override a locale, add entries to this file and copy ** only ** the strings you want to replace, otherwise you will not see any updated strings when mcMMO updates and will have to manually change them and read patch notes carefully.
|
||||
# If you wish to replace every line in some way, feel free to copy the entire contents of this file, just be advised that you will need to be on top of locale updates in mcMMO and follow our changelog closely.
|
||||
|
||||
|
||||
# WARNING: Locales only support ASCII and UTF16 characters at the moment, so you'll need to run special characters through a UTF16 converter (google it) to get them to work. This will be fixed in the future!
|
||||
# FIND KEYS HERE: On our github repo (en_US is our master file and has ALL the keys) -> https://github.com/mcMMO-Dev/mcMMO/tree/master/src/main/resources/locale
|
||||
# WARNING: Some keys in our master file are unused, make gratuitous use of Ctrl+F
|
||||
# HOW TO APPLY: You can either restart the server for these changes to take effect or run /mcreloadlocale.
|
||||
# -- Add Keys Below --
|
||||
""";
|
||||
return localeExplanation;
|
||||
}
|
||||
|
||||
|
@ -381,15 +381,10 @@ public class mcMMO extends JavaPlugin {
|
||||
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
||||
try {
|
||||
ZipLibrary.mcMMOBackup();
|
||||
}
|
||||
catch (IOException e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
catch(NoClassDefFoundError e) {
|
||||
} catch(NoClassDefFoundError e) {
|
||||
getLogger().severe("Backup class not found!");
|
||||
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
||||
}
|
||||
catch (Throwable e) {
|
||||
} catch (Throwable e) {
|
||||
getLogger().severe(e.toString());
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class PlayerProfileLoadingTask extends BukkitRunnable {
|
||||
// Increment attempt counter and try
|
||||
attempt++;
|
||||
|
||||
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, (100 + (attempt * 100)));
|
||||
new PlayerProfileLoadingTask(player, attempt).runTaskLaterAsynchronously(mcMMO.p, (100 + (attempt * 100L)));
|
||||
}
|
||||
|
||||
private class ApplySuccessfulProfile extends BukkitRunnable {
|
||||
|
@ -63,7 +63,7 @@ public class AbilityDisableTask extends BukkitRunnable {
|
||||
SkillUtils.sendSkillMessage(player, NotificationType.SUPER_ABILITY_ALERT_OTHERS, ability.getAbilityPlayerOff());
|
||||
}
|
||||
if(!mcMMO.isServerShutdownExecuted()) {
|
||||
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
|
||||
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLater(mcMMO.p, (long) PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,7 @@ public class DelayedCropReplant extends BukkitRunnable {
|
||||
public DelayedCropReplant(BlockBreakEvent blockBreakEvent, BlockState cropState, int desiredCropAge, boolean wasImmaturePlant) {
|
||||
BlockData cropData = cropState.getBlockData();
|
||||
|
||||
if(cropData instanceof Directional) {
|
||||
Directional cropDir = (Directional) cropData;
|
||||
if(cropData instanceof Directional cropDir) {
|
||||
cropFace = cropDir.getFacing();
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,7 @@ public class AcrobaticsManager extends SkillManager {
|
||||
}
|
||||
|
||||
if (SkillUtils.cooldownExpired(mmoPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
if(attacker instanceof Mob) {
|
||||
Mob mob = (Mob) attacker;
|
||||
if(attacker instanceof Mob mob) {
|
||||
//Check to see how many dodge XP rewards this mob has handed out
|
||||
if(mob.hasMetadata(MetadataConstants.METADATA_KEY_DODGE_TRACKER) && ExperienceConfig.getInstance().isAcrobaticsExploitingPrevented()) {
|
||||
//If Dodge XP has been handed out 5 times then consider it being exploited
|
||||
|
@ -15,12 +15,9 @@ import com.gmail.nossr50.util.random.RandomChanceUtil;
|
||||
import com.gmail.nossr50.util.skills.*;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class AxesManager extends SkillManager {
|
||||
public AxesManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.AXES);
|
||||
@ -93,8 +90,7 @@ public class AxesManager extends SkillManager {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CriticalHit");
|
||||
}
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
if (target instanceof Player defender) {
|
||||
|
||||
if (NotificationManager.doesPlayerUseNotifications(defender)) {
|
||||
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.CritStruck");
|
||||
@ -150,8 +146,7 @@ public class AxesManager extends SkillManager {
|
||||
NotificationManager.sendPlayerInformation(player, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Proc");
|
||||
}
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
if (target instanceof Player defender) {
|
||||
|
||||
if (NotificationManager.doesPlayerUseNotifications(defender)) {
|
||||
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Axes.Combat.GI.Struck");
|
||||
@ -163,11 +158,10 @@ public class AxesManager extends SkillManager {
|
||||
|
||||
/**
|
||||
* Handle the effects of the Skull Splitter ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*/
|
||||
public void skullSplitterCheck(@NotNull LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, modifiers, skill);
|
||||
public void skullSplitterCheck(@NotNull LivingEntity target, double damage) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
|
||||
}
|
||||
}
|
||||
|
@ -88,11 +88,9 @@ public class HerbalismManager extends SkillManager {
|
||||
mmoPlayer.getPlayer().sendMessage("Processing sweet berry bush rewards");
|
||||
}
|
||||
//Check the age
|
||||
if(blockState.getBlockData() instanceof Ageable) {
|
||||
if(blockState.getBlockData() instanceof Ageable ageable) {
|
||||
int rewardByAge = 0;
|
||||
|
||||
Ageable ageable = (Ageable) blockState.getBlockData();
|
||||
|
||||
if(ageable.getAge() == 2) {
|
||||
rewardByAge = 1; //Normal XP
|
||||
} else if(ageable.getAge() == 3) {
|
||||
@ -134,8 +132,7 @@ public class HerbalismManager extends SkillManager {
|
||||
BlockState blockState = block.getState();
|
||||
|
||||
if(blockState.getType().toString().equalsIgnoreCase("sweet_berry_bush")) {
|
||||
if(blockState.getBlockData() instanceof Ageable) {
|
||||
Ageable ageable = (Ageable) blockState.getBlockData();
|
||||
if(blockState.getBlockData() instanceof Ageable ageable) {
|
||||
|
||||
if(ageable.getAge() <= 1) {
|
||||
applyXpGain(xpReward, XPGainReason.PVE, XPGainSource.SELF);
|
||||
@ -351,8 +348,7 @@ public class HerbalismManager extends SkillManager {
|
||||
*/
|
||||
|
||||
//Not all things that are natural should give double drops, make sure its fully mature as well
|
||||
if(plantData instanceof Ageable) {
|
||||
Ageable ageable = (Ageable) plantData;
|
||||
if(plantData instanceof Ageable ageable) {
|
||||
|
||||
if(isAgeableMature(ageable) || isBizarreAgeable(plantData)) {
|
||||
if(checkDoubleDrop(brokenPlantState)) {
|
||||
@ -447,8 +443,7 @@ public class HerbalismManager extends SkillManager {
|
||||
*/
|
||||
|
||||
//Calculate XP
|
||||
if(plantData instanceof Ageable) {
|
||||
Ageable plantAgeable = (Ageable) plantData;
|
||||
if(plantData instanceof Ageable plantAgeable) {
|
||||
|
||||
if(isAgeableMature(plantAgeable) || isBizarreAgeable(plantData)) {
|
||||
xpToReward += ExperienceConfig.getInstance().getXp(PrimarySkillType.HERBALISM, brokenBlockNewState.getType());
|
||||
@ -764,12 +759,10 @@ public class HerbalismManager extends SkillManager {
|
||||
|
||||
BlockData blockData = blockState.getBlockData();
|
||||
|
||||
if (!(blockData instanceof Ageable)) {
|
||||
if (!(blockData instanceof Ageable ageable)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Ageable ageable = (Ageable) blockData;
|
||||
|
||||
//If the ageable is NOT mature and the player is NOT using a hoe, abort
|
||||
|
||||
Player player = getPlayer();
|
||||
|
@ -8,7 +8,6 @@ import com.gmail.nossr50.util.skills.RankUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
|
||||
public class BlastMining {
|
||||
// The order of the values is extremely important, a few methods depend on it to work properly
|
||||
@ -114,7 +113,7 @@ public class BlastMining {
|
||||
return false;
|
||||
}
|
||||
|
||||
event.setDamage(DamageModifier.BASE, miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||
event.setDamage(miningManager.processDemolitionsExpertise(event.getDamage()));
|
||||
|
||||
if (event.getFinalDamage() == 0) {
|
||||
event.setCancelled(true);
|
||||
|
@ -130,7 +130,7 @@ public class MiningManager extends SkillManager {
|
||||
|
||||
mmoPlayer.setAbilityDATS(SuperAbilityType.BLAST_MINING, System.currentTimeMillis());
|
||||
mmoPlayer.setAbilityInformed(SuperAbilityType.BLAST_MINING, false);
|
||||
new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
|
||||
new AbilityCooldownTask(mmoPlayer, SuperAbilityType.BLAST_MINING).runTaskLater(mcMMO.p, (long) SuperAbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,12 +21,9 @@ import com.gmail.nossr50.util.skills.SkillActivationType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class SwordsManager extends SkillManager {
|
||||
public SwordsManager(McMMOPlayer mcMMOPlayer) {
|
||||
super(mcMMOPlayer, PrimarySkillType.SWORDS);
|
||||
@ -81,8 +78,7 @@ public class SwordsManager extends SkillManager {
|
||||
|
||||
if (RandomChanceUtil.rollDice(mcMMO.p.getAdvancedConfig().getRuptureChanceToApplyOnHit(getRuptureRank()), 100)) {
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
if (target instanceof Player defender) {
|
||||
|
||||
//Don't start or add to a bleed if they are blocking
|
||||
if(defender.isBlocking())
|
||||
@ -158,11 +154,10 @@ public class SwordsManager extends SkillManager {
|
||||
|
||||
/**
|
||||
* Handle the effects of the Serrated Strikes ability
|
||||
*
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param target The {@link LivingEntity} being affected by the ability
|
||||
* @param damage The amount of damage initially dealt by the event
|
||||
*/
|
||||
public void serratedStrikes(@NotNull LivingEntity target, double damage, Map<DamageModifier, Double> modifiers) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, modifiers, skill);
|
||||
public void serratedStrikes(@NotNull LivingEntity target, double damage) {
|
||||
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
|
||||
}
|
||||
}
|
||||
|
@ -240,8 +240,7 @@ public class TamingManager extends SkillManager {
|
||||
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", target.getHealth(), target.getMaxHealth()));
|
||||
|
||||
// Bred mules & donkeys can actually have horse-like stats, but llamas cannot.
|
||||
if (beast instanceof AbstractHorse && !(beast instanceof Llama)) {
|
||||
AbstractHorse horseLikeCreature = (AbstractHorse) beast;
|
||||
if (beast instanceof AbstractHorse horseLikeCreature && !(beast instanceof Llama)) {
|
||||
AttributeInstance jumpAttribute = horseLikeCreature.getAttribute(Attribute.HORSE_JUMP_STRENGTH);
|
||||
|
||||
if(jumpAttribute != null) {
|
||||
@ -277,8 +276,7 @@ public class TamingManager extends SkillManager {
|
||||
ParticleEffectUtils.playGreaterImpactEffect(target);
|
||||
target.setVelocity(wolf.getLocation().getDirection().normalize().multiply(1.5D));
|
||||
|
||||
if (target instanceof Player) {
|
||||
Player defender = (Player) target;
|
||||
if (target instanceof Player defender) {
|
||||
|
||||
if (NotificationManager.doesPlayerUseNotifications(defender)) {
|
||||
NotificationManager.sendPlayerInformation(defender, NotificationType.SUBSKILL_MESSAGE, "Taming.SubSkill.Pummel.TargetMessage");
|
||||
@ -287,9 +285,8 @@ public class TamingManager extends SkillManager {
|
||||
}
|
||||
|
||||
public void attackTarget(LivingEntity target) {
|
||||
if(target instanceof Tameable)
|
||||
if(target instanceof Tameable tameable)
|
||||
{
|
||||
Tameable tameable = (Tameable) target;
|
||||
if(tameable.getOwner() == getPlayer())
|
||||
{
|
||||
return;
|
||||
|
@ -290,8 +290,7 @@ public final class BlockUtils {
|
||||
if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE) {
|
||||
return true;
|
||||
}
|
||||
if (data instanceof Ageable) {
|
||||
Ageable ageable = (Ageable) data;
|
||||
if (data instanceof Ageable ageable) {
|
||||
return ageable.getAge() == ageable.getMaximumAge();
|
||||
}
|
||||
return true;
|
||||
|
@ -130,12 +130,10 @@ public final class EventUtils {
|
||||
if(Misc.isNPCEntityExcludingVillagers(entity))
|
||||
return false;
|
||||
|
||||
if (!entity.isValid() || !(entity instanceof LivingEntity)) {
|
||||
if (!entity.isValid() || !(entity instanceof LivingEntity livingEntity)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
|
||||
if (CombatUtils.isInvincible(livingEntity, damage)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public final class MobHealthbarUtils {
|
||||
target.setMetadata(MetadataConstants.METADATA_KEY_NAME_VISIBILITY, new FixedMetadataValue(mcMMO.p, false));
|
||||
}
|
||||
|
||||
new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
|
||||
new MobHealthDisplayUpdaterTask(target).runTaskLater(mcMMO.p, (long) displayTime * Misc.TICK_CONVERSION_FACTOR); // Clear health display after 3 seconds
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ public class TransientEntityTracker {
|
||||
* @param playerUUID player to register
|
||||
*/
|
||||
private synchronized void registerPlayer(@NotNull UUID playerUUID) {
|
||||
getPerPlayerTransientEntityMap().put(playerUUID, new HashMap<CallOfTheWildType, HashSet<TrackedTamingEntity>>());
|
||||
getPerPlayerTransientEntityMap().put(playerUUID, new HashMap<>());
|
||||
|
||||
for(CallOfTheWildType callOfTheWildType : CallOfTheWildType.values()) {
|
||||
getPerPlayerTransientEntityMap().get(playerUUID).put(callOfTheWildType, new HashSet<>());
|
||||
|
@ -132,7 +132,7 @@ public class McMMOSimpleRegionFile {
|
||||
int oldSegmentIndex = chunkSegmentIndex[index]; // Get current segment index
|
||||
markChunkSegments(index, false); // Clear our old segments
|
||||
int newSegmentIndex = findContiguousSegments(oldSegmentIndex, size); // Find contiguous segments to save to
|
||||
file.seek(newSegmentIndex << segmentExponent); // Seek to file location
|
||||
file.seek((long) newSegmentIndex << segmentExponent); // Seek to file location
|
||||
file.write(buffer, 0, size); // Write data
|
||||
// update in memory info
|
||||
chunkSegmentIndex[index] = newSegmentIndex;
|
||||
@ -141,9 +141,9 @@ public class McMMOSimpleRegionFile {
|
||||
// Mark segments in use
|
||||
markChunkSegments(index, true);
|
||||
// Update header info
|
||||
file.seek(SEEK_CHUNK_SEGMENT_INDICES + (4 * index));
|
||||
file.seek(SEEK_CHUNK_SEGMENT_INDICES + (4L * index));
|
||||
file.writeInt(chunkSegmentIndex[index]);
|
||||
file.seek(SEEK_CHUNK_BYTE_LENGTHS + (4 * index));
|
||||
file.seek(SEEK_CHUNK_BYTE_LENGTHS + (4L * index));
|
||||
file.writeInt(chunkNumBytes[index]);
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ public class McMMOSimpleRegionFile {
|
||||
|
||||
byte[] data = new byte[byteLength];
|
||||
|
||||
file.seek(chunkSegmentIndex[index] << segmentExponent); // Seek to file location
|
||||
file.seek((long) chunkSegmentIndex[index] << segmentExponent); // Seek to file location
|
||||
file.readFully(data); // Read in the data
|
||||
return new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)));
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class ExperienceBarManager {
|
||||
return;
|
||||
|
||||
ExperienceBarHideTask experienceBarHideTask = new ExperienceBarHideTask(this, mcMMOPlayer, primarySkillType);
|
||||
experienceBarHideTask.runTaskLater(plugin, 20* delaySeconds);
|
||||
experienceBarHideTask.runTaskLater(plugin, 20L * delaySeconds);
|
||||
experienceBarHideTaskHashMap.put(primarySkillType, experienceBarHideTask);
|
||||
}
|
||||
|
||||
|
@ -32,11 +32,7 @@ public abstract class MajorMinorPatchVersion implements Versioned {
|
||||
this.majorVersion = majorVersion;
|
||||
this.minorVersion = minorVersion;
|
||||
|
||||
if(patchVersion == null) {
|
||||
this.patchVersion = new SimpleNumericVersion(0);
|
||||
} else {
|
||||
this.patchVersion = patchVersion;
|
||||
}
|
||||
this.patchVersion = Objects.requireNonNullElseGet(patchVersion, () -> new SimpleNumericVersion(0));
|
||||
}
|
||||
|
||||
public MajorMinorPatchVersion(int majorVerNumber, int minorVerNumber, int patchVerNumber) {
|
||||
|
@ -8,7 +8,6 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.metadata.MobMetaFlagType;
|
||||
import com.gmail.nossr50.metadata.MobMetadataService;
|
||||
@ -23,7 +22,6 @@ import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.util.*;
|
||||
import com.gmail.nossr50.util.player.NotificationManager;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -33,7 +31,6 @@ import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@ -41,10 +38,7 @@ import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CombatUtils {
|
||||
|
||||
@ -56,14 +50,10 @@ public final class CombatUtils {
|
||||
|
||||
//Likely.. because who knows what plugins are throwing around
|
||||
public static boolean isDamageLikelyFromNormalCombat(@NotNull DamageCause damageCause) {
|
||||
switch (damageCause) {
|
||||
case ENTITY_ATTACK:
|
||||
case ENTITY_SWEEP_ATTACK:
|
||||
case PROJECTILE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return switch (damageCause) {
|
||||
case ENTITY_ATTACK, ENTITY_SWEEP_ATTACK, PROJECTILE -> true;
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
|
||||
public static boolean hasWeakenedDamage(@NotNull LivingEntity livingEntity) {
|
||||
@ -83,10 +73,7 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
|
||||
double initialDamage = event.getDamage();
|
||||
double finalDamage = initialDamage;
|
||||
|
||||
Map<DamageModifier, Double> modifiers = getModifiers(event);
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
if (swordsManager.canActivateAbility()) {
|
||||
mcMMOPlayer.checkAbilityActivation(PrimarySkillType.SWORDS);
|
||||
@ -99,19 +86,19 @@ public final class CombatUtils {
|
||||
//Add Stab Damage
|
||||
if(swordsManager.canUseStab())
|
||||
{
|
||||
finalDamage+=(swordsManager.getStabDamage() * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage += (swordsManager.getStabDamage() * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
if (swordsManager.canUseSerratedStrike()) {
|
||||
swordsManager.serratedStrikes(target, initialDamage, modifiers);
|
||||
swordsManager.serratedStrikes(target, event.getDamage());
|
||||
}
|
||||
|
||||
if(canUseLimitBreak(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=(getLimitBreakDamage(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage += (getLimitBreakDamage(player, target, SubSkillType.SWORDS_SWORDS_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
event.setDamage(boostedDamage);
|
||||
processCombatXP(mcMMOPlayer, target, PrimarySkillType.SWORDS);
|
||||
|
||||
printFinalDamageDebug(player, event, mcMMOPlayer);
|
||||
@ -133,10 +120,8 @@ public final class CombatUtils {
|
||||
if (event.getCause() == DamageCause.THORNS) {
|
||||
return;
|
||||
}
|
||||
|
||||
double initialDamage = event.getDamage();
|
||||
double finalDamage = initialDamage;
|
||||
Map<DamageModifier, Double> modifiers = getModifiers(event);
|
||||
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
@ -152,30 +137,30 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (axesManager.canUseAxeMastery()) {
|
||||
finalDamage+=axesManager.axeMastery();
|
||||
boostedDamage+=axesManager.axeMastery();
|
||||
}
|
||||
|
||||
if (axesManager.canImpact(target)) {
|
||||
axesManager.impactCheck(target);
|
||||
}
|
||||
else if (axesManager.canGreaterImpact(target)) {
|
||||
finalDamage+=axesManager.greaterImpact(target);
|
||||
boostedDamage+=axesManager.greaterImpact(target);
|
||||
}
|
||||
|
||||
if (axesManager.canUseSkullSplitter(target)) {
|
||||
axesManager.skullSplitterCheck(target, initialDamage, modifiers);
|
||||
axesManager.skullSplitterCheck(target, event.getDamage());
|
||||
}
|
||||
|
||||
if (axesManager.canCriticalHit(target)) {
|
||||
finalDamage+=(axesManager.criticalHit(target, finalDamage) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage+=(axesManager.criticalHit(target, boostedDamage) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
if(canUseLimitBreak(player, target, SubSkillType.AXES_AXES_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=(getLimitBreakDamage(player, target, SubSkillType.AXES_AXES_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage+=(getLimitBreakDamage(player, target, SubSkillType.AXES_AXES_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
event.setDamage(boostedDamage);
|
||||
processCombatXP(mcMMOPlayer, target, PrimarySkillType.AXES);
|
||||
|
||||
printFinalDamageDebug(player, event, mcMMOPlayer);
|
||||
@ -186,8 +171,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
double initialDamage = event.getDamage();
|
||||
double finalDamage = initialDamage;
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
|
||||
@ -203,11 +187,11 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
if (unarmedManager.canUseSteelArm()) {
|
||||
finalDamage+=(unarmedManager.calculateSteelArmStyleDamage() * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage+=(unarmedManager.calculateSteelArmStyleDamage() * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
if (unarmedManager.canUseBerserk()) {
|
||||
finalDamage+=(unarmedManager.berserkDamage(finalDamage) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage+=(unarmedManager.berserkDamage(boostedDamage) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
if (unarmedManager.canDisarm(target)) {
|
||||
@ -216,10 +200,10 @@ public final class CombatUtils {
|
||||
|
||||
if(canUseLimitBreak(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=(getLimitBreakDamage(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
boostedDamage+=(getLimitBreakDamage(player, target, SubSkillType.UNARMED_UNARMED_LIMIT_BREAK) * mcMMOPlayer.getAttackStrength());
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
event.setDamage(boostedDamage);
|
||||
processCombatXP(mcMMOPlayer, target, PrimarySkillType.UNARMED);
|
||||
|
||||
printFinalDamageDebug(player, event, mcMMOPlayer);
|
||||
@ -227,7 +211,7 @@ public final class CombatUtils {
|
||||
|
||||
private static void processTamingCombat(@NotNull LivingEntity target, @Nullable Player master, @NotNull Wolf wolf, @NotNull EntityDamageByEntityEvent event) {
|
||||
double initialDamage = event.getDamage();
|
||||
double finalDamage = initialDamage;
|
||||
double boostedDamage = initialDamage;
|
||||
|
||||
if(master != null && master.isOnline() && master.isValid()) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(master);
|
||||
@ -246,14 +230,14 @@ public final class CombatUtils {
|
||||
tamingManager.pummel(target, wolf);
|
||||
|
||||
if (tamingManager.canUseSharpenedClaws()) {
|
||||
finalDamage+=tamingManager.sharpenedClaws();
|
||||
boostedDamage+=tamingManager.sharpenedClaws();
|
||||
}
|
||||
|
||||
if (tamingManager.canUseGore()) {
|
||||
finalDamage+=tamingManager.gore(target, initialDamage);
|
||||
boostedDamage+=tamingManager.gore(target, initialDamage);
|
||||
}
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
event.setDamage(boostedDamage);
|
||||
processCombatXP(mcMMOPlayer, target, PrimarySkillType.TAMING, 3);
|
||||
}
|
||||
|
||||
@ -272,15 +256,15 @@ public final class CombatUtils {
|
||||
|
||||
ArcheryManager archeryManager = mcMMOPlayer.getArcheryManager();
|
||||
|
||||
double finalDamage = event.getDamage();
|
||||
double boostedDamage = event.getDamage();
|
||||
|
||||
if (archeryManager.canSkillShot()) {
|
||||
//Not Additive
|
||||
finalDamage = archeryManager.skillShot(initialDamage);
|
||||
boostedDamage = archeryManager.skillShot(initialDamage);
|
||||
}
|
||||
|
||||
if (archeryManager.canDaze(target)) {
|
||||
finalDamage+=archeryManager.daze((Player) target); //the cast is checked by the if condition
|
||||
boostedDamage+=archeryManager.daze((Player) target); //the cast is checked by the if condition
|
||||
}
|
||||
|
||||
if (!arrow.hasMetadata(MetadataConstants.METADATA_KEY_INF_ARROW) && archeryManager.canRetrieveArrows()) {
|
||||
@ -289,7 +273,7 @@ public final class CombatUtils {
|
||||
|
||||
if(canUseLimitBreak(player, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK))
|
||||
{
|
||||
finalDamage+=getLimitBreakDamage(player, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
|
||||
boostedDamage+=getLimitBreakDamage(player, target, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK);
|
||||
}
|
||||
|
||||
double distanceMultiplier = archeryManager.distanceXpBonusMultiplier(target, arrow);
|
||||
@ -298,15 +282,14 @@ public final class CombatUtils {
|
||||
if(arrow.hasMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE))
|
||||
forceMultiplier = arrow.getMetadata(MetadataConstants.METADATA_KEY_BOW_FORCE).get(0).asDouble();
|
||||
|
||||
applyScaledModifiers(initialDamage, finalDamage, event);
|
||||
|
||||
event.setDamage(boostedDamage);
|
||||
processCombatXP(mcMMOPlayer, target, PrimarySkillType.ARCHERY, forceMultiplier * distanceMultiplier);
|
||||
|
||||
printFinalDamageDebug(player, event, mcMMOPlayer,
|
||||
"Distance Multiplier: "+distanceMultiplier,
|
||||
"Force Multiplier: "+forceMultiplier,
|
||||
"Initial Damage: "+initialDamage,
|
||||
"Final Damage: "+finalDamage);
|
||||
"Final Damage: "+boostedDamage);
|
||||
//Clean data
|
||||
cleanupArrowMetadata(arrow);
|
||||
}
|
||||
@ -351,8 +334,7 @@ public final class CombatUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if (painSourceRoot instanceof Player && entityType == EntityType.PLAYER) {
|
||||
Player player = (Player) painSourceRoot;
|
||||
if (painSourceRoot instanceof Player player && entityType == EntityType.PLAYER) {
|
||||
|
||||
if (!UserManager.hasPlayerDataKey(player)) {
|
||||
return;
|
||||
@ -410,8 +392,7 @@ public final class CombatUtils {
|
||||
Wolf wolf = (Wolf) painSource;
|
||||
AnimalTamer tamer = wolf.getOwner();
|
||||
|
||||
if (tamer instanceof Player && mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TAMING, target)) {
|
||||
Player master = (Player) tamer;
|
||||
if (tamer instanceof Player master && mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.TAMING, target)) {
|
||||
|
||||
if (!Misc.isNPCEntityExcludingVillagers(master) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(master, PrimarySkillType.TAMING)) {
|
||||
processTamingCombat(target, master, wolf, event);
|
||||
@ -422,8 +403,7 @@ public final class CombatUtils {
|
||||
Projectile arrow = (Projectile) painSource;
|
||||
ProjectileSource projectileSource = arrow.getShooter();
|
||||
|
||||
if (projectileSource instanceof Player && mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ARCHERY, target)) {
|
||||
Player player = (Player) projectileSource;
|
||||
if (projectileSource instanceof Player player && mcMMO.p.getSkillTools().canCombatSkillsTrigger(PrimarySkillType.ARCHERY, target)) {
|
||||
|
||||
if (!Misc.isNPCEntityExcludingVillagers(player) && mcMMO.p.getSkillTools().doesPlayerHaveSkillPermission(player, PrimarySkillType.ARCHERY)) {
|
||||
processArcheryCombat(target, player, event, arrow);
|
||||
@ -472,8 +452,7 @@ public final class CombatUtils {
|
||||
* @return the RAW damage bonus from Limit Break which is applied before reductions
|
||||
*/
|
||||
public static int getLimitBreakDamage(@NotNull Player attacker, @NotNull LivingEntity defender, @NotNull SubSkillType subSkillType) {
|
||||
if(defender instanceof Player) {
|
||||
Player playerDefender = (Player) defender;
|
||||
if(defender instanceof Player playerDefender) {
|
||||
return getLimitBreakDamageAgainstQuality(attacker, subSkillType, getArmorQualityLevel(playerDefender));
|
||||
} else {
|
||||
return getLimitBreakDamageAgainstQuality(attacker, subSkillType, 1000);
|
||||
@ -683,13 +662,12 @@ public final class CombatUtils {
|
||||
|
||||
/**
|
||||
* Apply Area-of-Effect ability actions.
|
||||
*
|
||||
* @param attacker The attacking player
|
||||
* @param attacker The attacking player
|
||||
* @param target The defending entity
|
||||
* @param damage The initial damage amount
|
||||
* @param type The type of skill being used
|
||||
*/
|
||||
public static void applyAbilityAoE(@NotNull Player attacker, @NotNull LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, @NotNull PrimarySkillType type) {
|
||||
public static void applyAbilityAoE(@NotNull Player attacker, @NotNull LivingEntity target, double damage, @NotNull PrimarySkillType type) {
|
||||
int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit
|
||||
double damageAmount = Math.max(damage, 1);
|
||||
|
||||
@ -698,11 +676,11 @@ public final class CombatUtils {
|
||||
break;
|
||||
}
|
||||
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity)) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
|
||||
if ((ExperienceConfig.getInstance().isNPCInteractionPrevented() && Misc.isNPCEntityExcludingVillagers(entity))
|
||||
|| !(entity instanceof LivingEntity livingEntity) || !shouldBeAffected(attacker, entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LivingEntity livingEntity = (LivingEntity) entity;
|
||||
EventUtils.callFakeArmSwingEvent(attacker);
|
||||
|
||||
switch (type) {
|
||||
@ -711,7 +689,12 @@ public final class CombatUtils {
|
||||
NotificationManager.sendPlayerInformation((Player)entity, NotificationType.SUBSKILL_MESSAGE, "Swords.Combat.SS.Struck");
|
||||
}
|
||||
|
||||
UserManager.getPlayer(attacker).getSwordsManager().processRupture(livingEntity);
|
||||
McMMOPlayer mmoAttacker = UserManager.getPlayer(attacker);
|
||||
|
||||
if(mmoAttacker != null) {
|
||||
mmoAttacker.getSwordsManager().processRupture(livingEntity);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AXES:
|
||||
@ -753,13 +736,12 @@ public final class CombatUtils {
|
||||
double baseXP = 0;
|
||||
XPGainReason xpGainReason;
|
||||
|
||||
if (target instanceof Player) {
|
||||
if (target instanceof Player defender) {
|
||||
if (!ExperienceConfig.getInstance().getExperienceGainsPlayerVersusPlayerEnabled() || PartyManager.inSameParty(mcMMOPlayer.getPlayer(), (Player) target)) {
|
||||
return;
|
||||
}
|
||||
|
||||
xpGainReason = XPGainReason.PVP;
|
||||
Player defender = (Player) target;
|
||||
|
||||
if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) {
|
||||
baseXP = 20 * ExperienceConfig.getInstance().getPlayerVersusPlayerXP();
|
||||
@ -833,9 +815,7 @@ public final class CombatUtils {
|
||||
* @return true if the Entity should be damaged, false otherwise.
|
||||
*/
|
||||
private static boolean shouldBeAffected(@NotNull Player player, @NotNull Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
Player defender = (Player) entity;
|
||||
|
||||
if (entity instanceof Player defender) {
|
||||
//TODO: NPC Interaction?
|
||||
if(UserManager.getPlayer(defender) == null)
|
||||
return true;
|
||||
@ -854,16 +834,8 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
// Spectators should not be affected
|
||||
if (defender.getGameMode() == GameMode.SPECTATOR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
|
||||
return getFakeDamageFinalResult(player, entity, 1.0) != 0;
|
||||
}
|
||||
else if (entity instanceof Tameable) {
|
||||
Tameable tameableEntity = (Tameable) entity;
|
||||
|
||||
return defender.getGameMode() != GameMode.SPECTATOR;
|
||||
} else if (entity instanceof Tameable tameableEntity) {
|
||||
if (isFriendlyPet(player, tameableEntity)) {
|
||||
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
|
||||
// So we can make some assumptions here, about our casting and our check
|
||||
@ -901,8 +873,7 @@ public final class CombatUtils {
|
||||
if (pet.isTamed()) {
|
||||
AnimalTamer tamer = pet.getOwner();
|
||||
|
||||
if (tamer instanceof Player) {
|
||||
Player owner = (Player) tamer;
|
||||
if (tamer instanceof Player owner) {
|
||||
|
||||
return (owner == attacker || PartyManager.inSameParty(attacker, owner) || PartyManager.areAllies(attacker, owner));
|
||||
}
|
||||
@ -911,99 +882,13 @@ public final class CombatUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static double getFakeDamageFinalResult(@Nullable Entity attacker, @NotNull Entity target, double damage) {
|
||||
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static double getFakeDamageFinalResult(@Nullable Entity attacker, @NotNull Entity target, @NotNull DamageCause damageCause, double damage) {
|
||||
EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage);
|
||||
|
||||
if (damageEvent.isCancelled()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return damageEvent.getFinalDamage();
|
||||
}
|
||||
|
||||
public static boolean canDamage(@NotNull Entity attacker, @NotNull Entity target, @NotNull DamageCause damageCause, double damage) {
|
||||
EntityDamageEvent damageEvent = sendEntityDamageEvent(attacker, target, damageCause, damage);
|
||||
EntityDamageEvent damageEvent = new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
||||
|
||||
return !damageEvent.isCancelled();
|
||||
}
|
||||
|
||||
public static @NotNull EntityDamageEvent sendEntityDamageEvent(@Nullable Entity attacker, @NotNull Entity target, @NotNull DamageCause damageCause, double damage) {
|
||||
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, damageCause, damage) : new FakeEntityDamageByEntityEvent(attacker, target, damageCause, damage);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
||||
return damageEvent;
|
||||
}
|
||||
|
||||
public static double getFakeDamageFinalResult(@Nullable Entity attacker, @NotNull Entity target, @NotNull Map<DamageModifier, Double> modifiers) {
|
||||
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, modifiers);
|
||||
}
|
||||
|
||||
public static double getFakeDamageFinalResult(@Nullable Entity attacker, @NotNull Entity target, double damage, @NotNull Map<DamageModifier, Double> modifiers) {
|
||||
return getFakeDamageFinalResult(attacker, target, DamageCause.ENTITY_ATTACK, getScaledModifiers(damage, modifiers));
|
||||
}
|
||||
|
||||
public static double getFakeDamageFinalResult(@Nullable Entity attacker, @NotNull Entity target, @NotNull DamageCause cause, @NotNull Map<DamageModifier, Double> modifiers) {
|
||||
EntityDamageEvent damageEvent = attacker == null ? new FakeEntityDamageEvent(target, cause, modifiers) : new FakeEntityDamageByEntityEvent(attacker, target, cause, modifiers);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(damageEvent);
|
||||
|
||||
if (damageEvent.isCancelled()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return damageEvent.getFinalDamage();
|
||||
}
|
||||
|
||||
private static @NotNull Map<DamageModifier, Double> getModifiers(@NotNull EntityDamageEvent event) {
|
||||
Map<DamageModifier, Double> modifiers = new HashMap<>();
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
modifiers.put(modifier, event.getDamage(modifier));
|
||||
}
|
||||
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
private static @NotNull Map<DamageModifier, Double> getScaledModifiers(double damage, @NotNull Map<DamageModifier, Double> modifiers) {
|
||||
Map<DamageModifier, Double> scaledModifiers = new HashMap<>();
|
||||
|
||||
for (DamageModifier modifier : modifiers.keySet()) {
|
||||
if (modifier == DamageModifier.BASE) {
|
||||
scaledModifiers.put(modifier, damage);
|
||||
continue;
|
||||
}
|
||||
|
||||
scaledModifiers.put(modifier, damage * modifiers.get(modifier));
|
||||
}
|
||||
|
||||
return scaledModifiers;
|
||||
}
|
||||
|
||||
public static @NotNull EntityDamageByEntityEvent applyScaledModifiers(double initialDamage, double finalDamage, @NotNull EntityDamageByEntityEvent event) {
|
||||
// No additional damage
|
||||
if (initialDamage == finalDamage) {
|
||||
return event;
|
||||
}
|
||||
|
||||
for (DamageModifier modifier : DamageModifier.values()) {
|
||||
if (!event.isApplicable(modifier)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (modifier == DamageModifier.BASE) {
|
||||
event.setDamage(modifier, finalDamage);
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setDamage(modifier, finalDamage / initialDamage * event.getDamage(modifier));
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the upgrade tier of the item in hand.
|
||||
*
|
||||
@ -1038,12 +923,10 @@ public final class CombatUtils {
|
||||
}
|
||||
|
||||
public static void handleHealthbars(@NotNull Entity attacker, @NotNull LivingEntity target, double damage, @NotNull mcMMO plugin) {
|
||||
if (!(attacker instanceof Player)) {
|
||||
if (!(attacker instanceof Player player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = (Player) attacker;
|
||||
|
||||
if (Misc.isNPCEntityExcludingVillagers(player) || Misc.isNPCEntityExcludingVillagers(target)) {
|
||||
return;
|
||||
}
|
||||
@ -1089,6 +972,6 @@ public final class CombatUtils {
|
||||
* @param entity the projectile
|
||||
*/
|
||||
public static void delayArrowMetaCleanup(@NotNull Projectile entity) {
|
||||
Bukkit.getServer().getScheduler().runTaskLater(mcMMO.p, () -> { cleanupArrowMetadata(entity);}, 20*60);
|
||||
Bukkit.getServer().getScheduler().runTaskLater(mcMMO.p, () -> cleanupArrowMetadata(entity), 20*60);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class RankUtils {
|
||||
{
|
||||
SkillUnlockNotificationTask skillUnlockNotificationTask = new SkillUnlockNotificationTask(mcMMOPlayer, subSkillType, newLevel);
|
||||
|
||||
skillUnlockNotificationTask.runTaskLater(plugin, (count * 100));
|
||||
skillUnlockNotificationTask.runTaskLater(plugin, (count * 100L));
|
||||
|
||||
count++;
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class SkillTools {
|
||||
/*
|
||||
* Setup subskill -> parent relationship map
|
||||
*/
|
||||
EnumMap<SubSkillType, PrimarySkillType> tempSubParentMap = new EnumMap<SubSkillType, PrimarySkillType>(SubSkillType.class);
|
||||
EnumMap<SubSkillType, PrimarySkillType> tempSubParentMap = new EnumMap<>(SubSkillType.class);
|
||||
|
||||
//Super hacky and disgusting
|
||||
for(PrimarySkillType primarySkillType1 : PrimarySkillType.values()) {
|
||||
@ -78,7 +78,7 @@ public class SkillTools {
|
||||
* Setup primary -> (collection) subskill map
|
||||
*/
|
||||
|
||||
EnumMap<PrimarySkillType, Set<SubSkillType>> tempPrimaryChildMap = new EnumMap<PrimarySkillType, Set<SubSkillType>>(PrimarySkillType.class);
|
||||
EnumMap<PrimarySkillType, Set<SubSkillType>> tempPrimaryChildMap = new EnumMap<>(PrimarySkillType.class);
|
||||
|
||||
//Init the empty Hash Sets
|
||||
for(PrimarySkillType primarySkillType1 : PrimarySkillType.values()) {
|
||||
@ -98,7 +98,7 @@ public class SkillTools {
|
||||
/*
|
||||
* Setup primary -> tooltype map
|
||||
*/
|
||||
EnumMap<PrimarySkillType, ToolType> tempToolMap = new EnumMap<PrimarySkillType, ToolType>(PrimarySkillType.class);
|
||||
EnumMap<PrimarySkillType, ToolType> tempToolMap = new EnumMap<>(PrimarySkillType.class);
|
||||
|
||||
tempToolMap.put(PrimarySkillType.AXES, ToolType.AXE);
|
||||
tempToolMap.put(PrimarySkillType.WOODCUTTING, ToolType.AXE);
|
||||
@ -115,8 +115,8 @@ public class SkillTools {
|
||||
* Setup primary -> ability map
|
||||
*/
|
||||
|
||||
EnumMap<SuperAbilityType, PrimarySkillType> tempAbilityParentRelationshipMap = new EnumMap<SuperAbilityType, PrimarySkillType>(SuperAbilityType.class);
|
||||
EnumMap<PrimarySkillType, SuperAbilityType> tempMainActivatedAbilityChildMap = new EnumMap<PrimarySkillType, SuperAbilityType>(PrimarySkillType.class);
|
||||
EnumMap<SuperAbilityType, PrimarySkillType> tempAbilityParentRelationshipMap = new EnumMap<>(SuperAbilityType.class);
|
||||
EnumMap<PrimarySkillType, SuperAbilityType> tempMainActivatedAbilityChildMap = new EnumMap<>(PrimarySkillType.class);
|
||||
|
||||
for(SuperAbilityType superAbilityType : SuperAbilityType.values()) {
|
||||
try {
|
||||
|
@ -109,8 +109,7 @@ public class StringUtils {
|
||||
case CARROTS:
|
||||
case POTATOES:
|
||||
case NETHER_WART: {
|
||||
if (data instanceof Ageable) {
|
||||
Ageable ageData = (Ageable) data;
|
||||
if (data instanceof Ageable ageData) {
|
||||
if (ageData.getAge() == ageData.getMaximumAge()) {
|
||||
return getPrettyItemString(data.getMaterial()).replace(" ", "_") + "_Ripe";
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ class MinecraftGameVersionTest {
|
||||
|
||||
try (MockedStatic<Bukkit> bukkit = Mockito.mockStatic(Bukkit.class)) {
|
||||
// Inject our own Bukkit versions
|
||||
bukkit.when(() -> Bukkit.getVersion()).thenReturn(serverSoftwareVersion);
|
||||
bukkit.when(() -> Bukkit.getBukkitVersion()).thenReturn(gameVersion);
|
||||
bukkit.when(Bukkit::getVersion).thenReturn(serverSoftwareVersion);
|
||||
bukkit.when(Bukkit::getBukkitVersion).thenReturn(gameVersion);
|
||||
|
||||
PlatformManager manager = new PlatformManager();
|
||||
Platform platform = manager.getPlatform();
|
||||
|
Loading…
Reference in New Issue
Block a user