Fixed issue with premature return statement in unmute task

This commit is contained in:
Aust1n46 2020-08-24 23:10:59 -05:00
parent b2b1a0ec38
commit c0847f6b87
4 changed files with 12 additions and 6 deletions

View File

@ -417,17 +417,18 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
} }
} }
}, 0L, getConfig().getInt("saveinterval") * 1200); //one minute * save interval }, 0L, getConfig().getInt("saveinterval") * 1200); //one minute * save interval
scheduler.runTaskTimerAsynchronously(this, new Runnable() { scheduler.runTaskTimerAsynchronously(this, new Runnable() {
@Override @Override
public void run() { public void run() {
for (MineverseChatPlayer p : MineverseChat.onlinePlayers) { for (MineverseChatPlayer p : MineverseChat.onlinePlayers) {
int time = (int) System.currentTimeMillis(); int time = Format.currentTimeMillis();
Iterator<String> iterator = p.getMutes().keySet().iterator(); Iterator<String> iterator = p.getMutes().keySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
ChatChannel channel = ChatChannel.getChannel(iterator.next()); ChatChannel channel = ChatChannel.getChannel(iterator.next());
int timemark = p.getMutes().get(channel.getName()); int timemark = p.getMutes().get(channel.getName());
if (timemark == 0) { if (timemark == 0) {
return; continue;
} }
if (getConfig().getString("loglevel", "info").equals("debug")) { if (getConfig().getString("loglevel", "info").equals("debug")) {
System.out.println(time + " " + timemark); System.out.println(time + " " + timemark);

View File

@ -8,6 +8,7 @@ import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import mineverse.Aust1n46.chat.channel.ChatChannel; import mineverse.Aust1n46.chat.channel.ChatChannel;
import mineverse.Aust1n46.chat.command.MineverseCommand; import mineverse.Aust1n46.chat.command.MineverseCommand;
import mineverse.Aust1n46.chat.localization.LocalizedMessage; import mineverse.Aust1n46.chat.localization.LocalizedMessage;
import mineverse.Aust1n46.chat.utilities.Format;
public class Mute extends MineverseCommand { public class Mute extends MineverseCommand {
private static final int MILLISECONDS_PER_MINUTE = 60000; private static final int MILLISECONDS_PER_MINUTE = 60000;
@ -73,7 +74,7 @@ public class Mute extends MineverseCommand {
} }
if (channel.isMutable()) { if (channel.isMutable()) {
try { try {
int datetime = (int) System.currentTimeMillis(); int datetime = Format.currentTimeMillis();
int time = Integer.parseInt(args[2]); int time = Integer.parseInt(args[2]);
if (time > 0) { if (time > 0) {
player.addMute(channel.getName(), datetime + (time * MILLISECONDS_PER_MINUTE)); player.addMute(channel.getName(), datetime + (time * MILLISECONDS_PER_MINUTE));

View File

@ -213,7 +213,7 @@ public class ChatListener implements Listener {
mcp.addListening(eventChannel.getName()); mcp.addListening(eventChannel.getName());
if (mcp.isMuted(eventChannel.getName())) { if (mcp.isMuted(eventChannel.getName())) {
if (mcp.getMutes().get(eventChannel.getName()).intValue() > 0) { if (mcp.getMutes().get(eventChannel.getName()).intValue() > 0) {
int dateTimeMillis = (int) System.currentTimeMillis(); int dateTimeMillis = Format.currentTimeMillis();
String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString(); String units = LocalizedMessage.UNITS_MINUTE_PLURAL.toString();
int muteTimeMillis = mcp.getMutes().get(eventChannel.getName()).intValue(); int muteTimeMillis = mcp.getMutes().get(eventChannel.getName()).intValue();
int remainingMuteTime = (muteTimeMillis - dateTimeMillis) / MILLISECONDS_PER_MINUTE; int remainingMuteTime = (muteTimeMillis - dateTimeMillis) / MILLISECONDS_PER_MINUTE;
@ -256,7 +256,7 @@ public class ChatListener implements Listener {
curColor = eventChannel.getChatColor(); curColor = eventChannel.getChatColor();
bungee = eventChannel.getBungee(); bungee = eventChannel.getBungee();
int dateTimeSeconds = (int) System.currentTimeMillis() / MILLISECONDS_PER_SECOND; int dateTimeSeconds = Format.currentTimeMillis() / MILLISECONDS_PER_SECOND;
if(eventChannel.hasCooldown()) { if(eventChannel.hasCooldown()) {
chCooldown = eventChannel.getCooldown(); chCooldown = eventChannel.getCooldown();
@ -292,7 +292,7 @@ public class ChatListener implements Listener {
int spamtime = mcp.getSpam().get(eventChannel).get(1); int spamtime = mcp.getSpam().get(eventChannel).get(1);
int spamtimeconfig = plugin.getConfig().getConfigurationSection("antispam").getInt("spamnumber"); int spamtimeconfig = plugin.getConfig().getConfigurationSection("antispam").getInt("spamnumber");
int mutedForTime = plugin.getConfig().getConfigurationSection("antispam").getInt("mutetime", 0); int mutedForTime = plugin.getConfig().getConfigurationSection("antispam").getInt("mutetime", 0);
int dateTime = (int) System.currentTimeMillis(); int dateTime = Format.currentTimeMillis();
if (dateTimeSeconds < spamtime if (dateTimeSeconds < spamtime
+ plugin.getConfig().getConfigurationSection("antispam").getInt("spamtime")) { + plugin.getConfig().getConfigurationSection("antispam").getInt("spamtime")) {
if (spamcount + 1 >= spamtimeconfig) { if (spamcount + 1 >= spamtimeconfig) {

View File

@ -540,4 +540,8 @@ public class Format {
public static boolean underlineURLs() { public static boolean underlineURLs() {
return plugin.getConfig().getBoolean("underlineurls", true); return plugin.getConfig().getBoolean("underlineurls", true);
} }
public static int currentTimeMillis() {
return (int) (System.currentTimeMillis() % Integer.MAX_VALUE);
}
} }