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

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

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
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; 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 org.bukkit.plugin.java.JavaPlugin;
import cn.citycraft.SimpleEssential.config.Config; 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.handler.teleport.TeleportControl;
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen; import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
/** /**
* @author 蒋天蓓 * @author 蒋天蓓 2015年8月11日下午3:29:32 TODO
* 2015年8月11日下午3:29:32
* TODO
*/ */
public class SimpleEssential extends JavaPlugin { public class SimpleEssential extends JavaPlugin {
public TeleportControl tpcontrol; public TeleportControl tpcontrol;
private List<SimpleEssentialCommand> commandlist;
@Override @Override
public void onLoad() { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Config.load(this, "1.0"); 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 @Override
@@ -30,9 +59,30 @@ public class SimpleEssential extends JavaPlugin {
@Override @Override
public void onEnable() { 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); tpcontrol = new TeleportControl(this);
getServer().getPluginManager().registerEvents(new PlayerLocationListen(this), 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 蒋天蓓
* 2015年8月11日下午4: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; package cn.citycraft.SimpleEssential.handler.command;
@@ -11,9 +11,7 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.handler.SimpleEssentialCommand; import cn.citycraft.SimpleEssential.handler.SimpleEssentialCommand;
/** /**
* @author 蒋天蓓 * @author 蒋天蓓 2015年8月12日下午2:04:05 TODO
* 2015年8月12日下午2:04:05
* TODO
*/ */
public class CommandBack extends SimpleEssentialCommand { public class CommandBack extends SimpleEssentialCommand {
SimpleEssential plugin; SimpleEssential plugin;
@@ -22,13 +20,13 @@ public class CommandBack extends SimpleEssentialCommand {
* @param name * @param name
*/ */
public CommandBack(SimpleEssential main) { public CommandBack(SimpleEssential main) {
super("tpback"); super("back", "seback");
this.plugin = main; this.plugin = main;
} }
@Override @Override
public String getPossibleArguments() { public void execute(CommandSender sender, String label, String[] args) throws CommandException {
return ""; plugin.tpcontrol.back((Player) sender);
} }
@Override @Override
@@ -37,7 +35,7 @@ public class CommandBack extends SimpleEssentialCommand {
} }
@Override @Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException { public String getPossibleArguments() {
plugin.tpcontrol.back((Player) sender); return "";
} }
} }

View File

@@ -1,5 +1,5 @@
/** /**
* *
*/ */
package cn.citycraft.SimpleEssential.handler.command; package cn.citycraft.SimpleEssential.handler.command;
@@ -13,31 +13,16 @@ import cn.citycraft.SimpleEssential.handler.SimpleEssentialCommand;
import cn.citycraft.SimpleEssential.handler.teleport.TeleportType; import cn.citycraft.SimpleEssential.handler.teleport.TeleportType;
/** /**
* @author 蒋天蓓 * @author 蒋天蓓 2015年8月12日下午2:04:05 TODO
* 2015年8月12日下午2:04:05
* TODO
*/ */
public class CommandTphere extends SimpleEssentialCommand { public class CommandTphere extends SimpleEssentialCommand {
SimpleEssential plugin; SimpleEssential plugin;
/**
* @param name
*/
public CommandTphere(SimpleEssential main) { public CommandTphere(SimpleEssential main) {
super("tphere", "tph"); super("tphere", "tph");
this.plugin = main; this.plugin = main;
} }
@Override
public String getPossibleArguments() {
return "<目标玩家>";
}
@Override
public int getMinimumArguments() {
return 1;
}
@Override @Override
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]);
@@ -47,10 +32,17 @@ public class CommandTphere extends SimpleEssentialCommand {
} }
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH); plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH);
sender.sendMessage("已经向玩家 " + target.getDisplayName() + " 发送传送请求!"); sender.sendMessage("已经向玩家 " + target.getDisplayName() + " 发送传送请求!");
target.sendMessage(new String[] { target.sendMessage(new String[] { "§b玩家: " + sender.getName() + "§b请求你传送到他那里!",
"§b玩家: " + sender.getName() + "§b请求你传送到他那里!", "§a输入命令/tpaccept 或 /tpok 接受传送", "§c输入命令/tpdeny 或 /tpno 拒绝传送" });
"§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; package cn.citycraft.SimpleEssential.handler.teleport;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
@@ -15,37 +17,41 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.config.Config; import cn.citycraft.SimpleEssential.config.Config;
/** /**
* @author 蒋天蓓 * @author 蒋天蓓 2015年8月12日下午2:26:10 传送控制类
* 2015年8月12日下午2:26:10
* 传送控制类
*/ */
public class TeleportControl { 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, TeleportInfo> teleportList = new HashMap<Player, TeleportInfo>();
protected HashMap<Player, Location> lastlocList = new HashMap<Player, Location>(); protected HashMap<Player, Location> lastlocList = new HashMap<Player, Location>();
private SimpleEssential plugin; private SimpleEssential plugin;
private int TpDelay = Config.getInstance().getInt("Teleport.delay", 3); private int TpDelay = Config.getInstance().getInt("Teleport.delay", 3);
public TeleportControl(SimpleEssential plugin) { public TeleportControl(SimpleEssential plugin) {
this.plugin = 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 * @param player
* - 执行的玩家 * - 执行的玩家
*/ */
@@ -72,9 +78,38 @@ public class TeleportControl {
player.sendMessage("§c未找到需要处理的队列!"); 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 * @param player
* - 执行的玩家 * - 执行的玩家
*/ */
@@ -91,36 +126,9 @@ public class TeleportControl {
player.sendMessage("§c未找到需要处理的队列!"); 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 player
* - 被传送的玩家 * - 被传送的玩家
* @param loc * @param loc
@@ -129,10 +137,13 @@ 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;
setLastloc(player, player.getLocation()); setLastloc(player, player.getLocation());
player.sendMessage("§a传送开始 " + delay + "秒 后到达目的地 世界: " + loc.getWorld() + " X: " player.sendMessage("§a传送开始 " + delay + "秒 后到达目的地 §d世界: " + loc.getWorld().getName()
+ loc.getX() + " Z: " + loc.getZ() + "!"); + " §3X: " + loc.getBlockX() + " Z: " + loc.getBlockZ() + "!");
player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, delay, 255)); List<PotionEffect> pe = new ArrayList<PotionEffect>();
pe.add(new PotionEffect(PotionEffectType.SLOW, petime, 255));
player.addPotionEffects(pe);
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() { plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
long timeoutmark = System.currentTimeMillis() + delay * 1000; long timeoutmark = System.currentTimeMillis() + delay * 1000;
long lrng = 0; long lrng = 0;
@@ -140,11 +151,12 @@ public class TeleportControl {
@Override @Override
public void run() { public void run() {
while (System.currentTimeMillis() < timeoutmark) { while (System.currentTimeMillis() < timeoutmark) {
if (player.isOnline()) if (player.isOnline()) {
pEffect(player.getLocation(), lrng); pEffect(player.getLocation(), lrng);
}
lrng++; lrng++;
try { try {
Thread.sleep(50); Thread.sleep(128);
} catch (Exception e) { } catch (Exception e) {
} }
} }
@@ -153,27 +165,22 @@ public class TeleportControl {
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
if (player.isOnline()) if (player.isOnline()) {
player.teleport(loc); player.teleport(loc);
}
} }
}, delay * 20); }, delay * 20);
} }
/** /**
* 粒子发生器 * 设置最后的地址数据
* *
* @param player
* - 玩家
* @param loc * @param loc
* - 粒子产生的地点 * - 地点
* @param range
* - 粒子的数量
*/ */
static void pEffect(Location loc, long range) { public void setLastloc(Player player, Location loc) {
int i; lastlocList.put(player, loc);
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);
}
} }
} }

View File

@@ -9,78 +9,3 @@ pluginname: '&6[&b保护系统&6]&r'
Teleport: Teleport:
#所有传送延时 #所有传送延时
delay: 3 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 拒绝传送或邀请! usage: §b使用/tpdeny 拒绝传送或邀请!
permission: se.tpdeny permission: se.tpdeny
permission-message: §c你没有 <permission> 的权限来执行此命令! permission-message: §c你没有 <permission> 的权限来执行此命令!
back:
description: 回到上一个TP地点
aliases: [seback]
usage: §b使用/back 回到上一个TP地点!
permission: se.back
permission-message: §c你没有 <permission> 的权限来执行此命令!
permissions: permissions:
se.*: se.user:
description: 简单基础插件所有权限! description: 简单基础插件玩家权限!
default: op default: true
children: children:
se.tpa: true se.tpa: true
se.tphere: true se.tphere: true
se.tpaccept: true se.tpaccept: true
se.tpdeny: true se.tpdeny: true
se.back: true