1
0
mirror of https://e.coding.net/circlecloud/Soulbound.git synced 2025-11-24 21:36:20 +00:00

using PluginHelper and update...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092
2015-09-28 21:06:34 +08:00
parent 5ab2ac354c
commit 37963894f3
42 changed files with 150 additions and 513 deletions

View File

@@ -0,0 +1,138 @@
package com.me.tft_02.soulbound;
import java.io.File;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.me.tft_02.soulbound.commands.BindCommand;
import com.me.tft_02.soulbound.commands.BindOnEquipCommand;
import com.me.tft_02.soulbound.commands.BindOnPickupCommand;
import com.me.tft_02.soulbound.commands.BindOnUseCommand;
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.hooks.EpicBossRecodedListener;
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;
public class Soulbound extends JavaPlugin {
/* File Paths */
private static String mainDirectory;
public static Soulbound p;
// Jar Stuff
public static File soulbound;
// Checks for hooking into other plugins
public static boolean epicBossRecodedEnabled = false;
public static boolean loreLocksEnabled = false;
FileConfig msgcfg;
FileConfig config;
// Update Check
private boolean updateAvailable;
public static String getMainDirectory() {
return mainDirectory;
}
public void debug(final String message) {
getLogger().info("[Debug] " + message);
}
@Override
public FileConfiguration getConfig() {
return config;
}
public String getlang(final String type) {
return this.getmessage("Message." + type);
}
public String getmessage(final String path) {
final String message = msgcfg.getMessage(path);
return message;
}
public boolean isUpdateAvailable() {
return updateAvailable;
}
/**
* Run things on enable.
*/
@Override
public void onEnable() {
p = this;
getLogger().setFilter(new LogFilter(this));
setupFilePaths();
loadConfigFiles();
setupEpicBossRecoded();
registerEvents();
getCommand("soulbound").setExecutor(new SoulboundCommand());
getCommand("bind").setExecutor(new BindCommand());
getCommand("bindonpickup").setExecutor(new BindOnPickupCommand());
getCommand("bindonuse").setExecutor(new BindOnUseCommand());
getCommand("bindonequip").setExecutor(new BindOnEquipCommand());
getCommand("unbind").setExecutor(new UnbindCommand());
new VersionChecker(this);
}
@Override
public void onLoad() {
msgcfg = new FileConfig(this, "message.yml");
config = new FileConfig(this);
}
@Override
public void reloadConfig() {
msgcfg.reload();
config.reload();
}
private void loadConfigFiles() {
Config.getInstance();
ItemsConfig.getInstance();
}
private void registerEvents() {
final PluginManager pm = getServer().getPluginManager();
pm.registerEvents(new PlayerListener(), this);
pm.registerEvents(new InventoryListener(), this);
pm.registerEvents(new EntityListener(), this);
pm.registerEvents(new BlockListener(), this);
}
private void setupEpicBossRecoded() {
if (getServer().getPluginManager().isPluginEnabled("EpicBossRecoded")) {
epicBossRecodedEnabled = true;
debug("EpicBossRecoded found!");
getServer().getPluginManager().registerEvents(new EpicBossRecodedListener(), this);
}
}
/**
* Setup the various storage file paths
*/
private void setupFilePaths() {
soulbound = getFile();
mainDirectory = getDataFolder().getPath() + File.separator;
}
}

View File

@@ -0,0 +1,116 @@
package com.me.tft_02.soulbound.api;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.util.ItemUtils;
public final class ItemAPI {
private ItemAPI() {}
/**
* Check if a Player is binded to an ItemStack.
* </br>
* This function is designed for API usage.
*
* @param player The Player to check
* @param itemStack The ItemStack to check
*
* @return true or false
*/
public static boolean isSoulbindedPlayer(Player player, ItemStack itemStack) {
return ItemUtils.isBindedPlayer(player, itemStack);
}
/**
* Soulbind an ItemStack to a Player.
* </br>
* This function is designed for API usage.
*
* @param player The Player to bind the item to
* @param itemStack The ItemStack to bind
*
* @return the soulbound ItemStack
*/
public static ItemStack soulbindItem(Player player, ItemStack itemStack) {
return ItemUtils.soulbindItem(player, itemStack);
}
/**
* Check if an itemstack is Soulbound.
* </br>
* This function is designed for API usage.
*
* @param itemStack The itemstack to check
*
* @return true or false
*/
public static boolean isSoulbound(ItemStack itemStack) {
return ItemUtils.isSoulbound(itemStack);
}
/**
* Mark an itemstack as Bind on Pickup
* </br>
* This function is designed for API usage.
*
* @param itemStack The itemstack to mark as Bind on Pickup
*
* @return the marked itemstack
*/
public static ItemStack bindOnPickupItem(ItemStack itemStack) {
return ItemUtils.bopItem(itemStack);
}
/**
* Check if an itemstack is Bind on Pickup.
* </br>
* This function is designed for API usage.
*
* @param itemStack The itemstack to check
*
* @return true or false
*/
public static boolean isBindOnPickup(ItemStack itemStack) {
return ItemUtils.isBindOnPickup(itemStack);
}
/**
* Mark an itemstack as Bind on Use
* </br>
* This function is designed for API usage.
*
* @param itemStack The itemstack to mark as Bind on Use
*
* @return the marked itemstack
*/
public static ItemStack bindOnUseItem(ItemStack itemStack) {
return ItemUtils.bouItem(itemStack);
}
/**
* Mark an itemstack as Bind on Equip
* </br>
* This function is designed for API usage.
*
* @param itemStack The itemstack to mark as Bind on Equip
*
* @return the marked itemstack
*/
public static ItemStack bindOnEquipItem(ItemStack itemStack) {
return ItemUtils.boeItem(itemStack);
}
/**
* Get the Soulbound type of an itemstack.
* </br>
* This function is designed for API usage.
*
* @param itemStack The itemstack to check
*
* @return the Bind type
*/
public static String getItemType(ItemStack itemStack) {
return ItemUtils.getItemType(itemStack).toString();
}
}

View File

