Skip to content

Commit

Permalink
3.0.1 Cleanup code
Browse files Browse the repository at this point in the history
アイテム系のStorageBoxの使用をできなくする。
  • Loading branch information
gotahu committed Apr 8, 2018
1 parent 9d150ca commit ddc9f4e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
30 changes: 24 additions & 6 deletions src/main/kotlin/net/hinyari/plugin/storagebox/event/Interact.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package net.hinyari.plugin.storagebox.event
import net.hinyari.plugin.storagebox.StorageBoxMain
import net.hinyari.plugin.storagebox.extensions.*
import net.hinyari.plugin.storagebox.util.SBUtil
import org.bukkit.Material
import org.bukkit.Sound
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
Expand All @@ -12,10 +11,7 @@ import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.inventory.EquipmentSlot

class Interact constructor(val plugin: StorageBoxMain) : Listener {

// StorageBoxの使用に対応するアイテム
private var materialArray = arrayOf(Material.ENDER_PEARL, Material.MINECART, Material.WATER_BUCKET,
Material.LAVA_BUCKET)

private val inventoryUtil = plugin.inventoryUtil

@EventHandler
Expand All @@ -40,12 +36,12 @@ class Interact constructor(val plugin: StorageBoxMain) : Listener {
}

val isMainHand = event.hand == EquipmentSlot.HAND
val amount = SBUtil.getAmountOfStorageBox(item)

// スニーク中
if (player.isSneaking) {
// アイテムを取り出す処理
if (event.action == Action.LEFT_CLICK_AIR || event.action == Action.LEFT_CLICK_BLOCK) { // 左クリ
val amount = SBUtil.getAmountOfStorageBox(item)
// 0個なら無視
if (amount <= 0) return

Expand All @@ -62,7 +58,29 @@ class Interact constructor(val plugin: StorageBoxMain) : Listener {
player.playSound(player.location, Sound.BLOCK_DISPENSER_DISPENSE, 1.0f, 1.5f)
}
}
}

if (!item.type.isSolid) {
event.isCancelled = true
player.sendActionBar("アイテムを使用にはまだ対応していません")
player.playSound(player.location, Sound.BLOCK_NOTE_BASS, 0.2f, 0.4f)
return
}

/*
when (item.type) {
Material.ENDER_PEARL -> {
object : BukkitRunnable() {
override fun run() {
// メインハンドにStorageBoxを所持している場合
if (isMainHand) player.itemInMainHand = item.toStorageBox(amount - 1)
else player.itemInOffHand = item.toStorageBox(amount - 1)
}
}.runTaskLater(plugin, 1L)
}
else -> return
}
*/
}
}
3 changes: 2 additions & 1 deletion src/main/kotlin/net/hinyari/plugin/storagebox/event/Place.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Place constructor(val plugin: StorageBoxMain) : Listener {

// 無効化リストに入っていた場合
if (Config.values.uncreatableMaterialList.contains(event.itemInHand.type)) {
player.sendMessageWithErrorPrefix("そのアイテムを設置することは出来ません。")
player.sendActionBar("&cそのアイテムを設置することは出来ません")
event.isCancelled = true
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fun ItemStack.toStorageBox(amount: Int): ItemStack {
}

if (type == Material.AIR) {
println("toStorageBox() {type=$type}")
return ItemStack(Material.AIR)
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ prefix:
normal: "&a&l[ StorageBox ]&r "
error: "&c&l[ StorageBox ]&r "
noPermission: "このコマンドを実行する権限がありません!"

sound:
# 十分なアイテムがない場合
noEnoughItems: [BLOCK_DISPENSER_FAIL, 0.4, 1.0]

crafting:
# クラフトでStorageBoxを作ることを許可するか
Expand Down

0 comments on commit ddc9f4e

Please sign in to comment.