Skip to content

Commit

Permalink
feat: 新增权限检测功能
Browse files Browse the repository at this point in the history
  • Loading branch information
imJack6 committed Mar 15, 2024
1 parent 8cbda44 commit 3852f2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ public class ItemHeldListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
Player player = event.getPlayer();
if (player.hasPermission("syncplayersitemslots.bypass")) return;
Player[] players = Bukkit.getServer().getOnlinePlayers().toArray(new Player[0]);
int currentSlot = event.getNewSlot();
for (Player p : players){
if (!p.equals(player)){
if (!p.equals(player) && !p.hasPermission("syncplayersitemslots.bypass")) {
p.getInventory().setHeldItemSlot(currentSlot);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
public class PlayerJoinListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onPlayerJoin(PlayerJoinEvent event) {
Map<Integer, Integer> slotCounts = new HashMap<>();
Player player = event.getPlayer();
if (player.hasPermission("syncplayersitemslots.bypass")) return;
Map<Integer, Integer> slotCounts = new HashMap<>();
for (Player p : Bukkit.getOnlinePlayers()) {
if (!p.hasPermission("syncplayersitemslots.bypass")) return;
int slot = p.getInventory().getHeldItemSlot();
slotCounts.put(slot, slotCounts.getOrDefault(slot, 0) + 1);
}
Expand Down

0 comments on commit 3852f2c

Please sign in to comment.