forked from RMCQAZ/KevinClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add AdminDetector Fix Render Bug(GL_BLEND) Fly Add AutoVerus Killaura Add KeepAutoblock
- Loading branch information
Showing
12 changed files
with
300 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
src/minecraft/kevin/module/modules/misc/AdminDetector.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package kevin.module.modules.misc | ||
|
||
import joptsimple.internal.Strings | ||
import kevin.command.ICommand | ||
import kevin.event.EventTarget | ||
import kevin.event.PacketEvent | ||
import kevin.event.UpdateEvent | ||
import kevin.hud.element.elements.Notification | ||
import kevin.main.KevinClient | ||
import kevin.module.* | ||
import kevin.utils.ChatUtils | ||
import kevin.utils.TickTimer | ||
import net.minecraft.network.play.client.C14PacketTabComplete | ||
import net.minecraft.network.play.server.S3APacketTabComplete | ||
import java.io.File | ||
|
||
object AdminDetector : Module("AdminDetector","Detect server admins."),ICommand { | ||
private val adminNamesFile:File by lazy { | ||
if (!KevinClient.fileManager.adminNamesFile.exists()) KevinClient.fileManager.adminNamesFile.createNewFile() | ||
KevinClient.fileManager.adminNamesFile | ||
} | ||
override fun run(args: Array<out String>?) { | ||
if (args.isNullOrEmpty()||args.size<2){ | ||
usageMessage() | ||
return | ||
} | ||
val name = args[1] | ||
val names = adminNamesFile.readLines() | ||
when{ | ||
args[0].equals("Add",true) -> { | ||
if (name in names) { | ||
ChatUtils.messageWithStart("§cName is already in the list!") | ||
return | ||
} | ||
adminNamesFile.appendText("$name\n") | ||
ChatUtils.messageWithStart("§aName successfully added to the list!") | ||
} | ||
args[0].equals("Remove",true) -> { | ||
if (name !in names){ | ||
ChatUtils.messageWithStart("§cName is not in the list!") | ||
return | ||
} | ||
adminNamesFile.writeText("") | ||
names.forEach { | ||
if (it!=name&&it.isNotEmpty()){ | ||
adminNamesFile.appendText("$it\n") | ||
} | ||
} | ||
ChatUtils.messageWithStart("§aName successfully removed from the list!") | ||
} | ||
else -> usageMessage() | ||
} | ||
} | ||
private fun usageMessage() = ChatUtils.messageWithStart("§cUsage: .Admin <Add/Remove> <Name>") | ||
|
||
private val modeValue = ListValue("Mode", arrayOf("Tab"),"Tab") | ||
private val tabCommand = TextValue("TabCommand","/tell") | ||
private val waitTicks = IntegerValue("WaitTick",100,0,200) | ||
private val notificationMode = ListValue("NotificationMode", arrayOf("Chat","Notification"),"Chat") | ||
private val noNotFindNotification = BooleanValue("NoNotFindNotification",true) | ||
|
||
private val timer = TickTimer() | ||
private var waiting = false | ||
|
||
@EventTarget fun onUpdate(event: UpdateEvent){ | ||
timer.update() | ||
if (!timer.hasTimePassed(waitTicks.get()+1)) return | ||
when(modeValue.get()){ | ||
"Tab" -> { | ||
mc.netHandler.addToSendQueue(C14PacketTabComplete("${tabCommand.get()} ")) | ||
waiting = true | ||
timer.reset() | ||
} | ||
} | ||
} | ||
@EventTarget fun onPacket(event: PacketEvent){ | ||
val packet = event.packet | ||
when(modeValue.get()){ | ||
"Tab" -> { | ||
if (!waiting) return | ||
if (packet is S3APacketTabComplete){ | ||
val players = packet.func_149630_c() | ||
val admins = adminNamesFile.readLines().toMutableList() | ||
admins.removeAll { it.isEmpty() } | ||
val findAdmins = arrayListOf<String>() | ||
players.forEach { | ||
if (it in admins) findAdmins.add(it) | ||
} | ||
n(findAdmins) | ||
waiting = false | ||
event.cancelEvent() | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun n(findAdmins:ArrayList<String>){ | ||
if (findAdmins.isEmpty()) { | ||
if (!noNotFindNotification.get()) when(notificationMode.get()){ | ||
"Chat" -> ChatUtils.messageWithStart("[AdminDetector] No admin find.") | ||
"Notification" -> KevinClient.hud.addNotification(Notification("No admin find."),"Admin Detector") | ||
} | ||
return | ||
} | ||
when(notificationMode.get()){ | ||
"Chat" -> ChatUtils.messageWithStart("[AdminDetector] Warning: find ${findAdmins.size} admin(s)![§c${Strings.join(findAdmins.toArray(arrayOfNulls<String>(0)), "§7, §c")}]") | ||
"Notification" -> KevinClient.hud.addNotification(Notification("Warning: find ${findAdmins.size} admin(s)![§c${Strings.join(findAdmins.toArray(arrayOfNulls<String>(0)), "§7, §c")}]"),"Admin Detector") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.