add language file message.yml...

Signed-off-by: j502647092 <jtb1@163.com>
pull/1/MERGE
j502647092 2015-04-30 15:18:56 +08:00
parent 0f4babe423
commit 9293ec35d5
8 changed files with 196 additions and 72 deletions

View File

@ -1,7 +1,12 @@
package com.me.tft_02.soulbound;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@ -32,11 +37,21 @@ public class Soulbound extends JavaPlugin {
// Checks for hooking into other plugins
public static boolean epicBossRecodedEnabled = false;
public static boolean loreLocksEnabled = false;
public static boolean mythicDropsEnabled = false;
// Update Check
private boolean updateAvailable;
public File msgfile;
public FileConfiguration msgConfig;
public void onLoad() {
saveDefaultConfig();
this.saveResource("message.yml", false);
msgfile = new File(this.getDataFolder(), "message.yml");
msgConfig = Loadcfg(msgfile);
}
/**
* Run things on enable.
*/
@ -107,5 +122,43 @@ public class Soulbound extends JavaPlugin {
Config.getInstance();
ItemsConfig.getInstance();
}
public FileConfiguration Loadcfg(File cfgfile) {
if (!cfgfile.exists()) {
saveResource(cfgfile.getName(), false);
return YamlConfiguration.loadConfiguration(cfgfile);
} else {
return YamlConfiguration.loadConfiguration(cfgfile);
}
}
public void LoadConfig(FileConfiguration cfg, File cfgfile)
throws FileNotFoundException, IOException,
InvalidConfigurationException {
if (!cfgfile.exists()) {
saveResource(cfgfile.getName(), false);
cfg.load(cfgfile);
} else {
cfg.load(cfgfile);
}
}
public void Savecfg(FileConfiguration cfg, File cfgfile) {
try {
// cfg.saveToString();
cfg.save(cfgfile);
} catch (IOException e) {
getLogger().info("配置文件" + cfgfile.getName() + "已保存!");
}
}
public String getmessage(String path) {
String message = this.msgConfig.getString(path).replaceAll("&", "§");
return message;
}
public String getlang(String type) {
return this.getmessage("Message." + type);
}
}

View File

@ -42,7 +42,8 @@ public class BindCommand implements CommandExecutor {
break;
case 2:
if (!args[1].equalsIgnoreCase("inventory")) {
sender.sendMessage(ChatColor.RED + "Proper usage: " + ChatColor.GREEN + "/bind <player> inventory");
sender.sendMessage(Soulbound.p.getlang("BIND_INVENTORY"));
//sender.sendMessage(ChatColor.RED + "Proper usage: " + ChatColor.GREEN + "/bind <player> inventory");
return true;
}
@ -65,14 +66,16 @@ public class BindCommand implements CommandExecutor {
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || ItemUtils.isSoulbound(itemInHand)) {
sender.sendMessage(ChatColor.GRAY + "You can't " + soulbound + ChatColor.GRAY + "this item.");
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND"));
//sender.sendMessage(ChatColor.GRAY + "You can't " + soulbound + ChatColor.GRAY + "this item.");
return false;
}
ItemUtils.soulbindItem(target, itemInHand);
if (ItemUtils.isSoulbound(itemInHand) && Config.getInstance().getFeedbackEnabled()) {
sender.sendMessage(ChatColor.GRAY + "Item is now " + soulbound + ChatColor.GRAY + "to " + ChatColor.DARK_AQUA + target.getName());
sender.sendMessage(Soulbound.p.getlang("BINDED").replace("%target%", target.getName()));
//sender.sendMessage(ChatColor.GRAY + "Item is now " + soulbound + ChatColor.GRAY + "to " + ChatColor.DARK_AQUA + target.getName());
}
return true;
}
@ -85,7 +88,10 @@ public class BindCommand implements CommandExecutor {
}
if (Config.getInstance().getFeedbackEnabled()) {
player.sendMessage(ChatColor.GRAY + "All items in " + ChatColor.DARK_AQUA + target.getName() + ChatColor.GRAY + "'s inventory are now " + soulbound + ChatColor.GRAY + "to " + ChatColor.DARK_AQUA + target.getName());
player.sendMessage(Soulbound.p.getlang("BIND_FULL_INEVNTORY").
replace("%player%", player.getName()).
replace("%target%", target.getName()));
//player.sendMessage(ChatColor.GRAY + "All items in " + ChatColor.DARK_AQUA + player.getName() + ChatColor.GRAY + "'s inventory are now " + soulbound + ChatColor.GRAY + "to " + ChatColor.DARK_AQUA + target.getName());
}
return true;
}

