本文整理匯總了Java中org.bukkit.command.BlockCommandSender類的典型用法代碼示例。如果您正苦於以下問題:Java BlockCommandSender類的具體用法?Java BlockCommandSender怎麽用?Java BlockCommandSender使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BlockCommandSender類屬於org.bukkit.command包,在下文中一共展示了BlockCommandSender類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getListener
import org.bukkit.command.BlockCommandSender; //導入依賴的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;
}
示例2: getSender
import org.bukkit.command.BlockCommandSender; //導入依賴的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;
}
示例3: onCommand
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
BlockCommandSender bcs = (BlockCommandSender) sender;
if (!Dungeons.isDungeon(bcs.getBlock().getWorld())) {
sender.sendMessage(ChatColor.RED + "This command can only be run in a dungeon.");
return;
}
Dungeon d = getDungeon(bcs);
if (d.isEditMode()) {
sender.sendMessage(ChatColor.RED + "This command cannot be run in edit-mode.");
return;
}
super.onCommand(sender, args);
if (deleteOnExecute() && !d.isEditMode())
bcs.getBlock().setType(Material.AIR); // Delete this command-block on execute, provided we aren't in edit-mode.
}
示例4: execute
import org.bukkit.command.BlockCommandSender; //導入依賴的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;
}
示例5: getMailSender
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
/**
* CommandSenderから、MailSenderを作成して返す
* @param sender
* @return MailSender
*/
public static MailSender getMailSender(CommandSender sender) {
if ( sender == null ) {
return null;
} else if ( sender instanceof BlockCommandSender ) {
return new MailSenderBlock((BlockCommandSender)sender);
} else if ( sender instanceof ConsoleCommandSender ) {
return new MailSenderConsole((ConsoleCommandSender)sender);
} else if ( sender instanceof OfflinePlayer ) {
OfflinePlayer player = (OfflinePlayer)sender;
if ( Utility.isCB178orLater() ) {
return new MailSenderPlayer("$" + player.getUniqueId().toString());
} else {
return new MailSenderPlayer(player.getName());
}
}
return null;
}
示例6: getListener
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
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;
}
示例7: execute
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
@Override
public boolean execute(org.bukkit.command.CommandSender sender, String label, String[] args) {
if(!this.testPermission(sender)) {
return true;
}
if((!this.command.player() && sender instanceof Player) || (!this.command.console() && sender instanceof ConsoleCommandSender) || (!this.command.commandblock() && sender instanceof BlockCommandSender)) {
sendMessage(sender, "internal.cannot-use-command");
return true;
}
if(args.length < this.command.min() || (this.command.max() > 0 && args.length > this.command.max())) {
sendUsage(sender, label, this.command.usage());
return true;
}
try {
this.method.invoke(this.executor, sender, label, args);
} catch(Throwable e) {
sendMessage(sender, "internal.command-error");
ModuleManager.getLogger().log(Level.SEVERE, "Exception while executing Peacecraft command \"" + label + "\".", e);
}
return true;
}
示例8: getListener
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
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");
}
示例9: toNMSIComandSender
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
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);
}
}
示例10: localeForCommandSender
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
@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;
}
示例11: getName
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
protected final String getName(CommandSender sender)
{
if (sender instanceof BlockCommandSender)
{
BlockCommandSender commandBlock = (BlockCommandSender) sender;
Location location = commandBlock.getBlock().getLocation();
return FormatUtil.format("CommandBlock ({0}, {1}, {2})", location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
else if (sender instanceof ConsoleCommandSender)
{
return "Console";
}
else
{
return sender.getName();
}
}
示例12: parseSender
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
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;
}
}
示例13: getListener
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
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");
}
示例14: canUse
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
@Override
public boolean canUse(CommandSender sender, boolean showMessage) {
boolean passBlock = sender instanceof BlockCommandSender;
if (!passBlock && showMessage)
sender.sendMessage(ChatColor.RED + "This command can only be in a command block.");
return passBlock;
}
示例15: getLocation
import org.bukkit.command.BlockCommandSender; //導入依賴的package包/類
public static Location getLocation(CommandSender sender) {
if (sender instanceof Entity) {
return ((Entity)sender).getLocation();
} else if (sender instanceof BlockCommandSender) {
return ((BlockCommandSender)sender).getBlock().getLocation().add(0.5f, 0.5f, 0.5f);
}
return null;
}