1
0
mirror of https://e.coding.net/circlecloud/SimpleEssential.git synced 2024-11-16 01:08:46 +00:00

add EnchantBench and WorkBench...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-08-21 20:48:27 +08:00
parent bdbe3282d7
commit c126d80a41
4 changed files with 167 additions and 0 deletions

View File

@ -15,6 +15,7 @@ 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;
@ -24,6 +25,7 @@ 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.listen.PlayerLocationListen;
@ -117,6 +119,8 @@ public class SimpleEssential extends JavaPlugin {
registerCommand(new CommandHome(this));
registerCommand(new CommandHat(this));
registerCommand(new CommandSuicide(this));
registerCommand(new CommandEnchantBench(this));
registerCommand(new CommandWorkBench(this));
}
/**

View File

@ -0,0 +1,103 @@
/**
*
*/
package cn.citycraft.SimpleEssential.command;
import org.bukkit.Location;
import org.bukkit.Material;
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 boolean isOnlyPlayerExecutable() {
return true;
};
@Override
public void execute(CommandSender sender, String label, String[] args) throws CommandException {
Player p = (Player) sender;
final Location loc = p.getLocation();
switch (args.length) {
case 0:
setEnchatRange(loc);
p.openEnchanting(loc, true);
clearEnchatRange(loc);
break;
case 1:
switch (args[0]) {
case "set":
setEnchatRange(loc);
break;
case "clear":
clearEnchatRange(loc);
break;
}
break;
default:
break;
}
}
protected void setRange(Location loc, Material ma) {
setBlock(loc, -2, 0, -2, ma);
setBlock(loc, -2, 1, -1, ma);
setBlock(loc, -2, 0, 1, ma);
setBlock(loc, -1, 0, 2, ma);
setBlock(loc, 2, 0, 2, ma);
setBlock(loc, 2, 1, 2, ma);
setBlock(loc, 1, 0, 2, ma);
setBlock(loc, 2, 0, 1, ma);
setBlock(loc, -2, 0, -2, ma);
setBlock(loc, -2, 1, -2, ma);
setBlock(loc, -1, 0, -2, ma);
setBlock(loc, -2, 0, -1, ma);
setBlock(loc, 2, 0, -2, ma);
setBlock(loc, 2, 1, -2, ma);
setBlock(loc, 1, 0, -2, ma);
setBlock(loc, 2, 0, -1, ma);
}
protected void clearEnchatRange(Location loc) {
setRange(loc, Material.AIR);
loc.getBlock().setType(Material.AIR);
}
protected void setEnchatRange(Location loc) {
setRange(loc, Material.BOOKSHELF);
loc.getBlock().setType(Material.ENCHANTMENT_TABLE);
}
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);
}
@Override
public int getMinimumArguments() {
return 0;
}
@Override
public String getPossibleArguments() {
return "";
}
}

View File

@ -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 "";
}
}

View File

@ -69,6 +69,19 @@ commands:
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> 的权限来执行此命令!
permissions:
se.*:
description: 简单基础插件所有权限!
@ -88,4 +101,6 @@ permissions:
se.home: true
se.suicide: true
se.hat: true
se.workbench: true
se.enchantbench: true