Skip to content
This repository was archived by the owner on Dec 5, 2021. It is now read-only.

Commit 328fe35

Browse files
committed
use more core premission check protection
Former-commit-id: 133ff74
1 parent ed77280 commit 328fe35

2 files changed

Lines changed: 13 additions & 18 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.maxgamer</groupId>
55
<artifactId>QuickShop</artifactId>
6-
<version>Reremake 1.2.0-beta7</version>
6+
<version>Reremake 1.2.0-beta8</version>
77
<!-- Fuck version -->
88
<licenses>
99
<license>

src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,6 @@ public HashMap<UUID, Info> getActions() {
5555
public void createShop(Shop shop) {
5656
Location loc = shop.getLocation();
5757
ItemStack item = shop.getItem();
58-
Player player = Bukkit.getPlayer(shop.getOwner());
59-
if(player==null || !player.isOnline()) {
60-
plugin.getLogger().info("Warning! Something wrong happed when createing shop,Canceling... (Code: Target player not online)");
61-
return;
62-
}
63-
PlayerInteractEvent e = new PlayerInteractEvent(player, Action.LEFT_CLICK_BLOCK, item, shop.getLocation().getBlock(), BlockFace.UP);
64-
Bukkit.getPluginManager().callEvent(e);
65-
if (e.isCancelled()) {
66-
e.getPlayer().sendMessage(MsgUtil.getMessage("no-permission"));
67-
return;
68-
}
69-
BlockBreakEvent be = new BlockBreakEvent(shop.getLocation().getBlock(),player);
70-
Bukkit.getPluginManager().callEvent(be);
71-
if (be.isCancelled()) {
72-
be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission"));
73-
return;
74-
}
7558
try {
7659
// Write it to the database
7760
String q = "INSERT INTO shops (owner, price, itemConfig, x, y, z, world, unlimited, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
@@ -186,6 +169,12 @@ private void addShop(String world, Shop shop) {
186169
ShopChunk shopChunk = new ShopChunk(world, x, z);
187170
HashMap<Location, Shop> inChunk = inWorld.get(shopChunk);
188171
// That chunk data hasn't been created yet - Create it!
172+
BlockBreakEvent be = new BlockBreakEvent(shop.getLocation().getBlock(),Bukkit.getPlayer(shop.getOwner()));
173+
Bukkit.getPluginManager().callEvent(be);
174+
if (be.isCancelled()) {
175+
be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission"));
176+
return;
177+
}
189178
if (inChunk == null) {
190179
inChunk = new HashMap<Location, Shop>(1);
191180
// Put it in the world
@@ -314,6 +303,12 @@ public void run() {
314303
if (info.getAction() == ShopAction.CREATE) {
315304
try {
316305
// Checking the shop can be created
306+
BlockBreakEvent be = new BlockBreakEvent(info.getLocation().getBlock(),p);
307+
Bukkit.getPluginManager().callEvent(be);
308+
if (be.isCancelled()) {
309+
be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission"));
310+
return;
311+
}
317312
if (plugin.getShopManager().getShop(info.getLocation()) != null) {
318313
p.sendMessage(MsgUtil.getMessage("shop-already-owned"));
319314
return;

0 commit comments

Comments
 (0)