本文整理匯總了Java中org.bukkit.event.player.PlayerCommandPreprocessEvent.isCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerCommandPreprocessEvent.isCancelled方法的具體用法?Java PlayerCommandPreprocessEvent.isCancelled怎麽用?Java PlayerCommandPreprocessEvent.isCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.player.PlayerCommandPreprocessEvent
的用法示例。
在下文中一共展示了PlayerCommandPreprocessEvent.isCancelled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@HookHandler(priority = Priority.CRITICAL, ignoreCanceled = true)
public void onCommand(final PlayerCommandHook hook) {
String command = "";
for (String s : hook.getCommand()) {
command += s + " ";
}
PlayerCommandPreprocessEvent event =
new PlayerCommandPreprocessEvent(new CanaryPlayer(hook.getPlayer()), command) {
@Override
public void setMessage(String msg) {
super.setMessage(msg);
// Set command
}
};
event.setCancelled(hook.isCanceled());
server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
hook.setCanceled();
}
if (server.dispatchCommand(new CanaryCommandSender(hook.getPlayer()), command)) {
hook.setCanceled(); //TODO: is this the best possible way?
}
}
示例2: onPlayerCommandPreprocess
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
if (!event.isCancelled())
{
Player player = event.getPlayer();
String command[] = event.getMessage().split(" ");
PlayerProfile profile = CoreData.getProfile(player);
if (command[0].equalsIgnoreCase("/home"))
{
plugin.getCoreMethods().teleport(player, profile.getHomeLocation().toLocation());
}
}
}
示例3: onPlayerCommandPreprocess
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
if (!event.isCancelled())
{
Player player = event.getPlayer();
String command[] = event.getMessage().split(" ");
if (command[0].equalsIgnoreCase("/spawn"))
{
if (player.getLocation().getWorld() == plugin.getCoreData().getSpawnLocation().getWorld())
{
plugin.getCoreMethods().teleport(player, plugin.getCoreData().getSpawnLocation());
}
else
{
plugin.getCoreErrors().mustBeInWorld(player, "main world");
}
}
}
}
示例4: onPlayerCommandPreprocess
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
if (!event.isCancelled())
{
Player player = event.getPlayer();
String command[] = event.getMessage().split(" ");
PlayerProfile profile = CoreData.getProfile(player);
if (command[0].equalsIgnoreCase("/spy"))
{
if (profile.isModMode())
{
plugin.getCoreMethods().hidePlayer(player);
player.sendMessage(ChatColor.GREEN + "You're now hidden from other players except people in mod mode.");
}
else
{
plugin.getCoreErrors().enableModMode(player);
}
}
}
}
示例5: onPlayerCommandPreprocess
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
{
if (!event.isCancelled())
{
Player player = event.getPlayer();
String command[] = event.getMessage().split(" ");
PlayerProfile profile = CoreData.getProfile(player);
if (command[0].equalsIgnoreCase("/god"))
{
if (profile.isModMode())
{
//todo make this a var passed by user with reason
profile.setData("Godmode", System.currentTimeMillis() + 1800000);
}
else
{
plugin.getCoreErrors().enableModMode(player);
}
}
}
}
示例6: onAction
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onAction(PlayerCommandPreprocessEvent e) {
if (e.isCancelled()) return;
boolean isAction = false;
String commandUsed = "";
for (String start : Config.actionAliases) {
if (!e.getMessage().startsWith(start)) continue;
isAction = true;
commandUsed = start;
break;
}
if (!isAction) return;
String message = Config.btiAction;
message = replaceVars(e, message);
message = message.replace("{message}", e.getMessage().substring(commandUsed.length()));
plugin.bh.sendMessage(message);
}
示例7: PlayerPreCommandHiddenPassword
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PlayerPreCommandHiddenPassword(final PlayerCommandPreprocessEvent event)
{
if (!plugin.isHidingPasswordsFromConsoleEnabled())
return;
final Player player = event.getPlayer();
final String message = event.getMessage().substring(1).toLowerCase();
final String[] split = PATTERN_SPACE.split(message);
final PluginCommand login = plugin.getCommand("login");
if (event.isCancelled())
return;
if ("login".equals(split[0]) || login.getAliases().contains(split[0]))
{
login.execute(player, split[0], ChatHelperExtended.shiftArray(split, 1));
event.setCancelled(true);
return;
}
final PluginCommand register = plugin.getCommand("register");
if ("register".equals(split[0]) || register.getAliases().contains(split[0]) || message.startsWith("cl password") || message.startsWith("crazylogin password"))
{
register.execute(player, split[0], ChatHelperExtended.shiftArray(split, 1));
event.setCancelled(true);
return;
}
}
示例8: processCommands
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void processCommands(PlayerCommandPreprocessEvent evt) {
if (evt.isCancelled() || evt.isAsynchronous()) return;
Command cmd = CommandFactory.commands.get(evt.getMessage());
if (cmd == null || cmd instanceof ConsoleOnly) return;
cmd.run(evt.getPlayer());
}
示例9: input
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
/**
* Input Listener
*
* @param event Event
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void input(PlayerCommandPreprocessEvent event) {
if (!event.isCancelled() && enabled && input.keySet().contains(event.getPlayer().getUniqueId())) {
JSONObject json = new JSONObject();
json.put("message", event.getMessage());
input.get(event.getPlayer().getUniqueId()).run(json);
input.remove(event.getPlayer().getUniqueId());
event.setCancelled(true);
}
}
示例10: onxAuthLogin
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler
public void onxAuthLogin(PlayerCommandPreprocessEvent event) {
if (event.isCancelled())
return;
String cmd = event.getMessage().split(" ")[0];
if (!cmd.equalsIgnoreCase("/register") && !cmd.equalsIgnoreCase("/login"))
return;
final Player player = event.getPlayer();
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
public void run() {
playerLogin(player);
}
}, 10L);
}
示例11: on
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void on(PlayerCommandPreprocessEvent e)
{
if(e.isCancelled())
{
return;
}
if(processCommand(e.getPlayer(), getParameters(e.getMessage())))
{
e.setCancelled(true);
}
}
示例12: onCommandPreprocess
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR)
public void onCommandPreprocess(PlayerCommandPreprocessEvent event) {
if(!event.isCancelled()) {
if (event.getPlayer().hasMetadata("SGCmd")) {
event.getPlayer().performCommand(event.getMessage().substring(1));
event.getPlayer().removeMetadata("SGCmd", this);
}
}
}
示例13: handleCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
private void handleCommand(String s) {
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.startTiming(); // Spigot
// CraftBukkit start
CraftPlayer player = this.getPlayer();
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(player, s, new LazyPlayerSet());
this.server.getPluginManager().callEvent(event);
if (event.isCancelled()) {
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
try {
// Spigot Start
if ( org.spigotmc.SpigotConfig.logCommands )
{
this.minecraftServer.getLogger().info(event.getPlayer().getName() + " issued server command: " + event.getMessage()); // CraftBukkit
}
// Spigot end
if (this.server.dispatchCommand(event.getPlayer(), event.getMessage().substring(1))) {
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
} catch (org.bukkit.command.CommandException ex) {
player.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
java.util.logging.Logger.getLogger(PlayerConnection.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
}
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
// CraftBukkit end
/* CraftBukkit start - No longer needed as we have already handled it in server.dispatchServerCommand above.
this.minecraftServer.getCommandHandler().a(this.player, s);
// CraftBukkit end */
}
示例14: onPlayerCommandPreprocessEvent
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
private final void onPlayerCommandPreprocessEvent(final PlayerCommandPreprocessEvent event) {
if(event.isCancelled()) {
return;
}
final Player player = event.getPlayer();
if(!player.hasPermission("commandscosts.bypass")) {
return;
}
final String rawCost = config.commands.get(event.getMessage().substring(1).split(" ")[0]);
if(rawCost == null) {
return;
}
final Double cost = Utils.doubleTryParse(rawCost);
if(cost == null) {
return;
}
if(!SkyowalletAPI.hasAccount(player)) {
player.sendMessage(Skyowallet.messages.message33);
return;
}
final SkyowalletAccount account = SkyowalletAPI.getAccount(player);
final double wallet = account.getWallet() - cost;
if(wallet < 0.0) {
player.sendMessage(PlaceholderFormatter.format(config.message1, new Placeholder("/cost/", String.valueOf(cost)), new CurrencyNamePlaceholder(cost)));
event.setCancelled(true);
return;
}
account.setWallet(wallet);
}
示例15: onPlayerCommand
import org.bukkit.event.player.PlayerCommandPreprocessEvent; //導入方法依賴的package包/類
protected void onPlayerCommand(PlayerCommandPreprocessEvent event) {
if (event.isCancelled() || !FactionChat.FactionsEnable) {
return;
}
String message = event.getMessage();
String[] split = message.split(" ");
if (split.length < 2) {
return;
}
if (split[0].equalsIgnoreCase("/factions") || split[0].equalsIgnoreCase(("/" + plugin.FactionsCommand))) {
if (split[1].equalsIgnoreCase("chat") || split[1].equalsIgnoreCase("c")) {
event.setCancelled(true);
Player player = event.getPlayer();
String senderFaction = FactionChat.factionsAPI.getFactionName(player);
if (senderFaction.contains("Wilderness") && !player.hasPermission("FactionChat.UserAssistantChat")
&& !plugin.isDebugger(player.getName())) {
//checks if player is in a faction
//mangaddp juniormoderators FactionChat.JrModChat
player.sendMessage(ChatColor.RED + Config.messageNotInFaction);
return;
}
if (split.length >= 3) {
ChatMode.setChatMode(player, split[2]);
} else {
ChatMode.NextChatMode(player);
}
}
}
}