Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64629bd878 | ||
|
|
e42be555b1 | ||
|
|
c62c5f5cae | ||
|
|
313bdbd8bf | ||
|
|
765b606e18 | ||
|
|
c0be685846 | ||
|
|
133e4c2c78 | ||
|
|
b7e91ac6d0 |
No files matched your search
@@ -1,3 +1,13 @@
|
||||
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
|
||||
|
||||
+17
@@ -119,6 +119,17 @@ 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.
|
||||
|
||||
- log-console (def. true)
|
||||
For blacklist log actions, print to console.
|
||||
|
||||
@@ -182,6 +193,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
|
||||
---------------
|
||||
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
WorldGuard-Version: 1.5
|
||||
WorldGuard-Version: 1.6
|
||||
@@ -97,6 +97,9 @@ public class WorldGuard extends Plugin {
|
||||
if (!registerHook("BLOCK_PHYSICS", PluginListener.Priority.MEDIUM)) {
|
||||
missingFeatures.add("controlling the physics of gravel, sand, or portal blocks");
|
||||
}
|
||||
if (!registerHook("HEALTH_CHANGE", PluginListener.Priority.MEDIUM)) {
|
||||
missingFeatures.add("god mode");
|
||||
}
|
||||
|
||||
if (missingFeatures.size() > 0) {
|
||||
logger.log(Level.WARNING, "WorldGuard: Your version of hMod does not support "
|
||||
|
||||
+127
-9
@@ -23,6 +23,8 @@ 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.*;
|
||||
|
||||
@@ -53,12 +55,20 @@ 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>();
|
||||
/**
|
||||
* 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;
|
||||
@@ -75,6 +85,9 @@ public class WorldGuardListener extends PluginListener {
|
||||
private boolean noPhysicsGravel;
|
||||
private boolean noPhysicsSand;
|
||||
private boolean allowPortalAnywhere;
|
||||
private int loginProtection;
|
||||
private int spawnProtection;
|
||||
private boolean kickOnDeath;
|
||||
private Blacklist blacklist;
|
||||
|
||||
/**
|
||||
@@ -123,6 +136,8 @@ public class WorldGuardListener extends PluginListener {
|
||||
public void loadConfiguration() {
|
||||
properties.load();
|
||||
|
||||
recentLogins.clear();
|
||||
|
||||
// Load basic options
|
||||
enforceOneSession = properties.getBoolean("enforce-single-session", true);
|
||||
blockCreepers = properties.getBoolean("block-creepers", false);
|
||||
@@ -140,6 +155,9 @@ public class WorldGuardListener extends PluginListener {
|
||||
noPhysicsGravel = properties.getBoolean("no-physics-gravel", false);
|
||||
noPhysicsSand = properties.getBoolean("no-physics-sand", false);
|
||||
allowPortalAnywhere = properties.getBoolean("allow-portal-anywhere", false);
|
||||
loginProtection = properties.getInt("login-protection", 3);
|
||||
spawnProtection = properties.getInt("spawn-protection", 0);
|
||||
kickOnDeath = properties.getBoolean("kick-on-death", false);
|
||||
|
||||
// Console log configuration
|
||||
boolean logConsole = properties.getBoolean("log-console", true);
|
||||
@@ -251,6 +269,10 @@ public class WorldGuardListener extends PluginListener {
|
||||
if (stopFireSpread) {
|
||||
player.sendMessage(Colors.Yellow + "Fire spread is currently globally disabled.");
|
||||
}
|
||||
|
||||
if (loginProtection > 0 || spawnProtection > 0 || kickOnDeath) {
|
||||
recentLogins.put(player.getName(), System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -283,6 +305,40 @@ 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;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -348,12 +404,9 @@ public class WorldGuardListener extends PluginListener {
|
||||
}
|
||||
}
|
||||
|
||||
if (!itemDurability) {
|
||||
try {
|
||||
item.setDamage(0);
|
||||
} catch (java.lang.NoSuchMethodError e) {
|
||||
}
|
||||
}
|
||||
/*if (!itemDurability) {
|
||||
item.setDamage(0);
|
||||
}*/
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -746,6 +799,69 @@ 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 (invinciblePlayers.contains(playerName)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (loginProtection > 0 || spawnProtection > 0 || kickOnDeath) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (kickOnDeath && oldValue == -1 && newValue == 20 && !recentLogin) {
|
||||
player.kick("You died! Rejoin please.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spawnProtection > 0) {
|
||||
if (oldValue == -1 && 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 on player disconnect
|
||||
*
|
||||
@@ -754,6 +870,8 @@ public class WorldGuardListener extends PluginListener {
|
||||
@Override
|
||||
public void onDisconnect(Player player) {
|
||||
BlacklistEntry.forgetPlayer(player);
|
||||
invinciblePlayers.remove(player.getName());
|
||||
recentLogins.remove(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,12 +30,17 @@ block-creepers=false
|
||||
block-lighter=false
|
||||
block-tnt=false
|
||||
|
||||
# Health related
|
||||
login-protection=3
|
||||
spawn-protection=0
|
||||
kick-on-death=false
|
||||
|
||||
# Control fire
|
||||
disable-all-fire-spread=false
|
||||
disallowed-fire-spread-blocks=
|
||||
|
||||
# Disable lava fire and spread
|
||||
disable-lava-fire=false
|
||||
disable-lava-fire=true
|
||||
allowed-lava-spread-blocks=
|
||||
|
||||
# Log/blacklist
|
||||
|
||||
Reference in new issue
Block a user