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

Commit

Permalink
use more core premission check protection
Browse files Browse the repository at this point in the history
Former-commit-id: 133ff74
  • Loading branch information
Ghost-chu committed Sep 23, 2018
1 parent ed77280 commit 328fe35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.maxgamer</groupId>
<artifactId>QuickShop</artifactId>
<version>Reremake 1.2.0-beta7</version>
<version>Reremake 1.2.0-beta8</version>
<!-- Fuck version -->
<licenses>
<license>
Expand Down
29 changes: 12 additions & 17 deletions src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,6 @@ public HashMap<UUID, Info> getActions() {
public void createShop(Shop shop) {
Location loc = shop.getLocation();
ItemStack item = shop.getItem();
Player player = Bukkit.getPlayer(shop.getOwner());
if(player==null || !player.isOnline()) {
plugin.getLogger().info("Warning! Something wrong happed when createing shop,Canceling... (Code: Target player not online)");
return;
}
PlayerInteractEvent e = new PlayerInteractEvent(player, Action.LEFT_CLICK_BLOCK, item, shop.getLocation().getBlock(), BlockFace.UP);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled()) {
e.getPlayer().sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
BlockBreakEvent be = new BlockBreakEvent(shop.getLocation().getBlock(),player);
Bukkit.getPluginManager().callEvent(be);
if (be.isCancelled()) {
be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
try {
// Write it to the database
String q = "INSERT INTO shops (owner, price, itemConfig, x, y, z, world, unlimited, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
Expand Down Expand Up @@ -186,6 +169,12 @@ private void addShop(String world, Shop shop) {
ShopChunk shopChunk = new ShopChunk(world, x, z);
HashMap<Location, Shop> inChunk = inWorld.get(shopChunk);
// That chunk data hasn't been created yet - Create it!
BlockBreakEvent be = new BlockBreakEvent(shop.getLocation().getBlock(),Bukkit.getPlayer(shop.getOwner()));
Bukkit.getPluginManager().callEvent(be);
if (be.isCancelled()) {
be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
if (inChunk == null) {
inChunk = new HashMap<Location, Shop>(1);
// Put it in the world
Expand Down Expand Up @@ -314,6 +303,12 @@ public void run() {
if (info.getAction() == ShopAction.CREATE) {
try {
// Checking the shop can be created
BlockBreakEvent be = new BlockBreakEvent(info.getLocation().getBlock(),p);
Bukkit.getPluginManager().callEvent(be);
if (be.isCancelled()) {
be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission"));
return;
}
if (plugin.getShopManager().getShop(info.getLocation()) != null) {
p.sendMessage(MsgUtil.getMessage("shop-already-owned"));
return;
Expand Down

0 comments on commit 328fe35

Please sign in to comment.