org.bukkit.craftbukkit.CraftServer Java Examples

The following examples show how to use org.bukkit.craftbukkit.CraftServer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VanillaCommandWrapper.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
private 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 ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlockLogic();
    }
    if (sender instanceof RemoteConsoleCommandSender) {
        return ((DedicatedServer) MinecraftServer.getServerCB()).rconConsoleSource;
    }
    if (sender instanceof ConsoleCommandSender) {
        return ((CraftServer) sender.getServer()).getServer();
    }
    if (sender instanceof ProxiedCommandSender) {
        return ((ProxiedNativeCommandSender) sender).getHandle();
    }
    if (sender instanceof CraftFunctionCommandSender) {
        return ((CraftFunctionCommandSender) sender).getHandle();
    }
    throw new IllegalArgumentException("Cannot make " + sender + " a vanilla command listener");
}
 
Example #2
Source File: SimpleHelpMap.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public SimpleHelpMap(CraftServer server) {
    this.helpTopics = new TreeMap<String, HelpTopic>(HelpTopicComparator.topicNameComparatorInstance()); // Using a TreeMap for its explicit sorting on key
    this.topicFactoryMap = new HashMap<Class, HelpTopicFactory<Command>>();
    this.server = server;
    this.yaml = new HelpYamlReader(server);

    Predicate indexFilter = Predicates.not(Predicates.instanceOf(CommandAliasHelpTopic.class));
    if (!yaml.commandTopicsInMasterIndex()) {
        indexFilter = Predicates.and(indexFilter, Predicates.not(new IsCommandTopicPredicate()));
    }

    this.defaultTopic = new IndexHelpTopic("Index", null, null, Collections2.filter(helpTopics.values(), indexFilter), "Use /help [n] to get page n of help.");

    registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());
}
 
Example #3
Source File: VanillaCommandWrapper.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: SimpleHelpMap.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public SimpleHelpMap(CraftServer server) {
    this.helpTopics = new TreeMap<String, HelpTopic>(HelpTopicComparator.topicNameComparatorInstance()); // Using a TreeMap for its explicit sorting on key
    this.topicFactoryMap = new HashMap<Class, HelpTopicFactory<Command>>();
    this.server = server;
    this.yaml = new HelpYamlReader(server);

    Predicate indexFilter = Predicates.not(Predicates.instanceOf(CommandAliasHelpTopic.class));
    if (!yaml.commandTopicsInMasterIndex()) {
        indexFilter = Predicates.and(indexFilter, Predicates.not(new IsCommandTopicPredicate()));
    }

    this.defaultTopic = new IndexHelpTopic("Index", null, null, Collections2.filter(helpTopics.values(), indexFilter), "Use /help [n] to get page n of help.");

    registerHelpTopicFactory(MultipleCommandAlias.class, new MultipleCommandAliasHelpTopicFactory());
}
 
Example #5
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityPlayer who, int clickedX, int clickedY, int clickedZ, EnumFacing clickedFace, ItemStack itemstack, net.minecraft.item.Item item) {
    Player player = (who == null) ? null : (Player) who.getBukkitEntity();
    CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
    Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());

    CraftWorld craftWorld = (CraftWorld) player.getWorld();
    CraftServer craftServer = (CraftServer) player.getServer();

    Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
    BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);

    PlayerEvent event = null;
    if (isFilling) {
        event = new PlayerBucketFillEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketFillEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    } else {
        event = new PlayerBucketEmptyEvent(player, blockClicked, blockFace, bucket, itemInHand);
        ((PlayerBucketEmptyEvent) event).setCancelled(!canBuild(craftWorld, player, clickedX, clickedZ));
    }

    craftServer.getPluginManager().callEvent(event);

    return event;
}
 
Example #6
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public static net.minecraft.inventory.Container callInventoryOpenEvent(net.minecraft.entity.player.EntityPlayerMP player, net.minecraft.inventory.Container container, boolean closeInv) {
    if (player.openContainer != player.inventoryContainer && closeInv) { // fire INVENTORY_CLOSE if one already open
// Cauldron end
        player.playerNetServerHandler.processCloseWindow(new net.minecraft.network.play.client.C0DPacketCloseWindow(player.openContainer.windowId));
    }

    CraftServer server = player.worldObj.getServer();
    CraftPlayer craftPlayer = player.getBukkitEntity();
    // Cauldron start - vanilla compatibility
    try {
        player.openContainer.transferTo(container, craftPlayer);
    }
    catch (AbstractMethodError e) {
        // do nothing
    }
    // Cauldron end
    InventoryOpenEvent event = new InventoryOpenEvent(container.getBukkitView());
    if (container.getBukkitView() != null) server.getPluginManager().callEvent(event); // Cauldron - allow vanilla mods to bypass

    if (event.isCancelled()) {
        container.transferTo(player.openContainer, craftPlayer);
        // Cauldron start - handle close for modded containers
        if (!closeInv) { // fire INVENTORY_CLOSE if one already open
            player.openContainer = container; // make sure the right container is processed
            player.closeScreen();
            player.openContainer = player.inventoryContainer;
        }
        // Cauldron end
        return null;
    }

    return container;
}
 