View File

@ -1,6 +1,5 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -8,6 +7,7 @@ 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;
@ -29,7 +29,7 @@ public class BindOnEquipCommand implements CommandExecutor {
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || ItemUtils.isSoulbound(itemInHand)) {
player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Soulbound " + ChatColor.GRAY + "this item.");
player.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND"));
return false;
}
@ -37,10 +37,12 @@ public class BindOnEquipCommand implements CommandExecutor {
ItemUtils.boeItem(itemInHand);
if (ItemUtils.isBindOnEquip(itemInHand)) {
player.sendMessage(ChatColor.GRAY + "Item is now " + ChatColor.DARK_RED + "Bind on Equip");
player.sendMessage(Soulbound.p.getlang("BIND_ON_EQUIP"));
//player.sendMessage(ChatColor.GRAY + "Item is now " + ChatColor.DARK_RED + "Bind on Equip");
}
else {
player.sendMessage(ChatColor.RED + "Cannot mark this item as " + ChatColor.DARK_RED + "Bind on Equip");
player.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND_ON_EQUIP"));
//player.sendMessage(ChatColor.RED + "Cannot mark this item as " + ChatColor.DARK_RED + "Bind on Equip");
}
return true;

View File

@ -1,6 +1,5 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -8,6 +7,7 @@ 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;
@ -29,13 +29,15 @@ public class BindOnPickupCommand implements CommandExecutor {
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || ItemUtils.isSoulbound(itemInHand)) {
player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Soulbound " + ChatColor.GRAY + "this item.");
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND_ON_PICKUP"));
//player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Soulbound " + ChatColor.GRAY + "this item.");
return false;
}
ItemUtils.unbindItem(itemInHand);
ItemUtils.bopItem(itemInHand);
player.sendMessage(ChatColor.GRAY + "Item is now " + ChatColor.DARK_RED + "Bind on pickup");
sender.sendMessage(Soulbound.p.getlang("BIND_ON_PICKUP"));
//player.sendMessage(ChatColor.GRAY + "Item is now " + ChatColor.DARK_RED + "Bind on pickup");
return true;
default:

View File

@ -1,6 +1,5 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -8,6 +7,7 @@ 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;
@ -29,14 +29,15 @@ public class BindOnUseCommand implements CommandExecutor {
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || ItemUtils.isSoulbound(itemInHand)) {
player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Soulbound " + ChatColor.GRAY + "this item.");
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_BIND_ON_USE"));
//player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Soulbound " + ChatColor.GRAY + "this item.");
return false;
}
ItemUtils.unbindItem(itemInHand);
ItemUtils.bouItem(itemInHand);
player.sendMessage(ChatColor.GRAY + "Item is now " + ChatColor.DARK_RED + "Bind on Use");
sender.sendMessage(Soulbound.p.getlang("BIND_ON_USE"));
//player.sendMessage(ChatColor.GRAY + "Item is now " + ChatColor.DARK_RED + "Bind on Use");
return true;
default:
return false;

View File

@ -14,7 +14,7 @@ public class SoulboundCommand implements CommandExecutor {
String label, String[] args) {
switch (args.length) {
case 0:
sender.sendMessage("Soulbound version "
sender.sendMessage(Soulbound.p.getlang("VERSION")
+ Soulbound.p.getDescription().getVersion());
return printUsage(sender);
case 1:
@ -43,7 +43,8 @@ public class SoulboundCommand implements CommandExecutor {
private boolean helpPages(CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Can't use this from the console, sorry!");
sender.sendMessage(Soulbound.p.getlang("CAN_NOT_USE_ON_CONSOLE"));
//sender.sendMessage("Can't use this from the console, sorry!");
return false;
}
if (args.length >= 2 && Integer.parseInt(args[1]) > 0) {
@ -57,78 +58,102 @@ public class SoulboundCommand implements CommandExecutor {
int maxPages = 2;
int nextPage = page + 1;
if (page > maxPages) {
sender.sendMessage(ChatColor.RED + "This page does not exist."
+ ChatColor.GOLD + " /help [0-" + maxPages + "]");
sender.sendMessage(Soulbound.p.getlang("PAGE_NOT_EXIST".
replace("%maxPages%", maxPages+"")));
//sender.sendMessage(ChatColor.RED + "This page does not exist."
//+ ChatColor.GOLD + " /help [0-" + maxPages + "]");
return;
}
String dot = ChatColor.DARK_RED + "* ";
sender.sendMessage(ChatColor.GRAY + "-----[ " + ChatColor.GOLD
+ "Soulbound Help" + ChatColor.GRAY + " ]----- Page " + page
+ "/" + maxPages);
//String dot = ChatColor.DARK_RED + "* ";
// sender.sendMessage(ChatColor.GRAY + "-----[ " + ChatColor.GOLD
// + "Soulbound Help" + ChatColor.GRAY + " ]----- Page " + page
// + "/" + maxPages);
sender.sendMessage(Soulbound.p.getlang("HELP_TITLE").
replace("%page%", page+"").
replace("%maxPages%", maxPages+"")
);
if (page == 1) {
sender.sendMessage(ChatColor.GOLD + "How does it work?");
sender.sendMessage(dot
+ ChatColor.GRAY
+ "Soulbound items are special items which are bound to a sender.");
sender.sendMessage(dot
+ ChatColor.GRAY
+ "Players are prevented from doing certain actions with Soulbound items, such as:");
sender.sendMessage(dot
+ ChatColor.GRAY
+ "dropping them on the ground, storing them in chests or giving them to other players.");
sender.sendMessage(dot
+ ChatColor.GRAY
+ "Items marked as 'Bind on Pickup' will get Soulbound as soon as they get picked up.");
sender.sendMessage(dot
+ ChatColor.GRAY
+ "Items marked as 'Bind on Use' will get Soulbound as soon as they get used.");
sender.sendMessage(dot
+ ChatColor.GRAY
+ "Items marked as 'Bind on Equip' will get Soulbound as soon as they get equipped.");
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_5"));
sender.sendMessage(Soulbound.p.getlang("HOW_DOES_IT_WORK_6"));
// sender.sendMessage(ChatColor.GOLD + "How does it work?");
// sender.sendMessage(dot
// + ChatColor.GRAY
// + "Soulbound items are special items which are bound to a sender.");
// sender.sendMessage(dot
// + ChatColor.GRAY
// + "Players are prevented from doing certain actions with Soulbound items, such as:");
// sender.sendMessage(dot
// + ChatColor.GRAY
// + "dropping them on the ground, storing them in chests or giving them to other players.");
// sender.sendMessage(dot
// + ChatColor.GRAY
// + "Items marked as 'Bind on Pickup' will get Soulbound as soon as they get picked up.");
// sender.sendMessage(dot
// + ChatColor.GRAY
// + "Items marked as 'Bind on Use' will get Soulbound as soon as they get used.");
// sender.sendMessage(dot
// + ChatColor.GRAY
// + "Items marked as 'Bind on Equip' will get Soulbound as soon as they get equipped.");
}
if (page == 2) {
sender.sendMessage(ChatColor.GOLD + "Commands:");
if (sender.hasPermission("soulbound.commands.bindonpickup")) {
sender.sendMessage(dot + ChatColor.GREEN + "/soulbound"
+ ChatColor.GRAY + " Check the status of the plugin.");
sender.sendMessage(Soulbound.p.getlang("CMD"));
//sender.sendMessage(ChatColor.GOLD + "Commands:");
if (sender.hasPermission("soulbound.commands.bind")) {
sender.sendMessage(Soulbound.p.getlang("CMDVERSION"));
//sender.sendMessage(dot + ChatColor.GREEN + "/soulbound"
//+ ChatColor.GRAY + " Check the status of the plugin.");
}
if (sender.hasPermission("soulbound.commands.bind")) {
sender.sendMessage(dot + ChatColor.GREEN + "/bind <sender>"
+ ChatColor.GRAY
+ " Soulbound the item currently in hand.");
sender.sendMessage(dot + ChatColor.GREEN
+ "/bind <sender> inventory" + ChatColor.GRAY
+ " Soulbound an entire inventory.");
sender.sendMessage(Soulbound.p.getlang("CMD_BIND"));
//sender.sendMessage(dot + ChatColor.GREEN + "/bind <sender>"
//+ ChatColor.GRAY
//+ " Soulbound the item currently in hand.");
sender.sendMessage(Soulbound.p.getlang("CMD_BIND_FULL_INVENTORY"));
//sender.sendMessage(dot + ChatColor.GREEN
//+ "/bind <sender> inventory" + ChatColor.GRAY
//+ " Soulbound an entire inventory.");
}
if (sender.hasPermission("soulbound.commands.bindonpickup")) {
sender.sendMessage(dot + ChatColor.GREEN + "/bindonpickup"
+ ChatColor.GRAY
+ " Mark the item in hand as 'Bind on Pickup'");
sender.sendMessage(Soulbound.p.getlang("CMD_BIND_ON_PICKUP"));
//sender.sendMessage(dot + ChatColor.GREEN + "/bindonpickup"
//+ ChatColor.GRAY
//+ " Mark the item in hand as 'Bind on Pickup'");
}
if (sender.hasPermission("soulbound.commands.bindonuse")) {
sender.sendMessage(dot + ChatColor.GREEN + "/bindonuse"
+ ChatColor.GRAY
+ " Mark the item in hand as 'Bind on Use'");
sender.sendMessage(Soulbound.p.getlang("CMD_BIND_ON_USE"));
//sender.sendMessage(dot + ChatColor.GREEN + "/bindonuse"
//+ ChatColor.GRAY
//+ " Mark the item in hand as 'Bind on Use'");
}
if (sender.hasPermission("soulbound.commands.bindonequip")) {
sender.sendMessage(dot + ChatColor.GREEN + "/bindonequip"
+ ChatColor.GRAY
+ " Mark the item in hand as 'Bind on Equip'");
sender.sendMessage(Soulbound.p.getlang("CMD_BIND_ON_EQUIP"));
//sender.sendMessage(dot + ChatColor.GREEN + "/bindonequip"
//+ ChatColor.GRAY
//+ " Mark the item in hand as 'Bind on Equip'");
}
if (sender.hasPermission("soulbound.commands.unbind")) {
sender.sendMessage(dot + ChatColor.GREEN + "/unbind"
+ ChatColor.GRAY + " Unbind the item in hand.");
sender.sendMessage(Soulbound.p.getlang("CMD_UNBIND"));
//sender.sendMessage(dot + ChatColor.GREEN + "/unbind"
//+ ChatColor.GRAY + " Unbind the item in hand.");
}
}
if (nextPage <= maxPages) {
sender.sendMessage(ChatColor.GOLD + "Type /soulbound help "
+ nextPage + " for more");
sender.sendMessage(Soulbound.p.getlang("CMD_NEXT").replace("%nextPage%", nextPage+""));
//sender.sendMessage(ChatColor.GOLD + "Type /soulbound help "
//+ nextPage + " for more");
}
}
private boolean printUsage(CommandSender sender) {
sender.sendMessage("Usage: /soulbound [reload | help]");
sender.sendMessage(Soulbound.p.getlang("CMD_USE"));
//sender.sendMessage("Usage: /soulbound [reload | help]");
return false;
}
}

View File

@ -1,6 +1,5 @@
package com.me.tft_02.soulbound.commands;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -8,6 +7,7 @@ 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;
@ -29,16 +29,18 @@ public class UnbindCommand implements CommandExecutor {
ItemStack itemInHand = player.getItemInHand();
if ((itemInHand.getType() == Material.AIR) || !ItemUtils.isSoulbound(itemInHand)) {
player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Unbind " + ChatColor.GRAY + "this item.");
player.sendMessage(Soulbound.p.getlang("CAN_NOT_UNBIND"));
//player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Unbind " + ChatColor.GRAY + "this item.");
return false;
}
if (ItemUtils.unbindItem(itemInHand)==null ){
player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Unbind " + ChatColor.GRAY + "this item.");
player.sendMessage(Soulbound.p.getlang("CAN_NOT_UNBIND"));
//player.sendMessage(ChatColor.GRAY + "You can't " + ChatColor.GOLD + "Unbind " + ChatColor.GRAY + "this item.");
return false;
}
player.sendMessage(ChatColor.GRAY + "Item no longer Soulbound.");
player.sendMessage(Soulbound.p.getlang("UNBINDED"));
//player.sendMessage(ChatColor.GRAY + "Item no longer Soulbound.");
return true;
default:
return false;

33
src/message.yml Normal file
View File

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