From 08229ed4f9e955a64ac9d0faf6d95a01c5fcefb5 Mon Sep 17 00:00:00 2001 From: sk89q Date: Mon, 17 Jan 2011 00:05:35 -0800 Subject: [PATCH] Made WorldGuard write default configuration files, more friendly. Removed hMod configuration files. --- blacklist.txt | 84 ++++++++++++++ build.xml | 7 +- config.yml | 97 ++++++++++------ .../worldguard/bukkit/WorldGuardPlugin.java | 45 +++++++- worldguard-blacklist.txt | 90 --------------- worldguard.properties | 108 ------------------ worldguard.updatr | 5 - 7 files changed, 196 insertions(+), 240 deletions(-) create mode 100644 blacklist.txt delete mode 100644 worldguard-blacklist.txt delete mode 100644 worldguard.properties delete mode 100644 worldguard.updatr diff --git a/blacklist.txt b/blacklist.txt new file mode 100644 index 00000000..90821561 --- /dev/null +++ b/blacklist.txt @@ -0,0 +1,84 @@ +# +# This is the blacklist for WorldGuard. The blacklist allows you to perform +# actions depending on an item or block ID. Comments start with # and they +# are ignored so you can put your own notes. +# +# -------------------------------------------------------------------------- +# +# WARNING: +# Remember to check the compatibility spreadsheet for WorldGuard to see +# if any events or actions are currently broken in your version of Bukkit. +# +# -------------------------------------------------------------------------- +# +# Format: +# [item1,item2] +# option1=options +# event1=whatToDo1,whatToDo2,whatToDo3 +# event2=whatToDo1,whatToDo2 +# +# Example to block some ore mining and placement: +# [coalore,goldore,ironore] +# on-break=deny,log,kick +# on-place=deny,tell +# +# Options: +# - ignore-groups (comma-separated list of groups to not affect) +# - comment (message for yourself that is printed with 'log' and 'notify') +# - message (optional message to show the user instead; %s is the item name) +# +# Events: +# - on-break (when a block of this type is about to be broken) +# - on-destroy-with (the item/block held by the user while destroying) +# - on-place (a block is being placed) +# - on-use (an item like flint and steel or a bucket is being used) +# - on-interact (when a block in used (doors, chests, etc.)) +# - on-drop (an item is being dropped from the player's inventory) +# - on-acquire (an item enters a player's inventory via some method) +# +# Actions (for events): +# - deny (deny completely) +# - notify (notify admins) +# - log (log to console/file/database) +# - tell (tell a player that that's not allowed) +# - kick (kick player) +# - ban (ban player) +# +# Users with the /worldguardnotify permission will receive notifications. +# +# ------------- +# +# You can have the same block or item used in two different sections and +# they will both apply: +# +# [goldblock] +# ignore-groups=vip +# on-break=deny +# [goldblock] +# ignore-groups=admins +# on-break=tell +# +# However, some events override others. For example, if you disable both +# usage of the diamond pickaxe (with the on-destroy-with event) and +# destruction of gold blocks (with the on-break event) and a player tries +# to destroy a gold block with a diamond pickaxe, because the +# on-destroy-with event comes first, the rules for the gold block +# will not be applied (but the player will be denied nevertheless). +# +# -------------------------------------------------------------------------- +# +# Some examples follow. +# +# REMEMBER: If a line has # in front, it will be ignored. +# +# -------------------------------------------------------------------------- + +# Deny lava buckets +#[lavabucket] +#ignore-groups=admins,mods +#on-use=deny,tell + +# Deny some ore +#[coalore,goldore,ironore] +#ignore-groups=admins,mods +#on-break=notify,deny,log \ No newline at end of file diff --git a/build.xml b/build.xml index 60c186ea..08490406 100644 --- a/build.xml +++ b/build.xml @@ -32,7 +32,11 @@ + + + + @@ -52,12 +56,9 @@ - - - diff --git a/config.yml b/config.yml index b1d72136..e72b038b 100644 --- a/config.yml +++ b/config.yml @@ -1,63 +1,94 @@ -summary-on-start: true +# +# WorldGuard's configuration file +# +# About editing this file: +# - DO NOT USE TABS. You MUST use spaces or Bukkit will complain. If +# you use an editor like Notepad++ (recommended for Windows users), you +# must configure it to "replace tabs with spaces." In Notepad++, this can +# be changed in Settings > Preferences > Language Menu. +# - Don't get rid of the indents. They are indented so some entries are +# in categories (like "enforce-single-session" is in the "protection" +# category. +# - If you want to check the format of this file before putting it +# into WorldGuard, paste it into http://yaml-online-parser.appspot.com/ +# and see if it gives "ERROR:". +# - Lines starting with # are commentsand so they are ignored. +# +# WARNING: +# Remember to check the compatibility spreadsheet for WorldGuard to see +# if any features are currently broken in your version of Bukkit. +# + +summary-on-start: on + protection: - enforce-single-session: true - item-durability: true + enforce-single-session: on + item-durability: on + simulation: - classic-water: false + classic-water: off sponge: - enable: true + enable: on radius: 3 + physics: - # Doesn't work in Bukkit yet - no-physics-gravel: false - no-physics-sand: false - allow-portal-anywhere: false + no-physics-gravel: off + no-physics-sand: off + allow-portal-anywhere: off disable-water-damage-blocks: [] + ignition: - block-tnt: false - block-lighter: false + block-tnt: off + block-lighter: off + fire: - disable-all-fire-spread: false + disable-all-fire-spread: off disable-fire-spread-blocks: [] - disable-lava-fire-spread: true + disable-lava-fire-spread: on lava-spread-blocks: [] + mobs: - # Doesn't work in Bukkit yet - block-creeper-explosions: false + block-creeper-explosions: off + spawn: - # Doesn't work in Bukkit yet login-protection: 3 spawn-protection: 0 - kick-on-death: false - exact-respawn: false - teleport-to-home-on-death: false + kick-on-death: off + exact-respawn: off + teleport-to-home-on-death: off + player-damage: - # Doesn't work in Bukkit yet - disable-fall-damage: true - disable-lava-damage: true - disable-fire-damage: true - disable-drowning-damage: true - disable-suffocation-damage: true - teleport-on-suffocation: true + disable-fall-damage: on + disable-lava-damage: on + disable-fire-damage: on + disable-drowning-damage: on + disable-suffocation-damage: on + teleport-on-suffocation: on + regions: - enable: true + enable: on wand: 287 + blacklist: logging: console: - enable: true + enable: on database: - enable: false + enable: off dsn: jdbc:mysql://localhost:3306/minecraft user: root password: pass table: blacklist_events file: - enable: true + enable: on path: worldguard/logs/%Y-%m-%d.log open-files: 10 + +# Change sk89q to your name (or sk89q will be able to change regions +# on your server!). Check the documentation to see how to configure this permissions: - groups: - default: + users: + sk89q: permissions: - users: \ No newline at end of file + - /region + - /reload \ No newline at end of file diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java index f8cc4ec5..379cbee1 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java @@ -21,7 +21,10 @@ import java.io.File; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -116,6 +119,9 @@ public WorldGuardPlugin(PluginLoader pluginLoader, Server instance, folder.mkdirs(); + createDefaultConfiguration("config.yml"); + createDefaultConfiguration("blacklist.txt"); + regionLoader = new CSVDatabase(new File(folder, "regions.txt")); perms = new ConfigurationPermissionsResolver(getConfiguration()); loadConfiguration(); @@ -151,6 +157,42 @@ private void registerEvents() { private void registerEvent(Event.Type type, Listener listener, Priority priority) { getServer().getPluginManager().registerEvent(type, listener, priority, this); } + + private void createDefaultConfiguration(String name) { + File actual = new File(getDataFolder(), name); + if (!actual.exists()) { + + InputStream input = + WorldGuardPlugin.class.getResourceAsStream("/defaults/" + name); + if (input != null) { + FileOutputStream output = null; + + try { + output = new FileOutputStream(actual); + byte[] buf = new byte[8192]; + int length = 0; + while ((length = input.read(buf)) > 0) { + output.write(buf, 0, length); + } + + logger.info("WorldGuard: Default configuration file written: " + + name); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (input != null) + input.close(); + } catch (IOException e) {} + + try { + if (output != null) + output.close(); + } catch (IOException e) {} + } + } + } + } /** * Load the configuration @@ -200,6 +242,7 @@ public void loadConfiguration() { try { regionLoader.load(); regionManager.setRegions(regionLoader.getRegions()); + } catch (FileNotFoundException e) { } catch (IOException e) { logger.warning("WorldGuard: Failed to load regions: " + e.getMessage()); @@ -275,7 +318,7 @@ public void loadConfiguration() { if (disableFireSpread) { logger.log(Level.INFO, "WorldGuard: All fire spread is disabled."); } else { - if (disableFireSpreadBlocks != null) { + if (disableFireSpreadBlocks.size() > 0) { logger.log(Level.INFO, "WorldGuard: Fire spread is limited to " + disableFireSpreadBlocks.size() + " block types."); } else { diff --git a/worldguard-blacklist.txt b/worldguard-blacklist.txt deleted file mode 100644 index 813b3e5d..00000000 --- a/worldguard-blacklist.txt +++ /dev/null @@ -1,90 +0,0 @@ -# -# This is the blacklist for WorldGuard. Comments start with # and they -# are ignored so you can put your own notes. -# -# Format: -# [item1,item2] -# option1=options -# event1=whatToDo1,whatToDo2,whatToDo3 -# event2=whatToDo1,whatToDo2 -# -# Example to block ore and catch some events: -# [coalore,goldore,ironore] -# on-destroy-with=deny,log,kick -# on-place=deny,tell -# -# Options: -# - ignore-groups (comma-delimited list of groups to not affect) -# - comment (message for yourself that is printed with 'log' and 'notify') -# - message (optional message to show the user instead; %s is the item name) -# -# Events: -# - on-destroy (when a block of this type is being destroyed) -# - on-break (when a block of this type is about to be broken) -# - on-destroy-with (the item/block held by the user while destroying) -# - on-place (a block is being placed) -# - on-use (an item like a lighter is being used) -# - on-right-click (the block is right clicked -- curently INEFFECTIVE) -# - on-drop (the item is being dropped from the player's inventory) -# - on-acquire (the item enters a player's inventory via some method) -# -# Actions (for events): -# - deny (deny completely) -# - notify (notify admins) -# - log (log to console/file/database) -# - tell (tell a player that that's not allowed) -# - kick (kick player) -# - ban (ban player) -# -# With the on-acquire event, it will completely block item pick ups -# (the item will still be on the ground) if you use 'deny' but the other -# actions (notify, log, etc.) won't do anything. However, if the player -# receives the item via a different method (i.e. from a chest), all actions -# will work although the item is removed after a short delay rather than -# blocked from the beginning (as it is part client-side). -# -# Users with the /worldguardnotify permission will be receive notifications. -# -# ------------- -# -# You can have the same block or item used in two different sections and -# they will both apply: -# -# [goldblock] -# ignore-groups=vip -# on-destroy=deny -# [goldblock] -# ignore-groups=admins -# on-destroy=tell -# -# However, some events override others. For example, if you disable both -# usage of the diamond pickaxe (with the on-destroy-with event) and -# destruction of gold blocks (with the on-destroy event) and a player tries -# to destroy a gold block with a diamond pickaxe, because the -# on-destroy-with event comes first, the rules for the gold block -# will not be applied (but the player will be denied nevertheless). -# -# ------------- -# -# Some examples follow. Remember to remove # in front if you want them -# to work for you! - -# Deny lava buckets -#[lavabucket] -#ignore-groups=admins,mods -#on-use=deny,tell - -# Deny lighter usage -#[259] -#on-use=deny,tell - -# Deny some ore -#[coalore,goldore,ironore] -#ignore-groups=admins,mods -#on-destroy=notify,deny,log - -#[cobblestone] -#on-place=deny,tell,log - -#[lever] -#on-break=deny,tell \ No newline at end of file diff --git a/worldguard.properties b/worldguard.properties deleted file mode 100644 index 45d344cd..00000000 --- a/worldguard.properties +++ /dev/null @@ -1,108 +0,0 @@ -# -# WorldGuard configuration -# -# This is a starter copy of WorldGuard's configuration so you can configure -# WorldGuard right from the beginning. Copy it into your server folder -# (into where server.properties resides) and edit the file as your desire. -# - -# Display a summary of WorldGuard's core protection features (lava fire -# disable and others) when Worldguard starts up. -summary-on-start=true - -# Toggle the item durabiltiy fix -item-durability=true - -# Simulate the sponge from Classic. It removes water and prevents water from -# flowing into an area containing sponges. Use this to protect circuits -# or to assist in underwater projects. -simulate-sponge=false -sponge-radius=3 - -# Simulate classic water. Water will spread infinitely. Be aware that this -# may likely flood your server. -classic-water=false - -# Allow the placement of portal blocks anyway. -allow-portal-anywhere=false - -# Prevent gravel from falling. -no-physics-gravel=false - -# Prevent sand from falling. -no-physics-sand=false - -# Kick the older player if a player attempts to join again without first -# logging out the first instance. -enforce-single-session=true - -# List of items to destroy on drop. You can also accomplish this using -# the blacklist. -item-drop-blacklist= - -# Simple prevention -block-creepers=false -block-lighter=false -block-tnt=false - -# Login protection prevents players from getting any damage for a few -# seconds after joining the server. -login-protection=3 - -# Spawn protection prevents players from getting any damage after spawning -# (after dying). -spawn-protection=0 - -# This is an deprecated feature to fix a bug. This kicks a user once the -# player dies and attemtps to respawn. The player can then still rejoin -# and be alive. -kick-on-death=false - -# Disable various ways of damage. If you want to give someone invincibility -# or the ability to breathe under water, create the groups wg-invincible -# and wg-amphibious respectively and apply them to users as needed. -disable-fall-damage=false -disable-lava-damage=false -disable-fire-damage=false -disable-water-damage=false -disable-suffocation-damage=false - -# Teleports player when s/he is suffocating. This can be abused to get -# through ceilings. -teleport-on-suffocation=false - -# Disable fire spreading between blocks. Note that this does not prevent -# fire damage -- it only prevents fire spread. -disable-all-fire-spread=false - -# List blocks that fire should not spread to or between. Cloth and wood -# are some good examples. -disallowed-fire-spread-blocks= - -# Prevent lava from starting fires. -disable-lava-fire=true - -# List of blocks that lava is allowed to spread onto. -allowed-lava-spread-blocks= - -# List of blocks that should not be destroyed by water (Redstone wire, -# minecart tracks, flowers, etc.). -disable-water-damage-blocks= - -# Control where to log blacklist events to. You can use multiple log -# methods as you please. -log-console=true -log-database-dsn=jdbc\:mysql\://localhost\:3306/minecraft -log-database-pass= -log-database-table=blacklist_events -log-database-user=root -log-database=false -log-file-open-files=10 -log-file-path=worldguard/logs/%Y-%m-%d.log -log-file=false - -# On death options. -teleport-to-home-on-death=false -exact-respawn=false - -#EOF \ No newline at end of file diff --git a/worldguard.updatr b/worldguard.updatr deleted file mode 100644 index 092f7507..00000000 --- a/worldguard.updatr +++ /dev/null @@ -1,5 +0,0 @@ -name = WorldGuard -version = %version% -url = updatr.update.sk89q.com/worldguard.updatr -file = cloud.github.com/downloads/sk89q/worldguard/worldguard-%version%.zip -notes = \ No newline at end of file