diff --git a/pom.xml b/pom.xml
index 68b648be..888d694d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,7 +35,7 @@
com.sk89q
worldedit
- 5.1-SNAPSHOT
+ 5.1
@@ -44,6 +44,13 @@
bukkit
1.0.0-R1-SNAPSHOT
+
+
+
+ com.sk89q
+ commandbook
+ 1.8-SNAPSHOT
+
diff --git a/src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java b/src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java
index 7992dedf..c78399d7 100644
--- a/src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java
+++ b/src/main/java/com/sk89q/worldguard/bukkit/ConfigurationManager.java
@@ -72,11 +72,6 @@ public class ConfigurationManager {
*/
private Map worlds;
- /**
- * List of people with god mode.
- */
- private Set hasGodMode = new HashSet();
-
/**
* List of people who can breathe underwater.
*/
@@ -173,39 +168,9 @@ public void forgetPlayer(LocalPlayer player) {
bl.forgetPlayer(player);
}
}
-
- hasGodMode.remove(player.getName());
hasAmphibious.remove(player.getName());
}
- /**
- * Enable god mode for a player.
- *
- * @param player
- */
- public void enableGodMode(Player player) {
- hasGodMode.add(player.getName());
- }
-
- /**
- * Disable god mode for a player.
- *
- * @param player
- */
- public void disableGodMode(Player player) {
- hasGodMode.remove(player.getName());
- }
-
- /**
- * Check to see if god mode is enabled for a player.
- *
- * @param player
- * @return
- */
- public boolean hasGodMode(Player player) {
- return hasGodMode.contains(player.getName());
- }
-
/**
* Enable amphibious mode for a player.
*
diff --git a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java
index bb924bc5..45560dab 100644
--- a/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java
+++ b/src/main/java/com/sk89q/worldguard/bukkit/FlagStateManager.java
@@ -89,7 +89,7 @@ public void run() {
.getApplicableRegions(playerLocation);
if (!RegionQueryUtil.isInvincible(plugin, player, applicable)
- && !plugin.getGlobalStateManager().hasGodMode(player)
+ && !RegionQueryUtil.hasGodMode(player, plugin)
&& !(player.getGameMode() == GameMode.CREATIVE)) {
processHeal(applicable, player, state);
processFeed(applicable, player, state);
diff --git a/src/main/java/com/sk89q/worldguard/bukkit/RegionQueryUtil.java b/src/main/java/com/sk89q/worldguard/bukkit/RegionQueryUtil.java
index 98e88ce4..91df5a86 100644
--- a/src/main/java/com/sk89q/worldguard/bukkit/RegionQueryUtil.java
+++ b/src/main/java/com/sk89q/worldguard/bukkit/RegionQueryUtil.java
@@ -19,6 +19,8 @@
package com.sk89q.worldguard.bukkit;
+import com.sk89q.commandbook.CommandBook;
+import com.sk89q.commandbook.GodComponent;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -73,11 +75,25 @@ public static Boolean isAllowedInvinciblity(WorldGuardPlugin plugin, Player play
StateFlag.State regionState = plugin.getGlobalRegionManager().get(world).
getApplicableRegions(vec).getFlag(DefaultFlag.INVINCIBILITY);
if (regionState == StateFlag.State.ALLOW) {
- return true;
+ return Boolean.TRUE;
} else if (regionState == StateFlag.State.DENY) {
- return false;
+ return Boolean.FALSE;
} else {
return null;
}
}
+
+ public static boolean hasGodMode(Player player, WorldGuardPlugin plugin) {
+ try {
+ if (plugin.getServer().getPluginManager().isPluginEnabled("CommandBook")) {
+ GodComponent god = CommandBook.inst().getComponentManager().getComponent(GodComponent.class);
+ if (god != null) {
+ return god.hasGodMode(player);
+ }
+ }
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ return false;
+ }
}
diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java
index 2d09e9ca..486a841e 100644
--- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java
+++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardEntityListener.java
@@ -202,7 +202,7 @@ private void onEntityDamageByBlock(EntityDamageByBlockEvent event) {
if (wcfg.disableLavaDamage && type == DamageCause.LAVA) {
event.setCancelled(true);
- if (cfg.hasGodMode(player)) player.setFireTicks(0);
+ player.setFireTicks(0);
return;
}
@@ -530,7 +530,7 @@ public void onEntityCombust(EntityCombustEvent event) {
if (entity instanceof Player) {
Player player = (Player) entity;
- if (cfg.hasGodMode(player) || (wcfg.useRegions && RegionQueryUtil.isInvincible(plugin, player))) {
+ if ((wcfg.useRegions && RegionQueryUtil.isInvincible(plugin, player))) {
event.setCancelled(true);
return;
}
@@ -914,10 +914,10 @@ private boolean isInvincible(Player player) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(player.getWorld());
- boolean god = cfg.hasGodMode(player);
+ boolean god = RegionQueryUtil.hasGodMode(player, plugin);
if (wcfg.useRegions) {
Boolean flag = RegionQueryUtil.isAllowedInvinciblity(plugin, player);
- boolean allowed = flag == null || flag == true;
+ boolean allowed = flag == null || flag == Boolean.TRUE;
boolean invincible = RegionQueryUtil.isInvincible(plugin, player);
if (allowed) {
diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java
index ee6c25ef..ae3e8c09 100644
--- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java
+++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlayerListener.java
@@ -165,11 +165,6 @@ public void onPlayerJoin(PlayerJoinEvent event) {
+ "Fire spread is currently globally disabled for this world.");
}
- if (cfg.autoGodMode && (plugin.inGroup(player, "wg-invincible")
- || plugin.hasPermission(player, "worldguard.auto-invincible"))) {
- cfg.enableGodMode(player);
- }
-
if (plugin.inGroup(player, "wg-amphibious")) {
cfg.enableAmphibiousMode(player);
}
diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java
index c1277ac0..a8addb0f 100644
--- a/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java
+++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java
@@ -50,7 +50,6 @@
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.TickSyncDelayLoggerFilter;
-import com.sk89q.worldguard.bukkit.commands.GeneralCommands;
import com.sk89q.worldguard.bukkit.commands.ProtectionCommands;
import com.sk89q.worldguard.bukkit.commands.ToggleCommands;
import com.sk89q.worldguard.protection.GlobalRegionManager;
@@ -118,7 +117,6 @@ public void onEnable() {
final CommandRegistration reg = new CommandRegistration(this, commands);
reg.register(ToggleCommands.class);
reg.register(ProtectionCommands.class);
- reg.register(GeneralCommands.class);
// Need to create the plugins/WorldGuard folder
getDataFolder().mkdirs();
@@ -166,14 +164,6 @@ public void onEnable() {
}
worldListener.registerEvents();
- // Check god mode for existing players, if any
- for (Player player : getServer().getOnlinePlayers()) {
- if (inGroup(player, "wg-invincible") ||
- (configuration.autoGodMode && hasPermission(player, "worldguard.auto-invincible"))) {
- configuration.enableGodMode(player);
- }
- }
-
logger.info("WorldGuard " + this.getDescription().getVersion() + " enabled.");
}
diff --git a/src/main/java/com/sk89q/worldguard/bukkit/commands/GeneralCommands.java b/src/main/java/com/sk89q/worldguard/bukkit/commands/GeneralCommands.java
deleted file mode 100644
index 8c74e8db..00000000
--- a/src/main/java/com/sk89q/worldguard/bukkit/commands/GeneralCommands.java
+++ /dev/null
@@ -1,301 +0,0 @@
-// $Id$
-/*
- * WorldGuard
- * Copyright (C) 2010 sk89q
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
-*/
-
-package com.sk89q.worldguard.bukkit.commands;
-
-import org.bukkit.ChatColor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
-
-import com.sk89q.minecraft.util.commands.Command;
-import com.sk89q.minecraft.util.commands.CommandContext;
-import com.sk89q.minecraft.util.commands.CommandException;
-import com.sk89q.minecraft.util.commands.CommandPermissions;
-import com.sk89q.worldedit.blocks.ItemType;
-import com.sk89q.worldguard.bukkit.ConfigurationManager;
-import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
-
-public class GeneralCommands {
- private final WorldGuardPlugin plugin;
-
- public GeneralCommands(WorldGuardPlugin plugin) {
- this.plugin = plugin;
- }
-
- @Command(aliases = {"god"}, usage = "[player]",
- desc = "Enable godmode on a player", flags = "s", max = 1)
- public void god(CommandContext args, CommandSender sender) throws CommandException {
- ConfigurationManager config = plugin.getGlobalStateManager();
-
- Iterable targets = null;
- boolean included = false;
-
- // Detect arguments based on the number of arguments provided
- if (args.argsLength() == 0) {
- targets = plugin.matchPlayers(plugin.checkPlayer(sender));
-
- // Check permissions!
- plugin.checkPermission(sender, "worldguard.god");
- } else if (args.argsLength() == 1) {
- targets = plugin.matchPlayers(sender, args.getString(0));
-
- // Check permissions!
- plugin.checkPermission(sender, "worldguard.god.other");
- }
-
- for (Player player : targets) {
- config.enableGodMode(player);
- player.setFireTicks(0);
-
- // Tell the user
- if (player.equals(sender)) {
- player.sendMessage(ChatColor.YELLOW + "God mode enabled! Use /ungod to disable.");
-
- // Keep track of this
- included = true;
- } else {
- player.sendMessage(ChatColor.YELLOW + "God enabled by "
- + plugin.toName(sender) + ".");
-
- }
- }
-
- // The player didn't receive any items, then we need to send the
- // user a message so s/he know that something is indeed working
- if (!included && args.hasFlag('s')) {
- sender.sendMessage(ChatColor.YELLOW.toString() + "Players now have god mode.");
- }
- }
-
- @Command(aliases = {"ungod"}, usage = "[player]",
- desc = "Disable godmode on a player", flags = "s", max = 1)
- public void ungod(CommandContext args, CommandSender sender) throws CommandException {
- ConfigurationManager config = plugin.getGlobalStateManager();
-
- Iterable targets = null;
- boolean included = false;
-
- // Detect arguments based on the number of arguments provided
- if (args.argsLength() == 0) {
- targets = plugin.matchPlayers(plugin.checkPlayer(sender));
-
- // Check permissions!
- plugin.checkPermission(sender, "worldguard.god");
- } else if (args.argsLength() == 1) {
- targets = plugin.matchPlayers(sender, args.getString(0));
-
- // Check permissions!
- plugin.checkPermission(sender, "worldguard.god.other");
- }
-
- for (Player player : targets) {
- config.disableGodMode(player);
-
- // Tell the user
- if (player.equals(sender)) {
- player.sendMessage(ChatColor.YELLOW + "God mode disabled!");
-
- // Keep track of this
- included = true;
- } else {
- player.sendMessage(ChatColor.YELLOW + "God disabled by "
- + plugin.toName(sender) + ".");
-
- }
- }
-
- // The player didn't receive any items, then we need to send the
- // user a message so s/he know that something is indeed working
- if (!included && args.hasFlag('s')) {
- sender.sendMessage(ChatColor.YELLOW.toString() + "Players no longer have god mode.");
- }
- }
-
- @Command(aliases = {"heal"}, usage = "[player]", desc = "Heal a player", flags = "s", max = 1)
- public void heal(CommandContext args,CommandSender sender) throws CommandException {
-
- Iterable targets = null;
- boolean included = false;
-
- // Detect arguments based on the number of arguments provided
- if (args.argsLength() == 0) {
- targets = plugin.matchPlayers(plugin.checkPlayer(sender));
-
- // Check permissions!
- plugin.checkPermission(sender, "worldguard.heal");
- } else if (args.argsLength() == 1) {
- targets = plugin.matchPlayers(sender, args.getString(0));
-
- // Check permissions!
- plugin.checkPermission(sender, "worldguard.heal.other");
- }
-
- for (Player player : targets) {
- player.setHealth(20);
- player.setFoodLevel(20);
-
- // Tell the user
- if (player.equals(sender)) {
- player.sendMessage(ChatColor.YELLOW + "Healed!");
-
- // Keep track of this
- included = true;
- } else {
- player.sendMessage(ChatColor.YELLOW + "Healed by "
- + plugin.toName(sender) + ".");
-
- }
- }
-
- // The player didn't receive any items, then we need to send the
- // user a message so s/he know that something is indeed working
- if (!included && args.hasFlag('s')) {
- sender.sendMessage(ChatColor.YELLOW.toString() + "Players healed.");
- }
- }
-
- @Command(aliases = {"slay"}, usage = "[player]", desc = "Slay a player", flags = "s", max = 1)
- public void slay(CommandContext args, CommandSender sender) throws CommandException {
-
- Iterable targets = null;
- boolean included = false;
-
- // Detect arguments based on the number of arguments provided
- if (args.argsLength() == 0) {
- targets = plugin.matchPlayers(plugin.checkPlayer(sender));
-
- // Check permissions!
- plugin.checkPermission(sender, "worldguard.slay");
- } else if (args.argsLength() == 1) {
- targets = plugin.matchPlayers(sender, args.getString(0));
-
- // Check permissions!
- plugin.checkPermission(sender, "worldguard.slay.other");
- }
-
- for (Player player : targets) {
- player.setHealth(0);
-
- // Tell the user
- if (player.equals(sender)) {
- player.sendMessage(ChatColor.YELLOW + "Slain!");
-
- // Keep track of this
- included = true;
- } else {
- player.sendMessage(ChatColor.YELLOW + "Slain by "
- + plugin.toName(sender) + ".");
-
- }
- }
-
- // The player didn't receive any items, then we need to send the
- // user a message so s/he know that something is indeed working
- if (!included && args.hasFlag('s')) {
- sender.sendMessage(ChatColor.YELLOW.toString() + "Players slain.");
- }
- }
-
- @Command(aliases = {"locate"}, usage = "[player]", desc = "Locate a player", max = 1)
- @CommandPermissions({"worldguard.locate"})
- public void locate(CommandContext args, CommandSender sender) throws CommandException {
-
- Player player = plugin.checkPlayer(sender);
-
- if (args.argsLength() == 0) {
- player.setCompassTarget(player.getWorld().getSpawnLocation());
-
- sender.sendMessage(ChatColor.YELLOW.toString() + "Compass reset to spawn.");
- } else {
- Player target = plugin.matchSinglePlayer(sender, args.getString(0));
- player.setCompassTarget(target.getLocation());
-
- sender.sendMessage(ChatColor.YELLOW.toString() + "Compass repointed.");
- }
- }
-
- @Command(aliases = {"stack", ";"}, usage = "", desc = "Stack items", max = 0)
- @CommandPermissions({"worldguard.stack"})
- public void stack(CommandContext args, CommandSender sender) throws CommandException {
-
- Player player = plugin.checkPlayer(sender);
- boolean ignoreMax = plugin.hasPermission(player, "worldguard.stack.illegitimate");
- boolean ignoreDamaged = plugin.hasPermission(player, "worldguard.stack.damaged");
-
- ItemStack[] items = player.getInventory().getContents();
- int len = items.length;
-
- int affected = 0;
-
- for (int i = 0; i < len; i++) {
- ItemStack item = items[i];
-
- // Avoid infinite stacks and stacks with durability
- if (item == null || item.getAmount() <= 0
- || (!ignoreMax && item.getMaxStackSize() == 1)) {
- continue;
- }
-
- int max = ignoreMax ? 64 : item.getMaxStackSize();
-
- if (item.getAmount() < max) {
- int needed = max - item.getAmount(); // Number of needed items until max
-
- // Find another stack of the same type
- for (int j = i + 1; j < len; j++) {
- ItemStack item2 = items[j];
-
- // Avoid infinite stacks and stacks with durability
- if (item2 == null || item2.getAmount() <= 0
- || (!ignoreMax && item.getMaxStackSize() == 1)) {
- continue;
- }
-
- // Same type?
- // Blocks store their color in the damage value
- if (item2.getTypeId() == item.getTypeId() &&
- ((!ItemType.usesDamageValue(item.getTypeId()) && ignoreDamaged)
- || item.getDurability() == item2.getDurability()) &&
- item.getEnchantments().equals(item2.getEnchantments())) {
- // This stack won't fit in the parent stack
- if (item2.getAmount() > needed) {
- item.setAmount(64);
- item2.setAmount(item2.getAmount() - needed);
- break;
- // This stack will
- } else {
- items[j] = null;
- item.setAmount(item.getAmount() + item2.getAmount());
- needed = 64 - item.getAmount();
- }
-
- affected++;
- }
- }
- }
- }
-
- if (affected > 0) {
- player.getInventory().setContents(items);
- }
-
- player.sendMessage(ChatColor.YELLOW + "Items compacted into stacks!");
- }
-}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index bfe0e567..1981a12a 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,4 +1,4 @@
name: WorldGuard
main: com.sk89q.worldguard.bukkit.WorldGuardPlugin
version: "${project.version}"
-softdepend: [WorldEdit]
\ No newline at end of file
+softdepend: [WorldEdit, CommandBook]