From f80a88174cb56485c823fe27ddc7293af0f8fc63 Mon Sep 17 00:00:00 2001 From: Jascha Starke Date: Wed, 16 Jan 2013 12:33:14 +0100 Subject: [PATCH] Complete rewrite beginning: - removed any old implementation - basic modul setup - using new hook system --- lang/de_DE.yml | 69 --- lang/en_US.yml | 68 --- lang/messages.properties | 55 ++ pom.xml | 5 +- .../integration/AbstractCommunicator.java | 80 --- .../minecraft/integration/AuthMe.java | 37 -- .../integration/CommunicationBridge.java | 21 - .../minecraft/integration/Communicator.java | 65 --- .../minecraft/integration/MultiVerse.java | 42 -- .../minecraft/integration/xAuth.java | 42 -- .../minecraft/limitedcreative/BlackList.java | 80 --- .../minecraft/limitedcreative/Commands.java | 226 -------- .../limitedcreative/Configuration.java | 307 ---------- .../minecraft/limitedcreative/Core.java | 139 ----- ...mSpawn.java => FeatureBlockItemSpawn.java} | 52 +- .../minecraft/limitedcreative/Hooks.java | 36 ++ .../minecraft/limitedcreative/Inventory.java | 107 ---- .../minecraft/limitedcreative/LCPlayer.java | 524 ------------------ .../limitedcreative/LimitedCreative.java | 24 + .../limitedcreative/ModCmdBlocker.java | 12 + .../limitedcreative/ModCreativeLimits.java | 24 + .../limitedcreative/ModInventories.java | 58 ++ .../minecraft/limitedcreative/ModRegions.java | 12 + .../limitedcreative/Permissions.java | 44 ++ .../minecraft/limitedcreative/Perms.java | 84 --- .../minecraft/limitedcreative/Players.java | 82 --- .../cmdblock/CmdBlockPerms.java | 48 -- .../cmdblock/CommandBlocker.java | 41 -- .../cmdblock/ICmdBlockEntry.java | 5 - .../cmdblock/RegexpBlockEntry.java | 19 - .../cmdblock/StringBlockEntry.java | 17 - .../limitedcreative/hooks/AuthMeHooks.java | 22 + .../hooks/MultiVerseHooks.java | 38 ++ .../hooks/PlayerCheckHooker.java | 24 + .../hooks/WorldTypeHooker.java | 20 + .../limitedcreative/hooks/xAuthHooks.java | 32 ++ .../inventories/InventoryPermissions.java} | 34 +- .../inventories/PlayerListener.java | 68 +++ .../limitedcreative/limits/LimitListener.java | 251 --------- .../limitedcreative/limits/NoLimitPerms.java | 59 -- .../listeners/MainListener.java | 87 --- .../limitedcreative/regions/Flags.java | 20 - .../limitedcreative/regions/GameModeFlag.java | 48 -- .../regions/RegionListener.java | 178 ------ .../regions/WorldGuardIntegration.java | 64 --- .../limitedcreative/store/Fallback.java | 172 ------ .../limitedcreative/store/InvConfStorage.java | 111 ---- .../limitedcreative/store/InvMemStorage.java | 47 -- .../limitedcreative/store/InvYamlStorage.java | 72 --- .../store/PlayerInventoryStorage.java | 41 -- .../limitedcreative/store/PlayerOptions.java | 89 --- .../minecraft/utils/IPermission.java | 23 - .../minecraft/utils/Permissions.java | 71 --- .../worldedit/PermissionsBridge.java | 34 -- .../worldguard/ApplicableRegions.java | 100 ---- .../minecraft/worldguard/CCommand.java | 202 ------- .../minecraft/worldguard/CListener.java | 105 ---- .../minecraft/worldguard/CPlayer.java | 60 -- .../minecraft/worldguard/CRegion.java | 72 --- .../minecraft/worldguard/CRegionManager.java | 179 ------ .../minecraft/worldguard/FlagList.java | 66 --- .../minecraft/worldguard/FlagValue.java | 35 -- .../minecraft/worldguard/IRestrictedFlag.java | 24 - .../minecraft/worldguard/Integration.java | 26 - .../minecraft/worldguard/Interface.java | 61 -- .../minecraft/worldguard/Perms.java | 38 -- .../worldguard/events/PlayerAreaEvent.java | 33 -- .../events/PlayerChangedAreaEvent.java | 72 --- .../events/PlayerNewLocationAreaEvent.java | 69 --- .../worldguard/events/PlayerSetAreaEvent.java | 66 --- .../events/PlayerUpdateAreaEvent.java | 59 -- 71 files changed, 513 insertions(+), 4784 deletions(-) delete mode 100644 lang/de_DE.yml delete mode 100644 lang/en_US.yml create mode 100644 lang/messages.properties delete mode 100644 src/de/jaschastarke/minecraft/integration/AbstractCommunicator.java delete mode 100644 src/de/jaschastarke/minecraft/integration/AuthMe.java delete mode 100644 src/de/jaschastarke/minecraft/integration/CommunicationBridge.java delete mode 100644 src/de/jaschastarke/minecraft/integration/Communicator.java delete mode 100644 src/de/jaschastarke/minecraft/integration/MultiVerse.java delete mode 100644 src/de/jaschastarke/minecraft/integration/xAuth.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/BlackList.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/Commands.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/Configuration.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/Core.java rename src/de/jaschastarke/minecraft/limitedcreative/{NoBlockItemSpawn.java => FeatureBlockItemSpawn.java} (57%) create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/Hooks.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/Inventory.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/LCPlayer.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/LimitedCreative.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/ModCmdBlocker.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/ModCreativeLimits.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/ModInventories.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/ModRegions.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/Permissions.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/Perms.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/Players.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/cmdblock/CmdBlockPerms.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/cmdblock/CommandBlocker.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/cmdblock/ICmdBlockEntry.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/cmdblock/RegexpBlockEntry.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/cmdblock/StringBlockEntry.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/hooks/AuthMeHooks.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/hooks/MultiVerseHooks.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/hooks/PlayerCheckHooker.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/hooks/WorldTypeHooker.java create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/hooks/xAuthHooks.java rename src/de/jaschastarke/minecraft/{worldguard/API.java => limitedcreative/inventories/InventoryPermissions.java} (53%) create mode 100644 src/de/jaschastarke/minecraft/limitedcreative/inventories/PlayerListener.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/limits/LimitListener.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/limits/NoLimitPerms.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/listeners/MainListener.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/regions/Flags.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/regions/RegionListener.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/regions/WorldGuardIntegration.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/store/Fallback.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/store/InvConfStorage.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/store/InvMemStorage.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/store/InvYamlStorage.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/store/PlayerInventoryStorage.java delete mode 100644 src/de/jaschastarke/minecraft/limitedcreative/store/PlayerOptions.java delete mode 100644 src/de/jaschastarke/minecraft/utils/IPermission.java delete mode 100644 src/de/jaschastarke/minecraft/utils/Permissions.java delete mode 100644 src/de/jaschastarke/minecraft/worldedit/PermissionsBridge.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/ApplicableRegions.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/CCommand.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/CListener.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/CPlayer.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/CRegion.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/CRegionManager.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/FlagList.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/FlagValue.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/IRestrictedFlag.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/Integration.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/Interface.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/Perms.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/events/PlayerAreaEvent.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/events/PlayerChangedAreaEvent.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/events/PlayerNewLocationAreaEvent.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/events/PlayerSetAreaEvent.java delete mode 100644 src/de/jaschastarke/minecraft/worldguard/events/PlayerUpdateAreaEvent.java diff --git a/lang/de_DE.yml b/lang/de_DE.yml deleted file mode 100644 index 2b63eac..0000000 --- a/lang/de_DE.yml +++ /dev/null @@ -1,69 +0,0 @@ -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 - \ No newline at end of file diff --git a/lang/en_US.yml b/lang/en_US.yml deleted file mode 100644 index ad4779a..0000000 --- a/lang/en_US.yml +++ /dev/null @@ -1,68 +0,0 @@ -basic: - loaded: - worldguard: Successfully loaded with WorldGuard-Integration - no_worldguard: Successfully loaded (without WorldGuard) - feature: - store: separated inventories - limit: creative restrictions - region: creative regions - conflict: Due to conflict with the plugin {0}, the feature {1} is disabled - warning: - worldguard_not_found: WorldGuard isn''t found, the feature {0} is disabled - # double single-quote '' because of MessageFormater to insert {0} -command: - player: player - switch: - survival: Changes the game mode of a player to survival - creative: Changes the game mode of a player to creative - adventure: Changes the game mode of a player to adventure - config: - overview: "[setting] - empty for list of settings" - settings: "Available Settings: " - reload: Reloads plugin (doesn't work on update!) - gamemode: - changed: "{0}'s game mode has been changed" - no_change: Already in that game mode. - option: - done: Option changed. - worldguard: - alias: Alias for //region-command - unknown_flag: Unknown flag specified - available_flags: Available flags - region_not_found: Could not find a region by that ID - world_not_found: Could not find a world by that name - no_flag_given: You need to specify a flag to set - no_integration: The worldguard-commands are not available, because worldguard wasn't found - flag_set: "The flag {0} was set" - additional_flags: Additional flags -cmdblock: - blocked: This command is blocked while in creative mode. -exception: - command: - lackingpermission: You do not have access to this command - toomuchparameter: Too much arguments given - missingparameter: Not enough arguments given - playernotfound: Player not found - invalidoption: Unknown option - config: - savefail: Failed to write modified configuration to disk - material_not_found: (Config) Material with name/id "{0}" was not found. - storage: - load: Failed to load your Inventory. Ask your Admin to enable "UnsafeStorage" for LimitedCreative to allow invalid enchants on items - region: - not_optional: You can not be {0} in that area -blocked: - chest: Access to chests is not allowed in creative mode - sign: To interact with signs is not allowed in creative mode - 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_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 - piston: Moving {0} block out of creative area was blocked at {1} - piston_in: Moving {0} block into creative area was blocked at {1} \ No newline at end of file diff --git a/lang/messages.properties b/lang/messages.properties new file mode 100644 index 0000000..ac98793 --- /dev/null +++ b/lang/messages.properties @@ -0,0 +1,55 @@ +basic.loaded.worldguard: Successfully loaded with WorldGuard-Integration +basic.loaded.no_worldguard: Successfully loaded (without WorldGuard) +basic.feature.store: separated inventories +basic.feature.limit: creative restrictions +basic.feature.region: creative regions +basic.conflict: Due to conflict with the plugin {0}, the feature {1} is disabled +basic.warning.worldguard_not_found: WorldGuard isn't found, the feature {0} is disabled +# double single-quote '' because of MessageFormater to insert {0} + +command.player: player +command.switch.survival: Changes the game mode of a player to survival +command.switch.creative: Changes the game mode of a player to creative +command.switch.adventure: Changes the game mode of a player to adventure +command.config.overview: [setting] - empty for list of settings +command.config.settings: Available Settings: +command.config.reload: Reloads plugin (doesn't work on update!) +command.gamemode.changed: {0}'s game mode has been changed +command.gamemode.no_change: Already in that game mode. +command.option.done: Option changed. +command.worldguard.alias: Alias for //region-command +command.worldguard.unknown_flag: Unknown flag specified +command.worldguard.available_flags: Available flags +command.worldguard.region_not_found: Could not find a region by that ID +command.worldguard.world_not_found: Could not find a world by that name +command.worldguard.no_flag_given: You need to specify a flag to set +command.worldguard.no_integration: The worldguard-commands are not available, because worldguard wasn't found +command.worldguard.flag_set: "The flag {0} was set" +command.worldguard.additional_flags: Additional flags + +cmdblock.blocked: This command is blocked while in creative mode. + +exception.command.lackingpermission: You do not have access to this command +exception.command.toomuchparameter: Too much arguments given +exception.command.missingparameter: Not enough arguments given +exception.command.playernotfound: Player not found +exception.command.invalidoption: Unknown option +exception.config.savefail: Failed to write modified configuration to disk +exception.config.material_not_found: (Config) Material with name/id "{0}" was not found. +exception.storage.load: Failed to load your Inventory. Ask your Admin to enable "UnsafeStorage" for LimitedCreative to allow invalid enchants on items +exception.region.not_optional: You can not be {0} in that area + +blocked.chest: Access to chests is not allowed in creative mode +blocked.sign: To interact with signs is not allowed in creative mode +blocked.button: To interact with buttons is not allowed in creative mode +blocked.lever: To interact with levers is not allowed in creative mode +blocked.survival_flying: You should stay on ground, when leaving a creative-area +blocked.outside_place: You can not place blocks outside of the gamemode-area +blocked.outside_break: You can not destroy blocks outside of the gamemode-area +blocked.inside_place: You can not place blocks inside of the gamemode-area +blocked.inside_break: You can not destroy blocks inside of the gamemode-area +blocked.use: You are not allowed to use this type of item +blocked.place: You are not allowed to place this type of block +blocked.break: You are not allowed to break this type of block +blocked.piston: Moving {0} block out of creative area was blocked at {1} +blocked.piston_in: Moving {0} block into creative area was blocked at {1} diff --git a/pom.xml b/pom.xml index 9c051af..f020bf8 100644 --- a/pom.xml +++ b/pom.xml @@ -123,6 +123,7 @@ + de.jaschastarke.minecraft.limitedcreative.LimitedCreative WorldGuard WorldEdit @@ -132,7 +133,8 @@ http://dev.bukkit.org/server-mods/limited-creative/ - de.jaschastarke.minecraft.limitedcreative.Perms:Root + de.jaschastarke.minecraft.limitedcreative.Permissions + de.jaschastarke.minecraft.limitedcreative.inventories.InventoryPermissions @@ -149,6 +151,7 @@ shade + false de.jaschastarke:plib diff --git a/src/de/jaschastarke/minecraft/integration/AbstractCommunicator.java b/src/de/jaschastarke/minecraft/integration/AbstractCommunicator.java deleted file mode 100644 index 4f458f3..0000000 --- a/src/de/jaschastarke/minecraft/integration/AbstractCommunicator.java +++ /dev/null @@ -1,80 +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 . - */ -package de.jaschastarke.minecraft.integration; - -//import java.util.HashMap; -//import java.util.Map; - -//import org.bukkit.event.EventHandler; -//import org.bukkit.event.Listener; -/*import org.bukkit.event.server.PluginDisableEvent; -import org.bukkit.event.server.PluginEnableEvent;*/ -import org.bukkit.plugin.java.JavaPlugin; - -abstract public class AbstractCommunicator /*implements Listener*/ { - private JavaPlugin plugin; - //private Map, CommunicationBridge> bridges = new HashMap, CommunicationBridge>(); - - public AbstractCommunicator(JavaPlugin plugin) { - this.plugin = plugin; - //plugin.getServer().getPluginManager().registerEvents(this, plugin); - } - protected boolean isPluginEnabled(String plugin) { - return this.plugin.getServer().getPluginManager().isPluginEnabled(plugin); - } - /*@SuppressWarnings("unchecked") - protected T getBridge(Class cls) { - if (!bridges.containsKey(cls)) { - try { - bridges.put(cls, cls.newInstance()); - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - return (T) bridges.get(cls); - }*/ - - /*@EventHandler - public void onPluginEnable(PluginEnableEvent event) { - - } - @EventHandler - public void onPluginDisable(PluginDisableEvent event) { - - } - protected boolean isPluginEnabled(String plugin, Class cls) { - if (!bridges.containsKey(plugin)) { - if (this.plugin.getServer().getPluginManager().isPluginEnabled(plugin)) { - - } else { - bridges.put(plugin, null); - } - } - return bridges.get(plugin) != null; - } - protected - protected T whenPluginEnabled(String plugin, Class cls) { - if (isPluginEnabled(plugin)) { - - } - }*/ -} diff --git a/src/de/jaschastarke/minecraft/integration/AuthMe.java b/src/de/jaschastarke/minecraft/integration/AuthMe.java deleted file mode 100644 index d6e2d84..0000000 --- a/src/de/jaschastarke/minecraft/integration/AuthMe.java +++ /dev/null @@ -1,37 +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 . - */ -package de.jaschastarke.minecraft.integration; - -import org.bukkit.entity.Player; - -import uk.org.whoami.authme.cache.auth.PlayerCache; -import uk.org.whoami.authme.cache.limbo.LimboCache; -import de.jaschastarke.minecraft.limitedcreative.Core; - -public class AuthMe implements CommunicationBridge { - public static boolean isLoggedIn(Player player) { - boolean li = PlayerCache.getInstance().isAuthenticated(player.getName().toLowerCase()); - Core.debug("AuthMe: "+player.getName()+": logged in: "+li); - return li; - } - public static boolean isLoggedInComplete(Player player) { - boolean li = isLoggedIn(player) && LimboCache.getInstance().getLimboPlayer(player.getName().toLowerCase()) == null; - Core.debug("AuthMe: "+player.getName()+": logged in complete: "+li); - return li; - } -} diff --git a/src/de/jaschastarke/minecraft/integration/CommunicationBridge.java b/src/de/jaschastarke/minecraft/integration/CommunicationBridge.java deleted file mode 100644 index 0894ff2..0000000 --- a/src/de/jaschastarke/minecraft/integration/CommunicationBridge.java +++ /dev/null @@ -1,21 +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 . - */ -package de.jaschastarke.minecraft.integration; - -public interface CommunicationBridge { -} diff --git a/src/de/jaschastarke/minecraft/integration/Communicator.java b/src/de/jaschastarke/minecraft/integration/Communicator.java deleted file mode 100644 index 283c085..0000000 --- a/src/de/jaschastarke/minecraft/integration/Communicator.java +++ /dev/null @@ -1,65 +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 . - */ -package de.jaschastarke.minecraft.integration; - -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; - -import de.jaschastarke.minecraft.limitedcreative.Core; - -public class Communicator extends AbstractCommunicator { - public Communicator(JavaPlugin plugin) { - super(plugin); - } - - public boolean isLoggedIn(Player player) { - if (isPluginEnabled("AuthMe") && !AuthMe.isLoggedInComplete(player)) - return false; - if (isPluginEnabled("xAuth") && !xAuth.isLoggedInNotGuest(player)) - return false; - return true; - } - - public boolean isCreative(World world) { - boolean creative = Bukkit.getServer().getDefaultGameMode() == GameMode.CREATIVE; - 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()) { - GameMode tmp = MultiVerse.getGameMode(world); - if (tmp != null) - def = tmp; - } - Core.debug("com: "+world.getName()+": game mode: "+def); - return def; - } - - public boolean isMultiVerse() { - return isPluginEnabled("Multiverse-Core"); - } -} diff --git a/src/de/jaschastarke/minecraft/integration/MultiVerse.java b/src/de/jaschastarke/minecraft/integration/MultiVerse.java deleted file mode 100644 index 62875eb..0000000 --- a/src/de/jaschastarke/minecraft/integration/MultiVerse.java +++ /dev/null @@ -1,42 +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 . - */ -package de.jaschastarke.minecraft.integration; - -import org.bukkit.Bukkit; -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 GameMode getGameMode(World world) { - 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; - } - - private static MultiverseCore getMV() { - return (MultiverseCore) Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core"); - } -} diff --git a/src/de/jaschastarke/minecraft/integration/xAuth.java b/src/de/jaschastarke/minecraft/integration/xAuth.java deleted file mode 100644 index fcea1a2..0000000 --- a/src/de/jaschastarke/minecraft/integration/xAuth.java +++ /dev/null @@ -1,42 +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 . - */ -package de.jaschastarke.minecraft.integration; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import com.cypherx.xauth.xAuthPlayer; - -import de.jaschastarke.minecraft.limitedcreative.Core; - -public class xAuth implements CommunicationBridge { - public static boolean isLoggedInNotGuest(Player player) { - xAuthPlayer xpl = getAuth().getPlayerManager().getPlayer(player); - boolean li = true; - if (!xpl.isAuthenticated()) - li = false; - else if (xpl.isGuest()) - li = false; - Core.debug("xAuth: "+player.getName()+": logged in not guest: "+li); - return li; - } - - private static com.cypherx.xauth.xAuth getAuth() { - return (com.cypherx.xauth.xAuth) Bukkit.getServer().getPluginManager().getPlugin("xAuth"); - } -} diff --git a/src/de/jaschastarke/minecraft/limitedcreative/BlackList.java b/src/de/jaschastarke/minecraft/limitedcreative/BlackList.java deleted file mode 100644 index d1f963b..0000000 --- a/src/de/jaschastarke/minecraft/limitedcreative/BlackList.java +++ /dev/null @@ -1,80 +0,0 @@ -package de.jaschastarke.minecraft.limitedcreative; - -import java.util.List; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.MaterialData; - -abstract public class BlackList { - - abstract public boolean matches(Block b); - abstract public boolean matches(ItemStack item); - - public static boolean isBlackListed(List list, Block block) { - for (BlackList bl : list) { - if (bl.matches(block)) - return true; - } - return false; - } - public static boolean isBlackListed(List list, ItemStack item) { - for (BlackList bl : list) { - if (bl.matches(item)) - return true; - } - return false; - } - - public static class Some extends BlackList { - private Material mat; - private int data = -1; - public Some(Material material, int data) { - mat = material; - this.data = data; - } - public Some(Material material) { - mat = material; - } - public Some(MaterialData md) { - mat = md.getItemType(); - if (md.getData() != 0) - this.data = md.getData(); - } - public boolean matches(Block block) { - if (this.mat == null) - return true; - if (this.mat != block.getType()) - return false; - if (this.data != -1 && this.data != block.getData()) - return false; - return true; - } - public boolean matches(ItemStack item) { - if (this.mat == null) - return true; - if (this.mat != item.getType()) - return false; - if (this.data != -1) { - if (this.mat == Material.MONSTER_EGG) { - if (this.data != item.getDurability()) - return false; - } else { - if (this.data != item.getData().getData()) - return false; - } - } - return true; - } - } - - public static class All extends BlackList { - public boolean matches(Block b) { - return true; - } - public boolean matches(ItemStack item) { - return true; - } - } -} diff --git a/src/de/jaschastarke/minecraft/limitedcreative/Commands.java b/src/de/jaschastarke/minecraft/limitedcreative/Commands.java deleted file mode 100644 index 1ffc26d..0000000 --- a/src/de/jaschastarke/minecraft/limitedcreative/Commands.java +++ /dev/null @@ -1,226 +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 . - */ -package de.jaschastarke.minecraft.limitedcreative; - -import static de.jaschastarke.minecraft.limitedcreative.Core.L; -import static de.jaschastarke.bukkit.lib.permissions.PermissionManager.hasPermission; - -import java.util.Arrays; -import java.util.List; - -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import de.jaschastarke.utils.StringUtil; - -public class Commands { - private static Core plugin; - public static class MainCommandExecutor implements CommandExecutor { - - public enum Action { - C, CREATIVE, - S, SURVIVAL, - A, ADVENTURE, - E, ENABLE, - D, DISABLE, - R, REGION, - RELOAD - }; - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - Core.debug(sender.getName() + ": /" + label + " " + StringUtil.join(args)); - if (args.length > 0) { - Action act = null; - try { - act = Action.valueOf(args[0].toUpperCase()); - } catch (IllegalArgumentException e) {} - if (act != null) { - try { - switch (act) { - case C: - case CREATIVE: - this.setGameMode(GameMode.CREATIVE, sender, args); - return true; - case S: - case SURVIVAL: - this.setGameMode(GameMode.SURVIVAL, sender, args); - return true; - case A: - case ADVENTURE: - this.setGameMode(GameMode.ADVENTURE, sender, args); - return true; - case E: - case ENABLE: - this.setOption(sender, args, true); - return true; - case D: - case DISABLE: - this.setOption(sender, args, false); - return true; - case R: - case REGION: - args = Arrays.copyOfRange(args, 1, args.length); - plugin.getCommand("/region").execute(sender, "/region", args); - return true; - case RELOAD: - //plugin.getServer().getPluginManager().disablePlugin(plugin); // disable removes classloader, so re-enabling causes problems - //plugin.getServer().getPluginManager().enablePlugin(plugin); - plugin.reload(); - return true; - } - } catch (CommandException e) { - Core.debug("CommandException: "+e.getMessage()); - sender.sendMessage(ChatColor.DARK_RED + e.getLocalizedMessage()); - return true; - } - } - } - - String c = label; - StringBuilder message = new StringBuilder(); - message.append("/"+c+" s[urvival] ["+L("command.player")+"] - "+L("command.switch.survival")+"\n"); - message.append("/"+c+" c[reative] ["+L("command.player")+"] - "+L("command.switch.creative")+"\n"); - message.append("/"+c+" a[dventure] ["+L("command.player")+"] - "+L("command.switch.adventure")+"\n"); - if (hasPermission(sender, Perms.CONFIG)) { - message.append("/"+c+" e[nable] "+L("command.config.overview")+"\n"); - message.append("/"+c+" d[isable] "+L("command.config.overview")+"\n"); - message.append("/"+c+" reload "+L("command.config.reload")+"\n"); - } - if (hasPermission(sender, Perms.REGIONS)) - message.append("/"+c+" r[egion] "+L("command.worldguard.alias")+"\n"); - if (message.length() > 0) { - sender.sendMessage("Usage:"); - for (String m : message.toString().split("\n")) { - sender.sendMessage(m); - } - return true; - } - return false; - } - - private void setOption(CommandSender sender, String[] args, boolean b) throws CommandException { - if (sender instanceof Player && !hasPermission(sender, Perms.CONFIG)) { - throw new LackingPermissionException(); - } - if (args.length > 2) - throw new InvalidCommandException("exception.command.tomuchparameter"); - if (args.length < 2) { - StringBuilder str = new StringBuilder(L("command.config.settings")); - List options = Configuration.Option.getAvailableOptions(); - for (int i = 0; i < options.size(); i++) { - str.append(options.get(i).name().toLowerCase()); - if (i < options.size() - 1) - str.append(", "); - if ((i - 1) % 4 == 0) { - sender.sendMessage(str.toString()); - str = new StringBuilder(); - } - } - if (str.length() > 0) - sender.sendMessage(str.toString()); - return; - } - - Configuration.Option opt = null; - try { - opt = Configuration.Option.valueOf(args[1].toUpperCase()); - } catch (IllegalArgumentException e) { - throw new InvalidCommandException("exception.command.invalidoption"); - } - - plugin.config.set(opt, b); - sender.sendMessage(L("command.option.done")); - } - - private void setGameMode(GameMode gm, CommandSender sender, String[] args) throws CommandException { - Player target = null; - if (args.length > 2) - throw new InvalidCommandException("exception.command.tomuchparameter"); - if (args.length == 2) - target = plugin.getServer().getPlayer(args[1]); - else if (sender instanceof Player) - target = (Player) sender; - - if (target == null) { - throw new InvalidCommandException("exception.command.playernotfound"); - } else if (sender instanceof Player && sender != target && !hasPermission(sender, Perms.GM_OTHER)) { - throw new LackingPermissionException(); - } else if (target.getGameMode() != gm) { - if ((hasPermission(sender, Perms.GM)) || - Players.get(target).isGameModeAllowed(gm) || - (gm == plugin.com.getDefaultGameMode(target.getWorld()) && hasPermission(sender, Perms.GM_BACKONLY)) || - (gm == GameMode.CREATIVE && hasPermission(sender, Perms.GM_CREATIVE)) || - (gm == GameMode.SURVIVAL && hasPermission(sender, Perms.GM_SURVIVAL)) || - (gm == GameMode.ADVENTURE && hasPermission(sender, Perms.GM_ADVENTURE))) { - target.setGameMode(gm); - } else { - throw new LackingPermissionException(); - } - if (target != sender) { - sender.sendMessage(L("command.gamemode.changed", target.getName())); - } - } else { - sender.sendMessage(L("command.gamemode.no_change")); - } - } - - } - - public static class NotAvailableCommandExecutor implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - sender.sendMessage(ChatColor.DARK_RED + L("command.worldguard.no_integration")); - return true; - } - - } - - public static void register(Core pplugin) { - plugin = pplugin; - plugin.getCommand("limitedcreative").setExecutor(new MainCommandExecutor()); - if (plugin.worldguard == null) { - plugin.getCommand("/region").setExecutor(new NotAvailableCommandExecutor()); - } - } - - abstract static public class CommandException extends Exception { - private static final long serialVersionUID = 1L; - - public CommandException(String s) {super(s);} - - @Override - public String getLocalizedMessage() { - return L(super.getLocalizedMessage()); - } - } - public static class InvalidCommandException extends CommandException { - private static final long serialVersionUID = 1L; - - public InvalidCommandException(String s) {super(s);} - } - public static class LackingPermissionException extends CommandException { - private static final long serialVersionUID = 1L; - - public LackingPermissionException() {super("exception.command.lackingpermission");} - } -} diff --git a/src/de/jaschastarke/minecraft/limitedcreative/Configuration.java b/src/de/jaschastarke/minecraft/limitedcreative/Configuration.java deleted file mode 100644 index 0148bfb..0000000 --- a/src/de/jaschastarke/minecraft/limitedcreative/Configuration.java +++ /dev/null @@ -1,307 +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 . - */ -package de.jaschastarke.minecraft.limitedcreative; - -import static de.jaschastarke.minecraft.limitedcreative.Core.L; -import static de.jaschastarke.utils.StringUtil.copyFile; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.bukkit.Material; -import org.bukkit.configuration.ConfigurationSection; -import org.bukkit.configuration.file.FileConfiguration; -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.PlayerInventoryStorage; - -public class Configuration { - private FileConfiguration c; - private File file; - public static Core plugin; - - public enum Option { - STORECREATIVE("store.creative", true), - CREATIVEARMOR("store.armor.enabled", true), - ADVENTUREINV("store.adventure", false), - REGION_OPTIONAL("region.optional", true), - REGION_REMEMBER("region.remember", false), - BLOCKPICKUP("limit.pickup", true), - BLOCKSIGN("limit.sign", true), - BLOCKBUTTON("limit.button", false), - BLOCKDAMAGEMOB("limit.damagemob", false), - BLOCKBENCHES("limit.workbench", false), - REMOVEDROP("limit.remove_drops", true), - REMOVEPICKUP("limit.remove_pickup", false), - PERM_WEPIF("permissions.wepif", true), - CMDBLOCKER("cmdblocker.enabled", true), - DEBUG("debug", false); - - private String key; - private boolean _default; - private Option(String key, boolean def) { - this.key = key; - this._default = def; - } - public String getKey() { - return key; - } - public boolean getDefault() { - return _default; - } - public static List