Add flag that prevents people from copying NBT data in the plot unless they're added as members

This commit is contained in:
Alexander Söderberg
2020-05-12 19:24:56 +02:00
parent be6910d5d9
commit d20fa39cf5
4 changed files with 63 additions and 0 deletions

View File

@ -79,6 +79,7 @@ import com.plotsquared.core.plot.flag.implementations.MobPlaceFlag;
import com.plotsquared.core.plot.flag.implementations.MycelGrowFlag;
import com.plotsquared.core.plot.flag.implementations.PlaceFlag;
import com.plotsquared.core.plot.flag.implementations.PlayerInteractFlag;
import com.plotsquared.core.plot.flag.implementations.PreventCreativeCopyFlag;
import com.plotsquared.core.plot.flag.implementations.PveFlag;
import com.plotsquared.core.plot.flag.implementations.PvpFlag;
import com.plotsquared.core.plot.flag.implementations.RedstoneFlag;
@ -173,6 +174,7 @@ import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -1677,6 +1679,19 @@ public class PlayerEvents extends PlotListener implements Listener {
ItemStack newItem = event.getCursor();
ItemMeta newMeta = newItem.getItemMeta();
ItemMeta oldMeta = newItem.getItemMeta();
if (event.getClick() == ClickType.CREATIVE) {
final Plot plot = pp.getCurrentPlot();
if (plot != null &&
plot.getFlag(PreventCreativeCopyFlag.class) &&
!plot.isAdded(player.getUniqueId()) &&
!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) {
final ItemStack newStack = new ItemStack(newItem.getType(), newItem.getAmount());
event.setCursor(newStack);
}
return;
}
String newLore = "";
if (newMeta != null) {
List<String> lore = newMeta.getLore();