mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
Return type McMMOPlayer from UserManager
This commit is contained in:
parent
7c270feacb
commit
a379b90c46
@ -5,6 +5,8 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.config.WorldBlacklist;
|
import com.gmail.nossr50.config.WorldBlacklist;
|
||||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||||
import com.gmail.nossr50.datatypes.meta.ProjectileOriginMeta;
|
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.neetgames.mcmmo.player.OnlineMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
@ -212,19 +214,18 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) {
|
||||||
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
|
projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markProjectileOriginAsCrossbow(Projectile projectile) {
|
private void markProjectileOriginAsCrossbow(@NotNull Projectile projectile) {
|
||||||
projectile.setMetadata(mcMMO.PROJECTILE_ORIGIN_METAKEY, new ProjectileOriginMeta(plugin, 2));
|
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));
|
projectile.setMetadata(mcMMO.PROJECTILE_ORIGIN_METAKEY, new ProjectileOriginMeta(plugin, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,14 +568,14 @@ public class EntityListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OnlineMMOPlayer mmoPlayer = mcMMO.getUserManager().queryPlayer(player);
|
McMMOPlayer mmoPlayer = (McMMOPlayer) mcMMO.getUserManager().queryPlayer(player);
|
||||||
|
|
||||||
//Profile not loaded
|
//Profile not loaded
|
||||||
if(mmoPlayer == null)
|
if(mmoPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Check for invincibility */
|
/* Check for invincibility */
|
||||||
if (mmoPlayer.getGodMode()) {
|
if (mmoPlayer.isGodMode()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -59,12 +59,12 @@ public final class UserManager {
|
|||||||
* @param player target player
|
* @param player target player
|
||||||
* @return OnlineMMOPlayer object for this player, null if Player has not been loaded
|
* @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)
|
if(player == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if(player.hasMetadata(mcMMO.playerDataKey))
|
if(player.hasMetadata(mcMMO.playerDataKey))
|
||||||
return (OnlineMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
return (McMMOPlayer) player.getMetadata(mcMMO.playerDataKey).get(0).value();
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user