diff --git a/.idea/statistic.xml b/.idea/statistic.xml
new file mode 100644
index 0000000..b0ae260
--- /dev/null
+++ b/.idea/statistic.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 340ac25..66d85aa 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -10,37 +10,20 @@
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
-
+
+
-
-
-
-
+
@@ -100,12 +83,8 @@
-
-
-
-
-
-
+
+
@@ -117,14 +96,12 @@
+
- "REPORT"
- "UNMUTE"
- "UNBAN"
"UNBANIP"
, "null"
"MUTE"
@@ -152,6 +129,9 @@
reason
REASON
e "§c§lJa §8/
+ hash
+ itera
+ chat
§o
@@ -164,12 +144,6 @@
@@ -239,36 +219,34 @@
-
-
-
+
-
+
-
+
-
+
-
+
@@ -276,7 +254,7 @@
-
+
@@ -285,7 +263,7 @@
-
+
@@ -295,7 +273,7 @@
-
+
@@ -305,7 +283,7 @@
-
+
@@ -315,17 +293,17 @@
-
+
-
+
-
+
@@ -335,209 +313,124 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
+
-
-
-
+
+
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
+
+
@@ -546,29 +439,33 @@
-
+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
@@ -710,7 +607,14 @@
1569177890237
-
+
+ 1569270672927
+
+
+
+ 1569270672927
+
+
@@ -724,7 +628,7 @@
-
+
@@ -816,67 +720,10 @@
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -894,16 +741,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -911,13 +748,6 @@
-
-
-
-
-
-
-
@@ -954,37 +784,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -995,16 +795,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1012,13 +802,6 @@
-
-
-
-
-
-
-
@@ -1039,13 +822,6 @@
-
-
-
-
-
-
-
@@ -1088,20 +864,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1109,13 +871,6 @@
-
-
-
-
-
-
-
@@ -1143,16 +898,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -1195,24 +940,177 @@
-
+
+
-
-
+
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
index adcafe1..31de2fd 100644
--- a/build.gradle
+++ b/build.gradle
@@ -54,6 +54,8 @@ configurations {
dependencies {
compile fileTree(libsDirName)
compileOnly 'net.md-5:bungeecord-api:1.14-SNAPSHOT'
+ compile "mysql:mysql-connector-java:5.1.46"
+ jarLibs 'org.jetbrains.exposed:exposed:0.17.4'
/*compileOnly 'com.velocitypowered:velocity-api:1.0.0-SNAPSHOT'*/
// compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
diff --git a/src/main/kotlin/de/tutorialwork/utils/BCrypt.java b/src/main/java/de/tutorialwork/utils/BCrypt.java
similarity index 97%
rename from src/main/kotlin/de/tutorialwork/utils/BCrypt.java
rename to src/main/java/de/tutorialwork/utils/BCrypt.java
index a805495..448ad93 100644
--- a/src/main/kotlin/de/tutorialwork/utils/BCrypt.java
+++ b/src/main/java/de/tutorialwork/utils/BCrypt.java
@@ -1,3 +1,17 @@
+// Copyright (c) 2006 Damien Miller
+//
+// Permission to use, copy, modify, and distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
package de.tutorialwork.utils;
import java.io.UnsupportedEncodingException;
@@ -365,8 +379,8 @@ public class BCrypt {
*
* @param d the byte array to encode
* @param len the number of bytes to encode
- * @return base64-encoded string
* @throws IllegalArgumentException if the length is invalid
+ * @return base64-encoded string
*/
private static String encode_base64(byte d[], int len)
throws IllegalArgumentException {
@@ -421,8 +435,8 @@ private static byte char64(char x) {
*
* @param s the string to decode
* @param maxolen the maximum number of bytes to decode
- * @return an array containing the decoded bytes
* @throws IllegalArgumentException if maxolen is invalid
+ * @return an array containing the decoded bytes
*/
private static byte[] decode_base64(String s, int maxolen)
throws IllegalArgumentException {
@@ -746,4 +760,4 @@ public static String gensalt() {
public static boolean checkpw(String plaintext, String hashed) {
return (hashed.compareTo(hashpw(plaintext, hashed)) == 0);
}
-}
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/main/Main.kt b/src/main/kotlin/de/tutorialwork/Main.kt
similarity index 99%
rename from src/main/kotlin/de/tutorialwork/main/Main.kt
rename to src/main/kotlin/de/tutorialwork/Main.kt
index b4ddc20..e26192d 100644
--- a/src/main/kotlin/de/tutorialwork/main/Main.kt
+++ b/src/main/kotlin/de/tutorialwork/Main.kt
@@ -1,4 +1,4 @@
-package de.tutorialwork.main
+package de.tutorialwork
import de.tutorialwork.commands.*
import de.tutorialwork.global.*
diff --git a/src/main/kotlin/de/tutorialwork/commands/ChatLog.kt b/src/main/kotlin/de/tutorialwork/commands/ChatLog.kt
index 50b5464..eb88749 100644
--- a/src/main/kotlin/de/tutorialwork/commands/ChatLog.kt
+++ b/src/main/kotlin/de/tutorialwork/commands/ChatLog.kt
@@ -30,7 +30,7 @@ object ChatLog : Command(simpleName()) {
return
}
val executor = sender.executor
- val id = Chat.createChatlog(target, executor)
+ val id = Chat.createChatLog(target, executor)
LogManager.createEntry(target.toString(), executor, ActionType.Chatlog("CREATE_CHATLOG", id))
sender.msg("${prefix}Der ChatLog von §e§l${target.name} §7wurde erfolgreich erstellt")
sender.msg("${prefix}Link: §e§l$chatLogUrl$id")
diff --git a/src/main/kotlin/de/tutorialwork/commands/WebAccount.kt b/src/main/kotlin/de/tutorialwork/commands/WebAccount.kt
index 290bd63..292942f 100644
--- a/src/main/kotlin/de/tutorialwork/commands/WebAccount.kt
+++ b/src/main/kotlin/de/tutorialwork/commands/WebAccount.kt
@@ -12,50 +12,43 @@ object WebAccount : Command(simpleName()) {
override fun execute(sender: CommandSender, args: Array) = sender.hasPermission(name) {
if (sender is ProxiedPlayer) {
- if (args.size <= 1) sender.msg("$prefix/webaccount [Rang]")
+ if (args.size <= 1) sender.msg("$prefix/webaccount [Rank]")
else {
- if (args[0].equals("erstellen", ignoreCase = true)) {
- if (args.size == 2) {
- sender.msg(prefix + "Du musst noch ein Rang des Accounts angeben §4Admin§7, §cMod§7, §9Sup")
- return
+ when (args[0].toLowerCase()) {
+ "create" -> {
+ if (args.size == 2) {
+ sender.msg("${prefix}Du musst noch ein Rang des Accounts angeben ${RankType.values().joinToString { "${it.color}${it.name}§7, " }}")
+ return
+ }
+ val uuid = UUIDFetcher.getUUID(args[1]) ?: return
+ if (uuid.playerExists()) {
+ if (!uuid.webaccountExists) {
+ val target = proxyServer.getPlayer(args[1])
+ if (target != null) {
+ val password = 7.randomString()
+ val rankType = RankType.values().find { it.name == args[2].toUpperCase() } ?: return
+ uuid.createWebAccount(rankType, password, sender)
+ sender.msg("${prefix}Ein ${rankType.color}§l${rankType.name.toLowerCase().capitalize()} §7Account für §e§l${uuid.name} §7wurde §aerstellt")
+ target.msg(
+ "${prefix}§e§l${sender.name} §7hat einen WebAccount für dich erstellt",
+ "${prefix}Passwort: §c§l$password"
+ )
+ } else sender.msg("$prefix§e§l${args[1]} §7ist derzeit nicht online")
+ } else sender.msg("${prefix}§cDieser Spieler hat bereits einen Zugang zum Webinterface")
+ } else sender.msg("${prefix}§cDieser Spieler hat den Server noch nie betreten")
}
- val uuid = UUIDFetcher.getUUID(args[1]) ?: return
- if (uuid.playerExists()) {
- if (!uuid.webaccountExists) {
- val target = proxyServer.getPlayer(args[1])
- if (target != null) {
- val rowPW = 7.randomString()
- val hash = BCrypt.hashpw(rowPW, BCrypt.gensalt())
- when (args[2].toLowerCase()) {
- "admin" -> {
- uuid.createWebAccount(uuid.name, 3, hash)
- sender.msg(prefix + "Ein §4§lAdmin §7Account für §e§l" + uuid.name + " §7wurde §aerstellt")
- }
- "mod" -> {
- uuid.createWebAccount(uuid.name, 2, hash)
- sender.msg(prefix + "Ein §c§lMod §7Account für §e§l" + uuid.name + " §7wurde §aerstellt")
- }
- "sup" -> {
- uuid.createWebAccount(uuid.name, 1, hash)
- sender.msg(prefix + "Ein §9§lSup §7Account für §e§l" + uuid.name + " §7wurde §aerstellt")
- }
- }
- target.msg("${prefix}§e§l${sender.name} §7hat einen Webaccount für dich erstellt")
- target.msg("${prefix}Passwort: §c§l$rowPW")
- LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), ActionType.Webaccount("ADD_WEBACCOUNT"))
- } else sender.msg(prefix + "§e§l" + args[1] + " §7ist derzeit nicht online")
- } else sender.msg("${prefix}§cDieser Spieler hat bereits einen Zugang zum Webinterface")
- } else sender.msg("${prefix}§cDieser Spieler hat den Server noch nie betreten")
- } else if (args[0].equals("löschen", ignoreCase = true)) {
- val uuid = UUIDFetcher.getUUID(args[1]) ?: return
- if (uuid.playerExists()) {
- if (uuid.webaccountExists) {
- uuid.deleteWebAccount()
- sender.msg("${prefix}Der Zugang von dem Spieler §e§l${uuid.name} §7wurde erfolgreich §agelöscht")
- LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), ActionType.Webaccount("DEL_WEBACCOUNT"))
- } else sender.msg("${prefix}§cDieser Spieler hat keinen Zugang zum Webinterface")
- } else sender.msg("${prefix}§cDieser Spieler hat den Server noch nie betreten")
- } else sender.msg("$prefix/webaccount [Rang]")
+ "delete" -> {
+ val uuid = UUIDFetcher.getUUID(args[1]) ?: return
+ if (uuid.playerExists()) {
+ if (uuid.webaccountExists) {
+ uuid.deleteWebAccount()
+ sender.msg("${prefix}Der Zugang von dem Spieler §e§l${uuid.name} §7wurde erfolgreich §agelöscht")
+ LogManager.createEntry(uuid.toString(), sender.uniqueId.toString(), ActionType.WebAccount("DEL_WEBACCOUNT"))
+ } else sender.msg("${prefix}§cDieser Spieler hat keinen Zugang zum Webinterface")
+ } else sender.msg("${prefix}§cDieser Spieler hat den Server noch nie betreten")
+ }
+ else -> sender.msg("$prefix/webaccount [Rang]")
+ }
}
} else sender.msg("${prefix}Nur Spieler können §e§lWebAccounts §7erstellen/löschen")
}
diff --git a/src/main/kotlin/de/tutorialwork/global/Vars.kt b/src/main/kotlin/de/tutorialwork/global/Vars.kt
index 763fccc..06af98a 100644
--- a/src/main/kotlin/de/tutorialwork/global/Vars.kt
+++ b/src/main/kotlin/de/tutorialwork/global/Vars.kt
@@ -1,6 +1,6 @@
package de.tutorialwork.global
-import de.tutorialwork.main.Main
+import de.tutorialwork.Main
import de.tutorialwork.utils.MySQLConnect
import net.md_5.bungee.api.connection.ProxiedPlayer
diff --git a/src/main/kotlin/de/tutorialwork/listener/Chat.kt b/src/main/kotlin/de/tutorialwork/listener/Chat.kt
index 11470d3..269d009 100644
--- a/src/main/kotlin/de/tutorialwork/listener/Chat.kt
+++ b/src/main/kotlin/de/tutorialwork/listener/Chat.kt
@@ -1,11 +1,14 @@
package de.tutorialwork.listener
import de.tutorialwork.global.*
+import de.tutorialwork.sql.Chat
import de.tutorialwork.utils.*
import net.md_5.bungee.api.connection.ProxiedPlayer
import net.md_5.bungee.api.event.ChatEvent
import net.md_5.bungee.api.plugin.Listener
import net.md_5.bungee.event.EventHandler
+import org.jetbrains.exposed.sql.insert
+import org.jetbrains.exposed.sql.select
import java.util.*
object Chat : Listener {
@@ -17,113 +20,84 @@ object Chat : Listener {
if (player in activechats) {
event.isCancelled = true
val target = activechats[player] ?: return
- target.msg("§9§lSUPPORT §8• §c${player.name} §8» ${event.message}")
- player.msg("§9§lSUPPORT §8• §aDu §8» ${event.message}")
- for (key in activechats.keys) {
- //Key has started the support chat
- key.msg("§9§lSUPPORT §8• §c${player.name} §8» ${event.message}")
- }
+ val prefix = "§9§lSUPPORT §8• §c"
+ target.msg(
+ "$prefix§c${player.name} §8» ${event.message}",
+ "$prefix§aDu §8» ${event.message}"
+ )
+ activechats.keys.forEach { it.msg("$prefix§c${player.name} §8» ${event.message}") }
}
val uuid = player.uniqueId
if (uuid.isMuted) {
- if (uuid.rawEnd == -1L) {
- event.isCancelled = true
- player.msg(config.getString("LAYOUT.MUTE").replace("%grund%", uuid.reasonString).translateColors())
- } else {
- if (System.currentTimeMillis() >= uuid.rawEnd) uuid.unMute()
- else {
- event.isCancelled = true
- player.sendTempMute()
- }
+ if (System.currentTimeMillis() >= uuid.rawEnd) {
+ uuid.unMute()
+ return
}
-
+ event.isCancelled = true
+ player.sendMute()
} else {
- if (player.hasPermission("${permissionPrefix}blacklist.bypass")) insertMessage(uuid, event.message, player.server.info.name)
- else {
- if (config.getBoolean("AUTOMUTE.ENABLED")) {
- insertMessage(uuid, event.message, player.server.info.name)
- for (blacklist in blacklist) {
- if (event.message.toUpperCase().contains(blacklist.toUpperCase())) {
- event.isCancelled = true
- uuid.mute(config.getInt("AUTOMUTE.MUTEID").reason, consoleName)
- LogManager.createEntry(uuid.toString(), consoleName, ActionType.Blacklist("AUTOMUTE_BLACKLIST"))
- ActionType.Mute(config.getInt("AUTOMUTE.MUTEID")).sendNotify(uuid.name, consoleName)
- player.sendMute()
- return
- }
- }
- for (adblacklist in adblacklist) {
- if (event.message.toUpperCase().contains(adblacklist.toUpperCase())) {
- if (!adwhitelist.contains(event.message.toUpperCase())) {
- event.isCancelled = true
- uuid.mute(config.getInt("AUTOMUTE.ADMUTEID").reason, consoleName)
- LogManager.createEntry(uuid.toString(), consoleName, ActionType.Blacklist("AUTOMUTE_ADBLACKLIST"))
- ActionType.Mute(config.getInt("AUTOMUTE.ADMUTEID")).sendNotify(uuid.name, consoleName)
- player.sendMute()
- return
- }
- }
+ insertMessage(uuid, event.message, player.server.info.name)
+ if (player.hasPermission("${permissionPrefix}blacklist.bypass")) return
+ val predicate: (String) -> Boolean = { it.toUpperCase() in event.message.toUpperCase() }
+ when {
+ config.getBoolean("AUTOMUTE.ENABLED") -> {
+ val a = if (blacklist.any(predicate)) "" else {
+ if (adblacklist.any(predicate) && event.message.toUpperCase() !in adwhitelist) "AD" else return
}
- } else {
- insertMessage(uuid, event.message, player.server.info.name)
- if (config.getBoolean("AUTOMUTE.AUTOREPORT")) {
- for (blacklist in blacklist) {
- if (event.message.toUpperCase().contains(blacklist.toUpperCase())) {
- event.isCancelled = true
- player.msg("${prefix}§cAchte auf deine Wortwahl")
- val logId = createChatlog(uuid, consoleName)
- uuid.createReport(consoleName, "VERHALTEN", logId)
- ActionType.Report("VERHALTEN").sendNotify(player.name, consoleName)
- return
- }
- }
- for (adblacklist in adblacklist) {
- if (event.message.toUpperCase().contains(adblacklist.toUpperCase())) {
- if (!adwhitelist.contains(event.message.toUpperCase())) {
- event.isCancelled = true
- player.msg("${prefix}§cDu darfst keine Werbung machen")
- val logId = createChatlog(uuid, consoleName)
- uuid.createReport(consoleName, "WERBUNG", logId)
- ActionType.Report("WERBUNG").sendNotify(player.name, consoleName)
- return
- }
- }
- }
+ uuid.mute(config.getInt("AUTOMUTE.${a}MUTEID").reason, consoleName)
+ LogManager.createEntry(uuid.toString(), consoleName, ActionType.Blacklist("AUTOMUTE_${a}BLACKLIST"))
+ ActionType.Mute(config.getInt("AUTOMUTE.MUTEID")).sendNotify(uuid.name, consoleName)
+ player.sendMute()
+ }
+ config.getBoolean("AUTOMUTE.AUTOREPORT") -> {
+ val reason: String = if (blacklist.any(predicate)) {
+ player.msg("${prefix}§cAchte auf deine Wortwahl")
+ "VERHALTEN"
+ } else {
+ if (adblacklist.any(predicate) && event.message.toUpperCase() !in adwhitelist) {
+ player.msg("${prefix}§cDu darfst keine Werbung machen")
+ "WERBUNG"
+ } else return
}
+ val logId = createChatLog(uuid, consoleName)
+ uuid.createReport(consoleName, reason, logId)
+ ActionType.Report(reason).sendNotify(player.name, consoleName)
}
+ else -> return
}
-
-
+ event.isCancelled = true
}
}
- private fun insertMessage(uuid: UUID, Message: String, Server: String) {
- mysql.update("INSERT INTO chat(UUID, SERVER, MESSAGE, SENDDATE) " +
- "VALUES ('" + uuid + "', '" + Server + "', '" + Message + "', '" + System.currentTimeMillis() + "')")
+ private fun insertMessage(uuid: UUID, message: String, server: String) {
+ Chat.insert {
+ it[this.uuid] = uuid.toString()
+ it[this.server] = server
+ it[this.message] = message
+ it[this.sendDate] = System.currentTimeMillis()
+ }
}
- fun createChatlog(uuid: UUID, createdUUID: String): String {
- val rs = mysql.query("SELECT * FROM chat WHERE uuid='$uuid'") ?: return "null"
+ fun createChatLog(uuid: UUID, createdUUID: String): String {
+ val query = Chat.getByUUID(uuid)
val id = 20.randomString()
val now = System.currentTimeMillis()
- while (rs.next()) {
- val tenMinutes = 10 * 60 * 1000
+ val tenMinutes = 10 * 60 * 1000
+ query.forEach {
val tenAgo = System.currentTimeMillis() - tenMinutes
- if (rs.getString("SENDDATE").toLong() > tenAgo) {
+ val sendDate = it[Chat.sendDate]
+ if (sendDate > tenAgo) {
mysql.update("""INSERT INTO chatlog(LOGID, uuid, CREATOR_UUID, SERVER, MESSAGE, SENDDATE, CREATED_AT) VALUES ('$id'
- |,'$uuid', '$createdUUID', '${rs.getString("SERVER")}', '${rs.getString("MESSAGE")}'
- |, '${rs.getString("SENDDATE")}', '$now')""".trimMargin())
+ |,'$uuid', '$createdUUID', '${it[Chat.server]}', '${it[Chat.message]}'
+ |, '${sendDate}', '$now')""".trimMargin())
}
}
return id
}
- fun hasMessages(uuid: UUID): Boolean {
- val rs = mysql.query("SELECT * FROM chat WHERE uuid='$uuid'") ?: return false
- var i = 0
- while (rs.next()) i++
- return i != 0
- }
+ fun hasMessages(uuid: UUID): Boolean = Chat.getByUUID(uuid).any()
+
+ private fun Chat.getByUUID(uuid: UUID) = select { Chat.uuid.eq(uuid.toString()) }
}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/sql/Chat.kt b/src/main/kotlin/de/tutorialwork/sql/Chat.kt
new file mode 100644
index 0000000..79ac864
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/sql/Chat.kt
@@ -0,0 +1,11 @@
+package de.tutorialwork.sql
+
+import org.jetbrains.exposed.sql.Table
+
+object Chat : Table() {
+ val id = integer("id").autoIncrement().primaryKey()
+ var uuid = varchar("uuid", 36)
+ var server = varchar("server", 64)
+ var message = varchar("message", 2500)
+ var sendDate = long("senddate")
+}
\ No newline at end of file
diff --git a/src/main/kotlin/de/tutorialwork/utils/ActionType.kt b/src/main/kotlin/de/tutorialwork/utils/ActionType.kt
index 9364bfd..a8f3e88 100644
--- a/src/main/kotlin/de/tutorialwork/utils/ActionType.kt
+++ b/src/main/kotlin/de/tutorialwork/utils/ActionType.kt
@@ -82,7 +82,7 @@ sealed class ActionType {
override val message: String = "§c§l$senderName §7hat §e§l$bannedName §7wegen §a$reason §7gemeldet"
}
- class Webaccount(override val reason: String) : ActionType() {
+ class WebAccount(override val reason: String) : ActionType() {
override val message: String = "§c§l$senderName §7hat §e§l$bannedName §7wegen §a$reason §7gemeldet"
}
diff --git a/src/main/kotlin/de/tutorialwork/utils/BanFunctions.kt b/src/main/kotlin/de/tutorialwork/utils/BanFunctions.kt
index 18afb13..42ff39d 100644
--- a/src/main/kotlin/de/tutorialwork/utils/BanFunctions.kt
+++ b/src/main/kotlin/de/tutorialwork/utils/BanFunctions.kt
@@ -2,6 +2,7 @@ package de.tutorialwork.utils
import de.tutorialwork.global.*
import net.md_5.bungee.api.CommandSender
+import net.md_5.bungee.api.connection.ProxiedPlayer
import java.text.SimpleDateFormat
import java.util.*
@@ -234,9 +235,10 @@ fun UUID.mute(reason: String, teamUUID: String) {
}
-fun UUID.createWebAccount(name: String, rank: Int, passwordHash: String) {
+fun UUID.createWebAccount(rank: RankType, password: String, sender: ProxiedPlayer) {
mysql.update("""INSERT INTO accounts(UUID, USERNAME, PASSWORD, RANK, GOOGLE_AUTH, AUTHCODE) VALUES ('$this', '$name'
- |, '$passwordHash', '$rank', 'null', 'initialpassword')""".trimMargin())
+ |, '${BCrypt.hashpw(password, BCrypt.gensalt())}', '${rank.id}', 'null', 'initialpassword')""".trimMargin())
+ LogManager.createEntry(this.toString(), sender.uniqueId.toString(), ActionType.WebAccount("ADD_WEBACCOUNT"))
}
fun UUID.deleteWebAccount() = mysql.update("DELETE FROM accounts WHERE UUID='$this'")
diff --git a/src/main/kotlin/de/tutorialwork/utils/RankType.kt b/src/main/kotlin/de/tutorialwork/utils/RankType.kt
new file mode 100644
index 0000000..b2cad3d
--- /dev/null
+++ b/src/main/kotlin/de/tutorialwork/utils/RankType.kt
@@ -0,0 +1,10 @@
+package de.tutorialwork.utils
+
+enum class RankType(val id: Int, val color: String) {
+
+ ADMIN(3, "§4"),
+ MOD(2, "§c"),
+ SUP(1, "§9")
+
+}
+
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 1a3b498..cfb63fe 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,4 +1,4 @@
name: ProfessionalBans Reloaded
author: Tutorialwork
version: 2.4
-main: de.tutorialwork.main.Main
\ No newline at end of file
+main: de.tutorialwork.Main
\ No newline at end of file