Return type McMMOPlayer from UserManager

This commit is contained in:
nossr50 2021-03-04 14:53:21 -08:00
parent 7c270feacb
commit a379b90c46
2 changed files with 10 additions and 9 deletions

View File

@ -5,6 +5,8 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.WorldBlacklist;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.meta.ProjectileOriginMeta;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.neetgames.mcmmo.player.MMOPlayer;
import com.neetgames.mcmmo.player.OnlineMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
@ -218,13 +220,12 @@ public class EntityListener implements Listener {
}
}
}
}
private void markProjectileOriginAsCrossbow(Projectile projectile) {
private void markProjectileOriginAsCrossbow(@NotNull Projectile projectile) {
projectile.setMetadata(mcMMO.PROJECTILE_ORIGIN_METAKEY, new ProjectileOriginMeta(plugin, 2));
}
private void markProjectileOriginAsBow(Projectile projectile) {
private void markProjectileOriginAsBow(@NotNull Projectile projectile) {
projectile.setMetadata(mcMMO.PROJECTILE_ORIGIN_METAKEY, new ProjectileOriginMeta(plugin, 1));
}
@ -567,14 +568,14 @@ public class EntityListener implements Listener {
return;
}
OnlineMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
McMMOPlayer mmoPlayer = (McMMOPlayer) mcMMO.getUserManager().queryPlayer(player);
//Profile not loaded
if(mmoPlayer == null)
return;
/* Check for invincibility */
if (mmoPlayer.getGodMode()) {
if (mmoPlayer.isGodMode()) {
event.setCancelled(true);
return;
}

View File

@ -59,12 +59,12 @@ public final class UserManager {
* @param player target player
* @return OnlineMMOPlayer object for this player, null if Player has not been loaded
*/
public @Nullable OnlineMMOPlayer queryPlayer(@Nullable Player player) {
public @Nullable McMMOPlayer queryPlayer(@Nullable Player player) {
if(player == null)
return null;
if(player.hasMetadata(mcMMO.playerDataKey))
return (OnlineMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
else
return null;
}