General improvements

This commit is contained in:
Auxilor
2022-03-16 19:56:09 +00:00
parent bb1b4ceb43
commit 9e48dda4ca
6 changed files with 64 additions and 10 deletions

View File

@@ -17,6 +17,7 @@ class CommandEcoCrates(plugin: EcoPlugin) : PluginCommand(
.addSubcommand(CommandGive(plugin))
.addSubcommand(CommandKeys(plugin))
.addSubcommand(CommandSet(plugin))
.addSubcommand(CommandForceOpen(plugin))
}
override fun onExecute(sender: CommandSender, args: List<String>) {

View File

@@ -0,0 +1,42 @@
package com.willfp.ecocrates.commands
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.impl.Subcommand
import com.willfp.ecocrates.crate.Crates
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import org.bukkit.util.StringUtil
class CommandForceOpen(plugin: EcoPlugin) : Subcommand(
plugin,
"forceopen",
"ecocrates.command.forceopen",
true
) {
override fun onExecute(player: CommandSender, args: List<String>) {
player as Player
val crate = Crates.getByID(args[0]) ?: return
crate.open(player)
}
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {
val completions = mutableListOf<String>()
if (args.isEmpty()) {
return Crates.values().map { it.id }
}
if (args.size == 1) {
StringUtil.copyPartialMatches(
args[0],
Crates.values().map { it.id },
completions
)
return completions
}
return emptyList()
}
}

View File

@@ -76,8 +76,8 @@ class Crate(
}
}
private val onFinishSound = PlayableSound(
config.getSubsections("onFinish.sounds")
private val finishSound = PlayableSound(
config.getSubsections("finish.sounds")
.map { ConfiguredSound.fromConfig(it) }
)
@@ -180,7 +180,7 @@ class Crate(
fun handleFinish(player: Player, roll: Roll) {
roll.reward.giveTo(player)
onFinishSound.play(player.location)
finishSound.play(player.location)
}
fun giveKeys(player: OfflinePlayer, amount: Int) {

View File

@@ -7,20 +7,21 @@ import com.willfp.eco.core.items.builder.ItemStackBuilder
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
class Reward(
private val config: Config
config: Config
) {
val commands = config.getStrings("commands")
private val commands = config.getStrings("commands")
val items = config.getStrings("items").map { Items.lookup(it) }.filterNot { it is EmptyTestableItem }
private val items = config.getStrings("items").map { Items.lookup(it) }.filterNot { it is EmptyTestableItem }
val display = ItemStackBuilder(Items.lookup(config.getString("display.item")))
private val messages = config.getFormattedStrings("messages")
val display: ItemStack = ItemStackBuilder(Items.lookup(config.getString("display.item")))
.addLoreLines(config.getStrings("display.lore"))
.build()
val messages = config.getFormattedStrings("messages")
val weight = config.getDouble("weight.actual")
val displayWeight = config.getDouble("weight.display")

View File

@@ -2,6 +2,7 @@ crates:
- id: demo
name: "Demo Crate"
roll: csgo
preview:
title: Demo Crate
rows: 6
@@ -15,6 +16,7 @@ crates:
- "100000001"
- "100000001"
- "111111111"
keygui:
item: tripwire_hook unbreaking:1 hide_enchants name:"Demo Crate"
lore:
@@ -24,6 +26,7 @@ crates:
column: 3
rightClickMessage:
- "Buy a Demo Crate key here! get lured into the trap of gambling addiction"
placed:
particles:
- particle: flame
@@ -34,11 +37,13 @@ crates:
- "Amogus? Sus!"
- "&b&lLeft Click to Preview"
- '&a&lRight click to Open'
onFinish:
finish:
sounds:
- sound: entity_firework_rocket_launch
volume: 100
pitch: 1
rewards:
- commands: [ ]
items:

View File

@@ -13,6 +13,7 @@ commands:
ecocrates:
aliases:
- crates
- crate
description: Base plugin command
permission: ecocrates.command.ecocrates
@@ -28,6 +29,7 @@ permissions:
ecocrates.command.preview: true
ecocrates.command.keys: true
ecocrates.command.set: true
ecocrates.command.forceopen: true
ecocrates.break: true
ecocrates.command.ecocrates:
@@ -42,6 +44,9 @@ permissions:
ecocrates.command.open:
description: Allows opening crates with /ecocrates open
default: true
ecocrates.command.forceopen:
description: Allows opening crates with /ecocrates forceopen
default: op
ecocrates.command.preview:
description: Allows previewing crates with /ecocrates preview
default: true