Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41daebb629 | ||
|
|
b496e88557 | ||
|
|
7c0e10d058 | ||
|
|
1d72447096 | ||
|
|
01e93a642e | ||
|
|
696ae7c967 | ||
|
|
b28202f1cb | ||
|
|
601e15db5a | ||
|
|
f30b413b46 | ||
|
|
a9c4a81abe | ||
|
|
d619ed5798 | ||
|
|
e94a9bf68f | ||
|
|
257c12e727 | ||
|
|
8b3eaa70fb | ||
|
|
c96bb890b4 | ||
|
|
8192a1962a | ||
|
|
80df9c6aa4 | ||
|
|
8073089da4 | ||
|
|
23e7d4a8bb | ||
|
|
0e1e92df13 | ||
|
|
d13f0b9191 | ||
|
|
aa2bffbd00 | ||
|
|
a456d67528 | ||
|
|
95f074342c | ||
|
|
74016bf93e | ||
|
|
3f8bac582c | ||
|
|
6b57e58d63 | ||
|
|
19aa20537d | ||
|
|
cf31df35ec | ||
|
|
6d39ce7240 | ||
|
|
0f3c1b94d7 | ||
|
|
13cc6736e2 | ||
|
|
64629bd878 | ||
|
|
e42be555b1 | ||
|
|
c62c5f5cae | ||
|
|
313bdbd8bf | ||
|
|
765b606e18 | ||
|
|
c0be685846 | ||
|
|
133e4c2c78 | ||
|
|
b7e91ac6d0 |
No files matched your search
@@ -1,3 +1,44 @@
|
||||
1.8.1
|
||||
- Fixed NullPointerException.
|
||||
|
||||
1.8
|
||||
- Updated for Minecraft beta.
|
||||
- Blacklist hooks have CHANGED. The new hooks are work better. on-create has
|
||||
been replaced with on-place (for block placement) and on-use
|
||||
(for item usage, light buckets and lighters). The old on-use is now
|
||||
on-right-click although it currently does nothing.
|
||||
- Added coordinates to blacklist file logger.
|
||||
- Added suffocation damage prevention.
|
||||
|
||||
1.7.1
|
||||
- Updated for v0.2.8.
|
||||
|
||||
1.7
|
||||
- Updated for v0.2.6_02 and hMod b129.
|
||||
- Added option to prevent water from damaging particular blocks
|
||||
(Redstone wire, Minecart tracks, etc.). See disable-water-damage-blocks.
|
||||
- /reload WorldGuard should now reload WorldGuard's configuration.
|
||||
- Added wg-invincible and wg-amphibious groups that let you give certain
|
||||
players invincibility or underwater breathing.
|
||||
- Added the ability to disable fall, water, lava, and/or fire damage.
|
||||
- Water/lava bucket blocking should now be more reliable.
|
||||
- Added /stack (alias /;) commands to stack items in your inventory into
|
||||
piles up to 64 items in size. Even unstackable items like signs can be
|
||||
stacked.
|
||||
- /god mode should now let you gain health.
|
||||
- /god mode should now work more reliably.
|
||||
- Caught an error message for when the configuration file does not exist.
|
||||
|
||||
1.6
|
||||
- Added spawn protection that prevents damage when a player spawns.
|
||||
- Added login protection that prevents damage when a player joins.
|
||||
- Added /god. /god can be used on others, provided that the /godother
|
||||
permission is set for the command's user.
|
||||
|
||||
1.5.1
|
||||
- Removed the 'java.lang.NoSuchMethodError: Item.setDamage(I)V' error
|
||||
generated.
|
||||
|
||||
1.5
|
||||
- Removed the block lag fix.
|
||||
- WorldGuard now conditionally loads features so you can use any up-to-date
|
||||
|
||||
+41
-3
@@ -13,20 +13,20 @@ use or not:
|
||||
- Block TNT explosions.
|
||||
- Block lighters from setting fires.
|
||||
- Block all fires.
|
||||
- Disable fall damage, lava damage, fire damage, and/or water damage.
|
||||
- Allow fire but prevent it from burning certain blocks.
|
||||
- Prevent lava from starting fires.
|
||||
- Restrict lava spreading to only some block types.
|
||||
- Simulate classic-esque water by letting water infinitely expand in
|
||||
area (only if there is a block underneath).
|
||||
- Prevent water from destroying blocks like Redstone wire and flowers.
|
||||
- Simulate the function of the sponge from Minecraft Classic.
|
||||
- Notify admins, block, log, kick or ban for the use of certain block types
|
||||
or items.
|
||||
- Temporarily stop fire globally with some commands.
|
||||
- Destroy tools on drop to alleviate the durability cheat.
|
||||
- OR just fix the durability bug. *Requires special version of hMod
|
||||
- Prevent gravel and sand from falling. *Requires special version of hMod
|
||||
- Prevent gravel and sand from falling.
|
||||
- Allow portal blocks to be placed anywhere.
|
||||
*Requires special version of hMod
|
||||
|
||||
hMod is required as WorldGuard is a plugin for hMod.
|
||||
|
||||
@@ -112,6 +112,10 @@ unsupported by your version of hMod.
|
||||
to disable this feature. Enabling disable-all-fire-spread will
|
||||
override this function.
|
||||
|
||||
- disable-water-damage-blocks (no default)
|
||||
List of blocks that should not be destroyed by water (Redstone wire,
|
||||
minecart tracks, flowers, etc.).
|
||||
|
||||
- item-drop-blacklist (no default)
|
||||
List of block names/IDs to destroy on drop. This can alleviate the
|
||||
durability cheat that allows you to drop your tools to fix their
|
||||
@@ -119,6 +123,23 @@ unsupported by your version of hMod.
|
||||
this is an easier way to do it (this way also prints a more
|
||||
friendly message than if you used the 'tell' action of the blacklist).
|
||||
|
||||
- login-protection (def. 3)
|
||||
Number of seconds to keep a player invincible when the player joins.
|
||||
|
||||
- spawn-protection (def. 0)
|
||||
Number of seconds to keep a player invincible when the player spawns.
|
||||
This does not apply to players joining the server.
|
||||
|
||||
- kick-on-death (def. false)
|
||||
Kick players when they die (and respawn). This is to work around the
|
||||
issues of invisible players when players die.
|
||||
|
||||
- disable-fall-damage (def. false)
|
||||
- disable-lava-damage (def. false)
|
||||
- disable-fire-damage (def. false)
|
||||
- disable-water-damage (def. false)
|
||||
Disable various types of damage.
|
||||
|
||||
- log-console (def. true)
|
||||
For blacklist log actions, print to console.
|
||||
|
||||
@@ -182,6 +203,12 @@ Commands
|
||||
WorldGuard. Note that disabling fire does not disable fire damage
|
||||
but fire at least won't spread.
|
||||
|
||||
- /god
|
||||
Toggles your invincibility. Players must have permission to use "/god"
|
||||
to be able to use this command. You can also use this command to
|
||||
toggle the invincibility of others although you must have the
|
||||
"/godother" permission.
|
||||
|
||||
Server Commands
|
||||
---------------
|
||||
|
||||
@@ -200,6 +227,17 @@ certain rules apply to only some groups.
|
||||
Edit the included worldguard-blacklist.txt file and follow the
|
||||
instructions inside. The file comes with the download for WorldGuard.
|
||||
|
||||
Other Features
|
||||
--------------
|
||||
|
||||
To give someone invincibility every time s/he joins the server, create
|
||||
a wg-invincible group and add the group to the user or have the user's
|
||||
group inherit this group.
|
||||
|
||||
To give someone the ability to breathe under water, create
|
||||
a wg-amphibious group and add the group to the user or have the user's
|
||||
group inherit this group.
|
||||
|
||||
Thanks
|
||||
------
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
<project name="WorldGuard" default="dist" basedir=".">
|
||||
<description>WorldGuard fixes bugs with Minecraft SMP and provides for
|
||||
protection.</description>
|
||||
|
||||
<property name="src.dir" location="src"/>
|
||||
<property name="build.dir" location="build"/>
|
||||
<property name="dist.dir" location="dist"/>
|
||||
<property name="release.dir" location="release"/>
|
||||
<property name="lib.dir" location="lib"/>
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${build.dir}"/>
|
||||
</target>
|
||||
|
||||
<!-- Compile the source files -->
|
||||
<target name="compile" depends="init">
|
||||
<javac srcdir="${src.dir}" deprecation="true" includeantruntime="true" destdir="${build.dir}" debug="true">
|
||||
<classpath>
|
||||
<fileset dir="${lib.dir}">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</classpath>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- Build the .jar -->
|
||||
<target name="jar" depends="compile">
|
||||
<mkdir dir="${dist.dir}"/>
|
||||
<manifest file="manifest.mf" mode="replace">
|
||||
<attribute name="Implementation-Title" value="WorldGuard"/>
|
||||
<attribute name="Implementation-Version" value="${version}"/>
|
||||
<attribute name="WorldGuard-Version" value="${version}"/>
|
||||
<attribute name="Class-Path" value="WorldGuard.jar"/>
|
||||
</manifest>
|
||||
<jar jarfile="${dist.dir}/WorldGuard.jar" basedir="${build.dir}" manifest="manifest.mf"/>
|
||||
</target>
|
||||
|
||||
<!-- Create the .jar -->
|
||||
<target name="dist">
|
||||
<property name="version" value="nightly"/>
|
||||
<antcall target="jar"/>
|
||||
</target>
|
||||
|
||||
<!-- Build a release -->
|
||||
<target name="release">
|
||||
<input message="Enter version:" addproperty="version"/>
|
||||
<antcall target="jar"/>
|
||||
<delete dir="${release.dir}"/>
|
||||
<mkdir dir="${release.dir}"/>
|
||||
<copy todir="${release.dir}">
|
||||
<fileset dir="."/>
|
||||
<globmapper from="*.txt" to="*.txt"/>
|
||||
</copy>
|
||||
<copy file="worldguard.properties" todir="${release.dir}"/>
|
||||
<copy tofile="${release.dir}/WorldGuard.jar" file="${dist.dir}/WorldGuard.jar"/>
|
||||
<zip destfile="${release.dir}/worldguard-${version}.zip" basedir="${release.dir}" excludes="*.zip"/>
|
||||
<mkdir dir="${release.dir}/src"/>
|
||||
<copy todir="${release.dir}/src">
|
||||
<fileset dir="${src.dir}"/>
|
||||
</copy>
|
||||
<zip destfile="${release.dir}/worldguard-${version}-source.zip" basedir="${release.dir}" excludes="*.zip"/>
|
||||
</target>
|
||||
|
||||
<!-- Clean the output -->
|
||||
<target name="clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
<delete dir="${dist.dir}"/>
|
||||
<delete dir="${release.dir}"/>
|
||||
</target>
|
||||
|
||||
<!--<target name="-get-version-git" if="git-revision">
|
||||
<sequential>
|
||||
<exec executable="git" failifexecutionfails="false" outputproperty="git-revision">
|
||||
<arg value="rev-parse"/>
|
||||
<arg value="HEAD"/>
|
||||
</exec>
|
||||
<exec executable="git" outputproperty="git-revision-dirty">
|
||||
<arg value="diff"/>
|
||||
<arg value="- -shortstat"/>
|
||||
</exec>
|
||||
<condition else="dev-${git-revision}-modified" property="version" value="dev-${git-revision}">
|
||||
<equals arg1="" arg2="${git-revision-dirty}"/>
|
||||
</condition>
|
||||
</sequential>
|
||||
</target>-->
|
||||
</project>
|
||||
@@ -1,2 +0,0 @@
|
||||
Manifest-Version: 1.0
|
||||
WorldGuard-Version: 1.5
|
||||
+32
-11
@@ -141,20 +141,20 @@ public class Blacklist {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click. Returns true to let the action pass through.
|
||||
* Called on place. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onCreate(int item, Player player) {
|
||||
public boolean onPlace(int item, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(item);
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onCreate(item, player)) {
|
||||
if (!entry.onPlace(item, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
@@ -164,18 +164,39 @@ public class Blacklist {
|
||||
/**
|
||||
* Called on right click upon. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param block
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onUse(Block block, Player player) {
|
||||
public boolean onRightClick(Block block, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(block.getType());
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onUse(block, player)) {
|
||||
if (!entry.onRightClick(block, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on item use. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onUse(int item, Player player) {
|
||||
List<BlacklistEntry> entries = getEntries(item);
|
||||
if (entries == null) {
|
||||
return true;
|
||||
}
|
||||
boolean ret = true;
|
||||
for (BlacklistEntry entry : entries) {
|
||||
if (!entry.onUse(item, player)) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
@@ -345,12 +366,12 @@ public class Blacklist {
|
||||
} else if (parts[0].equalsIgnoreCase("on-left")
|
||||
|| parts[0].equalsIgnoreCase("on-destroy-with")) {
|
||||
entry.setDestroyWithActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-right")
|
||||
|| parts[0].equalsIgnoreCase("on-create")) {
|
||||
entry.setCreateActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-right-on")
|
||||
|| parts[0].equalsIgnoreCase("on-use")) {
|
||||
} else if (parts[0].equalsIgnoreCase("on-place")) {
|
||||
entry.setPlaceActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-use")) {
|
||||
entry.setUseActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-right-click")) {
|
||||
entry.setRightClickActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-drop")) {
|
||||
entry.setDropActions(parts[1].split(","));
|
||||
} else if (parts[0].equalsIgnoreCase("on-acquire")) {
|
||||
|
||||
+69
-15
@@ -55,13 +55,17 @@ public class BlacklistEntry {
|
||||
*/
|
||||
private String[] destroyWithActions;
|
||||
/**
|
||||
* List of actions to perform on right click.
|
||||
* List of actions to perform on block placement.
|
||||
*/
|
||||
private String[] createActions;
|
||||
private String[] placeActions;
|
||||
/**
|
||||
* List of actions to perform on item use.
|
||||
*/
|
||||
private String[] useActions;
|
||||
/**
|
||||
* List of actions to perform on right click upon.
|
||||
*/
|
||||
private String[] useActions;
|
||||
private String[] rightClickActions;
|
||||
/**
|
||||
* List of actions to perform on drop.
|
||||
*/
|
||||
@@ -160,17 +164,17 @@ public class BlacklistEntry {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the rightClickActions
|
||||
* @return
|
||||
*/
|
||||
public String[] getCreateActions() {
|
||||
return createActions;
|
||||
public String[] getPlaceActions() {
|
||||
return placeActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setCreateActions(String[] actions) {
|
||||
this.createActions = actions;
|
||||
public void setPlaceActions(String[] actions) {
|
||||
this.placeActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,6 +191,20 @@ public class BlacklistEntry {
|
||||
this.useActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public String[] getRightClickActions() {
|
||||
return rightClickActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
*/
|
||||
public void setRightClickActions(String[] actions) {
|
||||
this.rightClickActions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@@ -401,14 +419,14 @@ public class BlacklistEntry {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on right click. Returns true to let the action pass through.
|
||||
* Called on block placement. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onCreate(final int item, final Player player) {
|
||||
if (createActions == null) {
|
||||
public boolean onPlace(final int item, final Player player) {
|
||||
if (placeActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -416,7 +434,7 @@ public class BlacklistEntry {
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logCreateAttempt(player, item, comment);
|
||||
blacklist.getLogger().logPlaceAttempt(player, item, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You can't place " + itemName);
|
||||
@@ -433,7 +451,43 @@ public class BlacklistEntry {
|
||||
}
|
||||
};
|
||||
|
||||
return process(item, player, createActions, handler, true, false);
|
||||
return process(item, player, placeActions, handler, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on use. Returns true to let the action pass through.
|
||||
*
|
||||
* @param item
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onUse(final int item, final Player player) {
|
||||
if (useActions == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final BlacklistEntry entry = this;
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logUseAttempt(player, item, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You can't use " + itemName);
|
||||
}
|
||||
public void ban(String itemName) {
|
||||
entry.banPlayer(player, "Banned: You can't use " + itemName);
|
||||
}
|
||||
public void notifyAdmins(String itemName) {
|
||||
entry.notifyAdmins(player.getName() + " (use) " + itemName
|
||||
+ (comment != null ? " (" + comment + ")" : "") + ".");
|
||||
}
|
||||
public void tell(String itemName) {
|
||||
player.sendMessage(Colors.Yellow + "You're not allowed to use " + itemName + ".");
|
||||
}
|
||||
};
|
||||
|
||||
return process(item, player, useActions, handler, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -443,7 +497,7 @@ public class BlacklistEntry {
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean onUse(final Block block, final Player player) {
|
||||
public boolean onRightClick(final Block block, final Player player) {
|
||||
if (useActions == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -452,7 +506,7 @@ public class BlacklistEntry {
|
||||
|
||||
ActionHandler handler = new ActionHandler() {
|
||||
public void log(String itemName) {
|
||||
blacklist.getLogger().logUseAttempt(player, block, comment);
|
||||
blacklist.getLogger().logRightClickAttempt(player, block, comment);
|
||||
}
|
||||
public void kick(String itemName) {
|
||||
player.kick("You can't use " + itemName);
|
||||
|
||||
@@ -88,9 +88,21 @@ public class BlacklistLogger implements BlacklistLoggerHandler {
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment) {
|
||||
public void logUseAttempt(Player player, int item, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logUseAttempt(player, block, comment);
|
||||
handler.logUseAttempt(player, item, comment);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a right click on attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logRightClickAttempt(Player player, Block block, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logRightClickAttempt(player, block, comment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,14 +119,14 @@ public class BlacklistLogger implements BlacklistLoggerHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a right click attempt.
|
||||
* Log a place attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment) {
|
||||
public void logPlaceAttempt(Player player, int item, String comment) {
|
||||
for (BlacklistLoggerHandler handler : handlers) {
|
||||
handler.logCreateAttempt(player, item, comment);
|
||||
handler.logPlaceAttempt(player, item, comment);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +38,12 @@ public interface BlacklistLoggerHandler {
|
||||
*/
|
||||
public void logBreakAttempt(Player player, Block block, String comment);
|
||||
/**
|
||||
* Log a right click on attempt.
|
||||
* Log a use attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment);
|
||||
public void logUseAttempt(Player player, int item, String comment);
|
||||
/**
|
||||
* Right a left click attempt.
|
||||
*
|
||||
@@ -52,12 +52,19 @@ public interface BlacklistLoggerHandler {
|
||||
*/
|
||||
public void logDestroyWithAttempt(Player player, int item, String comment);
|
||||
/**
|
||||
* Log a right click attempt.
|
||||
* Log a place attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment);
|
||||
public void logPlaceAttempt(Player player, int item, String comment);
|
||||
/**
|
||||
* Log a right click on attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logRightClickAttempt(Player player, Block block, String comment);
|
||||
/**
|
||||
* Log a drop attempt.
|
||||
*
|
||||
|
||||
@@ -60,9 +60,9 @@ public class ConsoleLoggerHandler implements BlacklistLoggerHandler {
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment) {
|
||||
public void logRightClickAttempt(Player player, Block block, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to use " + getFriendlyItemName(block.getType())
|
||||
+ " tried to right click " + getFriendlyItemName(block.getType())
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
@@ -84,9 +84,21 @@ public class ConsoleLoggerHandler implements BlacklistLoggerHandler {
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment) {
|
||||
public void logPlaceAttempt(Player player, int item, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to create " + getFriendlyItemName(item)
|
||||
+ " tried to place " + getFriendlyItemName(item)
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a use attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logUseAttempt(Player player, int item, String comment) {
|
||||
logger.log(Level.INFO, "WorldGuard: " + player.getName()
|
||||
+ " tried to use " + getFriendlyItemName(item)
|
||||
+ (comment != null ? " (" + comment + ")" : ""));
|
||||
}
|
||||
|
||||
|
||||
@@ -146,8 +146,8 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment) {
|
||||
logEvent("USE", player.getName(),
|
||||
public void logRightClickAttempt(Player player, Block block, String comment) {
|
||||
logEvent("RIGHT_CLICK", player.getName(),
|
||||
block.getX(), block.getY(), block.getZ(), block.getType(),
|
||||
comment);
|
||||
}
|
||||
@@ -165,13 +165,25 @@ public class DatabaseLoggerHandler implements BlacklistLoggerHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a right click attempt.
|
||||
* Log a place attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment) {
|
||||
logEvent("CREATE", player.getName(),
|
||||
public void logPlaceAttempt(Player player, int item, String comment) {
|
||||
logEvent("PLACE", player.getName(),
|
||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||
(int)Math.floor(player.getZ()), item, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a use attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logUseAttempt(Player player, int item, String comment) {
|
||||
logEvent("USE", player.getName(),
|
||||
(int)Math.floor(player.getX()), (int)Math.floor(player.getY()),
|
||||
(int)Math.floor(player.getZ()), item, comment);
|
||||
}
|
||||
|
||||
@@ -206,6 +206,16 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the coordinates of a block in text form for the log.
|
||||
*
|
||||
* @param block
|
||||
* @return
|
||||
*/
|
||||
private String getCoordinates(Block block) {
|
||||
return "@" + block.getX() + "," + block.getY() + "," + block.getZ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a block destroy attempt.
|
||||
*
|
||||
@@ -213,7 +223,8 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
||||
* @param block
|
||||
*/
|
||||
public void logDestroyAttempt(Player player, Block block, String comment) {
|
||||
log(player, "Tried to destroy " + getFriendlyItemName(block.getType()),
|
||||
log(player, "Tried to destroy " + getFriendlyItemName(block.getType())
|
||||
+ " " + getCoordinates(block),
|
||||
comment);
|
||||
}
|
||||
|
||||
@@ -224,7 +235,8 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
||||
* @param block
|
||||
*/
|
||||
public void logBreakAttempt(Player player, Block block, String comment) {
|
||||
log(player, "Tried to break " + getFriendlyItemName(block.getType()),
|
||||
log(player, "Tried to break " + getFriendlyItemName(block.getType())
|
||||
+ " " + getCoordinates(block),
|
||||
comment);
|
||||
}
|
||||
|
||||
@@ -234,8 +246,9 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
||||
* @param player
|
||||
* @param block
|
||||
*/
|
||||
public void logUseAttempt(Player player, Block block, String comment) {
|
||||
log(player, "Tried to use " + getFriendlyItemName(block.getType()),
|
||||
public void logRightClickAttempt(Player player, Block block, String comment) {
|
||||
log(player, "Tried to right click " + getFriendlyItemName(block.getType())
|
||||
+ " " + getCoordinates(block),
|
||||
comment);
|
||||
}
|
||||
|
||||
@@ -255,8 +268,18 @@ public class FileLoggerHandler implements BlacklistLoggerHandler {
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logCreateAttempt(Player player, int item, String comment) {
|
||||
log(player, "Tried to create " + getFriendlyItemName(item), comment);
|
||||
public void logPlaceAttempt(Player player, int item, String comment) {
|
||||
log(player, "Tried to place " + getFriendlyItemName(item), comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a block use attempt.
|
||||
*
|
||||
* @param player
|
||||
* @param item
|
||||
*/
|
||||
public void logUseAttempt(Player player, int item, String comment) {
|
||||
log(player, "Tried to use " + getFriendlyItemName(item), comment);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Inventory related functions.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class ItemArrayUtil {
|
||||
/**
|
||||
* Set the contents of an ItemArray.
|
||||
*
|
||||
* @param itemArray
|
||||
* @param contents
|
||||
*/
|
||||
public static void setContents(ItemArray<?> itemArray, Item[] contents) {
|
||||
int size = itemArray.getContentsSize();
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (contents[i] == null) {
|
||||
itemArray.removeItem(i);
|
||||
} else {
|
||||
itemArray.setSlot(contents[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldGuard
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
/**
|
||||
* Sends all logger messages to a player.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class LoggerToChatHandler extends Handler {
|
||||
/**
|
||||
* Player.
|
||||
*/
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public LoggerToChatHandler(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the handler.
|
||||
*/
|
||||
public void close() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the output.
|
||||
*/
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a log record.
|
||||
*/
|
||||
public void publish(LogRecord record) {
|
||||
player.sendMessage(Colors.LightGray + record.getLevel().getName() + ": "
|
||||
+ Colors.White + record.getMessage());
|
||||
}
|
||||
}
|
||||
+13
-30
@@ -60,43 +60,26 @@ public class WorldGuard extends Plugin {
|
||||
|
||||
registerHook("COMMAND", PluginListener.Priority.MEDIUM);
|
||||
registerHook("SERVERCOMMAND", PluginListener.Priority.MEDIUM);
|
||||
if (!registerHook("EXPLODE", PluginListener.Priority.HIGH)) {
|
||||
missingFeatures.add("disabling TNT or creeper explosions");
|
||||
}
|
||||
if (!registerHook("IGNITE", PluginListener.Priority.HIGH)) {
|
||||
missingFeatures.add("disabling fire or lava fire");
|
||||
}
|
||||
if (!registerHook("FLOW", PluginListener.Priority.HIGH)) {
|
||||
missingFeatures.add("controlling lava flow");
|
||||
missingFeatures.add("sponge simulation");
|
||||
}
|
||||
registerHook("EXPLODE", PluginListener.Priority.HIGH);
|
||||
registerHook("IGNITE", PluginListener.Priority.HIGH);
|
||||
registerHook("FLOW", PluginListener.Priority.HIGH);
|
||||
registerHook("LOGINCHECK", PluginListener.Priority.HIGH);
|
||||
registerHook("LOGIN", PluginListener.Priority.MEDIUM);
|
||||
registerHook("BLOCK_CREATED", PluginListener.Priority.HIGH);
|
||||
registerHook("BLOCK_DESTROYED", PluginListener.Priority.CRITICAL);
|
||||
registerHook("BLOCK_BROKEN", PluginListener.Priority.HIGH);
|
||||
registerHook("BLOCK_PLACE", PluginListener.Priority.HIGH);
|
||||
registerHook("DISCONNECT", PluginListener.Priority.HIGH);
|
||||
registerHook("ITEM_DROP", PluginListener.Priority.HIGH);
|
||||
if (!registerHook("ITEM_PICK_UP", PluginListener.Priority.HIGH)) {
|
||||
missingFeatures.add("denying item pickups");
|
||||
missingFeatures.add("the item durability fix");
|
||||
} else {
|
||||
try {
|
||||
Method method =
|
||||
Item.class.getDeclaredMethod("setDamage", new Class[]{ Integer.class });
|
||||
if (method == null) {
|
||||
missingFeatures.add("the item durability fix");
|
||||
}
|
||||
} catch (NoSuchMethodException e) {
|
||||
missingFeatures.add("the item durability fix");
|
||||
}
|
||||
}
|
||||
registerHook("COMPLEX_BLOCK_CHANGE", PluginListener.Priority.HIGH);
|
||||
registerHook("COMPLEX_BLOCK_SEND", PluginListener.Priority.HIGH);
|
||||
registerHook("ITEM_USE", PluginListener.Priority.HIGH);
|
||||
registerHook("ITEM_PICK_UP", PluginListener.Priority.HIGH);
|
||||
registerHook("SIGN_CHANGE", PluginListener.Priority.HIGH);
|
||||
registerHook("OPEN_INVENTORY", PluginListener.Priority.HIGH);
|
||||
registerHook("INVENTORY_CHANGE", PluginListener.Priority.HIGH);
|
||||
if (!registerHook("BLOCK_PHYSICS", PluginListener.Priority.MEDIUM)) {
|
||||
missingFeatures.add("controlling the physics of gravel, sand, or portal blocks");
|
||||
}
|
||||
registerHook("BLOCK_PHYSICS", PluginListener.Priority.MEDIUM);
|
||||
registerHook("HEALTH_CHANGE", PluginListener.Priority.MEDIUM);
|
||||
registerHook("DAMAGE", PluginListener.Priority.MEDIUM);
|
||||
registerHook("LIQUID_DESTROY", PluginListener.Priority.MEDIUM);
|
||||
|
||||
if (missingFeatures.size() > 0) {
|
||||
logger.log(Level.WARNING, "WorldGuard: Your version of hMod does not support "
|
||||
@@ -120,7 +103,7 @@ public class WorldGuard extends Plugin {
|
||||
etc.getLoader().addListener(hook, listener, this, priority);
|
||||
return true;
|
||||
} catch (IllegalArgumentException e) {
|
||||
//logger.log(Level.WARNING, "WorldGuard: Missing hook " + name + "!");
|
||||
logger.log(Level.WARNING, "WorldGuard: Missing hook " + name + "!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+495
-106
@@ -23,8 +23,11 @@ import java.util.logging.Logger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.io.*;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
|
||||
/**
|
||||
* Event listener for Hey0's server mod.
|
||||
@@ -53,12 +56,24 @@ public class WorldGuardListener extends PluginListener {
|
||||
* Properties file for WorldGuard.
|
||||
*/
|
||||
private PropertiesFile properties = new PropertiesFile("worldguard.properties");
|
||||
|
||||
/**
|
||||
* Stop fire spread mode.
|
||||
* List of players with god mode on.
|
||||
*/
|
||||
private Set<String> invinciblePlayers = new HashSet<String>();
|
||||
/**
|
||||
* List of amphibious players.
|
||||
*/
|
||||
private Set<String> amphibiousPlayers = new HashSet<String>();
|
||||
/**
|
||||
* Used to keep recent join times.
|
||||
*/
|
||||
private Map<String,Long> recentLogins = new HashMap<String,Long>();
|
||||
/**
|
||||
* Used to keep recent spawn times.
|
||||
*/
|
||||
private Map<String,Long> lastSpawn = new HashMap<String,Long>();
|
||||
|
||||
private boolean stopFireSpread = false;
|
||||
|
||||
private boolean enforceOneSession;
|
||||
private boolean blockCreepers;
|
||||
private boolean blockTNT;
|
||||
@@ -67,14 +82,25 @@ public class WorldGuardListener extends PluginListener {
|
||||
private boolean disableAllFire;
|
||||
private boolean simulateSponge;
|
||||
private int spongeRadius;
|
||||
private boolean itemDurability;
|
||||
private Set<Integer> fireNoSpreadBlocks;
|
||||
private Set<Integer> allowedLavaSpreadOver;
|
||||
private Set<Integer> itemDropBlacklist;
|
||||
private Set<Integer> preventWaterDamage;
|
||||
private boolean classicWater;
|
||||
private boolean noPhysicsGravel;
|
||||
private boolean noPhysicsSand;
|
||||
private boolean allowPortalAnywhere;
|
||||
private boolean disableFallDamage;
|
||||
private boolean disableLavaDamage;
|
||||
private boolean disableFireDamage;
|
||||
private boolean disableWaterDamage;
|
||||
private boolean disableSuffocationDamage;
|
||||
private boolean teleportOnSuffocation;
|
||||
private int loginProtection;
|
||||
private int spawnProtection;
|
||||
private boolean teleportToHome;
|
||||
private boolean exactRespawn;
|
||||
private boolean kickOnDeath;
|
||||
private Blacklist blacklist;
|
||||
|
||||
/**
|
||||
@@ -84,6 +110,7 @@ public class WorldGuardListener extends PluginListener {
|
||||
*/
|
||||
public WorldGuardListener(WorldGuard plugin) {
|
||||
this.plugin = plugin;
|
||||
postReload();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,11 +144,39 @@ public class WorldGuardListener extends PluginListener {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates various lists.
|
||||
*/
|
||||
public void postReload() {
|
||||
invinciblePlayers.clear();
|
||||
amphibiousPlayers.clear();
|
||||
|
||||
try {
|
||||
for (Player player : etc.getServer().getPlayerList()) {
|
||||
if (player.isInGroup("wg-invincible")) {
|
||||
invinciblePlayers.add(player.getName());
|
||||
}
|
||||
|
||||
if (player.isInGroup("wg-amphibious")) {
|
||||
amphibiousPlayers.add(player.getName());
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) { // Thrown if loaded too early
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the configuration
|
||||
*/
|
||||
public void loadConfiguration() {
|
||||
properties.load();
|
||||
try {
|
||||
properties.load();
|
||||
} catch (IOException e) {
|
||||
logger.log(Level.WARNING, "WorldGuard: Failed to load configuration: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
|
||||
recentLogins.clear();
|
||||
|
||||
// Load basic options
|
||||
enforceOneSession = properties.getBoolean("enforce-single-session", true);
|
||||
@@ -130,16 +185,27 @@ public class WorldGuardListener extends PluginListener {
|
||||
blockLighter = properties.getBoolean("block-lighter", false);
|
||||
preventLavaFire = properties.getBoolean("disable-lava-fire", true);
|
||||
disableAllFire = properties.getBoolean("disable-all-fire-spread", false);
|
||||
preventWaterDamage = toBlockIDSet(properties.getString("disable-water-damage-blocks", ""));
|
||||
itemDropBlacklist = toBlockIDSet(properties.getString("item-drop-blacklist", ""));
|
||||
fireNoSpreadBlocks = toBlockIDSet(properties.getString("disallowed-fire-spread-blocks", ""));
|
||||
allowedLavaSpreadOver = toBlockIDSet(properties.getString("allowed-lava-spread-blocks", ""));
|
||||
classicWater = properties.getBoolean("classic-water", false);
|
||||
simulateSponge = properties.getBoolean("simulate-sponge", true);
|
||||
spongeRadius = Math.max(1, properties.getInt("sponge-radius", 3)) - 1;
|
||||
itemDurability = properties.getBoolean("item-durability", false);
|
||||
noPhysicsGravel = properties.getBoolean("no-physics-gravel", false);
|
||||
noPhysicsSand = properties.getBoolean("no-physics-sand", false);
|
||||
allowPortalAnywhere = properties.getBoolean("allow-portal-anywhere", false);
|
||||
disableFallDamage = properties.getBoolean("disable-fall-damage", false);
|
||||
disableLavaDamage = properties.getBoolean("disable-lava-damage", false);
|
||||
disableFireDamage = properties.getBoolean("disable-fire-damage", false);
|
||||
disableWaterDamage = properties.getBoolean("disable-water-damage", false);
|
||||
disableSuffocationDamage = properties.getBoolean("disable-suffocation-damage", false);
|
||||
teleportOnSuffocation = properties.getBoolean("teleport-on-suffocation", false);
|
||||
loginProtection = properties.getInt("login-protection", 3);
|
||||
spawnProtection = properties.getInt("spawn-protection", 0);
|
||||
kickOnDeath = properties.getBoolean("kick-on-death", false);
|
||||
teleportToHome = properties.getBoolean("teleport-to-home-on-death", false);
|
||||
exactRespawn = properties.getBoolean("exact-respawn", false);
|
||||
|
||||
// Console log configuration
|
||||
boolean logConsole = properties.getBoolean("log-console", true);
|
||||
@@ -251,6 +317,19 @@ public class WorldGuardListener extends PluginListener {
|
||||
if (stopFireSpread) {
|
||||
player.sendMessage(Colors.Yellow + "Fire spread is currently globally disabled.");
|
||||
}
|
||||
|
||||
if (loginProtection > 0 || spawnProtection > 0
|
||||
|| kickOnDeath || teleportToHome || exactRespawn) {
|
||||
recentLogins.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
if (player.isInGroup("wg-invincible")) {
|
||||
invinciblePlayers.add(player.getName());
|
||||
}
|
||||
|
||||
if (player.isInGroup("wg-amphibious")) {
|
||||
amphibiousPlayers.add(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,10 +362,146 @@ public class WorldGuardListener extends PluginListener {
|
||||
}
|
||||
stopFireSpread = false;
|
||||
return true;
|
||||
} else if (split[0].equalsIgnoreCase("/god")
|
||||
&& player.canUseCommand("/god")) {
|
||||
// Allow setting other people invincible
|
||||
if (split.length > 1) {
|
||||
if (!player.canUseCommand("/godother")) {
|
||||
player.sendMessage(Colors.Rose + "You don't have permission to make others invincible.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player other = etc.getServer().matchPlayer(split[1]);
|
||||
if (other == null) {
|
||||
player.sendMessage(Colors.Rose + "Player not found.");
|
||||
} else {
|
||||
if (!invinciblePlayers.contains(other.getName())) {
|
||||
invinciblePlayers.add(other.getName());
|
||||
player.sendMessage(Colors.Yellow + other.getName() + " is now invincible!");
|
||||
other.sendMessage(Colors.Yellow + player.getName() + " has made you invincible!");
|
||||
} else {
|
||||
invinciblePlayers.remove(other.getName());
|
||||
player.sendMessage(Colors.Yellow + other.getName() + " is no longer invincible.");
|
||||
other.sendMessage(Colors.Yellow + player.getName() + " has taken away your invincibility.");
|
||||
}
|
||||
}
|
||||
// Invincibility for one's self
|
||||
} else {
|
||||
if (!invinciblePlayers.contains(player.getName())) {
|
||||
invinciblePlayers.add(player.getName());
|
||||
player.sendMessage(Colors.Yellow + "You are now invincible!");
|
||||
} else {
|
||||
invinciblePlayers.remove(player.getName());
|
||||
player.sendMessage(Colors.Yellow + "You are no longer invincible.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if ((split[0].equalsIgnoreCase("/stack")
|
||||
|| split[0].equalsIgnoreCase("/;"))
|
||||
&& player.canUseCommand("/stack")) {
|
||||
Item[] items = player.getInventory().getContents();
|
||||
int len = items.length;
|
||||
|
||||
int affected = 0;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
Item item = items[i];
|
||||
|
||||
// Avoid infinite stacks and stacks with durability
|
||||
if (item == null || item.getAmount() <= 0
|
||||
|| shouldNotStack(item.getItemId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore buckets
|
||||
if (item.getItemId() >= 325 && item.getItemId() <= 327) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item.getAmount() < 64) {
|
||||
int needed = 64 - item.getAmount(); // Number of needed items until 64
|
||||
|
||||
// Find another stack of the same type
|
||||
for (int j = i + 1; j < len; j++) {
|
||||
Item item2 = items[j];
|
||||
|
||||
// Avoid infinite stacks and stacks with durability
|
||||
if (item2 == null || item2.getAmount() <= 0
|
||||
|| shouldNotStack(item.getItemId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Same type?
|
||||
if (item2.getItemId() == item.getItemId()) {
|
||||
// This stack won't fit in the parent stack
|
||||
if (item2.getAmount() > needed) {
|
||||
item.setAmount(64);
|
||||
item2.setAmount(item2.getAmount() - needed);
|
||||
break;
|
||||
// This stack will
|
||||
} else {
|
||||
items[j] = null;
|
||||
item.setAmount(item.getAmount() + item2.getAmount());
|
||||
needed = 64 - item.getAmount();
|
||||
}
|
||||
|
||||
affected++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (affected > 0) {
|
||||
ItemArrayUtil.setContents((ItemArray<?>)player.getInventory(), items);
|
||||
}
|
||||
|
||||
player.sendMessage(Colors.Yellow + "Items compacted into stacks!");
|
||||
|
||||
return true;
|
||||
} else if (split[0].equalsIgnoreCase("/reload")
|
||||
&& player.canUseCommand("/reload")
|
||||
&& split.length > 1) {
|
||||
if (split[1].equalsIgnoreCase("WorldGuard")) {
|
||||
LoggerToChatHandler handler = new LoggerToChatHandler(player);
|
||||
handler.setLevel(Level.ALL);
|
||||
Logger minecraftLogger = Logger.getLogger("Minecraft");
|
||||
minecraftLogger.addHandler(handler);
|
||||
|
||||
try {
|
||||
loadConfiguration();
|
||||
postReload();
|
||||
player.sendMessage("WorldGuard configuration reloaded.");
|
||||
} catch (Throwable t) {
|
||||
player.sendMessage("Error while reloading: "
|
||||
+ t.getMessage());
|
||||
} finally {
|
||||
minecraftLogger.removeHandler(handler);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an item should not be stacked.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
private static boolean shouldNotStack(int id) {
|
||||
return (id >= 256 && id <= 259)
|
||||
|| id == 261
|
||||
|| (id >= 267 && id <= 279)
|
||||
|| (id >= 281 && id <= 286)
|
||||
|| (id >= 290 && id <= 294)
|
||||
|| (id >= 298 && id <= 317)
|
||||
|| (id >= 325 && id <= 327)
|
||||
|| id == 335
|
||||
|| id == 346;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before the console command is parsed. Return true if you don't
|
||||
@@ -348,12 +563,9 @@ public class WorldGuardListener extends PluginListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (!itemDurability) {
|
||||
try {
|
||||
item.setDamage(0);
|
||||
} catch (java.lang.NoSuchMethodError e) {
|
||||
}
|
||||
}
|
||||
/*if (!itemDurability) {
|
||||
item.setDamage(0);
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -388,12 +600,12 @@ public class WorldGuardListener extends PluginListener {
|
||||
@Override
|
||||
public boolean onInventoryChange(Player player) {
|
||||
if (blacklist != null && blacklist.hasOnAcquire()) {
|
||||
hl[] items = player.getInventory().getArray();
|
||||
Item[] items = player.getInventory().getContents();
|
||||
boolean needUpdate = false;
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null) {
|
||||
if (!blacklist.onAcquire(items[i].c, player)) {
|
||||
if (!blacklist.onAcquire(items[i].getItemId(), player)) {
|
||||
items[i] = null;
|
||||
needUpdate = true;
|
||||
}
|
||||
@@ -401,7 +613,7 @@ public class WorldGuardListener extends PluginListener {
|
||||
}
|
||||
|
||||
if (needUpdate) {
|
||||
player.getInventory().updateInventory();
|
||||
ItemArrayUtil.setContents((ItemArray<?>)player.getInventory(), items);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,42 +621,48 @@ public class WorldGuardListener extends PluginListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when someone presses right click. If they right clicked with a
|
||||
* block you can return true to cancel that. You can intercept this to add
|
||||
* your own right click actions to different item types (see itemInHand)
|
||||
* Called when a player uses an item (rightclick with item in hand)
|
||||
* @param player the player
|
||||
* @param blockPlaced where a block would end up when the item was a bucket
|
||||
* @param blockClicked
|
||||
* @param item the item being used (in hand)
|
||||
* @return true to prevent using the item.
|
||||
*/
|
||||
@Override
|
||||
public boolean onItemUse(Player player, Block blockPlaced,
|
||||
Block blockClicked, Item item) {
|
||||
if (blacklist != null) {
|
||||
int itemId = item.getItemId();
|
||||
|
||||
if (!blacklist.onUse(itemId, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when someone places a block. Return true to prevent the placement.
|
||||
*
|
||||
* @param player
|
||||
* @param blockPlaced
|
||||
* @param blockClicked
|
||||
* @param itemInHand
|
||||
* @return false if you want the action to go through
|
||||
* @return true if you want to undo the block placement
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockCreate(Player player, Block blockPlaced, Block blockClicked,
|
||||
int itemInHand) {
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onCreate(itemInHand, player)) {
|
||||
// Water/lava bucket fix
|
||||
if (itemInHand == 326 || itemInHand == 327) {
|
||||
final int x = blockPlaced.getX();
|
||||
final int y = blockPlaced.getY();
|
||||
final int z = blockPlaced.getZ();
|
||||
final int existingID = etc.getServer().getBlockIdAt(x, y, z);
|
||||
public boolean onBlockPlace(Player player, Block blockPlaced,
|
||||
Block blockClicked, Item itemInHand) {
|
||||
|
||||
int itemId = itemInHand.getItemId();
|
||||
|
||||
// This is REALLY BAD, but there's no other choice
|
||||
// at the moment that is as reliable
|
||||
timer.schedule(new TimerTask() {
|
||||
public void run() {
|
||||
try {
|
||||
etc.getServer().setBlockAt(existingID, x, y, z);
|
||||
} catch (Throwable t) {}
|
||||
}
|
||||
}, 200); // Just in case
|
||||
}
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onPlace(itemId, player)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!blacklist.onUse(blockClicked, player)) {
|
||||
if (!blacklist.onRightClick(blockClicked, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -480,8 +698,6 @@ public class WorldGuardListener extends PluginListener {
|
||||
*/
|
||||
@Override
|
||||
public boolean onBlockDestroy(Player player, Block block) {
|
||||
int type = block.getType();
|
||||
|
||||
if (blacklist != null) {
|
||||
if (!blacklist.onDestroyWith(player.getItemInHand(), player)) {
|
||||
return true;
|
||||
@@ -514,76 +730,40 @@ public class WorldGuardListener extends PluginListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when either a sign, chest or furnace is changed.
|
||||
* Called when a player attempts to open an inventory; whether it's a
|
||||
* workbench, a chest or their own player inventory
|
||||
*
|
||||
* @param player
|
||||
* player who changed it
|
||||
* @param complexBlock
|
||||
* complex block that changed
|
||||
* @return true if you want any changes to be reverted
|
||||
* @param player user who attempted to open the inventory
|
||||
* @param inventory the inventory that they are attempting to open
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onComplexBlockChange(Player player, ComplexBlock complexBlock) {
|
||||
if (blacklist != null) {
|
||||
if (complexBlock instanceof Chest) {
|
||||
Block block = new Block(54, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
} else if (complexBlock instanceof Furnace) {
|
||||
int id = etc.getServer().getBlockIdAt(complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
Block block = new Block(id, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
} else if (complexBlock instanceof Sign) {
|
||||
int id = etc.getServer().getBlockIdAt(complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
Block block = new Block(id, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean onOpenInventory(Player player, Inventory inventory) {
|
||||
/*Block block = new Block(54, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onRightClick(block, player)) {
|
||||
return true;
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when either a sign, chest or furnace is sent to a player
|
||||
*
|
||||
* @param player
|
||||
* player who the block is being sent to
|
||||
* @param complexBlock
|
||||
* complex block that's being sent
|
||||
* @return true if you want the chest, furnace or sign to be empty
|
||||
* Called when a sign is changed by a player (Usually, when they first place it)
|
||||
*
|
||||
* @param player Player who changed the sign
|
||||
* @param sign Sign which had changed
|
||||
* @return true if you wish to cancel this change
|
||||
*/
|
||||
@Override
|
||||
public boolean onSendComplexBlock(Player player, ComplexBlock complexBlock) {
|
||||
public boolean onSignChange(Player player, Sign sign) {
|
||||
if (blacklist != null) {
|
||||
if (complexBlock instanceof Chest) {
|
||||
Block block = new Block(54, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
int id = etc.getServer().getBlockIdAt(sign.getX(),
|
||||
sign.getY(), sign.getZ());
|
||||
Block block = new Block(id, sign.getX(),
|
||||
sign.getY(), sign.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
} else if (complexBlock instanceof Furnace) {
|
||||
int id = etc.getServer().getBlockIdAt(complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
Block block = new Block(id, complexBlock.getX(),
|
||||
complexBlock.getY(), complexBlock.getZ());
|
||||
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
if (!blacklist.onSilentUse(block, player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,10 +854,6 @@ public class WorldGuardListener extends PluginListener {
|
||||
*/
|
||||
@Override
|
||||
public boolean onFlow(Block blockFrom, Block blockTo) {
|
||||
int x = blockFrom.getX();
|
||||
int y = blockFrom.getY();
|
||||
int z = blockFrom.getZ();
|
||||
|
||||
boolean isWater = blockFrom.getType() == 8 || blockFrom.getType() == 9;
|
||||
boolean isLava = blockFrom.getType() == 10 || blockFrom.getType() == 11;
|
||||
|
||||
@@ -746,6 +922,177 @@ public class WorldGuardListener extends PluginListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a players health changes.
|
||||
* @param player
|
||||
* the player which health is changed.
|
||||
* @param oldValue
|
||||
* old lives value
|
||||
* @param newValue
|
||||
* new lives value
|
||||
* @return
|
||||
* return true to stop the change.
|
||||
*/
|
||||
@Override
|
||||
public boolean onHealthChange(Player player, int oldValue, int newValue) {
|
||||
String playerName = player.getName();
|
||||
|
||||
if (disableSuffocationDamage && oldValue - newValue == 1) {
|
||||
Location loc = player.getLocation();
|
||||
int x = (int)Math.floor(loc.x);
|
||||
int y = (int)Math.floor(loc.y);
|
||||
int z = (int)Math.floor(loc.z);
|
||||
int type = etc.getServer().getBlockIdAt(x, y + 1, z); // Head
|
||||
|
||||
// Assuming that this is suffocation damage
|
||||
if ((type < 8 || type > 11) && !BlockType.canPassThrough(type)) {
|
||||
if (teleportOnSuffocation) {
|
||||
findFreePosition(player, x, y, z);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (invinciblePlayers.contains(playerName)) {
|
||||
return oldValue > newValue;
|
||||
}
|
||||
|
||||
if (loginProtection > 0 || spawnProtection > 0
|
||||
|| kickOnDeath || teleportToHome || exactRespawn) {
|
||||
long now = System.currentTimeMillis();
|
||||
boolean recentLogin = false;
|
||||
|
||||
if (recentLogins.containsKey(playerName)) {
|
||||
long time = recentLogins.get(playerName);
|
||||
long elapsed = now - time;
|
||||
|
||||
if (loginProtection > 0 && elapsed <= loginProtection * 1000
|
||||
&& newValue < oldValue) {
|
||||
return true;
|
||||
}
|
||||
|
||||
recentLogin = elapsed <= 2000;
|
||||
|
||||
if (elapsed > 2000 && elapsed > loginProtection * 1000) {
|
||||
recentLogins.remove(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
boolean alreadyMoved = false;
|
||||
|
||||
if (teleportToHome && oldValue <= 0 && newValue == 20 && !recentLogin) {
|
||||
Warp warp = etc.getDataSource().getHome(player.getName());
|
||||
if (warp != null) {
|
||||
player.teleportTo(warp.Location);
|
||||
alreadyMoved = true;
|
||||
} else if (player.canUseCommand("/sethome")) {
|
||||
player.sendMessage(Colors.Yellow + "Use /sethome to set your spawn location.");
|
||||
}
|
||||
}
|
||||
|
||||
if (exactRespawn && !alreadyMoved && oldValue <= 0 && newValue == 20 && !recentLogin) {
|
||||
player.teleportTo(etc.getServer().getSpawnLocation());
|
||||
}
|
||||
|
||||
if (kickOnDeath && oldValue <= 0 && newValue == 20 && !recentLogin) {
|
||||
player.kick("You died! Rejoin please.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spawnProtection > 0) {
|
||||
if (oldValue <= 0 && newValue == 20 && !recentLogin) { // Player was just respawned
|
||||
lastSpawn.put(player.getName(), now);
|
||||
} else if (lastSpawn.containsKey(playerName)) {
|
||||
long time = lastSpawn.get(playerName);
|
||||
long elapsed = now - time;
|
||||
|
||||
if (elapsed < spawnProtection * 1000) {
|
||||
return newValue < oldValue;
|
||||
} else {
|
||||
lastSpawn.remove(playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a living object is attacked.
|
||||
* tip:
|
||||
* Use isMob() and isPlayer() and getPlayer().
|
||||
*
|
||||
* @param type
|
||||
* type of damage dealt.
|
||||
* @param attacker
|
||||
* object that is attacking.
|
||||
* @param defender
|
||||
* object that is defending.
|
||||
* @param amount
|
||||
* amount of damage dealt.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onDamage(PluginLoader.DamageType type, BaseEntity attacker,
|
||||
BaseEntity defender, int amount) {
|
||||
|
||||
if (defender.isPlayer()) {
|
||||
Player player = defender.getPlayer();
|
||||
|
||||
if (invinciblePlayers.contains(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (disableFallDamage && type == PluginLoader.DamageType.FALL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (disableLavaDamage && type == PluginLoader.DamageType.LAVA) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (disableFireDamage && (type == PluginLoader.DamageType.FIRE
|
||||
|| type == PluginLoader.DamageType.FIRE_TICK)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (disableWaterDamage && type == PluginLoader.DamageType.WATER) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type == PluginLoader.DamageType.WATER
|
||||
&& amphibiousPlayers.contains(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when water or lava tries to populate a block, you can prevent
|
||||
* crushing of torches, railways, flowers etc. You can alternatively allow
|
||||
* to let normally solid blocks be crushed.
|
||||
*
|
||||
* @param currentState the current tristate, once it's set to a non DEFAULT_ACTION it is final.
|
||||
* @param liquidBlock the type of the attacking block
|
||||
* @param targetBlock the block to be destroyed
|
||||
* @return final after a non DEFAULT_ACTION
|
||||
*/
|
||||
@Override
|
||||
public PluginLoader.HookResult onLiquidDestroy(PluginLoader.HookResult currentState,
|
||||
int liquidBlockId, Block targetBlock) {
|
||||
if (preventWaterDamage != null && liquidBlockId <= 9) {
|
||||
if (preventWaterDamage.contains(targetBlock.getType())) {
|
||||
return PluginLoader.HookResult.PREVENT_ACTION;
|
||||
}
|
||||
}
|
||||
|
||||
return PluginLoader.HookResult.DEFAULT_ACTION;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on player disconnect
|
||||
*
|
||||
@@ -754,6 +1101,9 @@ public class WorldGuardListener extends PluginListener {
|
||||
@Override
|
||||
public void onDisconnect(Player player) {
|
||||
BlacklistEntry.forgetPlayer(player);
|
||||
invinciblePlayers.remove(player.getName());
|
||||
amphibiousPlayers.remove(player.getName());
|
||||
recentLogins.remove(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -764,4 +1114,43 @@ public class WorldGuardListener extends PluginListener {
|
||||
blacklist.getLogger().close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a position for the player to stand that is not inside a block.
|
||||
* Blocks above the player will be iteratively tested until there is
|
||||
* a series of two free blocks. The player will be teleported to
|
||||
* that free position.
|
||||
*
|
||||
* @param player
|
||||
* @param sx
|
||||
* @param sy
|
||||
* @param sz
|
||||
*/
|
||||
public void findFreePosition(Player player, int sx, int sy, int sz) {
|
||||
int x = sx;
|
||||
int y = Math.max(0, sy);
|
||||
int origY = y;
|
||||
int z = sz;
|
||||
|
||||
byte free = 0;
|
||||
|
||||
while (y <= 129) {
|
||||
if (BlockType.canPassThrough(etc.getServer().getBlockIdAt(x, y, z))) {
|
||||
free++;
|
||||
} else {
|
||||
free = 0;
|
||||
}
|
||||
|
||||
if (free == 2) {
|
||||
if (y - 1 != origY) {
|
||||
player.teleportTo(x + 0.5, y, z + 0.5,
|
||||
player.getRotation(), player.getPitch());
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* Block types.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public enum BlockType {
|
||||
AIR(0, "Air", "air"),
|
||||
STONE(1, "Stone", new String[]{"stone", "rock"}),
|
||||
GRASS(2, "Grass", "grass"),
|
||||
DIRT(3, "Dirt", "dirt"),
|
||||
COBBLESTONE(4, "Cobblestone", "cobblestone"),
|
||||
WOOD(5, "Wood", "wood"),
|
||||
SAPLING(6, "Sapling", "sapling"),
|
||||
BEDROCK(7, "Bedrock", "bedrock"),
|
||||
WATER(8, "Water", "watermoving"),
|
||||
STATIONARY_WATER(9, "Water (stationary)", "water"),
|
||||
LAVA(10, "Lava", "lavamoving"),
|
||||
STATIONARY_LAVA(11, "Lava (stationary)", "lava"),
|
||||
SAND(12, "Sand", "sand"),
|
||||
GRAVEL(13, "Gravel", "gravel"),
|
||||
GOLD_ORE(14, "Gold ore", "goldore"),
|
||||
IRON_ORE(15, "Iron ore", "ironore"),
|
||||
COAL_ORE(16, "Coal ore", "coalore"),
|
||||
LOG(17, "Log", "log"),
|
||||
LEAVES(18, "Leaves", "leaves"),
|
||||
SPONGE(19, "Sponge", "sponge"),
|
||||
GLASS(20, "Glass", "glass"),
|
||||
CLOTH(35, "Cloth", "cloth"),
|
||||
YELLOW_FLOWER(37, "Yellow flower", "yellowflower"),
|
||||
RED_FLOWER(38, "Red rose", new String[]{"redflower", "redrose"}),
|
||||
BROWN_MUSHROOM(39, "Brown mushroom", "brownmushroom"),
|
||||
RED_MUSHROOM(40, "Red mushroom", "redmushroom"),
|
||||
GOLD_BLOCK(41, "Gold block", new String[]{"gold", "goldblock"}),
|
||||
IRON_BLOCK(42, "Iron block", new String[]{"iron", "ironblock"}),
|
||||
DOUBLE_STEP(43, "Double step", "doublestep"),
|
||||
STEP(44, "Step", "step"),
|
||||
BRICK(45, "Brick", "brick"),
|
||||
TNT(46, "TNT", "tnt"),
|
||||
BOOKCASE(47, "Bookcase", new String[]{"bookshelf", "bookshelf"}),
|
||||
MOSSY_COBBLESTONE(48, "Cobblestone (mossy)", "mossycobblestone"),
|
||||
OBSIDIAN(49, "Obsidian", "obsidian"),
|
||||
TORCH(50, "Torch", "torch"),
|
||||
FIRE(51, "Fire", "fire"),
|
||||
MOB_SPAWNER(52, "Mob spawner", "mobspawner"),
|
||||
WOODEN_STAIRS(53, "Wooden stairs", "woodstairs"),
|
||||
CHEST(54, "Chest", "chest"),
|
||||
REDSTONE_WIRE(55, "Redstone wire", "redstone"),
|
||||
DIAMOND_ORE(56, "Diamond ore", "diamondore"),
|
||||
DIAMOND_BLOCK(57, "Diamond block", new String[]{"diamond", "diamondblock"}),
|
||||
WORKBENCH(58, "Workbench", "workbench"),
|
||||
CROPS(59, "Crops", "crops"),
|
||||
SOIL(60, "Soil", "soil"),
|
||||
FURNACE(61, "Furnace", "furnace"),
|
||||
BURNING_FURNACE(62, "Furnace (burning)", "burningfurnace"),
|
||||
SIGN_POST(63, "Sign post", new String[]{"sign", "signpost"}),
|
||||
WOODEN_DOOR(64, "Wooden door", "wooddoor"),
|
||||
LADDER(65, "Ladder", "ladder"),
|
||||
MINECART_TRACKS(66, "Minecart tracks", new String[]{"track", "tracks"}),
|
||||
COBBLESTONE_STAIRS(67, "Cobblestone stairs", "cobblestonestairs"),
|
||||
WALL_SIGN(68, "Wall sign", "wallsign"),
|
||||
LEVER(69, "Lever", "level"),
|
||||
STONE_PRESSURE_PLATE(70, "Stone pressure plate", "stonepressureplate"),
|
||||
IRON_DOOR(71, "Iron Door", "irondoor"),
|
||||
WOODEN_PRESSURE_PLATE(72, "Wooden pressure plate", "woodpressureplate"),
|
||||
REDSTONE_ORE(73, "Redstone ore", "redstoneore"),
|
||||
GLOWING_REDSTONE_ORE(74, "Glowing redstone ore", "glowingredstoneore"),
|
||||
REDSTONE_TORCH_OFF(75, "Redstone torch (off)",
|
||||
new String[]{"redstonetorch"," redstonetorchon"}),
|
||||
REDSTONE_TORCH_ON(76, "Redstone torch (on)", "redstonetorchon"),
|
||||
STONE_BUTTON(77, "Stone Button", "stonebutton"),
|
||||
SNOW(78, "Snow", "snow"),
|
||||
ICE(79, "Ice", "ice"),
|
||||
SNOW_BLOCK(80, "Snow block", "snowblock"),
|
||||
CACTUS(81, "Cactus", "cactus"),
|
||||
CLAY(82, "Clay", "clay"),
|
||||
REED(83, "Reed", "reed"),
|
||||
JUKEBOX(84, "Jukebox", "jukebox"),
|
||||
FENCE(85, "Fence", "fence"),
|
||||
PUMPKIN(86, "Pumpkin", "pumpkin"),
|
||||
RED_BLOCK(87, "Cobblestone (red mossy)", new String[]{"redmossycobblestone", "redcobblestone"}),
|
||||
HELL_DIRT(88, "Mud", "mud"),
|
||||
HELL_GOLD(89, "Brittle gold", "brittlegold"),
|
||||
PORTAL(90, "Portal", "portal"),
|
||||
LIGHTED_PUMPKIN(91, "Pumpkin (on)", new String[]{"pumpkinlighted", "pumpkinon", "litpumpkin"});
|
||||
|
||||
/**
|
||||
* Stores a map of the IDs for fast access.
|
||||
*/
|
||||
private static final Map<Integer,BlockType> ids = new HashMap<Integer,BlockType>();
|
||||
/**
|
||||
* Stores a map of the names for fast access.
|
||||
*/
|
||||
private static final Map<String,BlockType> lookup = new HashMap<String,BlockType>();
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String[] lookupKeys;
|
||||
|
||||
static {
|
||||
for(BlockType type : EnumSet.allOf(BlockType.class)) {
|
||||
ids.put(type.id, type);
|
||||
for (String key : type.lookupKeys) {
|
||||
lookup.put(key, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
BlockType(int id, String name, String lookupKey) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = new String[]{lookupKey};
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
BlockType(int id, String name, String[] lookupKeys) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = lookupKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from ID. May return null.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static BlockType fromID(int id) {
|
||||
return ids.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from name. May return null.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static BlockType lookup(String name) {
|
||||
return lookup.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block numeric ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user-friendly block name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a block should be placed last.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public boolean shouldPlaceLast() {
|
||||
return shouldPlaceLast(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether a block should be placed last.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean shouldPlaceLast(int id) {
|
||||
return id == 6 // Saplings
|
||||
|| id == 37 // Yellow flower
|
||||
|| id == 38 // Red flower
|
||||
|| id == 39 // Brown mushroom
|
||||
|| id == 40 // Red mush room
|
||||
|| id == 50 // Torch
|
||||
|| id == 51 // Fire
|
||||
|| id == 55 // Redstone wire
|
||||
|| id == 59 // Crops
|
||||
|| id == 63 // Sign post
|
||||
|| id == 64 // Wooden door
|
||||
|| id == 65 // Ladder
|
||||
|| id == 66 // Minecart tracks
|
||||
|| id == 68 // Wall sign
|
||||
|| id == 69 // Lever
|
||||
|| id == 70 // Stone pressure plate
|
||||
|| id == 71 // Iron door
|
||||
|| id == 72 // Wooden pressure plate
|
||||
|| id == 75 // Redstone torch (off)
|
||||
|| id == 76 // Redstone torch (on)
|
||||
|| id == 77 // Stone button
|
||||
|| id == 78 // Snow
|
||||
|| id == 81 // Cactus
|
||||
|| id == 83 // Reed
|
||||
|| id == 90; // Portal
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a block can be passed through.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean canPassThrough(int id) {
|
||||
return id == 0 // Air
|
||||
|| id == 6 // Saplings
|
||||
|| id == 37 // Yellow flower
|
||||
|| id == 38 // Red flower
|
||||
|| id == 39 // Brown mushroom
|
||||
|| id == 40 // Red mush room
|
||||
|| id == 50 // Torch
|
||||
|| id == 51 // Fire
|
||||
|| id == 55 // Redstone wire
|
||||
|| id == 59 // Crops
|
||||
|| id == 63 // Sign post
|
||||
|| id == 65 // Ladder
|
||||
|| id == 66 // Minecart tracks
|
||||
|| id == 68 // Wall sign
|
||||
|| id == 69 // Lever
|
||||
|| id == 70 // Stone pressure plate
|
||||
|| id == 72 // Wooden pressure plate
|
||||
|| id == 75 // Redstone torch (off)
|
||||
|| id == 76 // Redstone torch (on)
|
||||
|| id == 77 // Stone button
|
||||
|| id == 78 // Snow
|
||||
|| id == 83 // Reed
|
||||
|| id == 90; // Portal
|
||||
}
|
||||
}
|
||||
+14
-15
@@ -11,7 +11,7 @@
|
||||
# Example to block ore and catch some events:
|
||||
# [coalore,goldore,ironore]
|
||||
# on-destroy-with=deny,log,kick
|
||||
# on-create=deny,tell
|
||||
# on-place=deny,tell
|
||||
#
|
||||
# Options:
|
||||
# - ignore-groups (comma-delimited list of groups to not affect)
|
||||
@@ -22,8 +22,9 @@
|
||||
# - 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-create (the item/block in the user's inventory is being created)
|
||||
# - on-use (the block is right clicked)
|
||||
# - 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)
|
||||
#
|
||||
@@ -68,24 +69,22 @@
|
||||
# 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-destroy-with=deny,log,kick
|
||||
#on-create=deny,tell
|
||||
#on-use=deny,tell
|
||||
|
||||
# Deny lighter usage
|
||||
#[259]
|
||||
#on-use=deny,tell
|
||||
|
||||
# Deny some ore
|
||||
#[coalore,goldore,ironore]
|
||||
#ignore-groups=admins,mods,vip
|
||||
#ignore-groups=admins,mods
|
||||
#on-destroy=notify,deny,log
|
||||
|
||||
#[cobblestone]
|
||||
#on-create=deny,tell,log
|
||||
#on-place=deny,tell,log
|
||||
|
||||
#[lever]
|
||||
#on-break=deny
|
||||
|
||||
# This is an example of the 'durability cheat' workaround that destroys your
|
||||
# tool when you drop it
|
||||
#[256,257,258,259,267,268,269,270,271,272,273,274,275,276,277,278,279,283,284,285,286,290,291,292,293,294,346]
|
||||
#on-drop=deny,tell
|
||||
#comment=Durability Hacks
|
||||
#message=Your tool was destroyed
|
||||
#on-break=deny,tell
|
||||
+68
-10
@@ -1,28 +1,43 @@
|
||||
#
|
||||
# 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.
|
||||
# These comments will be lost whenever WorldGuard updates this file.
|
||||
# More detailed descriptions of the options can be found in README.txt!
|
||||
#
|
||||
|
||||
# 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 sponge
|
||||
# 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
|
||||
# Simulate classic water. Water will spread infinitely. Be aware that this
|
||||
# may likely flood your server.
|
||||
classic-water=false
|
||||
|
||||
# Adjust physics
|
||||
# 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
|
||||
|
||||
# Protection
|
||||
# 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
|
||||
@@ -30,15 +45,52 @@ block-creepers=false
|
||||
block-lighter=false
|
||||
block-tnt=false
|
||||
|
||||
# Control fire
|
||||
# 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=
|
||||
|
||||
# Disable lava fire and spread
|
||||
disable-lava-fire=false
|
||||
# Prevent lava from starting fires.
|
||||
disable-lava-fire=true
|
||||
|
||||
# List of blocks that lava is allowed to spread onto.
|
||||
allowed-lava-spread-blocks=
|
||||
|
||||
# Log/blacklist
|
||||
# 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=
|
||||
@@ -48,3 +100,9 @@ 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
|
||||
Reference in new issue
Block a user