mirror of
https://e.coding.net/circlecloud/SimpleEssential.git
synced 2025-01-07 12:28:56 +00:00
#2 Update
+ /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:
parent
1c529d697c
commit
1ff9008275
@ -1,7 +1,8 @@
|
||||
package cn.citycraft.SimpleEssential;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -14,18 +15,20 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import cn.citycraft.SimpleEssential.command.CommandBack;
|
||||
import cn.citycraft.SimpleEssential.command.CommandHat;
|
||||
import cn.citycraft.SimpleEssential.command.CommandHome;
|
||||
import cn.citycraft.SimpleEssential.command.CommandSetHome;
|
||||
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.SimpleEssentialCommand;
|
||||
import cn.citycraft.SimpleEssential.command.utils.teleport.TeleportControl;
|
||||
import cn.citycraft.SimpleEssential.config.Config;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.listen.PlayerLocationListen;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportControl;
|
||||
import cn.citycraft.SimpleEssential.listeners.TeleportDeathBackListener;
|
||||
import cn.citycraft.SimpleEssential.utils.VersionChecker;
|
||||
|
||||
/**
|
||||
@ -36,7 +39,7 @@ import cn.citycraft.SimpleEssential.utils.VersionChecker;
|
||||
public class SimpleEssential extends JavaPlugin {
|
||||
|
||||
/**
|
||||
* 传送控制
|
||||
* 控制器
|
||||
*/
|
||||
public TeleportControl tpcontrol;
|
||||
/**
|
||||
@ -75,9 +78,9 @@ public class SimpleEssential extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
tpcontrol = new TeleportControl(this);
|
||||
this.registerCommands();
|
||||
this.registerEvents();
|
||||
this.registerControllers();
|
||||
new VersionChecker(this);
|
||||
}
|
||||
|
||||
@ -85,7 +88,13 @@ public class SimpleEssential extends JavaPlugin {
|
||||
* 注册事件
|
||||
*/
|
||||
private void registerEvents() {
|
||||
registerEvent(new PlayerLocationListen(this));
|
||||
registerEvent(new TeleportDeathBackListener(this));
|
||||
}
|
||||
/**
|
||||
* 初始化控制器
|
||||
*/
|
||||
private void registerControllers(){
|
||||
tpcontrol = new TeleportControl(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -107,6 +116,8 @@ public class SimpleEssential extends JavaPlugin {
|
||||
registerCommand(new CommandBack(this));
|
||||
registerCommand(new CommandSetHome(this));
|
||||
registerCommand(new CommandHome(this));
|
||||
registerCommand(new CommandSuicide(this));
|
||||
registerCommand(new CommandHat(this));
|
||||
|
||||
}
|
||||
|
||||
|
60
src/cn/citycraft/SimpleEssential/command/CommandHat.java
Normal file
60
src/cn/citycraft/SimpleEssential/command/CommandHat.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
61
src/cn/citycraft/SimpleEssential/command/CommandSuicide.java
Normal file
61
src/cn/citycraft/SimpleEssential/command/CommandSuicide.java
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -9,8 +9,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.command.utils.teleport.TeleportType;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
||||
|
||||
/**
|
||||
* 玩家传送命令
|
||||
|
@ -9,8 +9,8 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
import cn.citycraft.SimpleEssential.command.utils.teleport.TeleportType;
|
||||
import cn.citycraft.SimpleEssential.config.Language;
|
||||
import cn.citycraft.SimpleEssential.teleport.TeleportType;
|
||||
|
||||
/**
|
||||
* 传送到玩家命令
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.teleport;
|
||||
package cn.citycraft.SimpleEssential.command.utils.teleport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.teleport;
|
||||
package cn.citycraft.SimpleEssential.command.utils.teleport;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.teleport;
|
||||
package cn.citycraft.SimpleEssential.command.utils.teleport;
|
||||
|
||||
/**
|
||||
* 传送类型枚举
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package cn.citycraft.SimpleEssential.listen;
|
||||
package cn.citycraft.SimpleEssential.listeners;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -19,10 +19,10 @@ import cn.citycraft.SimpleEssential.SimpleEssential;
|
||||
* 2015年8月12日下午8:19:33
|
||||
*
|
||||
*/
|
||||
public class PlayerLocationListen implements Listener {
|
||||
public class TeleportDeathBackListener implements Listener {
|
||||
SimpleEssential plugin;
|
||||
|
||||
public PlayerLocationListen(SimpleEssential main) {
|
||||
public TeleportDeathBackListener(SimpleEssential main) {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
@ -24,3 +24,10 @@ Teleport:
|
||||
tpaccept: '§a输入命令/tpaccept 或 /tpok 接受传送'
|
||||
tpdeny: '§c输入命令/tpdeny 或 /tpno 拒绝传送'
|
||||
nobackloc: '§c未找到可以Back的地点!'
|
||||
#自杀
|
||||
Suicide:
|
||||
suicide: '玩家 %s 自刎了!'
|
||||
#帽子
|
||||
Hat:
|
||||
empty: '§c看上去你手上什么都没有啊!'
|
||||
enjoy: '§2享受你的新帽子吧!'
|
@ -63,6 +63,12 @@ commands:
|
||||
usage: §b使用/suicide结束自己的生命!
|
||||
permission: se.suicide
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
hat:
|
||||
description: 戴上手中的物品到脑袋上
|
||||
aliases: [sehat]
|
||||
usage: §b使用/hat戴上一款亮闪闪的帽子!
|
||||
permission: se.hat
|
||||
permission-message: §c你没有 <permission> 的权限来执行此命令!
|
||||
permissions:
|
||||
se.*:
|
||||
description: 简单基础插件所有权限!
|
||||
@ -81,4 +87,5 @@ permissions:
|
||||
se.sethome: true
|
||||
se.home: true
|
||||
se.suicide: true
|
||||
se.hat: true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user