private net.minecraft.command.ICommandSender getListener(CommandSender sender) { if (sender instanceof Player) { return ((CraftPlayer) sender).getHandle(); } if (sender instanceof BlockCommandSender) { return ((CraftBlockCommandSender) sender).getTileEntity(); } if (sender instanceof CommandMinecart) { return ((net.minecraft.entity.EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).func_145822_e(); } if (sender instanceof RemoteConsoleCommandSender) { return net.minecraft.network.rcon.RConConsoleSource.instance; } if (sender instanceof ConsoleCommandSender) { return ((CraftServer) sender.getServer()).getServer(); } return null; }
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.instance; } if (sender instanceof ConsoleCommandSender) { return ((CraftServer) sender.getServer()).getServer(); } return null; }
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"); }
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); } }
@Override public Locale localeForCommandSender(CommandSender sender) { if(sender instanceof BlockCommandSender) return commandBlockLocale; if(sender instanceof ConsoleCommandSender) return consoleLocale; if(sender instanceof RemoteConsoleCommandSender) return remoteConsoleLocale; if(sender instanceof Player) return LocaleUtils.toLocale(fetcher.getLocaleForPlayer((Player) sender)); return Locale.ENGLISH; }
private MCCommandSender parseSender(CommandSender s, MCSubcommand mcsc){ if (mcsc.commandSender().equals(MCCommandSender.GENERIC) || mcsc.commandSender().equals(null)){ return MCCommandSender.GENERIC; } else if (s instanceof ConsoleCommandSender){ return MCCommandSender.CONSOLE; } else if (s instanceof Player){ return MCCommandSender.PLAYER; } else if (s instanceof RemoteConsoleCommandSender){ return MCCommandSender.REMOTE; } else if (s instanceof BlockCommandSender){ return MCCommandSender.COMMANDBLOCK; }else{ return MCCommandSender.GENERIC; } }
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"); }
@Override protected void sendMessage(CommandSender sender, String s) { // we can safely send async for players and the console if (sender instanceof Player || sender instanceof ConsoleCommandSender || sender instanceof RemoteConsoleCommandSender) { sender.sendMessage(s); return; } // otherwise, send the message sync getPlugin().getScheduler().doSync(new SyncMessengerAgent(sender, s)); }
@Override protected void doExecute(CommandSender sender, String[] args) { if ((sender instanceof Player)||(sender instanceof ConsoleCommandSender)||(sender instanceof RemoteConsoleCommandSender)){ if (args.length != 1) { throw new IllegalArgumentException("Wrong arguments length"); } switch (args[0]) { case "save": saveVarTable(sender); break; case "load": if (plugin.getVarTable().isDirty()) { sender.sendMessage(ChatColor.RED.toString() + ChatColor.ITALIC.toString() + ChatColor.BOLD.toString() + "Warning:"); sender.sendMessage(ChatColor.RED.toString() + ChatColor.ITALIC.toString()+ "The var table is modify, and not saved!"); sender.sendMessage(ChatColor.RED.toString() + ChatColor.ITALIC.toString()+ "If you want to continue, use '/varTable load!'."); } else { loadVarTable(sender); } break; case "load!": loadVarTable(sender); break; default: throw new IllegalArgumentException(String.format("Unknown argument %s", args[0])); } }else{ throw new IllegalAccessError("Only a op/console can execute this command"); } }
@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; }
@Override public synchronized void start() { if (sender instanceof RemoteConsoleCommandSender) { run(); } else { super.start(); } }
public boolean isValidSender(CommandSender sender) { switch (this) { case PLAYER_ONLY: return (sender instanceof Player); case NO_PLAYER: return (sender instanceof ConsoleCommandSender || sender instanceof RemoteConsoleCommandSender || sender instanceof BlockCommandSender); case CONSOLE_ONLY: return (sender instanceof ConsoleCommandSender || sender instanceof RemoteConsoleCommandSender); case BLOCK_ONLY: return (sender instanceof BlockCommandSender); case DEFAULT: return true; } return false; }
public List<String> execute(Instances instances, CommandSender sender, String[] args) { switch (SenderType.getSenderType(sender)) { case BLOCK: return execute(instances, (BlockCommandSender) sender, args); case CONSOLE: return execute(instances, (ConsoleCommandSender) sender, args); case PLAYER: return execute(instances, (Player) sender, args); case RCONSOLE: return execute(instances, (RemoteConsoleCommandSender) sender, args); } return null; }
private boolean iARemoteConsoleCommandSender(final RemoteConsoleCommandSender rccs, final String node) { return true; }
public RconCommandPreprocessEvent(RemoteConsoleCommandSender sender, String message) { mSender = sender; mMessage = message; }
public RemoteConsoleCommandSender getSender() { return mSender; }
public List<String> execute(Instances instances, RemoteConsoleCommandSender sender, String[] args) { return null; }
/** * Returns if something has the specified permission node. That something can be one of the following: * <ul> * <li>Player</li> * <li>OfflinePlayer</li> * <li>CommandSender</li> * <li>RemoteConsoleCommandSender</li> * <li>BlockCommandSender</li> * </ul> * Anything else will throw an IllegalArgumentException. * * @param o Thing to check for permissions * @param node Node to check for * @return true or false * @throws IllegalArgumentException If invalid type if passed for <code>o</code>. */ protected boolean isAuthorized(final Object o, final String node) { if (o instanceof RemoteConsoleCommandSender) return this.iARemoteConsoleCommandSender((RemoteConsoleCommandSender) o, node); else if (o instanceof Player) return this.iAPlayer((Player) o, node); else if (o instanceof OfflinePlayer) return this.iAOfflinePlayer((OfflinePlayer) o, node); else if (o instanceof BlockCommandSender) return this.iABlockCommandSender((BlockCommandSender) o, node); else if (o instanceof CommandSender) return this.iACommandSender((CommandSender) o, node); else throw new IllegalArgumentException("Object was not a valid authorizable!"); }