无法找到命令并执行
Unable to find command and execute
我正在向我的我的世界服务器添加一个 teleport-here 命令。每当我在服务器中输入命令时,
没有任何反应,甚至 'unkown command' 消息也没有。我正确设置了执行程序(因为它不在主 class 中,就像我的其他完美运行的命令一样......并且该命令在 plugin.yml 中注册:/不知道发生了什么......帮助?
我正在使用 Eclipse Luna 和 1.8 spigot API.
传送class
package me.Zahachos.ServerManager.commands;
import java.util.HashMap;
import java.util.UUID;
import me.Zahachos.ServerManager.Main;
import me.Zahachos.ServerManager.managers.MessageManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class Teleport implements CommandExecutor {
public static HashMap<UUID, Integer> tpa = new HashMap<UUID, Integer>();
public static HashMap<UUID, Integer> tph = new HashMap<UUID, Integer>();
public static HashMap<UUID, UUID> tpaccept = new HashMap<UUID, UUID>();
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (cmd.getName().equalsIgnoreCase("tp")) {
if (sender.hasPermission("sm.tp.tp")) {
if (args.length == 0) {
MessageManager.getInstance().severe(sender, "Please specify a player!");
return true;
}
if (args.length == 1) {
if(!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console connot teleport! Specify a second player!");
return true;
}
Player p = (Player) sender;
Player target = null;
for (Player test : Bukkit.getOnlinePlayers()) {
if (test.getName().equals(args[0])) {
target = test;
break;
}
}
if (target == null) {
MessageManager.getInstance().severe(p, "Either that player doesn't exist or he isn't online!");
return true;
}
MessageManager.getInstance().good(p, "You have been teleported to " + target.getName());
p.teleport(target);
MessageManager.getInstance().info(target, p.getName() + " has teleported to you!");
return true;
}
if (args.length == 2) {
Player target = null;
for (Player test : Bukkit.getOnlinePlayers()) {
if (test.getName().equals(args[0])) {
target = test;
break;
}
}
Player target1 = null;
for (Player test1 : Bukkit.getOnlinePlayers()) {
if (test1.getName().equals(args[1])) {
target1 = test1;
break;
}
}
if (target == null || target1 == null) {
sender.sendMessage(ChatColor.RED + "One of the players doesn't exist or isn't online!");
return true;
}
target.teleport(target1);
MessageManager.getInstance().info(target, target1.getName() + " was teleported to you by " + sender.getName() + ".");
MessageManager.getInstance().info(target1, "You were teleported to " + target.getName() + " by " + sender.getName() + ".");
sender.sendMessage(ChatColor.GREEN + target.getName() + " has been teleported to " + target1.getName() + ".");
}
if (args.length > 2) {
MessageManager.getInstance().severe(sender, "Too many arguments!");
return true;
}
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
if (cmd.getName().equalsIgnoreCase("tpall")) {
if (sender.hasPermission("sm.tp.tpall")) {
if (!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console can't teleport players to him!");
return true;
}
if (args.length > 0) {
MessageManager.getInstance().severe(sender, "Too many arguments!");
return true;
}
Player p = (Player) sender;
for (Player player : Bukkit.getOnlinePlayers()) {
player.teleport(p);
MessageManager.getInstance().info(player, p.getName() + " has teleported everyone to him.");
}
MessageManager.getInstance().good(p, "Everyone one the server was teleported to you!");
return true;
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
if (cmd.getName().equalsIgnoreCase("tpa")) {
if (sender.hasPermission("sm.tp.tpa")) {
if (!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console cannot teleport!");
return true;
}
Player p = (Player) sender;
if (args.length == 0) {
MessageManager.getInstance().severe(p, "Please specify a player!");
return true;
}
if (args.length == 1) {
Player target = null;
for (Player test : Bukkit.getOnlinePlayers()) {
if (test.getName().equals(args[0])) {
target = test;
break;
}
}
if (target == null) {
MessageManager.getInstance().severe(p, "Either that player doesn't exist or he isn't online!");
return true;
}
tpa.put(target.getUniqueId(), 60);
tpaccept.put(target.getUniqueId(), p.getUniqueId());
if (tpa.size() == 1) {
new BukkitRunnable() {
@Override
public void run() {
if (!tpa.isEmpty()) {
for (UUID uuid : tpa.keySet()) {
Player player = Bukkit.getPlayer(uuid);
tpa.put(uuid, tpa.get(uuid) - 1);
if (tpa.get(uuid) == 10) {
if (player.isOnline()) {
MessageManager.getInstance().info(player, "Your teleport request will expire in 10 seconds!");
}
}
if (tpa.get(uuid) == 0) {
if (player.isOnline()) {
MessageManager.getInstance().severe(player, "Your teleport request has expired!");
}
tpa.remove(uuid);
tpaccept.remove(tpaccept.values().remove(uuid));
if (tpa.isEmpty()) {
this.cancel();
}
}
}
} else {
this.cancel();
}
}
}.runTaskTimer(Main.plugin, 20L, 20L);
}
MessageManager.getInstance().custom(target, ChatColor.YELLOW + "Player " + p.getName() + " has requested to teleport to you! Use " + ChatColor.YELLOW + ChatColor.BOLD + "/tpaccept" + ChatColor.RESET + ChatColor.YELLOW + " to teleport him!");
return true;
}
MessageManager.getInstance().severe(p, "Too many arguments!");
return true;
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
if (cmd.getName().equalsIgnoreCase("tphere")) {
if (sender.hasPermission("sm.tp.tph")) {
if (!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console cannot teleport!");
return true;
}
Player p = (Player) sender;
if (args.length == 0) {
MessageManager.getInstance().severe(p, "Please specify a player!");
return true;
}
if (args.length == 1) {
Player target = null;
for (Player test : Bukkit.getOnlinePlayers()) {
if (test.getName().equals(args[0])) {
target = test;
break;
}
}
if (target == null) {
MessageManager.getInstance().severe(p, "Either that player doesn't exist or he isn't online!");
return true;
}
tph.put(target.getUniqueId(), 60);
tpaccept.put(target.getUniqueId(), p.getUniqueId());
if (tph.size() == 1) {
new BukkitRunnable() {
@Override
public void run() {
if (!tph.isEmpty()) {
for (UUID uuid : tph.keySet()) {
Player player = Bukkit.getPlayer(uuid);
tph.put(uuid, tph.get(uuid) - 1);
if (tph.get(uuid) == 10) {
if (player.isOnline()) {
MessageManager.getInstance().info(player, "Your teleport request will expire in 10 seconds!");
}
}
if (tph.get(uuid) == 0) {
if (player.isOnline()) {
MessageManager.getInstance().severe(player, "Your teleport request has expired!");
}
tph.remove(uuid);
tpaccept.remove(tpaccept.values().remove(uuid));
if (tph.isEmpty()) {
this.cancel();
}
}
}
} else {
this.cancel();
}
}
}.runTaskTimer(Main.plugin, 20L, 20L);
}
MessageManager.getInstance().custom(target, ChatColor.YELLOW + "Player " + p.getName() + " has requested to teleport to you! Use " + ChatColor.YELLOW + ChatColor.BOLD + "/tpaccept" + ChatColor.RESET + ChatColor.YELLOW + " to teleport him!");
return true;
}
MessageManager.getInstance().severe(p, "Too many arguments!");
return true;
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
if (cmd.getName().equalsIgnoreCase("tpaccept")) {
if (sender.hasPermission("sm.tp.tpa")) {
if (!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console cannot teleport!");
return true;
}
Player p = (Player) sender;
if (args.length == 0) {
if (tpa.containsKey(p.getUniqueId()) || tpaccept.containsKey(p.getUniqueId())) {
Player target = Bukkit.getPlayer(tpaccept.get(p.getUniqueId()));
target.teleport(p);
tpaccept.remove(p.getUniqueId());
tpa.remove(p.getUniqueId());
return true;
} else if (tpaccept.containsKey(p.getUniqueId()) || tpaccept.containsKey(p.getUniqueId())) {
Player target = Bukkit.getPlayer(tpaccept.get(p.getUniqueId()));
target.teleport(p);
tpaccept.remove(p.getUniqueId());
tpa.remove(p.getUniqueId());
return true;
} else {
MessageManager.getInstance().severe(p, "You don't have any active requests!");
return true;
}
}
MessageManager.getInstance().severe(p, "Too many arguments!");
return true;
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
return true;
}
}
主要class
package me.Zahachos.ServerManager;
import me.Zahachos.ServerManager.commands.Freeze;
import me.Zahachos.ServerManager.commands.HealFeed;
import me.Zahachos.ServerManager.commands.KickBan;
import me.Zahachos.ServerManager.commands.Mute;
import me.Zahachos.ServerManager.commands.Spawn;
import me.Zahachos.ServerManager.commands.Teleport;
import me.Zahachos.ServerManager.commands.Warp;
import me.Zahachos.ServerManager.listeners.JoinLeave;
import me.Zahachos.ServerManager.listeners.OnDeath;
import me.Zahachos.ServerManager.listeners.OnReconnect;
import me.Zahachos.ServerManager.managers.ConfigManager;
import me.Zahachos.ServerManager.util.Cooldown;
import me.Zahachos.ServerManager.util.utilReloadSave;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public static Main plugin = null;
@Override
public void onEnable() {
ConfigManager.getInstance().setup(this);
getCommand("heal").setExecutor(new HealFeed());
getCommand("feed").setExecutor(new HealFeed());
getCommand("regenerate").setExecutor(new HealFeed());
getCommand("tp").setExecutor(new Teleport());
getCommand("tpall").setExecutor(new Teleport());
getCommand("tpa").setExecutor(new Teleport());
getCommand("tph").setExecutor(new Teleport());
getCommand("tpaccept").setExecutor(new Teleport());
getCommand("freeze").setExecutor(new Freeze());
getCommand("warp").setExecutor(new Warp());
getCommand("setwarp").setExecutor(new Warp());
getCommand("delwarp").setExecutor(new Warp());
getCommand("unmute").setExecutor(new Mute());
getCommand("mute").setExecutor(new Mute());
getCommand("tempmute").setExecutor(new Mute());
getCommand("tempban").setExecutor(new KickBan());
getCommand("pardon").setExecutor(new KickBan());
getCommand("ban").setExecutor(new KickBan());
getCommand("kick").setExecutor(new KickBan());
getCommand("spawn").setExecutor(new Spawn());
getCommand("setspawn").setExecutor(new Spawn());
Bukkit.getPluginManager().registerEvents(new JoinLeave(), this);
Bukkit.getPluginManager().registerEvents(new Freeze(), this);
Bukkit.getPluginManager().registerEvents(new OnReconnect(), this);
Bukkit.getPluginManager().registerEvents(new KickBan(), this);
Bukkit.getPluginManager().registerEvents(new Mute(), this);
Bukkit.getPluginManager().registerEvents(new OnDeath(), this);
Bukkit.getLogger().info("[" + this.getDescription().getName() + "] Has been enabled!");
plugin = this;
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Cooldown.handleCooldowns();
}
}, 1L, 1L);
utilReloadSave.loadBans();
utilReloadSave.loadMutes();
}
@Override
public void onDisable() {
Bukkit.getServer().getLogger().info("Basic is Disabled!");
utilReloadSave.saveMutes();
utilReloadSave.saveBans();
}
}
plugin.yml
name: ServerManager
main: me.Zahachos.ServerManager.Main
authors: [Zahachos, KarateMan]
version: 0.02
description: This manages the Zaphno's Network.
commands:
heal:
usage: /<command> [player]
aliases: [health, gethealth]
description: Heal yourself and others.
feed:
usage: /<command> [player]
aliases: [food, getfood, hunger]
description: Feed yourself and others.
regenerate:
usage: /<command> [player]
aliases: [regen, regeneration]
description: Heal and feed yourself and others.
tp:
usage: /<command> [player] [player2]
aliases: [regen, regeneration]
description: Teleport to a player, or another player to one.
tpall:
usage: /<command>
aliases: [teleportall, teleporteveryone]
description: Teleport everyone to you.
tpa:
usage: /<command> [player]
aliases: [askteleport]
description: Ask a player to teleport to him.
tph:
usage: /<command> [player]
aliases: [teleporthere, teleporth]
description: Ask a player to teleport them to you.
tpaccept:
usage: /<command>
aliases: [teleportaccept, acceptteleport]
description: Accepts the last teleport request.
freeze:
usage: /<command> [username]
aliases: [freezeplayer]
description: Freeze or unfreeze a player!
warp:
usage: /<command> [warp_name]
description: Teleport to a saved location!
setwarp:
usage: /<command> [warp_name]
description: Set a warp location!
delwarp:
usage: /<command> [warp_name]
aliases: [deletewarp]
description: Delete a warp!
mute:
usage: /<command> [username] [duration] [reason]
aliases: [muteplayer]
description: Temporarily mute a player!
tempmute:
usage: /<command>
aliases: [muteplayer]
description: Mute a player!
unmute:
usage: /<command> [username]
aliases: [unmuteplayer]
description: Unmute a player!
tempban:
usage: /<command> [username] [duration] [reason]
aliases: [tempbanplayer]
description: Temporarily ban a player!
pardon:
usage: /<command> [username]
aliases: [pardonplayer, unban]
description: Pardon/Unban a player!
ban:
usage: /<command> [username] [reason]
aliases: [setbanned, banplayer]
description: Permanently ban a player!
kick:
usage: /<command> [username] [reason]
aliases: [setbanned, banplayer]
description: Kick a player!
spawn:
usage: /<command>
description: Go to the server spawn!
setspawn:
usage: /<command>
description: Set the server spawn!
permissions:
sm.tp.*:
description: Use all tp commands!
children:
sm.tp.tph: true
sm.tp.tpa: true
sm.tp.tp: true
sm.tp.tpall: true
default: op
sm.health.*:
description: Use all health commands!
children:
sm.health.heal: true
sm.health.feed: true
sm.health.regen: true
default: op
sm.mute.*:
description: Use all mute commands!
children:
sm.mute.mute: true
sm.mute.unmute: true
sm.mute.canChat: true
sm.mute.tempmute: true
default: op
sm.ban.*:
description: Use all ban commands!
children:
sm.ban.pardon: true
sm.ban.ban: true
sm.ban.kick: true
sm.ban.tempban: true
default: op
sm.warp.*:
description: Use all warp commands!
children:
sm.warp.set: true
sm.warp.warp: true
sm.warp.delete: true
default: op
sm.heath.heal:
default: op
description: Heal a player!
sm.heath.feed:
default: op
description: Feed a player!
sm.heath.regen:
default: op
description: Heal and feed a player!
sm.tp.tp:
default: op
description: Teleport to a player, or another player to one!
sm.tp.tpall:
default: op
description: Teleport everyone to you!
sm.tp.tph:
default: op
description: Ask a player to teleport them to you.
sm.tp.tpa:
default: op
description: Teleport only if a player accepts!
sm.mute.mute:
default: op
description: Mute a player!
sm.mute.unmute:
default: op
description: Unmute a player!
sm.mute.canChat:
default: op
description: Sets if a muted player can chat!
sm.ban.tempban:
default: op
description: Temporarily ban a player!
sm.ban.pardon:
default: op
description: Pardon/Unban a player!
sm.ban.ban:
default: op
description: Permanently ban a player!
sm.ban.kick:
default: op
description: Kick a player!
sm.mute.tempmute:
default: op
description: Temporarily mute a player!
sm.freeze:
default: op
description: Freeze or unfreeze a player!
sm.warp.warp:
default: op
description: Teleport to a saved location!
sm.warp.set:
default: op
description: Set a warp location!
sm.warp.delete:
default: op
description: Delete a warp!
sm.setspawn:
default: op
description: Set the server spawn!
根据你所说的,那么问题一定出在你的插件文件中,而不是在你的plugin.ym或主程序class中。现在你还没有提供具体的命令和插件的代码,所以帮不了你了。
服务器很可能正在执行命令,然后什么也没有发生,仅仅是因为插件本身出现故障,而不是服务器。 开始使用您的插件进行调试。
我正在向我的我的世界服务器添加一个 teleport-here 命令。每当我在服务器中输入命令时, 没有任何反应,甚至 'unkown command' 消息也没有。我正确设置了执行程序(因为它不在主 class 中,就像我的其他完美运行的命令一样......并且该命令在 plugin.yml 中注册:/不知道发生了什么......帮助? 我正在使用 Eclipse Luna 和 1.8 spigot API.
传送class
package me.Zahachos.ServerManager.commands;
import java.util.HashMap;
import java.util.UUID;
import me.Zahachos.ServerManager.Main;
import me.Zahachos.ServerManager.managers.MessageManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class Teleport implements CommandExecutor {
public static HashMap<UUID, Integer> tpa = new HashMap<UUID, Integer>();
public static HashMap<UUID, Integer> tph = new HashMap<UUID, Integer>();
public static HashMap<UUID, UUID> tpaccept = new HashMap<UUID, UUID>();
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (cmd.getName().equalsIgnoreCase("tp")) {
if (sender.hasPermission("sm.tp.tp")) {
if (args.length == 0) {
MessageManager.getInstance().severe(sender, "Please specify a player!");
return true;
}
if (args.length == 1) {
if(!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console connot teleport! Specify a second player!");
return true;
}
Player p = (Player) sender;
Player target = null;
for (Player test : Bukkit.getOnlinePlayers()) {
if (test.getName().equals(args[0])) {
target = test;
break;
}
}
if (target == null) {
MessageManager.getInstance().severe(p, "Either that player doesn't exist or he isn't online!");
return true;
}
MessageManager.getInstance().good(p, "You have been teleported to " + target.getName());
p.teleport(target);
MessageManager.getInstance().info(target, p.getName() + " has teleported to you!");
return true;
}
if (args.length == 2) {
Player target = null;
for (Player test : Bukkit.getOnlinePlayers()) {
if (test.getName().equals(args[0])) {
target = test;
break;
}
}
Player target1 = null;
for (Player test1 : Bukkit.getOnlinePlayers()) {
if (test1.getName().equals(args[1])) {
target1 = test1;
break;
}
}
if (target == null || target1 == null) {
sender.sendMessage(ChatColor.RED + "One of the players doesn't exist or isn't online!");
return true;
}
target.teleport(target1);
MessageManager.getInstance().info(target, target1.getName() + " was teleported to you by " + sender.getName() + ".");
MessageManager.getInstance().info(target1, "You were teleported to " + target.getName() + " by " + sender.getName() + ".");
sender.sendMessage(ChatColor.GREEN + target.getName() + " has been teleported to " + target1.getName() + ".");
}
if (args.length > 2) {
MessageManager.getInstance().severe(sender, "Too many arguments!");
return true;
}
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
if (cmd.getName().equalsIgnoreCase("tpall")) {
if (sender.hasPermission("sm.tp.tpall")) {
if (!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console can't teleport players to him!");
return true;
}
if (args.length > 0) {
MessageManager.getInstance().severe(sender, "Too many arguments!");
return true;
}
Player p = (Player) sender;
for (Player player : Bukkit.getOnlinePlayers()) {
player.teleport(p);
MessageManager.getInstance().info(player, p.getName() + " has teleported everyone to him.");
}
MessageManager.getInstance().good(p, "Everyone one the server was teleported to you!");
return true;
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
if (cmd.getName().equalsIgnoreCase("tpa")) {
if (sender.hasPermission("sm.tp.tpa")) {
if (!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console cannot teleport!");
return true;
}
Player p = (Player) sender;
if (args.length == 0) {
MessageManager.getInstance().severe(p, "Please specify a player!");
return true;
}
if (args.length == 1) {
Player target = null;
for (Player test : Bukkit.getOnlinePlayers()) {
if (test.getName().equals(args[0])) {
target = test;
break;
}
}
if (target == null) {
MessageManager.getInstance().severe(p, "Either that player doesn't exist or he isn't online!");
return true;
}
tpa.put(target.getUniqueId(), 60);
tpaccept.put(target.getUniqueId(), p.getUniqueId());
if (tpa.size() == 1) {
new BukkitRunnable() {
@Override
public void run() {
if (!tpa.isEmpty()) {
for (UUID uuid : tpa.keySet()) {
Player player = Bukkit.getPlayer(uuid);
tpa.put(uuid, tpa.get(uuid) - 1);
if (tpa.get(uuid) == 10) {
if (player.isOnline()) {
MessageManager.getInstance().info(player, "Your teleport request will expire in 10 seconds!");
}
}
if (tpa.get(uuid) == 0) {
if (player.isOnline()) {
MessageManager.getInstance().severe(player, "Your teleport request has expired!");
}
tpa.remove(uuid);
tpaccept.remove(tpaccept.values().remove(uuid));
if (tpa.isEmpty()) {
this.cancel();
}
}
}
} else {
this.cancel();
}
}
}.runTaskTimer(Main.plugin, 20L, 20L);
}
MessageManager.getInstance().custom(target, ChatColor.YELLOW + "Player " + p.getName() + " has requested to teleport to you! Use " + ChatColor.YELLOW + ChatColor.BOLD + "/tpaccept" + ChatColor.RESET + ChatColor.YELLOW + " to teleport him!");
return true;
}
MessageManager.getInstance().severe(p, "Too many arguments!");
return true;
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
if (cmd.getName().equalsIgnoreCase("tphere")) {
if (sender.hasPermission("sm.tp.tph")) {
if (!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console cannot teleport!");
return true;
}
Player p = (Player) sender;
if (args.length == 0) {
MessageManager.getInstance().severe(p, "Please specify a player!");
return true;
}
if (args.length == 1) {
Player target = null;
for (Player test : Bukkit.getOnlinePlayers()) {
if (test.getName().equals(args[0])) {
target = test;
break;
}
}
if (target == null) {
MessageManager.getInstance().severe(p, "Either that player doesn't exist or he isn't online!");
return true;
}
tph.put(target.getUniqueId(), 60);
tpaccept.put(target.getUniqueId(), p.getUniqueId());
if (tph.size() == 1) {
new BukkitRunnable() {
@Override
public void run() {
if (!tph.isEmpty()) {
for (UUID uuid : tph.keySet()) {
Player player = Bukkit.getPlayer(uuid);
tph.put(uuid, tph.get(uuid) - 1);
if (tph.get(uuid) == 10) {
if (player.isOnline()) {
MessageManager.getInstance().info(player, "Your teleport request will expire in 10 seconds!");
}
}
if (tph.get(uuid) == 0) {
if (player.isOnline()) {
MessageManager.getInstance().severe(player, "Your teleport request has expired!");
}
tph.remove(uuid);
tpaccept.remove(tpaccept.values().remove(uuid));
if (tph.isEmpty()) {
this.cancel();
}
}
}
} else {
this.cancel();
}
}
}.runTaskTimer(Main.plugin, 20L, 20L);
}
MessageManager.getInstance().custom(target, ChatColor.YELLOW + "Player " + p.getName() + " has requested to teleport to you! Use " + ChatColor.YELLOW + ChatColor.BOLD + "/tpaccept" + ChatColor.RESET + ChatColor.YELLOW + " to teleport him!");
return true;
}
MessageManager.getInstance().severe(p, "Too many arguments!");
return true;
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
if (cmd.getName().equalsIgnoreCase("tpaccept")) {
if (sender.hasPermission("sm.tp.tpa")) {
if (!(sender instanceof Player)) {
MessageManager.getInstance().severe(sender, "The console cannot teleport!");
return true;
}
Player p = (Player) sender;
if (args.length == 0) {
if (tpa.containsKey(p.getUniqueId()) || tpaccept.containsKey(p.getUniqueId())) {
Player target = Bukkit.getPlayer(tpaccept.get(p.getUniqueId()));
target.teleport(p);
tpaccept.remove(p.getUniqueId());
tpa.remove(p.getUniqueId());
return true;
} else if (tpaccept.containsKey(p.getUniqueId()) || tpaccept.containsKey(p.getUniqueId())) {
Player target = Bukkit.getPlayer(tpaccept.get(p.getUniqueId()));
target.teleport(p);
tpaccept.remove(p.getUniqueId());
tpa.remove(p.getUniqueId());
return true;
} else {
MessageManager.getInstance().severe(p, "You don't have any active requests!");
return true;
}
}
MessageManager.getInstance().severe(p, "Too many arguments!");
return true;
}
MessageManager.getInstance().severe(sender, "Unfortunately you can't do that.");
return true;
}
return true;
}
}
主要class
package me.Zahachos.ServerManager;
import me.Zahachos.ServerManager.commands.Freeze;
import me.Zahachos.ServerManager.commands.HealFeed;
import me.Zahachos.ServerManager.commands.KickBan;
import me.Zahachos.ServerManager.commands.Mute;
import me.Zahachos.ServerManager.commands.Spawn;
import me.Zahachos.ServerManager.commands.Teleport;
import me.Zahachos.ServerManager.commands.Warp;
import me.Zahachos.ServerManager.listeners.JoinLeave;
import me.Zahachos.ServerManager.listeners.OnDeath;
import me.Zahachos.ServerManager.listeners.OnReconnect;
import me.Zahachos.ServerManager.managers.ConfigManager;
import me.Zahachos.ServerManager.util.Cooldown;
import me.Zahachos.ServerManager.util.utilReloadSave;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
public static Main plugin = null;
@Override
public void onEnable() {
ConfigManager.getInstance().setup(this);
getCommand("heal").setExecutor(new HealFeed());
getCommand("feed").setExecutor(new HealFeed());
getCommand("regenerate").setExecutor(new HealFeed());
getCommand("tp").setExecutor(new Teleport());
getCommand("tpall").setExecutor(new Teleport());
getCommand("tpa").setExecutor(new Teleport());
getCommand("tph").setExecutor(new Teleport());
getCommand("tpaccept").setExecutor(new Teleport());
getCommand("freeze").setExecutor(new Freeze());
getCommand("warp").setExecutor(new Warp());
getCommand("setwarp").setExecutor(new Warp());
getCommand("delwarp").setExecutor(new Warp());
getCommand("unmute").setExecutor(new Mute());
getCommand("mute").setExecutor(new Mute());
getCommand("tempmute").setExecutor(new Mute());
getCommand("tempban").setExecutor(new KickBan());
getCommand("pardon").setExecutor(new KickBan());
getCommand("ban").setExecutor(new KickBan());
getCommand("kick").setExecutor(new KickBan());
getCommand("spawn").setExecutor(new Spawn());
getCommand("setspawn").setExecutor(new Spawn());
Bukkit.getPluginManager().registerEvents(new JoinLeave(), this);
Bukkit.getPluginManager().registerEvents(new Freeze(), this);
Bukkit.getPluginManager().registerEvents(new OnReconnect(), this);
Bukkit.getPluginManager().registerEvents(new KickBan(), this);
Bukkit.getPluginManager().registerEvents(new Mute(), this);
Bukkit.getPluginManager().registerEvents(new OnDeath(), this);
Bukkit.getLogger().info("[" + this.getDescription().getName() + "] Has been enabled!");
plugin = this;
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Cooldown.handleCooldowns();
}
}, 1L, 1L);
utilReloadSave.loadBans();
utilReloadSave.loadMutes();
}
@Override
public void onDisable() {
Bukkit.getServer().getLogger().info("Basic is Disabled!");
utilReloadSave.saveMutes();
utilReloadSave.saveBans();
}
}
plugin.yml
name: ServerManager
main: me.Zahachos.ServerManager.Main
authors: [Zahachos, KarateMan]
version: 0.02
description: This manages the Zaphno's Network.
commands:
heal:
usage: /<command> [player]
aliases: [health, gethealth]
description: Heal yourself and others.
feed:
usage: /<command> [player]
aliases: [food, getfood, hunger]
description: Feed yourself and others.
regenerate:
usage: /<command> [player]
aliases: [regen, regeneration]
description: Heal and feed yourself and others.
tp:
usage: /<command> [player] [player2]
aliases: [regen, regeneration]
description: Teleport to a player, or another player to one.
tpall:
usage: /<command>
aliases: [teleportall, teleporteveryone]
description: Teleport everyone to you.
tpa:
usage: /<command> [player]
aliases: [askteleport]
description: Ask a player to teleport to him.
tph:
usage: /<command> [player]
aliases: [teleporthere, teleporth]
description: Ask a player to teleport them to you.
tpaccept:
usage: /<command>
aliases: [teleportaccept, acceptteleport]
description: Accepts the last teleport request.
freeze:
usage: /<command> [username]
aliases: [freezeplayer]
description: Freeze or unfreeze a player!
warp:
usage: /<command> [warp_name]
description: Teleport to a saved location!
setwarp:
usage: /<command> [warp_name]
description: Set a warp location!
delwarp:
usage: /<command> [warp_name]
aliases: [deletewarp]
description: Delete a warp!
mute:
usage: /<command> [username] [duration] [reason]
aliases: [muteplayer]
description: Temporarily mute a player!
tempmute:
usage: /<command>
aliases: [muteplayer]
description: Mute a player!
unmute:
usage: /<command> [username]
aliases: [unmuteplayer]
description: Unmute a player!
tempban:
usage: /<command> [username] [duration] [reason]
aliases: [tempbanplayer]
description: Temporarily ban a player!
pardon:
usage: /<command> [username]
aliases: [pardonplayer, unban]
description: Pardon/Unban a player!
ban:
usage: /<command> [username] [reason]
aliases: [setbanned, banplayer]
description: Permanently ban a player!
kick:
usage: /<command> [username] [reason]
aliases: [setbanned, banplayer]
description: Kick a player!
spawn:
usage: /<command>
description: Go to the server spawn!
setspawn:
usage: /<command>
description: Set the server spawn!
permissions:
sm.tp.*:
description: Use all tp commands!
children:
sm.tp.tph: true
sm.tp.tpa: true
sm.tp.tp: true
sm.tp.tpall: true
default: op
sm.health.*:
description: Use all health commands!
children:
sm.health.heal: true
sm.health.feed: true
sm.health.regen: true
default: op
sm.mute.*:
description: Use all mute commands!
children:
sm.mute.mute: true
sm.mute.unmute: true
sm.mute.canChat: true
sm.mute.tempmute: true
default: op
sm.ban.*:
description: Use all ban commands!
children:
sm.ban.pardon: true
sm.ban.ban: true
sm.ban.kick: true
sm.ban.tempban: true
default: op
sm.warp.*:
description: Use all warp commands!
children:
sm.warp.set: true
sm.warp.warp: true
sm.warp.delete: true
default: op
sm.heath.heal:
default: op
description: Heal a player!
sm.heath.feed:
default: op
description: Feed a player!
sm.heath.regen:
default: op
description: Heal and feed a player!
sm.tp.tp:
default: op
description: Teleport to a player, or another player to one!
sm.tp.tpall:
default: op
description: Teleport everyone to you!
sm.tp.tph:
default: op
description: Ask a player to teleport them to you.
sm.tp.tpa:
default: op
description: Teleport only if a player accepts!
sm.mute.mute:
default: op
description: Mute a player!
sm.mute.unmute:
default: op
description: Unmute a player!
sm.mute.canChat:
default: op
description: Sets if a muted player can chat!
sm.ban.tempban:
default: op
description: Temporarily ban a player!
sm.ban.pardon:
default: op
description: Pardon/Unban a player!
sm.ban.ban:
default: op
description: Permanently ban a player!
sm.ban.kick:
default: op
description: Kick a player!
sm.mute.tempmute:
default: op
description: Temporarily mute a player!
sm.freeze:
default: op
description: Freeze or unfreeze a player!
sm.warp.warp:
default: op
description: Teleport to a saved location!
sm.warp.set:
default: op
description: Set a warp location!
sm.warp.delete:
default: op
description: Delete a warp!
sm.setspawn:
default: op
description: Set the server spawn!
根据你所说的,那么问题一定出在你的插件文件中,而不是在你的plugin.ym或主程序class中。现在你还没有提供具体的命令和插件的代码,所以帮不了你了。
服务器很可能正在执行命令,然后什么也没有发生,仅仅是因为插件本身出现故障,而不是服务器。 开始使用您的插件进行调试。