基本传送指令修改完成...

Signed-off-by: j502647092 <jtb1@163.com>
pull/1/HEAD
j502647092 2015-08-12 23:11:20 +08:00
parent 4f376492a8
commit 7bc380da7d
7 changed files with 164 additions and 261 deletions

View File

@ -1,26 +1,55 @@
/**
*
*
*/
package cn.citycraft.SimpleEssential;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.SimpleEssential.config.Config;
import cn.citycraft.SimpleEssential.handler.SimpleEssentialCommandHandler;
import cn.citycraft.SimpleEssential.handler.SimpleEssentialCommand;
import cn.citycraft.SimpleEssential.handler.command.CommandBack;
import cn.citycraft.SimpleEssential.handler.command.CommandTpa;
import cn.citycraft.SimpleEssential.handler.command.CommandTpaccept;
import cn.citycraft.SimpleEssential.handler.command.CommandTpdeny;
import cn.citycraft.SimpleEssential.handler.command.CommandTphere;
import cn.citycraft.SimpleEssential.handler.teleport.TeleportControl;
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
/**
* @author
* 20158113:29:32
* TODO
* @author 20158113:29:32 TODO
*/
public class SimpleEssential extends JavaPlugin {
public TeleportControl tpcontrol;
private List<SimpleEssentialCommand> commandlist;
@Override
public void onLoad() {
Config.load(this, "1.0");
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
for (SimpleEssentialCommand command : commandlist) {
if (command.isValidTrigger(label)) {
if (!command.hasPermission(sender)) {
sender.sendMessage(ChatColor.RED + "你没有此命令的权限.");
return true;
}
if (args.length >= command.getMinimumArguments()) {
try {
command.execute(sender, label, args);
return true;
} catch (CommandException e) {
sender.sendMessage(e.getMessage());
}
}
sender.sendMessage("命令参数错误!");
}
}
sender.sendMessage("循环结束!");
return true;
}
@Override
@ -30,9 +59,30 @@ public class SimpleEssential extends JavaPlugin {
@Override
public void onEnable() {
new SimpleEssentialCommandHandler();
commandlist = new ArrayList<SimpleEssentialCommand>();
// registerSubCommand(new AddlineCommand());
registerSubCommand(new CommandTpa(this));
registerSubCommand(new CommandTpaccept(this));
registerSubCommand(new CommandTpdeny(this));
registerSubCommand(new CommandTphere(this));
registerSubCommand(new CommandBack(this));
tpcontrol = new TeleportControl(this);
getServer().getPluginManager().registerEvents(new PlayerLocationListen(this), this);
}
@Override
public void onLoad() {
Config.load(this, "1.0");
}
/**
*
*
* @param subCommand
* -
*/
public void registerSubCommand(SimpleEssentialCommand subCommand) {
commandlist.add(subCommand);
}
}

View File

@ -1,77 +0,0 @@
/**
*
*/
package cn.citycraft.SimpleEssential.handler;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandException;
import org.bukkit.command.CommandSender;
import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.handler.command.CommandBack;
import cn.citycraft.SimpleEssential.handler.command.CommandTpa;
import cn.citycraft.SimpleEssential.handler.command.CommandTpaccept;
import cn.citycraft.SimpleEssential.handler.command.CommandTpdeny;
/**
* @author
* 20158114:00:35
* TODO
*/
public class SimpleEssentialCommandHandler extends SimpleEssential {
private List<SimpleEssentialCommand> commandlist;
public SimpleEssentialCommandHandler() {
commandlist = new ArrayList<SimpleEssentialCommand>();
// registerSubCommand(new AddlineCommand());
registerSubCommand(new CommandTpa(this));
registerSubCommand(new CommandTpaccept(this));
registerSubCommand(new CommandTpdeny(this));
registerSubCommand(new CommandBack(this));
}
/**
*
*
* @param subCommand
* -
*/
public void registerSubCommand(SimpleEssentialCommand subCommand) {
commandlist.add(subCommand);
}
/**
*
*
* @return
*/
public List<SimpleEssentialCommand> getSubCommands() {
return new ArrayList<SimpleEssentialCommand>(commandlist);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
for (SimpleEssentialCommand command : commandlist) {
if (command.isValidTrigger(label)) {
if (!command.hasPermission(sender)) {
sender.sendMessage(ChatColor.RED + "你没有此命令的权限.");
return true;
}
if (args.length >= command.getMinimumArguments()) {
try {
command.execute(sender, label, args);
return true;
} catch (CommandException e) {
sender.sendMessage(e.getMessage());
}
}
}
}
return false;
}
}

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package cn.citycraft.SimpleEssential.handler.command;
@ -11,9 +11,7 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.handler.SimpleEssentialCommand;
/**
* @author
* 20158122:04:05
* TODO
* @author 20158122:04:05 TODO
*/
public class CommandBack extends SimpleEssentialCommand {
SimpleEssential plugin;
@ -22,13 +20,13 @@ public class CommandBack extends SimpleEssentialCommand {
* @param name
*/
public CommandBack(SimpleEssential main) {
super("tpback");
super("back", "seback");
this.plugin = main;
}
@Override
public String getPossibleArguments() {
return "";
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
plugin.tpcontrol.back((Player) sender);
}
@Override
@ -37,7 +35,7 @@ public class CommandBack extends SimpleEssentialCommand {
}
@Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
plugin.tpcontrol.back((Player) sender);
public String getPossibleArguments() {
return "";
}
}

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package cn.citycraft.SimpleEssential.handler.command;
@ -13,31 +13,16 @@ import cn.citycraft.SimpleEssential.handler.SimpleEssentialCommand;
import cn.citycraft.SimpleEssential.handler.teleport.TeleportType;
/**
* @author
* 20158122:04:05
* TODO
* @author 20158122:04:05 TODO
*/
public class CommandTphere extends SimpleEssentialCommand {
SimpleEssential plugin;
/**
* @param name
*/
public CommandTphere(SimpleEssential main) {
super("tphere", "tph");
this.plugin = main;
}
@Override
public String getPossibleArguments() {
return "<目标玩家>";
}
@Override
public int getMinimumArguments() {
return 1;
}
@Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
Player target = Bukkit.getPlayer(args[0]);
@ -47,10 +32,17 @@ public class CommandTphere extends SimpleEssentialCommand {
}
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH);
sender.sendMessage("已经向玩家 " + target.getDisplayName() + " 发送传送请求!");
target.sendMessage(new String[] {
"§b玩家: " + sender.getName() + "§b请求你传送到他那里!",
"§a输入命令/tpaccept 或 /tpok 接受传送",
"§c输入命令/tpdeny 或 /tpno 拒绝传送"
});
target.sendMessage(new String[] { "§b玩家: " + sender.getName() + "§b请求你传送到他那里!",
"§a输入命令/tpaccept 或 /tpok 接受传送", "§c输入命令/tpdeny 或 /tpno 拒绝传送" });
}
@Override
public int getMinimumArguments() {
return 1;
}
@Override
public String getPossibleArguments() {
return "<目标玩家>";
}
}

