diff --git a/.gitignore b/.gitignore
index 8baedc0..7961ff4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,10 @@
+/bin
+
+# Eclipse stuff
/.project
/.classpath
-/bin
/.settings
-/target
\ No newline at end of file
+/.buildpath
+
+# maven
+/target
diff --git a/README.md b/README.md
index 5f1ed53..a2127bf 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,25 @@
# Limited Creative
http://dev.bukkit.org/server-mods/limited-creative/
-There is no automated building yet, so just use "Export..." -> "JAR file" in Eclipse
+Required dependencies
+---------------------
-Dependencies:
+* [Bukkit](https://github.com/Bukkit/Bukkit)
-* [Craftbukkit](https://github.com/Bukkit/CraftBukkit)
- * which implies [Bukkit](https://github.com/Bukkit/Bukkit)
-* Optional: [WorldGuard](https://github.com/sk89q/worldguard)
- * which depends on [WorldEdit](https://github.com/sk89q/worldedit)
\ No newline at end of file
+Dependencies for optional integrations
+--------------------------------------
+
+* [WorldGuard](https://github.com/sk89q/worldguard)
+* [WorldEdit](https://github.com/sk89q/worldedit)
+* [xAuth](http://dev.bukkit.org/server-mods/xauth/)
+* [AuthMe](http://dev.bukkit.org/server-mods/authme-reloaded/)
+* [Multiverse-Core](http://dev.bukkit.org/server-mods/multiverse-core/)
+
+----
+
+To use Maven packaging
+----------------------
+
+For required development snapshots, that aren't found by maven, you have to clone the project and do:
+$ mvn install
+in the directory of the project
\ No newline at end of file
diff --git a/config.yml b/config.yml
index d593bf5..800d01a 100644
--- a/config.yml
+++ b/config.yml
@@ -105,8 +105,10 @@ limit:
# data-value, all items/blocks of this material are blocked.
# You also may add the special block "*" (better add quotes to don't break yml) which prevents the usage of ANY
# item/block.
- # default: []
- use: []
+ # default: [exp_bottle, bedrock]
+ use:
+ - EXP_BOTTLE
+ - bedrock
# BreakBlackList
# Prevents destroying of the given blocks in creative mode (and only in creative).
diff --git a/lang/en_US.yml b/lang/en_US.yml
index 6c95e07..9411b12 100644
--- a/lang/en_US.yml
+++ b/lang/en_US.yml
@@ -54,10 +54,10 @@ blocked:
button: To interact with buttons is not allowed in creative mode
lever: To interact with levers is not allowed in creative mode
survival_flying: You should stay on ground, when leaving a creative-area
- outside_creative: You can not place blocks outside of the creative-area
- outside_creative_break: You can not destroy blocks outside of the creative-area
- inside_survival: You can not place blocks inside of the survival-area
- inside_survival_break: You can not destroy blocks inside of the survival-area
+ outside_place: You can not place blocks outside of the gamemode-area
+ outside_break: You can not destroy blocks outside of the gamemode-area
+ inside_place: You can not place blocks inside of the gamemode-area
+ inside_break: You can not destroy blocks inside of the gamemode-area
use: You are not allowed to use this type of item
place: You are not allowed to place this type of block
break: You are not allowed to break this type of block
diff --git a/plugin.yml b/plugin.yml
index 5ceb9ea..375f3b7 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -1,6 +1,6 @@
name: LimitedCreative
main: de.jaschastarke.minecraft.limitedcreative.Core
-version: 1.0.1
+version: 1.2.3-beta
softdepend: [WorldGuard, WorldEdit, MultiInv]
dev-url: http://dev.bukkit.org/server-mods/limited-creative/
commands:
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..772a8f6
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,97 @@
+
+ 4.0.0
+ de.jaschastarke
+ LimitedCreative
+ LimitedCreative
+ 1.2.0-SNAPSHOT
+ https://github.com/possi/LimitedCreative
+
+ scm:git:git://github.com/possi/LimitedCreative.git
+ scm:git:git@github.com:possi/LimitedCreative.git
+ https://github.com/possi/LimitedCreative/tree/master
+
+
+
+
+ opt-dep
+ http://dl.dropbox.com/u/5023975/mvn-repo
+
+
+
+ bukkit-repo
+ http://repo.bukkit.org/content/groups/public
+
+
+
+ sk89q-mvn2
+ http://mvn2.sk89q.com/repo
+
+
+
+ onarandombox
+ http://repo.onarandombox.com/content/groups/public
+
+
+
+ ${basedir}/src
+ ${project.artifactId}
+
+
+
+ .
+ true
+ ${basedir}/
+
+ plugin.yml
+ config.yml
+
+
+
+ lang/
+ ${basedir}/lang/
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.0.2
+
+
+ 1.5
+
+
+
+
+
+
+ org.bukkit
+ bukkit
+ 1.2.5-R1.0
+
+
+ com.sk89q
+ worldguard
+ 5.5.2
+
+
+ uk.org.whoami
+ authme
+ 2.6.2
+
+
+ com.onarandombox.multiversecore
+ Multiverse-Core
+ 2.4
+
+
+ com.cypherx
+ xauth
+ 2.0.3
+
+
+
+ UTF-8
+
+
\ No newline at end of file
diff --git a/src/de/jaschastarke/minecraft/integration/Communicator.java b/src/de/jaschastarke/minecraft/integration/Communicator.java
index 111c473..283c085 100644
--- a/src/de/jaschastarke/minecraft/integration/Communicator.java
+++ b/src/de/jaschastarke/minecraft/integration/Communicator.java
@@ -40,15 +40,21 @@ public class Communicator extends AbstractCommunicator {
public boolean isCreative(World world) {
boolean creative = Bukkit.getServer().getDefaultGameMode() == GameMode.CREATIVE;
- if (isPluginEnabled("Multiverse-Core"))
- creative = MultiVerse.isCreative(world);
+ if (isMultiVerse()) {
+ GameMode tmp = MultiVerse.getGameMode(world);
+ if (tmp != null)
+ creative = tmp == GameMode.CREATIVE;
+ }
Core.debug("com: "+world.getName()+": is creative: "+creative);
return creative;
}
public GameMode getDefaultGameMode(World world) {
GameMode def = Bukkit.getServer().getDefaultGameMode();
- if (isMultiVerse())
- def = MultiVerse.getGameMode(world);
+ if (isMultiVerse()) {
+ GameMode tmp = MultiVerse.getGameMode(world);
+ if (tmp != null)
+ def = tmp;
+ }
Core.debug("com: "+world.getName()+": game mode: "+def);
return def;
}
diff --git a/src/de/jaschastarke/minecraft/integration/MultiVerse.java b/src/de/jaschastarke/minecraft/integration/MultiVerse.java
index e60185d..62875eb 100644
--- a/src/de/jaschastarke/minecraft/integration/MultiVerse.java
+++ b/src/de/jaschastarke/minecraft/integration/MultiVerse.java
@@ -22,19 +22,16 @@ import org.bukkit.GameMode;
import org.bukkit.World;
import com.onarandombox.MultiverseCore.MultiverseCore;
+import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import de.jaschastarke.minecraft.limitedcreative.Core;
public class MultiVerse implements CommunicationBridge {
-
- public static boolean isCreative(World world) {
- boolean ic = getMV().getMVWorldManager().getMVWorld(world).getGameMode() == GameMode.CREATIVE;
- Core.debug("Multiverse: "+world.getName()+": is creative: "+ic);
- return ic;
- }
-
public static GameMode getGameMode(World world) {
- GameMode gm = getMV().getMVWorldManager().getMVWorld(world).getGameMode();
+ MultiverseWorld mvWorld = getMV().getMVWorldManager().getMVWorld(world);
+ if (mvWorld == null)
+ return null;
+ GameMode gm = mvWorld.getGameMode();
Core.debug("Multiverse: "+world.getName()+": game mode: "+gm);
return gm;
}
diff --git a/src/de/jaschastarke/minecraft/integration/xAuth.java b/src/de/jaschastarke/minecraft/integration/xAuth.java
index 90915db..05bc96c 100644
--- a/src/de/jaschastarke/minecraft/integration/xAuth.java
+++ b/src/de/jaschastarke/minecraft/integration/xAuth.java
@@ -26,7 +26,7 @@ import de.jaschastarke.minecraft.limitedcreative.Core;
public class xAuth implements CommunicationBridge {
public static boolean isLoggedInNotGuest(Player player) {
- xAuthPlayer xpl = getAuth().getPlayer(player.getName());
+ xAuthPlayer xpl = getAuth().getPlyrMngr().getPlayer(player.getName());
boolean li = true;
if (!xpl.isAuthenticated())
li = false;
diff --git a/src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java b/src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java
index 7bc5310..c13e12a 100644
--- a/src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java
+++ b/src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java
@@ -62,8 +62,8 @@ public class LCPlayer {
//name = player.getName();
//touch();
- if (!this.isRegionGameMode(player.getGameMode())) {
- setPermanentGameMode(player.getGameMode());
+ if (!this.isActiveRegionGameMode(player.getGameMode())) {
+ setInPermanentGameMode(player.getGameMode());
}
}
@@ -94,24 +94,24 @@ public class LCPlayer {
}*/
private Map options = new HashMap();
- public void setRegionGameMode(final GameMode gm) {
+ public void storeActiveRegionGameMode(final GameMode gm) {
options.remove("region");
Core.debug(getName()+": set region game mode: " + gm);
Players.getOptions().setRegionGameMode(getName(), gm);
}
- private GameMode getRegionGameMode() {
+ public GameMode getActiveRegionGameMode() {
if (!options.containsKey("region")) {
options.put("region", Players.getOptions().getRegionGameMode(getName()));
}
Core.debug(getName()+": get region game mode: " + options.get("region"));
return (GameMode) options.get("region");
}
- public boolean isRegionGameMode(final GameMode gm) {
- return gm.equals(getRegionGameMode());
+ public boolean isActiveRegionGameMode(final GameMode gm) {
+ return gm.equals(getActiveRegionGameMode());
}
- public boolean isRegionGameMode() {
- return getRegionGameMode() != null;
+ public boolean isActiveRegionGameMode() {
+ return getActiveRegionGameMode() != null;
}
public boolean isOptionalRegionGameMode() {
@@ -149,26 +149,29 @@ public class LCPlayer {
Players.getOptions().setOptionalRegionGameMode(getName(), region, gm);
}
- public void setPermanentGameMode(GameMode temp) {
+ public void setInPermanentGameMode(GameMode temp) {
Core.debug(getName()+": set permanent game mode: " + temp);
if (temp != null) {
if (temp.equals(plugin.com.getDefaultGameMode(getPlayer().getWorld()))) {
temp = null;
} else {
- setRegionGameMode(null);
+ storeActiveRegionGameMode(null);
}
}
_permanent_gamemode = temp;
}
- public boolean isPermanentGameMode(GameMode temp) {
+ public boolean isInPermanentGameMode() {
+ return isInPermanentGameMode(getPlayer().getGameMode());
+ }
+ public boolean isInPermanentGameMode(GameMode temp) {
Core.debug(getName()+": get permanent game mode: " + _permanent_gamemode);
return temp.equals(_permanent_gamemode);
}
public boolean onSetGameMode(GameMode gm) {
Core.debug(getName() + " going into " + gm);
- if (isRegionGameMode()) { // change to the other gamemode as the area defines
- if (!isRegionGameMode(gm)) { // only when we are not switching to the mode the region allows
+ if (isActiveRegionGameMode()) { // change to the other gamemode as the area defines
+ if (!isActiveRegionGameMode(gm)) { // only when we are not switching to the mode the region allows
if (!plugin.config.getRegionOptional() && (!plugin.config.getPermissionsEnabled() || !hasPermission(Perms.REGIONS_BYPASS))) {
getPlayer().sendMessage(ChatColor.RED + L("exception.region.not_optional", gm.toString().toLowerCase()));
Core.debug("... denied");
@@ -179,10 +182,10 @@ public class LCPlayer {
} else {
// we are changing to the mode the region defines, thats not permanent
setOptionalRegionGameMode(null);
- setPermanentGameMode(null);
+ setInPermanentGameMode(null);
}
} else {
- setPermanentGameMode(gm); // we are not in a region, so the mode change is permanent
+ setInPermanentGameMode(gm); // we are not in a region, so the mode change is permanent
}
/*
@@ -191,6 +194,7 @@ public class LCPlayer {
if (plugin.config.getStoreEnabled()) {
if (plugin.config.getPermissionToKeepInventory() && hasPermission(Perms.KEEPINVENTORY))
return true;
+ getPlayer().closeInventory();
if (gm != GameMode.CREATIVE || plugin.config.getStoreCreative())
getInv().save();
if (gm == GameMode.CREATIVE) {
@@ -389,17 +393,16 @@ public class LCPlayer {
/*
* Attention: "Creative" stands for "the other gamemode". So true may mean, "be survival in creative world".
*/
- public void setRegionCreativeAllowed(boolean rcreative, PlayerAreaEvent area_event) {
- Core.debug(getName()+": changed region: "+rcreative+": " + area_event);
+ public void setRegionGameMode(GameMode region_gamemode, PlayerAreaEvent area_event) {
+ Core.debug(getName()+": changed region: "+region_gamemode+": " + area_event);
PlayerMoveEvent event = null;
if (area_event instanceof PlayerChangedAreaEvent)
event = ((PlayerChangedAreaEvent) area_event).getMoveEvent();
GameMode CURRENT_GAMEMODE = getPlayer().getGameMode();
GameMode DEFAULT_GAMEMODE = plugin.com.getDefaultGameMode(event != null ? event.getTo().getWorld() : getPlayer().getWorld());
- GameMode TEMPORARY_GAMEMODE = DEFAULT_GAMEMODE == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL; // the opposite
- if (rcreative && CURRENT_GAMEMODE != TEMPORARY_GAMEMODE && !this.isRegionGameMode(TEMPORARY_GAMEMODE)) {
+ if (region_gamemode != null && CURRENT_GAMEMODE != region_gamemode && !this.isActiveRegionGameMode(region_gamemode)) {
Core.debug(getName()+": entering creative area");
// 1. the region allows "the other (temporary) gamemode"
// 2. but the player is not in that mode
@@ -409,33 +412,29 @@ public class LCPlayer {
boolean isOptional = isOptionalRegionGameMode(area_event.getRegionHash(), CURRENT_GAMEMODE);
if (isOptional || checkSwitchFlight(area_event)) {
- setRegionGameMode(TEMPORARY_GAMEMODE); // have to be set, before setGameMode
+ storeActiveRegionGameMode(region_gamemode); // have to be set, before setGameMode
if (!isOptional) {
- getPlayer().setGameMode(TEMPORARY_GAMEMODE);
+ getPlayer().setGameMode(region_gamemode);
}
}
- } else if (!rcreative && getPlayer().getGameMode() == TEMPORARY_GAMEMODE && !isPermanentGameMode(TEMPORARY_GAMEMODE)) {
+ } else if (region_gamemode == null && getPlayer().getGameMode() != DEFAULT_GAMEMODE && !isInPermanentGameMode(CURRENT_GAMEMODE)) {
Core.debug(getName()+": leaving creative area");
// 1. the region doesn't allow "the other gamemode"
// 2. but the player is in that mode
// 3. and the player isn't global (permanent) in that mode
// result: change him back to default mode
if (checkSwitchFlight(area_event)) {
- setRegionGameMode(null);
- if (event == null || event.getTo().getWorld() == event.getFrom().getWorld() || !plugin.com.isMultiVerse()) {
- // do not enforce the game mode change, on world teleport, as multiverse may cancel the event afterwards
- // the world-change game-mode change is done by multiworld
- getPlayer().setGameMode(DEFAULT_GAMEMODE);
- }
+ storeActiveRegionGameMode(null);
+ getPlayer().setGameMode(DEFAULT_GAMEMODE);
}
- } else if (!rcreative && this.isRegionGameMode(TEMPORARY_GAMEMODE)) {
+ } else if (region_gamemode == null && this.isActiveRegionGameMode()) {
Core.debug(getName()+": leaving creative area (while already in default gamemode)");
// 1. the region doesn't allow "the other gamemode"
// 2. but he thinks he is still allowed
// 3. (because of else) we are not longer in that mode
// result: advise him to not longer allowed to that region
- setRegionGameMode(null);
+ storeActiveRegionGameMode(null);
}
/** At the moment, in permanent game mode, it ignores all regions
else if (this.isRegionGameMode()) {
@@ -501,7 +500,7 @@ public class LCPlayer {
}
public boolean isGameModeAllowed(GameMode gm) {
- if (plugin.config.getRegionOptional() && isRegionGameMode()) {
+ if (plugin.config.getRegionOptional() && isActiveRegionGameMode()) {
return true;
}
return false;
diff --git a/src/de/jaschastarke/minecraft/limitedcreative/regions/Flags.java b/src/de/jaschastarke/minecraft/limitedcreative/regions/Flags.java
index e921e01..1c20af6 100644
--- a/src/de/jaschastarke/minecraft/limitedcreative/regions/Flags.java
+++ b/src/de/jaschastarke/minecraft/limitedcreative/regions/Flags.java
@@ -4,21 +4,17 @@ import java.util.Arrays;
import java.util.List;
import com.sk89q.worldguard.protection.flags.Flag;
-import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
+import com.sk89q.worldguard.protection.flags.RegionGroup;
import com.sk89q.worldguard.protection.flags.StateFlag;
public final class Flags {
public static final StateFlag SPAWNDROPS = new StateFlag("spawndrops", true);
- 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 static final GameModeFlag GAMEMODE = new GameModeFlag("gamemode", RegionGroup.MEMBERS);
+
public static List> getList() {
return Arrays.asList(new Flag>[]{
SPAWNDROPS,
- CREATIVE,
- CREATIVE_GROUP
+ GAMEMODE,
});
}
}
diff --git a/src/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java b/src/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java
index d53ced9..30a305f 100644
--- a/src/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java
+++ b/src/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java
@@ -6,89 +6,41 @@ import org.bukkit.command.CommandSender;
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.RegionGroup;
/**
* Well, that was an interesting idea, but it doesn't work.
*/
-public class GameModeFlag extends Flag {
- private State def;
- private RegionGroupFlag groupFlag;
-
- public enum State {
- CREATIVE,
- SURVIVAL,
- NONE;
-
- public GameMode getGameMode() {
- return getBukkitGameMode(this);
- }
- public boolean equals (GameMode gm) {
- return gm == this.getGameMode();
- }
- public static GameMode getBukkitGameMode(State gm) {
- switch (gm) {
- case CREATIVE:
- return GameMode.CREATIVE;
- case SURVIVAL:
- return GameMode.SURVIVAL;
- default:
- return null;
- }
- }
- }
-
- public GameModeFlag(String name, State def) {
- super(name);
- this.def = def;
- }
-
- public State getDefault() {
- return def;
- }
-
- public RegionGroupFlag getGroupFlag() {
- return groupFlag;
- }
-
- public void setGroupFlag(RegionGroupFlag groupFlag) {
- this.groupFlag = groupFlag;
+public class GameModeFlag extends Flag {
+ public GameModeFlag(String name, RegionGroup defaultGroup) {
+ super(name, defaultGroup);
}
@Override
- public State parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
+ public GameMode parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
input = input.trim();
if (input.equalsIgnoreCase("creative")) {
- return State.CREATIVE;
+ return GameMode.CREATIVE;
} else if (input.equalsIgnoreCase("survival")) {
- return State.SURVIVAL;
+ return GameMode.SURVIVAL;
} else if (input.equalsIgnoreCase("none")) {
return null;
} else {
- throw new InvalidFlagFormat("Expected none/allow/deny but got '" + input + "'");
+ throw new InvalidFlagFormat("Expected survival/creative/none but got '" + input + "'");
}
}
@Override
- public State unmarshal(Object o) {
- String input = o.toString();
- if (input.equalsIgnoreCase("creative")) {
- return State.CREATIVE;
- } else if (input.equalsIgnoreCase("survival")) {
- return State.SURVIVAL;
- } else {
- return null;
+ public GameMode unmarshal(Object o) {
+ GameMode gm = null;
+ if (o != null) {
+ gm = GameMode.valueOf((String) o);
}
+ return gm;
}
-
+
@Override
- public Object marshal(State o) {
- if (o == State.CREATIVE) {
- return "allow";
- } else if (o == State.SURVIVAL) {
- return "deny";
- } else {
- return null;
- }
+ public Object marshal(GameMode o) {
+ return o == null ? null : o.name();
}
}
diff --git a/src/de/jaschastarke/minecraft/limitedcreative/regions/RegionListener.java b/src/de/jaschastarke/minecraft/limitedcreative/regions/RegionListener.java
index ae0dd72..7862940 100644
--- a/src/de/jaschastarke/minecraft/limitedcreative/regions/RegionListener.java
+++ b/src/de/jaschastarke/minecraft/limitedcreative/regions/RegionListener.java
@@ -38,31 +38,31 @@ public class RegionListener implements Listener {
private ApplicableRegions regionSet(Block block) {
return rm.getRegionSet(block);
}
+
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if (event.isCancelled())
return;
-
+
LCPlayer player = Players.get(event.getPlayer());
boolean diffrent_region = rm.isDiffrentRegion(event.getPlayer(), event.getBlock().getLocation());
- boolean creative_world = plugin.com.isCreative(event.getBlock().getWorld());
- if (player.isRegionGameMode() && diffrent_region) {
+ if (player.isActiveRegionGameMode() && diffrent_region) {
// do not break outside of "gamemod-change-region" when in the region
- if (!rm.getRegionSet(event.getBlock()).allows(Flags.CREATIVE, event.getPlayer())) {
- event.getPlayer().sendMessage(L("blocked.outside_creative_break"));
+ if (rm.getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE, event.getPlayer()) != player.getActiveRegionGameMode()) {
+ event.getPlayer().sendMessage(L("blocked.outside_break"));
event.setCancelled(true);
}
} else if (diffrent_region) {
// do not break inside of "survial-region in creative world" when outside
- if (rm.getRegionSet(event.getBlock()).allows(Flags.CREATIVE)) {
- event.getPlayer().sendMessage(L("blocked.inside_survival_break"));
+ if (rm.getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE) != null) {
+ event.getPlayer().sendMessage(L("blocked.inside_break"));
event.setCancelled(true);
}
}
- if (!creative_world) { // in survival world
- // prevent any drops for survival players in creative regions in survival worlds
- if (event.getPlayer().getGameMode() != GameMode.CREATIVE && rm.getRegionSet(event.getBlock()).allows(Flags.CREATIVE)) {
+ if (!event.isCancelled()) {
+ // prevent any drops for survival players in creative regions
+ if (event.getPlayer().getGameMode() != GameMode.CREATIVE && rm.getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE) == GameMode.CREATIVE) {
plugin.spawnblock.block(event.getBlock(), player);
}
}
@@ -76,16 +76,16 @@ public class RegionListener implements Listener {
LCPlayer player = Players.get(event.getPlayer());
boolean diffrent_region = rm.isDiffrentRegion(event.getPlayer(), event.getBlock().getLocation());
- if (player.isRegionGameMode() && diffrent_region) {
+ if (player.isActiveRegionGameMode() && diffrent_region) {
// do not build outside of "gamemod-change-region" when in the region
- if (!rm.getRegionSet(event.getBlock()).allows(Flags.CREATIVE, event.getPlayer())) {
- event.getPlayer().sendMessage(L("blocked.outside_creative"));
+ if (rm.getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE, event.getPlayer()) != player.getActiveRegionGameMode()) {
+ event.getPlayer().sendMessage(L("blocked.outside_place"));
event.setCancelled(true);
}
} else if (diffrent_region) {
// do not build inside of "survial-region in creative world" when outside
- if (rm.getRegionSet(event.getBlock()).allows(Flags.CREATIVE)) {
- event.getPlayer().sendMessage(L("blocked.inside_survival"));
+ if (rm.getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE) != null) {
+ event.getPlayer().sendMessage(L("blocked.inside_place"));
event.setCancelled(true);
}
}
@@ -93,17 +93,17 @@ public class RegionListener implements Listener {
@EventHandler
public void onPlayerChangedArea(PlayerNewLocationAreaEvent event) {
- Players.get(event.getPlayer()).setRegionCreativeAllowed(event.getRegionSet().allows(Flags.CREATIVE, event.getPlayer()), event);
+ Players.get(event.getPlayer()).setRegionGameMode(event.getRegionSet().getFlag(Flags.GAMEMODE, event.getPlayer()), event);
}
@EventHandler
public void onPlayerSetArea(PlayerSetAreaEvent event) {
- Players.get(event.getPlayer()).setRegionCreativeAllowed(event.getRegionSet().allows(Flags.CREATIVE, event.getPlayer()), event);
+ Players.get(event.getPlayer()).setRegionGameMode(event.getRegionSet().getFlag(Flags.GAMEMODE, event.getPlayer()), event);
}
@EventHandler
public void onPlayerUpdateArea(PlayerUpdateAreaEvent event) {
- Players.get(event.getPlayer()).setRegionCreativeAllowed(event.getRegionSet().allows(Flags.CREATIVE, event.getPlayer()), event);
+ Players.get(event.getPlayer()).setRegionGameMode(event.getRegionSet().getFlag(Flags.GAMEMODE, event.getPlayer()), event);
}
@EventHandler
@@ -114,11 +114,11 @@ public class RegionListener implements Listener {
Block source = event.getBlock().getRelative(event.getDirection());
Core.debug("PistonExtend "+source.getType()+" "+event.getDirection());
if (source.getType() != Material.AIR) {
- if (regionSet(source).allows(Flags.CREATIVE)) {
+ if (regionSet(source).getFlag(Flags.GAMEMODE) == GameMode.CREATIVE) {
for (int i = 1; i <= 12; i++) {
Block dest = source.getRelative(event.getDirection(), i);
Core.debug("dest "+i+": "+dest.getType());
- if (!regionSet(dest).allows(Flags.CREATIVE)) {
+ if (regionSet(dest).getFlag(Flags.GAMEMODE) != GameMode.CREATIVE) {
plugin.logger.warning(L("blocked.piston", source.getRelative(event.getDirection(), i - 1).getType().toString(), Util.toString(source.getLocation())));
event.setCancelled(true);
break;
@@ -139,19 +139,19 @@ public class RegionListener implements Listener {
Core.debug("PistonRetract "+source.getType()+" "+event.getDirection() + " " + event.isSticky());
if (event.isSticky() && source.getType() != Material.AIR) {
Core.debug("dest "+dest.getType());
- if (regionSet(source).allows(Flags.CREATIVE)) {
- if (!regionSet(dest).allows(Flags.CREATIVE)) {
+ if (regionSet(source).getFlag(Flags.GAMEMODE) == GameMode.CREATIVE) {
+ if (regionSet(dest).getFlag(Flags.GAMEMODE) != GameMode.CREATIVE) {
plugin.logger.warning(L("blocked.piston", source.getType().toString(), Util.toString(source.getLocation())));
event.setCancelled(true);
}
- } else if (regionSet(dest).allows(Flags.CREATIVE)) {
+ } else if (regionSet(dest).getFlag(Flags.GAMEMODE) == GameMode.CREATIVE) {
// source isn't creative
plugin.logger.warning(L("blocked.piston_in", source.getType().toString(), Util.toString(source.getLocation())));
event.setCancelled(true);
}
}
}
-
+
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
if (event.isCancelled())
diff --git a/src/de/jaschastarke/minecraft/worldguard/ApplicableRegions.java b/src/de/jaschastarke/minecraft/worldguard/ApplicableRegions.java
index 5785926..80e563c 100644
--- a/src/de/jaschastarke/minecraft/worldguard/ApplicableRegions.java
+++ b/src/de/jaschastarke/minecraft/worldguard/ApplicableRegions.java
@@ -49,6 +49,20 @@ public class ApplicableRegions {
contractRegionFlags();
return r;
}
+
+ public , V> V getFlag(T flag) {
+ extendRegionFlags();
+ V r = regions.getFlag(flag);
+ contractRegionFlags();
+ return r;
+ }
+
+ public , V> V getFlag(T flag, Player player) {
+ extendRegionFlags();
+ V r = regions.getFlag(flag, WorldGuardIntegration.wg.wrapPlayer(player));
+ contractRegionFlags();
+ return r;
+ }
@SuppressWarnings("unchecked")
private , V> void extendRegionFlags() {
diff --git a/src/de/jaschastarke/minecraft/worldguard/CCommand.java b/src/de/jaschastarke/minecraft/worldguard/CCommand.java
index 80a13ac..e14ac81 100644
--- a/src/de/jaschastarke/minecraft/worldguard/CCommand.java
+++ b/src/de/jaschastarke/minecraft/worldguard/CCommand.java
@@ -161,15 +161,24 @@ public class CCommand implements CommandExecutor {
return;
}
String flagName = args[2];
+ String value = null;
+
Flag> flag = FlagList.getFlag(flagName);
+
+ if (args.length > 3 && args[3].equalsIgnoreCase("-g")) {
+ flag = flag.getRegionGroupFlag();
+ if (args.length > 4)
+ value = Util.join(args, 4);
+ } else {
+ if (args.length > 3)
+ value = Util.join(args, 3);
+ }
+
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) {
diff --git a/src/de/jaschastarke/minecraft/worldguard/CListener.java b/src/de/jaschastarke/minecraft/worldguard/CListener.java
index ca956a0..84a1cc6 100644
--- a/src/de/jaschastarke/minecraft/worldguard/CListener.java
+++ b/src/de/jaschastarke/minecraft/worldguard/CListener.java
@@ -42,10 +42,11 @@ public class CListener implements Listener {
public void onPlayerMove(PlayerMoveEvent event) {
if (event.isCancelled())
return;
- //if (event.isCoarse()) { // next bukkit release will shortcut that
+
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
- || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) { // he really moved, and not just looked around
+ || event.getFrom().getBlockZ() != event.getTo().getBlockZ()
+ || !event.getFrom().getWorld().equals(event.getTo().getWorld())) { // he really moved, and not just looked around
String current_hash = CPlayer.get(event.getPlayer()).getHash();
if (current_hash == null) {
diff --git a/src/de/jaschastarke/minecraft/worldguard/CRegionManager.java b/src/de/jaschastarke/minecraft/worldguard/CRegionManager.java
index 031e9ba..ed25481 100644
--- a/src/de/jaschastarke/minecraft/worldguard/CRegionManager.java
+++ b/src/de/jaschastarke/minecraft/worldguard/CRegionManager.java
@@ -122,7 +122,7 @@ public class CRegionManager {
ConfigurationSection fs = rs.getConfigurationSection("flags");
for (Map.Entry data : fs.getValues(false).entrySet()) {
Flag> flag = FlagList.getFlag(data.getKey());
- if (flag != null) {
+ if (flag != null) { // the flag doesn't exists anymore. just ignore it without error
Object value = flag.unmarshal(data.getValue());
list.add(new FlagValue(flag, value));
}