Util for GameMode checking.
This commit is contained in:
parent
30a1b1bfa6
commit
738bb84dd8
@ -3,6 +3,7 @@ package com.massivecraft.mcore2.persist;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.massivecraft.mcore2.util.Txt;
|
||||
@ -25,6 +26,16 @@ public abstract class PlayerEntity<T extends PlayerEntity<T>> extends Entity<T>
|
||||
return ! isOnline();
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CHECKER UTILS
|
||||
// -------------------------------------------- //
|
||||
public boolean isGameMode(GameMode gm, boolean defaultIfOffline)
|
||||
{
|
||||
Player player = this.getPlayer();
|
||||
if (player == null || ! player.isOnline()) return defaultIfOffline;
|
||||
return player.getGameMode() == gm;
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// Message Sending Helpers
|
||||
// -------------------------------------------- //
|
||||
|
Loading…
Reference in New Issue
Block a user