mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-04 13:47:53 +02:00
Update offline user check.
Add ban reason to /seen
This commit is contained in:
@@ -115,7 +115,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
|||||||
acquireReadLock();
|
acquireReadLock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!(user.getBase() instanceof OfflinePlayer))
|
if (user.isOnline())
|
||||||
{
|
{
|
||||||
Location loc = getJail(jail);
|
Location loc = getJail(jail);
|
||||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||||
|
@@ -267,7 +267,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final String opPrefix = ess.getSettings().getOperatorColor().toString();
|
final String opPrefix = ess.getSettings().getOperatorColor().toString();
|
||||||
if (opPrefix.length() > 0) {
|
if (opPrefix.length() > 0)
|
||||||
|
{
|
||||||
nickname.insert(0, opPrefix);
|
nickname.insert(0, opPrefix);
|
||||||
nickname.append("§f");
|
nickname.append("§f");
|
||||||
}
|
}
|
||||||
@@ -326,7 +327,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
|||||||
@Override
|
@Override
|
||||||
public String getDisplayName()
|
public String getDisplayName()
|
||||||
{
|
{
|
||||||
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
|
if (base.isOnline() && ess.getSettings().changeDisplayName())
|
||||||
{
|
{
|
||||||
setDisplayNick();
|
setDisplayNick();
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
|||||||
|
|
||||||
import com.earth2me.essentials.Console;
|
import com.earth2me.essentials.Console;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@@ -24,7 +23,7 @@ public class Commandban extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
final User user = getPlayer(server, args, 0, true);
|
final User user = getPlayer(server, args, 0, true);
|
||||||
if (user.getBase() instanceof OfflinePlayer)
|
if (!user.isOnline())
|
||||||
{
|
{
|
||||||
if (sender instanceof Player
|
if (sender instanceof Player
|
||||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||||
|
@@ -23,20 +23,20 @@ public class Commandseen extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
User u = getPlayer(server, args, 0);
|
User user = getPlayer(server, args, 0);
|
||||||
sender.sendMessage(_("seenOnline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogin())));
|
sender.sendMessage(_("seenOnline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogin())));
|
||||||
}
|
}
|
||||||
catch (NoSuchFieldException e)
|
catch (NoSuchFieldException e)
|
||||||
{
|
{
|
||||||
User u = ess.getOfflineUser(args[0]);
|
User user = ess.getOfflineUser(args[0]);
|
||||||
if (u == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
throw new Exception(_("playerNotFound"));
|
throw new Exception(_("playerNotFound"));
|
||||||
}
|
}
|
||||||
sender.sendMessage(_("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
|
sender.sendMessage(_("seenOffline", user.getDisplayName(), Util.formatDateDiff(user.getLastLogout())));
|
||||||
if (u.isBanned())
|
if (user.isBanned())
|
||||||
{
|
{
|
||||||
sender.sendMessage(_("whoisBanned", _("true")));
|
sender.sendMessage(_("whoisBanned", user.getBanReason()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
|||||||
|
|
||||||
import com.earth2me.essentials.Console;
|
import com.earth2me.essentials.Console;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.Util;
|
import com.earth2me.essentials.Util;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@@ -25,7 +24,7 @@ public class Commandtempban extends EssentialsCommand
|
|||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
final User user = getPlayer(server, args, 0, true);
|
final User user = getPlayer(server, args, 0, true);
|
||||||
if (user.getBase() instanceof OfflinePlayer)
|
if (!user.isOnline())
|
||||||
{
|
{
|
||||||
if (sender instanceof Player
|
if (sender instanceof Player
|
||||||
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
|
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.Util;
|
import com.earth2me.essentials.Util;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@@ -28,7 +27,7 @@ public class Commandtogglejail extends EssentialsCommand
|
|||||||
|
|
||||||
if (args.length >= 2 && !player.isJailed())
|
if (args.length >= 2 && !player.isJailed())
|
||||||
{
|
{
|
||||||
if (player.getBase() instanceof OfflinePlayer)
|
if (!player.isOnline())
|
||||||
{
|
{
|
||||||
if (sender instanceof Player
|
if (sender instanceof Player
|
||||||
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
|
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
|
||||||
@@ -45,7 +44,7 @@ public class Commandtogglejail extends EssentialsCommand
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(player.getBase() instanceof OfflinePlayer))
|
if (player.isOnline())
|
||||||
{
|
{
|
||||||
ess.getJails().sendToJail(player, args[1]);
|
ess.getJails().sendToJail(player, args[1]);
|
||||||
}
|
}
|
||||||
@@ -96,7 +95,7 @@ public class Commandtogglejail extends EssentialsCommand
|
|||||||
player.setJailTimeout(0);
|
player.setJailTimeout(0);
|
||||||
player.sendMessage(_("jailReleasedPlayerNotify"));
|
player.sendMessage(_("jailReleasedPlayerNotify"));
|
||||||
player.setJail(null);
|
player.setJail(null);
|
||||||
if (!(player.getBase() instanceof OfflinePlayer))
|
if (player.isOnline())
|
||||||
{
|
{
|
||||||
player.getTeleport().back();
|
player.getTeleport().back();
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
|
||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@@ -21,7 +20,7 @@ public class Commandtpaccept extends EssentialsCommand
|
|||||||
|
|
||||||
final User target = user.getTeleportRequest();
|
final User target = user.getTeleportRequest();
|
||||||
if (target == null
|
if (target == null
|
||||||
|| target.getBase() instanceof OfflinePlayer
|
|| !target.isOnline()
|
||||||
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere"))
|
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere"))
|
||||||
|| (!user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpa") && !target.isAuthorized("essentials.tpaall"))
|
|| (!user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpa") && !target.isAuthorized("essentials.tpaall"))
|
||||||
)
|
)
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
@@ -25,7 +24,7 @@ public class Commandtpo extends EssentialsCommand
|
|||||||
//Just basically the old tp command
|
//Just basically the old tp command
|
||||||
final User player = getPlayer(server, args, 0, true);
|
final User player = getPlayer(server, args, 0, true);
|
||||||
// Check if user is offline
|
// Check if user is offline
|
||||||
if (player.getBase() instanceof OfflinePlayer)
|
if (!player.isOnline())
|
||||||
{
|
{
|
||||||
throw new NoSuchFieldException(_("playerNotFound"));
|
throw new NoSuchFieldException(_("playerNotFound"));
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
@@ -26,7 +25,7 @@ public class Commandtpohere extends EssentialsCommand
|
|||||||
final User player = getPlayer(server, args, 0, true);
|
final User player = getPlayer(server, args, 0, true);
|
||||||
|
|
||||||
// Check if user is offline
|
// Check if user is offline
|
||||||
if (player.getBase() instanceof OfflinePlayer)
|
if (!player.isOnline())
|
||||||
{
|
{
|
||||||
throw new NoSuchFieldException(_("playerNotFound"));
|
throw new NoSuchFieldException(_("playerNotFound"));
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
|||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.IEssentials;
|
import com.earth2me.essentials.IEssentials;
|
||||||
import com.earth2me.essentials.IEssentialsModule;
|
import com.earth2me.essentials.IEssentialsModule;
|
||||||
import com.earth2me.essentials.OfflinePlayer;
|
|
||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -31,7 +30,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
|||||||
{
|
{
|
||||||
this.ess = ess;
|
this.ess = ess;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setEssentialsModule(final IEssentialsModule module)
|
public void setEssentialsModule(final IEssentialsModule module)
|
||||||
{
|
{
|
||||||
@@ -62,7 +61,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
|||||||
final User user = ess.getUser(args[pos]);
|
final User user = ess.getUser(args[pos]);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
if (!getOffline && (user.getBase() instanceof OfflinePlayer || user.isHidden()))
|
if (!getOffline && (!user.isOnline() || user.isHidden()))
|
||||||
{
|
{
|
||||||
throw new NoSuchFieldException(_("playerNotFound"));
|
throw new NoSuchFieldException(_("playerNotFound"));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user