v1.4.0a:
- Fix: Block breaking of hanging entities (Paintings/ItemFrames) in/out of gamemode-areas - German Translation (As bad as English one, even its my primary lang.) - Removed Permission-Configuration * It is now always enabled to prevent confusion. * ATTION for PEX-Admins: # You have to add a Permission "-limitedcreative.keepinventory" if # you like to keep separated Inventories even with an # '*'-Admin-Permission - Now blocking interaction with item-frames in creative when nolimit.drop is enabled (default). So people neither can drop items, nor put it in a frame to pass it to survival. - Added Command Blocker * ATTENTION: You have to update the configuration by hand to add the commands to the block-list.
This commit is contained in:
parent
f382d56df5
commit
31f670aff3
15 changed files with 311 additions and 75 deletions
43
config.yml
43
config.yml
|
@ -101,7 +101,7 @@ limit:
|
||||||
|
|
||||||
# UseBlackList
|
# UseBlackList
|
||||||
# Prevents using or placing of the given blocks in creative mode (and only in creative).
|
# Prevents using or placing of the given blocks in creative mode (and only in creative).
|
||||||
# You can use the technical name (see http://jd.bukkit.org/doxygen/d7/dd9/namespaceorg_1_1bukkit.html#ab7fa290bb19b9a830362aa88028ec80a)
|
# You can use the technical name (see http://jd.bukkit.org/doxygen/d6/d0e/enumorg_1_1bukkit_1_1Material.html)
|
||||||
# or the id of the block/item (better use the id, if you're not sure).
|
# or the id of the block/item (better use the id, if you're not sure).
|
||||||
# To prevent Lava you need to add "LAVA_BUCKET", because lava-blocks aren't "placed", therefore Lava-Buckets are
|
# To prevent Lava you need to add "LAVA_BUCKET", because lava-blocks aren't "placed", therefore Lava-Buckets are
|
||||||
# "used".
|
# "used".
|
||||||
|
@ -117,7 +117,7 @@ limit:
|
||||||
|
|
||||||
# BreakBlackList
|
# BreakBlackList
|
||||||
# Prevents destroying of the given blocks in creative mode (and only in creative).
|
# Prevents destroying of the given blocks in creative mode (and only in creative).
|
||||||
# You can use the technical name (see http://jd.bukkit.org/doxygen/d7/dd9/namespaceorg_1_1bukkit.html#ab7fa290bb19b9a830362aa88028ec80a)
|
# You can use the technical name (see http://jd.bukkit.org/doxygen/d6/d0e/enumorg_1_1bukkit_1_1Material.html)
|
||||||
# or the id of the block/item (better use the id, if you're not sure).
|
# or the id of the block/item (better use the id, if you're not sure).
|
||||||
# You may add the data separated with a colon e.g.: "WOOL:11" blocks blue wool. But be sure to put it in quotes, to
|
# You may add the data separated with a colon e.g.: "WOOL:11" blocks blue wool. But be sure to put it in quotes, to
|
||||||
# not break yml-configuration! Named data values aren't supported yet. If you don't add a data-value, all blocks
|
# not break yml-configuration! Named data values aren't supported yet. If you don't add a data-value, all blocks
|
||||||
|
@ -130,7 +130,7 @@ limit:
|
||||||
|
|
||||||
region:
|
region:
|
||||||
# RegionsEnabled
|
# RegionsEnabled
|
||||||
# Enables the Feature for "creative-regions". This Feature is automatically disabled, if the required plugin
|
# Enables the feature for "creative-regions". This Feature is automatically disabled, if the required plugin
|
||||||
# "WorldGuard" (http://dev.bukkit.org/server-mods/worldguard/) isn't found.
|
# "WorldGuard" (http://dev.bukkit.org/server-mods/worldguard/) isn't found.
|
||||||
# default: true
|
# default: true
|
||||||
enabled: true
|
enabled: true
|
||||||
|
@ -148,24 +148,27 @@ region:
|
||||||
# default: true
|
# default: true
|
||||||
remember: true
|
remember: true
|
||||||
|
|
||||||
permissions:
|
|
||||||
# PermissionsEnabled
|
|
||||||
# When enabled, the Permissions will allow selected users to ignore limitations like PvP, Chest-Block, etc.
|
|
||||||
# When not enabled, all users are treated equally.
|
|
||||||
# Note: Not all Permission, are affected by this option. So you still need the defined permissions or op, to use
|
|
||||||
# commands, even if this options is disabled!
|
|
||||||
# default: false
|
|
||||||
enabled: false
|
|
||||||
|
|
||||||
# PermissionKeepInventory
|
|
||||||
# Disables the limitedcreative.keepinventory-Permission, so you can use the separated-inventories-feature, even
|
|
||||||
# if you have a permission plugin that grants ALL permission to you.
|
|
||||||
# If Enabled, only players WITHOUT the limitedcreative.keepinventory-Permission, have separated inventories;
|
|
||||||
# Players with the permission will have the inventory, like this plugin were not installed.
|
|
||||||
# When "PermissionsEnabled" is false, the KeepInventory-Option will act like disabled, even if you set it to true.
|
|
||||||
# default: false
|
|
||||||
keepinventory: false
|
|
||||||
|
|
||||||
|
cmdblock:
|
||||||
|
# CommandBlockerEnabled
|
||||||
|
# Enables the feature for blocking certain commands in creative mode.
|
||||||
|
# default: true
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# CommandBlockerList
|
||||||
|
# Defines the list of commands that are blocked while in creative mode. The leading / isn't included. By default
|
||||||
|
# the list-item is treated as simple string as typed in by the user after the /. All commands starting with
|
||||||
|
# this string are blocked, even if more parameteres are entered by the user.
|
||||||
|
# If the first Char is ^ the entry is interpreted as a regular expression (including the ^ for begin of the string).
|
||||||
|
# Only use regular expressions if you know them.
|
||||||
|
# default: []
|
||||||
|
commands:
|
||||||
|
# - logout
|
||||||
|
# - home
|
||||||
|
# - home second
|
||||||
|
# - ^chest (one|two|three)
|
||||||
|
# - ^(lc|limitedcreative) s(urvival)?
|
||||||
|
|
||||||
|
|
||||||
# Locale (Language)
|
# Locale (Language)
|
||||||
# Uncomment the "locale: en_US"-Line, to override the locale which be used for localized messages. By default the
|
# Uncomment the "locale: en_US"-Line, to override the locale which be used for localized messages. By default the
|
||||||
|
|
68
lang/de_DE.yml
Normal file
68
lang/de_DE.yml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
basic:
|
||||||
|
loaded:
|
||||||
|
worldguard: Erfolgreich mit WorldGuard-Integration geladen
|
||||||
|
no_worldguard: Erfolgreich geladen (ohne WorldGuard)
|
||||||
|
feature:
|
||||||
|
store: Getrennte Inventare
|
||||||
|
limit: Kreativ-Einschränkungen
|
||||||
|
region: Kreativ-Regionen
|
||||||
|
conflict: Wegen eines Konfliktes mit {0} ist die Funktion {1} deaktiviert
|
||||||
|
warning:
|
||||||
|
worldguard_not_found: WorldGuard wurd enicht gefunde, dahier ist die Funktion {0} deaktiviert
|
||||||
|
# double single-quote '' because of MessageFormater to insert {0}
|
||||||
|
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
|
||||||
|
config:
|
||||||
|
overview: "[Einstellung] - liste durch weglassen"
|
||||||
|
settings: "Verfügbare Einstellungen: "
|
||||||
|
reload: Lädt das Plugin neu (funktioniert nur teilweise)
|
||||||
|
gamemode:
|
||||||
|
changed: "{0}'s Spiel-Modus wurde geändert"
|
||||||
|
no_change: Bereits in diesem Spiel-Modus
|
||||||
|
option:
|
||||||
|
done: Option geändert.
|
||||||
|
worldguard:
|
||||||
|
alias: Alias für den //region-Befehl
|
||||||
|
unknown_flag: Unbekanntes Attribut
|
||||||
|
available_flags: Verfügbare Attribute
|
||||||
|
region_not_found: Keine Region mit dieser ID gefunden
|
||||||
|
world_not_found: Es konnte keine Welt mit diesem Namen gefunden werden
|
||||||
|
no_flag_given: Es muss ein Attribut angegeben werden, dass gesetzt werden soll
|
||||||
|
no_integration: Der worldguard-Befehl ist nicht verfügbar, da WorldGuard nicht gefunden wurde
|
||||||
|
flag_set: "Das Attribut {0} wurde gesetzt"
|
||||||
|
additional_flags: Zusätzliche Attribute
|
||||||
|
cmdblock:
|
||||||
|
blocked: Dieser Befehl ist im Kreativ-Modus blockiert.
|
||||||
|
exception:
|
||||||
|
command:
|
||||||
|
lackingpermission: Kein Zugriff auf diesen Befehl
|
||||||
|
toomuchparameter: Zuviele Argumente angegeben
|
||||||
|
missingparameter: Nicht genügen Argumente angegeben
|
||||||
|
playernotfound: Spieler nicht gefunden
|
||||||
|
invalidoption: Unbkeannte Option
|
||||||
|
config:
|
||||||
|
savefail: Die Konfiguration konnte nicht gespeichert werden
|
||||||
|
material_not_found: (Konfiguration) Material mit Name/ID "{0}" wurde nicht gefunden.
|
||||||
|
storage:
|
||||||
|
load: Fehler beim Laden des Inventars. Bitte einen Admin die Option "UnsafeStorege" in LimitedCreative zu aktivieren um ungültig verzauberte Gegenstände zu erlauben
|
||||||
|
region:
|
||||||
|
not_optional: "In dieser Region kannst du nicht im folgenden Modus sein: {0}"
|
||||||
|
blocked:
|
||||||
|
chest: Zugriff auf Truhen ist im Kreativ-Modus nicht erlaubt
|
||||||
|
sign: Im Kreativ-Modus kann nicht mit Schildern interagiert werden
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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
|
||||||
|
piston: Verschieben von Block {0} aus einer Spiel-Modus-Region bei {1} wurde blockiert
|
||||||
|
piston_in: Verschieben von Block {0} in eine Spiel-Modus-Region bei {1} wurde blockiert
|
|
@ -35,6 +35,8 @@ command:
|
||||||
no_integration: The worldguard-commands are not available, because worldguard wasn't found
|
no_integration: The worldguard-commands are not available, because worldguard wasn't found
|
||||||
flag_set: "The flag {0} was set"
|
flag_set: "The flag {0} was set"
|
||||||
additional_flags: Additional flags
|
additional_flags: Additional flags
|
||||||
|
cmdblock:
|
||||||
|
blocked: This command is blocked while in creative mode.
|
||||||
exception:
|
exception:
|
||||||
command:
|
command:
|
||||||
lackingpermission: You do not have access to this command
|
lackingpermission: You do not have access to this command
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: LimitedCreative
|
name: LimitedCreative
|
||||||
main: de.jaschastarke.minecraft.limitedcreative.Core
|
main: de.jaschastarke.minecraft.limitedcreative.Core
|
||||||
version: 1.3.0c
|
version: 1.4.0a
|
||||||
softdepend: [WorldGuard, WorldEdit, MultiInv]
|
softdepend: [WorldGuard, WorldEdit, MultiInv]
|
||||||
dev-url: http://dev.bukkit.org/server-mods/limited-creative/
|
dev-url: http://dev.bukkit.org/server-mods/limited-creative/
|
||||||
commands:
|
commands:
|
||||||
|
@ -72,4 +72,7 @@ permissions:
|
||||||
default: false
|
default: false
|
||||||
limitedcreative.nolimit.break:
|
limitedcreative.nolimit.break:
|
||||||
description: Allows bypassing the "block break"-limitation
|
description: Allows bypassing the "block break"-limitation
|
||||||
default: false
|
default: false
|
||||||
|
limitedcreative.cmdblock.all:
|
||||||
|
description: Allowy bypassting the "command block"-limitation
|
||||||
|
default: op
|
||||||
|
|
10
pom.xml
10
pom.xml
|
@ -3,7 +3,7 @@
|
||||||
<groupId>de.jaschastarke</groupId>
|
<groupId>de.jaschastarke</groupId>
|
||||||
<artifactId>LimitedCreative</artifactId>
|
<artifactId>LimitedCreative</artifactId>
|
||||||
<name>LimitedCreative</name>
|
<name>LimitedCreative</name>
|
||||||
<version>1.3.0c</version>
|
<version>1.4.0a</version>
|
||||||
<url>https://github.com/possi/LimitedCreative</url>
|
<url>https://github.com/possi/LimitedCreative</url>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git://github.com/possi/LimitedCreative.git</connection>
|
<connection>scm:git:git://github.com/possi/LimitedCreative.git</connection>
|
||||||
|
@ -31,6 +31,10 @@
|
||||||
<id>onarandombox</id>
|
<id>onarandombox</id>
|
||||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>vault-repo</id>
|
||||||
|
<url>http://ci.herocraftonline.com/plugin/repository/everything</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>${basedir}/src</sourceDirectory>
|
<sourceDirectory>${basedir}/src</sourceDirectory>
|
||||||
|
@ -68,12 +72,12 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.3.1-R1.0</version>
|
<version>1.4.2-R0.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>worldguard</artifactId>
|
<artifactId>worldguard</artifactId>
|
||||||
<version>5.5.4-SNAPSHOT</version>
|
<version>5.6.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>uk.org.whoami</groupId>
|
<groupId>uk.org.whoami</groupId>
|
||||||
|
|
|
@ -32,6 +32,9 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.cmdblock.ICmdBlockEntry;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.cmdblock.RegexpBlockEntry;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.cmdblock.StringBlockEntry;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.store.InvYamlStorage;
|
import de.jaschastarke.minecraft.limitedcreative.store.InvYamlStorage;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.store.PlayerInventoryStorage;
|
import de.jaschastarke.minecraft.limitedcreative.store.PlayerInventoryStorage;
|
||||||
|
|
||||||
|
@ -53,9 +56,8 @@ public class Configuration {
|
||||||
BLOCKBENCHES("limit.workbench", false),
|
BLOCKBENCHES("limit.workbench", false),
|
||||||
REMOVEDROP("limit.remove_drops", true),
|
REMOVEDROP("limit.remove_drops", true),
|
||||||
REMOVEPICKUP("limit.remove_pickup", false),
|
REMOVEPICKUP("limit.remove_pickup", false),
|
||||||
PERMISSIONS("permissions.enabled", false),
|
|
||||||
PERM_KEEPINVENTORY("permissions.keepinventory", false),
|
|
||||||
PERM_WEPIF("permissions.wepif", true),
|
PERM_WEPIF("permissions.wepif", true),
|
||||||
|
CMDBLOCKER("cmdblocker.enabled", true),
|
||||||
DEBUG("debug", false);
|
DEBUG("debug", false);
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
@ -93,8 +95,6 @@ public class Configuration {
|
||||||
throw new IllegalArgumentException("Setting this option is not allowed");*/
|
throw new IllegalArgumentException("Setting this option is not allowed");*/
|
||||||
this.reload();
|
this.reload();
|
||||||
c.set(opt.getKey(), value);
|
c.set(opt.getKey(), value);
|
||||||
if (value && opt == Option.PERM_KEEPINVENTORY && !this.getPermissionsEnabled())
|
|
||||||
c.set(Option.PERMISSIONS.getKey(), true);
|
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,12 +153,6 @@ public class Configuration {
|
||||||
return this.getBoolean(Option.BLOCKDAMAGEMOB);
|
return this.getBoolean(Option.BLOCKDAMAGEMOB);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getPermissionsEnabled() {
|
|
||||||
return this.getBoolean(Option.PERMISSIONS);
|
|
||||||
}
|
|
||||||
public boolean getPermissionToKeepInventory() {
|
|
||||||
return this.getPermissionsEnabled() && this.getBoolean(Option.PERM_KEEPINVENTORY);
|
|
||||||
}
|
|
||||||
public boolean getWEPIFEnabled() {
|
public boolean getWEPIFEnabled() {
|
||||||
return this.getBoolean(Option.PERM_WEPIF);
|
return this.getBoolean(Option.PERM_WEPIF);
|
||||||
}
|
}
|
||||||
|
@ -291,4 +285,23 @@ public class Configuration {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getCommandBlockerEnabled() {
|
||||||
|
return this.getBoolean(Option.CMDBLOCKER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ICmdBlockEntry> _blocklist = null;
|
||||||
|
public List<ICmdBlockEntry> getCommandBlockList() {
|
||||||
|
if (_blocklist == null) {
|
||||||
|
_blocklist = new ArrayList<ICmdBlockEntry>();
|
||||||
|
for (String cmd : c.getStringList("cmdblock.commands")) {
|
||||||
|
if (cmd.startsWith("^")) {
|
||||||
|
_blocklist.add(new RegexpBlockEntry(cmd));
|
||||||
|
} else {
|
||||||
|
_blocklist.add(new StringBlockEntry(cmd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _blocklist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import de.jaschastarke.minecraft.integration.Communicator;
|
import de.jaschastarke.minecraft.integration.Communicator;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.cmdblock.CommandBlocker;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.listeners.LimitListener;
|
import de.jaschastarke.minecraft.limitedcreative.listeners.LimitListener;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.listeners.MainListener;
|
import de.jaschastarke.minecraft.limitedcreative.listeners.MainListener;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
|
import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
|
||||||
|
@ -40,6 +41,7 @@ public class Core extends JavaPlugin {
|
||||||
public Communicator com;
|
public Communicator com;
|
||||||
public static Core plugin;
|
public static Core plugin;
|
||||||
public NoBlockItemSpawn spawnblock;
|
public NoBlockItemSpawn spawnblock;
|
||||||
|
public CommandBlocker cmdblock;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
@ -55,6 +57,7 @@ public class Core extends JavaPlugin {
|
||||||
config = null;
|
config = null;
|
||||||
spawnblock = null;
|
spawnblock = null;
|
||||||
com = null;
|
com = null;
|
||||||
|
cmdblock = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -86,9 +89,14 @@ public class Core extends JavaPlugin {
|
||||||
warn(L("basic.warning.worldguard_not_found", L("basic.feature.region")));
|
warn(L("basic.warning.worldguard_not_found", L("basic.feature.region")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 4th Feature: Command Blocker
|
||||||
|
if (config.getCommandBlockerEnabled())
|
||||||
|
cmdblock = new CommandBlocker(this);
|
||||||
|
|
||||||
debug("Store: " + config.getStoreEnabled());
|
debug("Store: " + config.getStoreEnabled());
|
||||||
debug("Limit: " + config.getLimitEnabled());
|
debug("Limit: " + config.getLimitEnabled());
|
||||||
debug("Region: " + (worldguard != null));
|
debug("Region: " + (worldguard != null));
|
||||||
|
debug("CmdBlock: " + config.getCommandBlockerEnabled());
|
||||||
|
|
||||||
Commands.register(this);
|
Commands.register(this);
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ public class LCPlayer {
|
||||||
Core.debug(getName() + " going into " + gm);
|
Core.debug(getName() + " going into " + gm);
|
||||||
if (isActiveRegionGameMode()) { // change to the other gamemode as the area defines
|
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 (!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))) {
|
if (!plugin.config.getRegionOptional() && !hasPermission(Perms.REGIONS_BYPASS)) {
|
||||||
getPlayer().sendMessage(ChatColor.RED + L("exception.region.not_optional", gm.toString().toLowerCase()));
|
getPlayer().sendMessage(ChatColor.RED + L("exception.region.not_optional", gm.toString().toLowerCase()));
|
||||||
Core.debug("... denied");
|
Core.debug("... denied");
|
||||||
return false;
|
return false;
|
||||||
|
@ -192,7 +192,7 @@ public class LCPlayer {
|
||||||
* Feature 1: Separated Inventories / Storage
|
* Feature 1: Separated Inventories / Storage
|
||||||
*/
|
*/
|
||||||
if (plugin.config.getStoreEnabled()) {
|
if (plugin.config.getStoreEnabled()) {
|
||||||
if (plugin.config.getPermissionToKeepInventory() && hasPermission(Perms.KEEPINVENTORY))
|
if (hasPermission(Perms.KEEPINVENTORY))
|
||||||
return true;
|
return true;
|
||||||
getPlayer().closeInventory();
|
getPlayer().closeInventory();
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ public class LCPlayer {
|
||||||
public void onDropItem(PlayerDropItemEvent event) {
|
public void onDropItem(PlayerDropItemEvent event) {
|
||||||
Core.debug(getName() + " ("+getPlayer().getGameMode()+") drops items " + event.getItemDrop().getItemStack().getType());
|
Core.debug(getName() + " ("+getPlayer().getGameMode()+") drops items " + event.getItemDrop().getItemStack().getType());
|
||||||
if (getPlayer().getGameMode() == GameMode.CREATIVE) {
|
if (getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
if (plugin.config.getPermissionsEnabled() && hasPermission(Perms.NoLimit.DROP))
|
if (hasPermission(Perms.NoLimit.DROP))
|
||||||
return;
|
return;
|
||||||
Core.debug("removed");
|
Core.debug("removed");
|
||||||
if (plugin.config.getRemoveDrop())
|
if (plugin.config.getRemoveDrop())
|
||||||
|
@ -263,7 +263,7 @@ public class LCPlayer {
|
||||||
}
|
}
|
||||||
public void onPickupItem(PlayerPickupItemEvent event) {
|
public void onPickupItem(PlayerPickupItemEvent event) {
|
||||||
if (getPlayer().getGameMode() == GameMode.CREATIVE) {
|
if (getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
if (plugin.config.getPermissionsEnabled() && hasPermission(Perms.NoLimit.PICKUP))
|
if (hasPermission(Perms.NoLimit.PICKUP))
|
||||||
return;
|
return;
|
||||||
if (plugin.config.getBlockPickupInCreative()) {
|
if (plugin.config.getBlockPickupInCreative()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -276,7 +276,7 @@ public class LCPlayer {
|
||||||
|
|
||||||
public void onDie(EntityDeathEvent event) {
|
public void onDie(EntityDeathEvent event) {
|
||||||
if (getPlayer().getGameMode() == GameMode.CREATIVE) {
|
if (getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
if (!plugin.config.getPermissionsEnabled() || !hasPermission(Perms.NoLimit.DROP)) {
|
if (!hasPermission(Perms.NoLimit.DROP)) {
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
//getInv().storeTemp();
|
//getInv().storeTemp();
|
||||||
}
|
}
|
||||||
|
@ -297,13 +297,13 @@ public class LCPlayer {
|
||||||
// its PVP
|
// its PVP
|
||||||
Player attacker = (Player) from;
|
Player attacker = (Player) from;
|
||||||
if (attacker.getGameMode() == GameMode.CREATIVE) {
|
if (attacker.getGameMode() == GameMode.CREATIVE) {
|
||||||
if (!plugin.config.getPermissionsEnabled() || !Players.get(attacker).hasPermission(Perms.NoLimit.PVP)) {
|
if (!Players.get(attacker).hasPermission(Perms.NoLimit.PVP)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return; // skip next check
|
return; // skip next check
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getPlayer().getGameMode() == GameMode.CREATIVE) {
|
if (getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
if (!plugin.config.getPermissionsEnabled() || !hasPermission(Perms.NoLimit.PVP)) {
|
if (!hasPermission(Perms.NoLimit.PVP)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ public class LCPlayer {
|
||||||
public void onDealDamage(EntityDamageByEntityEvent event) { // deals damage
|
public void onDealDamage(EntityDamageByEntityEvent event) { // deals damage
|
||||||
if (event.getEntity() instanceof Creature) {
|
if (event.getEntity() instanceof Creature) {
|
||||||
if (getPlayer().getGameMode() == GameMode.CREATIVE && plugin.config.getMobDamageBlock()) {
|
if (getPlayer().getGameMode() == GameMode.CREATIVE && plugin.config.getMobDamageBlock()) {
|
||||||
if (!plugin.config.getPermissionsEnabled() || !hasPermission(Perms.NoLimit.MOB_DAMAGE)) {
|
if (!hasPermission(Perms.NoLimit.MOB_DAMAGE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -325,7 +325,7 @@ public class LCPlayer {
|
||||||
public void onTarget(EntityTargetEvent event) {
|
public void onTarget(EntityTargetEvent event) {
|
||||||
if (event.getEntity() instanceof Creature) {
|
if (event.getEntity() instanceof Creature) {
|
||||||
if (((Player) event.getTarget()).getGameMode() == GameMode.CREATIVE && plugin.config.getMobDamageBlock()) {
|
if (((Player) event.getTarget()).getGameMode() == GameMode.CREATIVE && plugin.config.getMobDamageBlock()) {
|
||||||
if (!plugin.config.getPermissionsEnabled() || !hasPermission(Perms.NoLimit.MOB_DAMAGE)) {
|
if (!hasPermission(Perms.NoLimit.MOB_DAMAGE)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,7 +335,7 @@ public class LCPlayer {
|
||||||
public void onChestAccess(PlayerInteractEvent event) {
|
public void onChestAccess(PlayerInteractEvent event) {
|
||||||
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
return;
|
return;
|
||||||
if (plugin.config.getPermissionsEnabled() && hasPermission(Perms.NoLimit.CHEST))
|
if (hasPermission(Perms.NoLimit.CHEST))
|
||||||
return;
|
return;
|
||||||
event.getPlayer().sendMessage(L("blocked.chest"));
|
event.getPlayer().sendMessage(L("blocked.chest"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -343,7 +343,7 @@ public class LCPlayer {
|
||||||
public void onChestAccess(PlayerInteractEntityEvent event) { // chest-minecarts are different events
|
public void onChestAccess(PlayerInteractEntityEvent event) { // chest-minecarts are different events
|
||||||
if (getPlayer().getGameMode() != GameMode.CREATIVE)
|
if (getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
return;
|
return;
|
||||||
if (plugin.config.getPermissionsEnabled() && hasPermission(Perms.NoLimit.CHEST))
|
if (hasPermission(Perms.NoLimit.CHEST))
|
||||||
return;
|
return;
|
||||||
event.getPlayer().sendMessage(L("blocked.chest"));
|
event.getPlayer().sendMessage(L("blocked.chest"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -351,7 +351,7 @@ public class LCPlayer {
|
||||||
public void onBenchAccess(PlayerInteractEvent event) {
|
public void onBenchAccess(PlayerInteractEvent event) {
|
||||||
if (!plugin.config.getBenchBlock() || event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
if (!plugin.config.getBenchBlock() || event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
return;
|
return;
|
||||||
if (plugin.config.getPermissionsEnabled() && hasPermission(Perms.NoLimit.CHEST))
|
if (hasPermission(Perms.NoLimit.CHEST))
|
||||||
return;
|
return;
|
||||||
event.getPlayer().sendMessage(L("blocked.chest"));
|
event.getPlayer().sendMessage(L("blocked.chest"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -359,7 +359,7 @@ public class LCPlayer {
|
||||||
public void onSignAccess(PlayerInteractEvent event) {
|
public void onSignAccess(PlayerInteractEvent event) {
|
||||||
if (!plugin.config.getSignBlock() || event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
if (!plugin.config.getSignBlock() || event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
return;
|
return;
|
||||||
if (plugin.config.getPermissionsEnabled() && hasPermission(Perms.NoLimit.SIGN))
|
if (hasPermission(Perms.NoLimit.SIGN))
|
||||||
return;
|
return;
|
||||||
event.getPlayer().sendMessage(L("blocked.sign"));
|
event.getPlayer().sendMessage(L("blocked.sign"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -368,12 +368,12 @@ public class LCPlayer {
|
||||||
if (!plugin.config.getButtonBlock() || event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
if (!plugin.config.getButtonBlock() || event.getPlayer().getGameMode() != GameMode.CREATIVE)
|
||||||
return;
|
return;
|
||||||
if (event.getClickedBlock().getState() instanceof Lever) {
|
if (event.getClickedBlock().getState() instanceof Lever) {
|
||||||
if (plugin.config.getPermissionsEnabled() && hasPermission(Perms.NoLimit.LEVER))
|
if (hasPermission(Perms.NoLimit.LEVER))
|
||||||
return;
|
return;
|
||||||
event.getPlayer().sendMessage(L("blocked.lever"));
|
event.getPlayer().sendMessage(L("blocked.lever"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
if (plugin.config.getPermissionsEnabled() && hasPermission(Perms.NoLimit.BUTTON))
|
if (hasPermission(Perms.NoLimit.BUTTON))
|
||||||
return;
|
return;
|
||||||
event.getPlayer().sendMessage(L("blocked.button"));
|
event.getPlayer().sendMessage(L("blocked.button"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
|
@ -65,4 +65,14 @@ public enum Perms implements IPermission {
|
||||||
return Perms.NS + SEP + NoLimit.NS + SEP + perm;
|
return Perms.NS + SEP + NoLimit.NS + SEP + perm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class CmdBlock { // not the best way, but this matches to everything in this plugin ;)
|
||||||
|
public static final String NS = "cmdblock";
|
||||||
|
|
||||||
|
public static IPermission ALL = new IPermission() {
|
||||||
|
public String toString() {
|
||||||
|
return Perms.NS + SEP + CmdBlock.NS + SEP + "all";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package de.jaschastarke.minecraft.limitedcreative.cmdblock;
|
||||||
|
|
||||||
|
import static de.jaschastarke.minecraft.utils.Locale.L;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.Core;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.LCPlayer;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.Perms;
|
||||||
|
import de.jaschastarke.minecraft.limitedcreative.Players;
|
||||||
|
|
||||||
|
public class CommandBlocker {
|
||||||
|
private Core plugin;
|
||||||
|
public CommandBlocker(Core plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(new Listener(), plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Listener implements org.bukkit.event.Listener {
|
||||||
|
@EventHandler
|
||||||
|
public void onPreCommand(PlayerCommandPreprocessEvent event) {
|
||||||
|
String cmd = event.getMessage();
|
||||||
|
if (cmd.startsWith("/")) { // just to be sure ;)
|
||||||
|
cmd = cmd.substring(1);
|
||||||
|
for (ICmdBlockEntry blockentry : plugin.config.getCommandBlockList()) {
|
||||||
|
if (blockentry.test(cmd)) {
|
||||||
|
LCPlayer player = Players.get(event.getPlayer());
|
||||||
|
if (!player.hasPermission(Perms.CmdBlock.ALL)) {
|
||||||
|
Core.debug("CmdBlock: "+event.getPlayer().getName()+": '/"+cmd+"' blocked by rule '"+blockentry.toString()+"'");
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(L("cmdblock.blocked"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package de.jaschastarke.minecraft.limitedcreative.cmdblock;
|
||||||
|
|
||||||
|
public interface ICmdBlockEntry {
|
||||||
|
public boolean test(String cmd);
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package de.jaschastarke.minecraft.limitedcreative.cmdblock;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class RegexpBlockEntry implements ICmdBlockEntry {
|
||||||
|
private Pattern rx;
|
||||||
|
public RegexpBlockEntry(String regex) {
|
||||||
|
rx = Pattern.compile(regex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(String cmd) {
|
||||||
|
return rx.matcher(cmd).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return rx.pattern();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package de.jaschastarke.minecraft.limitedcreative.cmdblock;
|
||||||
|
|
||||||
|
public class StringBlockEntry implements ICmdBlockEntry {
|
||||||
|
private String str;
|
||||||
|
public StringBlockEntry(String cmd) {
|
||||||
|
str = cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(String cmd) {
|
||||||
|
return cmd.startsWith(this.str);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,9 +25,11 @@ import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.StorageMinecart;
|
import org.bukkit.entity.StorageMinecart;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
@ -39,6 +41,7 @@ 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.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
@ -76,7 +79,7 @@ public class LimitListener implements Listener {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LCPlayer player = Players.get(event.getPlayer());
|
LCPlayer player = Players.get(event.getPlayer());
|
||||||
if (!plugin.config.getPermissionsEnabled() || !player.hasPermission(Perms.NoLimit.USE)) {
|
if (!player.hasPermission(Perms.NoLimit.USE)) {
|
||||||
if (event.getItem() != null && BlackList.isBlackListed(plugin.config.getBlockedUse(), event.getItem())) {
|
if (event.getItem() != null && BlackList.isBlackListed(plugin.config.getBlockedUse(), event.getItem())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.setUseItemInHand(Event.Result.DENY);
|
event.setUseItemInHand(Event.Result.DENY);
|
||||||
|
@ -107,16 +110,25 @@ public class LimitListener implements Listener {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LCPlayer player = Players.get(event.getPlayer());
|
LCPlayer player = Players.get(event.getPlayer());
|
||||||
if (!plugin.config.getPermissionsEnabled() || !player.hasPermission(Perms.NoLimit.USE)) {
|
if (!player.hasPermission(Perms.NoLimit.USE)) {
|
||||||
if (event.getPlayer().getItemInHand() != null && BlackList.isBlackListed(plugin.config.getBlockedUse(), event.getPlayer().getItemInHand())) {
|
if (event.getPlayer().getItemInHand() != null && BlackList.isBlackListed(plugin.config.getBlockedUse(), event.getPlayer().getItemInHand())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(L("blocked.use"));
|
event.getPlayer().sendMessage(L("blocked.use"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = event.getRightClicked();
|
Entity entity = event.getRightClicked();
|
||||||
|
|
||||||
|
// Temporary Solution: While dropping of Items is prevented we don't allow Interaction with ItemFrames, so no
|
||||||
|
// Items can be "placed" anywhere.
|
||||||
|
if (!player.hasPermission(Perms.NoLimit.DROP)) {
|
||||||
|
if (entity instanceof ItemFrame && plugin.config.getRemoveDrop()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(L("blocked.use"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (entity instanceof StorageMinecart) {
|
if (entity instanceof StorageMinecart) {
|
||||||
player.onChestAccess(event);
|
player.onChestAccess(event);
|
||||||
}
|
}
|
||||||
|
@ -168,25 +180,24 @@ public class LimitListener implements Listener {
|
||||||
Players.get(event.getPlayer()).onRespawn(event);
|
Players.get(event.getPlayer()).onRespawn(event);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
private void whenBlockBreak(Cancellable event, Block block, Player eventPlayer) {
|
||||||
if (event.isCancelled())
|
if (eventPlayer.getGameMode() == GameMode.CREATIVE) {
|
||||||
return;
|
LCPlayer player = Players.get(eventPlayer);
|
||||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
if (!player.hasPermission(Perms.NoLimit.BREAK)) {
|
||||||
LCPlayer player = Players.get(event.getPlayer());
|
if (BlackList.isBlackListed(plugin.config.getBlockedBreaks(), block)) {
|
||||||
if (!plugin.config.getPermissionsEnabled() || !player.hasPermission(Perms.NoLimit.BREAK)) {
|
|
||||||
if (BlackList.isBlackListed(plugin.config.getBlockedBreaks(), event.getBlock())) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(L("blocked.break"));
|
eventPlayer.sendMessage(L("blocked.break"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.config.getPermissionsEnabled() && player.hasPermission(Perms.NoLimit.DROP))
|
if (player.hasPermission(Perms.NoLimit.DROP))
|
||||||
return;
|
return;
|
||||||
// Prevent dropping of doors and beds when destroying the wrong part
|
// Prevent dropping of doors and beds when destroying the wrong part
|
||||||
Block block = event.getBlock();
|
|
||||||
|
// TODO: Fix, Remove, or make it god like, but this little thing is crap ;)
|
||||||
Material mat = block.getType();
|
Material mat = block.getType();
|
||||||
switch (event.getBlock().getType()) {
|
switch (block.getType()) {
|
||||||
case WOODEN_DOOR:
|
case WOODEN_DOOR:
|
||||||
mat = Material.WOOD_DOOR;
|
mat = Material.WOOD_DOOR;
|
||||||
plugin.spawnblock.block(block.getRelative(BlockFace.DOWN).getLocation(), mat);
|
plugin.spawnblock.block(block.getRelative(BlockFace.DOWN).getLocation(), mat);
|
||||||
|
@ -203,17 +214,34 @@ public class LimitListener implements Listener {
|
||||||
plugin.spawnblock.block(block.getRelative(BlockFace.WEST).getLocation(), mat);
|
plugin.spawnblock.block(block.getRelative(BlockFace.WEST).getLocation(), mat);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
plugin.spawnblock.block(event.getBlock().getLocation(), mat);
|
plugin.spawnblock.block(block.getLocation(), mat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Doesn't make sense yet, as the block always will be Air. whenBlockBreak should be changed to use Material
|
||||||
|
* instead. Maybe in the Feature.
|
||||||
|
@EventHandler
|
||||||
|
public void onHangingBreak(HangingBreakByEntityEvent event) {
|
||||||
|
if (event.getRemover() instanceof Player) {
|
||||||
|
Player eventPlayer = (Player) event.getRemover();
|
||||||
|
whenBlockBreak(event, event.getEntity().getLocation().getBlock(), eventPlayer);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
|
whenBlockBreak(event, event.getBlock(), event.getPlayer());
|
||||||
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
LCPlayer player = Players.get(event.getPlayer());
|
LCPlayer player = Players.get(event.getPlayer());
|
||||||
if (!plugin.config.getPermissionsEnabled() || !player.hasPermission(Perms.NoLimit.USE)) {
|
if (!player.hasPermission(Perms.NoLimit.USE)) {
|
||||||
if (BlackList.isBlackListed(plugin.config.getBlockedUse(), event.getBlock())) {
|
if (BlackList.isBlackListed(plugin.config.getBlockedUse(), event.getBlock())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(L("blocked.place"));
|
event.getPlayer().sendMessage(L("blocked.place"));
|
||||||
|
|
|
@ -7,6 +7,8 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
@ -14,6 +16,7 @@ import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
|
|
||||||
import de.jaschastarke.minecraft.limitedcreative.Core;
|
import de.jaschastarke.minecraft.limitedcreative.Core;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.LCPlayer;
|
import de.jaschastarke.minecraft.limitedcreative.LCPlayer;
|
||||||
|
@ -43,27 +46,38 @@ public class RegionListener implements Listener {
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
return;
|
return;
|
||||||
|
whenBlockBreak(event, event.getBlock(), event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onHangingBreak(HangingBreakByEntityEvent event) {
|
||||||
|
if (event.getRemover() instanceof Player) {
|
||||||
|
Player eventPlayer = (Player) event.getRemover();
|
||||||
|
whenBlockBreak(event, event.getEntity().getLocation().getBlock(), eventPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LCPlayer player = Players.get(event.getPlayer());
|
private void whenBlockBreak(Cancellable event, Block block, Player eventPlayer) {
|
||||||
boolean diffrent_region = rm.isDiffrentRegion(event.getPlayer(), event.getBlock().getLocation());
|
LCPlayer player = Players.get(eventPlayer);
|
||||||
|
boolean diffrent_region = rm.isDiffrentRegion(eventPlayer, block.getLocation());
|
||||||
|
|
||||||
if (player.isActiveRegionGameMode() && diffrent_region) {
|
if (player.isActiveRegionGameMode() && diffrent_region) {
|
||||||
// do not break outside of "gamemod-change-region" when in the region
|
// do not break outside of "gamemod-change-region" when in the region
|
||||||
if (rm.getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE, event.getPlayer()) != player.getActiveRegionGameMode()) {
|
if (rm.getRegionSet(block).getFlag(Flags.GAMEMODE, eventPlayer) != player.getActiveRegionGameMode()) {
|
||||||
event.getPlayer().sendMessage(L("blocked.outside_break"));
|
eventPlayer.sendMessage(L("blocked.outside_break"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (diffrent_region) {
|
} else if (diffrent_region) {
|
||||||
// do not break inside of "survial-region in creative world" when outside
|
// do not break inside of "survial-region in creative world" when outside
|
||||||
if (rm.getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE) != null) {
|
if (rm.getRegionSet(block).getFlag(Flags.GAMEMODE) != null) {
|
||||||
event.getPlayer().sendMessage(L("blocked.inside_break"));
|
eventPlayer.sendMessage(L("blocked.inside_break"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
// prevent any drops for survival players in creative regions
|
// prevent any drops for survival players in creative regions
|
||||||
if (event.getPlayer().getGameMode() != GameMode.CREATIVE && rm.getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE) == GameMode.CREATIVE) {
|
if (eventPlayer.getGameMode() != GameMode.CREATIVE && rm.getRegionSet(block).getFlag(Flags.GAMEMODE) == GameMode.CREATIVE) {
|
||||||
plugin.spawnblock.block(event.getBlock(), player);
|
plugin.spawnblock.block(block, player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue