- fixed localization encoding (again)
 - Bench-Block now also blocks Villagers and Anvils
 - Interacting with specific blocks is now also blocked cross regions
This commit is contained in:
Jascha Starke 2012-12-07 20:03:15 +01:00
parent e726509472
commit 679978a561
8 changed files with 72 additions and 10 deletions

View file

@ -90,7 +90,7 @@ limit:
button: false
# BlockWorkbenches
# When enabled also blocks usage of workbenches like chests (so the creative player never can see his inventar).
# When enabled also blocks usage of workbenches, anvils and vendor-villagers like chests.
# default: false
workbench: false

View file

@ -13,9 +13,9 @@ basic:
command:
player: Spieler
switch:
survival: ÿndert den Spiel-Modus des Charakters zu ÿberleben
creative: ÿndert den Spiel-Modus des Charakters zu Kreativ
adventure: ÿndert den Spiel-Modus des Charakters zu Abenteuer
survival: Ändert den Spiel-Modus des Charakters zu Überleben
creative: Ändert den Spiel-Modus des Charakters zu Kreativ
adventure: Ändert den Spiel-Modus des Charakters zu Abenteuer
config:
overview: "[Einstellung] - liste durch weglassen"
settings: "Verfügbare Einstellungen: "
@ -57,10 +57,12 @@ blocked:
button: Im Kreativ-Modus kann nicht mit Buttons interagiert werden
lever: Im Kreativ-Modus kann nicht mit Schaltern interagiert werden
survival_flying: Du solltest auf dem Boden stehen wenn du Kreativ-Regionen verlässt
outside_place: Du kannst keine Blöcke auÿerhalb von Spiel-Modus-Regionen setzen
outside_break: Du kannst keine Blöcke auÿerhalb von Spiel-Modus-Regionen zerstören
outside_place: Du kannst keine Blöcke außerhalb von Spiel-Modus-Regionen setzen
outside_break: Du kannst keine Blöcke außerhalb von Spiel-Modus-Regionen zerstören
outside_interact: Du kannst nicht mit Blöcken außerhalb von Spiel-Modus-Regionen interagieren
inside_place: Du kannst keine Blöcke innerhalb von Spiel-Modus-Regionen setzen
inside_break: Du kannst keine Blöcke innerhalb von Spiel-Modus-Regionen zerstören
inside_interact: Du kannst nicht mit Blöcken innerhalb von Spiel-Modus-Regionen interagieren
use: Du darfst diese Art von Gegenständen im Kreativ-Modus verwenden
place: Du darfst diese Art von Blöcken im Kreativ-Modus nicht setzen
break: Du darfst diese Art von Blöcken im Kreativ-Modus nicht zerstören

View file

@ -59,8 +59,10 @@ blocked:
survival_flying: You should stay on ground, when leaving a creative-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
outside_interact: You can not interact with 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
inside_interact: You can not interact with 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

View file

@ -1,6 +1,6 @@
name: LimitedCreative
main: de.jaschastarke.minecraft.limitedcreative.Core
version: 1.4.0b
version: 1.4.5a
softdepend: [WorldGuard, WorldEdit, MultiInv]
dev-url: http://dev.bukkit.org/server-mods/limited-creative/
commands:

View file

@ -3,7 +3,7 @@
<groupId>de.jaschastarke</groupId>
<artifactId>LimitedCreative</artifactId>
<name>LimitedCreative</name>
<version>1.4.0b</version>
<version>1.4.5a</version>
<url>https://github.com/possi/LimitedCreative</url>
<scm>
<connection>scm:git:git://github.com/possi/LimitedCreative.git</connection>
@ -72,8 +72,13 @@
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.4.2-R0.2</version>
<version>1.4.5-R0.2</version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.4.5-R0.2</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>

View file

