1
0
mirror of https://e.coding.net/circlecloud/Soulbound.git synced 2024-11-21 01:39:10 +00:00

补全部分汉化 移除无用代码...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-11-24 20:50:45 +08:00
parent 220ca9e339
commit 6195f57d62
15 changed files with 410 additions and 559 deletions

View File

@ -18,7 +18,6 @@ import com.me.tft_02.soulbound.listeners.BlockListener;
import com.me.tft_02.soulbound.listeners.EntityListener;
import com.me.tft_02.soulbound.listeners.InventoryListener;
import com.me.tft_02.soulbound.listeners.PlayerListener;
import com.me.tft_02.soulbound.util.LogFilter;
import cn.citycraft.PluginHelper.config.FileConfig;
import cn.citycraft.PluginHelper.utils.VersionChecker;
@ -75,7 +74,6 @@ public class Soulbound extends JavaPlugin {
@Override
public void onEnable() {
p = this;
getLogger().setFilter(new LogFilter(this));
setupFilePaths();

View File

@ -1,6 +1,5 @@
package com.me.tft_02.soulbound.config;
import java.util.ArrayList;
import java.util.List;
import cn.citycraft.PluginHelper.config.FileConfig;
@ -20,48 +19,10 @@ public class Config {
return config.getStringList("Soulbound.Blocked_Commands");
}
public static boolean getConfigOverwriteEnabled() {
return config.getBoolean("General.Config_Update_Overwrite", true);
}
public static boolean getDeleteOnDrop() {
return config.getBoolean("Soulbound.Delete_On_Drop", false);
}
public static List<String> getDiabloDropsBindOnEquipTiers() {
return getDiabloDropsItemTiers("BindOnEquip");
}
public static List<String> getDiabloDropsBindOnPickupTiers() {
return getDiabloDropsItemTiers("BindOnPickup");
}
public static List<String> getDiabloDropsBindOnUseTiers() {
return getDiabloDropsItemTiers("BindOnUse");
}
public static List<String> getDiabloDropsItemTiers(final String bindType) {
final String[] tiersString = config.getString("Dependency_Plugins.DiabloDrops." + bindType).replaceAll(" ", "").split("[,]");
final List<String> tiers = new ArrayList<String>();
for (final String tier : tiersString) {
tiers.add(tier);
}
return tiers;
}
public static boolean getEBRBindOnEquip() {
return config.getBoolean("Dependency_Plugins.EpicBossRecoded.BindOnEquip");
}
public static boolean getEBRBindOnPickup() {
return config.getBoolean("Dependency_Plugins.EpicBossRecoded.BindOnPickup");
}
public static boolean getEBRBindOnUse() {
return config.getBoolean("Dependency_Plugins.EpicBossRecoded.BindOnUse");
}
public static boolean getFeedbackEnabled() {
return config.getBoolean("Soulbound.Feedback_Messages_Enabled", true);
}
@ -70,36 +31,6 @@ public class Config {
return config.getBoolean("Soulbound.Infinite_Durability", false);
}
public static boolean getLoreLocksBindKeys() {
return config.getBoolean("Dependency_Plugins.LoreLocks.Bind_Keys");
}
public static List<String> getMythicDropsBindOnEquipTiers() {
return getMythicDropsItemTiers("BindOnEquip");
}
public static List<String> getMythicDropsBindOnPickupTiers() {
return getMythicDropsItemTiers("BindOnPickup");
}
public static List<String> getMythicDropsBindOnUseTiers() {
return getMythicDropsItemTiers("BindOnUse");
}
public static List<String> getMythicDropsItemTiers(final String bindType) {
final String[] tiersString = config.getString("Dependency_Plugins.MythicDrops." + bindType).replaceAll(" ", "").split("[,]");
final List<String> tiers = new ArrayList<String>();
for (final String tier : tiersString) {
tiers.add(tier);
}
return tiers;
}
public static boolean getPreferBeta() {
return config.getBoolean("General.Prefer_Beta", false);
}
public static boolean getPreventItemDrop() {
return config.getBoolean("Soulbound.Prevent_Item_Drop", false);
}
@ -108,18 +39,6 @@ public class Config {
return config.getBoolean("Soulbound.Show_Name_In_Lore", true);
}
public static boolean getStatsTrackingEnabled() {
return config.getBoolean("General.Stats_Tracking", true);
}
public static boolean getUpdateCheckEnabled() {
return config.getBoolean("General.Update_Check", true);
}
public static boolean getVerboseLoggingEnabled() {
return config.getBoolean("General.Verbose_Logging", false);
}
public static void load(final FileConfig config) {
Config.config = config;
}

View File

@ -43,7 +43,7 @@ public class InventoryListener implements Listener {
if (itemType != ItemType.SOULBOUND) {
return;
}
if (!Config.getAllowItemStoring() && !(inventoryType == InventoryType.CRAFTING)) {
if (!Config.getAllowItemStoring() && inventoryType != InventoryType.CRAFTING) {
event.setCancelled(true);
}
if (ItemUtils.isBindedPlayer(player, itemStack) || Permissions.pickupBypass(player)) {

View File

@ -50,7 +50,7 @@ public class PlayerListener implements Listener {
final String command = event.getMessage();
if (ItemUtils.isSoulbound(itemStack) && Config.getBlockedCommands().contains(command)) {
player.sendMessage(ChatColor.RED + "You're not allowed to use " + ChatColor.GOLD + command + ChatColor.RED + " command while holding a Soulbound item.");
player.sendMessage(ChatColor.RED + "不允许使用命令 " + ChatColor.GOLD + command + ChatColor.RED + " 当拿着绑定物品的时候.");
event.setCancelled(true);
}
}

View File

@ -29,7 +29,7 @@ public class SelfListener implements Listener {
}
}
if (count >= maxAmount) {
player.sendMessage(ChatColor.RED + "Cannot Soulbind any more items, maximum amount reached! " + ChatColor.GOLD + "(" + maxAmount + ")");
player.sendMessage(ChatColor.RED + "无法绑定更多的物品, 已到达最大上限! " + ChatColor.GOLD + "(" + maxAmount + ")");
event.setCancelled(true);
}
}

View File

@ -9,26 +9,25 @@ import com.me.tft_02.soulbound.datatypes.ActionType;
import com.me.tft_02.soulbound.util.ItemUtils;
public class SoulbindInventoryTask extends BukkitRunnable {
private Player player;
private ActionType actionType;
private final ActionType actionType;
private final Player player;
public SoulbindInventoryTask(Player player, ActionType actionType) {
this.player = player;
this.actionType = actionType;
}
public SoulbindInventoryTask(final Player player, final ActionType actionType) {
this.player = player;
this.actionType = actionType;
}
@Override
public void run() {
for (ItemStack itemStack : player.getInventory().getContents()) {
if (itemStack != null && ItemsConfig.isActionItem(itemStack, actionType)) {
ItemUtils.soulbindItem(player, itemStack);
}
}
for (ItemStack itemStack : player.getInventory().getArmorContents()) {
if (itemStack != null && ItemsConfig.isActionItem(itemStack, actionType)) {
ItemUtils.soulbindItem(player, itemStack);
}
}
}
@Override
public void run() {
for (final ItemStack itemStack : player.getInventory().getContents()) {
if (itemStack != null && ItemsConfig.isActionItem(itemStack, actionType)) {
ItemUtils.soulbindItem(player, itemStack);
}
}
for (final ItemStack itemStack : player.getInventory().getArmorContents()) {
if (itemStack != null && ItemsConfig.isActionItem(itemStack, actionType)) {
ItemUtils.soulbindItem(player, itemStack);
}
}
}
}

View File

@ -8,24 +8,23 @@ import com.me.tft_02.soulbound.util.ItemUtils;
import com.me.tft_02.soulbound.util.ItemUtils.ItemType;
public class UpdateArmorTask extends BukkitRunnable {
private Player player;
private final Player player;
public UpdateArmorTask(Player player) {
this.player = player;
}
public UpdateArmorTask(final Player player) {
this.player = player;
}
@Override
public void run() {
handleBindOnEquip(player);
}
public void handleBindOnEquip(final Player player) {
for (final ItemStack armor : player.getInventory().getArmorContents()) {
if (armor != null && ItemUtils.getItemType(armor) == ItemType.BIND_ON_EQUIP) {
ItemUtils.soulbindItem(player, armor);
}
}
player.getInventory().setArmorContents(player.getInventory().getArmorContents());
}
public void handleBindOnEquip(Player player) {
for (ItemStack armor : player.getInventory().getArmorContents()) {
if (armor != null && ItemUtils.getItemType(armor) == ItemType.BIND_ON_EQUIP) {
ItemUtils.soulbindItem(player, armor);
}
}
player.getInventory().setArmorContents(player.getInventory().getArmorContents());
}
@Override
public void run() {
handleBindOnEquip(player);
}
}

View File

@ -4,9 +4,9 @@ import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class UpdateInventoryTask extends BukkitRunnable {
private Player player;
private final Player player;
public UpdateInventoryTask(Player player) {
public UpdateInventoryTask(final Player player) {
this.player = player;
}

View File

@ -7,32 +7,30 @@ import org.bukkit.entity.Player;
public final class CommandUtils {
public static String[] extractArgs(String command) {
String[] args = {""};
String[] split = command.split(" ", 2);
public static String[] extractArgs(final String command) {
String[] args = { "" };
final String[] split = command.split(" ", 2);
if (split.length > 1) {
args = split[1].split(" ");
}
return args;
}
if (split.length > 1) {
args = split[1].split(" ");
}
public static boolean isOffline(final CommandSender sender, final OfflinePlayer player) {
if (player != null && player.isOnline()) {
return false;
}
return args;
}
sender.sendMessage(ChatColor.RED + "当前命令不能作用于离线的玩家.");
return true;
}
public static boolean noConsoleUsage(CommandSender sender) {
if (sender instanceof Player) {
return false;
}
public static boolean noConsoleUsage(final CommandSender sender) {
if (sender instanceof Player) {
return false;
}
sender.sendMessage("This command does not support console usage.");
return true;
}
public static boolean isOffline(CommandSender sender, OfflinePlayer player) {
if (player != null && player.isOnline()) {
return false;
}
sender.sendMessage(ChatColor.RED + "This command does not work for offline players.");
return true;
}
sender.sendMessage("当前命令不能再控制台执行!");
return true;
}
}

View File

@ -6,10 +6,10 @@ import com.me.tft_02.soulbound.config.Config;
public class DurabilityUtils {
public static void handleInfiniteDurability(ItemStack itemStack) {
if (Config.getInfiniteDurability() && ItemUtils.isSoulbound(itemStack)) {
itemStack.setDurability((short) 0);
return;
}
}
public static void handleInfiniteDurability(final ItemStack itemStack) {
if (Config.getInfiniteDurability() && ItemUtils.isSoulbound(itemStack)) {
itemStack.setDurability((short) 0);
return;
}
}
}

View File

@ -13,363 +13,361 @@ import com.me.tft_02.soulbound.config.Config;
import com.me.tft_02.soulbound.events.SoulbindItemEvent;
public class ItemUtils {
public enum ItemType {
NORMAL,
SOULBOUND,
BIND_ON_PICKUP,
BIND_ON_USE,
BIND_ON_EQUIP;
}
public static ItemStack boeItem(final ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
public static ItemStack soulbindItem(Player player, ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
if (isBindOnEquip(itemStack)) {
return itemStack;
}
if (isSoulbound(itemStack)) {
return itemStack;
}
final ItemMeta itemMeta = itemStack.getItemMeta();
SoulbindItemEvent soulbindItemEvent = new SoulbindItemEvent(player, itemStack);
Soulbound.p.getServer().getPluginManager().callEvent(soulbindItemEvent);
itemStack = soulbindItemEvent.getItemStack();
final List<String> itemLore = new ArrayList<String>();
if (itemMeta.hasLore()) {
itemLore.addAll(itemMeta.getLore());
}
itemLore.add(Misc.EQUIPBIND_TAG);
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
if (soulbindItemEvent.isCancelled()) {
return itemStack;
}
public static ItemStack bopItem(final ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> itemLore = new ArrayList<String>();
if (isBindOnPickup(itemStack)) {
return itemStack;
}
if (itemMeta.hasLore()) {
List<String> oldLore = itemMeta.getLore();
oldLore.remove(Misc.EQUIPBIND_TAG);
oldLore.remove(Misc.PICKUPBIND_TAG);
oldLore.remove(Misc.USEBIND_TAG);
itemLore.addAll(oldLore);
}
final ItemMeta itemMeta = itemStack.getItemMeta();
itemLore.add(Misc.SOULBOUND_TAG);
if (Config.getShowNameInLore()) {
itemLore.add(player.getName());
}
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
final List<String> itemLore = new ArrayList<String>();
if (itemMeta.hasLore()) {
itemLore.addAll(itemMeta.getLore());
}
itemLore.add(Misc.PICKUPBIND_TAG);
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack bopItem(ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
public static ItemStack bouItem(final ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
if (isBindOnPickup(itemStack)) {
return itemStack;
}
if (isBindOnUse(itemStack)) {
return itemStack;
}
ItemMeta itemMeta = itemStack.getItemMeta();
final ItemMeta itemMeta = itemStack.getItemMeta();
List<String> itemLore = new ArrayList<String>();
if (itemMeta.hasLore()) {
itemLore.addAll(itemMeta.getLore());
}
itemLore.add(Misc.PICKUPBIND_TAG);
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
final List<String> itemLore = new ArrayList<String>();
if (itemMeta.hasLore()) {
itemLore.addAll(itemMeta.getLore());
}
itemLore.add(Misc.USEBIND_TAG);
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack boeItem(ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
public static ItemType getItemType(final ItemStack itemStack) {
if (itemStack == null) {
return ItemType.NORMAL;
} else if (isSoulbound(itemStack)) {
return ItemType.SOULBOUND;
} else if (isBindOnPickup(itemStack)) {
return ItemType.BIND_ON_PICKUP;
} else if (isBindOnUse(itemStack)) {
return ItemType.BIND_ON_USE;
} else if (isBindOnEquip(itemStack)) {
return ItemType.BIND_ON_EQUIP;
} else {
return ItemType.NORMAL;
}
}
if (isBindOnEquip(itemStack)) {
return itemStack;
}
public static boolean isBindedPlayer(final Player player, final ItemStack itemStack) {
final List<String> itemLore = itemStack.getItemMeta().getLore();
ItemMeta itemMeta = itemStack.getItemMeta();
return itemLore.contains(player.getName());
}
List<String> itemLore = new ArrayList<String>();
if (itemMeta.hasLore()) {
itemLore.addAll(itemMeta.getLore());
}
itemLore.add(Misc.EQUIPBIND_TAG);
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static boolean isBindOnEquip(final ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
public static ItemStack bouItem(ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
final ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
final List<String> itemLore = itemMeta.getLore();
if (itemLore.contains(Misc.EQUIPBIND_TAG)) {
return true;
}
}
return false;
}
if (isBindOnUse(itemStack)) {
return itemStack;
}
public static boolean isBindOnPickup(final ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
ItemMeta itemMeta = itemStack.getItemMeta();
final ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
final List<String> itemLore = itemMeta.getLore();
if (itemLore.contains(Misc.PICKUPBIND_TAG)) {
return true;
}
}
return false;
}
List<String> itemLore = new ArrayList<String>();
if (itemMeta.hasLore()) {
itemLore.addAll(itemMeta.getLore());
}
itemLore.add(Misc.USEBIND_TAG);
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static boolean isBindOnUse(final ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
public static ItemStack unbindItem(ItemStack itemStack) {
if (itemStack == null) {
return null;
}
final ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
final List<String> itemLore = itemMeta.getLore();
if (itemLore.contains(Misc.USEBIND_TAG)) {
return true;
}
}
return false;
}
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore() && isSoulbound(itemStack)) {
List<String> oldLore = itemMeta.getLore();
int loreSize = oldLore.size();
/**
* Checks to see if an item is a chainmail armor piece.
*
* @param is
* Item to check
*
* @return true if the item is chainmail armor, false otherwise
*/
public static boolean isChainmailArmor(final ItemStack is) {
switch (is.getType()) {
case CHAINMAIL_BOOTS:
case CHAINMAIL_CHESTPLATE:
case CHAINMAIL_HELMET:
case CHAINMAIL_LEGGINGS:
return true;
default:
return false;
}
}
if (loreSize <= 2) {
itemMeta.setLore(null);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
/**
* Checks to see if an item is a diamond armor piece.
*
* @param is
* Item to check
*
* @return true if the item is diamond armor, false otherwise
*/
public static boolean isDiamondArmor(final ItemStack is) {
switch (is.getType()) {
case DIAMOND_BOOTS:
case DIAMOND_CHESTPLATE:
case DIAMOND_HELMET:
case DIAMOND_LEGGINGS:
return true;
default:
return false;
}
}
List<String> itemLore = new ArrayList<String>();
itemLore.addAll(oldLore);
int index = StringUtils.getIndexOfSoulbound(itemLore);
if (index == -1){
return null;
}
itemLore.remove(index);
if (index<itemLore.size())
itemLore.remove(index);
/**
* Checks to see if an item is an equipable item.
*
* @param is
* Item to check
*
* @return true if the item is equipable, false otherwise
*/
public static boolean isEquipable(final ItemStack is) {
return isMinecraftArmor(is) || is.getType() == Material.SKULL_ITEM || is.getType() == Material.JACK_O_LANTERN;
}
itemMeta.setLore(itemLore);
}
/**
* Checks to see if an item is a gold armor piece.
*
* @param is
* Item to check
*
* @return true if the item is gold armor, false otherwise
*/
public static boolean isGoldArmor(final ItemStack is) {
switch (is.getType()) {
case GOLD_BOOTS:
case GOLD_CHESTPLATE:
case GOLD_HELMET:
case GOLD_LEGGINGS:
return true;
default:
return false;
}
}
itemStack.setItemMeta(itemMeta);
return itemStack;
}
/**
* Checks to see if an item is an iron armor piece.
*
* @param is
* Item to check
*
* @return true if the item is iron armor, false otherwise
*/
public static boolean isIronArmor(final ItemStack is) {
switch (is.getType()) {
case IRON_BOOTS:
case IRON_CHESTPLATE:
case IRON_HELMET:
case IRON_LEGGINGS:
return true;
default:
return false;
}
}
public static boolean isSoulbound(ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
/**
* Checks to see if an item is a leather armor piece.
*
* @param is
* Item to check
*
* @return true if the item is leather armor, false otherwise
*/
public static boolean isLeatherArmor(final ItemStack is) {
switch (is.getType()) {
case LEATHER_BOOTS:
case LEATHER_CHESTPLATE:
case LEATHER_HELMET:
case LEATHER_LEGGINGS:
return true;
default:
return false;
}
}
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
List<String> itemLore = itemMeta.getLore();
for (String lore : itemLore) {
if (lore.contains(Misc.SOULBOUND_TAG)) {
return true;
}
}
}
return false;
}
/**
* Checks to see if an item is a wearable armor piece.
*
* @param is
* Item to check
*
* @return true if the item is armor, false otherwise
*/
public static boolean isMinecraftArmor(final ItemStack is) {
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is) || isChainmailArmor(is);
}
public static boolean isBindOnPickup(ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
public static boolean isNormalItem(final ItemStack itemStack) {
return !itemStack.hasItemMeta() && !itemStack.getItemMeta().hasLore() || ItemUtils.getItemType(itemStack) == ItemType.NORMAL;
}
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
List<String> itemLore = itemMeta.getLore();
if (itemLore.contains(Misc.PICKUPBIND_TAG)) {
return true;
}
}
return false;
}
public static boolean isSoulbound(final ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
public static boolean isBindOnUse(ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
final ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
final List<String> itemLore = itemMeta.getLore();
for (final String lore : itemLore) {
if (lore.contains(Misc.SOULBOUND_TAG)) {
return true;
}
}
}
return false;
}
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
List<String> itemLore = itemMeta.getLore();
if (itemLore.contains(Misc.USEBIND_TAG)) {
return true;
}
}
return false;
}
public static ItemStack soulbindItem(final Player player, ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
public static boolean isBindOnEquip(ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
if (isSoulbound(itemStack)) {
return itemStack;
}
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
List<String> itemLore = itemMeta.getLore();
if (itemLore.contains(Misc.EQUIPBIND_TAG)) {
return true;
}
}
return false;
}
final SoulbindItemEvent soulbindItemEvent = new SoulbindItemEvent(player, itemStack);
Soulbound.p.getServer().getPluginManager().callEvent(soulbindItemEvent);
itemStack = soulbindItemEvent.getItemStack();
public static boolean isBindedPlayer(Player player, ItemStack itemStack) {
List<String> itemLore = itemStack.getItemMeta().getLore();
if (soulbindItemEvent.isCancelled()) {
return itemStack;
}
return itemLore.contains(player.getName());
}
final ItemMeta itemMeta = itemStack.getItemMeta();
final List<String> itemLore = new ArrayList<String>();
public static boolean isNormalItem(ItemStack itemStack) {
return !itemStack.hasItemMeta() && !itemStack.getItemMeta().hasLore() || ItemUtils.getItemType(itemStack) == ItemType.NORMAL;
}
if (itemMeta.hasLore()) {
final List<String> oldLore = itemMeta.getLore();
oldLore.remove(Misc.EQUIPBIND_TAG);
oldLore.remove(Misc.PICKUPBIND_TAG);
oldLore.remove(Misc.USEBIND_TAG);
itemLore.addAll(oldLore);
}
public static ItemType getItemType(ItemStack itemStack) {
if (itemStack == null) {
return ItemType.NORMAL;
}
else if (isSoulbound(itemStack)) {
return ItemType.SOULBOUND;
}
else if (isBindOnPickup(itemStack)) {
return ItemType.BIND_ON_PICKUP;
}
else if (isBindOnUse(itemStack)) {
return ItemType.BIND_ON_USE;
}
else if (isBindOnEquip(itemStack)) {
return ItemType.BIND_ON_EQUIP;
}
else {
return ItemType.NORMAL;
}
}
itemLore.add(Misc.SOULBOUND_TAG);
/**
* Checks to see if an item is an equipable item.
*
* @param is Item to check
*
* @return true if the item is equipable, false otherwise
*/
public static boolean isEquipable(ItemStack is) {
return isMinecraftArmor(is) || is.getType() == Material.SKULL_ITEM || is.getType() == Material.JACK_O_LANTERN;
}
if (Config.getShowNameInLore()) {
itemLore.add(player.getName());
}
/**
* Checks to see if an item is a wearable armor piece.
*
* @param is Item to check
*
* @return true if the item is armor, false otherwise
*/
public static boolean isMinecraftArmor(ItemStack is) {
return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is) || isChainmailArmor(is);
}
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
/**
* Checks to see if an item is a leather armor piece.
*
* @param is Item to check
*
* @return true if the item is leather armor, false otherwise
*/
public static boolean isLeatherArmor(ItemStack is) {
switch (is.getType()) {
case LEATHER_BOOTS:
case LEATHER_CHESTPLATE:
case LEATHER_HELMET:
case LEATHER_LEGGINGS:
return true;
public static ItemStack unbindItem(final ItemStack itemStack) {
if (itemStack == null) {
return null;
}
default:
return false;
}
}
final ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore() && isSoulbound(itemStack)) {
final List<String> oldLore = itemMeta.getLore();
final int loreSize = oldLore.size();
/**
* Checks to see if an item is a gold armor piece.
*
* @param is Item to check
*
* @return true if the item is gold armor, false otherwise
*/
public static boolean isGoldArmor(ItemStack is) {
switch (is.getType()) {
case GOLD_BOOTS:
case GOLD_CHESTPLATE:
case GOLD_HELMET:
case GOLD_LEGGINGS:
return true;
if (loreSize <= 2) {
itemMeta.setLore(null);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
default:
return false;
}
}
final List<String> itemLore = new ArrayList<String>();
itemLore.addAll(oldLore);
final int index = StringUtils.getIndexOfSoulbound(itemLore);
/**
* Checks to see if an item is an iron armor piece.
*
* @param is Item to check
*
* @return true if the item is iron armor, false otherwise
*/
public static boolean isIronArmor(ItemStack is) {
switch (is.getType()) {
case IRON_BOOTS:
case IRON_CHESTPLATE:
case IRON_HELMET:
case IRON_LEGGINGS:
return true;
if (index == -1) {
return null;
}
default:
return false;
}
}
itemLore.remove(index);
if (index < itemLore.size()) {
itemLore.remove(index);
}
/**
* Checks to see if an item is a diamond armor piece.
*
* @param is Item to check
*
* @return true if the item is diamond armor, false otherwise
*/
public static boolean isDiamondArmor(ItemStack is) {
switch (is.getType()) {
case DIAMOND_BOOTS:
case DIAMOND_CHESTPLATE:
case DIAMOND_HELMET:
case DIAMOND_LEGGINGS:
return true;
itemMeta.setLore(itemLore);
}
default:
return false;
}
}
itemStack.setItemMeta(itemMeta);
return itemStack;
}
/**
* Checks to see if an item is a chainmail armor piece.
*
* @param is Item to check
*
* @return true if the item is chainmail armor, false otherwise
*/
public static boolean isChainmailArmor(ItemStack is) {
switch (is.getType()) {
case CHAINMAIL_BOOTS:
case CHAINMAIL_CHESTPLATE:
case CHAINMAIL_HELMET:
case CHAINMAIL_LEGGINGS:
return true;
default:
return false;
}
}
public enum ItemType {
BIND_ON_EQUIP,
BIND_ON_PICKUP,
BIND_ON_USE,
NORMAL,
SOULBOUND;
}
}

View File

@ -1,23 +0,0 @@
package com.me.tft_02.soulbound.util;
import java.util.logging.Filter;
import java.util.logging.LogRecord;
import com.me.tft_02.soulbound.Soulbound;
public class LogFilter implements Filter {
private final boolean debug;
public LogFilter(final Soulbound plugin) {
// Doing a config loading lite here, because we can't depend on the config loader to have loaded before any debug messages are sent
debug = plugin.getConfig().getBoolean("General.Verbose_Logging");
}
@Override
public boolean isLoggable(final LogRecord record) {
if (record.getMessage().contains("[Debug]") && !debug) {
return false;
}
return true;
}
}

View File

@ -6,35 +6,26 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
public class Permissions {
public static boolean keepOnDeath(Permissible permissible) {
return permissible.hasPermission("soulbound.items.keep_on_death");
}
public static boolean deleteOnDeath(Permissible permissible) {
public static boolean deleteOnDeath(final Permissible permissible) {
return permissible.hasPermission("soulbound.items.delete_on_death");
}
public static boolean pickupBypass(Permissible permissible) {
return permissible.hasPermission("soulbound.pickup.bypass");
}
public static boolean updateCheck(Permissible permissible) {
return permissible.hasPermission("soulbound.updatecheck");
}
public static int getSoulbindMaximum(Player player) {
String match = "soulbound.maximum_allowed.";
public static int getSoulbindMaximum(final Player player) {
final String match = "soulbound.maximum_allowed.";
int amount = -1;
for (PermissionAttachmentInfo permission : player
.getEffectivePermissions()) {
if (permission.getPermission().startsWith(match)
&& permission.getValue()) {
amount = Integer.parseInt(permission.getPermission().split(
"[.]")[2]);
for (final PermissionAttachmentInfo permission : player.getEffectivePermissions()) {
if (permission.getPermission().startsWith(match) && permission.getValue()) {
amount = Integer.parseInt(permission.getPermission().split("[.]")[2]);
}
}
return amount;
}
public static boolean keepOnDeath(final Permissible permissible) {
return permissible.hasPermission("soulbound.items.keep_on_death");
}
public static boolean pickupBypass(final Permissible permissible) {
return permissible.hasPermission("soulbound.pickup.bypass");
}
}

View File

@ -4,14 +4,14 @@ import java.util.List;
public class StringUtils {
public static int getIndexOfSoulbound(List<String> itemLore) {
int index = -1;
public static int getIndexOfSoulbound(final List<String> itemLore) {
final int index = -1;
for (String line : itemLore) {
if (line.contains(Misc.SOULBOUND_TAG)) {
return itemLore.indexOf(line);
}
}
return index;
}
for (final String line : itemLore) {
if (line.contains(Misc.SOULBOUND_TAG)) {
return itemLore.indexOf(line);
}
}
return index;
}
}

View File

@ -1,40 +1,12 @@
#
# Soulbound configuration
# Last updated on ${project.version}-b${BUILD_NUMBER}
#
#####
#
# Settings for Soulbound in general
###
General:
# Allow Soulbound to report on basic anonymous usage
Stats_Tracking: true
# Allow Soulbound to check if a new version is available
Update_Check: true
Prefer_Beta: false
# Should Soulbound print out debug messages?
Verbose_Logging: false
# Should Soulbound over-write configs to update, or make new ones ending in .new?
Config_Update_Overwrite: true
Stats_Tracking: true
Config_Update_Overwrite: true
Soulbound:
Show_Name_In_Lore: true
Feedback_Messages_Enabled: true
Prevent_Item_Drop: false
Delete_On_Drop: false
Allow_Item_Storing: true
Infinite_Durability: false
Blocked_Commands:
/blockedcommand
Commands_Bind_When_Used:
/enchant
Dependency_Plugins:
EpicBossRecoded:
BindOnPickup: true
BindOnUse: false
BindOnEquip: false
Show_Name_In_Lore: true
Feedback_Messages_Enabled: true
Prevent_Item_Drop: false
Delete_On_Drop: false
Allow_Item_Storing: true
Infinite_Durability: false
Blocked_Commands: /blockedcommand
Commands_Bind_When_Used: /enchant