Search in sources :

Example 36 with CraftServer

use of org.bukkit.craftbukkit.v1_15_R1.CraftServer in project LoliServer by Loli-Server.

the class CommandDispatcherHook method onRegisterPost.

public static <S> void onRegisterPost(RootCommandNode<S> root, CommandNode<S> child) {
    if (Bukkit.getServer() instanceof CraftServer) {
        CraftServer craftServer = (CraftServer) Bukkit.getServer();
        if (craftServer.isVanillaCommandRegistered && !craftServer.isSyncingCommand && !(child.getCommand() instanceof BukkitCommandWrapper)) {
            Commands dispatcher = craftServer.getServer().getCommands();
            RootCommandNode<CommandSource> vanillaRoot = dispatcher.getDispatcher().getRoot();
            if (root == vanillaRoot) {
                craftServer.getCommandMap().register("minecraft", new VanillaCommandWrapper(dispatcher, (CommandNode<CommandSource>) child));
            }
        }
    }
}
Also used : CommandNode(com.mojang.brigadier.tree.CommandNode) RootCommandNode(com.mojang.brigadier.tree.RootCommandNode) BukkitCommandWrapper(org.bukkit.craftbukkit.v1_16_R3.command.BukkitCommandWrapper) Commands(net.minecraft.command.Commands) VanillaCommandWrapper(org.bukkit.craftbukkit.v1_16_R3.command.VanillaCommandWrapper) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer) CommandSource(net.minecraft.command.CommandSource)

Example 37 with CraftServer

use of org.bukkit.craftbukkit.v1_15_R1.CraftServer in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelperImpl method registerStonecuttingRecipe.

@Override
public void registerStonecuttingRecipe(String keyName, String group, ItemStack result, ItemStack[] ingredient, boolean exact) {
    ResourceLocation key = new ResourceLocation("denizen", keyName);
    Ingredient itemRecipe = itemArrayToRecipe(ingredient, exact);
    StonecutterRecipe recipe = new StonecutterRecipe(key, group, itemRecipe, CraftItemStack.asNMSCopy(result));
    ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().addRecipe(recipe);
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) CraftServer(org.bukkit.craftbukkit.v1_18_R2.CraftServer)

Example 38 with CraftServer

use of org.bukkit.craftbukkit.v1_15_R1.CraftServer in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelperImpl method registerSmithingRecipe.

@Override
public void registerSmithingRecipe(String keyName, ItemStack result, ItemStack[] baseItem, boolean baseExact, ItemStack[] upgradeItem, boolean upgradeExact) {
    ResourceLocation key = new ResourceLocation("denizen", keyName);
    Ingredient baseItemRecipe = itemArrayToRecipe(baseItem, baseExact);
    Ingredient upgradeItemRecipe = itemArrayToRecipe(upgradeItem, upgradeExact);
    UpgradeRecipe recipe = new UpgradeRecipe(key, baseItemRecipe, upgradeItemRecipe, CraftItemStack.asNMSCopy(result));
    ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().addRecipe(recipe);
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) CraftServer(org.bukkit.craftbukkit.v1_18_R2.CraftServer)

Example 39 with CraftServer

use of org.bukkit.craftbukkit.v1_15_R1.CraftServer in project Denizen-For-Bukkit by DenizenScript.

the class ItemHelperImpl method renderEntireMap.

@Override
public boolean renderEntireMap(int mapId, int xMin, int zMin, int xMax, int zMax) {
    MapItemSavedData worldmap = ((CraftServer) Bukkit.getServer()).getServer().getLevel(net.minecraft.world.level.Level.OVERWORLD).getMapData("map_" + mapId);
    if (worldmap == null) {
        return false;
    }
    renderFullMap(worldmap, xMin, zMin, xMax, zMax);
    return true;
}
Also used : MapItemSavedData(net.minecraft.world.level.saveddata.maps.MapItemSavedData) CraftServer(org.bukkit.craftbukkit.v1_18_R2.CraftServer)

Example 40 with CraftServer

use of org.bukkit.craftbukkit.v1_15_R1.CraftServer in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditorImpl method updatePlayer.

@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
    final ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    final UUID uuid = player.getUniqueId();
    ClientboundRemoveEntitiesPacket destroyPacket = new ClientboundRemoveEntitiesPacket(entityPlayer.getId());
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (!p.getUniqueId().equals(uuid)) {
            PacketHelperImpl.send(p, destroyPacket);
        }
    }
    new BukkitRunnable() {

        @Override
        public void run() {
            ClientboundPlayerInfoPacket playerInfo = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, entityPlayer);
            ClientboundAddPlayerPacket spawnPacket = new ClientboundAddPlayerPacket(entityPlayer);
            for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                PacketHelperImpl.send(player, playerInfo);
                if (!player.getUniqueId().equals(uuid)) {
                    PacketHelperImpl.send(player, spawnPacket);
                } else {
                    if (isSkinChanging) {
                        ((CraftServer) Bukkit.getServer()).getHandle().respawn(entityPlayer, (ServerLevel) entityPlayer.level, true, player.getLocation(), false);
                    }
                    player.updateInventory();
                }
            }
        }
    }.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) ClientboundRemoveEntitiesPacket(net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket) Player(org.bukkit.entity.Player) ServerPlayer(net.minecraft.server.level.ServerPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) ServerPlayer(net.minecraft.server.level.ServerPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer) ClientboundAddPlayerPacket(net.minecraft.network.protocol.game.ClientboundAddPlayerPacket) UUID(java.util.UUID) CraftServer(org.bukkit.craftbukkit.v1_18_R2.CraftServer) ClientboundPlayerInfoPacket(net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)49 CraftServer (org.bukkit.craftbukkit.v1_16_R3.CraftServer)38 Player (org.bukkit.entity.Player)29 CraftServer (org.bukkit.craftbukkit.v1_18_R2.CraftServer)23 MinecraftServer (net.minecraft.server.MinecraftServer)22 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)21 CraftServer (org.bukkit.craftbukkit.v1_17_R1.CraftServer)21 ResourceLocation (net.minecraft.resources.ResourceLocation)20 NotNull (org.jetbrains.annotations.NotNull)18 ServerPlayer (net.minecraft.server.level.ServerPlayer)16 OfflinePlayer (org.bukkit.OfflinePlayer)16 CraftServer (org.bukkit.craftbukkit.v1_12_R1.CraftServer)16 Block (org.bukkit.block.Block)15 ServerLevel (net.minecraft.server.level.ServerLevel)14 Property (com.mojang.authlib.properties.Property)13 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)11 CraftBlock (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)10 CraftServer (org.bukkit.craftbukkit.v1_18_R1.CraftServer)8 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)7 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)7