parent
0586c3642d
commit
6e761d5cbd
|
@ -23,12 +23,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||
*/
|
||||
public class CarryEnchantBench extends JavaPlugin implements Listener {
|
||||
Location loc = null;
|
||||
List<String> setList = new ArrayList<String>();
|
||||
List<String> setList = new ArrayList<>();
|
||||
|
||||
@EventHandler
|
||||
public void onClick(PlayerInteractEvent e) {
|
||||
Block b = e.getClickedBlock();
|
||||
Player p = e.getPlayer();
|
||||
public void onClick(final PlayerInteractEvent e) {
|
||||
final Block b = e.getClickedBlock();
|
||||
final Player p = e.getPlayer();
|
||||
if (setList.contains(p.getName())) {
|
||||
if (b.getType() == Material.ENCHANTMENT_TABLE) {
|
||||
loc = b.getLocation();
|
||||
|
@ -47,15 +47,16 @@ public class CarryEnchantBench extends JavaPlugin implements Listener {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("§c控制台吃饱了撑着用毛线附魔台啊");
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
Player p = (Player) sender;
|
||||
final Player p = (Player) sender;
|
||||
if (loc.getBlock().getType() != Material.ENCHANTMENT_TABLE) {
|
||||
p.sendMessage("§c管理员尚未配置随身附魔台的位置或附魔台被破坏!");
|
||||
return true;
|
||||
}
|
||||
p.openEnchanting(loc, true);
|
||||
p.sendMessage("§a已打开随身附魔台!");
|
||||
|
@ -78,11 +79,11 @@ public class CarryEnchantBench extends JavaPlugin implements Listener {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
this.saveDefaultConfig();
|
||||
String worldname = getConfig().getString("Location.World");
|
||||
World world = Bukkit.getWorld(worldname);
|
||||
int x = getConfig().getInt("Location.X");
|
||||
int y = getConfig().getInt("Location.Y");
|
||||
int z = getConfig().getInt("Location.Z");
|
||||
final String worldname = getConfig().getString("Location.World");
|
||||
final World world = Bukkit.getWorld(worldname);
|
||||
final int x = getConfig().getInt("Location.X");
|
||||
final int y = getConfig().getInt("Location.Y");
|
||||
final int z = getConfig().getInt("Location.Z");
|
||||
loc = new Location(world, x, y, z);
|
||||
this.getServer().getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue