9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-30 04:19:28 +00:00

Mainhand mostly works

This commit is contained in:
LoJoSho
2022-12-22 18:37:52 -06:00
parent c579923562
commit 6cd2a72f8d
3 changed files with 36 additions and 9 deletions

View File

@@ -11,6 +11,7 @@ import com.hibiscusmc.hmccosmetics.HMCCosmeticsPlugin;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetic;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.types.CosmeticArmorType;
import com.hibiscusmc.hmccosmetics.nms.NMSHandlers;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import com.hibiscusmc.hmccosmetics.user.CosmeticUsers;
import com.hibiscusmc.hmccosmetics.util.InventoryUtils;
@@ -156,16 +157,14 @@ public class PlayerGameListener implements Listener {
@EventHandler
public void onMainHandSwitch(PlayerItemHeldEvent event) {
HMCCosmeticsPlugin.getInstance().getLogger().info("PlayerItemHeldEvent");
CosmeticUser user = CosmeticUsers.getUser(event.getPlayer());
if (user == null) return;
HMCCosmeticsPlugin.getInstance().getLogger().info("PlayerItemHeldEvent 2");
event.getPreviousSlot();
user.updateCosmetic(CosmeticSlot.MAINHAND);
event.getPlayer().getInventory().setItem(event.getPreviousSlot(), event.getPlayer().getInventory().getItem(event.getPreviousSlot()));
//NMSHandlers.getHandler().slotUpdate(event.getPlayer(), event.getPreviousSlot());
Bukkit.getScheduler().runTaskLater(HMCCosmeticsPlugin.getInstance(), () -> {
user.updateCosmetic(CosmeticSlot.MAINHAND);
}, 2);
}
private void registerInventoryClickListener() {

View File

@@ -32,6 +32,10 @@ public interface NMSHandler {
List<Player> sendTo
);
void slotUpdate(
Player player,
int slot
);
default boolean getSupported () {
return false;