Skip to content

Commit

Permalink
improved code.... #WeAreStillCrying
Browse files Browse the repository at this point in the history
  • Loading branch information
LeBaasti committed Sep 23, 2019
1 parent d004076 commit bb6d0fd
Show file tree
Hide file tree
Showing 33 changed files with 1,172 additions and 856 deletions.
9 changes: 9 additions & 0 deletions .idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

704 changes: 527 additions & 177 deletions .idea/workspace.xml

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ wrapper {
def lines = file.readLines()
def list = []
lines.each { String line ->
list += line.replace("var msg = config.getString(\"LAYOUT.TEMPMUTE\")\n" +
" msg = msg.replace(\"%grund%\", uuid.reasonString)\n" +
" msg = msg.replace(\"%dauer%\", uuid.endTime)\n" +
" p.msg(msg))", "p.sendTempmute()")
list += line.replace("import de.tutorialwork.XX", "import de.tutorialwork.global.")
}
file.write(list.join("\n"), "UTF-8")
}
Expand Down
49 changes: 0 additions & 49 deletions src/main/kotlin/de/tutorialwork/Global.kt

This file was deleted.

78 changes: 29 additions & 49 deletions src/main/kotlin/de/tutorialwork/commands/Ban.kt
Original file line number Diff line number Diff line change
@@ -1,58 +1,38 @@
package de.tutorialwork.commands

import de.tutorialwork.*
import de.tutorialwork.global.executor
import de.tutorialwork.global.prefix
import de.tutorialwork.utils.*
import net.darkdevelopers.darkbedrock.darkness.general.functions.simpleName
import net.md_5.bungee.api.CommandSender
import net.md_5.bungee.api.connection.ProxiedPlayer
import net.md_5.bungee.api.plugin.Command

