mirror of
https://e.coding.net/circlecloud/Soulbound.git
synced 2024-11-21 01:39:10 +00:00
Accept Merge Request #4 : ( J_twitter : master -> 502647092 : master )
修复盔甲架导致绑定物品转移的问题
This commit is contained in:
commit
b0395c0bf0
@ -2,6 +2,7 @@ package com.me.tft_02.soulbound;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
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.config.Config;
|
||||
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.EntityListener;
|
||||
import com.me.tft_02.soulbound.listeners.InventoryListener;
|
||||
@ -115,10 +117,14 @@ public class Soulbound extends JavaPlugin {
|
||||
|
||||
private void registerEvents() {
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
final String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
pm.registerEvents(new PlayerListener(), this);
|
||||
pm.registerEvents(new InventoryListener(), this);
|
||||
pm.registerEvents(new EntityListener(), 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() {
|
||||
|
@ -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.
|
||||
*
|
||||
* @param event The event to watch
|
||||
* @param event
|
||||
* The event to watch
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerCommand(final PlayerCommandPreprocessEvent event) {
|
||||
@ -103,7 +104,8 @@ public class PlayerListener implements Listener {
|
||||
/**
|
||||
* Monitor PlayerCommandPreprocessEvent events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event
|
||||
* The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerCommandMonitor(final PlayerCommandPreprocessEvent event) {
|
||||
@ -152,7 +154,8 @@ public class PlayerListener implements Listener {
|
||||
/**
|
||||
* Monitor PlayerFishEvent events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event
|
||||
* The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerFish(final PlayerFishEvent event) {
|
||||
@ -163,7 +166,8 @@ public class PlayerListener implements Listener {
|
||||
/**
|
||||
* Watch PlayerInteract events.
|
||||
*
|
||||
* @param event The event to watch
|
||||
* @param event
|
||||
* The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
@ -206,7 +210,8 @@ public class PlayerListener implements Listener {
|
||||
/**
|
||||
* Monitor PlayerShearEntityEvent events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event
|
||||
* The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerShearEntity(final PlayerShearEntityEvent event) {
|
||||
@ -217,7 +222,8 @@ public class PlayerListener implements Listener {
|
||||
/**
|
||||
* Monitor ServerCommandEvent events.
|
||||
*
|
||||
* @param event The event to monitor
|
||||
* @param event
|
||||
* The event to monitor
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onServerCommand(final ServerCommandEvent event) {
|
||||
|
Loading…
Reference in New Issue
Block a user