mirror of
https://e.coding.net/circlecloud/Soulbound.git
synced 2024-11-22 01:49:09 +00:00
禁止将绑定物品放置在盔甲架上
This commit is contained in:
parent
b558cd9bdb
commit
2185518737
@ -2,6 +2,7 @@ package com.me.tft_02.soulbound;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -14,6 +15,7 @@ import com.me.tft_02.soulbound.commands.SoulboundCommand;
|
|||||||
import com.me.tft_02.soulbound.commands.UnbindCommand;
|
import com.me.tft_02.soulbound.commands.UnbindCommand;
|
||||||
import com.me.tft_02.soulbound.config.Config;
|
import com.me.tft_02.soulbound.config.Config;
|
||||||
import com.me.tft_02.soulbound.config.ItemsConfig;
|
import com.me.tft_02.soulbound.config.ItemsConfig;
|
||||||
|
import com.me.tft_02.soulbound.listeners.ArmorStandListener;
|
||||||
import com.me.tft_02.soulbound.listeners.BlockListener;
|
import com.me.tft_02.soulbound.listeners.BlockListener;
|
||||||
import com.me.tft_02.soulbound.listeners.EntityListener;
|
import com.me.tft_02.soulbound.listeners.EntityListener;
|
||||||
import com.me.tft_02.soulbound.listeners.InventoryListener;
|
import com.me.tft_02.soulbound.listeners.InventoryListener;
|
||||||
@ -115,10 +117,14 @@ public class Soulbound extends JavaPlugin {
|
|||||||
|
|
||||||
private void registerEvents() {
|
private void registerEvents() {
|
||||||
final PluginManager pm = getServer().getPluginManager();
|
final PluginManager pm = getServer().getPluginManager();
|
||||||
|
final String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||||
pm.registerEvents(new PlayerListener(), this);
|
pm.registerEvents(new PlayerListener(), this);
|
||||||
pm.registerEvents(new InventoryListener(), this);
|
pm.registerEvents(new InventoryListener(), this);
|
||||||
pm.registerEvents(new EntityListener(), this);
|
pm.registerEvents(new EntityListener(), this);
|
||||||
pm.registerEvents(new BlockListener(), this);
|
pm.registerEvents(new BlockListener(), this);
|
||||||
|
if (version.equals("v1_8_R1") || version.equals("v1_8_R2") || version.equals("v1_8_R3")) {
|
||||||
|
pm.registerEvents(new ArmorStandListener(), this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupFilePaths() {
|
private void setupFilePaths() {
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.me.tft_02.soulbound.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.me.tft_02.soulbound.util.ItemUtils;
|
||||||
|
|
||||||
|
public class ArmorStandListener implements Listener {
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
|
public void onPlayerArmorStandManipulate(PlayerArmorStandManipulateEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final ItemStack itemStack = event.getPlayerItem();
|
||||||
|
if (itemStack != null && ItemUtils.isSoulbound(itemStack)) {
|
||||||
|
player.sendMessage(ChatColor.RED + "绑定物品不允许被放置在盔甲架上.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -86,7 +86,8 @@ public class PlayerListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Watch PlayerCommandPreprocessEvent events.
|
* Watch PlayerCommandPreprocessEvent events.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event
|
||||||
|
* The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerCommand(final PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommand(final PlayerCommandPreprocessEvent event) {
|
||||||
@ -103,7 +104,8 @@ public class PlayerListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Monitor PlayerCommandPreprocessEvent events.
|
* Monitor PlayerCommandPreprocessEvent events.
|
||||||
*
|
*
|
||||||
* @param event The event to monitor
|
* @param event
|
||||||
|
* The event to monitor
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerCommandMonitor(final PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandMonitor(final PlayerCommandPreprocessEvent event) {
|
||||||
@ -152,7 +154,8 @@ public class PlayerListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Monitor PlayerFishEvent events.
|
* Monitor PlayerFishEvent events.
|
||||||
*
|
*
|
||||||
* @param event The event to monitor
|
* @param event
|
||||||
|
* The event to monitor
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerFish(final PlayerFishEvent event) {
|
public void onPlayerFish(final PlayerFishEvent event) {
|
||||||
@ -163,7 +166,8 @@ public class PlayerListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Watch PlayerInteract events.
|
* Watch PlayerInteract events.
|
||||||
*
|
*
|
||||||
* @param event The event to watch
|
* @param event
|
||||||
|
* The event to watch
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||||
@ -206,7 +210,8 @@ public class PlayerListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Monitor PlayerShearEntityEvent events.
|
* Monitor PlayerShearEntityEvent events.
|
||||||
*
|
*
|
||||||
* @param event The event to monitor
|
* @param event
|
||||||
|
* The event to monitor
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
public void onPlayerShearEntity(final PlayerShearEntityEvent event) {
|
public void onPlayerShearEntity(final PlayerShearEntityEvent event) {
|
||||||
@ -217,7 +222,8 @@ public class PlayerListener implements Listener {
|
|||||||
/**
|
/**
|
||||||
* Monitor ServerCommandEvent events.
|
* Monitor ServerCommandEvent events.
|
||||||
*
|
*
|
||||||
* @param event The event to monitor
|
* @param event
|
||||||
|
* The event to monitor
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onServerCommand(final ServerCommandEvent event) {
|
public void onServerCommand(final ServerCommandEvent event) {
|
||||||
|
Loading…
Reference in New Issue
Block a user