use of org.bukkit.craftbukkit.v1_18_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);
}
use of org.bukkit.craftbukkit.v1_18_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();
}
use of org.bukkit.craftbukkit.v1_18_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);
}
use of org.bukkit.craftbukkit.v1_18_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);
}
use of org.bukkit.craftbukkit.v1_18_R1.CraftServer in project Denizen-For-Bukkit by DenizenScript.
the class ItemHelperImpl method registerShapelessRecipe.
@Override
public void registerShapelessRecipe(String keyName, String group, ItemStack result, List<ItemStack[]> ingredients, boolean[] exact) {
ResourceLocation key = new ResourceLocation("denizen", keyName);
ArrayList<Ingredient> ingredientList = new ArrayList<>();
for (int i = 0; i < ingredients.size(); i++) {
ingredientList.add(itemArrayToRecipe(ingredients.get(i), exact[i]));
}
ShapelessRecipe recipe = new ShapelessRecipe(key, group, CraftItemStack.asNMSCopy(result), NonNullList.of(null, ingredientList.toArray(new Ingredient[0])));
((CraftServer) Bukkit.getServer()).getServer().getRecipeManager().addRecipe(recipe);
}
Aggregations