@@ -0,0 +1,90 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.Soulbound;
import com.me.tft_02.soulbound.config.Config;
import com.me.tft_02.soulbound.util.CommandUtils;
import com.me.tft_02.soulbound.util.ItemUtils;
public class BindCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!sender.hasPermission("soulbound.commands.bind")) {
return false;
}
boolean bindFullInventory = false;
Player player = (Player) sender;
Player target;
switch (args.length) {
case 1:
target = Soulbound.p.getServer().getPlayerExact(args[0]);
if (CommandUtils.isOffline(sender, target)) {
return true;
}
break;
case 2:
if (!args[1].equalsIgnoreCase("inventory")) {
sender.sendMessage(Soulbound.p.getlang("BIND_INVENTORY"));
return true;
}
bindFullInventory = true;
target = Soulbound.p.getServer().getPlayerExact(args[0]);
if (CommandUtils.isOffline(sender, target)) {
return true;
}
break;
default:
target = player;
}
if (bindFullInventory) {
return handleBindFullInventory(player, target);
}
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || ItemUtils.isSoulbound(itemInHand)) {
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND"));
return false;
}
ItemUtils.soulbindItem(target, itemInHand);
if (ItemUtils.isSoulbound(itemInHand) && Config.getInstance().getFeedbackEnabled()) {
sender.sendMessage(Soulbound.p.getlang("BINDED").replace("%target%", target.getName()));
}
return true;
}
private boolean handleBindFullInventory(Player player, Player target) {
for (ItemStack itemStack : player.getInventory().getContents()) {
if (itemStack != null && itemStack.getType() != Material.AIR) {
ItemUtils.soulbindItem(target, itemStack);
}
}
if (Config.getInstance().getFeedbackEnabled()) {
player.sendMessage(Soulbound.p.getlang("BIND_FULL_INEVNTORY")
.replace("%player%", player.getName()).replace("%target%", target.getName()));
}
return true;
}
}

View File

@@ -0,0 +1,51 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.Soulbound;
import com.me.tft_02.soulbound.util.CommandUtils;
import com.me.tft_02.soulbound.util.ItemUtils;
public class BindOnEquipCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (!player.hasPermission("soulbound.commands.bindonequip")) {
return false;
}
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || ItemUtils.isSoulbound(itemInHand)) {
player.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND"));
return false;
}
ItemUtils.unbindItem(itemInHand);
ItemUtils.boeItem(itemInHand);
if (ItemUtils.isBindOnEquip(itemInHand)) {
player.sendMessage(Soulbound.p.getlang("BIND_ON_EQUIP"));
}
else {
player.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND_ON_EQUIP"));
}
return true;
default:
return false;
}
}
}

View File

@@ -0,0 +1,45 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.Soulbound;
import com.me.tft_02.soulbound.util.CommandUtils;
import com.me.tft_02.soulbound.util.ItemUtils;
public class BindOnPickupCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (!player.hasPermission("soulbound.commands.bindonpickup")) {
return false;
}
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || ItemUtils.isSoulbound(itemInHand)) {
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND_ON_PICKUP"));
return false;
}
ItemUtils.unbindItem(itemInHand);
ItemUtils.bopItem(itemInHand);
sender.sendMessage(Soulbound.p.getlang("BIND_ON_PICKUP"));
return true;
default:
return false;
}
}
}

View File

@@ -0,0 +1,44 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.Soulbound;
import com.me.tft_02.soulbound.util.CommandUtils;
import com.me.tft_02.soulbound.util.ItemUtils;
public class BindOnUseCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (!player.hasPermission("soulbound.commands.bindonuse")) {
return false;
}
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || ItemUtils.isSoulbound(itemInHand)) {
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND_ON_USE"));
return false;
}
ItemUtils.unbindItem(itemInHand);
ItemUtils.bouItem(itemInHand);
sender.sendMessage(Soulbound.p.getlang("BIND_ON_USE"));
return true;
default:
return false;
}
}
}

View File

@@ -0,0 +1,105 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.me.tft_02.soulbound.Soulbound;
public class SoulboundCommand implements CommandExecutor {
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
switch (args.length) {
case 0:
sender.sendMessage(Soulbound.p.getlang("VERSION") + Soulbound.p.getDescription().getVersion());
return printUsage(sender);
case 1:
if (args[0].equalsIgnoreCase("reload")) {
return reloadConfiguration(sender);
}
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
getHelpPage(1, sender);
return true;
}
default:
if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
return helpPages(sender, args);
}
return false;
}
}
private void getHelpPage(final int page, final CommandSender sender) {
final int maxPages = 2;
final int nextPage = page + 1;
if (page > maxPages) {
sender.sendMessage(Soulbound.p.getlang("PAGE_NOT_EXIST".replace("%maxPages%", maxPages + "")));
return;
}
sender.sendMessage(Soulbound.p.getlang("HELP_TITLE").replace("%page%", page + "").replace("%maxPages%", maxPages + ""));
if (page == 1) {
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_1"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_2"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_3"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_4"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_4_1"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_5"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_5_1"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_6"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_6_1"));
}
if (page == 2) {
sender.sendMessage(Soulbound.p.getlang("CMD"));
if (sender.hasPermission("soulbound.commands.bind")) {
sender.sendMessage(Soulbound.p.getlang("CMDVERSION"));
}
if (sender.hasPermission("soulbound.commands.bind")) {
sender.sendMessage(Soulbound.p.getlang("CMD_BIND"));
sender.sendMessage(Soulbound.p.getlang("CMD_BIND_FULL_INVENTORY"));
}
if (sender.hasPermission("soulbound.commands.bindonpickup")) {
sender.sendMessage(Soulbound.p.getlang("CMD_BIND_ON_PICKUP"));
}
if (sender.hasPermission("soulbound.commands.bindonuse")) {
sender.sendMessage(Soulbound.p.getlang("CMD_BIND_ON_USE"));
}
if (sender.hasPermission("soulbound.commands.bindonequip")) {
sender.sendMessage(Soulbound.p.getlang("CMD_BIND_ON_EQUIP"));
}
if (sender.hasPermission("soulbound.commands.unbind")) {
sender.sendMessage(Soulbound.p.getlang("CMD_UNBIND"));
}
}
if (nextPage <= maxPages) {
sender.sendMessage(Soulbound.p.getlang("CMD_NEXT").replace("%nextPage%", nextPage + ""));
}
}
private boolean helpPages(final CommandSender sender, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_USE_ON_CONSOLE"));
return false;
}
if (args.length >= 2 && Integer.parseInt(args[1]) > 0) {
getHelpPage(Integer.parseInt(args[1]), sender);
return true;
}
return false;
}
private boolean printUsage(final CommandSender sender) {
sender.sendMessage(Soulbound.p.getlang("CMD_USE"));
return false;
}
private boolean reloadConfiguration(final CommandSender sender) {
if (sender instanceof Player && !sender.hasPermission("soulbound.commands.reload")) {
return false;
}
Soulbound.p.reloadConfig();
sender.sendMessage(Soulbound.p.getlang("RELOAD"));
return false;
}
}

View File

@@ -0,0 +1,46 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.Soulbound;
import com.me.tft_02.soulbound.util.CommandUtils;
import com.me.tft_02.soulbound.util.ItemUtils;
public class UnbindCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
switch (args.length) {
case 0:
Player player = (Player) sender;
if (!player.hasPermission("soulbound.commands.unbind")) {
return false;
}
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || !ItemUtils.isSoulbound(itemInHand)) {
player.sendMessage(Soulbound.p.getlang("CAN_NOT_UNBIND"));
return false;
}
if (ItemUtils.unbindItem(itemInHand)==null ){
player.sendMessage(Soulbound.p.getlang("CAN_NOT_UNBIND"));
return false;
}
player.sendMessage(Soulbound.p.getlang("UNBINDED"));
return true;
default:
return false;
}
}
}

