mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 20:00:46 +00:00
Disable god mode automatically in worlds defined by config
This commit is contained in:
parent
73d13f5748
commit
871c0e6b6a
13 changed files with 54 additions and 11 deletions
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 | #
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue