mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-14 21:22:09 +00:00
Add muting offline players
Permission: essentials.mute.offline
This commit is contained in:
parent
75fe543579
commit
92a2244650
3 changed files with 54 additions and 27 deletions
|
@ -1,6 +1,7 @@
|
||||||
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.utils.DateUtil;
|
import com.earth2me.essentials.utils.DateUtil;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
@ -18,50 +19,76 @@ public class Commandmute extends EssentialsCommand
|
||||||
@Override
|
@Override
|
||||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||||
{
|
{
|
||||||
|
boolean nomatch = false;
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
throw new NotEnoughArgumentsException();
|
throw new NotEnoughArgumentsException();
|
||||||
}
|
}
|
||||||
|
User user;
|
||||||
final User player = getPlayer(server, sender, args, 0);
|
try
|
||||||
if (sender instanceof Player && !player.isMuted() && player.isAuthorized("essentials.mute.exempt"))
|
|
||||||
{
|
{
|
||||||
throw new Exception(_("muteExempt"));
|
user = getPlayer(server, args, 0, true, true);
|
||||||
}
|
}
|
||||||
|
catch (NoSuchFieldException e)
|
||||||
|
{
|
||||||
|
nomatch = true;
|
||||||
|
user = ess.getUser(new OfflinePlayer(args[0], ess));
|
||||||
|
}
|
||||||
|
if (!user.isOnline())
|
||||||
|
{
|
||||||
|
if (sender instanceof Player
|
||||||
|
&& !ess.getUser(sender).isAuthorized("essentials.mute.offline"))
|
||||||
|
{
|
||||||
|
throw new Exception(_("muteExempt"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (user.isAuthorized("essentials.mute.exempt") && sender instanceof Player)
|
||||||
|
{
|
||||||
|
throw new Exception(_("muteExempt"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
long muteTimestamp = 0;
|
long muteTimestamp = 0;
|
||||||
|
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
final String time = getFinalArg(args, 1);
|
final String time = getFinalArg(args, 1);
|
||||||
muteTimestamp = DateUtil.parseDateDiff(time, true);
|
muteTimestamp = DateUtil.parseDateDiff(time, true);
|
||||||
player.setMuted(true);
|
user.setMuted(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.setMuted(!player.getMuted());
|
user.setMuted(!user.getMuted());
|
||||||
}
|
}
|
||||||
player.setMuteTimeout(muteTimestamp);
|
user.setMuteTimeout(muteTimestamp);
|
||||||
final boolean muted = player.getMuted();
|
final boolean muted = user.getMuted();
|
||||||
String muteTime = DateUtil.formatDateDiff(muteTimestamp);
|
String muteTime = DateUtil.formatDateDiff(muteTimestamp);
|
||||||
|
|
||||||
|
if (nomatch)
|
||||||
|
{
|
||||||
|
sender.sendMessage(_("userUnknown", user.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
if (muted)
|
if (muted)
|
||||||
{
|
{
|
||||||
if (muteTimestamp > 0)
|
if (muteTimestamp > 0)
|
||||||
{
|
{
|
||||||
sender.sendMessage(_("mutedPlayerFor", player.getDisplayName(), muteTime));
|
sender.sendMessage(_("mutedPlayerFor", user.getDisplayName(), muteTime));
|
||||||
player.sendMessage(_("playerMutedFor", muteTime));
|
user.sendMessage(_("playerMutedFor", muteTime));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage(_("mutedPlayer", player.getDisplayName()));
|
sender.sendMessage(_("mutedPlayer", user.getDisplayName()));
|
||||||
player.sendMessage(_("playerMuted"));
|
user.sendMessage(_("playerMuted"));
|
||||||
}
|
}
|
||||||
ess.broadcastMessage("essentials.mute.notify", _("muteNotify", sender.getName(), player.getName(), muteTime));
|
ess.broadcastMessage("essentials.mute.notify", _("muteNotify", sender.getName(), user.getName(), muteTime));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage(_("unmutedPlayer", player.getDisplayName()));
|
sender.sendMessage(_("unmutedPlayer", user.getDisplayName()));
|
||||||
player.sendMessage(_("playerUnmuted"));
|
user.sendMessage(_("playerUnmuted"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,9 +250,9 @@ msgFormat=\u00a76[{0}\u00a76 -> {1}\u00a76] \u00a7r{2}
|
||||||
multipleCharges=\u00a74You cannot apply more than one charge to this firework.
|
multipleCharges=\u00a74You cannot apply more than one charge to this firework.
|
||||||
multiplePotionEffects=\u00a74You cannot apply more than one effect to this potion.
|
multiplePotionEffects=\u00a74You cannot apply more than one effect to this potion.
|
||||||
muteExempt=\u00a74You may not mute that player.
|
muteExempt=\u00a74You may not mute that player.
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}\u00a76.
|
muteNotify=\u00a7c{0} \u00a76has muted \u00a7c{1}\u00a76.
|
||||||
mutedPlayer=\u00a76Player {0} \u00a76muted.
|
mutedPlayer=\u00a76Player\u00a7c {0} \u00a76muted.
|
||||||
mutedPlayerFor=\u00a76Player {0} \u00a76muted for {1}.
|
mutedPlayerFor=\u00a76Player\u00a7c {0} \u00a76muted for\u00a7c {1}\u00a76.
|
||||||
mutedUserSpeaks={0} tried to speak, but is muted.
|
mutedUserSpeaks={0} tried to speak, but is muted.
|
||||||
nearbyPlayers=\u00a76Players nearby\:\u00a7r {0}
|
nearbyPlayers=\u00a76Players nearby\:\u00a7r {0}
|
||||||
negativeBalanceError=\u00a74User is not allowed to have a negative balance.
|
negativeBalanceError=\u00a74User is not allowed to have a negative balance.
|
||||||
|
@ -319,8 +319,8 @@ pWeatherPlayers=\u00a76These players have their own weather\:\u00a7r
|
||||||
pWeatherReset=\u00a76Player weather has been reset for\: \u00a7c{0}
|
pWeatherReset=\u00a76Player weather has been reset for\: \u00a7c{0}
|
||||||
pWeatherSet=\u00a76Player weather is set to \u00a7c{0}\u00a76 for\: \u00a7c{1}.
|
pWeatherSet=\u00a76Player weather is set to \u00a7c{0}\u00a76 for\: \u00a7c{1}.
|
||||||
pendingTeleportCancelled=\u00a74Pending teleportation request cancelled.
|
pendingTeleportCancelled=\u00a74Pending teleportation request cancelled.
|
||||||
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1}\u00a76.
|
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address\u00a7c {1}\u00a76.
|
||||||
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned {1} \u00a76for {2}.
|
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned\u00a7c {1} \u00a76for {2}.
|
||||||
playerInJail=\u00a74Player is already in jail\u00a7c {0}\u00a76.
|
playerInJail=\u00a74Player is already in jail\u00a7c {0}\u00a76.
|
||||||
playerJailed=\u00a76Player\u00a7c {0} \u00a76jailed.
|
playerJailed=\u00a76Player\u00a7c {0} \u00a76jailed.
|
||||||
playerJailedFor=\u00a76Player\u00a7c {0} \u00a76jailed for {1}.
|
playerJailedFor=\u00a76Player\u00a7c {0} \u00a76jailed for {1}.
|
||||||
|
@ -330,7 +330,7 @@ playerMutedFor=\u00a76You have been muted for\u00a7c {0}.
|
||||||
playerNeverOnServer=\u00a74Player\u00a7c {0} \u00a74was never on this server.
|
playerNeverOnServer=\u00a74Player\u00a7c {0} \u00a74was never on this server.
|
||||||
playerNotFound=\u00a74Player not found.
|
playerNotFound=\u00a74Player not found.
|
||||||
playerUnbanIpAddress=\u00a76Player\u00a7c {0} \u00a76unbanned IP\: {1}.
|
playerUnbanIpAddress=\u00a76Player\u00a7c {0} \u00a76unbanned IP\: {1}.
|
||||||
playerUnbanned=\u00a76Player\u00a7c {0} \u00a76unbanned {1}.
|
playerUnbanned=\u00a76Player\u00a7c {0} \u00a76unbanned\u00a7c {1}.
|
||||||
playerUnmuted=\u00a76You have been unmuted.
|
playerUnmuted=\u00a76You have been unmuted.
|
||||||
pong=Pong\!
|
pong=Pong\!
|
||||||
posPitch=\u00a76Pitch\: {0} (Head angle)
|
posPitch=\u00a76Pitch\: {0} (Head angle)
|
||||||
|
|
|
@ -250,9 +250,9 @@ msgFormat=\u00a76[{0}\u00a76 -> {1}\u00a76] \u00a7r{2}
|
||||||
multipleCharges=\u00a74You cannot apply more than one charge to this firework.
|
multipleCharges=\u00a74You cannot apply more than one charge to this firework.
|
||||||
multiplePotionEffects=\u00a74You cannot apply more than one effect to this potion.
|
multiplePotionEffects=\u00a74You cannot apply more than one effect to this potion.
|
||||||
muteExempt=\u00a74You may not mute that player.
|
muteExempt=\u00a74You may not mute that player.
|
||||||
muteNotify=\u00a74{0} \u00a76has muted \u00a74{1}\u00a76.
|
muteNotify=\u00a7c{0} \u00a76has muted \u00a7c{1}\u00a76.
|
||||||
mutedPlayer=\u00a76Player {0} \u00a76muted.
|
mutedPlayer=\u00a76Player\u00a7c {0} \u00a76muted.
|
||||||
mutedPlayerFor=\u00a76Player {0} \u00a76muted for {1}.
|
mutedPlayerFor=\u00a76Player\u00a7c {0} \u00a76muted for\u00a7c {1}\u00a76.
|
||||||
mutedUserSpeaks={0} tried to speak, but is muted.
|
mutedUserSpeaks={0} tried to speak, but is muted.
|
||||||
nearbyPlayers=\u00a76Players nearby\:\u00a7r {0}
|
nearbyPlayers=\u00a76Players nearby\:\u00a7r {0}
|
||||||
negativeBalanceError=\u00a74User is not allowed to have a negative balance.
|
negativeBalanceError=\u00a74User is not allowed to have a negative balance.
|
||||||
|
@ -319,8 +319,8 @@ pWeatherPlayers=\u00a76These players have their own weather\:\u00a7r
|
||||||
pWeatherReset=\u00a76Player weather has been reset for\: \u00a7c{0}
|
pWeatherReset=\u00a76Player weather has been reset for\: \u00a7c{0}
|
||||||
pWeatherSet=\u00a76Player weather is set to \u00a7c{0}\u00a76 for\: \u00a7c{1}.
|
pWeatherSet=\u00a76Player weather is set to \u00a7c{0}\u00a76 for\: \u00a7c{1}.
|
||||||
pendingTeleportCancelled=\u00a74Pending teleportation request cancelled.
|
pendingTeleportCancelled=\u00a74Pending teleportation request cancelled.
|
||||||
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address {1}\u00a76.
|
playerBanIpAddress=\u00a76Player\u00a7c {0} \u00a76banned IP address\u00a7c {1}\u00a76.
|
||||||
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned {1} \u00a76for {2}.
|
playerBanned=\u00a76Player\u00a7c {0} \u00a76banned\u00a7c {1} \u00a76for {2}.
|
||||||
playerInJail=\u00a74Player is already in jail\u00a7c {0}\u00a76.
|
playerInJail=\u00a74Player is already in jail\u00a7c {0}\u00a76.
|
||||||
playerJailed=\u00a76Player\u00a7c {0} \u00a76jailed.
|
playerJailed=\u00a76Player\u00a7c {0} \u00a76jailed.
|
||||||
playerJailedFor=\u00a76Player\u00a7c {0} \u00a76jailed for {1}.
|
playerJailedFor=\u00a76Player\u00a7c {0} \u00a76jailed for {1}.
|
||||||
|
@ -330,7 +330,7 @@ playerMutedFor=\u00a76You have been muted for\u00a7c {0}.
|
||||||
playerNeverOnServer=\u00a74Player\u00a7c {0} \u00a74was never on this server.
|
playerNeverOnServer=\u00a74Player\u00a7c {0} \u00a74was never on this server.
|
||||||
playerNotFound=\u00a74Player not found.
|
playerNotFound=\u00a74Player not found.
|
||||||
playerUnbanIpAddress=\u00a76Player\u00a7c {0} \u00a76unbanned IP\: {1}.
|
playerUnbanIpAddress=\u00a76Player\u00a7c {0} \u00a76unbanned IP\: {1}.
|
||||||
playerUnbanned=\u00a76Player\u00a7c {0} \u00a76unbanned {1}.
|
playerUnbanned=\u00a76Player\u00a7c {0} \u00a76unbanned\u00a7c {1}.
|
||||||
playerUnmuted=\u00a76You have been unmuted.
|
playerUnmuted=\u00a76You have been unmuted.
|
||||||
pong=Pong\!
|
pong=Pong\!
|
||||||
posPitch=\u00a76Pitch\: {0} (Head angle)
|
posPitch=\u00a76Pitch\: {0} (Head angle)
|
||||||
|
|
Loading…
Reference in a new issue