Add a config setting to allow creative mode players to override inventory setting.

This commit is contained in:
Wizjany 2013-01-19 19:06:55 -05:00
parent 89bdd8d9ba
commit 6abd48ab08
6 changed files with 23 additions and 2 deletions

View File

@ -98,6 +98,7 @@ public abstract class LocalConfiguration {
public boolean noDoubleSlash = false;
public boolean useInventory = false;
public boolean useInventoryOverride = false;
public boolean useInventoryCreativeOverride = false;
public int navigationWand = ItemID.COMPASS;
public int navigationWandMaxDistance = 50;
public int scriptTimeout = 3000;

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit;
import java.io.File;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType;
@ -669,4 +670,8 @@ public abstract class LocalPlayer {
public boolean isPlayer() {
return true;
}
public boolean hasCreativeMode() {
return false;
}
}

View File

@ -345,7 +345,8 @@ public class WorldEdit {
// Have the session use inventory if it's enabled and the player
// doesn't have an override
session.setUseInventory(config.useInventory
&& !(config.useInventoryOverride
&& !((config.useInventoryOverride ||
(config.useInventoryCreativeOverride && player.hasCreativeMode()))
&& player.hasPermission("worldedit.inventory.unrestricted")));
}

View File

@ -19,11 +19,17 @@
package com.sk89q.worldedit.bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.sk89q.util.StringUtil;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.LocalPlayer;
import com.sk89q.worldedit.LocalWorld;
import com.sk89q.worldedit.ServerInterface;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldVector;
import com.sk89q.worldedit.bags.BlockBag;
import com.sk89q.worldedit.cui.CUIEvent;
@ -139,4 +145,9 @@ public class BukkitPlayer extends LocalPlayer {
public Player getPlayer() {
return player;
}
@Override
public boolean hasCreativeMode() {
return player.getGameMode() == GameMode.CREATIVE;
}
}

View File

@ -93,6 +93,8 @@ public class YAMLConfiguration extends LocalConfiguration {
useInventory = config.getBoolean("use-inventory.enable", useInventory);
useInventoryOverride = config.getBoolean("use-inventory.allow-override",
useInventoryOverride);
useInventoryCreativeOverride = config.getBoolean("use-inventory.creative-mode-overrides",
useInventoryCreativeOverride);
navigationWand = config.getInt("navigation-wand.item", navigationWand);
navigationWandMaxDistance = config.getInt("navigation-wand.max-distance", navigationWandMaxDistance);

View File

@ -34,6 +34,7 @@ limits:
use-inventory:
enable: false
allow-override: true
creative-mode-overrides: false
logging:
log-commands: false