object Ban : Command(Ban::class.simpleName) {
object Ban : Command(simpleName<Ban>()) {

override fun execute(sender: CommandSender, args: Array<String>) {
val executor = if (sender is ProxiedPlayer) sender.uniqueId.toString() else consoleName
if (sender.hasPermission("professionalbans.ban")) {
if (args.size == 2) {
val uuid = UUIDFetcher.getUUID(args[0]) ?: return
val id = args[1].toIntOrNull() ?: return //add fail message
val banned = instance.proxy.getPlayer(uuid)
if (uuid.playerExists()) {
if (uuid.isWebaccountAdmin) sender.msg("$prefix§cDiesen Spieler kannst du nicht bannen/muten")
else {
if (id.isBanReason) {
if (id.hasExtraPermissions) {
if (!sender.hasPermission(id.extraPermissions)) sender.msg("$prefix§cDu hast keine Berechtigung diesen Bangrund zu nutzen")
} else {
uuid.ban(id, executor, increaseValue, increaseBans)
LogManager.createEntry("", executor, ActionType.Ban(id))
uuid.bans += 1
ActionType.Ban(id).sendNotify(uuid.name, sender.name)
if (banned.uniqueId.rawEnd == -1L) {
banned.kick(config.getString("LAYOUT.BAN").replace("%grund%", id.reason).translateColors())
} else banned.sendTempban()
saveConfig()
}
} else {
if (id.hasExtraPermissions) {
if (!sender.hasPermission(id.extraPermissions)) sender.msg("$prefix§cDu hast keine Berechtigung diesen Mutegrund zu nutzen")
} else {
uuid.mute(id, executor)
LogManager.createEntry(uuid.toString(), executor, ActionType.Mute(id))
uuid.mutes += 1
ActionType.Mute(id).sendNotify(uuid.name, sender.name)
if (banned != null) {
if (banned.uniqueId.rawEnd == -1L) {
banned.msg(config.getString("LAYOUT.MUTE").replace("%grund%", id.reason).translateColors())
} else banned.sendTempmute()
saveConfig()
}
}
}
}
} else sender.msg("$prefix§cDieser Spieler hat den Server noch nie betreten")
} else {
sender.sendBanReasonsList()
sender.msg("$prefix/ban <Spieler> <Grund-ID>")
}
} else sender.msg(noPerms)
override fun execute(sender: CommandSender, args: Array<String>) = sender.hasPermission(name.toLowerCase()) {
if (args.size != 2) {
sender.sendBanReasonsList()
sender.msg("$prefix/${name.toLowerCase()} <Spieler> <Grund-ID>")
return
}
val uuid = UUIDFetcher.getUUID(args[0]) ?: return
if (!uuid.playerExists()) {
sender.msg("${prefix}§cDieser Spieler hat den Server noch nie betreten")
return
}
if (uuid.isWebaccountAdmin) {
sender.msg("${prefix}§cDiesen Spieler kannst du nicht bannen/muten")
return
}
val id = args[1].toIntOrNull() ?: return //add fail message
val type = if (id.isBanReason) ActionType.Ban(id) else ActionType.Mute(id)
if (id.hasExtraPermissions && !sender.hasPermission(id.extraPermissions)) {
sender.msg("${prefix}§cDu hast keine Berechtigung diesen ${type::class.java.simpleName}grund zu nutzen")
return
}
val executor = sender.executor
type.execute(uuid, executor)
type.sendNotify(uuid.name, sender.name)
LogManager.createEntry(uuid.toString(), executor, type)
}
}
33 changes: 13 additions & 20 deletions src/main/kotlin/de/tutorialwork/commands/Blacklist.kt
Original file line number Diff line number Diff line change
@@ -1,44 +1,37 @@
package de.tutorialwork.commands

import de.tutorialwork.*
import de.tutorialwork.utils.ActionType
import de.tutorialwork.utils.LogManager
import de.tutorialwork.utils.msg
import de.tutorialwork.utils.saveConfig
import de.tutorialwork.global.*
import de.tutorialwork.utils.*
import net.darkdevelopers.darkbedrock.darkness.general.functions.simpleName
import net.md_5.bungee.api.CommandSender
import net.md_5.bungee.api.connection.ProxiedPlayer
import net.md_5.bungee.api.plugin.Command

class Blacklist : Command(Blacklist::class.java.simpleName) {
object Blacklist : Command(simpleName<Blacklist>()) {

override fun execute(sender: CommandSender, args: Array<String>) {
if (sender.hasPermission("professionalbans.blacklist")) {
sender.msg(noPerms)
return
}
override fun execute(sender: CommandSender, args: Array<String>) = sender.hasPermission(name) {
if (args.size != 2) {
sender.msg("${prefix}Derzeit sind §e§l${blacklist.size} Wörter §7auf der Blacklist")
sender.msg("$prefix/blacklistFile <add/del> <Wort>")
sender.msg("$prefix/${name.toLowerCase()} <add/del> <Wort>")
return
}
val executor = if (sender is ProxiedPlayer) sender.uniqueId.toString() else consoleName
val word = args[1]
when (args[0].toLowerCase()) {
val x = when (args[0].toLowerCase()) {
"add" -> {
blacklist.add(word)
sender.msg("$prefix§e§l$word §7wurde zur Blacklist hinzugefügt")
LogManager.createEntry("", executor, ActionType.Blacklist("ADD_WORD_BLACKLIST"))
"hinzugefügt"
}
"del" -> {
if (word !in blacklist) {
sender.msg("$prefix§cDieses Wort steht nicht auf der Blacklist")
sender.msg("${prefix}§cDieses Wort steht nicht auf der Blacklist")
return
}
blacklist.remove(word)
sender.msg("$prefix§e§l$word §7wurde von der Blacklist entfernt")
LogManager.createEntry("", executor, ActionType.Blacklist("DEL_WORD_BLACKLIST"))
"entfernt"
}
else -> return
}
LogManager.createEntry("", sender.executor, ActionType.Blacklist("${args[0].toUpperCase()}_WORD_BLACKLIST"))
sender.msg("${prefix}§e§l$word §7wurde zur Blacklist $x")
blacklistConfig.set("BLACKLIST", blacklist)
saveConfig(blacklistConfig, blacklistFile)
}
Expand Down
39 changes: 39 additions & 0 deletions src/main/kotlin/de/tutorialwork/commands/ChatLog.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.tutorialwork.commands

import de.tutorialwork.global.config
import de.tutorialwork.global.executor
import de.tutorialwork.global.prefix
import de.tutorialwork.listener.Chat
import de.tutorialwork.utils.*
import net.darkdevelopers.darkbedrock.darkness.general.functions.simpleName
import net.md_5.bungee.api.CommandSender
import net.md_5.bungee.api.connection.ProxiedPlayer
import net.md_5.bungee.api.plugin.Command

object ChatLog : Command(simpleName<ChatLog>()) {

private val chatLogUrl by lazy { config.getString("CHATLOG.URL") }

override fun execute(sender: CommandSender, args: Array<String>) {
if (args.size != 1) {
sender.msg("$prefix/${name.toLowerCase()} <Spieler>")
return
}
val target = args[0].getUUID(sender) ?: return
target.exists(sender) ?: return
if (sender is ProxiedPlayer && sender.uniqueId == target) {
sender.msg("${prefix}§cDu kannst kein ChatLog von dir selbst erstellen")
return
}
if (!Chat.hasMessages(target)) {
sender.msg("${prefix}§cDieser Spieler hat in der letzten Zeit keine Nachrichten verfasst")
return
}
val executor = sender.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")
}

}
34 changes: 0 additions & 34 deletions src/main/kotlin/de/tutorialwork/commands/Chatlog.kt

This file was deleted.

Loading

0 comments on commit bb6d0fd

Please sign in to comment.