Prevent players from adding the shortcut to item frames and armor stands

This commit is contained in:
GeorgH93 2020-01-09 14:11:44 +01:00
parent 67169278b7
commit 124f865104
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 37 additions and 6 deletions

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>at.pcgamingfreaks</groupId>
<artifactId>Minepacks</artifactId>
<version>2.1.1</version>
<version>2.1.2</version>
<scm>
<connection>scm:git:git@github.com:GeorgH93/Minepacks.git</connection>

View File

@ -113,7 +113,7 @@ public String getDBFields(String sub, String def)
public boolean getUseUUIDs()
{
boolean uuid = getConfigE().getBoolean("Database.UseUUIDs", true);
if(!uuid) logger.warning(ConsoleColor.RED + "Disabling UUIDs is not recommended and can lead to unexpected behaviour. Please consider enabling UUIDs. The option will be removed with v2.1." + ConsoleColor.RESET);
if(!uuid) logger.warning(ConsoleColor.RED + "Disabling UUIDs is not recommended and can lead to unexpected behaviour. Please consider enabling UUIDs. The option will be removed at some point." + ConsoleColor.RESET);
return uuid;
}

View File

@ -18,6 +18,7 @@
package at.pcgamingfreaks.Minepacks.Bukkit.Listener;
import at.pcgamingfreaks.Bukkit.HeadUtils;
import at.pcgamingfreaks.Bukkit.MCVersion;
import at.pcgamingfreaks.Bukkit.Message.Message;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
@ -33,10 +34,8 @@
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
@ -97,6 +96,38 @@ public void onItemInteract(PlayerInteractEvent event)
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onArmorStandManipulation(PlayerArmorStandManipulateEvent event)
{
if(isItemShortcut(event.getPlayerItem()))
{
event.getPlayer().performCommand("backpack open");
event.setCancelled(true);
}
}
private static final boolean DUAL_WIELDING_MC = MCVersion.isNewerOrEqualThan(MCVersion.MC_1_9);
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onItemFrameInteract(PlayerInteractEntityEvent event)
{
Player player = event.getPlayer();
ItemStack item;
if(DUAL_WIELDING_MC)
{
item = (event.getHand() == EquipmentSlot.HAND) ? player.getInventory().getItemInMainHand() : player.getInventory().getItemInOffHand();
}
else
{
item = player.getItemInHand();
}
if(isItemShortcut(item))
{
event.getPlayer().performCommand("backpack open");
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onItemClick(InventoryClickEvent event)
{