Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
Features:Commands(beta)
Browse files Browse the repository at this point in the history
  • Loading branch information
CerealAxis committed Mar 17, 2024
1 parent 93c4e87 commit 6cea251
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
compileOnly(files("libs/ThemisAPI_0.15.3.jar"))
compileOnly(files("libs/Matrix_7.7.15A.jar"))
compileOnly("top.leavesmc.leaves:leaves-api:1.20.4-R0.1-SNAPSHOT")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0")
compileOnly("org.bstats:bstats-bukkit:3.0.2")
implementation("com.moandjiezana.toml:toml4j:0.7.2")
}
Expand Down
64 changes: 60 additions & 4 deletions src/main/java/xaviermc/top/iseeyou/ISeeYou.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package xaviermc.top.iseeyou

import org.bukkit.Bukkit
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.configuration.InvalidConfigurationException
import org.bukkit.entity.Player
import org.bukkit.plugin.java.JavaPlugin
import org.bukkit.scheduler.BukkitRunnable
import top.leavesmc.leaves.entity.Photographer
Expand All @@ -20,7 +23,7 @@ import java.time.LocalDate
import java.util.*
import kotlin.io.path.isDirectory
import kotlin.math.pow

import com.moandjiezana.toml.Toml

var toml: TomlEx<ConfigData>? = null
var photographers = mutableMapOf<String, Photographer>()
Expand Down Expand Up @@ -71,18 +74,20 @@ class ISeeYou : JavaPlugin(), CommandExecutor {
toml!!.data.recordSuspiciousPlayer.enableMatrixIntegration
) Bukkit.getPluginManager().registerEvents(MatrixListener(), this)

if (toml!!.data.enableBstats){
if (toml!!.data.enableBstats) {
val pluginId = 21068
val metrics: Metrics = Metrics(this, pluginId)
metrics.addCustomChart(
Metrics.SimplePie(
"chart_id"
) { "My value" })
}
if (toml!!.data.enableUpdateChecker){
if (toml!!.data.enableUpdateChecker) {
val updateChecker: UpdateChecker = UpdateChecker(this, 115177)
updateChecker.checkForUpdates()
}
// Registering custom commands
this.getCommand("icu")?.setExecutor(this)
}

private fun setupConfig() {
Expand Down Expand Up @@ -179,4 +184,55 @@ class ISeeYou : JavaPlugin(), CommandExecutor {
return deletedCount
}

}
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if (command.name.equals("icu", ignoreCase = true)) {
if (args.isEmpty()) {
// Handle /icu command
// Add logic here if needed
return true
}

when (args[0]) {
"place" -> {
if (args.size < 2 || args.size > 3) {
sender.sendMessage("Usage: /icu place [name] [<player>]")
return true
}
val name = args[1]
val player: Player? = if (args.size == 3) Bukkit.getPlayer(args[2]) else sender as? Player
if (player != null) {
// Place photographer at player's location
val photographer = Bukkit.getPhotographerManager().createPhotographer(name, player.location)
if (photographer != null) {
photographers[name] = photographer
sender.sendMessage("Photographer '$name' has been placed.")
} else {
sender.sendMessage("Failed to place photographer.")
}
} else {
sender.sendMessage("Player not found.")
}
}

"remove" -> {
if (args.size < 2) {
sender.sendMessage("Usage: /icu remove [name]")
return true
}
val name = args[1]
val photographer = photographers.remove(name)
if (photographer != null) {
photographer.stopRecording()
sender.sendMessage("Photographer '$name' has been removed.")
} else {
sender.sendMessage("Photographer '$name' not found.")
}
}

else -> sender.sendMessage("Unknown command. Usage: /icu place|remove [name] <player>")
}
return true
}
return false
}
}
2 changes: 1 addition & 1 deletion src/main/java/xaviermc/top/iseeyou/TomlEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public TomlEx(String filePath, Class<T> clazz) {
save();
}

public void read(){
public void read() {
data = this.read(file).to(clazz);
}

Expand Down

0 comments on commit 6cea251

Please sign in to comment.