mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-05 12:10:12 +08:00
Implement max mute time feature (#2807)
This commit is contained in:
parent
347179373d
commit
338b371e4c
@ -238,6 +238,8 @@ public interface ISettings extends IConf {
|
||||
|
||||
void setEssentialsChatActive(boolean b);
|
||||
|
||||
long getMaxMute();
|
||||
|
||||
long getMaxTempban();
|
||||
|
||||
Map<String, Object> getListGroupConfig();
|
||||
|
@ -1133,6 +1133,11 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
return permissionsLagWarning;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxMute() {
|
||||
return config.getLong("max-mute-time", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxTempban() {
|
||||
return config.getLong("max-tempban-time", -1);
|
||||
|
@ -7,6 +7,7 @@ import com.earth2me.essentials.utils.DateUtil;
|
||||
import net.ess3.api.events.MuteStatusChangeEvent;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -40,6 +41,25 @@ public class Commandmute extends EssentialsCommand {
|
||||
throw new Exception(tl("muteExempt"));
|
||||
}
|
||||
}
|
||||
|
||||
long muteTimestamp = 0;
|
||||
String time;
|
||||
String muteReason = "";
|
||||
|
||||
if (args.length > 1) {
|
||||
time = args[1];
|
||||
try {
|
||||
muteTimestamp = DateUtil.parseDateDiff(time, true);
|
||||
muteReason = getFinalArg(args, 2);
|
||||
} catch (Exception e) {
|
||||
muteReason = getFinalArg(args, 1);
|
||||
}
|
||||
final long maxMuteLength = ess.getSettings().getMaxMute() * 1000;
|
||||
if (maxMuteLength > 0 && ((muteTimestamp - GregorianCalendar.getInstance().getTimeInMillis()) > maxMuteLength) && sender.isPlayer() && !(ess.getUser(sender.getPlayer()).isAuthorized("essentials.mute.unlimited"))) {
|
||||
sender.sendMessage(tl("oversizedMute"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
final boolean willMute = (args.length > 1) || !user.getMuted();
|
||||
final User controller = sender.isPlayer() ? ess.getUser(sender.getPlayer()) : null;
|
||||
@ -47,18 +67,7 @@ public class Commandmute extends EssentialsCommand {
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
long muteTimestamp = 0;
|
||||
|
||||
if (args.length > 1) {
|
||||
final String time = args[1];
|
||||
String muteReason;
|
||||
try {
|
||||
muteTimestamp = DateUtil.parseDateDiff(time, true);
|
||||
muteReason = getFinalArg(args, 2);
|
||||
} catch (Exception e) {
|
||||
muteReason = getFinalArg(args, 1);
|
||||
}
|
||||
|
||||
user.setMuteReason(muteReason.isEmpty() ? null : muteReason);
|
||||
user.setMuted(true);
|
||||
} else {
|
||||
|
@ -491,6 +491,10 @@ max-walk-speed: 0.8
|
||||
#Set the maximum amount of mail that can be sent within a minute.
|
||||
mails-per-minute: 1000
|
||||
|
||||
# Set the maximum time /mute can be used for in seconds.
|
||||
# Set to -1 to disable, and essentials.mute.unlimited can be used to override.
|
||||
max-mute-time: -1
|
||||
|
||||
# Set the maximum time /tempban can be used for in seconds.
|
||||
# Set to -1 to disable, and essentials.tempban.unlimited can be used to override.
|
||||
max-tempban-time: -1
|
||||
|
@ -376,6 +376,7 @@ onlyPlayerSkulls=\u00a74You can only set the owner of player skulls (\u00a7c397\
|
||||
onlySunStorm=\u00a74/weather only supports sun/storm.
|
||||
openingDisposal=\u00a76Opening disposal menu...
|
||||
orderBalances=\u00a76Ordering balances of\u00a7c {0} \u00a76users, please wait...
|
||||
oversizedMute=§4You may not mute a player for this period of time.
|
||||
oversizedTempban=\u00a74You may not ban a player for this period of time.
|
||||
payConfirmToggleOff=\u00a76You will no longer be prompted to confirm payments.
|
||||
payConfirmToggleOn=\u00a76You will now be prompted to confirm payments.
|
||||
|
Loading…
Reference in New Issue
Block a user