View File

@@ -0,0 +1,119 @@
package com.me.tft_02.soulbound.config;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
public AutoUpdateConfigLoader(String relativePath, String fileName) {
super(relativePath, fileName);
}
public AutoUpdateConfigLoader(String fileName) {
super(fileName);
}
@SuppressWarnings("deprecation")
@Override
protected void loadFile() {
super.loadFile();
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
Set<String> configKeys = config.getKeys(true);
Set<String> internalConfigKeys = internalConfig.getKeys(true);
boolean needSave = false;
Set<String> oldKeys = new HashSet<String>(configKeys);
oldKeys.removeAll(internalConfigKeys);
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
newKeys.removeAll(configKeys);
// Don't need a re-save if we have old keys sticking around?
// Would be less saving, but less... correct?
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
needSave = true;
}
for (String key : oldKeys) {
plugin.debug("Removing unused key: " + key);
config.set(key, null);
}
for (String key : newKeys) {
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));
config.set(key, internalConfig.get(key));
}
if (needSave) {
// Get Bukkit's version of an acceptable config with new keys, and no old keys
String output = config.saveToString();
// Convert to the superior 4 space indentation
output = output.replace(" ", " ");
// Rip out Bukkit's attempt to save comments at the top of the file
while (output.indexOf('#') != -1) {
output = output.substring(output.indexOf('\n', output.indexOf('#')) + 1);
}
// Read the internal config to get comments, then put them in the new one
try {
// Read internal
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
HashMap<String, String> comments = new HashMap<String, String>();
String temp = "";
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("#")) {
temp += line + "\n";
}
else if (line.contains(":")) {
line = line.substring(0, line.indexOf(":") + 1);
if (!temp.isEmpty()) {
comments.put(line, temp);
temp = "";
}
}
}
// Dump to the new one
for (String key : comments.keySet()) {
if (output.indexOf(key) != -1) {
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
}
}
}
catch (Exception e) {
e.printStackTrace();
}
// Save it
try {
String saveName = fileName;
// At this stage we cannot guarantee that Config has been loaded, so we do the check directly here
if (!plugin.getConfig().getBoolean("General.Config_Update_Overwrite", true)) {
saveName += ".new";
}
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), saveName)));
writer.write(output);
writer.flush();
writer.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@@ -0,0 +1,89 @@
package com.me.tft_02.soulbound.config;
import java.util.ArrayList;
import java.util.List;
public class Config extends AutoUpdateConfigLoader {
private static Config instance;
private Config() {
super("config.yml");
}
public static Config getInstance() {
if (instance == null) {
instance = new Config();
}
return instance;
}
@Override
protected void loadKeys() {}
/* @formatter:off */
/* GENERAL SETTINGS */
// public String getLocale() { return config.getString("General.Locale", "en_us"); }
// public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
/* @formatter:on */
/* SOULBOUND SETTINGS */
public boolean getShowNameInLore() { return config.getBoolean("Soulbound.Show_Name_In_Lore", true); }
public boolean getFeedbackEnabled() { return config.getBoolean("Soulbound.Feedback_Messages_Enabled", true); }
public boolean getPreventItemDrop() { return config.getBoolean("Soulbound.Prevent_Item_Drop", false); }
public boolean getDeleteOnDrop() { return config.getBoolean("Soulbound.Delete_On_Drop", false); }
public boolean getAllowItemStoring() { return config.getBoolean("Soulbound.Allow_Item_Storing", true); }
public boolean getInfiniteDurability() { return config.getBoolean("Soulbound.Infinite_Durability", false); }
public List<String> getBlockedCommands() { return config.getStringList("Soulbound.Blocked_Commands"); }
public List<String> getBindCommands() { return config.getStringList("Soulbound.Commands_Bind_When_Used"); }
// EpicBossRecoded config settings
public boolean getEBRBindOnPickup() { return config.getBoolean("Dependency_Plugins.EpicBossRecoded.BindOnPickup"); }
public boolean getEBRBindOnEquip() { return config.getBoolean("Dependency_Plugins.EpicBossRecoded.BindOnEquip"); }
public boolean getEBRBindOnUse() { return config.getBoolean("Dependency_Plugins.EpicBossRecoded.BindOnUse");}
// DiabloDrops config settings
public List<String> getDiabloDropsBindOnPickupTiers() { return getDiabloDropsItemTiers("BindOnPickup");}
public List<String> getDiabloDropsBindOnUseTiers() { return getDiabloDropsItemTiers("BindOnUse");}
public List<String> getDiabloDropsBindOnEquipTiers() { return getDiabloDropsItemTiers("BindOnEquip"); }
public List<String> getDiabloDropsItemTiers(String bindType) {
String[] tiersString = config.getString("Dependency_Plugins.DiabloDrops." + bindType).replaceAll(" ", "").split("[,]");
List<String> tiers = new ArrayList<String>();
for (String tier : tiersString) {
tiers.add(tier);
}
return tiers;
}
// LoreLocks config settings
public boolean getLoreLocksBindKeys() { return config.getBoolean("Dependency_Plugins.LoreLocks.Bind_Keys"); }
// MythicDrops config settings
public List<String> getMythicDropsBindOnPickupTiers() { return getMythicDropsItemTiers("BindOnPickup"); }
public List<String> getMythicDropsBindOnUseTiers() { return getMythicDropsItemTiers("BindOnUse"); }
public List<String> getMythicDropsBindOnEquipTiers() { return getMythicDropsItemTiers("BindOnEquip"); }
public List<String> getMythicDropsItemTiers(String bindType) {
String[] tiersString = config.getString("Dependency_Plugins.MythicDrops." + bindType).replaceAll(" ", "").split("[,]");
List<String> tiers = new ArrayList<String>();
for (String tier : tiersString) {
tiers.add(tier);
}
return tiers;
}
}

View File

