Skip to content

Commit

Permalink
Merge pull request #44 from Nookure/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Angelillo15 authored Sep 8, 2023
2 parents 5b0ecd4 + 4dbfd3e commit 747aa6c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand All @@ -23,16 +23,12 @@ class CustomCommand(private var command: Command, private var permission: String
return
}

command.onCommand(sender, invocation.alias(), invocation.arguments())
}

override fun hasPermission(invocation: SimpleCommand.Invocation?): Boolean {
if (permission.isNullOrBlank()) return true

if (invocation is Player) {
return invocation.hasPermission(permission)
if (invocation.source().hasPermission(permission)) {
command.onCommand(sender, invocation.alias(), invocation.arguments())
}
}

return true
override fun hasPermission(invocation: SimpleCommand.Invocation): Boolean {
return invocation.source().hasPermission(permission)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "es.angelillo15"
version = "2.4.0"
version = "2.4.1"

tasks.shadowJar {
relocate("es.angelillo15.configmanager", "es.angelillo15.mast.libs.config.manager")
Expand Down

0 comments on commit 747aa6c

Please sign in to comment.