Search in sources :

Example 21 with CraftServer

use of org.bukkit.craftbukkit.v1_17_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_17_R1.CraftServer)

Example 22 with CraftServer

use of org.bukkit.craftbukkit.v1_17_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_17_R1.CraftServer)

Example 23 with CraftServer

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

the class PlayerHelperImpl method setTemporaryOp.

@Override
public void setTemporaryOp(Player player, boolean op) {
    MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
    GameProfile profile = ((CraftPlayer) player).getProfile();
    ServerOpList opList = server.getPlayerList().getOps();
    if (op) {
        int permLevel = server.getOperatorUserPermissionLevel();
        opList.add(new ServerOpListEntry(profile, permLevel, opList.canBypassPlayerLimit(profile)));
    } else {
        opList.remove(profile);
    }
    player.recalculatePermissions();
}
Also used : GameProfile(com.mojang.authlib.GameProfile) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) CraftServer(org.bukkit.craftbukkit.v1_17_R1.CraftServer) ServerOpListEntry(net.minecraft.server.players.ServerOpListEntry) MinecraftServer(net.minecraft.server.MinecraftServer) ServerOpList(net.minecraft.server.players.ServerOpList)

Example 24 with CraftServer

use of org.bukkit.craftbukkit.v1_17_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().moveToWorld(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) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) Player(org.bukkit.entity.Player) ServerPlayer(net.minecraft.server.level.ServerPlayer) ServerPlayer(net.minecraft.server.level.ServerPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) ClientboundAddPlayerPacket(net.minecraft.network.protocol.game.ClientboundAddPlayerPacket) UUID(java.util.UUID) CraftServer(org.bukkit.craftbukkit.v1_17_R1.CraftServer) ClientboundPlayerInfoPacket(net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket)

Example 25 with CraftServer

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

the class ItemHelperImpl method registerFurnaceRecipe.

@Override
public void registerFurnaceRecipe(String keyName, String group, ItemStack result, ItemStack[] ingredient, float exp, int time, String type, boolean exact) {
    ResourceLocation key = new ResourceLocation("denizen", keyName);
    Ingredient itemRecipe = itemArrayToRecipe(ingredient, exact);
    AbstractCookingRecipe recipe;
    if (type.equalsIgnoreCase("smoker")) {
        recipe = new SmokingRecipe(key, group, itemRecipe, CraftItemStack.asNMSCopy(result), exp, time);
    } else if (type.equalsIgnoreCase("blast")) {
        recipe = new BlastingRecipe(key, group, itemRecipe, CraftItemStack.asNMSCopy(result), exp, time);
    } else if (type.equalsIgnoreCase("campfire")) {
        recipe = new CampfireCookingRecipe(key, group, itemRecipe, CraftItemStack.asNMSCopy(result), exp, time);
    } else {
        recipe = new SmeltingRecipe(key, group, itemRecipe, CraftItemStack.asNMSCopy(result), exp, time);
    }
    ((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().addRecipe(recipe);
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) CraftServer(org.bukkit.craftbukkit.v1_17_R1.CraftServer)

Aggregations

GameProfile (com.mojang.authlib.GameProfile)14 ResourceLocation (net.minecraft.resources.ResourceLocation)8 CraftServer (org.bukkit.craftbukkit.v1_17_R1.CraftServer)8 CraftServer (org.bukkit.craftbukkit.v1_18_R1.CraftServer)8 Property (com.mojang.authlib.properties.Property)7 PlayerProfile (net.aufdemrand.denizen.nms.util.PlayerProfile)4 MinecraftServer (net.minecraft.server.MinecraftServer)4 PlayerProfile (com.denizenscript.denizen.nms.util.PlayerProfile)3 UUID (java.util.UUID)3 CraftServer (org.bukkit.craftbukkit.v1_10_R1.CraftServer)3 CraftServer (org.bukkit.craftbukkit.v1_11_R1.CraftServer)3 CraftServer (org.bukkit.craftbukkit.v1_16_R3.CraftServer)3 CraftServer (org.bukkit.craftbukkit.v1_8_R3.CraftServer)3 ClientboundAddPlayerPacket (net.minecraft.network.protocol.game.ClientboundAddPlayerPacket)2 ClientboundPlayerInfoPacket (net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket)2 ClientboundRemoveEntitiesPacket (net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket)2 ServerLevel (net.minecraft.server.level.ServerLevel)2 ServerPlayer (net.minecraft.server.level.ServerPlayer)2 ServerOpList (net.minecraft.server.players.ServerOpList)2 ServerOpListEntry (net.minecraft.server.players.ServerOpListEntry)2