Compare commits

...
7 Commits
10 changed files with 177 additions and 39 deletions

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
1.1.1
- Fixed redstone wire dropping wood blocks with the block lag fix.
- The block lag fix now consults other plugins so that ALL protection
mechanisms and plugins should work.
1.1
- Added block lag fix.
1.0
- Initial release.
+3 -3
View File
@@ -5,11 +5,11 @@ This plugin requires Hey0's server modification.
1. Create a "plugins" folder inside your "bin" folder.
2. Copy WorldProtect.jar into "plugins".
2. Copy WorldGuard.jar into "plugins".
3. Add "WorldProtect" to the "plugins" line of your server.properties file.
3. Add "WorldGuard" to the "plugins" line of your server.properties file.
If it's not already there, add the line. The line should look like this:
plugins=WorldProtect
plugins=WorldGuard
If you have multiple plugins, separate plugin names with commas.
+10 -7
View File
@@ -1,11 +1,11 @@
WorldProtect
WorldGuard
Copyright (c) 2010 sk89q <http://www.sk89q.com>
Licensed under the GNU Lesser General Public License v3
Introduction
------------
WorldProtect has a number of features, any of which you can choose to
WorldGuard has a number of features, any of which you can choose to
use or not:
- Enforce only one session for a player on a server (can't login twice).
@@ -25,14 +25,14 @@ use or not:
- Log the use, destruction, and/or placement of some blocks/items.
- Kick for the use, destruction, and/or placement of some blocks.
hMod is required as WorldProtect is a plugin for hMod.
hMod is required as WorldGuard is a plugin for hMod.
Configuration
-------------
A "worldprotect.properties" will be created the first the time that you load
WorldProtect on your server. You can either restart your server or use
/reloadplugin WorldProtect to reload the configuraton file after editing it.
A "worldguard.properties" will be created the first the time that you load
WorldGuard on your server. You can either restart your server or use
/reloadplugin WorldGuard to reload the configuraton file after editing it.
- classic-water (def. false)
Toggle use of classic water. Be foreward that your world may be
@@ -100,8 +100,11 @@ WorldProtect on your server. You can either restart your server or use
to disable this feature. Enabling disable-all-fire-spread will
override this function.
- block-lag-fix (def. false)
Attempts to fix block lag.
Blacklists
----------
Edit the included worldprotect-blacklist.txt file and follow the
Edit the included worldguard-blacklist.txt file and follow the
instructions inside.
+1 -1
View File
@@ -1,2 +1,2 @@
Manifest-Version: 1.0
WorldProtect-Version: 1.0
WorldGuard-Version: 1.1.1
+3 -3
View File
@@ -1,6 +1,6 @@
// $Id$
/*
* WorldProtect
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
@@ -37,7 +37,7 @@ public class BlacklistEntry {
/**
* Logger.
*/
private static final Logger logger = Logger.getLogger("WorldProtect.Blacklist");
private static final Logger logger = Logger.getLogger("WorldGuard.Blacklist");
/**
* List of groups to not affect.
*/
@@ -142,7 +142,7 @@ public class BlacklistEntry {
public void notifyAdmins(String str) {
for (Player player : etc.getServer().getPlayerList()) {
if (player.canUseCommand("/wprotectalerts")) {
player.sendMessage(Colors.LightPurple + "WorldProtect: " + str);
player.sendMessage(Colors.LightPurple + "WorldGuard: " + str);
}
}
}
+15 -9
View File
@@ -1,6 +1,6 @@
// $Id$
/*
* WorldProtect
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
@@ -29,16 +29,22 @@ import java.io.*;
*
* @author sk89q
*/
public class WorldProtect extends Plugin {
public class WorldGuard extends Plugin {
/**
* Logger.
*/
private static final Logger logger = Logger.getLogger("Minecraft.WorldProtect");
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
/**
* Listener for the plugin system.
*/
private static final WorldProtectListener listener =
new WorldProtectListener();
private WorldGuardListener listener;
/**
* Initialize the plugin.
*/
public WorldGuard() {
listener = new WorldGuardListener(this);
}
/**
* Initializes the plugin.
@@ -70,7 +76,7 @@ public class WorldProtect extends Plugin {
public void enable() {
listener.loadConfiguration();
logger.log(Level.INFO, "WorldProtect version " + getVersion() + " loaded");
logger.log(Level.INFO, "WorldGuard version " + getVersion() + " loaded");
}
/**
@@ -82,18 +88,18 @@ public class WorldProtect extends Plugin {
}
/**
* Get the WorldProtect version.
* Get the WorldGuard version.
*
* @return
*/
private String getVersion() {
try {
String classContainer = WorldProtect.class.getProtectionDomain()
String classContainer = WorldGuard.class.getProtectionDomain()
.getCodeSource().getLocation().toString();
URL manifestUrl = new URL("jar:" + classContainer + "!/META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(manifestUrl.openStream());
Attributes attrib = manifest.getMainAttributes();
String ver = (String)attrib.getValue("WorldProtect-Version");
String ver = (String)attrib.getValue("WorldGuard-Version");
return ver != null ? ver : "(unavailable)";
} catch (IOException e) {
return "(unknown)";
@@ -1,6 +1,6 @@
// $Id$
/*
* WorldProtect
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
@@ -27,8 +27,10 @@ import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Random;
import java.io.*;
import com.sk89q.worldprotect.*;
import com.sk89q.worldguard.*;
import java.util.logging.FileHandler;
/**
@@ -36,15 +38,28 @@ import java.util.logging.FileHandler;
*
* @author sk89q
*/
public class WorldProtectListener extends PluginListener {
public class WorldGuardListener extends PluginListener {
/**
* Logger.
*/
private static final Logger logger = Logger.getLogger("Minecraft.WorldProtect");
private static final Logger logger = Logger.getLogger("Minecraft.WorldGuard");
/**
* Random number generator.
*/
private static Random rand = new Random();
/**
* Plugin host.
*/
private WorldGuard plugin;
/**
* Properties file for CraftBook.
*/
private PropertiesFile properties = new PropertiesFile("worldprotect.properties");
private PropertiesFile properties = new PropertiesFile("worldguard.properties");
/**
* List of blocks to remove when possible.
*/
private LinkedList<int[]> blockRemoveQueue = new LinkedList<int[]>();
private boolean enforceOneSession;
private boolean blockCreepers;
@@ -53,11 +68,21 @@ public class WorldProtectListener extends PluginListener {
private boolean preventLavaFire;
private boolean disableAllFire;
private boolean simulateSponge;
private boolean blockLagFix;
private Set<Integer> fireNoSpreadBlocks;
private Set<Integer> allowedLavaSpreadOver;
private boolean classicWater;
private Map<Integer,BlacklistEntry> blacklist;
/**
* Construct the listener.
*
* @param plugin
*/
public WorldGuardListener(WorldGuard plugin) {
this.plugin = plugin;
}
/**
* Convert a comma-delimited list to a set of integers.
*
@@ -80,7 +105,7 @@ public class WorldProtectListener extends PluginListener {
if (id != 0) {
result.add(id);
} else {
logger.log(Level.WARNING, "WorldProtect: Unknown block name: "
logger.log(Level.WARNING, "WorldGuard: Unknown block name: "
+ item);
}
}
@@ -105,17 +130,18 @@ public class WorldProtectListener extends PluginListener {
allowedLavaSpreadOver = toBlockIDSet(properties.getString("allowed-lava-spread-blocks", ""));
classicWater = properties.getBoolean("classic-water", false);
simulateSponge = properties.getBoolean("simulate-sponge", false);
blockLagFix = properties.getBoolean("block-lag-fix", false);
try {
blacklist = loadBlacklist(new File("worldprotect-blacklist.txt"));
blacklist = loadBlacklist(new File("worldguard-blacklist.txt"));
} catch (FileNotFoundException e) {
logger.log(Level.WARNING, "WorldProtect blacklist does not exist.");
logger.log(Level.WARNING, "WorldGuard blacklist does not exist.");
} catch (IOException e) {
logger.log(Level.WARNING, "Could not load WorldProtect blacklist: "
logger.log(Level.WARNING, "Could not load WorldGuard blacklist: "
+ e.getMessage());
}
Logger blacklistLogger = Logger.getLogger("WorldProtect.Blacklist");
Logger blacklistLogger = Logger.getLogger("WorldGuard.Blacklist");
blacklistLogger.setUseParentHandlers(false);
for (Handler handler : blacklistLogger.getHandlers()) {
blacklistLogger.removeHandler(handler);
@@ -180,6 +206,11 @@ public class WorldProtectListener extends PluginListener {
BlacklistEntry entry = blacklist.get(itemInHand);
if (entry != null) {
if (!entry.onRightClick(itemInHand, player)) {
// Water/lava bucket fix
if (itemInHand == 326 || itemInHand == 327) {
blockPlaced.setType(0);
blockPlaced.update();
}
return true;
}
}
@@ -196,6 +227,8 @@ public class WorldProtectListener extends PluginListener {
* @return
*/
public boolean onBlockDestroy(Player player, Block block) {
int type = block.getType();
if (blacklist != null) {
BlacklistEntry entry = blacklist.get(player.getItemInHand());
if (entry != null) {
@@ -211,6 +244,73 @@ public class WorldProtectListener extends PluginListener {
}
}
}
if (blockLagFix
&& type != 64 // Wooden door
&& type != 71 // Iron door
&& type != 77 // Stone button
&& type != 69 // Lever
&& type != 7 // Bedrock
&& type != 51 // Fire
&& type != 46 // TNT
&& type != 59 // Crops
&& type != 62 // Burning furnace
&& type != 50 // Torch
&& type != 75 // Redstone torch
&& type != 76 // Redstone torch
&& canDestroyBlock(player, block)) {
if (block.getStatus() == 3) {
int dropped = type;
int count = 1;
if (type == 1) { dropped = 4; } // Stone
else if (type == 2) { dropped = 3; } // Grass
else if (type == 16) { dropped = 263; } // Coal ore
else if (type == 18) { // Leaves
if (rand.nextDouble() > 0.95) {
dropped = 6;
} else {
dropped = 0;
}
}
else if (type == 47) { dropped = 0; } // Bookshelves
else if (type == 52) { dropped = 0; } // Mob spawner
else if (type == 53) { dropped = 5; } // Wooden stairs
else if (type == 55) { dropped = 331; } // Redstone wire
else if (type == 56) { dropped = 264; } // Diamond ore
else if (type == 60) { dropped = 3; } // Soil
else if (type == 63) { dropped = 323; } // Sign post
else if (type == 67) { dropped = 4; } // Cobblestone stairs
else if (type == 68) { dropped = 323; } // Wall sign
else if (type == 73) { dropped = 331; count = 4; } // Redstone ore
else if (type == 74) { dropped = 331; count = 4; } // Glowing redstone ore
else if (type == 75) { dropped = 76; count = 4; } // Redstone torch
else if (type == 79) { dropped = 0; count = 4; } // Ice
else if (type == 82) { dropped = 337; count = 4; } // Clay
else if (type == 83) { dropped = 338; count = 4; } // Reed
else if (type == 89) { dropped = 348; } // Lightstone
etc.getServer().setBlockAt(0, block.getX(), block.getY(), block.getZ());
if (dropped > 0) {
for (int i = 0; i < count; i++) {
etc.getServer().dropItem(block.getX(), block.getY(), block.getZ(),
dropped, i);
}
// Drop flint with gravel
if (type == 13) {
if (rand.nextDouble() > 0.95) {
etc.getServer().dropItem(block.getX(), block.getY(), block.getZ(),
318, 1);
}
}
}
}
return true;
}
return false;
}
@@ -336,6 +436,25 @@ public class WorldProtectListener extends PluginListener {
BlacklistEntry.forgetPlayer(player);
}
/**
* Checks if a block can be destroyed.
*
* @param player
* @param block
* @return
*/
public boolean canDestroyBlock(Player player, Block block) {
plugin.toggleEnabled(); // Prevent infinite loop
try {
return !(Boolean)etc.getLoader().callHook(PluginLoader.Hook.BLOCK_DESTROYED,
new Object[]{ player.getUser(), block });
} catch (Throwable t) {
return true;
} finally {
plugin.toggleEnabled();
}
}
/**
* Load the blacklist.
*
@@ -376,7 +495,7 @@ public class WorldProtectListener extends PluginListener {
} catch (NumberFormatException e) {
id = etc.getDataSource().getItem(item.trim());
if (id == 0) {
logger.log(Level.WARNING, "WorldProtect: Unknown block name: "
logger.log(Level.WARNING, "WorldGuard: Unknown block name: "
+ item);
break;
}
@@ -1,6 +1,6 @@
// $Id$
/*
* WorldProtect
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldprotect;
package com.sk89q.worldguard;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;
@@ -1,6 +1,6 @@
// $Id$
/*
* WorldProtect
* WorldGuard
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
*
* This program is free software: you can redistribute it and/or modify
@@ -17,7 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldprotect;
package com.sk89q.worldguard;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -1,5 +1,5 @@
#
# This is the blacklist for WorldProtect. Comments start with # and they
# This is the blacklist for WorldGuard. Comments start with # and they
# are ignored so you can put your own notes.
#
# Format: