mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2025-01-06 12:18:56 +00:00
添加基础命令...
Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
parent
2f868049b8
commit
5a19aa12ba
@ -10,9 +10,11 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.SimpleEssential.command.CommandBack;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTop;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTpa;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTpaccept;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTpdeny;
|
||||
@ -45,10 +47,9 @@ public class SimpleEssential extends JavaPlugin {
|
||||
sender.sendMessage(e.getMessage());
|
||||
}
|
||||
}
|
||||
sender.sendMessage("命令参数错误!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
sender.sendMessage("循环结束!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -59,16 +60,17 @@ public class SimpleEssential extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
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));
|
||||
|
||||
this.registerCommands();
|
||||
this.registerEvents();
|
||||
tpcontrol = new TeleportControl(this);
|
||||
getServer().getPluginManager().registerEvents(new PlayerLocationListen(this), this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册监听
|
||||
*/
|
||||
private void registerEvents() {
|
||||
registerEvent(new PlayerLocationListen(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,13 +78,36 @@ public class SimpleEssential extends JavaPlugin {
|
||||
Config.load(this, "1.0");
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册命令
|
||||
*/
|
||||
public void registerCommands() {
|
||||
commandlist = new ArrayList<SimpleEssentialCommand>();
|
||||
registerCommand(new CommandTpa(this));
|
||||
registerCommand(new CommandTop(this));
|
||||
registerCommand(new CommandTpaccept(this));
|
||||
registerCommand(new CommandTpdeny(this));
|
||||
registerCommand(new CommandTphere(this));
|
||||
registerCommand(new CommandBack(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册命令
|
||||
*
|
||||
* @param subCommand
|
||||
* @param command
|
||||
* - 被注册的命令类
|
||||
*/
|
||||
public void registerSubCommand(SimpleEssentialCommand subCommand) {
|
||||
commandlist.add(subCommand);
|
||||
public void registerCommand(SimpleEssentialCommand command) {
|
||||
commandlist.add(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册事件
|
||||
*
|
||||
* @param listener
|
||||
* - 被注册的事件类
|
||||
*/
|
||||
public void registerEvent(Listener listener) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
}
|
||||
}
|
||||
|
45
src/cn/citycraft/SimpleEssential/command/CommandHome.java
Normal file
45
src/cn/citycraft/SimpleEssential/command/CommandHome.java
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午2:04:05
|
||||
* TODO
|
||||
*/
|
||||
public class CommandHome extends SimpleEssentialCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandHome(SimpleEssential main) {
|
||||
super("home", "eshome");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Location loc = p.getBedSpawnLocation();
|
||||
plugin.tpcontrol.magicTeleport(p, loc);
|
||||
}
|
||||
}
|
50
src/cn/citycraft/SimpleEssential/command/CommandSetHome.java
Normal file
50
src/cn/citycraft/SimpleEssential/command/CommandSetHome.java
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午2:04:05
|
||||
* TODO
|
||||
*/
|
||||
public class CommandSetHome extends SimpleEssentialCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandSetHome(SimpleEssential main) {
|
||||
super("sethome", "essethome");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Block b = p.getLocation().add(0, -1, 0).getBlock();
|
||||
if (b.getType() == Material.BED_BLOCK) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
48
src/cn/citycraft/SimpleEssential/command/CommandTop.java
Normal file
48
src/cn/citycraft/SimpleEssential/command/CommandTop.java
Normal file
@ -0,0 +1,48 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午2:04:05
|
||||
* TODO
|
||||
*/
|
||||
public class CommandTop extends SimpleEssentialCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandTop(SimpleEssential main) {
|
||||
super("top", "estop");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Location loc = p.getLocation();
|
||||
int top = loc.getWorld().getHighestBlockYAt(loc);
|
||||
loc.setY(top);
|
||||
p.teleport(loc);
|
||||
p.sendMessage("&a已传送至当前位置最高方块!");
|
||||
}
|
||||
}
|
@ -41,11 +41,11 @@ public class CommandTpa extends SimpleEssentialCommand {
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage("玩家 " + args[0] + " 不存在或不在线!");
|
||||
sender.sendMessage("§c玩家 " + args[0] + " 不存在或不在线!");
|
||||
return;
|
||||
}
|
||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPA);
|
||||
sender.sendMessage("已经向玩家 " + target.getDisplayName() + " 发送传送请求!");
|
||||
sender.sendMessage("§a已经向玩家 " + target.getDisplayName() + " §a发送传送请求!");
|
||||
target.sendMessage(new String[] {
|
||||
"§a玩家: " + sender.getName() + "§a请求传送到你这里!",
|
||||
"§a输入命令/tpaccept 或 /tpok 接受传送",
|
||||
|
@ -26,13 +26,16 @@ public class CommandTphere extends SimpleEssentialCommand {
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage("玩家 " + args[0] + " 不存在或不在线!");
|
||||
sender.sendMessage("§c玩家 " + args[0] + " 不存在或不在线!");
|
||||
return;
|
||||
}
|
||||
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 拒绝传送" });
|
||||
sender.sendMessage("§a已经向玩家 " + target.getDisplayName() + " §a发送传送请求!");
|
||||
target.sendMessage(new String[] {
|
||||
"§b玩家: " + sender.getName() + "§b请求你传送到他那里!",
|
||||
"§a输入命令/tpaccept 或 /tpok 接受传送",
|
||||
"§c输入命令/tpdeny 或 /tpno 拒绝传送"
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
48
src/cn/citycraft/SimpleEssential/config/PlayerConfig.java
Normal file
48
src/cn/citycraft/SimpleEssential/config/PlayerConfig.java
Normal file
@ -0,0 +1,48 @@
|
||||
package cn.citycraft.SimpleEssential.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PlayerConfig extends ConfigLoader {
|
||||
private static String CONFIG_FOLDER = "userdate";
|
||||
private static FileConfig instance;
|
||||
private static File file;
|
||||
|
||||
public PlayerConfig(Plugin p, String player) {
|
||||
super(p, CONFIG_FOLDER + File.separator + player + ".yml", false);
|
||||
file = new File(p.getDataFolder(), CONFIG_FOLDER + File.separator
|
||||
+ player + ".yml");
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public static FileConfig getInstance(Plugin p, Player player) {
|
||||
new PlayerConfig(p, player.getName());
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static FileConfig getInstance(Plugin p, String player) {
|
||||
new PlayerConfig(p, player);
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getMessage(String path) {
|
||||
String message = instance.getString(path).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();
|
||||
}
|
||||
}
|
||||
}
|
@ -126,6 +126,18 @@ public class TeleportControl {
|
||||
player.sendMessage("§c未找到需要处理的队列!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 魔法传送
|
||||
*
|
||||
* @param player
|
||||
* - 被传送的玩家
|
||||
* @param loc
|
||||
* - 传送的地点
|
||||
*/
|
||||
public void magicTeleport(final Player player, final Location loc) {
|
||||
magicTeleport(player, loc, TpDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 魔法传送
|
||||
*
|
||||
@ -143,6 +155,7 @@ public class TeleportControl {
|
||||
+ " §3X: " + loc.getBlockX() + " Z: " + loc.getBlockZ() + "!");
|
||||
List<PotionEffect> pe = new ArrayList<PotionEffect>();
|
||||
pe.add(new PotionEffect(PotionEffectType.SLOW, petime, 255));
|
||||
pe.add(new PotionEffect(PotionEffectType.CONFUSION, petime, 255));
|
||||
player.addPotionEffects(pe);
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
long timeoutmark = System.currentTimeMillis() + delay * 1000;
|
||||
|
@ -39,7 +39,18 @@ commands:
|
||||
usage: §b使用/back 回到上一个TP地点!
|
||||
permission: se.back
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
top:
|
||||
description: 回到上一个TP地点
|
||||
aliases: [setop]
|
||||
usage: §b使用/top 传送到当前位置最高方块!
|
||||
permission: se.top
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
permissions:
|
||||
se.*:
|
||||
description: 简单基础插件所有权限!
|
||||
default: op
|
||||
children:
|
||||
se.user: true
|
||||
se.user:
|
||||
description: 简单基础插件玩家权限!
|
||||
default: true
|
||||
|
Loading…
Reference in New Issue
Block a user