From d07cba403a7ddc91897b70f13cac7c6adb9774ec Mon Sep 17 00:00:00 2001 From: Angelillo15 Date: Fri, 8 Sep 2023 15:36:09 +0200 Subject: [PATCH 1/5] Fix bug with max health --- .../main/java/es/angelillo15/mast/bukkit/StaffPlayer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MAStaff-Bukkit/src/main/java/es/angelillo15/mast/bukkit/StaffPlayer.java b/MAStaff-Bukkit/src/main/java/es/angelillo15/mast/bukkit/StaffPlayer.java index 0e817cce..d3dc501b 100644 --- a/MAStaff-Bukkit/src/main/java/es/angelillo15/mast/bukkit/StaffPlayer.java +++ b/MAStaff-Bukkit/src/main/java/es/angelillo15/mast/bukkit/StaffPlayer.java @@ -33,6 +33,7 @@ import lombok.Getter; import lombok.Setter; import lombok.SneakyThrows; +import lombok.val; import org.bukkit.*; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; @@ -565,7 +566,11 @@ public void saveHealthAndFood() { @Override public void restoreHealthAndFood() { if (!playerInventoryConfig.contains("health")) return; - player.setHealth(playerInventoryConfig.getDouble("health")); player.setFoodLevel(playerInventoryConfig.getInt("food")); + val health = playerInventoryConfig.getDouble("health"); + if (health > 20) + player.setHealth(20); + else + player.setHealth(health); } } From e4f10e50095c5aa07aa1549b4ea36dc5bfb5487a Mon Sep 17 00:00:00 2001 From: Angelillo15 Date: Fri, 8 Sep 2023 16:20:17 +0200 Subject: [PATCH 2/5] Fix velocity custom command --- .../es/angelillo15/mast/velocity/cmd/CustomCommand.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt b/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt index dda56a15..140d4359 100644 --- a/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt +++ b/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt @@ -29,8 +29,12 @@ class CustomCommand(private var command: Command, private var permission: String override fun hasPermission(invocation: SimpleCommand.Invocation?): Boolean { if (permission.isNullOrBlank()) return true - if (invocation is Player) { - return invocation.hasPermission(permission) + if (invocation == null) { + return false + } + + if (invocation.source() is Player) { + return invocation.source().hasPermission(permission) } return true From 7930bbe587c923a15a7c65c9755644d21476a5ad Mon Sep 17 00:00:00 2001 From: Angelillo15 Date: Fri, 8 Sep 2023 16:29:01 +0200 Subject: [PATCH 3/5] Fix staffchat --- .../es/angelillo15/mast/handler/OnStaffMessageEvent.kt | 1 + .../es/angelillo15/mast/velocity/cmd/CustomCommand.kt | 8 ++++---- .../mast/velocity/listeners/staffchat/OnPlayerChat.kt | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/MAStaff-Common/src/main/kotlin/es/angelillo15/mast/handler/OnStaffMessageEvent.kt b/MAStaff-Common/src/main/kotlin/es/angelillo15/mast/handler/OnStaffMessageEvent.kt index ae992086..af59d308 100644 --- a/MAStaff-Common/src/main/kotlin/es/angelillo15/mast/handler/OnStaffMessageEvent.kt +++ b/MAStaff-Common/src/main/kotlin/es/angelillo15/mast/handler/OnStaffMessageEvent.kt @@ -15,6 +15,7 @@ open class OnStaffMessageEvent { fun onStaffMessageEvent(player: String, message: String, server: String): Boolean { if (!CommonConfig.StaffChat.enabled()) return false + if (!CommonConfig.StaffChat.Prefix.enabled()) return false val key = CommonConfig.StaffChat.Prefix.key() var strippedMessage = message diff --git a/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt b/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt index 140d4359..0274a574 100644 --- a/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt +++ b/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt @@ -22,6 +22,9 @@ class CustomCommand(private var command: Command, private var permission: String logger.error("Unknown command sender: ${invocation.source()}") return } + if (!hasPermission(invocation)) { + return + } command.onCommand(sender, invocation.alias(), invocation.arguments()) } @@ -33,10 +36,7 @@ class CustomCommand(private var command: Command, private var permission: String return false } - if (invocation.source() is Player) { - return invocation.source().hasPermission(permission) - } - + invocation.source().hasPermission(permission) return true } } \ No newline at end of file diff --git a/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/listeners/staffchat/OnPlayerChat.kt b/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/listeners/staffchat/OnPlayerChat.kt index 86715627..78ade4eb 100644 --- a/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/listeners/staffchat/OnPlayerChat.kt +++ b/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/listeners/staffchat/OnPlayerChat.kt @@ -7,6 +7,8 @@ import es.angelillo15.mast.handler.OnStaffMessageEvent class OnPlayerChat : OnStaffMessageEvent() { @Subscribe fun onPlayerChat(event: PlayerChatEvent) { + if (!event.player.hasPermission("mast.staffchat")) return + if (onStaffMessageEvent( event.player.username, event.message, event.player.currentServer.get().serverInfo.name ) From 180c9b32d588f944879ab01c2b1f4d2f85eb73e7 Mon Sep 17 00:00:00 2001 From: Angelillo15 Date: Fri, 8 Sep 2023 16:59:08 +0200 Subject: [PATCH 4/5] Fix permission --- .../mast/velocity/cmd/CustomCommand.kt | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt b/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt index 0274a574..f7f537ac 100644 --- a/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt +++ b/MAStaff-Velocity/src/main/java/es/angelillo15/mast/velocity/cmd/CustomCommand.kt @@ -10,7 +10,7 @@ import es.angelillo15.mast.api.cmd.sender.CommandSender import es.angelillo15.mast.api.cmd.sender.VelocityConsoleCommandSender import es.angelillo15.mast.api.cmd.sender.VelocityPlayerCommandSender -class CustomCommand(private var command: Command, private var permission: String?) : SimpleCommand { +class CustomCommand(private var command: Command, private var permission: String) : SimpleCommand { @Inject private lateinit var logger: ILogger; override fun execute(invocation: SimpleCommand.Invocation?) { @@ -22,21 +22,13 @@ class CustomCommand(private var command: Command, private var permission: String logger.error("Unknown command sender: ${invocation.source()}") return } - if (!hasPermission(invocation)) { - return - } - - command.onCommand(sender, invocation.alias(), invocation.arguments()) - } - - override fun hasPermission(invocation: SimpleCommand.Invocation?): Boolean { - if (permission.isNullOrBlank()) return true - if (invocation == null) { - return false + if (invocation.source().hasPermission(permission)) { + command.onCommand(sender, invocation.alias(), invocation.arguments()) } + } - invocation.source().hasPermission(permission) - return true + override fun hasPermission(invocation: SimpleCommand.Invocation): Boolean { + return invocation.source().hasPermission(permission) } } \ No newline at end of file From d0af0b2b6ea46443798c708e306b4dcafc4e93a8 Mon Sep 17 00:00:00 2001 From: Angelillo15 Date: Fri, 8 Sep 2023 16:59:35 +0200 Subject: [PATCH 5/5] Change plugin version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4b0b7f36..b954dfcf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { } group = "es.angelillo15" -version = "2.4.0-BETA" +version = "2.4.1" tasks.shadowJar { relocate("es.angelillo15.configmanager", "es.angelillo15.mast.libs.config.manager")