Util for GameMode checking.

This commit is contained in:
Olof Larsson 2012-05-11 15:08:58 +02:00
parent 30a1b1bfa6
commit 738bb84dd8

View File

@ -3,6 +3,7 @@ package com.massivecraft.mcore2.persist;
import java.util.Collection; import java.util.Collection;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.massivecraft.mcore2.util.Txt; import com.massivecraft.mcore2.util.Txt;
@ -25,6 +26,16 @@ public abstract class PlayerEntity<T extends PlayerEntity<T>> extends Entity<T>
return ! isOnline(); 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 // Message Sending Helpers
// -------------------------------------------- // // -------------------------------------------- //