Skip to content

Commit

Permalink
Added protection check, should solve #21
Browse files Browse the repository at this point in the history
  • Loading branch information
GallowsDove committed Mar 23, 2021
1 parent 2ba719e commit ae8d8ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void onEnable() {
PluginUtils.registerListener(new PoseidonsFishingRodListener());
PluginUtils.registerListener(new ArmorListener());
PluginUtils.registerListener(new BowListener());

ItemSetup.INSTANCE.init();
ResearchSetup.INSTANCE.init();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.gallowsdove.foxymachines.FoxyMachines;
import me.gallowsdove.foxymachines.Items;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.cscorelib2.protection.ProtectableAction;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
Expand Down Expand Up @@ -57,17 +60,22 @@ public void onRightClick(PlayerRightClickEvent e) {
Block b = e.getClickedBlock().get().getRelative(e.getClickedFace());

if (b.getWorld().getNearbyEntities(b.getLocation().add(0.5, 0, 0.5), 0.01, 0.01, 0.01).isEmpty()) {
FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, 0, 0.5), material.createBlockData());
block.setVelocity(new Vector(0, 0, 0));
block.setGravity(false);
block.setDropItem(false);
block.setPersistent(true);
block.setInvulnerable(true);
block.getPersistentDataContainer().set(KEY, PersistentDataType.STRING, "true");
if (SlimefunPlugin.getProtectionManager().hasPermission(p, b, ProtectableAction.PLACE_BLOCK)) {
FallingBlock block = b.getWorld().spawnFallingBlock(b.getLocation().add(0.5, 0, 0.5), material.createBlockData());
block.setVelocity(new Vector(0, 0, 0));
block.setGravity(false);
block.setDropItem(false);
block.setPersistent(true);
block.setInvulnerable(true);
block.getPersistentDataContainer().set(KEY, PersistentDataType.STRING, "true");

ItemStack item = e.getInteractEvent().getItem();

item.setAmount(item.getAmount() - 1);
ItemStack item = e.getInteractEvent().getItem();

item.setAmount(item.getAmount() - 1);
} else {
p.sendMessage(ChatColor.LIGHT_PURPLE + "You don't have permission to place this here!");
}
}
}
}
Expand Down

0 comments on commit ae8d8ab

Please sign in to comment.