View File

@ -1,9 +1,11 @@
/**
*
*
*/
package cn.citycraft.SimpleEssential.handler.teleport;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Effect;
import org.bukkit.Location;
@ -15,37 +17,41 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.config.Config;
/**
* @author
* 20158122:26:10
*
* @author 20158122:26:10
*/
public class TeleportControl {
/**
*
*
* @param loc
* -
* @param range
* -
*/
static void pEffect(Location loc, long range) {
int i;
if (range < 2) {
range = 2;
}
for (i = 0; i < range; i++) {
loc.getWorld().playEffect(loc, Effect.LAVA_POP, 10, 100);
loc.getWorld().playEffect(loc, Effect.PORTAL, 10, 100);
}
}
protected HashMap<Player, TeleportInfo> teleportList = new HashMap<Player, TeleportInfo>();
protected HashMap<Player, Location> lastlocList = new HashMap<Player, Location>();
private SimpleEssential plugin;
private int TpDelay = Config.getInstance().getInt("Teleport.delay", 3);
public TeleportControl(SimpleEssential plugin) {
this.plugin = plugin;
}
/**
*
*
* @param player
* -
* @param target
* -
* @param tptype
* -
*/
public void addtp(Player player, Player target, TeleportType tptype) {
teleportList.put(target, new TeleportInfo(player, tptype));
}
/**
*
*
*
* @param player
* -
*/
@ -72,9 +78,38 @@ public class TeleportControl {
player.sendMessage("§c未找到需要处理的队列!");
}
/**
*
*
* @param player
* -
* @param target
* -
* @param tptype
* -
*/
public void addtp(Player player, Player target, TeleportType tptype) {
teleportList.put(target, new TeleportInfo(player, tptype));
}
/**
*
*
* @param player
* -
*/
public void back(Player player) {
Location loc = lastlocList.get(player);
if (loc != null) {
magicTeleport(player, loc, 3);
} else {
player.sendMessage("§c未找到可以Back的地点!");
}
}
/**
*
*
*
* @param player
* -
*/
@ -91,36 +126,9 @@ public class TeleportControl {
player.sendMessage("§c未找到需要处理的队列!");
}
/**
*
*
* @param player
* -
* @param loc
* -
*/
public void setLastloc(Player player, Location loc) {
lastlocList.put(player, loc);
}
/**
*
*
* @param player
* -
*/
public void back(Player player) {
Location loc = lastlocList.get(player);
if (loc != null) {
magicTeleport(player, loc, 3);
} else {
player.sendMessage("§c未找到可以Back的地点!");
}
}
/**
*
*
*
* @param player
* -
* @param loc
@ -129,10 +137,13 @@ public class TeleportControl {
* -
*/
public void magicTeleport(final Player player, final Location loc, final int delay) {
int petime = delay * 20 + 10;
setLastloc(player, player.getLocation());
player.sendMessage("§a传送开始 " + delay + "秒 后到达目的地 世界: " + loc.getWorld() + " X: "
+ loc.getX() + " Z: " + loc.getZ() + "!");
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, delay, 255));
player.sendMessage("§a传送开始 " + delay + "秒 后到达目的地 §d世界: " + loc.getWorld().getName()
+ " §3X: " + loc.getBlockX() + " Z: " + loc.getBlockZ() + "!");
List<PotionEffect> pe = new ArrayList<PotionEffect>();
pe.add(new PotionEffect(PotionEffectType.SLOW, petime, 255));
player.addPotionEffects(pe);
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
long timeoutmark = System.currentTimeMillis() + delay * 1000;
long lrng = 0;
@ -140,11 +151,12 @@ public class TeleportControl {
@Override
public void run() {
while (System.currentTimeMillis() < timeoutmark) {
if (player.isOnline())
if (player.isOnline()) {
pEffect(player.getLocation(), lrng);
}
lrng++;
try {
Thread.sleep(50);
Thread.sleep(128);
} catch (Exception e) {
}
}
@ -153,27 +165,22 @@ public class TeleportControl {
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
if (player.isOnline())
if (player.isOnline()) {
player.teleport(loc);
}
}
}, delay * 20);
}
/**
*
*
*
*
* @param player
* -
* @param loc
* -
* @param range
* -
* -
*/
static void pEffect(Location loc, long range) {
int i;
if (range < 2)
range = 2;
for (i = 0; i < range; i++) {
loc.getWorld().playEffect(loc, Effect.LAVA_POP, 10, 100);
loc.getWorld().playEffect(loc, Effect.PORTAL, 10, 100);
}
public void setLastloc(Player player, Location loc) {
lastlocList.put(player, loc);
}
}

