mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2024-11-16 01:08:46 +00:00
add Language file and Complete Teleport System...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
60bc20b7f0
commit
b9edf12f09
@ -23,6 +23,7 @@ import cn.citycraft.SimpleEssential.command.CommandTpdeny;
|
|||||||
import cn.citycraft.SimpleEssential.command.CommandTphere;
|
import cn.citycraft.SimpleEssential.command.CommandTphere;
|
||||||
import cn.citycraft.SimpleEssential.command.SimpleEssentialCommand;
|
import cn.citycraft.SimpleEssential.command.SimpleEssentialCommand;
|
||||||
import cn.citycraft.SimpleEssential.config.Config;
|
import cn.citycraft.SimpleEssential.config.Config;
|
||||||
|
import cn.citycraft.SimpleEssential.config.Language;
|
||||||
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
|
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
|
||||||
import cn.citycraft.SimpleEssential.teleport.TeleportControl;
|
import cn.citycraft.SimpleEssential.teleport.TeleportControl;
|
||||||
import cn.citycraft.SimpleEssential.utils.VersionChecker;
|
import cn.citycraft.SimpleEssential.utils.VersionChecker;
|
||||||
@ -84,6 +85,7 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
Config.load(this, "1.0");
|
Config.load(this, "1.0");
|
||||||
|
Language.load(this, "1.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||||
|
import cn.citycraft.SimpleEssential.config.Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 蒋天蓓 2015年8月12日下午2:04:05 TODO
|
* @author 蒋天蓓 2015年8月12日下午2:04:05 TODO
|
||||||
@ -29,7 +30,7 @@ public class CommandHome extends SimpleEssentialCommand {
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
Location loc = p.getBedSpawnLocation();
|
Location loc = p.getBedSpawnLocation();
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
p.sendMessage("§c你的床丢失了或者被方块阻挡了!");
|
p.sendMessage(Language.getMessage("Teleport.homelose"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.tpcontrol.magicTeleport(p, loc);
|
plugin.tpcontrol.magicTeleport(p, loc);
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||||
|
import cn.citycraft.SimpleEssential.config.Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 蒋天蓓 2015年8月12日下午2:04:05 TODO
|
* @author 蒋天蓓 2015年8月12日下午2:04:05 TODO
|
||||||
@ -31,9 +32,9 @@ public class CommandSetHome extends SimpleEssentialCommand {
|
|||||||
Block b = p.getLocation().getBlock();
|
Block b = p.getLocation().getBlock();
|
||||||
if (b.getType() == Material.BED_BLOCK) {
|
if (b.getType() == Material.BED_BLOCK) {
|
||||||
p.setBedSpawnLocation(b.getLocation(), true);
|
p.setBedSpawnLocation(b.getLocation(), true);
|
||||||
p.sendMessage("§a家设置成功!");
|
p.sendMessage(Language.getMessage("Teleport.sethomesuccess"));
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage("§c请站在床上设置家!");
|
p.sendMessage(Language.getMessage("Teleport.sethomeerror"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||||
|
import cn.citycraft.SimpleEssential.config.Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 蒋天蓓
|
* @author 蒋天蓓
|
||||||
@ -43,6 +44,6 @@ public class CommandTop extends SimpleEssentialCommand {
|
|||||||
int top = loc.getWorld().getHighestBlockYAt(loc);
|
int top = loc.getWorld().getHighestBlockYAt(loc);
|
||||||
loc.setY(top);
|
loc.setY(top);
|
||||||
p.teleport(loc);
|
p.teleport(loc);
|
||||||
p.sendMessage("&a已传送至当前位置最高方块!");
|
p.sendMessage(Language.getMessage("Teleport.top"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||||
|
import cn.citycraft.SimpleEssential.config.Language;
|
||||||
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,15 +42,15 @@ public class CommandTpa extends SimpleEssentialCommand {
|
|||||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
sender.sendMessage("§c玩家 " + args[0] + " 不存在或不在线!");
|
sender.sendMessage(Language.getMessage("Base.offline", args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPA);
|
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPA);
|
||||||
sender.sendMessage("§a已经向玩家 " + target.getDisplayName() + " §a发送传送请求!");
|
sender.sendMessage(Language.getMessage("Teleport.tpsend"));
|
||||||
target.sendMessage(new String[] {
|
target.sendMessage(new String[] {
|
||||||
"§a玩家: " + sender.getName() + "§a请求传送到你这里!",
|
Language.getMessage("Teleport.tpa", sender.getName()),
|
||||||
"§a输入命令/tpaccept 或 /tpok 接受传送",
|
Language.getMessage("Teleport.tpaccept"),
|
||||||
"§c输入命令/tpdeny 或 /tpno 拒绝传送"
|
Language.getMessage("Teleport.tpdeny")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||||
|
import cn.citycraft.SimpleEssential.config.Language;
|
||||||
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,15 +27,15 @@ public class CommandTphere extends SimpleEssentialCommand {
|
|||||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||||
Player target = Bukkit.getPlayer(args[0]);
|
Player target = Bukkit.getPlayer(args[0]);
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
sender.sendMessage("§c玩家 " + args[0] + " 不存在或不在线!");
|
sender.sendMessage(Language.getMessage("Base.offline", args[0]));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH);
|
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH);
|
||||||
sender.sendMessage("§a已经向玩家 " + target.getDisplayName() + " §a发送传送请求!");
|
sender.sendMessage(Language.getMessage("Teleport.tpsend"));
|
||||||
target.sendMessage(new String[] {
|
target.sendMessage(new String[] {
|
||||||
"§b玩家: " + sender.getName() + "§b请求你传送到他那里!",
|
Language.getMessage("Teleport.tphere", sender.getName()),
|
||||||
"§a输入命令/tpaccept 或 /tpok 接受传送",
|
Language.getMessage("Teleport.tpaccept"),
|
||||||
"§c输入命令/tpdeny 或 /tpno 拒绝传送"
|
Language.getMessage("Teleport.tpdeny")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
65
src/cn/citycraft/SimpleEssential/config/Language.java
Normal file
65
src/cn/citycraft/SimpleEssential/config/Language.java
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package cn.citycraft.SimpleEssential.config;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class Language extends ConfigLoader {
|
||||||
|
private static String CONFIG_NAME = "language.yml";
|
||||||
|
private static FileConfig instance;
|
||||||
|
private static File file;
|
||||||
|
|
||||||
|
public Language(Plugin p) {
|
||||||
|
super(p, CONFIG_NAME);
|
||||||
|
file = new File(p.getDataFolder(), CONFIG_NAME);
|
||||||
|
instance = super.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Language(Plugin p, String ver) {
|
||||||
|
super(p, CONFIG_NAME, ver);
|
||||||
|
instance = super.getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void load(Plugin p) {
|
||||||
|
new Language(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void load(Plugin p, String ver) {
|
||||||
|
new Language(p, ver);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FileConfig getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(String path, Object... paramVarArgs) {
|
||||||
|
String message = instance.getString(path);
|
||||||
|
try {
|
||||||
|
if (message != null)
|
||||||
|
message = String.format(message.replaceAll("&", "§"), paramVarArgs);
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessage(String path) {
|
||||||
|
String message = instance.getString(path);
|
||||||
|
if (message != null)
|
||||||
|
message = message.replaceAll("&", "§");
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String[] getStringArray(String path) {
|
||||||
|
return instance.getStringList(path).toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void save() {
|
||||||
|
try {
|
||||||
|
instance.save(file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
saveError(file);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||||
import cn.citycraft.SimpleEssential.config.Config;
|
import cn.citycraft.SimpleEssential.config.Config;
|
||||||
|
import cn.citycraft.SimpleEssential.config.Language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 蒋天蓓 2015年8月12日下午2:26:10 传送控制类
|
* @author 蒋天蓓 2015年8月12日下午2:26:10 传送控制类
|
||||||
@ -29,13 +30,16 @@ public class TeleportControl {
|
|||||||
* - 粒子的数量
|
* - 粒子的数量
|
||||||
*/
|
*/
|
||||||
static void pEffect(Location loc, long range) {
|
static void pEffect(Location loc, long range) {
|
||||||
int i;
|
try {
|
||||||
if (range < 2) {
|
int i;
|
||||||
range = 2;
|
if (range < 2) {
|
||||||
}
|
range = 2;
|
||||||
for (i = 0; i < range; i++) {
|
}
|
||||||
loc.getWorld().playEffect(loc, Effect.LAVA_POP, 10, 100);
|
for (i = 0; i < range; i++) {
|
||||||
loc.getWorld().playEffect(loc, Effect.PORTAL, 10, 100);
|
loc.getWorld().playEffect(loc, Effect.LAVA_POP, 10, 100);
|
||||||
|
loc.getWorld().playEffect(loc, Effect.PORTAL, 10, 100);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +51,7 @@ public class TeleportControl {
|
|||||||
|
|
||||||
public TeleportControl(SimpleEssential plugin) {
|
public TeleportControl(SimpleEssential plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,10 +66,9 @@ public class TeleportControl {
|
|||||||
Player target = ti.getTarget();
|
Player target = ti.getTarget();
|
||||||
Location loc = null;
|
Location loc = null;
|
||||||
if (!target.isOnline()) {
|
if (!target.isOnline()) {
|
||||||
player.sendMessage("§c目标玩家已离线 传送失败!");
|
player.sendMessage(Language.getMessage("Teleport.offline"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
target.sendMessage("§a玩家: " + player.getDisplayName() + "§a受了您的请求!");
|
|
||||||
if (ti.getTptype() == TeleportType.TPA) {
|
if (ti.getTptype() == TeleportType.TPA) {
|
||||||
target = ti.getTarget();
|
target = ti.getTarget();
|
||||||
loc = player.getLocation();
|
loc = player.getLocation();
|
||||||
@ -72,10 +76,12 @@ public class TeleportControl {
|
|||||||
target = player;
|
target = player;
|
||||||
loc = ti.getTarget().getLocation();
|
loc = ti.getTarget().getLocation();
|
||||||
}
|
}
|
||||||
|
player.sendMessage(Language.getMessage("Teleport.accept"));
|
||||||
|
target.sendMessage(Language.getMessage("Teleport.acceptfrom"));
|
||||||
magicTeleport(target, loc, TpDelay);
|
magicTeleport(target, loc, TpDelay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendMessage("§c未找到需要处理的队列!");
|
player.sendMessage(Language.getMessage("Teleport.none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -103,7 +109,7 @@ public class TeleportControl {
|
|||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
magicTeleport(player, loc, 3);
|
magicTeleport(player, loc, 3);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage("§c未找到可以Back的地点!");
|
player.sendMessage(Language.getMessage("Teleport.nobackloc"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,14 +122,14 @@ public class TeleportControl {
|
|||||||
public void deny(Player player) {
|
public void deny(Player player) {
|
||||||
TeleportInfo ti = teleportList.remove(player);
|
TeleportInfo ti = teleportList.remove(player);
|
||||||
if (ti != null) {
|
if (ti != null) {
|
||||||
player.sendMessage("§c已拒绝玩家的传送请求!");
|
|
||||||
Player target = ti.getTarget();
|
Player target = ti.getTarget();
|
||||||
if (target.isOnline()) {
|
if (target.isOnline()) {
|
||||||
target.sendMessage("§c玩家: " + player.getDisplayName() + "§c拒绝了您的请求!");
|
player.sendMessage(Language.getMessage("Teleport.deny"));
|
||||||
|
target.sendMessage(Language.getMessage("Teleport.denyfrom"));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.sendMessage("§c未找到需要处理的队列!");
|
player.sendMessage(Language.getMessage("Teleport.none"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -151,8 +157,7 @@ public class TeleportControl {
|
|||||||
public void magicTeleport(final Player player, final Location loc, final int delay) {
|
public void magicTeleport(final Player player, final Location loc, final int delay) {
|
||||||
int petime = delay * 20 + 10;
|
int petime = delay * 20 + 10;
|
||||||
setLastloc(player, player.getLocation());
|
setLastloc(player, player.getLocation());
|
||||||
player.sendMessage("§a传送开始 " + delay + "秒 后到达目的地 §d世界: " + loc.getWorld().getName()
|
player.sendMessage(Language.getMessage("Teleport.tp", delay, loc.getWorld().getName(), loc.getBlockX(), loc.getBlockZ()));
|
||||||
+ " §3X: " + loc.getBlockX() + " Z: " + loc.getBlockZ() + "!");
|
|
||||||
List<PotionEffect> pe = new ArrayList<PotionEffect>();
|
List<PotionEffect> pe = new ArrayList<PotionEffect>();
|
||||||
pe.add(new PotionEffect(PotionEffectType.SLOW, petime, 255));
|
pe.add(new PotionEffect(PotionEffectType.SLOW, petime, 255));
|
||||||
pe.add(new PotionEffect(PotionEffectType.CONFUSION, petime, 255));
|
pe.add(new PotionEffect(PotionEffectType.CONFUSION, petime, 255));
|
||||||
|
@ -3,9 +3,10 @@ version: 1.0
|
|||||||
#服务器名称
|
#服务器名称
|
||||||
servername: ''
|
servername: ''
|
||||||
#插件名称
|
#插件名称
|
||||||
pluginname: '&6[&b保护系统&6]&r'
|
pluginname: '&6[&b基础系统&6]&r'
|
||||||
|
|
||||||
#基础传送系统
|
#基础传送系统
|
||||||
Teleport:
|
Teleport:
|
||||||
|
name: '&6[&b传送系统&6]&r'
|
||||||
#所有传送延时
|
#所有传送延时
|
||||||
delay: 3
|
delay: 3
|
||||||
|
27
src/language.yml
Normal file
27
src/language.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#本文件为基础插件的语言配置文件
|
||||||
|
version: 1.0
|
||||||
|
#基础语言配置
|
||||||
|
Base:
|
||||||
|
offline: "§c玩家 {0} 不存在或不在线!"
|
||||||
|
#基础传送系统
|
||||||
|
Teleport:
|
||||||
|
tp: '§a传送开始 {0}秒 后到达 目的地 §d世界: {1} §3X: {2} Z: {3}!'
|
||||||
|
accept: '§a已接受玩家: {0} §a的传送请求!'
|
||||||
|
acceptfrom: '§a玩家: {0}§a接受了您的请求!'
|
||||||
|
deny: '§c已拒绝玩家: {0} §c的传送请求!'
|
||||||
|
denyfrom: '§c玩家: {0}§c拒绝了您的请求!'
|
||||||
|
offline: '§c目标玩家已离线 本次传送取消!'
|
||||||
|
none: '§c没有找到需要传送的队列!'
|
||||||
|
sethomesuccess: '§a家设置成功!'
|
||||||
|
sethomeerror: '§c请站在床上设置家!'
|
||||||
|
homelose: '§c你的床丢失了或者被方块阻挡了!'
|
||||||
|
top: '&a已传送至当前位置最高方块!'
|
||||||
|
tpsend: '§a已经向玩家 {0} §a发送传送请求!'
|
||||||
|
tpa: '§a玩家: {0}§a请求传送到你这里!'
|
||||||
|
tphere: '§b玩家: {0}§b请求你传送到他那里!'
|
||||||
|
tpaccept: '§a输入命令/tpaccept 或 /tpok 接受传送'
|
||||||
|
tpdeny: '§c输入命令/tpdeny 或 /tpno 拒绝传送'
|
||||||
|
nobackloc: '§c未找到可以Back的地点!'
|
||||||
|
|
||||||
|
|
||||||
|
Language.getMessage("Teleport.none")
|
Loading…
Reference in New Issue
Block a user