diff --git a/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsGet.kt b/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsGet.kt index 3249bd43..d0c0fe6a 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsGet.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsGet.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.commands import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.util.toNiceString +import com.willfp.libreforge.globalPoints import com.willfp.libreforge.points import com.willfp.libreforge.toFriendlyPointName import org.bukkit.Bukkit @@ -26,7 +27,7 @@ internal class CommandPointsGet(plugin: EcoPlugin): Subcommand( val player = Bukkit.getPlayer(playerString) - if (player == null) { + if (player == null && playerString.equals("global", ignoreCase = true)) { sender.sendMessage(plugin.langYml.getMessage("invalid-player")) return } @@ -38,10 +39,10 @@ internal class CommandPointsGet(plugin: EcoPlugin): Subcommand( return } - val amountNum = player.points[pointString] + val amountNum = player?.points?.get(pointString) ?: globalPoints[pointString] sender.sendMessage(plugin.langYml.getMessage("points-amount") - .replace("%playername%", player.name) + .replace("%playername%", player?.name ?: "server") .replace("%point%", pointString.toFriendlyPointName()) .replace("%amount%", amountNum.toNiceString()) ) @@ -52,7 +53,7 @@ internal class CommandPointsGet(plugin: EcoPlugin): Subcommand( 1 -> StringUtil.copyPartialMatches( args[0], Bukkit.getOnlinePlayers().map { it.name }, - mutableListOf() + mutableListOf("global") ) 2 -> listOf("point") 3 -> mutableListOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsGive.kt b/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsGive.kt index 411a7360..a4373ba5 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsGive.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsGive.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.commands import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.util.toNiceString +import com.willfp.libreforge.globalPoints import com.willfp.libreforge.points import com.willfp.libreforge.toFriendlyPointName import org.bukkit.Bukkit @@ -26,7 +27,7 @@ internal class CommandPointsGive(plugin: EcoPlugin): Subcommand( val player = Bukkit.getPlayer(playerString) - if (player == null) { + if (player == null && playerString.equals("global", ignoreCase = true)) { sender.sendMessage(plugin.langYml.getMessage("invalid-player")) return } @@ -52,10 +53,14 @@ internal class CommandPointsGive(plugin: EcoPlugin): Subcommand( return } - player.points[pointString] = player.points[pointString] + amountNum + if (player != null) { + player.points[pointString] = player.points[pointString] + amountNum + } else { + globalPoints[pointString] = globalPoints[pointString] + amountNum + } sender.sendMessage(plugin.langYml.getMessage("points-given") - .replace("%playername%", player.name) + .replace("%playername%", player?.name ?: "server") .replace("%point%", pointString.toFriendlyPointName()) .replace("%amount%", amountNum.toNiceString()) ) @@ -66,7 +71,7 @@ internal class CommandPointsGive(plugin: EcoPlugin): Subcommand( 1 -> StringUtil.copyPartialMatches( args[0], Bukkit.getOnlinePlayers().map { it.name }, - mutableListOf() + mutableListOf("global") ) 2 -> listOf("point") 3 -> mutableListOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsSet.kt b/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsSet.kt index 8280ca53..64501733 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsSet.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsSet.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.commands import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.util.toNiceString +import com.willfp.libreforge.globalPoints import com.willfp.libreforge.points import com.willfp.libreforge.toFriendlyPointName import org.bukkit.Bukkit @@ -26,7 +27,7 @@ internal class CommandPointsSet(plugin: EcoPlugin): Subcommand( val player = Bukkit.getPlayer(playerString) - if (player == null) { + if (player == null && playerString.equals("global", ignoreCase = true)) { sender.sendMessage(plugin.langYml.getMessage("invalid-player")) return } @@ -52,10 +53,14 @@ internal class CommandPointsSet(plugin: EcoPlugin): Subcommand( return } - player.points[pointString] = amountNum + if (player != null) { + player.points[pointString] = amountNum + } else { + globalPoints[pointString] = amountNum + } sender.sendMessage(plugin.langYml.getMessage("points-set") - .replace("%playername%", player.name) + .replace("%playername%", player?.name ?: "server") .replace("%point%", pointString.toFriendlyPointName()) .replace("%amount%", amountNum.toNiceString()) ) @@ -66,7 +71,7 @@ internal class CommandPointsSet(plugin: EcoPlugin): Subcommand( 1 -> StringUtil.copyPartialMatches( args[0], Bukkit.getOnlinePlayers().map { it.name }, - mutableListOf() + mutableListOf("global") ) 2 -> listOf("point") 3 -> mutableListOf( diff --git a/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsTake.kt b/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsTake.kt index 3694eae5..0a014118 100644 --- a/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsTake.kt +++ b/core/src/main/kotlin/com/willfp/libreforge/commands/CommandPointsTake.kt @@ -3,6 +3,7 @@ package com.willfp.libreforge.commands import com.willfp.eco.core.EcoPlugin import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.util.toNiceString +import com.willfp.libreforge.globalPoints import com.willfp.libreforge.points import com.willfp.libreforge.toFriendlyPointName import org.bukkit.Bukkit @@ -26,7 +27,7 @@ internal class CommandPointsTake(plugin: EcoPlugin): Subcommand( val player = Bukkit.getPlayer(playerString) - if (player == null) { + if (player == null && playerString.equals("global", ignoreCase = true)) { sender.sendMessage(plugin.langYml.getMessage("invalid-player")) return } @@ -52,10 +53,14 @@ internal class CommandPointsTake(plugin: EcoPlugin): Subcommand( return } - player.points[pointString] = player.points[pointString] - amountNum + if (player != null) { + player.points[pointString] = player.points[pointString] - amountNum + } else { + globalPoints[pointString] = globalPoints[pointString] - amountNum + } sender.sendMessage(plugin.langYml.getMessage("points-taken") - .replace("%playername%", player.name) + .replace("%playername%", player?.name ?: "server") .replace("%point%", pointString.toFriendlyPointName()) .replace("%amount%", amountNum.toNiceString()) ) @@ -66,7 +71,7 @@ internal class CommandPointsTake(plugin: EcoPlugin): Subcommand( 1 -> StringUtil.copyPartialMatches( args[0], Bukkit.getOnlinePlayers().map { it.name }, - mutableListOf() + mutableListOf("global") ) 2 -> listOf("point") 3 -> mutableListOf(