mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-23 10:39:05 +00:00
Changed cooldown code to be unbreakable this time (Lets all hope)
This commit is contained in:
parent
221e523c79
commit
d1d1f4c4b8
@ -482,11 +482,14 @@ public class MineverseChat extends JavaPlugin implements PluginMessageListener {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for(MineverseChatPlayer p : MineverseChat.players) {
|
for(MineverseChatPlayer p : MineverseChat.players) {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
//Calendar currentDate = Calendar.getInstance();
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
//SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
||||||
String date = formatter.format(currentDate.getTime());
|
//String date = formatter.format(currentDate.getTime());
|
||||||
String[] datearray = date.split(":");
|
//String[] datearray = date.split(":");
|
||||||
int time = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
//int time = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
||||||
|
|
||||||
|
int time = (int) (System.currentTimeMillis() / 60000);
|
||||||
|
|
||||||
for(String c : p.getMutes().keySet()) {
|
for(String c : p.getMutes().keySet()) {
|
||||||
ChatChannel channel = ccInfo.getChannelInfo(c);
|
ChatChannel channel = ccInfo.getChannelInfo(c);
|
||||||
int timemark = p.getMutes().get(channel.getName());
|
int timemark = p.getMutes().get(channel.getName());
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
package mineverse.Aust1n46.chat.command.mute;
|
package mineverse.Aust1n46.chat.command.mute;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -65,11 +62,14 @@ public class Mute extends MineverseCommand {
|
|||||||
}
|
}
|
||||||
if(channel.isMutable()) {
|
if(channel.isMutable()) {
|
||||||
try {
|
try {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
//Calendar currentDate = Calendar.getInstance();
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
//SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
||||||
String date = formatter.format(currentDate.getTime());
|
//String date = formatter.format(currentDate.getTime());
|
||||||
String[] datearray = date.split(":");
|
//String[] datearray = date.split(":");
|
||||||
int datetime = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
//int datetime = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
||||||
|
|
||||||
|
int datetime = (int) (System.currentTimeMillis() / 60000);
|
||||||
|
|
||||||
int time = Integer.parseInt(args[2]);
|
int time = Integer.parseInt(args[2]);
|
||||||
if(time > 0) {
|
if(time > 0) {
|
||||||
player.addMute(channel.getName(), datetime + time);
|
player.addMute(channel.getName(), datetime + time);
|
||||||
|
@ -409,14 +409,17 @@ public class ChatListener implements Listener {
|
|||||||
if(mcp.isMuted(eventChannel.getName())) {
|
if(mcp.isMuted(eventChannel.getName())) {
|
||||||
String timedMute = "";
|
String timedMute = "";
|
||||||
if(mcp.getMutes().get(eventChannel.getName()).intValue() > 0) {
|
if(mcp.getMutes().get(eventChannel.getName()).intValue() > 0) {
|
||||||
Calendar currentDate = Calendar.getInstance();
|
//Calendar currentDate = Calendar.getInstance();
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
//SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
||||||
String date = formatter.format(currentDate.getTime());
|
//String date = formatter.format(currentDate.getTime());
|
||||||
String[] datearray = date.split(":");
|
//String[] datearray = date.split(":");
|
||||||
int datetime = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
//int datetime = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
||||||
|
|
||||||
|
int time = (int) (System.currentTimeMillis() / 60000);
|
||||||
|
|
||||||
String keyword = "minutes";
|
String keyword = "minutes";
|
||||||
int time = mcp.getMutes().get(eventChannel.getName()).intValue();
|
int timemark = mcp.getMutes().get(eventChannel.getName()).intValue();
|
||||||
int remaining = time - datetime;
|
int remaining = timemark - time;
|
||||||
if(remaining <= 0) remaining = 1;
|
if(remaining <= 0) remaining = 1;
|
||||||
if(remaining == 1) keyword = "minute";
|
if(remaining == 1) keyword = "minute";
|
||||||
timedMute = ChatColor.RED + " for " + remaining + " more " + keyword;
|
timedMute = ChatColor.RED + " for " + remaining + " more " + keyword;
|
||||||
@ -445,17 +448,21 @@ public class ChatListener implements Listener {
|
|||||||
Calendar currentDate = Calendar.getInstance();
|
Calendar currentDate = Calendar.getInstance();
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
SimpleDateFormat formatter = new SimpleDateFormat("dd:HH:mm:ss");
|
||||||
String date = formatter.format(currentDate.getTime());
|
String date = formatter.format(currentDate.getTime());
|
||||||
String[] datearray = date.split(":");
|
//String[] datearray = date.split(":");
|
||||||
int time = (Integer.parseInt(datearray[0]) * 86400) + (Integer.parseInt(datearray[1]) * 3600) + (Integer.parseInt(datearray[2]) * 60) + (Integer.parseInt(datearray[3]));
|
//int time = (Integer.parseInt(datearray[0]) * 86400) + (Integer.parseInt(datearray[1]) * 3600) + (Integer.parseInt(datearray[2]) * 60) + (Integer.parseInt(datearray[3]));
|
||||||
int datetime = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
//int datetime = (Integer.parseInt(datearray[0]) * 1440) + (Integer.parseInt(datearray[1]) * 60) + (Integer.parseInt(datearray[2]));
|
||||||
|
|
||||||
|
int time = (int) (System.currentTimeMillis() / 1000);
|
||||||
|
|
||||||
if(eventChannel.hasCooldown()) {
|
if(eventChannel.hasCooldown()) {
|
||||||
chCooldown = eventChannel.getCooldown();
|
chCooldown = eventChannel.getCooldown();
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if(mcp.hasCooldown(eventChannel)) {
|
if(mcp.hasCooldown(eventChannel)) {
|
||||||
int timemark = mcp.getCooldowns().get(eventChannel).intValue();
|
int timemark = mcp.getCooldowns().get(eventChannel).intValue();
|
||||||
if(time < timemark + chCooldown) {
|
System.out.println("Checking cooldown for " + mcp.getName() + " as time " + timemark + " current time as " + time);
|
||||||
int remaining = timemark + chCooldown - time;
|
if(time < timemark) {
|
||||||
|
int remaining = timemark - time;
|
||||||
String keyword = "seconds";
|
String keyword = "seconds";
|
||||||
if(remaining == 1) keyword = "second";
|
if(remaining == 1) keyword = "second";
|
||||||
mcp.getPlayer().sendMessage(ChatColor.RED + "" + remaining + " " + keyword + " of cooldown remaining.");
|
mcp.getPlayer().sendMessage(ChatColor.RED + "" + remaining + " " + keyword + " of cooldown remaining.");
|
||||||
@ -467,7 +474,8 @@ public class ChatListener implements Listener {
|
|||||||
}
|
}
|
||||||
if(eventChannel.hasCooldown() && !event.isCancelled()) {
|
if(eventChannel.hasCooldown() && !event.isCancelled()) {
|
||||||
if(!mcp.getPlayer().hasPermission("venturechat.cooldown.bypass")) {
|
if(!mcp.getPlayer().hasPermission("venturechat.cooldown.bypass")) {
|
||||||
mcp.addCooldown(eventChannel, time);
|
mcp.addCooldown(eventChannel, time + chCooldown);
|
||||||
|
System.out.println("Added new cooldown for " + mcp.getName() + " as current time " + (time + chCooldown));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,7 +488,9 @@ 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 mutedfor = plugin.getConfig().getConfigurationSection("antispam").getInt("mutetime", 0);
|
int mutedfor = plugin.getConfig().getConfigurationSection("antispam").getInt("mutetime", 0);
|
||||||
if(time < spamtime + plugin.getConfig().getConfigurationSection("antispam").getInt("spamtime")) {
|
|
||||||
|
int datetime = time/60;
|
||||||
|
if(datetime < spamtime + plugin.getConfig().getConfigurationSection("antispam").getInt("spamtime")) {
|
||||||
if(spamcount + 1 >= spamtimeconfig) {
|
if(spamcount + 1 >= spamtimeconfig) {
|
||||||
mcp.addMute(eventChannel.getName(), datetime + mutedfor);
|
mcp.addMute(eventChannel.getName(), datetime + mutedfor);
|
||||||
String timedmute = "";
|
String timedmute = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user