mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2025-11-25 21:46:03 +00:00
165
src/main/java/cn/citycraft/SimpleEssential/SimpleEssential.java
Normal file
165
src/main/java/cn/citycraft/SimpleEssential/SimpleEssential.java
Normal file
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.SimpleEssential.command.BaseCommand;
|
||||
import cn.citycraft.SimpleEssential.command.CommandBack;
|
||||
import cn.citycraft.SimpleEssential.command.CommandEnchantBench;
|
||||
import cn.citycraft.SimpleEssential.command.CommandHat;
|
||||
import cn.citycraft.SimpleEssential.command.CommandHome;
|
||||
import cn.citycraft.SimpleEssential.command.CommandSetHome;
|
||||
import cn.citycraft.SimpleEssential.command.CommandSetSpawn;
|
||||
import cn.citycraft.SimpleEssential.command.CommandSpawn;
|
||||
import cn.citycraft.SimpleEssential.command.CommandSuicide;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTop;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTpa;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTpaccept;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTpdeny;
|
||||
import cn.citycraft.SimpleEssential.command.CommandTphere;
|
||||
import cn.citycraft.SimpleEssential.command.CommandWorkBench;
|
||||
import cn.citycraft.SimpleEssential.config.Config;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.inventory.InventoryControl;
|
||||
import cn.citycraft.SimpleEssential.listen.PlayerInventoryViewListen;
|
||||
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportControl;
|
||||
import cn.citycraft.SimpleEssential.utils.VersionChecker;
|
||||
|
||||
/**
|
||||
* 简单基础插件
|
||||
*
|
||||
* @author 蒋天蓓 2015年8月11日下午3:29:32
|
||||
*/
|
||||
public class SimpleEssential extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* 传送控制
|
||||
*/
|
||||
public TeleportControl tpcontrol;
|
||||
/**
|
||||
* 容器界面控制
|
||||
*/
|
||||
public InventoryControl invcontrol;
|
||||
/**
|
||||
* 命令监听列表
|
||||
*/
|
||||
private List<BaseCommand> commandlist;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void initInventoryControl() {
|
||||
invcontrol = new InventoryControl(this);
|
||||
}
|
||||
|
||||
private void initTeleportControl() {
|
||||
int tpdelay = Config.getInstance().getInt("Teleport.delay", 3);
|
||||
String tpcontorlname = Config.getMessage("Teleport.name");
|
||||
tpcontrol = new TeleportControl(this, tpcontorlname, tpdelay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (BaseCommand command : commandlist) {
|
||||
if (command.isValidTrigger(label)) {
|
||||
if (!command.hasPermission(sender)) {
|
||||
sender.sendMessage(Language.getMessage("Base.no-permission"));
|
||||
return true;
|
||||
}
|
||||
if (command.isOnlyPlayerExecutable() && !(sender instanceof Player)) {
|
||||
sender.sendMessage(Language.getMessage("Base.playercommand"));
|
||||
return true;
|
||||
}
|
||||
if (args.length >= command.getMinimumArguments()) {
|
||||
try {
|
||||
command.execute(sender, label, args);
|
||||
return true;
|
||||
} catch (CommandException e) {
|
||||
sender.sendMessage(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
invcontrol.clearAllEnchantBench();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.initTeleportControl();
|
||||
this.initInventoryControl();
|
||||
this.registerCommands();
|
||||
this.registerEvents();
|
||||
new VersionChecker(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
Config.load(this, "1.0");
|
||||
Language.load(this, "1.0");
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册命令
|
||||
*
|
||||
* @param command
|
||||
* - 被注册的命令类
|
||||
*/
|
||||
public void registerCommand(BaseCommand command) {
|
||||
commandlist.add(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册命令
|
||||
*/
|
||||
public void registerCommands() {
|
||||
commandlist = new ArrayList<BaseCommand>();
|
||||
registerCommand(new CommandTpa(this));
|
||||
registerCommand(new CommandTop(this));
|
||||
registerCommand(new CommandTpaccept(this));
|
||||
registerCommand(new CommandTpdeny(this));
|
||||
registerCommand(new CommandTphere(this));
|
||||
registerCommand(new CommandBack(this));
|
||||
registerCommand(new CommandSetHome(this));
|
||||
registerCommand(new CommandHome(this));
|
||||
registerCommand(new CommandHat(this));
|
||||
registerCommand(new CommandSuicide(this));
|
||||
registerCommand(new CommandEnchantBench(this));
|
||||
registerCommand(new CommandWorkBench(this));
|
||||
registerCommand(new CommandSetSpawn(this));
|
||||
registerCommand(new CommandSpawn(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册事件
|
||||
*
|
||||
* @param listener
|
||||
* - 被注册的事件类
|
||||
*/
|
||||
public void registerEvent(Listener listener) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册事件
|
||||
*/
|
||||
private void registerEvents() {
|
||||
registerEvent(new PlayerLocationListen(this));
|
||||
registerEvent(new PlayerInventoryViewListen(this));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
* 基础命令类
|
||||
*
|
||||
* @author 蒋天蓓 2015年8月12日下午12:49:34
|
||||
*/
|
||||
public abstract class BaseCommand {
|
||||
private String name;
|
||||
private String permission;
|
||||
private String[] aliases;
|
||||
|
||||
public BaseCommand(String name) {
|
||||
this(name, new String[0]);
|
||||
}
|
||||
|
||||
public BaseCommand(String name, String... aliases) {
|
||||
this.name = name;
|
||||
this.aliases = aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令参数
|
||||
*
|
||||
* @param sender
|
||||
* - 命令发送者
|
||||
* @param label
|
||||
* - 命令
|
||||
* @param args
|
||||
* - 命令附加参数
|
||||
* @throws CommandException
|
||||
* - 命令异常
|
||||
*/
|
||||
public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException;
|
||||
|
||||
/**
|
||||
* 获得最小参数个数
|
||||
*
|
||||
* @return 最小参数个数
|
||||
*/
|
||||
public abstract int getMinimumArguments();
|
||||
|
||||
/**
|
||||
* 获取命令名称
|
||||
*
|
||||
* @return 命令名称
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得命令权限
|
||||
*
|
||||
* @return 目录命令权限
|
||||
*/
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得可能的参数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract String getPossibleArguments();
|
||||
|
||||
/**
|
||||
* 检查Sender权限
|
||||
*
|
||||
* @param sender
|
||||
* - 命令发送者
|
||||
* @return 是否有权限执行命令
|
||||
*/
|
||||
public final boolean hasPermission(CommandSender sender) {
|
||||
if (permission == null)
|
||||
return true;
|
||||
return sender.hasPermission(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否只有玩家才能执行此命令
|
||||
*
|
||||
* @return 是否为玩家命令
|
||||
*/
|
||||
public abstract boolean isOnlyPlayerExecutable();
|
||||
|
||||
/**
|
||||
* 命令匹配检测
|
||||
*
|
||||
* @param name
|
||||
* - 命令
|
||||
* @return 是否匹配
|
||||
*/
|
||||
public final boolean isValidTrigger(String name) {
|
||||
if (this.name.equalsIgnoreCase(name))
|
||||
return true;
|
||||
if (aliases != null) {
|
||||
for (String alias : aliases) {
|
||||
if (alias.equalsIgnoreCase(name))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置命令权限
|
||||
*
|
||||
* @param permission
|
||||
* - 命令权限
|
||||
*/
|
||||
public void setPermission(String permission) {
|
||||
this.permission = permission;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
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
|
||||
*/
|
||||
public class CommandBack extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandBack(SimpleEssential main) {
|
||||
super("back", "seback");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.back((Player) sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
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
|
||||
*/
|
||||
public class CommandEnchantBench extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandEnchantBench(SimpleEssential main) {
|
||||
super("enchantbench", "seenchantbench", "eb", "seeb");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
plugin.invcontrol.openEnchantBench(p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
|
||||
/**
|
||||
* @Author 代小呆 created in 2015年8月16日下午1:44:22
|
||||
*/
|
||||
|
||||
public class CommandHat extends BaseCommand {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private SimpleEssential plugin;
|
||||
|
||||
public CommandHat(SimpleEssential main) {
|
||||
super("hat", "sehat");
|
||||
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;
|
||||
if (p.getItemInHand() == null) {
|
||||
sender.sendMessage(Language.getMessage("Hat.empty"));
|
||||
return;
|
||||
} else {
|
||||
ItemStack hand = p.getItemInHand();
|
||||
p.setItemInHand(null);
|
||||
ItemStack helmet = p.getInventory().getHelmet();
|
||||
if (!(helmet == null)) {
|
||||
p.getInventory().addItem(helmet);
|
||||
}
|
||||
p.getInventory().setHelmet(hand);
|
||||
sender.sendMessage(Language.getMessage("Hat.enjoy"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
|
||||
/**
|
||||
* 传送回家的命令
|
||||
*
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
*/
|
||||
public class CommandHome extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandHome(SimpleEssential main) {
|
||||
super("home", "eshome");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Location loc = p.getBedSpawnLocation();
|
||||
if (loc == null) {
|
||||
p.sendMessage(Language.getMessage("Teleport.homelose"));
|
||||
return;
|
||||
}
|
||||
plugin.tpcontrol.magicTeleport(p, loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
|
||||
/**
|
||||
* 设置家的命令
|
||||
*
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
*/
|
||||
public class CommandSetHome extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
public CommandSetHome(SimpleEssential main) {
|
||||
super("sethome", "essethome");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Block b = p.getLocation().getBlock();
|
||||
if (b.getType() == Material.BED_BLOCK) {
|
||||
p.setBedSpawnLocation(b.getLocation(), true);
|
||||
p.sendMessage(Language.getMessage("Teleport.sethomesuccess"));
|
||||
} else {
|
||||
p.sendMessage(Language.getMessage("Teleport.sethomeerror"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
*/
|
||||
public class CommandSetSpawn extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandSetSpawn(SimpleEssential main) {
|
||||
super("setspawn", "sesetspawn");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
Location loc = p.getLocation();
|
||||
p.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
p.sendMessage(Language.getMessage("Teleport.setspawn", p.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
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
|
||||
*/
|
||||
public class CommandSpawn extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandSpawn(SimpleEssential main) {
|
||||
super("spawn", "sespawn");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
plugin.tpcontrol.magicTeleport(p, p.getWorld().getSpawnLocation());
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
// import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
// import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.utils.EffectUtil;
|
||||
|
||||
// import cn.citycraft.SimpleEssential.utils.Randomer;
|
||||
|
||||
/**
|
||||
* 自杀命令
|
||||
*
|
||||
* @Author 代小呆 created in 2015年8月14日下午4:24:19
|
||||
*/
|
||||
|
||||
public class CommandSuicide extends BaseCommand {
|
||||
private SimpleEssential plugin;
|
||||
|
||||
public CommandSuicide(SimpleEssential main) {
|
||||
super("suicide", "sesuicide", "sd");
|
||||
this.plugin = main;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player p = (Player) sender;
|
||||
List<ItemStack> drops = Arrays.asList(p.getInventory().getContents());
|
||||
int deoppedexp = (int) Math.floor(p.getExp());
|
||||
String deathMessage = Language.getMessage("Suicide.msg");
|
||||
PlayerDeathEvent pd = new PlayerDeathEvent(p, drops, deoppedexp, deathMessage);
|
||||
plugin.getServer().getPluginManager().callEvent(pd);
|
||||
Bukkit.broadcastMessage(pd.getDeathMessage());
|
||||
EffectUtil.run(p.getLocation(), 10, Effect.POTION_BREAK);
|
||||
p.setHealth(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
|
||||
/**
|
||||
* 传送到顶部命令
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午2:04:05
|
||||
*
|
||||
*/
|
||||
public class CommandTop extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandTop(SimpleEssential main) {
|
||||
super("top", "estop");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@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(Language.getMessage("Teleport.top"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
||||
|
||||
/**
|
||||
* 玩家传送命令
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午2:04:05
|
||||
*
|
||||
*/
|
||||
public class CommandTpa extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandTpa(SimpleEssential main) {
|
||||
super("tpa");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@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]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(Language.getMessage("Base.offline", args[0]));
|
||||
return;
|
||||
}
|
||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPA);
|
||||
sender.sendMessage(Language.getMessage("Teleport.tpsend"));
|
||||
target.sendMessage(new String[] {
|
||||
Language.getMessage("Teleport.tpa", sender.getName()),
|
||||
Language.getMessage("Teleport.tpaccept"),
|
||||
Language.getMessage("Teleport.tpdeny")
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
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
|
||||
*
|
||||
*/
|
||||
public class CommandTpaccept extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandTpaccept(SimpleEssential main) {
|
||||
super("tpaccept", "tpok");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.accept((Player) sender);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
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
|
||||
*
|
||||
*/
|
||||
public class CommandTpdeny extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
public CommandTpdeny(SimpleEssential main) {
|
||||
super("tpdeny", "tpno");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
plugin.tpcontrol.accept((Player) sender);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
||||
|
||||
/**
|
||||
* 传送到玩家命令
|
||||
*
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
*/
|
||||
public class CommandTphere extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
public CommandTphere(SimpleEssential main) {
|
||||
super("tphere", "tph");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
sender.sendMessage(Language.getMessage("Base.offline", args[0]));
|
||||
return;
|
||||
}
|
||||
plugin.tpcontrol.addtp((Player) sender, Bukkit.getPlayer(args[0]), TeleportType.TPH);
|
||||
sender.sendMessage(Language.getMessage("Teleport.tpsend"));
|
||||
target.sendMessage(new String[] {
|
||||
Language.getMessage("Teleport.tphere", sender.getName()),
|
||||
Language.getMessage("Teleport.tpaccept"),
|
||||
Language.getMessage("Teleport.tpdeny")
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "<目标玩家>";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.command;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||
*/
|
||||
public class CommandWorkBench extends BaseCommand {
|
||||
SimpleEssential plugin;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
public CommandWorkBench(SimpleEssential main) {
|
||||
super("workbench", "seworkbench", "wb", "sewb");
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyPlayerExecutable() {
|
||||
return true;
|
||||
};
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
|
||||
Bukkit.getPlayer(sender.getName()).openWorkbench(null, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMinimumArguments() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPossibleArguments() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package cn.citycraft.SimpleEssential.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Config extends ConfigLoader {
|
||||
private static String CONFIG_NAME = "config.yml";
|
||||
private static FileConfig instance;
|
||||
private static File file;
|
||||
|
||||
public Config(Plugin p) {
|
||||
super(p, CONFIG_NAME);
|
||||
file = new File(p.getDataFolder(), CONFIG_NAME);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public Config(Plugin p, String ver) {
|
||||
super(p, CONFIG_NAME, ver);
|
||||
instance = super.getInstance();
|
||||
}
|
||||
|
||||
public static void load(Plugin p) {
|
||||
new Config(p);
|
||||
}
|
||||
|
||||
public static void load(Plugin p, String ver) {
|
||||
new Config(p, ver);
|
||||
}
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getMessage(String path) {
|
||||
String message = instance.getString(path);
|
||||
if (message != null && message.length() != 0)
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package cn.citycraft.SimpleEssential.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class ConfigLoader extends FileConfig {
|
||||
protected static FileConfig config;
|
||||
protected static boolean tip = true;
|
||||
protected static Plugin plugin;
|
||||
|
||||
public ConfigLoader(Plugin p, File file) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, null, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, null, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, String ver) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, ver, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, File file, String ver, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, file, ver, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), null, res);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, String ver) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), ver, true);
|
||||
}
|
||||
|
||||
public ConfigLoader(Plugin p, String filename, String ver, boolean res) {
|
||||
ConfigLoader.plugin = p;
|
||||
config = loadConfig(p, new File(p.getDataFolder(), filename), ver, true);
|
||||
}
|
||||
|
||||
public static FileConfig getInstance() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public FileConfig loadConfig(Plugin p, File file, String ver, boolean res) {
|
||||
tip = res;
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
p.getLogger().info("创建新的文件夹" + file.getParentFile().getAbsolutePath() + "...");
|
||||
}
|
||||
if (!file.exists()) {
|
||||
fileCreate(p, file, res);
|
||||
} else {
|
||||
if (ver != null) {
|
||||
FileConfig configcheck = init(file);
|
||||
String version = configcheck.getString("version");
|
||||
if (version == null || !version.equals(ver)) {
|
||||
p.getLogger().warning("配置文件: " + file.getName() + " 版本过低 正在升级...");
|
||||
try {
|
||||
configcheck.save(new File(file.getParent(), file.getName() + ".backup"));
|
||||
p.getLogger()
|
||||
.warning(
|
||||
"配置文件: " + file.getName() + " 已备份为 " + file.getName()
|
||||
+ ".backup !");
|
||||
} catch (IOException e) {
|
||||
p.getLogger().warning("配置文件: " + file.getName() + "备份失败!");
|
||||
}
|
||||
p.saveResource(file.getName(), true);
|
||||
p.getLogger().info("配置文件: " + file.getName() + "升级成功!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tip)
|
||||
p.getLogger().info("载入配置文件: " + file.getName() + (ver != null ? " 版本: " + ver : ""));
|
||||
return init(file);
|
||||
}
|
||||
|
||||
private void fileCreate(Plugin p, File file, boolean res) {
|
||||
if (res) {
|
||||
p.saveResource(file.getName(), false);
|
||||
} else {
|
||||
try {
|
||||
p.getLogger().info("创建新的配置文件" + file.getAbsolutePath() + "...");
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
p.getLogger().info("配置文件" + file.getName() + "创建失败...");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void saveError(File file) {
|
||||
plugin.getLogger().info("配置文件" + file.getName() + "保存错误...");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package cn.citycraft.SimpleEssential.config;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConstructor;
|
||||
import org.bukkit.configuration.file.YamlRepresenter;
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
/**
|
||||
* An implementation of {@link Configuration} which saves all files in Yaml. Note that this
|
||||
* implementation is not synchronized.
|
||||
*/
|
||||
public class FileConfig extends YamlConfiguration {
|
||||
|
||||
public static FileConfig init(File file) {
|
||||
return FileConfig.loadConfiguration(file);
|
||||
}
|
||||
|
||||
public static FileConfig loadConfiguration(File file) {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
FileConfig config = new FileConfig();
|
||||
try {
|
||||
config.load(file);
|
||||
} catch (FileNotFoundException ex) {
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load " + file, ex);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
protected final DumperOptions yamlOptions = new DumperOptions();
|
||||
|
||||
protected final Representer yamlRepresenter = new YamlRepresenter();
|
||||
|
||||
protected final Yaml yaml = new Yaml(new YamlConstructor(), yamlRepresenter, yamlOptions);
|
||||
|
||||
@Override
|
||||
public void load(File file) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
final FileInputStream stream = new FileInputStream(file);
|
||||
load(new InputStreamReader(stream, Charsets.UTF_8));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
||||
BufferedReader input = (reader instanceof BufferedReader) ? (BufferedReader) reader
|
||||
: new BufferedReader(reader);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
try {
|
||||
String line;
|
||||
while ((line = input.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append('\n');
|
||||
}
|
||||
} finally {
|
||||
input.close();
|
||||
}
|
||||
loadFromString(builder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(File file) throws IOException {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
Files.createParentDirs(file);
|
||||
String data = saveToString();
|
||||
Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8);
|
||||
try {
|
||||
writer.write(data);
|
||||
} finally {
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveToString() {
|
||||
yamlOptions.setIndent(options().indent());
|
||||
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
String header = buildHeader();
|
||||
String dump = yaml.dump(getValues(false));
|
||||
if (dump.equals(BLANK_CONFIG)) {
|
||||
dump = "";
|
||||
}
|
||||
return header + dump;
|
||||
}
|
||||
}
|
||||
@@ -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.length() != 0)
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.inventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓
|
||||
*
|
||||
*/
|
||||
public class InventoryControl {
|
||||
SimpleEssential plugin;
|
||||
HashMap<String, Location> enchantbench = new HashMap<String, Location>();
|
||||
|
||||
public InventoryControl(SimpleEssential main) {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
public void clearAllEnchantBench() {
|
||||
for (Entry<String, Location> item : enchantbench.entrySet()) {
|
||||
setRange(item.getValue(), Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
public void clearEnchantBench(Player player) {
|
||||
if (!isOpenEnchantBench(player))
|
||||
return;
|
||||
Location loc = enchantbench.get(player.getName());
|
||||
setRange(loc, Material.AIR);
|
||||
loc.getBlock().setType(Material.AIR);
|
||||
}
|
||||
|
||||
public boolean isOpenEnchantBench(Player player) {
|
||||
return enchantbench.containsKey(player.getName());
|
||||
}
|
||||
|
||||
public void openEnchantBench(Player player) {
|
||||
Location loc = player.getLocation();
|
||||
loc.setY(250);
|
||||
setEnchatRange(loc);
|
||||
player.openEnchanting(loc, true);
|
||||
enchantbench.put(player.getName(), loc);
|
||||
};
|
||||
|
||||
protected void setBlock(Location loc, int x, int y, int z, Material ma) {
|
||||
new Location(loc.getWorld(), loc.getBlockX() + x, loc.getBlockY() + y, loc.getBlockZ() + z).getBlock().setType(ma);
|
||||
}
|
||||
|
||||
protected void setEnchatRange(Location loc) {
|
||||
setRange(loc, Material.BOOKSHELF);
|
||||
loc.getBlock().setType(Material.ENCHANTMENT_TABLE);
|
||||
}
|
||||
|
||||
protected void setRange(Location loc, Material ma) {
|
||||
for (int i = -2; i < 3; i++) {
|
||||
for (int j = 0; j < 2; j++) {
|
||||
for (int k = -2; k < 3; k++) {
|
||||
if (!((i * k == 0) || (i * k * i * k == 1))) {
|
||||
setBlock(loc, i, j, k, ma);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.listen;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
|
||||
/**
|
||||
* 玩家随身附魔台记录监听
|
||||
*
|
||||
* @author 蒋天蓓 2015年8月12日下午8:19:33
|
||||
*
|
||||
*/
|
||||
public class PlayerInventoryViewListen implements Listener {
|
||||
SimpleEssential plugin;
|
||||
|
||||
public PlayerInventoryViewListen(SimpleEssential main) {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onInventoryClose(InventoryCloseEvent e) {
|
||||
if (!(e.getPlayer() instanceof Player))
|
||||
return;
|
||||
Player player = (Player) e.getPlayer();
|
||||
Inventory inv = e.getInventory();
|
||||
if (inv.getType() == InventoryType.ENCHANTING) {
|
||||
ItemStack item = e.getInventory().getContents()[0];
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
plugin.invcontrol.clearEnchantBench(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.listen;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
|
||||
/**
|
||||
* 玩家传送点记录监听
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午8:19:33
|
||||
*
|
||||
*/
|
||||
public class PlayerLocationListen implements Listener {
|
||||
SimpleEssential plugin;
|
||||
|
||||
public PlayerLocationListen(SimpleEssential main) {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||
Player player = e.getEntity();
|
||||
Location loc = player.getLocation();
|
||||
plugin.tpcontrol.setLastloc(player, loc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.teleport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.utils.EffectUtil;
|
||||
|
||||
/**
|
||||
* @author 蒋天蓓 2015年8月12日下午2:26:10 传送控制类
|
||||
*/
|
||||
public class TeleportControl {
|
||||
protected HashMap<Player, TeleportInfo> teleportList = new HashMap<Player, TeleportInfo>();
|
||||
protected HashMap<Player, Location> lastlocList = new HashMap<Player, Location>();
|
||||
private SimpleEssential plugin;
|
||||
|
||||
private int TpDelay = 0;
|
||||
private String TpControlName = "";
|
||||
|
||||
public TeleportControl(SimpleEssential plugin, String tpcontrolname, int tpdelay) {
|
||||
this.plugin = plugin;
|
||||
this.TpDelay = tpdelay;
|
||||
this.TpControlName = tpcontrolname;
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家接受传送请求
|
||||
*
|
||||
* @param player
|
||||
* - 执行的玩家
|
||||
*/
|
||||
public void accept(Player player) {
|
||||
TeleportInfo ti = teleportList.remove(player);
|
||||
if (ti != null) {
|
||||
Player target = ti.getTarget();
|
||||
Location loc = null;
|
||||
if (!target.isOnline()) {
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.offline"));
|
||||
return;
|
||||
}
|
||||
if (ti.getTptype() == TeleportType.TPA) {
|
||||
target = ti.getTarget();
|
||||
loc = player.getLocation();
|
||||
} else {
|
||||
target = player;
|
||||
loc = ti.getTarget().getLocation();
|
||||
}
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.accept", target.getDisplayName()));
|
||||
target.sendMessage(TpControlName + Language.getMessage("Teleport.acceptfrom", player.getDisplayName()));
|
||||
magicTeleport(target, loc, TpDelay);
|
||||
return;
|
||||
}
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.none"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加传送请求到传送列表
|
||||
*
|
||||
* @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(TpControlName + Language.getMessage("Teleport.nobackloc"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 玩家拒绝传送请求
|
||||
*
|
||||
* @param player
|
||||
* - 执行的玩家
|
||||
*/
|
||||
public void deny(Player player) {
|
||||
TeleportInfo ti = teleportList.remove(player);
|
||||
if (ti != null) {
|
||||
Player target = ti.getTarget();
|
||||
if (target.isOnline()) {
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.deny", target.getDisplayName()));
|
||||
target.sendMessage(TpControlName + Language.getMessage("Teleport.denyfrom", player.getDisplayName()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.none"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 魔法传送
|
||||
*
|
||||
* @param player
|
||||
* - 被传送的玩家
|
||||
* @param loc
|
||||
* - 传送的地点
|
||||
*/
|
||||
public void magicTeleport(final Player player, final Location loc) {
|
||||
magicTeleport(player, loc, TpDelay);
|
||||
}
|
||||
|
||||
/**
|
||||
* 魔法传送
|
||||
*
|
||||
* @param player
|
||||
* - 被传送的玩家
|
||||
* @param loc
|
||||
* - 传送的地点
|
||||
* @param delay
|
||||
* - 传送延时
|
||||
*/
|
||||
public void magicTeleport(final Player player, final Location loc, final int delay) {
|
||||
int petime = delay * 20 + 10;
|
||||
setLastloc(player, player.getLocation());
|
||||
player.sendMessage(TpControlName + Language.getMessage("Teleport.tp", delay, loc.getWorld().getName(), loc.getBlockX(), 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;
|
||||
long lrng = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (System.currentTimeMillis() < timeoutmark) {
|
||||
if (player.isOnline()) {
|
||||
EffectUtil.run(player.getLocation(), lrng, Effect.MOBSPAWNER_FLAMES, Effect.PORTAL);
|
||||
}
|
||||
lrng++;
|
||||
try {
|
||||
Thread.sleep(128);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (player.isOnline()) {
|
||||
player.teleport(loc);
|
||||
}
|
||||
}
|
||||
}, delay * 20);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置最后的地址数据
|
||||
*
|
||||
* @param player
|
||||
* - 玩家
|
||||
* @param loc
|
||||
* - 地点
|
||||
*/
|
||||
public void setLastloc(Player player, Location loc) {
|
||||
lastlocList.put(player, loc);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.teleport;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* 玩家传送记录
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午2:56:25
|
||||
*
|
||||
*/
|
||||
public class TeleportInfo {
|
||||
protected TeleportType tptype;
|
||||
protected Player target;
|
||||
|
||||
public TeleportInfo(Player target, TeleportType tptype) {
|
||||
this.target = target;
|
||||
this.tptype = tptype;
|
||||
}
|
||||
|
||||
public TeleportType getTptype() {
|
||||
return tptype;
|
||||
}
|
||||
|
||||
public Player getTarget() {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.teleport;
|
||||
|
||||
/**
|
||||
* 传送类型枚举
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月12日下午2:56:59
|
||||
*
|
||||
*/
|
||||
public enum TeleportType {
|
||||
TPA, TPH
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.utils;
|
||||
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
* 粒子发生器
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月14日下午2:07:02
|
||||
*
|
||||
*/
|
||||
public class EffectUtil {
|
||||
|
||||
/**
|
||||
* 粒子发生器
|
||||
*
|
||||
* @param loc
|
||||
* - 粒子产生地点
|
||||
* @param range
|
||||
* - 粒子产生数量
|
||||
* @param effects
|
||||
* - 粒子类型
|
||||
*/
|
||||
public static void run(Location loc, long range, Effect... effects) {
|
||||
try {
|
||||
int i;
|
||||
if (range < 2) {
|
||||
range = 2;
|
||||
}
|
||||
for (i = 0; i < range; i++) {
|
||||
for (Effect effect : effects) {
|
||||
loc.getWorld().playEffect(loc, effect, 10, 100);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package cn.citycraft.SimpleEssential.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
/**
|
||||
* 自动更新类
|
||||
*
|
||||
* @author 蒋天蓓
|
||||
* 2015年8月14日下午4:01:15
|
||||
*/
|
||||
public class VersionChecker implements Listener {
|
||||
Plugin plugin;
|
||||
public String checkurl = "https://coding.net/u/502647092/p/%s/git/raw/%s/src/plugin.yml";
|
||||
public String branch = "master";
|
||||
|
||||
/**
|
||||
* @param plugin
|
||||
* - 插件
|
||||
*/
|
||||
public VersionChecker(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.versioncheck(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plugin
|
||||
* - 插件
|
||||
* @param branch
|
||||
* - 分支名称
|
||||
*/
|
||||
public VersionChecker(Plugin plugin, String branch) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
this.checkurl = branch;
|
||||
this.versioncheck(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件更新链接
|
||||
*
|
||||
* @param pluginName
|
||||
* - 插件名称
|
||||
* @param branch
|
||||
* - 插件分支
|
||||
* @return 更新链接
|
||||
*/
|
||||
public String getCheckUrl(String pluginName, String branch) {
|
||||
return String.format(checkurl, pluginName, branch);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
if (e.getPlayer().isOp()) {
|
||||
this.versioncheck(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始更新
|
||||
*
|
||||
* @param player
|
||||
* - 获取更新的玩家(null则默认为控制台)
|
||||
*/
|
||||
public void versioncheck(final Player player) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String readURL = getCheckUrl(plugin.getName(), branch);
|
||||
FileConfiguration config;
|
||||
String currentVersion = plugin.getDescription().getVersion();
|
||||
try {
|
||||
URL url = new URL(readURL);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), Charsets.UTF_8));
|
||||
config = YamlConfiguration.loadConfiguration(br);
|
||||
String newVersion = config.getString("version");
|
||||
br.close();
|
||||
if (!newVersion.equals(currentVersion)) {
|
||||
String[] msg = new String[] {
|
||||
ChatColor.GREEN + plugin.getName() + " 插件最新版本 v" + newVersion,
|
||||
ChatColor.RED + "服务器运行版本: v" + currentVersion,
|
||||
ChatColor.GOLD + "插件更新网站: " + ChatColor.BLUE + plugin.getDescription().getWebsite()
|
||||
};
|
||||
if (player != null) {
|
||||
player.sendMessage(msg);
|
||||
} else {
|
||||
plugin.getServer().getConsoleSender().sendMessage(msg);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().warning("版本更新检查失败!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
12
src/main/resources/config.yml
Normal file
12
src/main/resources/config.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
#本文件为保护插件的主配置文件
|
||||
version: 1.0
|
||||
#服务器名称
|
||||
servername: ''
|
||||
#插件名称
|
||||
pluginname: '&6[&b基础系统&6]&r'
|
||||
|
||||
#基础传送系统
|
||||
Teleport:
|
||||
name: '&6[&b传送系统&6]&r'
|
||||
#所有传送延时
|
||||
delay: 3
|
||||
34
src/main/resources/language.yml
Normal file
34
src/main/resources/language.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
#本文件为基础插件的语言配置文件
|
||||
version: 1.0
|
||||
#基础语言配置
|
||||
Base:
|
||||
offline: "§c玩家 %s 不存在或不在线!"
|
||||
no-permission: '§c你没有此命令的权限.'
|
||||
playercommand: '§c此命令只能由玩家执行.'
|
||||
#基础传送系统
|
||||
Teleport:
|
||||
tp: '§a传送开始 %s秒 后到达 目的地 §d世界: %s §3X: %s Z: %s!'
|
||||
accept: '§a已接受玩家: %s §a的传送请求!'
|
||||
acceptfrom: '§a玩家: %s§a接受了您的请求!'
|
||||
deny: '§c已拒绝玩家: %s §c的传送请求!'
|
||||
denyfrom: '§c玩家: %s§c拒绝了您的请求!'
|
||||
offline: '§c目标玩家已离线 本次传送取消!'
|
||||
none: '§c没有找到需要传送的队列!'
|
||||
sethomesuccess: '§a家设置成功!'
|
||||
sethomeerror: '§c请站在床上设置家!'
|
||||
homelose: '§c你的床丢失了或者被方块阻挡了!'
|
||||
top: '&a已传送至当前位置最高方块!'
|
||||
tpsend: '§a已经向玩家 %s §a发送传送请求!'
|
||||
tpa: '§a玩家: %s§a请求传送到你这里!'
|
||||
tphere: '§b玩家: %s§b请求你传送到他那里!'
|
||||
tpaccept: '§a输入命令/tpaccept 或 /tpok 接受传送'
|
||||
tpdeny: '§c输入命令/tpdeny 或 /tpno 拒绝传送'
|
||||
nobackloc: '§c未找到可以Back的地点!'
|
||||
setspawn: '§a已配置 §d世界:%s §a出生点 §3X: %s Y: %s Z: %s!'
|
||||
#自杀
|
||||
Suicide:
|
||||
msg: '§6玩家: §a%s §d活不下去 - §c自杀了!'
|
||||
#帽子
|
||||
Hat:
|
||||
empty: '§c看上去你手上什么都没有啊!'
|
||||
enjoy: '§2享受你的新帽子吧!'
|
||||
119
src/main/resources/plugin.yml
Normal file
119
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,119 @@
|
||||
name: ${project.artifactId}
|
||||
main: ${project.groupId}.${project.artifactId}.${project.artifactId}
|
||||
website: http://ci.citycraft.cn:8800/jenkins/job/${project.artifactId}/
|
||||
version: ${project.version}
|
||||
commands:
|
||||
simpleessential:
|
||||
description: 简单基础插件
|
||||
aliases: [se,sme]
|
||||
usage: §6使用 §a/se help §6查看帮助!
|
||||
permission: se.*
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
tpa:
|
||||
description: 传送到目标玩家
|
||||
aliases: [setps,smetpa]
|
||||
usage: §6使用 §a/tpa <player> §6传送到目标玩家!
|
||||
permission: se.tpa
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
tphere:
|
||||
description: 邀请目标玩家
|
||||
aliases: [tph]
|
||||
usage: §6使用 §a/tphere <player> §6邀请目标玩家!
|
||||
permission: se.tphere
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
tpaccept:
|
||||
description: 接受传送或邀请
|
||||
aliases: [tpok]
|
||||
usage: §6使用 §a/tpaccept §6接受传送或邀请!
|
||||
permission: se.tpaccept
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
tpdeny:
|
||||
description: 拒绝传送或邀请
|
||||
aliases: [tpno]
|
||||
usage: §6使用 §a/tpdeny §6拒绝传送或邀请!
|
||||
permission: se.tpdeny
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
back:
|
||||
description: 回到上一个TP地点
|
||||
aliases: [seback]
|
||||
usage: §6使用 §a/back §6回到上一个TP地点!
|
||||
permission: se.back
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
top:
|
||||
description: 传送到最高方块
|
||||
aliases: [setop]
|
||||
usage: §6使用 §a/top §6传送到当前位置最高方块!
|
||||
permission: se.top
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
home:
|
||||
description: 传送到家里
|
||||
aliases: [sehome]
|
||||
usage: §6使用 §a/home §6传送到家里!
|
||||
permission: se.home
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
sethome:
|
||||
description: 设置当前位置为家
|
||||
aliases: [sesethome]
|
||||
usage: §6使用 §a/sethome §6设置当前位置为家!
|
||||
permission: se.sethome
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
suicide:
|
||||
description: 自杀
|
||||
aliases: [sesuicide,sd]
|
||||
usage: §6使用 §a/suicide §6结束自己的生命!
|
||||
permission: se.suicide
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
hat:
|
||||
description: 帽子
|
||||
aliases: [sehat]
|
||||
usage: §6使用 §a/hat §6把手上的物品带在头上!
|
||||
permission: se.hat
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
workbench:
|
||||
description: 打开随身工作台
|
||||
aliases: [seworkbench,wb,sewb]
|
||||
usage: §6使用 §a/workbench §6打开随身工作台!
|
||||
permission: se.workbench
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
enchantbench:
|
||||
description: 打开随身附魔台(30级)
|
||||
aliases: [seenchantbench,seeb,eb]
|
||||
usage: §6使用 §a/enchantbench §6打开随身附魔台(30级)!
|
||||
permission: se.enchantbench
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
setspawn:
|
||||
description: 设置世界出生点
|
||||
aliases: [sesetspawn]
|
||||
usage: §6使用 §a/setspawn §6设置世界出生点!
|
||||
permission: se.setspawn
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
spawn:
|
||||
description: 返回世界出生点
|
||||
aliases: [sespawn]
|
||||
usage: §6使用 §a/spawn §6返回世界出生点!
|
||||
permission: se.spawn
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
|
||||
permissions:
|
||||
se.*:
|
||||
description: 简单基础插件所有权限!
|
||||
default: op
|
||||
children:
|
||||
se.user: true
|
||||
se.user:
|
||||
description: 简单基础插件玩家权限!
|
||||
default: true
|
||||
children:
|
||||
se.tpa: true
|
||||
se.tphere: true
|
||||
se.tpaccept: true
|
||||
se.tpdeny: true
|
||||
se.back: true
|
||||
se.sethome: true
|
||||
se.home: true
|
||||
se.suicide: true
|
||||
se.hat: true
|
||||
se.workbench: true
|
||||
se.enchantbench: true
|
||||
se.spawn: true
|
||||
|
||||
Reference in New Issue
Block a user