Java 类org.bukkit.command.ProxiedCommandSender 实例源码

项目:Craftbukkit    文件:VanillaCommandWrapper.java   
private ICommandListener getListener(CommandSender sender) {
    if (sender instanceof Player) {
        return ((CraftPlayer) sender).getHandle();
    }
    if (sender instanceof BlockCommandSender) {
        return ((CraftBlockCommandSender) sender).getTileEntity();
    }
    if (sender instanceof CommandMinecart) {
        return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock();
    }
    if (sender instanceof RemoteConsoleCommandSender) {
        return RemoteControlCommandListener.getInstance();
    }
    if (sender instanceof ConsoleCommandSender) {
        return ((CraftServer) sender.getServer()).getServer();
    }
    if (sender instanceof ProxiedCommandSender) {
        return ((ProxiedNativeCommandSender) sender).getHandle();
    }
    throw new IllegalArgumentException("Cannot make " + sender + " a vanilla command listener");
}
项目:AdvancedCommands    文件:ReflectionHelper.java   
public static Object toNMSIComandSender(CommandSender s) {
    try {
        if (s instanceof Entity) {
            return getEntityByUUID(((Entity) s).getUniqueId());
        } else if (s instanceof ConsoleCommandSender) {
            return getServer();
        } else if (s instanceof RemoteConsoleCommandSender) {
            return getRemoteControlCommandListener();
        } else if (s instanceof ProxiedCommandSender) {
            return getProxiedCommandSender((ProxiedCommandSender) s);
        } else if (s instanceof BlockCommandSender) {
            return getCommandBlockLogic(((BlockCommandSender) s).getBlock());
        } else if (s instanceof CommandMinecart) {
            return getCommandBlockLogic((CommandMinecart) s);
        }
        return null;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
项目:SpigotSource    文件:VanillaCommandWrapper.java   
private ICommandListener getListener(CommandSender sender) {
    if (sender instanceof Player) {
        return ((CraftPlayer) sender).getHandle();
    }
    if (sender instanceof BlockCommandSender) {
        return ((CraftBlockCommandSender) sender).getTileEntity();
    }
    if (sender instanceof CommandMinecart) {
        return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock();
    }
    if (sender instanceof RemoteConsoleCommandSender) {
        return ((DedicatedServer)MinecraftServer.getServer()).remoteControlCommandListener;
    }
    if (sender instanceof ConsoleCommandSender) {
        return ((CraftServer) sender.getServer()).getServer();
    }
    if (sender instanceof ProxiedCommandSender) {
        return ((ProxiedNativeCommandSender) sender).getHandle();
    }
    throw new IllegalArgumentException("Cannot make " + sender + " a vanilla command listener");
}
项目:AdvancedCommands    文件:ReflectionHelper.java   
public static Object getProxiedCommandSender(ProxiedCommandSender s) {
    try {
        return craftProxiedCommandSenderGetHandlerMethod.invoke(s);
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
项目:AdvancedCommands    文件:CommandHelper.java   
public static World getWorldByCommandSender(CommandSender sender) {
    if (sender instanceof Entity) {
        return ((Entity) sender).getWorld();
    } else if (sender instanceof BlockCommandSender) {
        return ((BlockCommandSender) sender).getBlock().getWorld();
    } else if (sender instanceof ProxiedCommandSender) {
        return getWorldByCommandSender(((ProxiedCommandSender) sender).getCaller());
    } else {
        return null;
    }
}
项目:PlotSquared    文件:BukkitCommand.java   
@Override
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) {
    if (commandSender instanceof Player) {
        return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
    }
    if (commandSender instanceof ConsoleCommandSender || commandSender instanceof ProxiedCommandSender
            || commandSender instanceof RemoteConsoleCommandSender) {
        return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
    }
    return false;
}