namespace rework
moved worldguardintegration into own namespace moved worldguardcommand to correct namepsace added prevention: dropping items in creative zone added prevention: placing blocks outside creative zone added prevention: dropping doors/beds in creative mode
This commit is contained in:
parent
dd87aef066
commit
2c9e4b80a3
16 changed files with 504 additions and 229 deletions
|
@ -32,3 +32,4 @@ blocked:
|
||||||
chest: Access to chests is not allowed in creative mode
|
chest: Access to chests is not allowed in creative mode
|
||||||
sign: To interact with signs is not allowed in creative mode
|
sign: To interact with signs is not allowed in creative mode
|
||||||
survival_flying: You should stay on ground, when leaving a creative-area
|
survival_flying: You should stay on ground, when leaving a creative-area
|
||||||
|
outside_creative: You can not place blocks outside of the creative-area
|
|
@ -1,6 +1,6 @@
|
||||||
name: LimitedCreative
|
name: LimitedCreative
|
||||||
main: de.jaschastarke.minecraft.limitedcreative.LimitedCreativeCore
|
main: de.jaschastarke.minecraft.limitedcreative.LimitedCreativeCore
|
||||||
version: 0.5-alpha
|
version: 0.5.1-alpha
|
||||||
softdepend: [WorldGuard]
|
softdepend: [WorldGuard]
|
||||||
commands:
|
commands:
|
||||||
limitedcreative:
|
limitedcreative:
|
||||||
|
|
|
@ -25,6 +25,8 @@ import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import de.jaschastarke.minecraft.worldguard.CCommand;
|
||||||
import static de.jaschastarke.minecraft.utils.Locale.L;
|
import static de.jaschastarke.minecraft.utils.Locale.L;
|
||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
|
@ -190,7 +192,7 @@ public class Commands {
|
||||||
plugin = pplugin;
|
plugin = pplugin;
|
||||||
plugin.getCommand("limitedcreative").setExecutor(new MainCommandExecutor());
|
plugin.getCommand("limitedcreative").setExecutor(new MainCommandExecutor());
|
||||||
if (plugin.worldguard != null) {
|
if (plugin.worldguard != null) {
|
||||||
plugin.getCommand("/region").setExecutor(plugin.worldguard.new WGICommandExecutor()); // very odd syntax, but i liiiikey internal classes :D
|
plugin.getCommand("/region").setExecutor(new CCommand(plugin, plugin.worldguard.getRegionManager()));
|
||||||
} else {
|
} else {
|
||||||
plugin.getCommand("/region").setExecutor(new NotAvailableCommandExecutor());
|
plugin.getCommand("/region").setExecutor(new NotAvailableCommandExecutor());
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class LCPlayer {
|
||||||
|
|
||||||
private LCPlayer(Player pplayer) {
|
private LCPlayer(Player pplayer) {
|
||||||
player = pplayer;
|
player = pplayer;
|
||||||
_isRegionCreative = store.getBoolean(player.getName()+".region_creative", false);
|
_isRegionCreative = store.getBoolean(player.getName()+".region_creative", false) && player.getGameMode() == GameMode.CREATIVE;
|
||||||
if (player.getGameMode() == GameMode.CREATIVE && !this.getRegionCreative())
|
if (player.getGameMode() == GameMode.CREATIVE && !this.getRegionCreative())
|
||||||
isPermanentCreative = true;
|
isPermanentCreative = true;
|
||||||
}
|
}
|
||||||
|
@ -198,13 +198,18 @@ public class LCPlayer {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long lastFloatingTimeWarning = 0;
|
||||||
|
|
||||||
public void setRegionCreativeAllowed(boolean rcreative, PlayerMoveEvent event) {
|
public void setRegionCreativeAllowed(boolean rcreative, PlayerMoveEvent event) {
|
||||||
if (rcreative && player.getGameMode() == GameMode.SURVIVAL) {
|
if (rcreative && player.getGameMode() == GameMode.SURVIVAL) {
|
||||||
setRegionCreative(true); // have to be set, before setGameMode
|
setRegionCreative(true); // have to be set, before setGameMode
|
||||||
player.setGameMode(GameMode.CREATIVE);
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
} else if (!rcreative && player.getGameMode() == GameMode.CREATIVE && !isPermanentCreative) {
|
} else if (!rcreative && player.getGameMode() == GameMode.CREATIVE && !isPermanentCreative) {
|
||||||
if (getFloatingHeight() > 3) {
|
if (getFloatingHeight() > 3) {
|
||||||
player.sendMessage(L("blocked.survival_flying"));
|
if (System.currentTimeMillis() - lastFloatingTimeWarning > 10000) {// 10 sec. limit
|
||||||
|
player.sendMessage(L("blocked.survival_flying"));
|
||||||
|
lastFloatingTimeWarning = System.currentTimeMillis();
|
||||||
|
}
|
||||||
event.setTo(event.getFrom());
|
event.setTo(event.getFrom());
|
||||||
} else {
|
} else {
|
||||||
player.setGameMode(GameMode.SURVIVAL); // also unsets isRegionCreative;
|
player.setGameMode(GameMode.SURVIVAL); // also unsets isRegionCreative;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import static de.jaschastarke.minecraft.utils.Locale.L;
|
import static de.jaschastarke.minecraft.utils.Locale.L;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
|
||||||
import de.jaschastarke.minecraft.utils.Locale;
|
import de.jaschastarke.minecraft.utils.Locale;
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ public class LimitedCreativeCore extends JavaPlugin {
|
||||||
public Configuration config;
|
public Configuration config;
|
||||||
public WorldGuardIntegration worldguard;
|
public WorldGuardIntegration worldguard;
|
||||||
public static LimitedCreativeCore plugin;
|
public static LimitedCreativeCore plugin;
|
||||||
|
public NoBlockItemSpawn spawnblock;
|
||||||
|
|
||||||
public static boolean serializeFallBack = false;
|
public static boolean serializeFallBack = false;
|
||||||
|
|
||||||
|
@ -51,6 +53,8 @@ public class LimitedCreativeCore extends JavaPlugin {
|
||||||
|
|
||||||
new Locale(this);
|
new Locale(this);
|
||||||
|
|
||||||
|
spawnblock = new NoBlockItemSpawn();
|
||||||
|
|
||||||
Listener.register(this);
|
Listener.register(this);
|
||||||
|
|
||||||
if (config.getRegionEnabled() && WorldGuardIntegration.available()) {
|
if (config.getRegionEnabled() && WorldGuardIntegration.available()) {
|
||||||
|
|
|
@ -18,19 +18,25 @@
|
||||||
package de.jaschastarke.minecraft.limitedcreative;
|
package de.jaschastarke.minecraft.limitedcreative;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.ContainerBlock;
|
import org.bukkit.block.ContainerBlock;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.StorageMinecart;
|
import org.bukkit.entity.StorageMinecart;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.Event.Priority;
|
import org.bukkit.event.Event.Priority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockListener;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityListener;
|
import org.bukkit.event.entity.EntityListener;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
|
@ -129,19 +135,92 @@ public final class Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemSpawn(ItemSpawnEvent event) {
|
||||||
|
if (event.getEntity() instanceof Item) {
|
||||||
|
if (plugin.spawnblock.isBlocked(event.getLocation().getBlock().getLocation(), ((Item) event.getEntity()).getItemStack().getType())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void register() {
|
private void register() {
|
||||||
if (plugin.config.getLimitEnabled()) {
|
if (plugin.config.getLimitEnabled()) {
|
||||||
|
plugin.getServer().getPluginManager().registerEvent(Event.Type.ITEM_SPAWN, this, Priority.Normal, plugin);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this, Priority.Normal, plugin);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this, Priority.Normal, plugin);
|
||||||
pm.registerEvent(Event.Type.ENTITY_DEATH, this, Priority.Low, plugin);
|
pm.registerEvent(Event.Type.ENTITY_DEATH, this, Priority.Low, plugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class BlockListen extends BlockListener {
|
||||||
|
@Override
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
|
// Prevent dropping of doors and beds when destroying the wrong part
|
||||||
|
if (plugin.config.getPermissionsEnabled() && event.getPlayer().hasPermission("limitedcreative.nolimit.drop"))
|
||||||
|
return;
|
||||||
|
Block block = event.getBlock();
|
||||||
|
Material mat = block.getType();
|
||||||
|
switch (event.getBlock().getType()) {
|
||||||
|
case WOODEN_DOOR:
|
||||||
|
mat = Material.WOOD_DOOR;
|
||||||
|
plugin.spawnblock.block(block.getRelative(BlockFace.DOWN).getLocation(), mat);
|
||||||
|
break;
|
||||||
|
case IRON_DOOR_BLOCK:
|
||||||
|
mat = Material.IRON_DOOR;
|
||||||
|
plugin.spawnblock.block(block.getRelative(BlockFace.DOWN).getLocation(), mat);
|
||||||
|
break;
|
||||||
|
case BED_BLOCK:
|
||||||
|
mat = Material.BED;
|
||||||
|
plugin.spawnblock.block(block.getRelative(BlockFace.NORTH).getLocation(), mat);
|
||||||
|
plugin.spawnblock.block(block.getRelative(BlockFace.EAST).getLocation(), mat);
|
||||||
|
plugin.spawnblock.block(block.getRelative(BlockFace.SOUTH).getLocation(), mat);
|
||||||
|
plugin.spawnblock.block(block.getRelative(BlockFace.WEST).getLocation(), mat);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plugin.spawnblock.block(event.getBlock().getLocation(), mat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void register() {
|
||||||
|
if (plugin.config.getLimitEnabled()) {
|
||||||
|
pm.registerEvent(Event.Type.BLOCK_BREAK, this, Priority.Normal, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
public static class VehicleListen extends VehicleListener {
|
||||||
|
@Override
|
||||||
|
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
if (event.getAttacker() instanceof Player) {
|
||||||
|
Player player = (Player) event.getAttacker();
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||||
|
if (plugin.config.getPermissionsEnabled() && player.hasPermission("limitedcreative.nolimit.drop"))
|
||||||
|
return;
|
||||||
|
plugin.logger.info("Vehicle destroy: "+event.getVehicle() + " - "+event.getVehicle().getEntityId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void register() {
|
||||||
|
if (plugin.config.getLimitEnabled()) {
|
||||||
|
pm.registerEvent(Event.Type.VEHICLE_DESTROY, this, Priority.Normal, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
public static void register(LimitedCreativeCore pplugin) {
|
public static void register(LimitedCreativeCore pplugin) {
|
||||||
plugin = pplugin;
|
plugin = pplugin;
|
||||||
pm = plugin.getServer().getPluginManager();
|
pm = plugin.getServer().getPluginManager();
|
||||||
|
|
||||||
new PlayerListen().register();
|
new PlayerListen().register();
|
||||||
new EntityListen().register();
|
new EntityListen().register();
|
||||||
|
new BlockListen().register();
|
||||||
|
//new VehicleListen().register();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Limited Creative - (Bukkit Plugin)
|
||||||
|
* Copyright (C) 2012 jascha@ja-s.de
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.jaschastarke.minecraft.limitedcreative;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
|
||||||
|
|
||||||
|
public class NoBlockItemSpawn {
|
||||||
|
public final static long TIME_OFFSET = 1000;
|
||||||
|
|
||||||
|
private List<BlockItemDrop> list = new ArrayList<BlockItemDrop>();
|
||||||
|
|
||||||
|
public boolean isBlocked(Location l, Material type) {
|
||||||
|
cleanup();
|
||||||
|
for (BlockItemDrop block : list) {
|
||||||
|
if (block.getLocation().equals(l) && block.getType().equals(type))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
private void cleanup() {
|
||||||
|
Iterator<BlockItemDrop> i = list.iterator();
|
||||||
|
while (i.hasNext()) {
|
||||||
|
BlockItemDrop block = i.next();
|
||||||
|
if (block.getTimestamp() < System.currentTimeMillis() - TIME_OFFSET)
|
||||||
|
i.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BlockItemDrop {
|
||||||
|
public BlockItemDrop(Location l, Material type) {
|
||||||
|
this.l = l;
|
||||||
|
this.type = type;
|
||||||
|
this.timestamp = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
private Location l;
|
||||||
|
private Material type;
|
||||||
|
private long timestamp;
|
||||||
|
public Location getLocation() {
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
public Material getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
public long getTimestamp() {
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void block(Block block, LCPlayer player) {
|
||||||
|
Material mat = block.getType();
|
||||||
|
if (player == null || !player.getRaw().getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) { // different drop type prevention
|
||||||
|
net.minecraft.server.Block type = net.minecraft.server.Block.byId[mat.getId()];
|
||||||
|
mat = Material.getMaterial(type.getDropType(block.getData(), null, 0));
|
||||||
|
}
|
||||||
|
block(block.getLocation(), mat);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void block(Block block) {
|
||||||
|
block(block, null);
|
||||||
|
}
|
||||||
|
public void block(Location l, Material type) {
|
||||||
|
list.add(new BlockItemDrop(l, type));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,216 +0,0 @@
|
||||||
/*
|
|
||||||
* Limited Creative - (Bukkit Plugin)
|
|
||||||
* Copyright (C) 2012 jascha@ja-s.de
|
|
||||||
*
|
|
||||||
* 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 <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package de.jaschastarke.minecraft.limitedcreative;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.Event.Priority;
|
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
|
||||||
|
|
||||||
import static de.jaschastarke.minecraft.utils.Locale.L;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
|
||||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
|
||||||
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
|
||||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
|
||||||
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|
||||||
|
|
||||||
import de.jaschastarke.minecraft.regions.ApplicableRegions;
|
|
||||||
import de.jaschastarke.minecraft.regions.CRegion;
|
|
||||||
import de.jaschastarke.minecraft.regions.CRegionManager;
|
|
||||||
import de.jaschastarke.minecraft.regions.FlagList;
|
|
||||||
import de.jaschastarke.minecraft.regions.FlagValue;
|
|
||||||
import de.jaschastarke.minecraft.utils.Util;
|
|
||||||
|
|
||||||
public class WorldGuardIntegration {
|
|
||||||
public static LimitedCreativeCore plugin;
|
|
||||||
public static WorldGuardPlugin wg;
|
|
||||||
private CRegionManager rm;
|
|
||||||
|
|
||||||
public WorldGuardIntegration(LimitedCreativeCore pplugin) {
|
|
||||||
plugin = pplugin;
|
|
||||||
wg = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean available() {
|
|
||||||
return LimitedCreativeCore.plugin.getServer().getPluginManager().getPlugin("WorldGuard") != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static final StateFlag CREATIVE = new StateFlag("creative", false);
|
|
||||||
public static final RegionGroupFlag CREATIVE_GROUP = new RegionGroupFlag("creative-group", RegionGroupFlag.RegionGroup.MEMBERS);
|
|
||||||
static {
|
|
||||||
CREATIVE.setGroupFlag(CREATIVE_GROUP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init() {
|
|
||||||
rm = new CRegionManager(new File(plugin.getDataFolder(), "regions.yml"));
|
|
||||||
FlagList.addFlag(CREATIVE);
|
|
||||||
FlagList.addFlag(CREATIVE_GROUP);
|
|
||||||
|
|
||||||
new WGIPlayerListen().register();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Action {
|
|
||||||
FLAG,
|
|
||||||
INFO
|
|
||||||
}
|
|
||||||
|
|
||||||
public class WGIPlayerListen extends PlayerListener {
|
|
||||||
@Override
|
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
|
||||||
if (event.isCancelled())
|
|
||||||
return;
|
|
||||||
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|
|
||||||
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|
|
||||||
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
|
|
||||||
|
|
||||||
LCPlayer player = LCPlayer.get(event.getPlayer());
|
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().get(event.getPlayer().getWorld());
|
|
||||||
Vector pt = new Vector(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
|
||||||
ApplicableRegions set = new ApplicableRegions(mgr.getApplicableRegions(pt), rm.world(event.getPlayer().getWorld()));
|
|
||||||
|
|
||||||
player.setRegionCreativeAllowed(set.allows(CREATIVE, player), event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void register() {
|
|
||||||
plugin.getServer().getPluginManager().registerEvent(Event.Type.PLAYER_MOVE, this, Priority.Normal, plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @TODO: Move "generic" region command to .regions-NS
|
|
||||||
*/
|
|
||||||
public class WGICommandExecutor implements CommandExecutor {
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (args.length < 2) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!sender.hasPermission("limitedcreative.regions")) {
|
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "exception.command.lackingpermission");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Player player = sender instanceof Player ? (Player) sender : null;
|
|
||||||
World world = null;
|
|
||||||
Action act;
|
|
||||||
String rid;
|
|
||||||
try {
|
|
||||||
act = Action.valueOf(args[0].toUpperCase());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String[] wr = args[1].split("#");
|
|
||||||
if (wr.length == 2) {
|
|
||||||
world = plugin.getServer().getWorld(wr[0]);
|
|
||||||
rid = wr[1];
|
|
||||||
} else {
|
|
||||||
rid = args[1];
|
|
||||||
if (player != null) {
|
|
||||||
world = player.getWorld();
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.world_not_found"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RegionManager mgr = wg.getGlobalRegionManager().get(world);
|
|
||||||
ProtectedRegion region = mgr.getRegion(rid);
|
|
||||||
if (region == null) {
|
|
||||||
if (rid.equalsIgnoreCase("__global__")) {
|
|
||||||
region = new GlobalProtectedRegion(rid);
|
|
||||||
mgr.addRegion(region);
|
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.region_not_found"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CRegion reg = rm.world(world).region(region);
|
|
||||||
|
|
||||||
switch (act) {
|
|
||||||
case INFO:
|
|
||||||
onInfo(sender, player, reg);
|
|
||||||
return true;
|
|
||||||
case FLAG:
|
|
||||||
onFlag(sender, player, reg, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onInfo(CommandSender sender, Player player, CRegion region) {
|
|
||||||
String[] args = new String[]{"info", region.getWorld().getName(), region.getProtectedRegion().getId()};
|
|
||||||
wg.onCommand(sender, wg.getCommand("region"), "/region", args);
|
|
||||||
|
|
||||||
StringBuilder list = new StringBuilder();
|
|
||||||
for (FlagValue data : region.getFlags()) {
|
|
||||||
if (list.length() > 0)
|
|
||||||
list.append(", ");
|
|
||||||
list.append(data.getFlag().getName());
|
|
||||||
list.append(": ");
|
|
||||||
list.append(data.getValue().toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GREEN + L("command.worldguard.additional_flags") + ": " + list.toString());
|
|
||||||
}
|
|
||||||
private void onFlag(CommandSender sender, Player player, CRegion region, String[] args) {
|
|
||||||
if (args.length < 3) {
|
|
||||||
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.no_flag_given"));
|
|
||||||
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.available_flags") + ": " + FlagList.getStringListAvailableFlags(sender));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String flagName = args[2];
|
|
||||||
Flag<?> flag = FlagList.getFlag(flagName);
|
|
||||||
if (flag == null) {
|
|
||||||
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.unknown_flag") + ": " + flagName);
|
|
||||||
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.available_flags") + ": " + FlagList.getStringListAvailableFlags(sender));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String value = null;
|
|
||||||
if (args.length > 3)
|
|
||||||
value = Util.join(args, 3);
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (value != null) {
|
|
||||||
region.setFlag(flag, flag.parseInput(wg, sender, value));
|
|
||||||
} else {
|
|
||||||
region.setFlag(flag, null);
|
|
||||||
}
|
|
||||||
} catch (InvalidFlagFormat e) {
|
|
||||||
sender.sendMessage(ChatColor.DARK_RED + e.getLocalizedMessage());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sender.sendMessage(L("command.worldguard.flag_set", flag.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
/*
|
||||||
|
* Limited Creative - (Bukkit Plugin)
|
||||||
|
* Copyright (C) 2012 jascha@ja-s.de
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.jaschastarke.minecraft.limitedcreative.regions;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.Event.Priority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
|
import org.bukkit.event.block.BlockListener;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
||||||
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.LCPlayer;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.LimitedCreativeCore;
|
||||||
|
import de.jaschastarke.minecraft.worldguard.ApplicableRegions;
|
||||||
|
import de.jaschastarke.minecraft.worldguard.CRegionManager;
|
||||||
|
import de.jaschastarke.minecraft.worldguard.FlagList;
|
||||||
|
import static de.jaschastarke.minecraft.utils.Locale.L;
|
||||||
|
|
||||||
|
public class WorldGuardIntegration {
|
||||||
|
public static LimitedCreativeCore plugin;
|
||||||
|
public static WorldGuardPlugin wg;
|
||||||
|
private CRegionManager rm;
|
||||||
|
|
||||||
|
public WorldGuardIntegration(LimitedCreativeCore pplugin) {
|
||||||
|
plugin = pplugin;
|
||||||
|
wg = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean available() {
|
||||||
|
return LimitedCreativeCore.plugin.getServer().getPluginManager().getPlugin("WorldGuard") != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static final StateFlag CREATIVE = new StateFlag("creative", false);
|
||||||
|
public static final RegionGroupFlag CREATIVE_GROUP = new RegionGroupFlag("creative-group", RegionGroupFlag.RegionGroup.MEMBERS);
|
||||||
|
static {
|
||||||
|
CREATIVE.setGroupFlag(CREATIVE_GROUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
rm = new CRegionManager(new File(plugin.getDataFolder(), "regions.yml"));
|
||||||
|
|
||||||
|
FlagList.addFlag(CREATIVE);
|
||||||
|
FlagList.addFlag(CREATIVE_GROUP);
|
||||||
|
|
||||||
|
new WGIPlayerListen().register();
|
||||||
|
new WGIBlockListen().register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CRegionManager getRegionManager() {
|
||||||
|
return rm;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class WGIBlockListen extends BlockListener {
|
||||||
|
@Override
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
LCPlayer player = LCPlayer.get(event.getPlayer());
|
||||||
|
RegionManager mgr = wg.getGlobalRegionManager().get(event.getPlayer().getWorld());
|
||||||
|
Vector pt = new Vector(event.getBlock().getLocation().getBlockX(), event.getBlock().getLocation().getBlockY(), event.getBlock().getLocation().getBlockZ());
|
||||||
|
ApplicableRegions set = new ApplicableRegions(mgr.getApplicableRegions(pt), rm.world(event.getPlayer().getWorld()));
|
||||||
|
|
||||||
|
boolean creative_region = set.allows(CREATIVE);
|
||||||
|
plugin.logger.info("in creative region: "+Boolean.toString(creative_region)+" - "+event.getBlock().getLocation());
|
||||||
|
if (creative_region && player.getRaw().getGameMode() != GameMode.CREATIVE) {
|
||||||
|
plugin.spawnblock.block(event.getBlock(), player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
LCPlayer player = LCPlayer.get(event.getPlayer());
|
||||||
|
if (player.getRegionCreative()) {
|
||||||
|
// do not build outside of creative regions, when in the region
|
||||||
|
RegionManager mgr = wg.getGlobalRegionManager().get(event.getPlayer().getWorld());
|
||||||
|
Vector pt = new Vector(event.getBlock().getLocation().getBlockX(), event.getBlock().getLocation().getBlockY(), event.getBlock().getLocation().getBlockZ());
|
||||||
|
ApplicableRegions set = new ApplicableRegions(mgr.getApplicableRegions(pt), rm.world(event.getPlayer().getWorld()));
|
||||||
|
if (!set.allows(CREATIVE, player)) {
|
||||||
|
event.getPlayer().sendMessage(L("blocked.outside_creative"));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockDispense(BlockDispenseEvent event) {
|
||||||
|
plugin.logger.info("Block dispense: "+event.getBlock().getType()+" - "+event.getItem().getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void register() {
|
||||||
|
plugin.getServer().getPluginManager().registerEvent(Event.Type.BLOCK_BREAK, this, Priority.Normal, plugin);
|
||||||
|
plugin.getServer().getPluginManager().registerEvent(Event.Type.BLOCK_PLACE, this, Priority.Normal, plugin);
|
||||||
|
plugin.getServer().getPluginManager().registerEvent(Event.Type.BLOCK_DISPENSE, this, Priority.Normal, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class WGIPlayerListen extends PlayerListener {
|
||||||
|
@Override
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|
||||||
|
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|
||||||
|
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
|
||||||
|
|
||||||
|
LCPlayer player = LCPlayer.get(event.getPlayer());
|
||||||
|
RegionManager mgr = wg.getGlobalRegionManager().get(event.getPlayer().getWorld());
|
||||||
|
Vector pt = new Vector(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
||||||
|
ApplicableRegions set = new ApplicableRegions(mgr.getApplicableRegions(pt), rm.world(event.getPlayer().getWorld()));
|
||||||
|
|
||||||
|
player.setRegionCreativeAllowed(set.allows(CREATIVE, player), event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void register() {
|
||||||
|
plugin.getServer().getPluginManager().registerEvent(Event.Type.PLAYER_MOVE, this, Priority.Normal, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.jaschastarke.minecraft.regions;
|
package de.jaschastarke.minecraft.worldguard;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
|
@ -23,7 +23,7 @@ import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
import de.jaschastarke.minecraft.limitedcreative.LCPlayer;
|
import de.jaschastarke.minecraft.limitedcreative.LCPlayer;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.WorldGuardIntegration;
|
import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
|
||||||
|
|
||||||
public class ApplicableRegions {
|
public class ApplicableRegions {
|
||||||
private ApplicableRegionSet regions;
|
private ApplicableRegionSet regions;
|
163
src/de/jaschastarke/minecraft/worldguard/CCommand.java
Normal file
163
src/de/jaschastarke/minecraft/worldguard/CCommand.java
Normal file
|
@ -0,0 +1,163 @@
|
||||||
|
/*
|
||||||
|
* Limited Creative - (Bukkit Plugin)
|
||||||
|
* Copyright (C) 2012 jascha@ja-s.de
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package de.jaschastarke.minecraft.worldguard;
|
||||||
|
|
||||||
|
import static de.jaschastarke.minecraft.utils.Locale.L;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
|
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
|
||||||
|
import de.jaschastarke.minecraft.utils.Util;
|
||||||
|
|
||||||
|
public class CCommand implements CommandExecutor {
|
||||||
|
public enum Action {
|
||||||
|
FLAG,
|
||||||
|
INFO
|
||||||
|
}
|
||||||
|
|
||||||
|
private CRegionManager rm;
|
||||||
|
private JavaPlugin plugin;
|
||||||
|
private WorldGuardPlugin wg;
|
||||||
|
|
||||||
|
public CCommand(JavaPlugin plugin, CRegionManager mgr, WorldGuardPlugin wg) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.rm = mgr;
|
||||||
|
this.wg = wg;
|
||||||
|
}
|
||||||
|
public CCommand(JavaPlugin plugin, CRegionManager mgr) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.rm = mgr;
|
||||||
|
this.wg = (WorldGuardPlugin) plugin.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (args.length < 2) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!sender.hasPermission("limitedcreative.regions")) {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + "exception.command.lackingpermission");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player player = sender instanceof Player ? (Player) sender : null;
|
||||||
|
World world = null;
|
||||||
|
Action act;
|
||||||
|
String rid;
|
||||||
|
try {
|
||||||
|
act = Action.valueOf(args[0].toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String[] wr = args[1].split("#");
|
||||||
|
if (wr.length == 2) {
|
||||||
|
world = plugin.getServer().getWorld(wr[0]);
|
||||||
|
rid = wr[1];
|
||||||
|
} else {
|
||||||
|
rid = args[1];
|
||||||
|
if (player != null) {
|
||||||
|
world = player.getWorld();
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.world_not_found"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
RegionManager mgr = wg.getGlobalRegionManager().get(world);
|
||||||
|
ProtectedRegion region = mgr.getRegion(rid);
|
||||||
|
if (region == null) {
|
||||||
|
if (rid.equalsIgnoreCase("__global__")) {
|
||||||
|
region = new GlobalProtectedRegion(rid);
|
||||||
|
mgr.addRegion(region);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.region_not_found"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CRegion reg = rm.world(world).region(region);
|
||||||
|
|
||||||
|
switch (act) {
|
||||||
|
case INFO:
|
||||||
|
onInfo(sender, player, reg);
|
||||||
|
return true;
|
||||||
|
case FLAG:
|
||||||
|
onFlag(sender, player, reg, args);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onInfo(CommandSender sender, Player player, CRegion region) {
|
||||||
|
String[] args = new String[]{"info", region.getWorld().getName(), region.getProtectedRegion().getId()};
|
||||||
|
wg.onCommand(sender, wg.getCommand("region"), "/region", args);
|
||||||
|
|
||||||
|
StringBuilder list = new StringBuilder();
|
||||||
|
for (FlagValue data : region.getFlags()) {
|
||||||
|
if (list.length() > 0)
|
||||||
|
list.append(", ");
|
||||||
|
list.append(data.getFlag().getName());
|
||||||
|
list.append(": ");
|
||||||
|
list.append(data.getValue().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN + L("command.worldguard.additional_flags") + ": " + list.toString());
|
||||||
|
}
|
||||||
|
private void onFlag(CommandSender sender, Player player, CRegion region, String[] args) {
|
||||||
|
if (args.length < 3) {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.no_flag_given"));
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.available_flags") + ": " + FlagList.getStringListAvailableFlags(sender));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String flagName = args[2];
|
||||||
|
Flag<?> flag = FlagList.getFlag(flagName);
|
||||||
|
if (flag == null) {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.unknown_flag") + ": " + flagName);
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.available_flags") + ": " + FlagList.getStringListAvailableFlags(sender));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String value = null;
|
||||||
|
if (args.length > 3)
|
||||||
|
value = Util.join(args, 3);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (value != null) {
|
||||||
|
region.setFlag(flag, flag.parseInput(wg, sender, value));
|
||||||
|
} else {
|
||||||
|
region.setFlag(flag, null);
|
||||||
|
}
|
||||||
|
} catch (InvalidFlagFormat e) {
|
||||||
|
sender.sendMessage(ChatColor.DARK_RED + e.getLocalizedMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sender.sendMessage(L("command.worldguard.flag_set", flag.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.jaschastarke.minecraft.regions;
|
package de.jaschastarke.minecraft.worldguard;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -24,7 +24,8 @@ import org.bukkit.World;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
import de.jaschastarke.minecraft.regions.CRegionManager.CWorld;
|
|
||||||
|
import de.jaschastarke.minecraft.worldguard.CRegionManager.CWorld;
|
||||||
|
|
||||||
public class CRegion {
|
public class CRegion {
|
||||||
private ProtectedRegion region;
|
private ProtectedRegion region;
|
|
@ -15,7 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.jaschastarke.minecraft.regions;
|
package de.jaschastarke.minecraft.worldguard;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
|
@ -15,7 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.jaschastarke.minecraft.regions;
|
package de.jaschastarke.minecraft.worldguard;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -15,7 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.jaschastarke.minecraft.regions;
|
package de.jaschastarke.minecraft.worldguard;
|
||||||
|
|
||||||
import com.sk89q.worldguard.protection.flags.Flag;
|
import com.sk89q.worldguard.protection.flags.Flag;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package de.jaschastarke.minecraft.regions;
|
package de.jaschastarke.minecraft.worldguard;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
Loading…
Reference in a new issue