Refactoring

This commit is contained in:
Auxilor
2022-03-20 14:49:08 +00:00
parent 6717b29460
commit 9404367a89
3 changed files with 6 additions and 6 deletions

View File

@@ -18,7 +18,7 @@ class CommandOpen(plugin: EcoPlugin) : Subcommand(
player as Player
val crate = Crates.getByID(args[0]) ?: return
crate.openWithKey(player, OpenMethod.VIRTUAL_KEY)
crate.openWithMethod(player, OpenMethod.VIRTUAL_KEY)
}
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {

View File

@@ -273,7 +273,7 @@ class Crate(
if (config.getBool("keygui.left-click-opens")) {
val player = event.whoClicked as Player
player.closeInventory()
openWithKey(player, OpenMethod.VIRTUAL_KEY)
openWithMethod(player, OpenMethod.VIRTUAL_KEY)
}
}
@@ -309,7 +309,7 @@ class Crate(
return (0..amount).map { getRandomReward(player, displayWeight) }
}
fun openPhysical(player: Player, location: Location, method: OpenMethod) {
fun openPlaced(player: Player, location: Location, method: OpenMethod) {
val nicerLocation = location.clone().add(0.5, 1.5, 0.5)
if (!hasKeysAndNotify(player, method)) {
@@ -324,10 +324,10 @@ class Crate(
return
}
openWithKey(player, method, nicerLocation)
openWithMethod(player, method, nicerLocation)
}
fun openWithKey(player: Player, method: OpenMethod, location: Location? = null) {
fun openWithMethod(player: Player, method: OpenMethod, location: Location? = null) {
if (!hasKeysAndNotify(player, method)) {
return
}

View File

@@ -35,7 +35,7 @@ class PlacedCrateListener(
when (event.action) {
Action.LEFT_CLICK_BLOCK -> crate.previewForPlayer(player)
Action.RIGHT_CLICK_BLOCK -> crate.openPhysical(
Action.RIGHT_CLICK_BLOCK -> crate.openPlaced(
player,
block.location,
if (physicalKey) OpenMethod.PHYSICAL_KEY else OpenMethod.VIRTUAL_KEY