From 742847c63f94e25b51824ce609d462cbf43dde16 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Fri, 9 Sep 2011 01:15:37 +0100 Subject: Added GameMode methods to Server and HumanEntity --- src/main/java/org/bukkit/GameMode.java | 18 ++++++++++++++++++ src/main/java/org/bukkit/Server.java | 14 ++++++++++++++ src/main/java/org/bukkit/entity/HumanEntity.java | 15 +++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 src/main/java/org/bukkit/GameMode.java (limited to 'src/main/java/org') diff --git a/src/main/java/org/bukkit/GameMode.java b/src/main/java/org/bukkit/GameMode.java new file mode 100644 index 00000000..173acf8a --- /dev/null +++ b/src/main/java/org/bukkit/GameMode.java @@ -0,0 +1,18 @@ +package org.bukkit; + +import org.bukkit.entity.HumanEntity; + +/** + * Represents the various type of game modes that {@link HumanEntity}s may have + */ +public enum GameMode { + /** + * Creative mode may fly, build instantly, become invulnerable and create free items + */ + CREATIVE, + + /** + * Survival mode is the "normal" gameplay type, with no special features. + */ + SURVIVAL; +} diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 1ef6cfa7..356036ee 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -441,4 +441,18 @@ public interface Server { * @return Set containing banned players */ public Set getBannedPlayers(); + + /** + * Gets the default {@link GameMode} for new players + * + * @return Default game mode + */ + public GameMode getDefaultGameMode(); + + /** + * Sets the default {@link GameMode} for new players + * + * @param mode New game mode + */ + public void setDefaultGameMode(GameMode mode); } diff --git a/src/main/java/org/bukkit/entity/HumanEntity.java b/src/main/java/org/bukkit/entity/HumanEntity.java index 8c6efae8..64aedfed 100644 --- a/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/src/main/java/org/bukkit/entity/HumanEntity.java @@ -1,5 +1,6 @@ package org.bukkit.entity; +import org.bukkit.GameMode; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.permissions.Permissible; @@ -60,4 +61,18 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, Permissible { * @return slumber ticks */ public int getSleepTicks(); + + /** + * Gets this humans current {@link GameMode} + * + * @return Current game mode + */ + public GameMode getGameMode(); + + /** + * Sets this humans current {@link GameMode} + * + * @param mode New game mode + */ + public void setGameMode(GameMode mode); } -- cgit v1.2.3