@ -356,6 +356,14 @@ public class LCPlayer {
event.getPlayer().sendMessage(L("blocked.chest"));
event.setCancelled(true);
}
public void onBenchAccess(PlayerInteractEntityEvent event) {
if (!plugin.config.getBenchBlock() || event.getPlayer().getGameMode() != GameMode.CREATIVE)
return;
if (hasPermission(Perms.NoLimit.CHEST))
return;
event.getPlayer().sendMessage(L("blocked.chest"));
event.setCancelled(true);
}
public void onSignAccess(PlayerInteractEvent event) {
if (!plugin.config.getSignBlock() || event.getPlayer().getGameMode() != GameMode.CREATIVE)
return;

View file

@ -29,6 +29,7 @@ import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.StorageMinecart;
import org.bukkit.entity.Villager;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
@ -98,7 +99,7 @@ public class LimitListener implements Listener {
player.onSignAccess(event);
} else if (block.getState() instanceof Lever || block.getState() instanceof Button) {
player.onButtonAccess(event);
} else if (block.getType() == Material.WORKBENCH) {
} else if (block.getType() == Material.WORKBENCH || block.getType() == Material.ANVIL) {
player.onBenchAccess(event);
}
}
@ -120,6 +121,7 @@ public class LimitListener implements Listener {
// Temporary Solution: While dropping of Items is prevented we don't allow Interaction with ItemFrames, so no
// Items can be "placed" anywhere.
// TODO: Improve Configuration
if (!player.hasPermission(Perms.NoLimit.DROP)) {
if (entity instanceof ItemFrame && plugin.config.getRemoveDrop()) {
event.setCancelled(true);
@ -130,6 +132,8 @@ public class LimitListener implements Listener {
if (entity instanceof StorageMinecart) {
player.onChestAccess(event);
} else if (entity instanceof Villager) {
player.onBenchAccess(event);
}
}

View file

@ -6,21 +6,28 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.material.Button;
import org.bukkit.material.Lever;
import de.jaschastarke.minecraft.limitedcreative.Core;
import de.jaschastarke.minecraft.limitedcreative.LCPlayer;
import de.jaschastarke.minecraft.limitedcreative.Players;
import de.jaschastarke.minecraft.limitedcreative.listeners.MainListener;
import de.jaschastarke.minecraft.utils.Util;
import de.jaschastarke.minecraft.worldguard.ApplicableRegions;
import de.jaschastarke.minecraft.worldguard.CRegionManager;
@ -56,6 +63,40 @@ public class RegionListener implements Listener {
whenBlockBreak(event, event.getEntity().getLocation().getBlock(), eventPlayer);
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (MainListener.isCancelled(event))
return;
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
Block block = event.getClickedBlock();
if (block.getState() instanceof InventoryHolder || block.getType() == Material.ENDER_CHEST || // Workaround, Bukkit not recognize a Enderchest
block.getState() instanceof Sign ||
block.getState() instanceof Lever || block.getState() instanceof Button ||
block.getType() == Material.WORKBENCH || block.getType() == Material.ANVIL) {
LCPlayer player = Players.get(event.getPlayer());
boolean diffrent_region = rm.isDiffrentRegion(event.getPlayer(), block.getLocation());
if (player.isActiveRegionGameMode() && diffrent_region) {
// do not break outside of "gamemod-change-region" when in the region
if (rm.getRegionSet(block).getFlag(Flags.GAMEMODE, event.getPlayer()) != player.getActiveRegionGameMode()) {
event.getPlayer().sendMessage(L("blocked.outside_interact"));
event.setCancelled(true);
}
} else if (diffrent_region) {
// do not break inside of "survial-region in creative world" when outside
if (rm.getRegionSet(block).getFlag(Flags.GAMEMODE) != null) {
event.getPlayer().sendMessage(L("blocked.inside_interact"));
event.setCancelled(true);
}
}
}
}
private void whenBlockBreak(Cancellable event, Block block, Player eventPlayer) {
LCPlayer player = Players.get(eventPlayer);