Skip to content

Commit

Permalink
修复多余事件带来的异常
Browse files Browse the repository at this point in the history
  • Loading branch information
Tining123 committed Jun 27, 2023
1 parent 01802d0 commit 25257dd
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.Tining</groupId>
<artifactId>DemonMarket</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,4 @@ else if(Objects.equals(LangUtil.get(AcquireListGui.GUI_NAME),e.getView().getTitl
}
}
}

/**
* 防止物品被放入商店列表
* @param e
*/
@EventHandler(priority = EventPriority.LOW)
public void disableMove(InventoryMoveItemEvent e) {
Inventory source = e.getSource();
Inventory destination = e.getDestination();

// 获取触发移动事件的玩家
Player player = (Player) e.getInitiator();
AcquireListGui acquireListGui = AcquireListGui.getMyAcquireListGui(player);

if(Objects.nonNull(acquireListGui) && Objects.nonNull(acquireListGui.getInventory())){
Inventory shopInventory = acquireListGui.getInventory();
// 如果目标活源头是商店背包,返回
if(destination.equals(shopInventory) || source.equals(shopInventory)){
e.setCancelled(true);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: DemonMarket
main: com.tining.demonmarket.Main
version: 1.5.1
version: 1.5.2
api-version: 1.13
# YAML 中的注释,一行有效
# 以上是插件基本信息,以下是命令注册
Expand Down

0 comments on commit 25257dd

Please sign in to comment.