mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +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_EGG_THROW, playerListener, Priority.High, this);
|
||||||
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, 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_ANIMATION, playerListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Type.PLAYER_CHANGED_WORLD, playerListener, Priority.Normal, this);
|
||||||
|
|
||||||
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
|
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
|
||||||
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);
|
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);
|
||||||
|
|
|
@ -385,4 +385,15 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||||
user.updateActivity(true);
|
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 com.earth2me.essentials.commands.IEssentialsCommand;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
|
||||||
public interface ISettings extends IConf
|
public interface ISettings extends IConf
|
||||||
{
|
{
|
||||||
|
|
||||||
boolean areSignsDisabled();
|
boolean areSignsDisabled();
|
||||||
|
|
||||||
String format(String format, IUser user);
|
String format(String format, IUser user);
|
||||||
|
@ -138,4 +138,6 @@ public interface ISettings extends IConf
|
||||||
boolean areDeathMessagesEnabled();
|
boolean areDeathMessagesEnabled();
|
||||||
|
|
||||||
public void setDebug(boolean debug);
|
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 com.earth2me.essentials.commands.IEssentialsCommand;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -341,6 +344,7 @@ public class Settings implements ISettings
|
||||||
public void reloadConfig()
|
public void reloadConfig()
|
||||||
{
|
{
|
||||||
config.load();
|
config.load();
|
||||||
|
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds",Collections.<String>emptyList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -544,6 +548,14 @@ public class Settings implements ISettings
|
||||||
return config.getBoolean("death-messages", true);
|
return config.getBoolean("death-messages", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Set <String> noGodWorlds = new HashSet<String>();
|
||||||
|
@Override
|
||||||
|
public Set<String> getNoGodWorlds()
|
||||||
|
{
|
||||||
|
return noGodWorlds;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDebug(final boolean debug)
|
public void setDebug(final boolean debug)
|
||||||
{
|
{
|
||||||
|
|
|
@ -513,7 +513,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
@Override
|
@Override
|
||||||
public boolean isGodModeEnabled()
|
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()
|
public String getGroup()
|
||||||
|
|
|
@ -229,6 +229,10 @@ freeze-afk-players: false
|
||||||
# You can disable the death messages of minecraft here
|
# You can disable the death messages of minecraft here
|
||||||
death-messages: true
|
death-messages: true
|
||||||
|
|
||||||
|
# Add worlds to this list, if you want to automatically disable god mode there
|
||||||
|
no-god-in-worlds:
|
||||||
|
# - world_nether
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# +------------------------------------------------------+ #
|
# +------------------------------------------------------+ #
|
||||||
# | EssentialsHome | #
|
# | EssentialsHome | #
|
||||||
|
|
|
@ -196,6 +196,7 @@ nickSet=\u00a77Your nickname is now \u00a7c{0}
|
||||||
noAccessCommand=\u00a7cYou do not have access to that command.
|
noAccessCommand=\u00a7cYou do not have access to that command.
|
||||||
noAccessPermission=\u00a7cYou do not have permission to access that {0}.
|
noAccessPermission=\u00a7cYou do not have permission to access that {0}.
|
||||||
noDestroyPermission=\u00a7cYou do not have permission to destroy that {0}.
|
noDestroyPermission=\u00a7cYou do not have permission to destroy that {0}.
|
||||||
|
noGodWorldWarning=\u00a7cWarning! God mode in this world disabled.
|
||||||
noHelpFound=\u00a7cNo matching commands.
|
noHelpFound=\u00a7cNo matching commands.
|
||||||
noHomeSet=You have not set a home.
|
noHomeSet=You have not set a home.
|
||||||
noHomeSetPlayer=Player has 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}.
|
noAccessPermission=\u00a7cDu har ikke tilladelse til at f\u00e5 adgang til det {0}.
|
||||||
noDestroyPermission=\u00a7cDu har ikke tilladelse til at \u00f8del\u00e6gge det {0}.
|
noDestroyPermission=\u00a7cDu har ikke tilladelse til at \u00f8del\u00e6gge det {0}.
|
||||||
noHelpFound=\u00a7cNo matching commands.
|
noHelpFound=\u00a7cNo matching commands.
|
||||||
|
noGodWorldWarning=\u00a7cWarning! God mode in this world disabled.
|
||||||
noHomeSet=Du har sat et nyt hjem.
|
noHomeSet=Du har sat et nyt hjem.
|
||||||
noHomeSetPlayer=Spiller har ikke sat et hjem.
|
noHomeSetPlayer=Spiller har ikke sat et hjem.
|
||||||
noKitPermission=\u00a7cDu har brug for \u00a7c{0}\u00a7c tilladelsen for at bruge den pakke.
|
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.
|
noAccessCommand=\u00a7cDu hast keinen Zugriff auf diesen Befehl.
|
||||||
noAccessPermission=\u00a7cDu hast keine Rechte, den Block {0} zu \u00f6ffnen.
|
noAccessPermission=\u00a7cDu hast keine Rechte, den Block {0} zu \u00f6ffnen.
|
||||||
noDestroyPermission=\u00a7cDu hast keine Rechte, den Block {0} zu zerst\u00f6ren.
|
noDestroyPermission=\u00a7cDu hast keine Rechte, den Block {0} zu zerst\u00f6ren.
|
||||||
|
noGodWorldWarning=\u00a7cWarning! God mode in this world disabled.
|
||||||
noHelpFound=\u00a7cKeine \u00fcbereinstimmenden Kommandos.
|
noHelpFound=\u00a7cKeine \u00fcbereinstimmenden Kommandos.
|
||||||
noHomeSet=Du hast kein Zuhause gesetzt.
|
noHomeSet=Du hast kein Zuhause gesetzt.
|
||||||
noHomeSetPlayer=Spieler hat 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.
|
noAccessCommand=\u00a7cYou do not have access to that command.
|
||||||
noAccessPermission=\u00a7cYou do not have permission to access that {0}.
|
noAccessPermission=\u00a7cYou do not have permission to access that {0}.
|
||||||
noDestroyPermission=\u00a7cYou do not have permission to destroy that {0}.
|
noDestroyPermission=\u00a7cYou do not have permission to destroy that {0}.
|
||||||
|
noGodWorldWarning=\u00a7cWarning! God mode in this world disabled.
|
||||||
noHelpFound=\u00a7cNo matching commands.
|
noHelpFound=\u00a7cNo matching commands.
|
||||||
noHomeSet=You have not set a home.
|
noHomeSet=You have not set a home.
|
||||||
noHomeSetPlayer=Player has 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.
|
noAccessCommand=\u00a7cNo tienes acceso a ese comando.
|
||||||
noAccessPermission=\u00a7cNo tienes permisos para hacer eso {0}.
|
noAccessPermission=\u00a7cNo tienes permisos para hacer eso {0}.
|
||||||
noDestroyPermission=\u00a7cNo tienes permisos para destrozar eso {0}.
|
noDestroyPermission=\u00a7cNo tienes permisos para destrozar eso {0}.
|
||||||
|
noGodWorldWarning=\u00a7cWarning! God mode in this world disabled.
|
||||||
noHelpFound=\u00a7cNo hay comandos relacionados.
|
noHelpFound=\u00a7cNo hay comandos relacionados.
|
||||||
noHomeSet=No has establecido un hogar.
|
noHomeSet=No has establecido un hogar.
|
||||||
noHomeSetPlayer=El jugador no ha 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.
|
noAccessCommand=\u00a7cVous n''avez pas acc\u00e8s \u00e0 cette commande.
|
||||||
noAccessPermission=\u00a7cVous n''avez pas la permissions d''acc\u00e9der \u00e0 cette {0}
|
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}.
|
noDestroyPermission=\u00a7cVous n''avez pas la permission de d\u00e9truire ce {0}.
|
||||||
|
noGodWorldWarning=\u00a7cWarning! God mode in this world disabled.
|
||||||
noHelpFound=\u00a7cNo matching commands.
|
noHelpFound=\u00a7cNo matching commands.
|
||||||
noHomeSet=Vous n''avez pas d\u00e9fini de home.
|
noHomeSet=Vous n''avez pas d\u00e9fini de home.
|
||||||
noHomeSetPlayer=Le joueur n''a pas d\u00e9fini son 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.
|
noAccessCommand=\u00a7cJe hebt geen toegang tot die opdracht.
|
||||||
noAccessPermission=\u00a7cJe hebt hier geen toegang voor {0}.
|
noAccessPermission=\u00a7cJe hebt hier geen toegang voor {0}.
|
||||||
noDestroyPermission=\u00a7cJe hebt geen toegang om dat te vernietigen {0}.
|
noDestroyPermission=\u00a7cJe hebt geen toegang om dat te vernietigen {0}.
|
||||||
|
noGodWorldWarning=\u00a7cWarning! God mode in this world disabled.
|
||||||
noHelpFound=\u00a7cNo matching commands.
|
noHelpFound=\u00a7cNo matching commands.
|
||||||
noHomeSet=Je hebt geen home gemaakt.
|
noHomeSet=Je hebt geen home gemaakt.
|
||||||
noHomeSetPlayer=Speler heeft geen home.
|
noHomeSetPlayer=Speler heeft geen home.
|
||||||
|
|
Loading…
Reference in a new issue