@@ -0,0 +1,93 @@
package com.me.tft_02.soulbound.config;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.me.tft_02.soulbound.Soulbound;
public abstract class ConfigLoader {
protected static final Soulbound plugin = Soulbound.p;
protected String fileName;
protected File configFile;
protected FileConfiguration config;
public ConfigLoader(String relativePath, String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), relativePath + File.separator + fileName);
loadFile();
}
public ConfigLoader(String fileName) {
this.fileName = fileName;
configFile = new File(plugin.getDataFolder(), fileName);
loadFile();
}
protected void loadFile() {
if (!configFile.exists()) {
plugin.debug("Creating Soulbound " + fileName + " File...");
createFile();
}
else {
plugin.debug("Loading Soulbound " + fileName + " File...");
}
config = YamlConfiguration.loadConfiguration(configFile);
}
protected abstract void loadKeys();
protected void createFile() {
configFile.getParentFile().mkdirs();
InputStream inputStream = plugin.getResource(fileName);
if (inputStream == null) {
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
return;
}
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(configFile);
int read;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
finally {
if (outputStream != null) {
try {
outputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
try {
inputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
}

View File

@@ -0,0 +1,151 @@
package com.me.tft_02.soulbound.config;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import com.me.tft_02.soulbound.datatypes.ActionType;
import com.me.tft_02.soulbound.datatypes.SoulbindItem;
public class ItemsConfig extends ConfigLoader {
private static ItemsConfig instance;
private List<SoulbindItem> soulbindOnCraft = new ArrayList<SoulbindItem>();
private List<SoulbindItem> soulbindOnOpenChest = new ArrayList<SoulbindItem>();
private List<SoulbindItem> soulbindOnPickupItem = new ArrayList<SoulbindItem>();
private List<SoulbindItem> soulbindOnDrop = new ArrayList<SoulbindItem>();
private List<SoulbindItem> soulbindOnRespawn = new ArrayList<SoulbindItem>();
private List<SoulbindItem> soulbindOnKit = new ArrayList<SoulbindItem>();
public ItemsConfig() {
super("items.yml");
loadKeys();
}
public static ItemsConfig getInstance() {
if (instance == null) {
instance = new ItemsConfig();
}
return instance;
}
@SuppressWarnings("deprecation")
@Override
protected void loadKeys() {
ConfigurationSection configurationSection = config.getConfigurationSection("Items");
if (configurationSection == null) {
return;
}
Set<String> itemConfigSet = configurationSection.getKeys(false);
for (String itemName : itemConfigSet) {
String[] itemInfo = itemName.split("[|]");
Material itemMaterial = Material.matchMaterial(itemInfo[0]);
if (itemMaterial == null) {
plugin.getLogger().warning(
"Invalid material name. This item will be skipped. - " + itemInfo[0]);
continue;
}
byte itemData = (itemInfo.length == 2) ? Byte.valueOf(itemInfo[1]) : 0;
MaterialData itemMaterialData = new MaterialData(itemMaterial, itemData);
List<String> lore = new ArrayList<String>();
if (config.contains("Items." + itemName + ".Lore")) {
for (String loreEntry : config.getStringList("Items." + itemName + ".Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', loreEntry));
}
}
String name = null;
if (config.contains("Items." + itemName + ".Name")) {
name = ChatColor.translateAlternateColorCodes('&',
config.getString("Items." + itemName + ".Name"));
}
SoulbindItem soulbindItem = new SoulbindItem(itemMaterialData, name, lore);
List<String> actions = config.getStringList("Items." + itemName + ".Actions");
for (ActionType actionType : ActionType.values()) {
if (actions.contains(actionType.toString())) {
addSoulbindItem(actionType, soulbindItem);
}
}
}
}
private void addSoulbindItem(ActionType actionType, SoulbindItem soulbindItem) {
switch (actionType) {
case CRAFT:
soulbindOnCraft.add(soulbindItem);
return;
case OPEN_CHEST:
soulbindOnOpenChest.add(soulbindItem);
return;
case PICKUP_ITEM:
soulbindOnPickupItem.add(soulbindItem);
return;
case DROP_ITEM:
soulbindOnDrop.add(soulbindItem);
return;
case RESPAWN:
soulbindOnRespawn.add(soulbindItem);
return;
case KIT:
soulbindOnKit.add(soulbindItem);
return;
}
}
public List<SoulbindItem> getSoulbindItems(ActionType actionType) {
switch (actionType) {
case CRAFT:
return soulbindOnCraft;
case OPEN_CHEST:
return soulbindOnOpenChest;
case PICKUP_ITEM:
return soulbindOnPickupItem;
case DROP_ITEM:
return soulbindOnDrop;
case RESPAWN:
return soulbindOnRespawn;
case KIT:
return soulbindOnKit;
default:
return null;
}
}
public boolean isActionItem(ItemStack itemStack, ActionType actionType) {
for (SoulbindItem soulbindItem : getSoulbindItems(actionType)) {
if (itemStack.getData().equals(soulbindItem.getMaterialData())) {
if (itemStack.hasItemMeta()) {
ItemMeta itemMeta = itemStack.getItemMeta();
if (soulbindItem.getName() != null)
if (itemMeta.getDisplayName().contains(soulbindItem.getName()))
if (soulbindItem.getLore() != null && !soulbindItem.getLore().isEmpty())
if (itemMeta.hasLore()
&& itemMeta.getLore().containsAll(soulbindItem.getLore()))
return true;
}
}
}
return false;
}
}

View File

@@ -0,0 +1,10 @@
package com.me.tft_02.soulbound.datatypes;
public enum ActionType {
CRAFT,
OPEN_CHEST,
PICKUP_ITEM,
DROP_ITEM,
RESPAWN,
KIT;
};

View File

@@ -0,0 +1,34 @@
package com.me.tft_02.soulbound.datatypes;
import java.util.List;
import org.bukkit.material.MaterialData;
public class SoulbindItem {
private MaterialData materialData;
private String name;
private List<String> lore;
public SoulbindItem(MaterialData materialData, String name, List<String> lore) {
this.materialData = materialData;
this.name = name;
this.lore = lore;
}
public MaterialData getMaterialData() {
return materialData;
}
public List<String> getLore() {
return lore;
}
public String getName() {
return name;
}
@Override
public String toString() {
return materialData.toString() + " " + name.toString() + " " + lore.toString();
}
}

View File

@@ -0,0 +1,54 @@
package com.me.tft_02.soulbound.events;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.inventory.ItemStack;
public class SoulbindItemEvent extends PlayerEvent implements Cancellable {
private ItemStack itemStack;
private boolean cancelled;
public SoulbindItemEvent(Player player, ItemStack itemStack) {
super(player);
this.setItemStack(itemStack);
this.cancelled = false;
}
/**
* @return The itemStack being soulbound
*/
public ItemStack getItemStack() {
return itemStack;
}
/**
* @return Set the itemStack being soulbound
*/
public void setItemStack(ItemStack itemStack) {
this.itemStack = itemStack;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -0,0 +1,40 @@
package com.me.tft_02.soulbound.hooks;
//import me.ThaH3lper.com.Api.BossDeathEvent;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.config.Config;
import com.me.tft_02.soulbound.util.ItemUtils;
public class EpicBossRecodedListener implements Listener {
/**
* Check BossDeathEvent events.
*
* @param event The event to check
*/
/* @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBossDeath(BossDeathEvent event) {
if (event.getDrops().isEmpty()) {
return;
}
for (ItemStack itemStack : event.getDrops()) {
handleEpicBossItems(itemStack);
}
}
*/
public void handleEpicBossItems(ItemStack itemStack) {
if (Config.getInstance().getEBRBindOnEquip() && ItemUtils.isEquipable(itemStack)) {
ItemUtils.boeItem(itemStack);
}
else if (Config.getInstance().getEBRBindOnPickup()) {
ItemUtils.bopItem(itemStack);
}
else if (Config.getInstance().getEBRBindOnUse()) {
ItemUtils.bouItem(itemStack);
}
}
}

View File

@@ -0,0 +1,19 @@
package com.me.tft_02.soulbound.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.util.DurabilityUtils;
public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
ItemStack itemStack = event.getPlayer().getItemInHand();
DurabilityUtils.handleInfiniteDurability(itemStack);
}
}

View File

@@ -0,0 +1,80 @@
package com.me.tft_02.soulbound.listeners;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.util.DurabilityUtils;
public class EntityListener implements Listener {
/**
* Check EntityDamageByEntityEvent events.
*
* @param event The event to check
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityDeath(EntityDamageByEntityEvent event) {
if (event.getDamage() == 0 || event.getEntity().isDead()) {
return;
}
if (event.getEntity() instanceof LivingEntity) {
combatChecks(event);
}
}
/**
* Apply combat modifiers
*
* @param event The event to run the combat checks on.
*/
void combatChecks(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
EntityType damagerType = damager.getType();
switch (damagerType) {
case PLAYER:
Player attacker = (Player) event.getDamager();
ItemStack itemInHand = attacker.getItemInHand();
DurabilityUtils.handleInfiniteDurability(itemInHand);
default:
return;
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
private void onEntityShootBow(EntityShootBowEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
DurabilityUtils.handleInfiniteDurability(((Player) entity).getItemInHand());
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
private void onEntityDamage(EntityDamageEvent event) {
if (event.getDamage() == 0 || event.getEntity().isDead()) {
return;
}
Entity entity = event.getEntity();
if (entity instanceof Player) {
Player player = (Player) entity;
for (ItemStack itemStack : player.getInventory().getArmorContents()) {
DurabilityUtils.handleInfiniteDurability(itemStack);
}
}
}
}

View File

@@ -0,0 +1,179 @@
package com.me.tft_02.soulbound.listeners;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.Soulbound;
import com.me.tft_02.soulbound.config.Config;
import com.me.tft_02.soulbound.config.ItemsConfig;
import com.me.tft_02.soulbound.datatypes.ActionType;
import com.me.tft_02.soulbound.runnables.UpdateArmorTask;
import com.me.tft_02.soulbound.util.ItemUtils;
import com.me.tft_02.soulbound.util.ItemUtils.ItemType;
import com.me.tft_02.soulbound.util.Permissions;
public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onInventoryClick(InventoryClickEvent event) {
HumanEntity entity = event.getWhoClicked();
ItemStack itemStack = event.getCurrentItem();
SlotType slotType = event.getSlotType();
InventoryType inventoryType = event.getInventory().getType();
if (inventoryType == null) {
return;
}
if (itemStack == null) {
return;
}
if (entity instanceof Player) {
Player player = (Player) entity;
switch (slotType) {
case ARMOR:
new UpdateArmorTask(player).runTaskLater(Soulbound.p, 2);
return;
case CONTAINER:
ItemType itemType = ItemUtils.getItemType(itemStack);
switch (itemType) {
case BIND_ON_PICKUP:
ItemUtils.soulbindItem(player, itemStack);
return;
default:
return;
}
default:
if (ItemUtils.isEquipable(itemStack) && event.isShiftClick()) {
new UpdateArmorTask(player).runTaskLater(Soulbound.p, 2);
return;
}
break;
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClickEvent(InventoryClickEvent event) {
HumanEntity entity = event.getWhoClicked();
if (!(entity instanceof Player)) {
return;
}
Player player = (Player) entity;
ItemStack itemStack = event.getCurrentItem();
InventoryType inventoryType = event.getInventory().getType();
if (inventoryType == null) {
return;
}
ItemType itemType = ItemUtils.getItemType(itemStack);
if (itemType != ItemType.SOULBOUND) {
return;
}
if (!Config.getInstance().getAllowItemStoring() && !(inventoryType == InventoryType.CRAFTING)) {
event.setCancelled(true);
}
if (ItemUtils.isBindedPlayer(player, itemStack) || Permissions.pickupBypass(player)) {
return;
}
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryMoveEvent(InventoryMoveItemEvent event) {
ItemStack itemStack = event.getItem();
ItemType itemType = ItemUtils.getItemType(itemStack);
if (itemType == ItemType.SOULBOUND) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryPickupItemEvent(InventoryPickupItemEvent event) {
ItemStack itemStack = event.getItem().getItemStack();
ItemType itemType = ItemUtils.getItemType(itemStack);
if (itemType == ItemType.SOULBOUND) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
HumanEntity humanEntity = event.getPlayer();
Inventory inventory = event.getInventory();
if (!(humanEntity instanceof Player)) {
return;
}
Player player = (Player) humanEntity;
for (ItemStack itemStack : inventory.getContents()) {
if (itemStack != null && ItemsConfig.getInstance().isActionItem(itemStack, ActionType.OPEN_CHEST)) {
ItemUtils.soulbindItem(player, itemStack);
}
}
}
/**
* Check CraftItemEvent events.
*
* @param event The event to check
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onCraftItem(CraftItemEvent event) {
HumanEntity humanEntity = event.getWhoClicked();
if (!(humanEntity instanceof Player)) {
return;
}
Player player = (Player) humanEntity;
ItemStack itemStack = event.getRecipe().getResult();
if (ItemsConfig.getInstance().isActionItem(itemStack, ActionType.CRAFT)) {
event.getInventory().setResult(ItemUtils.soulbindItem(player, itemStack));
}
}
/**
* Check EnchantItemEvent events.
*
* @param event The event to check
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onEnchantItem(EnchantItemEvent event) {
Player player = event.getEnchanter();
ItemStack itemStack = event.getItem();
if (ItemUtils.isBindOnUse(itemStack)) {
ItemUtils.soulbindItem(player, itemStack);
return;
}
}
}

View File

@@ -0,0 +1,297 @@
package com.me.tft_02.soulbound.listeners;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerShearEntityEvent;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.Soulbound;
import com.me.tft_02.soulbound.config.Config;
import com.me.tft_02.soulbound.config.ItemsConfig;
import com.me.tft_02.soulbound.datatypes.ActionType;
import com.me.tft_02.soulbound.runnables.SoulbindInventoryTask;
import com.me.tft_02.soulbound.runnables.UpdateArmorTask;
import com.me.tft_02.soulbound.runnables.UpdateInventoryTask;
import com.me.tft_02.soulbound.util.CommandUtils;
import com.me.tft_02.soulbound.util.DurabilityUtils;
import com.me.tft_02.soulbound.util.ItemUtils;
import com.me.tft_02.soulbound.util.Permissions;
import com.me.tft_02.soulbound.util.PlayerData;
public class PlayerListener implements Listener {
@EventHandler(
priority = EventPriority.LOWEST,
ignoreCancelled = true)
private void onItemPickup(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
Item item = event.getItem();
ItemStack itemStack = item.getItemStack();
if (ItemUtils.isSoulbound(itemStack) && !ItemUtils.isBindedPlayer(player, itemStack)) {
if (Permissions.pickupBypass(player)) {
return;
}
event.setCancelled(true);
return;
}
if (ItemUtils.isBindOnPickup(itemStack)) {
ItemUtils.soulbindItem(player, itemStack);
return;
}
if (ItemsConfig.getInstance().isActionItem(itemStack, ActionType.PICKUP_ITEM)) {
ItemUtils.soulbindItem(player, itemStack);
return;
}
}
@EventHandler(
priority = EventPriority.HIGHEST,
ignoreCancelled = true)
private void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
Item item = event.getItemDrop();
ItemStack itemStack = item.getItemStack();
if (Config.getInstance().getPreventItemDrop()) {
if (ItemUtils.isSoulbound(itemStack) && ItemUtils.isBindedPlayer(player, itemStack)) {
item.setPickupDelay(2 * 20);
event.setCancelled(true);
new UpdateInventoryTask(player).runTask(Soulbound.p);
}
return;
}
if (Config.getInstance().getDeleteOnDrop()) {
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);
event.getItemDrop().remove();
return;
}
if (ItemsConfig.getInstance().isActionItem(itemStack, ActionType.DROP_ITEM)) {
ItemUtils.soulbindItem(player, itemStack);
return;
}
}
@EventHandler(
priority = EventPriority.HIGHEST,
ignoreCancelled = true)
private void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
boolean deleteOnDeath = Permissions.deleteOnDeath(player);
boolean keepOnDeath = Permissions.keepOnDeath(player);
List<ItemStack> items = new ArrayList<ItemStack>();
if (!keepOnDeath && !deleteOnDeath) {
return;
}
for (ItemStack item : new ArrayList<ItemStack>(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);
}
}
}
PlayerData.storeItemsDeath(player, items);
}
@EventHandler(
priority = EventPriority.NORMAL,
ignoreCancelled = true)
private void onPlayerRespawn(PlayerRespawnEvent event) {
new SoulbindInventoryTask(event.getPlayer(), ActionType.RESPAWN).runTask(Soulbound.p);
}
@EventHandler(
priority = EventPriority.HIGHEST,
ignoreCancelled = true)
private void onPlayerRespawnHighest(PlayerRespawnEvent event) {
Player player = event.getPlayer();
boolean keepOnDeath = Permissions.keepOnDeath(player);
if (!keepOnDeath) {
return;
}
List<ItemStack> items = new ArrayList<ItemStack>();
items = PlayerData.retrieveItemsDeath(player);
if (items != null) {
for (ItemStack item : items) {
player.getInventory().addItem(item);
}
}
new UpdateInventoryTask(player).runTask(Soulbound.p);
}
/**
* Watch PlayerInteract events.
*
* @param event
* The event to watch
*/
@EventHandler(
priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Action action = event.getAction();
ItemStack inHand = player.getItemInHand();
switch (action) {
case RIGHT_CLICK_BLOCK:
case RIGHT_CLICK_AIR:
case LEFT_CLICK_AIR:
case LEFT_CLICK_BLOCK:
if (ItemUtils.isEquipable(inHand)) {
new UpdateArmorTask(player).runTaskLater(Soulbound.p, 2);
} else if (ItemUtils.isBindOnUse(inHand)) {
ItemUtils.soulbindItem(player, inHand);
}
default:
break;
}
}
/**
* Monitor PlayerFishEvent events.
*
* @param event
* The event to monitor
*/
@EventHandler(
priority = EventPriority.LOWEST,
ignoreCancelled = true)
private void onPlayerFish(PlayerFishEvent event) {
ItemStack itemInHand = event.getPlayer().getItemInHand();
DurabilityUtils.handleInfiniteDurability(itemInHand);
}
/**
* Monitor PlayerShearEntityEvent events.
*
* @param event
* The event to monitor
*/
@EventHandler(
priority = EventPriority.LOWEST,
ignoreCancelled = true)
private void onPlayerShearEntity(PlayerShearEntityEvent event) {
ItemStack itemInHand = event.getPlayer().getItemInHand();
DurabilityUtils.handleInfiniteDurability(itemInHand);
}
/**
* Watch PlayerCommandPreprocessEvent events.
*
* @param event
* The event to watch
*/
@EventHandler(
priority = EventPriority.NORMAL,
ignoreCancelled = true)
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
ItemStack itemStack = player.getItemInHand();
String command = event.getMessage();
if (ItemUtils.isSoulbound(itemStack)
&& Config.getInstance().getBlockedCommands().contains(command)) {
player.sendMessage(ChatColor.RED + "You're not allowed to use " + ChatColor.GOLD
+ command + ChatColor.RED + " command while holding a Soulbound item.");
event.setCancelled(true);
}
}
/**
* Monitor PlayerCommandPreprocessEvent events.
*
* @param event
* The event to monitor
*/
@EventHandler(
priority = EventPriority.MONITOR,
ignoreCancelled = true)
public void onPlayerCommandMonitor(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
ItemStack inHand = player.getItemInHand();
String command = event.getMessage();
String[] args = CommandUtils.extractArgs(command);
if (!ItemUtils.isSoulbound(inHand)
&& Config.getInstance().getBindCommands().contains(command)) {
ItemUtils.soulbindItem(player, inHand);
return;
}
if (command.contains("kit")) {
Player target;
if (args.length >= 2) {
target = Soulbound.p.getServer().getPlayer(args[1]);
} else {
target = player;
}
if (target == null) {
return;
}
new SoulbindInventoryTask(target, ActionType.KIT).runTask(Soulbound.p);
}
}
/**
* Monitor ServerCommandEvent events.
*
* @param event
* The event to monitor
*/
@EventHandler(
priority = EventPriority.MONITOR,
ignoreCancelled = true)
public void onServerCommand(ServerCommandEvent event) {
String command = event.getCommand();
String[] args = CommandUtils.extractArgs(command);
if (!command.contains("kit")) {
return;
}
if (args.length < 2) {
return;
}
Player target = Soulbound.p.getServer().getPlayer(args[1]);
new SoulbindInventoryTask(target, ActionType.KIT).runTask(Soulbound.p);
}
}

View File

@@ -0,0 +1,38 @@
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.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.events.SoulbindItemEvent;
import com.me.tft_02.soulbound.util.ItemUtils;
import com.me.tft_02.soulbound.util.Permissions;
public class SelfListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onItemSoulbound(SoulbindItemEvent event) {
Player player = event.getPlayer();
Inventory inventory = player.getInventory();
int maxAmount = Permissions.getSoulbindMaximum(player);
if (maxAmount < 0) {
return;
}
int count = 0;
for (ItemStack itemStack : inventory.getContents()) {
if (itemStack != null && ItemUtils.isSoulbound(itemStack)) {
count++;
}
}
if (count >= maxAmount) {
player.sendMessage(ChatColor.RED + "Cannot Soulbind any more items, maximum amount reached! " + ChatColor.GOLD + "(" + maxAmount + ")");
event.setCancelled(true);
}
}
}

View File

@@ -0,0 +1,34 @@
package com.me.tft_02.soulbound.runnables;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import com.me.tft_02.soulbound.config.ItemsConfig;
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;
public SoulbindInventoryTask(Player player, ActionType actionType) {
this.player = player;
this.actionType = actionType;
}
@Override
public void run() {
for (ItemStack itemStack : player.getInventory().getContents()) {
if (itemStack != null && ItemsConfig.getInstance().isActionItem(itemStack, actionType)) {
ItemUtils.soulbindItem(player, itemStack);
}
}
for (ItemStack itemStack : player.getInventory().getArmorContents()) {
if (itemStack != null && ItemsConfig.getInstance().isActionItem(itemStack, actionType)) {
ItemUtils.soulbindItem(player, itemStack);
}
}
}
}

View File

@@ -0,0 +1,31 @@
package com.me.tft_02.soulbound.runnables;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
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;
public UpdateArmorTask(Player player) {
this.player = player;
}
@Override
public void run() {
handleBindOnEquip(player);
}
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());
}
}

View File

@@ -0,0 +1,19 @@
package com.me.tft_02.soulbound.runnables;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class UpdateInventoryTask extends BukkitRunnable {
private Player player;
public UpdateInventoryTask(Player player) {
this.player = player;
}
@Override
public void run() {
if (player.isValid()) {
player.updateInventory();
}
}
}

View File

@@ -0,0 +1,38 @@
package com.me.tft_02.soulbound.util;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public final class CommandUtils {
public static String[] extractArgs(String command) {
String[] args = {""};
String[] split = command.split(" ", 2);
if (split.length > 1) {
args = split[1].split(" ");
}
return args;
}
public static boolean noConsoleUsage(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;
}
}

View File

@@ -0,0 +1,15 @@
package com.me.tft_02.soulbound.util;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.config.Config;
public class DurabilityUtils {
public static void handleInfiniteDurability(ItemStack itemStack) {
if (Config.getInstance().getInfiniteDurability() && ItemUtils.isSoulbound(itemStack)) {
itemStack.setDurability((short) 0);
return;
}
}
}

View File

@@ -0,0 +1,375 @@
package com.me.tft_02.soulbound.util;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.me.tft_02.soulbound.Soulbound;
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 soulbindItem(Player player, ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
if (isSoulbound(itemStack)) {
return itemStack;
}
SoulbindItemEvent soulbindItemEvent = new SoulbindItemEvent(player, itemStack);
Soulbound.p.getServer().getPluginManager().callEvent(soulbindItemEvent);
itemStack = soulbindItemEvent.getItemStack();
if (soulbindItemEvent.isCancelled()) {
return itemStack;
}
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> itemLore = new ArrayList<String>();
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);
}
itemLore.add(Misc.SOULBOUND_TAG);
if (Config.getInstance().getShowNameInLore()) {
itemLore.add(player.getName());
}
itemMeta.setLore(itemLore);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static ItemStack bopItem(ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
if (isBindOnPickup(itemStack)) {
return itemStack;
}
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;
}
public static ItemStack boeItem(ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
if (isBindOnEquip(itemStack)) {
return itemStack;
}
ItemMeta itemMeta = itemStack.getItemMeta();
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 ItemStack bouItem(ItemStack itemStack) {
if (itemStack == null) {
return itemStack;
}
if (isBindOnUse(itemStack)) {
return itemStack;
}
ItemMeta itemMeta = itemStack.getItemMeta();
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 unbindItem(ItemStack itemStack) {
if (itemStack == null) {
return null;
}
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore() && isSoulbound(itemStack)) {
List<String> oldLore = itemMeta.getLore();
int loreSize = oldLore.size();
if (loreSize <= 2) {
itemMeta.setLore(null);
itemStack.setItemMeta(itemMeta);
return itemStack;
}
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);
itemMeta.setLore(itemLore);
}
itemStack.setItemMeta(itemMeta);
return itemStack;
}
public static boolean isSoulbound(ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
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;
}
public static boolean isBindOnPickup(ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
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 isBindOnUse(ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
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 boolean isBindOnEquip(ItemStack itemStack) {
if (!itemStack.hasItemMeta()) {
return false;
}
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasLore()) {
List<String> itemLore = itemMeta.getLore();
if (itemLore.contains(Misc.EQUIPBIND_TAG)) {
return true;
}
}
return false;
}
public static boolean isBindedPlayer(Player player, ItemStack itemStack) {
List<String> itemLore = itemStack.getItemMeta().getLore();
return itemLore.contains(player.getName());
}
public static boolean isNormalItem(ItemStack itemStack) {
return !itemStack.hasItemMeta() && !itemStack.getItemMeta().hasLore() || ItemUtils.getItemType(itemStack) == ItemType.NORMAL;
}
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;
}
}
/**
* 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;
}
/**
* 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);
}
/**
* 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;
default:
return false;
}
}
/**
* 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;
default:
return false;
}
}
/**
* 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;
default:
return false;
}
}
/**
* 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;
default:
return false;
}
}
/**
* 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;
}
}
}

View File

@@ -0,0 +1,23 @@
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

@@ -0,0 +1,10 @@
package com.me.tft_02.soulbound.util;
import org.bukkit.ChatColor;
public class Misc {
public static String SOULBOUND_TAG = ChatColor.GOLD + "灵魂绑定";
public static String PICKUPBIND_TAG = ChatColor.DARK_RED + "拾取后绑定";
public static String USEBIND_TAG = ChatColor.DARK_RED + "使用后绑定";
public static String EQUIPBIND_TAG = ChatColor.DARK_RED + "装备后绑定";
}

View File

@@ -0,0 +1,40 @@
package com.me.tft_02.soulbound.util;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
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) {
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.";
int amount = -1;
for (PermissionAttachmentInfo permission : player
.getEffectivePermissions()) {
if (permission.getPermission().startsWith(match)
&& permission.getValue()) {
amount = Integer.parseInt(permission.getPermission().split(
"[.]")[2]);
}
}
return amount;
}
}

View File

@@ -0,0 +1,40 @@
package com.me.tft_02.soulbound.util;
import java.util.HashMap;
import java.util.List;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.me.tft_02.soulbound.Soulbound;
public class PlayerData {
Soulbound plugin;
public PlayerData(Soulbound instance) {
plugin = instance;
}
public static HashMap<String, List<ItemStack>> playerSoulboundItems = new HashMap<String, List<ItemStack>>();
public static void storeItemsDeath(Player player, List<ItemStack> items) {
String playerName = player.getName();
if (playerSoulboundItems.containsKey(playerName)) {
playerSoulboundItems.put(playerName, null);
}
playerSoulboundItems.put(playerName, items);
}
public static List<ItemStack> retrieveItemsDeath(Player player) {
String playerName = player.getName();
if (playerSoulboundItems.containsKey(playerName)) {
return playerSoulboundItems.get(playerName);
}
else {
return null;
}
}
}

View File

@@ -0,0 +1,17 @@
package com.me.tft_02.soulbound.util;
import java.util.List;
public class StringUtils {
public static int getIndexOfSoulbound(List<String> itemLore) {
int index = -1;
for (String line : itemLore) {
if (line.contains(Misc.SOULBOUND_TAG)) {
return itemLore.indexOf(line);
}
}
return index;
}
}

View File

@@ -0,0 +1,40 @@
#
# 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
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

View File

@@ -0,0 +1,35 @@
#
# Soulbound item configuration
#
# Items in this config file will be automatically Soulbound to the player on certain
# actions, such as dropping the item or picking it up.
#
# You can add items under "Items" using the exact material name. You can add a data value using a |
# For example, WOOL|15 would be Material.WOOL with data value 15.
#
# The bare minimum of a Soulbound item is that it has Actions
#
# Name: This is the displayname of an item
#
# Lore: List one or more lines of lore here
#
# Actions: The actions when the item should be soulbound to the player.
# Valid values are: CRAFT, OPEN_CHEST, PICKUP_ITEM, DROP_ITEM, RESPAWN, KIT
#
#
###
Items:
DIAMOND_SPADE:
Lore:
- Made from diamond,
- can dig dirt!
Actions:
- CRAFT
- OPEN_CHEST
WOOL|15:
Name: Black Piece Of Wool
Actions:
- PICKUP_ITEM
- DROP_ITEM

View File

@@ -0,0 +1,44 @@
#提示消息
Message:
CAN_NOT_BIND: '&7你不能&c绑定&7这个物品'
CAN_NOT_UNBIND: '&7你不能&6解绑&7这个物品'
BINDED: '&7物品已经&a绑定&7到玩家&c%target%'
UNBINDED: '&7物品已经解绑'
BIND_FULL_INEVNTORY: '&a玩家&c%player%&a背包内的所有物品已绑定到玩家&6%target%'
BIND_INVENTORY: '&c你可能需要的命令: &a/bind <player> inventory'
BIND_ON_EQUIP: '&7当前物品已标记为 &4装备后绑定'
BIND_ON_PICKUP: '&7当前物品已标记为 &4拾取后绑定'
BIND_ON_USE: '&7当前物品已标记为 &4使用后绑定'
CAN_NOT_BIND_ON_EQUIP: '&7当前物品不能标记为 &4装备后绑定'
CAN_NOT_BIND_ON_PICKUP: '&7当前物品不能标记为 &4拾取后绑定'
CAN_NOT_BIND_ON_USE: '&7当前物品不能标记为 &4使用后绑定'
VERSION: '灵魂绑定(&3修改by喵♂呜) &r版本号'
CAN_NOT_USE_ON_CONSOLE: '抱歉 此命令不能在控制台使用'
PAGE_NOT_EXIST: '&c帮助页面不存在 请输入 /Soulbound help [0-%maxPages%]'
HELP_TITLE: '&7--[ &6灵魂绑定 帮助 &a-汉化by邱 &3-修改by喵♂呜 &7 ]-- 页面 %page%/%maxPages%'
HOW_DOES_IT_WORK: '&4* &c它是如何工作的'
HOW_DOES_IT_WORK_1: '&4* &c灵魂绑定的物品只有自己才能使用。'
HOW_DOES_IT_WORK_2: '&4* &c绑定后的物品某些行为将会被阻止:'
HOW_DOES_IT_WORK_3: '&4* &c扔在地上、或者放到箱子里让其他玩家拿。'
HOW_DOES_IT_WORK_4: '&4* &c标记为 &4拾取后绑定 &c的物品'
HOW_DOES_IT_WORK_4_1: ' &c一旦被玩家捡起来就会立即绑定成为该玩家的物品。'
HOW_DOES_IT_WORK_5: '&4* &c标记为 &4使用后绑定 &c的物品'
HOW_DOES_IT_WORK_5_1: ' &c只要拿在手中左键或者右键就会立即绑定成为该玩家的物品。'
HOW_DOES_IT_WORK_6: '&4* &c标记为 &4装备后绑定 &c的物品'
HOW_DOES_IT_WORK_6_1: ' &c装备到身上后就能立即绑定成为该玩家的物品。'
CMD: '&6指令:'
CMDVERSION: '&4* &a/soulbound &7查看插件版本。'
CMD_BIND: '&4* &a/bind <sender> &7绑定手上的物品。'
CMD_BIND_FULL_INVENTORY: '&4* &a/bind <sender> inventory &7绑定玩家背包里的所有物品。'
CMD_BIND_ON_EQUIP: '&4* &a/bindonequip &7将当前物品标记为 &4装备后绑定'
CMD_BIND_ON_PICKUP: '&4* &a/bindonpickup &7将当前物品标记为 &4拾取后绑定'
CMD_BIND_ON_USE: '&4* &a/bindonuse &7将当前物品标记为 &4使用后绑定'
CMD_UNBIND: '&4* &a/unbind &7解除手中物品的绑定。'
CMD_NEXT: '&6使用 /soulbound help %nextPage% 查看更多'
CMD_USE: '使用: /soulbound [reload | help]'
RELOAD: '&a配置文件已重载...'

View File

@@ -0,0 +1,57 @@
name: ${project.artifactId}
description: ${project.description}
authors: [TfT_02,喵♂呜]
version: ${project.version}
main: com.me.tft_02.soulbound.Soulbound
website: http://ci.citycraft.cn:8800/jenkins/job/Soulbound/
softdepend: [EpicBossRecoded]
commands:
soulbound:
description: Usage /soulbound
permission-message: §c你没有 <permission> 的权限来执行此命令!
bind:
description: Usage /bind
alias: bound
permission: soulbound.commands.bind
permission-message: §c你没有 <permission> 的权限来执行此命令!
bindonpickup:
description: Usage /bindonpickup
permission: soulbound.commands.bindonpickup
permission-message: §c你没有 <permission> 的权限来执行此命令!
bindonuse:
description: Usage /bindonuse
permission: soulbound.commands.bindonuse
permission-message: §c你没有 <permission> 的权限来执行此命令!
bindonequip:
description: Usage /bindonequip
permission: soulbound.commands.bindonequip
permission-message: §c你没有 <permission> 的权限来执行此命令!
unbind:
description: Usage /unbind
alias: unbound
permission: soulbound.commands.unbind
permission-message: §c你没有 <permission> 的权限来执行此命令!
permissions:
soulbound.commands.all:
description: Gives access to the Soulbound commands
default: op
children:
soulbound.commands.bind: true
soulbound.commands.bindonpickup: true
soulbound.commands.bindonuse: true
soulbound.commands.bindonequip: true
soulbound.commands.unbind: true
soulbound.commands.reload: true
soulbound.updatecheck: true
soulbound.pickup.bypass:
description: Users with this permission will be able to pickup Soulbound items that do not belong to them.
default: false
soulbound.items.keep_on_death:
description: Users with this permission will keep their Soulbound items after dying
default: false
soulbound.items.delete_on_death:
description: Users with this permission will have their Soulbound items deleted on death
default: false
soulbound.updatecheck:
description: Users with this permission will receive a notification when there is a new version available.
default: op