Skip to content

Commit

Permalink
Fix items
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelillo15 committed Nov 10, 2023
1 parent 7f8d904 commit 85902d3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import es.angelillo15.mast.api.items.IPlayerInteractItem;
import es.angelillo15.mast.api.items.StaffItem;
import es.angelillo15.mast.bukkit.MAStaff;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

Expand All @@ -18,7 +20,9 @@ public ChestItem(ItemStack item, int slot, String permission) {

@Override
public void interact(Player player, Player target) {
player.openInventory(target.getInventory());
Bukkit.getScheduler().runTaskLater(MAStaff.getPlugin(), () -> {
player.openInventory(target.getInventory());
}, 1L);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import es.angelillo15.mast.api.items.IPlayerInteractItem;
import es.angelillo15.mast.api.items.StaffItem;
import es.angelillo15.mast.bukkit.MAStaff;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

Expand All @@ -18,7 +20,9 @@ public EnderChestItem(ItemStack item, int slot, String permission) {

@Override
public void interact(Player player, Player target) {
player.openInventory(target.getEnderChest());
Bukkit.getScheduler().runTaskLater(MAStaff.getPlugin(), () -> {
player.openInventory(target.getEnderChest());
}, 1L);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import es.angelillo15.mast.api.items.IPlayerInteractItem;
import es.angelillo15.mast.api.items.StaffItem;
import es.angelillo15.mast.bukkit.MAStaff;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

Expand Down Expand Up @@ -44,7 +46,9 @@ public int getSlot() {
@Override
public void interact(Player player, Player target) {
if (target != null) {
player.performCommand("freeze " + target.getName());
Bukkit.getScheduler().runTaskLater(MAStaff.getPlugin(), () -> {
player.performCommand("freeze " + target.getName());
}, 1L);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import es.angelillo15.mast.api.items.IPlayerInteractItem;
import es.angelillo15.mast.api.items.StaffItem;
import es.angelillo15.mast.bukkit.MAStaff;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

Expand All @@ -23,8 +25,8 @@ public CustomCommandInteractionItem(

@Override
public void interact(Player player, Player target) {
player.performCommand(
command.replace("{target}", target.getName()).replace("{player}", player.getName()));
Bukkit.getScheduler().runTaskLater(MAStaff.getPlugin(), () -> player.performCommand(
command.replace("{target}", target.getName()).replace("{player}", player.getName())), 1L);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import es.angelillo15.mast.api.items.IExecutableItem;
import es.angelillo15.mast.api.items.StaffItem;
import es.angelillo15.mast.bukkit.MAStaff;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

Expand All @@ -23,7 +25,10 @@ public CustomCommandItem(

@Override
public void click(Player player) {
player.performCommand(this.command.replace("{player}", player.getName()));
Bukkit.getScheduler().runTaskLater(
MAStaff.getPlugin(), () -> player.performCommand(this.command.replace("{player}", player.getName())),
1L
);
}

@Override
Expand Down

0 comments on commit 85902d3

Please sign in to comment.