diff options
author | snowleo <schneeleo@gmail.com> | 2011-11-25 07:12:21 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-11-25 07:12:21 +0100 |
commit | 871c0e6b6a1cf8998c92171b5ab42ebb8edb011e (patch) | |
tree | cc9c7b618a891ce08ee8032ec0018d4b82d54999 | |
parent | 73d13f574899819ef345e2ae1128bcb8a799c9d1 (diff) | |
download | Essentials-871c0e6b6a1cf8998c92171b5ab42ebb8edb011e.tar Essentials-871c0e6b6a1cf8998c92171b5ab42ebb8edb011e.tar.gz Essentials-871c0e6b6a1cf8998c92171b5ab42ebb8edb011e.tar.lz Essentials-871c0e6b6a1cf8998c92171b5ab42ebb8edb011e.tar.xz Essentials-871c0e6b6a1cf8998c92171b5ab42ebb8edb011e.zip |
Disable god mode automatically in worlds defined by config
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 1 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java | 11 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/ISettings.java | 20 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Settings.java | 12 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/User.java | 10 | ||||
-rw-r--r-- | Essentials/src/config.yml | 4 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_da.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_en.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_es.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_fr.properties | 1 | ||||
-rw-r--r-- | Essentials/src/messages_nl.properties | 1 |
13 files changed, 54 insertions, 11 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index c74ce7312..9679aa64e 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -181,6 +181,7 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvent(Type.PLAYER_EGG_THROW, playerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this); + pm.registerEvent(Type.PLAYER_CHANGED_WORLD, playerListener, Priority.Normal, this); final EssentialsBlockListener blockListener = new EssentialsBlockListener(this); pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this); diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index cb3be43c7..c6cbfe232 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -385,4 +385,15 @@ public class EssentialsPlayerListener extends PlayerListener user.updateActivity(true); } } + + @Override + public void onPlayerChangedWorld(PlayerChangedWorldEvent event) + { + if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName())) { + User user = ess.getUser(event.getPlayer()); + if (user.isGodModeEnabledRaw()) { + user.sendMessage(_("noGodWorldWarning")); + } + } + } } diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 49a6ebf23..7891190dc 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -3,12 +3,12 @@ package com.earth2me.essentials; import com.earth2me.essentials.commands.IEssentialsCommand; import java.util.List; import java.util.Map; +import java.util.Set; import org.bukkit.ChatColor; public interface ISettings extends IConf { - boolean areSignsDisabled(); String format(String format, IUser user); @@ -64,11 +64,11 @@ public interface ISettings extends IConf boolean getReclaimSetting(); boolean getRespawnAtHome(); - + List getMultipleHomes(); - + int getHomeLimit(String set); - + int getHomeLimit(User user); boolean getSortListByGroups(); @@ -110,11 +110,11 @@ public interface ISettings extends IConf boolean warnOnBuildDisallow(); boolean warnOnSmite(); - + double getMaxMoney(); boolean isEcoLogEnabled(); - + boolean removeGodOnDisconnect(); boolean changeDisplayName(); @@ -124,9 +124,9 @@ public interface ISettings extends IConf boolean useBukkitPermissions(); boolean addPrefixSuffix(); - + boolean disablePrefix(); - + boolean disableSuffix(); long getAutoAfk(); @@ -134,8 +134,10 @@ public interface ISettings extends IConf long getAutoAfkKick(); boolean getFreezeAfkPlayers(); - + boolean areDeathMessagesEnabled(); public void setDebug(boolean debug); + + Set<String> getNoGodWorlds(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index b004925e6..47a102326 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -4,9 +4,12 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.commands.IEssentialsCommand; import java.io.File; import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.ChatColor; @@ -341,6 +344,7 @@ public class Settings implements ISettings public void reloadConfig() { config.load(); + noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds",Collections.<String>emptyList())); } @Override @@ -543,6 +547,14 @@ public class Settings implements ISettings { return config.getBoolean("death-messages", true); } + + Set <String> noGodWorlds = new HashSet<String>(); + @Override + public Set<String> getNoGodWorlds() + { + return noGodWorlds; + + } @Override public void setDebug(final boolean debug) diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index e58cbfb50..3c1166240 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -513,14 +513,20 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser @Override public boolean isGodModeEnabled() { - return super.isGodModeEnabled() || (isAfk() && ess.getSettings().getFreezeAfkPlayers()); + return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName())) + || (isAfk() && ess.getSettings().getFreezeAfkPlayers()); } + public boolean isGodModeEnabledRaw() + { + return super.isGodModeEnabled(); + } + public String getGroup() { return ess.getPermissionsHandler().getGroup(base); } - + public boolean inGroup(final String group) { return ess.getPermissionsHandler().inGroup(base, group); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index b063d1e41..de53ebbcf 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -229,6 +229,10 @@ freeze-afk-players: false # You can disable the death messages of minecraft here death-messages: true +# Add worlds to this list, if you want to automatically disable god mode there +no-god-in-worlds: +# - world_nether + ############################################################ # +------------------------------------------------------+ # # | EssentialsHome | # diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index cfbf33f5b..fdbe917df 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -196,6 +196,7 @@ nickSet=\u00a77Your nickname is now \u00a7c{0} noAccessCommand=\u00a7cYou do not have access to that command. noAccessPermission=\u00a7cYou do not have permission to access that {0}. noDestroyPermission=\u00a7cYou do not have permission to destroy that {0}. +noGodWorldWarning=\u00a7cWarning! God mode in this world disabled. noHelpFound=\u00a7cNo matching commands. noHomeSet=You have not set a home. noHomeSetPlayer=Player has not set a home. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 0650019ce..dd2ee3b97 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -197,6 +197,7 @@ noAccessCommand=\u00a7cDu har ikke adgang til den kommando. noAccessPermission=\u00a7cDu har ikke tilladelse til at f\u00e5 adgang til det {0}. noDestroyPermission=\u00a7cDu har ikke tilladelse til at \u00f8del\u00e6gge det {0}. noHelpFound=\u00a7cNo matching commands. +noGodWorldWarning=\u00a7cWarning! God mode in this world disabled. noHomeSet=Du har sat et nyt hjem. noHomeSetPlayer=Spiller har ikke sat et hjem. noKitPermission=\u00a7cDu har brug for \u00a7c{0}\u00a7c tilladelsen for at bruge den pakke. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 609618a68..d14141507 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -196,6 +196,7 @@ nickSet=\u00a77Dein Nickname ist nun \u00a7c{0} noAccessCommand=\u00a7cDu hast keinen Zugriff auf diesen Befehl. noAccessPermission=\u00a7cDu hast keine Rechte, den Block {0} zu \u00f6ffnen. noDestroyPermission=\u00a7cDu hast keine Rechte, den Block {0} zu zerst\u00f6ren. +noGodWorldWarning=\u00a7cWarning! God mode in this world disabled. noHelpFound=\u00a7cKeine \u00fcbereinstimmenden Kommandos. noHomeSet=Du hast kein Zuhause gesetzt. noHomeSetPlayer=Spieler hat kein Zuhause gesetzt. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index a78dfe94f..8843cf194 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -196,6 +196,7 @@ nickSet=\u00a77Your nickname is now \u00a7c{0} noAccessCommand=\u00a7cYou do not have access to that command. noAccessPermission=\u00a7cYou do not have permission to access that {0}. noDestroyPermission=\u00a7cYou do not have permission to destroy that {0}. +noGodWorldWarning=\u00a7cWarning! God mode in this world disabled. noHelpFound=\u00a7cNo matching commands. noHomeSet=You have not set a home. noHomeSetPlayer=Player has not set a home. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index ae3156d86..95fda63ac 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -196,6 +196,7 @@ nickSet=\u00a77Tu nombre es ahora \u00a7c{0} noAccessCommand=\u00a7cNo tienes acceso a ese comando. noAccessPermission=\u00a7cNo tienes permisos para hacer eso {0}. noDestroyPermission=\u00a7cNo tienes permisos para destrozar eso {0}. +noGodWorldWarning=\u00a7cWarning! God mode in this world disabled. noHelpFound=\u00a7cNo hay comandos relacionados. noHomeSet=No has establecido un hogar. noHomeSetPlayer=El jugador no ha establecido un hogar. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index df51d80d3..f64968250 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -196,6 +196,7 @@ nickSet=\u00a77Votre pseudo est maintenant \u00a7c{0} noAccessCommand=\u00a7cVous n''avez pas acc\u00e8s \u00e0 cette commande. noAccessPermission=\u00a7cVous n''avez pas la permissions d''acc\u00e9der \u00e0 cette {0} noDestroyPermission=\u00a7cVous n''avez pas la permission de d\u00e9truire ce {0}. +noGodWorldWarning=\u00a7cWarning! God mode in this world disabled. noHelpFound=\u00a7cNo matching commands. noHomeSet=Vous n''avez pas d\u00e9fini de home. noHomeSetPlayer=Le joueur n''a pas d\u00e9fini son home. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 1fe0ab01f..5907a1047 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -196,6 +196,7 @@ nickSet=\u00a77Je nickname is nu \u00a7c{0} noAccessCommand=\u00a7cJe hebt geen toegang tot die opdracht. noAccessPermission=\u00a7cJe hebt hier geen toegang voor {0}. noDestroyPermission=\u00a7cJe hebt geen toegang om dat te vernietigen {0}. +noGodWorldWarning=\u00a7cWarning! God mode in this world disabled. noHelpFound=\u00a7cNo matching commands. noHomeSet=Je hebt geen home gemaakt. noHomeSetPlayer=Speler heeft geen home. |