mirror of
https://e.coding.net/circlecloud/Soulbound.git
synced 2024-11-22 01:49:09 +00:00
修复Prevent_Item_Drop设置为TRUE时死亡物品消失的问题...
Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
parent
6195f57d62
commit
a51e7638c5
17
pom.xml
17
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.me.tft_02.soulbound</groupId>
|
||||
<artifactId>Soulbound</artifactId>
|
||||
<version>1.2</version>
|
||||
<version>1.3</version>
|
||||
<name>Soulbound</name>
|
||||
<description>Soulbound items for your RPG servers!</description>
|
||||
<url>https://github.com/TfT-02/Soulbound</url>
|
||||
@ -60,21 +60,18 @@
|
||||
</build>
|
||||
<properties>
|
||||
<jenkins.url>http://ci.citycraft.cn:8080</jenkins.url>
|
||||
<update.description>&c修复自动获取版本错误...</update.description>
|
||||
<env.BUILD_NUMBER>Debug</env.BUILD_NUMBER>
|
||||
<update.description>&c修复Prevent_Item_Drop设置为TRUE时死亡物品消失的问题...</update.description>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>mengcraft-repo</id>
|
||||
<url>http://ci.mengcraft.com:8080/plugin/repository/everything/</url>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>citycraft-repo</id>
|
||||
<url>http://ci.citycraft.cn:8800/jenkins/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
<url>${jenkins.url}/plugin/repository/everything/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
@ -82,7 +79,7 @@
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<type>jar</type>
|
||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.citycraft</groupId>
|
||||
|
@ -40,8 +40,7 @@ public class PlayerListener implements Listener {
|
||||
/**
|
||||
* Watch PlayerCommandPreprocessEvent events.
|
||||
*
|
||||
* @param event
|
||||
* The event to watch
|
||||
* @param event The event to watch
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPlayerCommand(final PlayerCommandPreprocessEvent event) {
|
||||
@ -58,8 +57,7 @@ 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) {
|
||||
@ -88,8 +86,7 @@ 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) {
|
||||
@ -114,8 +111,7 @@ 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) {
|
||||
@ -132,8 +128,11 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
private void onItemDrop(final PlayerDropItemEvent event) {
|
||||
public void onItemDrop(final PlayerDropItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (!player.isValid()) {
|
||||
return;
|
||||
}
|
||||
final Item item = event.getItemDrop();
|
||||
final ItemStack itemStack = item.getItemStack();
|
||||
if (Config.getPreventItemDrop()) {
|
||||
@ -151,12 +150,11 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
if (ItemsConfig.isActionItem(itemStack, ActionType.DROP_ITEM)) {
|
||||
ItemUtils.soulbindItem(player, itemStack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
private void onItemPickup(final PlayerPickupItemEvent event) {
|
||||
public void onItemPickup(final PlayerPickupItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Item item = event.getItem();
|
||||
final ItemStack itemStack = item.getItemStack();
|
||||
@ -173,27 +171,24 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
if (ItemsConfig.isActionItem(itemStack, ActionType.PICKUP_ITEM)) {
|
||||
ItemUtils.soulbindItem(player, itemStack);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
private void onPlayerDeath(final PlayerDeathEvent event) {
|
||||
public void onPlayerDeath(final PlayerDeathEvent event) {
|
||||
final Player player = event.getEntity();
|
||||
final boolean deleteOnDeath = Permissions.deleteOnDeath(player);
|
||||
final boolean keepOnDeath = Permissions.keepOnDeath(player);
|
||||
final List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
final List<ItemStack> items = new ArrayList<>();
|
||||
if (!keepOnDeath && !deleteOnDeath) {
|
||||
return;
|
||||
}
|
||||
for (final ItemStack item : new ArrayList<ItemStack>(event.getDrops())) {
|
||||
for (final ItemStack item : new ArrayList<>(event.getDrops())) {
|
||||
if (ItemUtils.isSoulbound(item) && ItemUtils.isBindedPlayer(player, item)) {
|
||||
if (keepOnDeath) {
|
||||
items.add(item);
|
||||
event.getDrops().remove(item);
|
||||
} else if (deleteOnDeath) {
|
||||
event.getDrops().remove(item);
|
||||
}
|
||||
event.getDrops().remove(item);
|
||||
}
|
||||
}
|
||||
PlayerData.storeItemsDeath(player, items);
|
||||
@ -202,34 +197,28 @@ 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)
|
||||
private void onPlayerFish(final PlayerFishEvent event) {
|
||||
public void onPlayerFish(final PlayerFishEvent event) {
|
||||
final ItemStack itemInHand = event.getPlayer().getItemInHand();
|
||||
|
||||
DurabilityUtils.handleInfiniteDurability(itemInHand);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
private void onPlayerRespawn(final PlayerRespawnEvent event) {
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event) {
|
||||
new SoulbindInventoryTask(event.getPlayer(), ActionType.RESPAWN).runTask(Soulbound.p);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
private void onPlayerRespawnHighest(final PlayerRespawnEvent event) {
|
||||
public void onPlayerRespawnHighest(final PlayerRespawnEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final boolean keepOnDeath = Permissions.keepOnDeath(player);
|
||||
if (!keepOnDeath) {
|
||||
if (!Permissions.keepOnDeath(player)) {
|
||||
return;
|
||||
}
|
||||
List<ItemStack> items = new ArrayList<ItemStack>();
|
||||
items = PlayerData.retrieveItemsDeath(player);
|
||||
final ItemStack[] items = PlayerData.retrieveItemsDeath(player).toArray(new ItemStack[0]);
|
||||
if (items != null) {
|
||||
for (final ItemStack item : items) {
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
player.getInventory().addItem(items);
|
||||
}
|
||||
new UpdateInventoryTask(player).runTask(Soulbound.p);
|
||||
}
|
||||
@ -237,13 +226,11 @@ 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)
|
||||
private void onPlayerShearEntity(final PlayerShearEntityEvent event) {
|
||||
public void onPlayerShearEntity(final PlayerShearEntityEvent event) {
|
||||
final ItemStack itemInHand = event.getPlayer().getItemInHand();
|
||||
|
||||
DurabilityUtils.handleInfiniteDurability(itemInHand);
|
||||
}
|
||||
}
|
||||
|
@ -18,20 +18,10 @@ public class PlayerData {
|
||||
}
|
||||
|
||||
public static List<ItemStack> retrieveItemsDeath(final Player player) {
|
||||
final String playerName = player.getName();
|
||||
|
||||
if (playerSoulboundItems.containsKey(playerName)) {
|
||||
return playerSoulboundItems.get(playerName);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return playerSoulboundItems.get(player.getName());
|
||||
}
|
||||
|
||||
public static void storeItemsDeath(final Player player, final List<ItemStack> items) {
|
||||
final String playerName = player.getName();
|
||||
if (playerSoulboundItems.containsKey(playerName)) {
|
||||
playerSoulboundItems.put(playerName, null);
|
||||
}
|
||||
playerSoulboundItems.put(playerName, items);
|
||||
playerSoulboundItems.put(player.getName(), items);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user