View File

@ -9,78 +9,3 @@ pluginname: '&6[&b保护系统&6]&r'
Teleport:
#所有传送延时
delay: 3
#登陆提示
Tip:
#是否开启
Enable: false
Message:
- '&a服务器已开启保护功能'
- '&c将会实时监控您的操作'
- '&e挖矿请带上火把或药水'
#耕地保护配置
BreakFarm:
#是否开启
Enable: true
Tip: '&c服务器已开启耕地保护请不要踩庄稼'
#爆炸保护配置
Explosion:
#是否开启
Enable: true
#高频红石检测
HighRedstone:
#是否开启
Enable: true
Maxevents: 35
Find: '&c发现高频红石 &3世界%world% &d坐标 X:%x% Y:%y% Z:%z% §a已清理'
Check: '&c高频红石数据监测 &5上述高频红石由 &6玩家&a%player%& 6放置'
Admin: '&c发现您放置高频红石,由于您是管理员,在服务器重启之前此高频将不会被清理,请用完后及时清理!'
#防止无限夜视
Nightvision:
#是否开启
Enable: true
Tip: '&c为防止无限夜视作弊已阻止挖矿请插火把或用夜视药水'
#安全地狱门
SafeNetherDoor:
#是否开启
Enable: true
Tip: '&5为防止您卡在地狱门现在将您传送回主城'
Set: '&a新的传送点已设置'
World: world
X: 0
Y: 70
Z: 0
#刷屏保护
Spam:
#是否开启
Enable: true
ChatWait: 3
SameChatWait: 8
CommandWait: 2
SameCommandWait: 3
MuteCheck: 3
MuteReset: 3
TooMuchChat: '请不要短时间内发送大量消息'
TooMuchSameChat: '请不要短时间内发送相同的信息'
TooMuchCommand: '请不要短时间内发送大量命令'
TooMuchSameCommand: '请不要短时间内发送相同的命令'
MuteOn: '&a已允许玩家 %player% &a聊天'
MuteOff: '§c已禁止玩家 %player% §c聊天'
OffLine: '&c玩家不存在或不在线'
NotMute: '&c玩家未被禁言或不存在'
AdminChatOn: '&a服务器已开启管理员聊天'
AdminChatOff: '&c服务器已关闭管理员聊天'
AdminChat: '&c服务器已开启管理员聊天'
MuteMsg: '&c您由于多次刷屏已被禁言请联系管理解禁'

View File

@ -33,12 +33,20 @@ commands:
usage: §b使用/tpdeny 拒绝传送或邀请!
permission: se.tpdeny
permission-message: §c你没有 <permission> 的权限来执行此命令!
back:
description: 回到上一个TP地点
aliases: [seback]
usage: §b使用/back 回到上一个TP地点!
permission: se.back
permission-message: §c你没有 <permission> 的权限来执行此命令!
permissions:
se.*:
description: 简单基础插件所有权限!
default: op
se.user:
description: 简单基础插件玩家权限!
default: true
children:
se.tpa: true
se.tphere: true
se.tpaccept: true
se.tpdeny: true
se.back: true