Example #7
Source File: CraftLivingEntity.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public CraftLivingEntity(final CraftServer server, final net.minecraft.entity.EntityLivingBase entity) {
    super(server, entity);
    // Cauldron start
    this.entityClass = entity.getClass();
    this.entityName = EntityRegistry.getCustomEntityTypeName(entityClass);
    if (entityName == null)
        entityName = entity.getCommandSenderName();
    // Cauldron end

    if (entity instanceof net.minecraft.entity.EntityLiving) {
        equipment = new CraftEntityEquipment(this);
    }
}
 
Example #8
Source File: AbstractProjectile.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public AbstractProjectile(CraftServer server, net.minecraft.entity.Entity entity) {
    super(server, entity);
    doesBounce = false;
}
 
Example #9
Source File: CraftCaveSpider.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftCaveSpider(CraftServer server, EntityCaveSpider entity) {
    super(server, entity);
}
 
Example #10
Source File: CraftMinecartFurnace.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftMinecartFurnace(CraftServer server, EntityMinecartFurnace entity) {
    super(server, entity);
}
 
Example #11
Source File: CraftSilverfish.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftSilverfish(CraftServer server, EntitySilverfish entity) {
    super(server, entity);
}
 
Example #12
Source File: CraftComplexLivingEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftComplexLivingEntity(CraftServer server, EntityLivingBase entity) {
    super(server, entity);
}
 
Example #13
Source File: CraftItem.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftItem(CraftServer server, net.minecraft.entity.item.EntityItem entity) {
    this(server, entity, entity);
}
 
Example #14
Source File: CraftSquid.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftSquid(CraftServer server, net.minecraft.entity.passive.EntitySquid entity) {
    super(server, entity);
}
 
Example #15
Source File: CraftSpider.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftSpider(CraftServer server, net.minecraft.entity.monster.EntitySpider entity) {
    super(server, entity);
}
 
Example #16
Source File: CraftWeather.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftWeather(final CraftServer server, final EntityWeatherEffect entity) {
    super(server, entity);
}
 
Example #17
Source File: CraftItemFrame.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftItemFrame(CraftServer server, EntityItemFrame entity) {
    super(server, entity);
}
 
Example #18
Source File: CraftVex.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftVex(CraftServer server, EntityVex entity) {
    super(server, entity);
}
 
Example #19
Source File: CraftBoat.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftBoat(CraftServer server, EntityBoat entity) {
    super(server, entity);
}
 
Example #20
Source File: CraftComplexPart.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftComplexPart(CraftServer server, MultiPartEntityPart entity) {
    super(server, entity);
}
 
Example #21
Source File: CraftBat.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftBat(CraftServer server, EntityBat entity) {
    super(server, entity);
}
 
Example #22
Source File: CustomProjectileEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CustomProjectileEntity(CraftServer server, Entity entity) {
    super(server, entity);
}
 
Example #23
Source File: CraftAgeable.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftAgeable(CraftServer server, EntityAgeable entity) {
    super(server, entity);
}
 
Example #24
Source File: ConsoleCommandCompleter.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public ConsoleCommandCompleter(CraftServer server) {
    this.server = server;
}
 
Example #25
Source File: CraftThrownExpBottle.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftThrownExpBottle(CraftServer server, net.minecraft.entity.item.EntityExpBottle entity) {
    super(server, entity);
}
 
Example #26
Source File: CraftMagmaCube.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftMagmaCube(CraftServer server, net.minecraft.entity.monster.EntityMagmaCube entity) {
    super(server, entity);
}
 
Example #27
Source File: AbstractProjectile.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public AbstractProjectile(CraftServer server, net.minecraft.entity.Entity entity) {
    super(server, entity);
    doesBounce = false;
}
 
Example #28
Source File: CraftFallingSand.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftFallingSand(CraftServer server, net.minecraft.entity.item.EntityFallingBlock entity) {
    super(server, entity);
}
 
Example #29
Source File: CraftMonster.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftMonster(CraftServer server, EntityMob entity) {
    super(server, entity);
}
 
Example #30
Source File: CraftItem.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftItem(CraftServer server, net.minecraft.entity.Entity entity, net.minecraft.entity.item.EntityItem item) {
    super(server, entity);
    this.item = item;
}