mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2024-11-16 01:08:46 +00:00
add hat command and suicide command...
This commit is contained in:
parent
1c529d697c
commit
568ea95ad2
@ -13,15 +13,17 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import cn.citycraft.SimpleEssential.command.BaseCommand;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandBack;
|
import cn.citycraft.SimpleEssential.command.CommandBack;
|
||||||
|
import cn.citycraft.SimpleEssential.command.CommandHat;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandHome;
|
import cn.citycraft.SimpleEssential.command.CommandHome;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandSetHome;
|
import cn.citycraft.SimpleEssential.command.CommandSetHome;
|
||||||
|
import cn.citycraft.SimpleEssential.command.CommandSuicide;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandTop;
|
import cn.citycraft.SimpleEssential.command.CommandTop;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandTpa;
|
import cn.citycraft.SimpleEssential.command.CommandTpa;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandTpaccept;
|
import cn.citycraft.SimpleEssential.command.CommandTpaccept;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandTpdeny;
|
import cn.citycraft.SimpleEssential.command.CommandTpdeny;
|
||||||
import cn.citycraft.SimpleEssential.command.CommandTphere;
|
import cn.citycraft.SimpleEssential.command.CommandTphere;
|
||||||
import cn.citycraft.SimpleEssential.command.SimpleEssentialCommand;
|
|
||||||
import cn.citycraft.SimpleEssential.config.Config;
|
import cn.citycraft.SimpleEssential.config.Config;
|
||||||
import cn.citycraft.SimpleEssential.config.Language;
|
import cn.citycraft.SimpleEssential.config.Language;
|
||||||
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
|
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
|
||||||
@ -42,11 +44,11 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
/**
|
/**
|
||||||
* 命令监听列表
|
* 命令监听列表
|
||||||
*/
|
*/
|
||||||
private List<SimpleEssentialCommand> commandlist;
|
private List<BaseCommand> commandlist;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
for (SimpleEssentialCommand command : commandlist) {
|
for (BaseCommand command : commandlist) {
|
||||||
if (command.isValidTrigger(label)) {
|
if (command.isValidTrigger(label)) {
|
||||||
if (!command.hasPermission(sender)) {
|
if (!command.hasPermission(sender)) {
|
||||||
sender.sendMessage(Language.getMessage("Base.no-permission"));
|
sender.sendMessage(Language.getMessage("Base.no-permission"));
|
||||||
@ -98,7 +100,7 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
* 注册命令
|
* 注册命令
|
||||||
*/
|
*/
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
commandlist = new ArrayList<SimpleEssentialCommand>();
|
commandlist = new ArrayList<BaseCommand>();
|
||||||
registerCommand(new CommandTpa(this));
|
registerCommand(new CommandTpa(this));
|
||||||
registerCommand(new CommandTop(this));
|
registerCommand(new CommandTop(this));
|
||||||
registerCommand(new CommandTpaccept(this));
|
registerCommand(new CommandTpaccept(this));
|
||||||
@ -107,7 +109,8 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
registerCommand(new CommandBack(this));
|
registerCommand(new CommandBack(this));
|
||||||
registerCommand(new CommandSetHome(this));
|
registerCommand(new CommandSetHome(this));
|
||||||
registerCommand(new CommandHome(this));
|
registerCommand(new CommandHome(this));
|
||||||
|
registerCommand(new CommandHat(this));
|
||||||
|
registerCommand(new CommandSuicide(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +119,7 @@ public class SimpleEssential extends JavaPlugin {
|
|||||||
* @param command
|
* @param command
|
||||||
* - 被注册的命令类
|
* - 被注册的命令类
|
||||||
*/
|
*/
|
||||||
public void registerCommand(SimpleEssentialCommand command) {
|
public void registerCommand(BaseCommand command) {
|
||||||
commandlist.add(command);
|
commandlist.add(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,16 +12,16 @@ import org.bukkit.command.CommandSender;
|
|||||||
* @author 蒋天蓓
|
* @author 蒋天蓓
|
||||||
* 2015年8月12日下午12:49:34
|
* 2015年8月12日下午12:49:34
|
||||||
*/
|
*/
|
||||||
public abstract class SimpleEssentialCommand {
|
public abstract class BaseCommand {
|
||||||
private String name;
|
private String name;
|
||||||
private String permission;
|
private String permission;
|
||||||
private String[] aliases;
|
private String[] aliases;
|
||||||
|
|
||||||
public SimpleEssentialCommand(String name) {
|
public BaseCommand(String name) {
|
||||||
this(name, new String[0]);
|
this(name, new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleEssentialCommand(String name, String... aliases) {
|
public BaseCommand(String name, String... aliases) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
}
|
}
|
@ -12,7 +12,7 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
|
|||||||
/**
|
/**
|
||||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||||
*/
|
*/
|
||||||
public class CommandBack extends SimpleEssentialCommand {
|
public class CommandBack extends BaseCommand {
|
||||||
SimpleEssential plugin;
|
SimpleEssential plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
59
src/cn/citycraft/SimpleEssential/command/CommandHat.java
Normal file
59
src/cn/citycraft/SimpleEssential/command/CommandHat.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -16,7 +16,7 @@ import cn.citycraft.SimpleEssential.config.Language;
|
|||||||
*
|
*
|
||||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||||
*/
|
*/
|
||||||
public class CommandHome extends SimpleEssentialCommand {
|
public class CommandHome extends BaseCommand {
|
||||||
SimpleEssential plugin;
|
SimpleEssential plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,7 +17,7 @@ import cn.citycraft.SimpleEssential.config.Language;
|
|||||||
*
|
*
|
||||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||||
*/
|
*/
|
||||||
public class CommandSetHome extends SimpleEssentialCommand {
|
public class CommandSetHome extends BaseCommand {
|
||||||
SimpleEssential plugin;
|
SimpleEssential plugin;
|
||||||
|
|
||||||
public CommandSetHome(SimpleEssential main) {
|
public CommandSetHome(SimpleEssential main) {
|
||||||
|
66
src/cn/citycraft/SimpleEssential/command/CommandSuicide.java
Normal file
66
src/cn/citycraft/SimpleEssential/command/CommandSuicide.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,7 +18,7 @@ import cn.citycraft.SimpleEssential.config.Language;
|
|||||||
* 2015年8月12日下午2:04:05
|
* 2015年8月12日下午2:04:05
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CommandTop extends SimpleEssentialCommand {
|
public class CommandTop extends BaseCommand {
|
||||||
SimpleEssential plugin;
|
SimpleEssential plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,7 @@ import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
|||||||
* 2015年8月12日下午2:04:05
|
* 2015年8月12日下午2:04:05
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CommandTpa extends SimpleEssentialCommand {
|
public class CommandTpa extends BaseCommand {
|
||||||
SimpleEssential plugin;
|
SimpleEssential plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
|
|||||||
* 2015年8月12日下午2:04:05
|
* 2015年8月12日下午2:04:05
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CommandTpaccept extends SimpleEssentialCommand {
|
public class CommandTpaccept extends BaseCommand {
|
||||||
SimpleEssential plugin;
|
SimpleEssential plugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
|
|||||||
* 2015年8月12日下午2:04:05
|
* 2015年8月12日下午2:04:05
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CommandTpdeny extends SimpleEssentialCommand {
|
public class CommandTpdeny extends BaseCommand {
|
||||||
SimpleEssential plugin;
|
SimpleEssential plugin;
|
||||||
|
|
||||||
public CommandTpdeny(SimpleEssential main) {
|
public CommandTpdeny(SimpleEssential main) {
|
||||||
|
@ -17,7 +17,7 @@ import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
|||||||
*
|
*
|
||||||
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
* @author 蒋天蓓 2015年8月12日下午2:04:05
|
||||||
*/
|
*/
|
||||||
public class CommandTphere extends SimpleEssentialCommand {
|
public class CommandTphere extends BaseCommand {
|
||||||
SimpleEssential plugin;
|
SimpleEssential plugin;
|
||||||
|
|
||||||
public CommandTphere(SimpleEssential main) {
|
public CommandTphere(SimpleEssential main) {
|
||||||
|
@ -35,7 +35,7 @@ public class Config extends ConfigLoader {
|
|||||||
|
|
||||||
public static String getMessage(String path) {
|
public static String getMessage(String path) {
|
||||||
String message = instance.getString(path);
|
String message = instance.getString(path);
|
||||||
if (message != null)
|
if (message != null && message.length() != 0)
|
||||||
message = message.replaceAll("&", "§");
|
message = message.replaceAll("&", "§");
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ public class Config extends ConfigLoader {
|
|||||||
return instance.getStringList(path).toArray(new String[0]);
|
return instance.getStringList(path).toArray(new String[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save(){
|
public static void save() {
|
||||||
try {
|
try {
|
||||||
instance.save(file);
|
instance.save(file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -45,7 +45,7 @@ public class Language extends ConfigLoader {
|
|||||||
|
|
||||||
public static String getMessage(String path) {
|
public static String getMessage(String path) {
|
||||||
String message = instance.getString(path);
|
String message = instance.getString(path);
|
||||||
if (message != null)
|
if (message != null && message.length() != 0)
|
||||||
message = message.replaceAll("&", "§");
|
message = message.replaceAll("&", "§");
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,16 @@ import org.bukkit.Location;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EffectUtil {
|
public class EffectUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 粒子发生器
|
* 粒子发生器
|
||||||
*
|
*
|
||||||
* @param loc
|
* @param loc
|
||||||
* - 粒子产生的地点
|
* - 粒子产生地点
|
||||||
* @param range
|
* @param range
|
||||||
* - 粒子的数量
|
* - 粒子产生数量
|
||||||
|
* @param effects
|
||||||
|
* - 粒子类型
|
||||||
*/
|
*/
|
||||||
public static void run(Location loc, long range, Effect... effects) {
|
public static void run(Location loc, long range, Effect... effects) {
|
||||||
try {
|
try {
|
||||||
|
@ -24,3 +24,10 @@ Teleport:
|
|||||||
tpaccept: '§a输入命令/tpaccept 或 /tpok 接受传送'
|
tpaccept: '§a输入命令/tpaccept 或 /tpok 接受传送'
|
||||||
tpdeny: '§c输入命令/tpdeny 或 /tpno 拒绝传送'
|
tpdeny: '§c输入命令/tpdeny 或 /tpno 拒绝传送'
|
||||||
nobackloc: '§c未找到可以Back的地点!'
|
nobackloc: '§c未找到可以Back的地点!'
|
||||||
|
#自杀
|
||||||
|
Suicide:
|
||||||
|
msg: '§6玩家: %s §c活不下去自杀了!'
|
||||||
|
#帽子
|
||||||
|
Hat:
|
||||||
|
empty: '§c看上去你手上什么都没有啊!'
|
||||||
|
enjoy: '§2享受你的新帽子吧!'
|
Loading…
Reference in New Issue
Block a user