var script=registerScript({name:"ModCheck",version:"1.2",authors:["liulihaocai"]});var MSTimer=Java.type("net.ccbluex.liquidbounce.utils.timer.MSTimer");var ScaledResolution=Java.type("net.minecraft.client.gui.ScaledResolution");var Runnable=Java.type("java.lang.Runnable");var Thread=Java.type("java.lang.Thread");var URL=Java.type("java.net.URL");var IOUtils=Java.type("org.apache.commons.io.IOUtils");var timer=new MSTimer()
var header="§fONLINE §2MODS§f: ";function get(theUrl){var con=new URL(theUrl).openConnection();con.requestMethod="GET";con.setRequestProperty("User-Agent","Mozilla/5.0");input=con.getInputStream();encoding=con.getContentEncoding();encoding=encoding==null?"UTF-8":encoding;body=IOUtils.toString(input,encoding);return body;}
script.registerModule({name:"ModCheck",description:"OL MOD WARN FOR REDE SKY",category:"Fun",settings:{active:Setting.integer({name:"ActiveMin",default:10,min:0,max:30}),reflesh:Setting.integer({name:"RefleshSec",default:60,min:0,max:120}),showname:Setting.boolean({name:"ShowName",default:true}),mods:Setting.text({name:"OnlineMods",default:"não"})}},function(module){var mcWidth,mcHeight,renderStr=header+"§cNEED CHECK";var MyRun=Java.extend(Runnable,{run:function(){renderStr=header+"§aCHECKING";try{var active=module.settings.active.get()*60*1000,nowTime=new Date().getTime();var json=JSON.parse(get("https://api.redesky.com/punishments/lasts"))[0].data.data;var mods=[],modsTime={};for(var i in json){if((nowTime-json[i].start_time)<active){var modName=json[i].staffer_obj.nick;if(mods.indexOf(modName)==-1){mods.push(modName);modsTime[modName]=new Date(json[i].start_time).toLocaleTimeString();}}}
if(mods.length==0){renderStr=header+"§a0";module.settings.mods.set("não")}else{var modsStr="";for(var j in mods){modsStr+=mods[j]+"["+modsTime[mods[j]]+"]; ";}
modsStr=modsStr.substring(0,modsStr.length-2);module.settings.mods.set(modsStr)
renderStr=header+"§c"+mods.length+(module.settings.showname.get()?" §f("+modsStr+")":"");}}catch(e){renderStr=header+"§cFAILED";module.settings.mods.set("FAILED")
e.printStackTrace();}}});module.on("update",function(){var SR=new ScaledResolution(mc)
mcWidth=SR.getScaledWidth();mcHeight=SR.getScaledHeight();if(timer.hasTimePassed(module.settings.reflesh.get()*1000)){timer.reset();var th=new Thread(new MyRun());th.start();}})
module.on("render2D",function(){mc.fontRendererObj.drawString(renderStr,3,mcHeight-10,0);})})