forked from SteamWar/SteamWar
@@ -73,8 +73,8 @@ class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
|
|||||||
this.rawInventory = rawInventory
|
this.rawInventory = rawInventory
|
||||||
this.rawArmor = rawArmor
|
this.rawArmor = rawArmor
|
||||||
this.inUse = false
|
this.inUse = false
|
||||||
}
|
}.also { it.setDefault() }
|
||||||
}.also { it.setDefault() }
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getKitInUse(userId: Int, gamemode: String) = useDb {
|
fun getKitInUse(userId: Int, gamemode: String) = useDb {
|
||||||
@@ -110,6 +110,7 @@ class InternalKit(id: EntityID<CompositeID>): CompositeEntity(id) {
|
|||||||
|
|
||||||
fun setDefault() = useDb {
|
fun setDefault() = useDb {
|
||||||
find { PersonalKitTable.userId eq userID and (PersonalKitTable.gamemode eq gameMode) and (PersonalKitTable.inUse eq true) }
|
find { PersonalKitTable.userId eq userID and (PersonalKitTable.gamemode eq gameMode) and (PersonalKitTable.inUse eq true) }
|
||||||
|
.filter { it.id.value != this@InternalKit.id.value }
|
||||||
.forEach { it.inUse = false }
|
.forEach { it.inUse = false }
|
||||||
inUse = true
|
inUse = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import org.bukkit.event.block.Action;
|
|||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -62,6 +63,7 @@ public class HotbarKitListener implements Listener {
|
|||||||
public void onInventoryClick(InventoryClickEvent event) {
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
int slot = event.getSlot();
|
int slot = event.getSlot();
|
||||||
if (slot < 0 || slot >= HotbarKit.HOTBAR_SIZE) return;
|
if (slot < 0 || slot >= HotbarKit.HOTBAR_SIZE) return;
|
||||||
|
if (!(event.getClickedInventory() instanceof PlayerInventory)) return;
|
||||||
|
|
||||||
Player player = (Player) event.getWhoClicked();
|
Player player = (Player) event.getWhoClicked();
|
||||||
click(player, slot, event);
|
click(player, slot, event);
|
||||||
|
|||||||
Reference in New Issue
Block a user