1
0
mirror of https://e.coding.net/circlecloud/SimpleEssential.git synced 2025-01-08 12:39:20 +00:00
+ /suicide command with a not working death message
+ Buggy /hat
+ A function to register controllers likes register events and commands
* Moved command utility to a single package cn.citycraft/SimpleEssential/command/utils

! Sometimes language file dosn't working and I don't know what happened
! Hat cannot judge is a air on hand... I tried to if but not working!
! Death message for suicide is not working!

# I know that's all my fault and please fix them!
# Symbols: + Add - Remove x Fixed ! Bug # Description * Change
# Wish you know!
This commit is contained in:
代小呆 2015-08-16 14:19:11 +08:00
parent 1c529d697c
commit 1ff9008275
11 changed files with 420 additions and 274 deletions

View File

@ -1,7 +1,8 @@
package cn.citycraft.SimpleEssential;
/** /**
* *
*/ */
package cn.citycraft.SimpleEssential;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -14,18 +15,20 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
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.command.SimpleEssentialCommand;
import cn.citycraft.SimpleEssential.command.utils.teleport.TeleportControl;
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.listeners.TeleportDeathBackListener;
import cn.citycraft.SimpleEssential.teleport.TeleportControl;
import cn.citycraft.SimpleEssential.utils.VersionChecker; import cn.citycraft.SimpleEssential.utils.VersionChecker;
/** /**
@ -36,7 +39,7 @@ import cn.citycraft.SimpleEssential.utils.VersionChecker;
public class SimpleEssential extends JavaPlugin { public class SimpleEssential extends JavaPlugin {
/** /**
* 传送控制 * 控制
*/ */
public TeleportControl tpcontrol; public TeleportControl tpcontrol;
/** /**
@ -75,9 +78,9 @@ public class SimpleEssential extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
tpcontrol = new TeleportControl(this);
this.registerCommands(); this.registerCommands();
this.registerEvents(); this.registerEvents();
this.registerControllers();
new VersionChecker(this); new VersionChecker(this);
} }
@ -85,7 +88,13 @@ public class SimpleEssential extends JavaPlugin {
* 注册事件 * 注册事件
*/ */
private void registerEvents() { private void registerEvents() {
registerEvent(new PlayerLocationListen(this)); registerEvent(new TeleportDeathBackListener(this));
}
/**
* 初始化控制器
*/
private void registerControllers(){
tpcontrol = new TeleportControl(this);
} }
@Override @Override
@ -107,6 +116,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 CommandSuicide(this));
registerCommand(new CommandHat(this));
} }

View File

@ -0,0 +1,60 @@
package cn.citycraft.SimpleEssential.command;
import org.bukkit.Material;
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 SimpleEssentialCommand{
@SuppressWarnings("unused")
private SimpleEssential plugin;
public CommandHat(SimpleEssential se) {
super("hat","sehat");
this.plugin = se;
}
@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;
}
}

View File

@ -0,0 +1,61 @@
package cn.citycraft.SimpleEssential.command;
import java.util.Arrays;
import cn.citycraft.SimpleEssential.SimpleEssential;
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 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 SimpleEssentialCommand{
private SimpleEssential plugin;
public CommandSuicide(SimpleEssential main) {
super("suicide", new String[]{"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;
EffectUtil.run(p.getLocation(), 10, Effect.POTION_BREAK);
PlayerDeathEvent pd = new PlayerDeathEvent(p,Arrays.asList(p.getInventory().getContents()),
(int) Math.floor(p.getExp()),p.getName() + "自杀了");
plugin.getServer().getPluginManager().callEvent(pd);
// plugin.getServer().broadcastMessage(Language.getMessage("Suicide.suicide",sender.getName()));
p.setHealth(0);
}
@Override
public boolean isOnlyPlayerExecutable() {
return true;
}
}

View File

@ -9,8 +9,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import cn.citycraft.SimpleEssential.SimpleEssential; import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.command.utils.teleport.TeleportType;
import cn.citycraft.SimpleEssential.config.Language; import cn.citycraft.SimpleEssential.config.Language;
import cn.citycraft.SimpleEssential.teleport.TeleportType;
/** /**
* 玩家传送命令 * 玩家传送命令

View File

@ -9,8 +9,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import cn.citycraft.SimpleEssential.SimpleEssential; import cn.citycraft.SimpleEssential.SimpleEssential;
import cn.citycraft.SimpleEssential.command.utils.teleport.TeleportType;
import cn.citycraft.SimpleEssential.config.Language; import cn.citycraft.SimpleEssential.config.Language;
import cn.citycraft.SimpleEssential.teleport.TeleportType;
/** /**
* 传送到玩家命令 * 传送到玩家命令

View File

@ -1,7 +1,7 @@
/** /**
* *
*/ */
package cn.citycraft.SimpleEssential.teleport; package cn.citycraft.SimpleEssential.command.utils.teleport;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;

View File

@ -1,7 +1,7 @@
/** /**
* *
*/ */
package cn.citycraft.SimpleEssential.teleport; package cn.citycraft.SimpleEssential.command.utils.teleport;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;

View File

@ -1,7 +1,7 @@
/** /**
* *
*/ */
package cn.citycraft.SimpleEssential.teleport; package cn.citycraft.SimpleEssential.command.utils.teleport;
/** /**
* 传送类型枚举 * 传送类型枚举

View File

@ -1,7 +1,7 @@
/** /**
* *
*/ */
package cn.citycraft.SimpleEssential.listen; package cn.citycraft.SimpleEssential.listeners;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -19,10 +19,10 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
* 2015年8月12日下午8:19:33 * 2015年8月12日下午8:19:33
* *
*/ */
public class PlayerLocationListen implements Listener { public class TeleportDeathBackListener implements Listener {
SimpleEssential plugin; SimpleEssential plugin;
public PlayerLocationListen(SimpleEssential main) { public TeleportDeathBackListener(SimpleEssential main) {
this.plugin = main; this.plugin = main;
} }

View File

@ -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:
suicide: '玩家 %s 自刎了!'
#帽子
Hat:
empty: '§c看上去你手上什么都没有啊'
enjoy: '§2享受你的新帽子吧'

View File

@ -63,6 +63,12 @@ commands:
usage: §b使用/suicide结束自己的生命! usage: §b使用/suicide结束自己的生命!
permission: se.suicide permission: se.suicide
permission-message: §c你没有 <permission> 的权限来执行此命令! permission-message: §c你没有 <permission> 的权限来执行此命令!
hat:
description: 戴上手中的物品到脑袋上
aliases: [sehat]
usage: §b使用/hat戴上一款亮闪闪的帽子
permission: se.hat
permission-message: §c你没有 <permission> 的权限来执行此命令!
permissions: permissions:
se.*: se.*:
description: 简单基础插件所有权限! description: 简单基础插件所有权限!
@ -81,4 +87,5 @@ permissions:
se.sethome: true se.sethome: true
se.home: true se.home: true
se.suicide: true se.suicide: true
se.hat: true