mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-26 13:42:51 +02:00
6ee7c4759a
Message configs are now selected based on the client's language (can be toggled in the config) and will use MineDown formatting to allow display of component messages as well as usage of RGB colors in 1.16. If found the legacy local.yml will be used instead of the per-language files. Move your local.yml to the correct lang config to if you want to use the per-client language option. Version was also changed to 3.11 due to the many internal changes that have accumulated over time
54 lines
1.6 KiB
Java
54 lines
1.6 KiB
Java
package com.Acrobot.ChestShop.Listeners.Player;
|
|
|
|
import com.Acrobot.ChestShop.Configuration.Messages;
|
|
import com.Acrobot.ChestShop.Configuration.Properties;
|
|
import com.Acrobot.ChestShop.Security;
|
|
import com.Acrobot.ChestShop.Signs.ChestShopSign;
|
|
import org.bukkit.block.Block;
|
|
import org.bukkit.block.BlockState;
|
|
import org.bukkit.block.DoubleChest;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
|
import org.bukkit.inventory.InventoryHolder;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
*/
|
|
public class PlayerInventory implements Listener {
|
|
@EventHandler
|
|
public static void onInventoryOpen(InventoryOpenEvent event) {
|
|
if (!Properties.TURN_OFF_DEFAULT_PROTECTION_WHEN_PROTECTED_EXTERNALLY) {
|
|
return;
|
|
}
|
|
|
|
if (!(event.getPlayer() instanceof Player)) {
|
|
return;
|
|
}
|
|
|
|
InventoryHolder holder = event.getInventory().getHolder();
|
|
if (!(holder instanceof BlockState)) {
|
|
return;
|
|
}
|
|
|
|
Player player = (Player) event.getPlayer();
|
|
Block container;
|
|
|
|
if (holder instanceof DoubleChest) {
|
|
container = ((DoubleChest) holder).getLocation().getBlock();
|
|
} else {
|
|
container = ((BlockState) holder).getBlock();
|
|
}
|
|
|
|
if (!ChestShopSign.isShopBlock(container)) {
|
|
return;
|
|
}
|
|
|
|
if (!Security.canAccess(player, container)) {
|
|
Messages.ACCESS_DENIED.sendWithPrefix(player);
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
}
|