Refactoring
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user