mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-11 11:49:12 +00:00
Document no-god-in-worlds feature usage in code.
This commit is contained in:
parent
04f14285e7
commit
0ab9f04ea4
2 changed files with 18 additions and 1 deletions
|
@ -484,6 +484,8 @@ public class EssentialsPlayerListener implements Listener {
|
|||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw()) {
|
||||
// Player god mode is never disabled in order to retain it when changing worlds once more.
|
||||
// With that said, players will still take damage as per the result of User#isGodModeEnabled()
|
||||
user.sendMessage(tl("noGodWorldWarning"));
|
||||
}
|
||||
|
||||
|
|
|
@ -550,7 +550,22 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
|||
|
||||
@Override
|
||||
public boolean isGodModeEnabled() {
|
||||
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(this.getLocation().getWorld().getName())) || (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
||||
if (super.isGodModeEnabled()) {
|
||||
// This enables the no-god-in-worlds functionality where the actual player god mode state is never modified in disabled worlds,
|
||||
// but this method gets called every time the player takes damage. In the case that the world has god-mode disabled then this method
|
||||
// will return false and the player will take damage, even though they are in god mode (isGodModeEnabledRaw()).
|
||||
if (ess.getSettings().getNoGodWorlds().contains(this.getLocation().getWorld().getName())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (isAfk()) {
|
||||
// Protect AFK players by representing them in a god mode state to render them invulnerable to damage.
|
||||
if (ess.getSettings().getFreezeAfkPlayers()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isGodModeEnabledRaw() {
|
||||
|
|
Loading…
Reference in a new issue