本文整理汇总了Java中org.bukkit.command.ConsoleCommandSender类的典型用法代码示例。如果您正苦于以下问题:Java ConsoleCommandSender类的具体用法?Java ConsoleCommandSender怎么用?Java ConsoleCommandSender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsoleCommandSender类属于org.bukkit.command包,在下文中一共展示了ConsoleCommandSender类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canSee
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
public boolean canSee(CommandSender sender) {
if (amendedPermission == null) {
if (sender instanceof ConsoleCommandSender) {
return true;
}
for (Command command : alias.getCommands()) {
if (!command.testPermissionSilent(sender)) {
return false;
}
}
return true;
} else {
return sender.hasPermission(amendedPermission);
}
}
示例2: dispatchCommand
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
@Override
public boolean dispatchCommand(CommandSender sender, String commandLine) {
Validate.notNull(sender, "Sender cannot be null");
Validate.notNull(commandLine, "CommandLine cannot be null");
if (commandMap.dispatch(sender, commandLine)) {
return true;
}
// Cauldron start - handle vanilla commands called from plugins
if(sender instanceof ConsoleCommandSender) {
craftCommandMap.setVanillaConsoleSender(this.console);
}
return this.dispatchVanillaCommand(sender, commandLine);
// Cauldron end
}
示例3: getListener
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
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;
}
示例4: BroadcastScheduler
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
@Inject BroadcastScheduler(Loggers loggers,
@Named("configuration") Path configPath,
Scheduler scheduler,
ConsoleCommandSender console,
OnlinePlayers onlinePlayers,
LocalizedMessageMap.Factory messageMapFactory,
DocumentWatcher.Factory<List<BroadcastSchedule>> documentWatcherFactory,
Server localServer,
BroadcastFormatter formatter,
ComponentRenderContext renderer,
BroadcastSettings settings) {
this.logger = loggers.get(getClass());
this.configPath = configPath;
this.configFile = configPath.resolve(CONFIG_FILE);
this.scheduler = scheduler;
this.console = console;
this.onlinePlayers = onlinePlayers;
this.messageMapFactory = messageMapFactory;
this.documentWatcherFactory = documentWatcherFactory;
this.localServer = localServer;
this.formatter = formatter;
this.renderer = renderer;
this.settings = settings;
}
示例5: onCommand
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
Bukkit.getPluginManager().disablePlugin(Survival.instance);
Bukkit.getPluginManager().enablePlugin(Survival.instance);
Survival.instance.reloadConfig();
if(sender instanceof Player)
{
sender.sendMessage(ChatColor.AQUA + "[SurvivalPlus] " + ChatColor.GREEN + "Reload complete.");
sender.getServer().getConsoleSender().sendMessage("[SurvivalPlus] " + ChatColor.GREEN + "Reload complete.");
}
else if(sender instanceof ConsoleCommandSender)
{
sender.sendMessage("[SurvivalPlus] " + ChatColor.GREEN + "Reload complete.");
}
return true;
}
示例6: getSender
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
private static Sender getSender(CommandSender sender) {
if (sender instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity) sender;
Sender s;
if (cachedSenders.containsKey(livingEntity.getUniqueId())) {
s = cachedSenders.get(livingEntity.getUniqueId());
s.refresh(livingEntity);
} else {
cachedSenders.put(livingEntity.getUniqueId(), s = new Sender(livingEntity));
}
return s;
}
if (sender instanceof ConsoleCommandSender)
return consoleSender == null ? consoleSender = new Sender(sender) : consoleSender;
if (sender instanceof BlockCommandSender)
return new Sender(sender);
return null;
}
示例7: onArgsComplete
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
@EventHandler // Handles command-specific tab-completes.
public void onArgsComplete(TabCompleteEvent evt) {
String input = evt.getBuffer();
String label = input.split(" ")[0];
boolean console = evt.getSender() instanceof ConsoleCommandSender;
Command cmd = getUsable(evt.getSender()).stream()
.filter(c -> !c.getCommandPrefix().contains(" ") && label.length() >= c.getCommandPrefix().length()) // Don't count /trigger
.filter(c -> c.getAlias().contains(console ? label : label.substring(c.getCommandPrefix().length())))
.findAny().orElse(null); // Get the command for the input supplied.
if (!input.contains(" ") || cmd == null)
return; // No command was found.
String[] args = Utils.shift(input.split(" "));
String lastArg = (args.length > 0 ? args[args.length - 1] : "").toLowerCase();
boolean space = input.endsWith(" ");
List<String> possible = cmd.getCompletions(evt.getSender(), args, args.length + (space ? 1 : 0) - 1);
evt.setCompletions(possible.stream().filter(ac -> ac.toLowerCase().startsWith(lastArg) || space).collect(Collectors.toList()));
}
示例8: handle
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
public void handle(String msg, CommandSender sender, Cancellable event) {
if (Config.get().hiddenMode && !sender.hasPermission("camerastudio.use") && !sender.isOp()) return;
if (msg.startsWith("/cam") || msg.startsWith("/camerastudio")) {
event.setCancelled(true);
List<String> args = Lists.newArrayList(msg.split(" "));
if (args.size() > 1) {
args.remove(0);
}
Traveller traveller = null;
if (sender instanceof ConsoleCommandSender) {
traveller = new BukkitTraveller(null);
} else {
Player player = (Player) sender;
traveller = Travellers.impl().get(player.getUniqueId());
}
CmdCam.get().preExec(traveller, args);
}
}
示例9: createMockServer
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
public static Server createMockServer() {
ConsoleCommandSender commandSender = (ConsoleCommandSender) createCommandSender();
Server server = mock(Server.class);
when(server.getLogger()).thenReturn(Logger.getGlobal());
when(server.getPluginManager()).thenReturn(
new SimplePluginManager(server, new SimpleCommandMap(server)));
when(server.getItemFactory()).thenReturn(new MockItemFactory());
doAnswer(invocation -> new MockInventory(InventoryType.CHEST, invocation.getArgument(1), invocation.getArgument(2)))
.when(server).createInventory(any(), anyInt(), anyString());
when(server.getBukkitVersion()).thenReturn("1.0");
when(server.getConsoleSender()).thenReturn(commandSender);
doAnswer(invocation -> createMockWorld())
.when(server).getWorld(anyString());
return server;
}
示例10: createCommandSender
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
public static CommandSender createCommandSender() {
CommandSender sender = mock(
CommandSender.class,
withSettings().extraInterfaces(Player.class, ConsoleCommandSender.class)
);
when(sender.getServer()).thenReturn(Bukkit.getServer());
doAnswer(invocation -> {
String fixed = StringUtils.join((String[]) invocation.getArguments()[0], '\n');
System.out.println(ChatColor.stripColor(fixed));
return null;
}).when(sender).sendMessage(any(String[].class));
doAnswer(invocation -> {
sender.sendMessage(new String[]{(String) invocation.getArguments()[0]});
return null;
}).when(sender).sendMessage(anyString());
return sender;
}
示例11: execute
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
public boolean execute(CommandSender sender, String label, String[] args) {
VPSender vpSender;
if(sender instanceof Player)
vpSender = VanillaPlusCore.getPlayerManager().getPlayer(((Player)sender).getUniqueId());
else if(sender instanceof BlockCommandSender)
vpSender = new VPCommandBlock((BlockCommandSender) sender);
else if(sender instanceof ConsoleCommandSender)
vpSender = VanillaPlusCore.getVPConsole();
else
return false;
if(label.equalsIgnoreCase(PlaceH.HELP.get())){
showTopHelp(vpSender, label, args.length > 0 ? Utils.parseInt(args[0], 1, false) : 1);
return true;
}
for(CommandPlus command : getLoaded())
if(command.is(label.toLowerCase())){
if(command.hasRequirement(vpSender))
command.onExecute(vpSender, label, new LinkedList<String>(Arrays.asList(args)));
return true;
}
return false;
}
示例12: onCommand
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
@Override
protected boolean onCommand(CommandSender sender, String label, String[] arguments)
{
if (!(sender instanceof ConsoleCommandSender) && !sender.isOp())
return true;
if (arguments.length != 2)
return true;
String cheat = arguments[0];
String player = arguments[1];
String server = SamaGamesAPI.get().getServerName();
new JsonModMessage("AntiCheat", ModChannel.REPORT, ChatColor.DARK_RED, player + "#####" + server + "#####Possible usage de la triche : " + cheat).send();
return true;
}
示例13: onCommand
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (args.length > 0 && args[0].equalsIgnoreCase("reload")){
if (sender instanceof ConsoleCommandSender || sender.hasPermission("sddls.reload")) {
plugin.reloadConfig();
plugin.loadConfig();
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&6[Sddls] &rReloaded!"));
return true;
}
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&6[Sddls] &rv"+plugin.getDescription().getVersion()));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&r"+plugin.getDescription().getDescription()));
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&7"+plugin.getDescription().getWebsite()));
if (sender instanceof ConsoleCommandSender || sender.hasPermission("sddls.reload"))
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&6/sddls reload &r- reloads config"));
return true;
}
示例14: sendMessage
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
/** Send a message from a channel as console.
* @param sender {@code ConsoleCommandSender} - Console sender.
* @param message {@code FancyMessage} - Message to send.
* @param direct {@code boolean} - Send message direct to players on channel.
*/
public void sendMessage(ConsoleCommandSender sender, UltimateFancy message, boolean direct){
if (direct){
for (Player p:Bukkit.getOnlinePlayers()){
UCChannel chp = UChat.get().getPlayerChannel(p);
if (UCPerms.channelReadPerm(p, this) && !this.isIgnoring(p.getName()) && (!this.neeFocus() || chp.equals(this))){
UChat.get().getUCLogger().timings(timingType.START, "UCChannel#sendMessage()|Direct Message");
message.send(p);
}
}
message.send(sender);
} else {
UChat.get().getUCLogger().timings(timingType.START, "UCChannel#sendMessage()|Fire MessageChannelEvent");
UCMessages.sendFancyMessage(new String[0], message.toOldFormat(), this, sender, null);
}
}
示例15: injectConsole
import org.bukkit.command.ConsoleCommandSender; //导入依赖的package包/类
private void injectConsole() throws Exception {
ConsoleCommandSender consoleSender = this.plugin.getServer().getConsoleSender();
// get the ServerCommandSender class
Class<?> serverCommandSenderClass = ReflectionUtil.obcClass("command.ServerCommandSender");
// get the perm field
Field permField = serverCommandSenderClass.getDeclaredField("perm");
permField.setAccessible(true);
// get the PermissibleBase instance
PermissibleBase permBase = (PermissibleBase) permField.get(consoleSender);
// create a monitored instance which delegates to the previous PermissibleBase
MonitoredPermissibleBase newPermBase = wrap(permBase, "internal/console");
// inject the monitored instance
permField.set(consoleSender, newPermBase);
}