mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-18 15:17:36 +01:00
Added /god mode.
This commit is contained in:
parent
133e4c2c78
commit
c0be685846
@ -97,6 +97,9 @@ public void initialize() {
|
||||
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 "
|
||||
|
@ -53,12 +53,12 @@ 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>();
|
||||
|
||||
private boolean stopFireSpread = false;
|
||||
|
||||
private boolean enforceOneSession;
|
||||
private boolean blockCreepers;
|
||||
private boolean blockTNT;
|
||||
@ -283,6 +283,16 @@ public boolean onCommand(Player player, String[] split) {
|
||||
}
|
||||
stopFireSpread = false;
|
||||
return true;
|
||||
} else if (split[0].equalsIgnoreCase("/god")
|
||||
&& player.canUseCommand("/god")) {
|
||||
if (!invinciblePlayers.contains(player.getName())) {
|
||||
invinciblePlayers.add(player.getName());
|
||||
player.sendMessage(Colors.Yellow + "You are now invicible!");
|
||||
} else {
|
||||
invinciblePlayers.remove(player.getName());
|
||||
player.sendMessage(Colors.Yellow + "You are no longer invicible.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -743,6 +753,26 @@ public boolean onBlockPhysics(Block block, boolean placed) {
|
||||
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) {
|
||||
if (invinciblePlayers.contains(player.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on player disconnect
|
||||
*
|
||||
@ -751,6 +781,7 @@ public boolean onBlockPhysics(Block block, boolean placed) {
|
||||
@Override
|
||||
public void onDisconnect(Player player) {
|
||||
BlacklistEntry.forgetPlayer(player);
|
||||
invinciblePlayers.remove(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user