Added no-physics-gravel, no-physics-sand, and allow-portal-anywhere.

This commit is contained in:
sk89q 2010-11-21 01:12:00 -08:00
parent eb78b390ca
commit c3eef60672
3 changed files with 45 additions and 0 deletions

View File

@ -54,6 +54,15 @@ WorldGuard on your server. You can either restart your server or use
creating a 5x5x5 cuboid free of water. Increasing the number will
increase server load exponentially, although 3-5 has fairly low impact.
- no-physics-gravel (def. false)
Prevents gravel from falling due to gravity.
- no-physics-sand (def. false)
Prevents sand from falling due to gravity.
- allow-portal-anywhere (def. false)
Allows you to place portal blocks anywhere.
- enforce-single-session (def. true)
Enforce single sessions. If the player is already found to be on
the server when s/he logs in, the other player will be kicked with

View File

@ -85,6 +85,8 @@ public void initialize() {
PluginListener.Priority.HIGH);
loader.addListener(PluginLoader.Hook.INVENTORY_CHANGE, listener, this,
PluginListener.Priority.HIGH);
loader.addListener(PluginLoader.Hook.BLOCK_PHYSICS, listener, this,
PluginListener.Priority.MEDIUM);
}
/**

View File

@ -78,6 +78,9 @@ public class WorldGuardListener extends PluginListener {
private Set<Integer> allowedLavaSpreadOver;
private Set<Integer> itemDropBlacklist;
private boolean classicWater;
private boolean noPhysicsGravel;
private boolean noPhysicsSand;
private boolean allowPortalAnywhere;
private Blacklist blacklist;
/**
@ -141,6 +144,9 @@ public void loadConfiguration() {
spongeRadius = Math.max(1, properties.getInt("sponge-radius", 3)) - 1;
blockLagFix = properties.getBoolean("block-lag-fix", false);
itemDurability = properties.getBoolean("item-durability", true);
noPhysicsGravel = properties.getBoolean("no-physics-gravel", false);
noPhysicsSand = properties.getBoolean("no-physics-sand", false);
allowPortalAnywhere = properties.getBoolean("allow-portal-anywhere", false);
// Console log configuration
boolean logConsole = properties.getBoolean("log-console", true);
@ -781,6 +787,34 @@ public boolean onFlow(Block blockFrom, Block blockTo) {
return false;
}
/**
* Called when the game is checking the physics for a certain block.
* This method is called frequently whenever a nearby block is changed,
* or if the block has just been placed.
* Currently the only supported blocks are sand, gravel and portals.
*
* @param block Block which requires special physics
* @param boolean true if this block has just been placed
* @return true if you do want to stop the default physics for this block
*/
public boolean onBlockPhysics(Block block, boolean placed) {
int id = block.getType();
if (id == 13 && noPhysicsGravel) {
return true;
}
if (id == 12 && noPhysicsSand) {
return true;
}
if (id == 90 && allowPortalAnywhere) {
return true;
}
return false;
}
/**
* Called on player disconnect
*