fixed all deprecations

This commit is contained in:
Janik Heß
2025-03-09 01:34:02 +01:00
parent 585fd3c7e2
commit acd07b1643
19 changed files with 300 additions and 252 deletions

49
betterhoppers/build.gradle.kts Executable file
View File

@@ -0,0 +1,49 @@
plugins {
`java-library`
id("io.papermc.paperweight.userdev") version "2.0.0-beta.14"
id("xyz.jpenilla.run-paper") version "2.3.1" // Adds runServer and runMojangMappedServer tasks for testing
}
group = "de.hessj.betterhoppers"
version = "1.0-SNAPSHOT"
description = "betterhoppers"
tasks.withType<Jar> {
destinationDirectory.set(file("../"))
}
dependencies {
implementation(files("../craftbukkit.jar"))
implementation(files("../helper-1.0-SNAPSHOT.jar"))
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT")
}
tasks {
// Configure reobfJar to run when invoking the build task
assemble {
dependsOn(reobfJar)
}
compileJava {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
// See https://openjdk.java.net/jeps/247 for more information.
options.release.set(21)
}
javadoc {
options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything
}
processResources {
filteringCharset = Charsets.UTF_8.name() // We want UTF-8 for everything
val props = mapOf(
"name" to project.name,
"version" to project.version,
"description" to project.description,
"apiVersion" to "1.21"
)
inputs.properties(props)
filesMatching("plugin.yml") {
expand(props)
}
}
}

View File

@@ -29,14 +29,14 @@
<artifactId>mc-api</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/Users/janik/Documents/MCPlugins/craftbukkit-1.21.1.jar</systemPath>
<systemPath>/Users/janik/Desktop/MCPlugins/craftbukkit.jar</systemPath>
</dependency>
<dependency>
<groupId>de.hessj.helper</groupId>
<artifactId>helper</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/Users/janik/Desktop/helper-1.0-SNAPSHOT.jar</systemPath>
<systemPath>/Users/janik/Desktop/MCPlugins/helper-1.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>

View File

@@ -0,0 +1,5 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
}
rootProject.name = "betterhoppers"

View File

@@ -1,21 +1,16 @@
package de.hessj.betterhoppers;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.CustomModelDataComponent;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.io.BukkitObjectInputStream;
import org.bukkit.util.io.BukkitObjectOutputStream;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.ChatColor;
@@ -38,6 +33,15 @@ public class App extends JavaPlugin {
im.lore(Arrays.asList(Component.text(ChatColor.GRAY + "STRG + Rechtsklick auf den platzierten Filter"),
Component.text(ChatColor.GRAY + "ohne Item in der Hand, um den Filter zu öffnen")));
im.setCustomModelData(1000021);
CustomModelDataComponent cmdc = im.getCustomModelDataComponent();
List<String> list = Arrays.asList("filter_hopper");
cmdc.setStrings(list);
im.setCustomModelDataComponent(cmdc);
hopper.setItemMeta(im);
ShapelessRecipe srHopper = new ShapelessRecipe(nskHopper, hopper);
@@ -73,35 +77,4 @@ public class App extends JavaPlugin {
return false;
}
public String itemStackArrayToBase64(ItemStack[] itemArray) throws IllegalStateException {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeObject(itemArray);
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Error whilst saving items, Please contact the developer", e);
}
}
public ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
ItemStack[] itemArray = (ItemStack[]) dataInput.readObject();
dataInput.close();
return itemArray;
} catch (ClassNotFoundException e) {
throw new IOException("Error whilst loading items, Please contact the developer", e);
}
}
}

View File

@@ -21,14 +21,15 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import de.hessj.helper.Helper;
import net.kyori.adventure.text.Component;
public class BetterHopperListener implements Listener {
Component inventoryname = Component.text("Items zum filtern:");
//TODO: test if plugin works
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
if (App.main.checkFilterHopper(e.getItemInHand())) {
Location loc = e.getBlockPlaced().getLocation();
InventoryHolder invh = (InventoryHolder) e.getBlockPlaced().getState();
@@ -36,7 +37,7 @@ public class BetterHopperListener implements Listener {
App.main.getConfig()
.set("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory",
App.main.itemStackArrayToBase64(newHopperinv.getContents()));
Helper.itemStackArrayToBase64(newHopperinv.getContents()));
App.main.saveConfig();
}
@@ -58,7 +59,7 @@ public class BetterHopperListener implements Listener {
InventoryHolder invh = (InventoryHolder) e.getClickedBlock().getState();
Inventory hopperinv = Bukkit.createInventory(invh, 9, inventoryname);
hopperinv.setContents(App.main.itemStackArrayFromBase64(
hopperinv.setContents(Helper.itemStackArrayFromBase64(
App.main.getConfig().getString("hoppers." + w + "." + loc.getBlockX() + "~"
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory")));
e.getPlayer().openInventory(hopperinv);
@@ -77,7 +78,7 @@ public class BetterHopperListener implements Listener {
App.main.getConfig()
.set("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory",
App.main.itemStackArrayToBase64(invtosave.getContents()));
Helper.itemStackArrayToBase64(invtosave.getContents()));
App.main.saveConfig();
}
}
@@ -164,7 +165,7 @@ public class BetterHopperListener implements Listener {
.getBlockAt(event.getInventory().getLocation()).getState();
Inventory hopperinv = Bukkit.createInventory(invh, 9, inventoryname);
hopperinv.setContents(App.main.itemStackArrayFromBase64(
hopperinv.setContents(Helper.itemStackArrayFromBase64(
App.main.getConfig().getString("hoppers." + loc.getWorld().getName() + "." + loc.getBlockX() + "~"
+ loc.getBlockY() + "~" + loc.getBlockZ() + ".filterinventory")));
@@ -208,7 +209,7 @@ public class BetterHopperListener implements Listener {
filterInv.setContents(App.main.itemStackArrayFromBase64(
filterInv.setContents(Helper.itemStackArrayFromBase64(
App.main.getConfig().getString("hoppers." + destLoc.getWorld().getName() + "." + destLoc.getBlockX() + "~"
+ destLoc.getBlockY() + "~" + destLoc.getBlockZ() + ".filterinventory")));

View File

@@ -29,14 +29,14 @@
<artifactId>mc-api</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/Users/janik/Documents/MCPlugins/craftbukkit-1.21.1.jar</systemPath>
<systemPath>/Users/janik/Desktop/MCPlugins/craftbukkit.jar</systemPath>
</dependency>
<dependency>
<groupId>de.hessj.helper</groupId>
<artifactId>helper</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>/Users/janik/Desktop/helper-1.0-SNAPSHOT.jar</systemPath>
<systemPath>/Users/janik/Desktop/MCPlugins/helper-1.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>

5
chestex/settings.gradle.kts Executable file
View File

@@ -0,0 +1,5 @@
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
}
rootProject.name = "chestex"

View File

@@ -34,7 +34,7 @@ public class SafeChestListener implements Listener {
@EventHandler
public void onInteract(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && !e.getClickedBlock().getType().isInteractable()) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && !helper.isInteractable(e.getClickedBlock())) {
if (e.getPlayer().getInventory().getItemInMainHand() != null
&& e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && e.getPlayer().getInventory()
.getItemInMainHand().getItemMeta().getPersistentDataContainer() != null) {
@@ -43,7 +43,7 @@ public class SafeChestListener implements Listener {
lastPlacedIsSafeChest = true;
}
}
} else if (e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getClickedBlock().getType().isInteractable()) {
} else if (e.getAction() == Action.RIGHT_CLICK_BLOCK && helper.isInteractable(e.getClickedBlock())) {
Location loc = e.getClickedBlock().getLocation();
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
if (App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())

View File

@@ -7,6 +7,9 @@ group = "de.hessj.dailyquests"
version = "1.0-SNAPSHOT"
description = "dailyquests"
tasks.withType<Jar> {
destinationDirectory.set(file("../"))
}
dependencies {
implementation(files("../craftbukkit.jar"))

View File

@@ -29,7 +29,7 @@ public class AFKListener implements Listener {
BukkitTask i = Bukkit.getServer().getScheduler().runTaskLater(App.main, new Runnable() {
@Override
public void run() {
p.playerListName(App.main.helper.R3SMessage(Type.ERROR, "[AFK] " + p.getName()));
p.playerListName(App.helper.R3SMessage(Type.ERROR, "[AFK] " + p.getName()));
}
}, (5 * 60 * 20));
timers.put(p.getUniqueId(), i);

View File

@@ -10,7 +10,6 @@ import net.kyori.adventure.text.Component;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@@ -25,7 +24,6 @@ import org.bukkit.inventory.RecipeChoice.MaterialChoice;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.CustomModelDataComponent;
import org.bukkit.persistence.PersistentDataType;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -36,7 +34,7 @@ import java.util.List;
import java.util.Map;
public class App extends JavaPlugin {
public de.hessj.helper.Helper helper = new de.hessj.helper.Helper();
public static de.hessj.helper.Helper helper = new de.hessj.helper.Helper();
public static App main;
public ItemStack backPack;
public ItemStack backPack2;
@@ -62,133 +60,8 @@ public class App extends JavaPlugin {
public FileConfiguration tpConfig = YamlConfiguration.loadConfiguration(tpYml);
public boolean isInteractable(Block b) {
List<Material> interactableBlocks = new ArrayList<Material>();
interactableBlocks.add(Material.CHEST);
interactableBlocks.add(Material.TRAPPED_CHEST);
interactableBlocks.add(Material.ENDER_CHEST);
interactableBlocks.add(Material.BARREL);
interactableBlocks.add(Material.SHULKER_BOX);
interactableBlocks.add(Material.HOPPER);
interactableBlocks.add(Material.DISPENSER);
interactableBlocks.add(Material.DROPPER);
interactableBlocks.add(Material.CRAFTING_TABLE);
interactableBlocks.add(Material.FURNACE);
interactableBlocks.add(Material.BLAST_FURNACE);
interactableBlocks.add(Material.SMOKER);
interactableBlocks.add(Material.CARTOGRAPHY_TABLE);
interactableBlocks.add(Material.SMITHING_TABLE);
interactableBlocks.add(Material.LOOM);
interactableBlocks.add(Material.STONECUTTER);
interactableBlocks.add(Material.GRINDSTONE);
interactableBlocks.add(Material.ANVIL);
interactableBlocks.add(Material.CHIPPED_ANVIL);
interactableBlocks.add(Material.DAMAGED_ANVIL);
interactableBlocks.add(Material.LEVER);
interactableBlocks.add(Material.STONE_BUTTON);
interactableBlocks.add(Material.OAK_BUTTON);
interactableBlocks.add(Material.BIRCH_BUTTON);
interactableBlocks.add(Material.BAMBOO_BUTTON);
interactableBlocks.add(Material.DARK_OAK_BUTTON);
interactableBlocks.add(Material.SPRUCE_BUTTON);
interactableBlocks.add(Material.JUNGLE_BUTTON);
interactableBlocks.add(Material.ACACIA_BUTTON);
interactableBlocks.add(Material.STONE_PRESSURE_PLATE);
interactableBlocks.add(Material.OAK_PRESSURE_PLATE);
interactableBlocks.add(Material.BIRCH_PRESSURE_PLATE);
interactableBlocks.add(Material.BAMBOO_PRESSURE_PLATE);
interactableBlocks.add(Material.DARK_OAK_PRESSURE_PLATE);
interactableBlocks.add(Material.SPRUCE_PRESSURE_PLATE);
interactableBlocks.add(Material.JUNGLE_PRESSURE_PLATE);
interactableBlocks.add(Material.ACACIA_PRESSURE_PLATE);
interactableBlocks.add(Material.LIGHT_WEIGHTED_PRESSURE_PLATE);
interactableBlocks.add(Material.HEAVY_WEIGHTED_PRESSURE_PLATE);
interactableBlocks.add(Material.TRIPWIRE_HOOK);
interactableBlocks.add(Material.COMPARATOR);
interactableBlocks.add(Material.REPEATER);
interactableBlocks.add(Material.LECTERN);
interactableBlocks.add(Material.OAK_DOOR);
interactableBlocks.add(Material.BIRCH_DOOR);
interactableBlocks.add(Material.BAMBOO_DOOR);
interactableBlocks.add(Material.DARK_OAK_DOOR);
interactableBlocks.add(Material.SPRUCE_DOOR);
interactableBlocks.add(Material.JUNGLE_DOOR);
interactableBlocks.add(Material.ACACIA_DOOR);
interactableBlocks.add(Material.OAK_TRAPDOOR);
interactableBlocks.add(Material.BIRCH_TRAPDOOR);
interactableBlocks.add(Material.BAMBOO_TRAPDOOR);
interactableBlocks.add(Material.DARK_OAK_TRAPDOOR);
interactableBlocks.add(Material.SPRUCE_TRAPDOOR);
interactableBlocks.add(Material.JUNGLE_TRAPDOOR);
interactableBlocks.add(Material.ACACIA_TRAPDOOR);
interactableBlocks.add(Material.OAK_FENCE_GATE);
interactableBlocks.add(Material.BIRCH_FENCE_GATE);
interactableBlocks.add(Material.BAMBOO_FENCE_GATE);
interactableBlocks.add(Material.DARK_OAK_FENCE_GATE);
interactableBlocks.add(Material.SPRUCE_FENCE_GATE);
interactableBlocks.add(Material.JUNGLE_FENCE_GATE);
interactableBlocks.add(Material.ACACIA_FENCE_GATE);
interactableBlocks.add(Material.CHEST_MINECART);
interactableBlocks.add(Material.HOPPER_MINECART);
interactableBlocks.add(Material.FURNACE_MINECART);
interactableBlocks.add(Material.MINECART);
interactableBlocks.add(Material.TNT_MINECART);
interactableBlocks.add(Material.OAK_BOAT);
interactableBlocks.add(Material.BIRCH_BOAT);
interactableBlocks.add(Material.BAMBOO_RAFT);
interactableBlocks.add(Material.DARK_OAK_BOAT);
interactableBlocks.add(Material.SPRUCE_BOAT);
interactableBlocks.add(Material.JUNGLE_BOAT);
interactableBlocks.add(Material.ACACIA_BOAT);
interactableBlocks.add(Material.OAK_CHEST_BOAT);
interactableBlocks.add(Material.BIRCH_CHEST_BOAT);
interactableBlocks.add(Material.BAMBOO_CHEST_RAFT);
interactableBlocks.add(Material.DARK_OAK_CHEST_BOAT);
interactableBlocks.add(Material.SPRUCE_CHEST_BOAT);
interactableBlocks.add(Material.JUNGLE_CHEST_BOAT);
interactableBlocks.add(Material.ACACIA_CHEST_BOAT);
interactableBlocks.add(Material.ENCHANTING_TABLE);
interactableBlocks.add(Material.RESPAWN_ANCHOR);
interactableBlocks.add(Material.BREWING_STAND);
interactableBlocks.add(Material.LECTERN);
interactableBlocks.add(Material.WHITE_BED);
interactableBlocks.add(Material.LIGHT_GRAY_BED);
interactableBlocks.add(Material.GRAY_BED);
interactableBlocks.add(Material.BLACK_BED);
interactableBlocks.add(Material.BROWN_BED);
interactableBlocks.add(Material.RED_BED);
interactableBlocks.add(Material.ORANGE_BED);
interactableBlocks.add(Material.YELLOW_BED);
interactableBlocks.add(Material.LIME_BED);
interactableBlocks.add(Material.GREEN_BED);
interactableBlocks.add(Material.CYAN_BED);
interactableBlocks.add(Material.LIGHT_BLUE_BED);
interactableBlocks.add(Material.BLUE_BED);
interactableBlocks.add(Material.PURPLE_BED);
interactableBlocks.add(Material.MAGENTA_BED);
interactableBlocks.add(Material.PINK_BED);
interactableBlocks.add(Material.BELL);
interactableBlocks.add(Material.CAKE);
interactableBlocks.add(Material.JUKEBOX);
interactableBlocks.add(Material.NOTE_BLOCK);
interactableBlocks.add(Material.CANDLE);
interactableBlocks.add(Material.COMPOSTER);
interactableBlocks.add(Material.ITEM_FRAME);
interactableBlocks.add(Material.GLOW_ITEM_FRAME);
interactableBlocks.add(Material.ARMOR_STAND);
interactableBlocks.add(Material.DRAGON_EGG);
interactableBlocks.add(Material.BEACON);
if(interactableBlocks.contains(b.getType())){
return true;
} else {
return false;
}
}
@Override
public void onEnable() {
tpConfig.addDefault("url", "https://mc.hessj.de/texturepack/CUSTOM.zip");
tpConfig.addDefault("sha1", "a7f7bde9e54279b502d65435877d251aa522cabc");
@@ -435,7 +308,7 @@ public class App extends JavaPlugin {
Recipe r = Bukkit.getServer().getRecipe(desiredItem.getType().getKey());
ShapedRecipe sr = (ShapedRecipe) r;
HashMap<RecipeChoice, Integer> ingredients = new HashMap<RecipeChoice, Integer>();
HashMap<Material, Integer> helper = new HashMap<Material, Integer>();
HashMap<Material, Integer> hmhelper = new HashMap<Material, Integer>();
int reqItemsCount = 0;
for (RecipeChoice rC : sr.getChoiceMap().values()) {
if (rC != null) {
@@ -454,7 +327,7 @@ public class App extends JavaPlugin {
ItemStack is = new ItemStack(maat);
if (playerInv.containsAtLeast(is, amount)) {
reqItemsCount++;
helper.put(maat, amount);
hmhelper.put(maat, amount);
break;
} else {
}
@@ -462,13 +335,13 @@ public class App extends JavaPlugin {
}
if (reqItemsCount == ingredients.size()) {
for (Map.Entry<Material, Integer> entry : helper.entrySet()) {
for (Map.Entry<Material, Integer> entry : hmhelper.entrySet()) {
ItemStack is = new ItemStack(entry.getKey(), entry.getValue());
playerInv.removeItem(is);
}
}
reqItemsCount = 0;
helper = new HashMap<Material, Integer>();
hmhelper = new HashMap<Material, Integer>();
ingredients = new HashMap<RecipeChoice, Integer>();
////////////////////////

View File

@@ -51,7 +51,7 @@ public class EnvironmentExCommands implements CommandExecutor, Listener {
if (label.equalsIgnoreCase("afk")) {
Player p = (Player) sender;
p.playerListName(App.main.helper.R3SMessage(Type.ERROR, "[AFK] " + p.getName()));
p.playerListName(App.helper.R3SMessage(Type.ERROR, "[AFK] " + p.getName()));
}
if (label.equalsIgnoreCase("pin")) {

View File

@@ -55,7 +55,6 @@ import org.bukkit.event.player.PlayerAttemptPickupItemEvent;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.util.Vector;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.MerchantRecipe;
@@ -63,6 +62,7 @@ import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import net.kyori.adventure.text.Component;
import de.hessj.helper.Helper;
import de.hessj.helper.Helper.*;
public class EnvironmentExListeners implements Listener {
@@ -541,25 +541,25 @@ public class EnvironmentExListeners implements Listener {
if (size == 1) {
inv = Bukkit.createInventory(null, 9, Component.translatable("tempBackpack"));
ItemStack[] is;
is = itemStackArrayFromBase64(
is = Helper.itemStackArrayFromBase64(
App.main.getConfig().getString(p.getUniqueId() + ".backpack.contents.leatherbackpack"));
inv.setContents(is);
} else if (size == 2) {
inv = Bukkit.createInventory(null, 18, Component.translatable("tempBackpack2"));
ItemStack[] is;
is = itemStackArrayFromBase64(
is = Helper.itemStackArrayFromBase64(
App.main.getConfig().getString(p.getUniqueId() + ".backpack.contents.ironbackpack"));
inv.setContents(is);
} else if (size == 3) {
inv = Bukkit.createInventory(null, 27, Component.translatable("tempBackpack3"));
ItemStack[] is;
is = itemStackArrayFromBase64(
is = Helper.itemStackArrayFromBase64(
App.main.getConfig().getString(p.getUniqueId() + ".backpack.contents.goldbackpack"));
inv.setContents(is);
} else if (size == 4) {
inv = Bukkit.createInventory(null, 36, Component.translatable("tempBackpack4"));
ItemStack[] is;
is = itemStackArrayFromBase64(
is = Helper.itemStackArrayFromBase64(
App.main.getConfig().getString(p.getUniqueId() + ".backpack.contents.diamondbackpack"));
inv.setContents(is);
}
@@ -606,16 +606,16 @@ public class EnvironmentExListeners implements Listener {
if (size == 1) {
App.main.getConfig().set(p.getUniqueId() + ".backpack.contents.leatherbackpack",
itemStackArrayToBase64(inv.getContents()));
Helper.itemStackArrayToBase64(inv.getContents()));
} else if (size == 2) {
App.main.getConfig().set(p.getUniqueId() + ".backpack.contents.ironbackpack",
itemStackArrayToBase64(inv.getContents()));
Helper.itemStackArrayToBase64(inv.getContents()));
} else if (size == 3) {
App.main.getConfig().set(p.getUniqueId() + ".backpack.contents.goldbackpack",
itemStackArrayToBase64(inv.getContents()));
Helper.itemStackArrayToBase64(inv.getContents()));
} else if (size == 4) {
App.main.getConfig().set(p.getUniqueId() + ".backpack.contents.diamondbackpack",
itemStackArrayToBase64(inv.getContents()));
Helper.itemStackArrayToBase64(inv.getContents()));
}
App.main.saveConfig();
}
@@ -647,8 +647,8 @@ public class EnvironmentExListeners implements Listener {
&& e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
.get(App.main.nsk, PersistentDataType.STRING).toString().equals("R3S_kleiner_Rucksack")) {
if (e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.RIGHT_CLICK_BLOCK
&& (!App.main.isInteractable(e.getClickedBlock()))
|| e.getClickedBlock() != null && (App.main.isInteractable(e.getClickedBlock())
&& (!App.helper.isInteractable(e.getClickedBlock()))
|| e.getClickedBlock() != null && (App.helper.isInteractable(e.getClickedBlock())
&& (e.getClickedBlock().getBlockData() != null
&& (e.getClickedBlock().getBlockData() instanceof Stairs
|| e.getClickedBlock().getBlockData() instanceof Fence))))) {
@@ -675,8 +675,8 @@ public class EnvironmentExListeners implements Listener {
&& e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
.get(App.main.nsk2, PersistentDataType.STRING).toString().equals("R3S_Rucksack")) {
if (e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.RIGHT_CLICK_BLOCK
&& (!App.main.isInteractable(e.getClickedBlock()))
|| (App.main.isInteractable(e.getClickedBlock())
&& (!App.helper.isInteractable(e.getClickedBlock()))
|| (App.helper.isInteractable(e.getClickedBlock())
&& (e.getClickedBlock().getBlockData() != null
&& (e.getClickedBlock().getBlockData() instanceof Stairs
|| e.getClickedBlock().getBlockData() instanceof Fence))))) { // inv2 =
@@ -700,8 +700,8 @@ public class EnvironmentExListeners implements Listener {
&& e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
.get(App.main.nsk3, PersistentDataType.STRING).toString().equals("R3S_großer_Rucksack")) {
if (e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.RIGHT_CLICK_BLOCK
&& (!App.main.isInteractable(e.getClickedBlock()))
|| (App.main.isInteractable(e.getClickedBlock())
&& (!App.helper.isInteractable(e.getClickedBlock()))
|| (App.helper.isInteractable(e.getClickedBlock())
&& (e.getClickedBlock().getBlockData() != null
&& (e.getClickedBlock().getBlockData() instanceof Stairs
|| e.getClickedBlock().getBlockData() instanceof Fence))))) { // inv3 =
@@ -726,8 +726,8 @@ public class EnvironmentExListeners implements Listener {
&& e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
.get(App.main.nsk4, PersistentDataType.STRING).toString().equals("R3S_riesiger_Rucksack")) {
if (e.getAction() == Action.RIGHT_CLICK_AIR || (e.getAction() == Action.RIGHT_CLICK_BLOCK
&& (!App.main.isInteractable(e.getClickedBlock()))
|| (App.main.isInteractable(e.getClickedBlock())
&& (!App.helper.isInteractable(e.getClickedBlock()))
|| (App.helper.isInteractable(e.getClickedBlock())
&& (e.getClickedBlock().getBlockData() != null
&& (e.getClickedBlock().getBlockData() instanceof Stairs
|| e.getClickedBlock().getBlockData() instanceof Fence))))) { // inv4 =
@@ -760,28 +760,28 @@ public class EnvironmentExListeners implements Listener {
App.main.getConfig().createSection(e.getPlayer().getUniqueId() + ".backpack.contents.leatherbackpack");
}
App.main.getConfig().set(e.getPlayer().getUniqueId() + ".backpack.contents.leatherbackpack",
itemStackArrayToBase64(e.getInventory().getContents()));
Helper.itemStackArrayToBase64(e.getInventory().getContents()));
App.main.saveConfig();
} else if (e.getInventory() == hm2.get(e.getPlayer())) {
if (!App.main.getConfig().contains(e.getPlayer().getUniqueId() + ".backpack.contents.ironbackpack")) {
App.main.getConfig().createSection(e.getPlayer().getUniqueId() + ".backpack.contents.ironbackpack");
}
App.main.getConfig().set(e.getPlayer().getUniqueId() + ".backpack.contents.ironbackpack",
itemStackArrayToBase64(e.getInventory().getContents()));
Helper.itemStackArrayToBase64(e.getInventory().getContents()));
App.main.saveConfig();
} else if (e.getInventory() == hm3.get(e.getPlayer())) {
if (!App.main.getConfig().contains(e.getPlayer().getUniqueId() + ".backpack.contents.goldbackpack")) {
App.main.getConfig().createSection(e.getPlayer().getUniqueId() + ".backpack.contents.goldbackpack");
}
App.main.getConfig().set(e.getPlayer().getUniqueId() + ".backpack.contents.goldbackpack",
itemStackArrayToBase64(e.getInventory().getContents()));
Helper.itemStackArrayToBase64(e.getInventory().getContents()));
App.main.saveConfig();
} else if (e.getInventory() == hm4.get(e.getPlayer())) {
if (!App.main.getConfig().contains(e.getPlayer().getUniqueId() + ".backpack.contents.diamondbackpack")) {
App.main.getConfig().createSection(e.getPlayer().getUniqueId() + ".backpack.contents.diamondbackpack");
}
App.main.getConfig().set(e.getPlayer().getUniqueId() + ".backpack.contents.diamondbackpack",
itemStackArrayToBase64(e.getInventory().getContents()));
Helper.itemStackArrayToBase64(e.getInventory().getContents()));
App.main.saveConfig();
}
}
@@ -789,7 +789,7 @@ public class EnvironmentExListeners implements Listener {
@EventHandler
public void onDeath(PlayerDeathEvent e) throws IllegalArgumentException, IOException {
e.deathMessage(null);
ItemStack itemStack[] = itemStackArrayFromBase64(
ItemStack itemStack[] = Helper.itemStackArrayFromBase64(
"rO0ABXVyACFbTG9yZy5idWtraXQuaW52ZW50b3J5Lkl0ZW1TdGFjazuWEWyPcqQUzwIAAHhwAAAACXBwcHBwcHBwcA==");
for (ItemStack is : e.getPlayer().getInventory().getContents()) {
if (is == null || !is.hasItemMeta() || is.getItemMeta().getPersistentDataContainer() == null) {
@@ -802,7 +802,7 @@ public class EnvironmentExListeners implements Listener {
.contains(e.getPlayer().getUniqueId() + ".backpack.contents.leatherbackpack")) {
Inventory inv = Bukkit.createInventory(null, 9,
Component.translatable("Kleiner Rucksack DEAD"));
inv.setContents(itemStackArrayFromBase64(App.main.getConfig()
inv.setContents(Helper.itemStackArrayFromBase64(App.main.getConfig()
.getString(e.getPlayer().getUniqueId() + ".backpack.contents.leatherbackpack")));
for (ItemStack bis : inv.getContents()) {
if (bis != null) {
@@ -812,7 +812,7 @@ public class EnvironmentExListeners implements Listener {
}
App.main.getConfig().set(e.getPlayer().getUniqueId() + ".backpack.contents.leatherbackpack",
itemStackArrayToBase64(itemStack));
Helper.itemStackArrayToBase64(itemStack));
App.main.saveConfig();
}
@@ -821,7 +821,7 @@ public class EnvironmentExListeners implements Listener {
if (App.main.getConfig()
.contains(e.getPlayer().getUniqueId() + ".backpack.contents.ironbackpack")) {
Inventory inv = Bukkit.createInventory(null, 18, Component.translatable("Rucksack DEAD"));
inv.setContents(itemStackArrayFromBase64(App.main.getConfig()
inv.setContents(Helper.itemStackArrayFromBase64(App.main.getConfig()
.getString(e.getPlayer().getUniqueId() + ".backpack.contents.ironbackpack")));
for (ItemStack bis : inv.getContents()) {
if (bis != null) {
@@ -830,7 +830,7 @@ public class EnvironmentExListeners implements Listener {
}
App.main.getConfig().set(e.getPlayer().getUniqueId() + ".backpack.contents.ironbackpack",
itemStackArrayToBase64(itemStack));
Helper.itemStackArrayToBase64(itemStack));
App.main.saveConfig();
}
} else if (is.getItemMeta().getPersistentDataContainer().has(App.main.nsk3,
@@ -839,7 +839,7 @@ public class EnvironmentExListeners implements Listener {
.contains(e.getPlayer().getUniqueId() + ".backpack.contents.goldbackpack")) {
Inventory inv = Bukkit.createInventory(null, 27,
Component.translatable("Großer Rucksack DEAD"));
inv.setContents(itemStackArrayFromBase64(App.main.getConfig()
inv.setContents(Helper.itemStackArrayFromBase64(App.main.getConfig()
.getString(e.getPlayer().getUniqueId() + ".backpack.contents.goldbackpack")));
for (ItemStack bis : inv.getContents()) {
if (bis != null) {
@@ -848,7 +848,7 @@ public class EnvironmentExListeners implements Listener {
}
App.main.getConfig().set(e.getPlayer().getUniqueId() + ".backpack.contents.goldbackpack",
itemStackArrayToBase64(itemStack));
Helper.itemStackArrayToBase64(itemStack));
App.main.saveConfig();
}
} else if (is.getItemMeta().getPersistentDataContainer().has(App.main.nsk4,
@@ -857,7 +857,7 @@ public class EnvironmentExListeners implements Listener {
.contains(e.getPlayer().getUniqueId() + ".backpack.contents.diamondbackpack")) {
Inventory inv = Bukkit.createInventory(null, 36,
Component.translatable("Riesiger Rucksack DEAD"));
inv.setContents(itemStackArrayFromBase64(App.main.getConfig()
inv.setContents(Helper.itemStackArrayFromBase64(App.main.getConfig()
.getString(e.getPlayer().getUniqueId() + ".backpack.contents.diamondbackpack")));
for (ItemStack bis : inv.getContents()) {
if (bis != null) {
@@ -866,7 +866,7 @@ public class EnvironmentExListeners implements Listener {
}
App.main.getConfig().set(e.getPlayer().getUniqueId() + ".backpack.contents.diamondbackpack",
itemStackArrayToBase64(itemStack));
Helper.itemStackArrayToBase64(itemStack));
App.main.saveConfig();
}
}
@@ -888,7 +888,7 @@ public class EnvironmentExListeners implements Listener {
.equals("R3S_kleiner_Rucksack")) {
if (App.main.getConfig()
.contains(e.getPlayer().getUniqueId() + ".backpack.contents.leatherbackpack")) {
e.getInventory().setContents(itemStackArrayFromBase64(App.main.getConfig()
e.getInventory().setContents(Helper.itemStackArrayFromBase64(App.main.getConfig()
.getString(e.getPlayer().getUniqueId() + ".backpack.contents.leatherbackpack")));
}
} else if (e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
@@ -897,7 +897,7 @@ public class EnvironmentExListeners implements Listener {
.get(App.main.nsk2, PersistentDataType.STRING).toString().equals("R3S_Rucksack")) {
if (App.main.getConfig()
.contains(e.getPlayer().getUniqueId() + ".backpack.contents.ironbackpack")) {
e.getInventory().setContents(itemStackArrayFromBase64(App.main.getConfig()
e.getInventory().setContents(Helper.itemStackArrayFromBase64(App.main.getConfig()
.getString(e.getPlayer().getUniqueId() + ".backpack.contents.ironbackpack")));
}
} else if (e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
@@ -907,7 +907,7 @@ public class EnvironmentExListeners implements Listener {
.equals("R3S_großer_Rucksack")) {
if (App.main.getConfig()
.contains(e.getPlayer().getUniqueId() + ".backpack.contents.goldbackpack")) {
e.getInventory().setContents(itemStackArrayFromBase64(App.main.getConfig()
e.getInventory().setContents(Helper.itemStackArrayFromBase64(App.main.getConfig()
.getString(e.getPlayer().getUniqueId() + ".backpack.contents.goldbackpack")));
}
} else if (e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
@@ -917,7 +917,7 @@ public class EnvironmentExListeners implements Listener {
.equals("R3S_riesiger_Rucksack")) {
if (App.main.getConfig()
.contains(e.getPlayer().getUniqueId() + ".backpack.contents.diamondbackpack")) {
e.getInventory().setContents(itemStackArrayFromBase64(App.main.getConfig()
e.getInventory().setContents(Helper.itemStackArrayFromBase64(App.main.getConfig()
.getString(e.getPlayer().getUniqueId() + ".backpack.contents.diamondbackpack")));
}
}
@@ -1095,28 +1095,6 @@ public class EnvironmentExListeners implements Listener {
}
}
static String itemStackArrayToBase64(ItemStack[] itemArray) throws IllegalStateException {
try {
byte[] iss = ItemStack.serializeItemsAsBytes(itemArray);
App.main.log(Base64Coder.encodeLines(iss));
return Base64Coder.encodeLines(iss);
} catch (Exception e) {
throw new IllegalStateException("Error whilst saving items, Please contact the developer", e);
}
}
static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
App.main.log(data);
ItemStack[] is = ItemStack.deserializeItemsFromBytes(Base64Coder.decodeLines(data));
return is;
} catch (IllegalStateException e) {
throw new IOException("Error whilst loading items, Please contact the developer", e);
}
}
@EventHandler
public void onTraderDeath(EntityDeathEvent event) {
if (event.getEntityType() == EntityType.WANDERING_TRADER) {

View File

@@ -55,7 +55,7 @@ public class ExpBottleListener implements Listener {
public void onUse(PlayerInteractEvent e) {
ExperienceManager expMan = new ExperienceManager(e.getPlayer());
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK
|| (e.getAction() == Action.RIGHT_CLICK_BLOCK && App.main.isInteractable(e.getClickedBlock()))) {
|| (e.getAction() == Action.RIGHT_CLICK_BLOCK && App.helper.isInteractable(e.getClickedBlock()))) {
return;
}

View File

@@ -95,7 +95,7 @@ public class InfinityWaterBucket implements Listener {
e.setCancelled(true);
Player player = e.getPlayer();
if (player.getWorld().getEnvironment() == Environment.NETHER
|| (App.main.isInteractable(e.getClickedBlock()) && !e.getPlayer().isSneaking()))
|| (App.helper.isInteractable(e.getClickedBlock()) && !e.getPlayer().isSneaking()))
return;
Block block = e.getClickedBlock().getRelative(e.getBlockFace());

View File

@@ -57,7 +57,7 @@ public class WorkbenchToGo implements Listener {
if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK
|| e.getAction() == Action.PHYSICAL
|| (e.getClickedBlock() != null && App.main.isInteractable(e.getClickedBlock()))) {
|| (e.getClickedBlock() != null && App.helper.isInteractable(e.getClickedBlock()))) {
return;
}
e.setCancelled(true);

View File

@@ -1,5 +1,14 @@
package de.hessj.helper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.inventory.ItemStack;
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.format.TextDecoration;
@@ -18,15 +27,164 @@ public class Helper {
switch (type) {
case ERROR:
return Component.text(msg).color(TextColor.fromHexString("#c0392b")).decoration(TextDecoration.ITALIC, false);
return Component.text(msg).color(TextColor.fromHexString("#c0392b")).decoration(TextDecoration.ITALIC,
false);
case INFO:
return Component.text(msg).color(TextColor.fromHexString("#3498db")).decoration(TextDecoration.ITALIC, false);
return Component.text(msg).color(TextColor.fromHexString("#3498db")).decoration(TextDecoration.ITALIC,
false);
case OK:
return Component.text(msg).color(TextColor.fromHexString("#2ecc71")).decoration(TextDecoration.ITALIC, false);
return Component.text(msg).color(TextColor.fromHexString("#2ecc71")).decoration(TextDecoration.ITALIC,
false);
case SUCCESS:
return Component.text(msg).color(TextColor.fromHexString("#2ecc71")).decoration(TextDecoration.ITALIC, false);
return Component.text(msg).color(TextColor.fromHexString("#2ecc71")).decoration(TextDecoration.ITALIC,
false);
}
return Component.text(ChatColor.WHITE + msg);
}
public boolean isInteractable(Block b) {
List<Material> interactableBlocks = new ArrayList<Material>();
interactableBlocks.add(Material.CHEST);
interactableBlocks.add(Material.TRAPPED_CHEST);
interactableBlocks.add(Material.ENDER_CHEST);
interactableBlocks.add(Material.BARREL);
interactableBlocks.add(Material.SHULKER_BOX);
interactableBlocks.add(Material.HOPPER);
interactableBlocks.add(Material.DISPENSER);
interactableBlocks.add(Material.DROPPER);
interactableBlocks.add(Material.CRAFTING_TABLE);
interactableBlocks.add(Material.FURNACE);
interactableBlocks.add(Material.BLAST_FURNACE);
interactableBlocks.add(Material.SMOKER);
interactableBlocks.add(Material.CARTOGRAPHY_TABLE);
interactableBlocks.add(Material.SMITHING_TABLE);
interactableBlocks.add(Material.LOOM);
interactableBlocks.add(Material.STONECUTTER);
interactableBlocks.add(Material.GRINDSTONE);
interactableBlocks.add(Material.ANVIL);
interactableBlocks.add(Material.CHIPPED_ANVIL);
interactableBlocks.add(Material.DAMAGED_ANVIL);
interactableBlocks.add(Material.LEVER);
interactableBlocks.add(Material.STONE_BUTTON);
interactableBlocks.add(Material.OAK_BUTTON);
interactableBlocks.add(Material.BIRCH_BUTTON);
interactableBlocks.add(Material.BAMBOO_BUTTON);
interactableBlocks.add(Material.DARK_OAK_BUTTON);
interactableBlocks.add(Material.SPRUCE_BUTTON);
interactableBlocks.add(Material.JUNGLE_BUTTON);
interactableBlocks.add(Material.ACACIA_BUTTON);
interactableBlocks.add(Material.STONE_PRESSURE_PLATE);
interactableBlocks.add(Material.OAK_PRESSURE_PLATE);
interactableBlocks.add(Material.BIRCH_PRESSURE_PLATE);
interactableBlocks.add(Material.BAMBOO_PRESSURE_PLATE);
interactableBlocks.add(Material.DARK_OAK_PRESSURE_PLATE);
interactableBlocks.add(Material.SPRUCE_PRESSURE_PLATE);
interactableBlocks.add(Material.JUNGLE_PRESSURE_PLATE);
interactableBlocks.add(Material.ACACIA_PRESSURE_PLATE);
interactableBlocks.add(Material.LIGHT_WEIGHTED_PRESSURE_PLATE);
interactableBlocks.add(Material.HEAVY_WEIGHTED_PRESSURE_PLATE);
interactableBlocks.add(Material.TRIPWIRE_HOOK);
interactableBlocks.add(Material.COMPARATOR);
interactableBlocks.add(Material.REPEATER);
interactableBlocks.add(Material.LECTERN);
interactableBlocks.add(Material.OAK_DOOR);
interactableBlocks.add(Material.BIRCH_DOOR);
interactableBlocks.add(Material.BAMBOO_DOOR);
interactableBlocks.add(Material.DARK_OAK_DOOR);
interactableBlocks.add(Material.SPRUCE_DOOR);
interactableBlocks.add(Material.JUNGLE_DOOR);
interactableBlocks.add(Material.ACACIA_DOOR);
interactableBlocks.add(Material.OAK_TRAPDOOR);
interactableBlocks.add(Material.BIRCH_TRAPDOOR);
interactableBlocks.add(Material.BAMBOO_TRAPDOOR);
interactableBlocks.add(Material.DARK_OAK_TRAPDOOR);
interactableBlocks.add(Material.SPRUCE_TRAPDOOR);
interactableBlocks.add(Material.JUNGLE_TRAPDOOR);
interactableBlocks.add(Material.ACACIA_TRAPDOOR);
interactableBlocks.add(Material.OAK_FENCE_GATE);
interactableBlocks.add(Material.BIRCH_FENCE_GATE);
interactableBlocks.add(Material.BAMBOO_FENCE_GATE);
interactableBlocks.add(Material.DARK_OAK_FENCE_GATE);
interactableBlocks.add(Material.SPRUCE_FENCE_GATE);
interactableBlocks.add(Material.JUNGLE_FENCE_GATE);
interactableBlocks.add(Material.ACACIA_FENCE_GATE);
interactableBlocks.add(Material.CHEST_MINECART);
interactableBlocks.add(Material.HOPPER_MINECART);
interactableBlocks.add(Material.FURNACE_MINECART);
interactableBlocks.add(Material.MINECART);
interactableBlocks.add(Material.TNT_MINECART);
interactableBlocks.add(Material.OAK_BOAT);
interactableBlocks.add(Material.BIRCH_BOAT);
interactableBlocks.add(Material.BAMBOO_RAFT);
interactableBlocks.add(Material.DARK_OAK_BOAT);
interactableBlocks.add(Material.SPRUCE_BOAT);
interactableBlocks.add(Material.JUNGLE_BOAT);
interactableBlocks.add(Material.ACACIA_BOAT);
interactableBlocks.add(Material.OAK_CHEST_BOAT);
interactableBlocks.add(Material.BIRCH_CHEST_BOAT);
interactableBlocks.add(Material.BAMBOO_CHEST_RAFT);
interactableBlocks.add(Material.DARK_OAK_CHEST_BOAT);
interactableBlocks.add(Material.SPRUCE_CHEST_BOAT);
interactableBlocks.add(Material.JUNGLE_CHEST_BOAT);
interactableBlocks.add(Material.ACACIA_CHEST_BOAT);
interactableBlocks.add(Material.ENCHANTING_TABLE);
interactableBlocks.add(Material.RESPAWN_ANCHOR);
interactableBlocks.add(Material.BREWING_STAND);
interactableBlocks.add(Material.LECTERN);
interactableBlocks.add(Material.WHITE_BED);
interactableBlocks.add(Material.LIGHT_GRAY_BED);
interactableBlocks.add(Material.GRAY_BED);
interactableBlocks.add(Material.BLACK_BED);
interactableBlocks.add(Material.BROWN_BED);
interactableBlocks.add(Material.RED_BED);
interactableBlocks.add(Material.ORANGE_BED);
interactableBlocks.add(Material.YELLOW_BED);
interactableBlocks.add(Material.LIME_BED);
interactableBlocks.add(Material.GREEN_BED);
interactableBlocks.add(Material.CYAN_BED);
interactableBlocks.add(Material.LIGHT_BLUE_BED);
interactableBlocks.add(Material.BLUE_BED);
interactableBlocks.add(Material.PURPLE_BED);
interactableBlocks.add(Material.MAGENTA_BED);
interactableBlocks.add(Material.PINK_BED);
interactableBlocks.add(Material.BELL);
interactableBlocks.add(Material.CAKE);
interactableBlocks.add(Material.JUKEBOX);
interactableBlocks.add(Material.NOTE_BLOCK);
interactableBlocks.add(Material.CANDLE);
interactableBlocks.add(Material.COMPOSTER);
interactableBlocks.add(Material.ITEM_FRAME);
interactableBlocks.add(Material.GLOW_ITEM_FRAME);
interactableBlocks.add(Material.ARMOR_STAND);
interactableBlocks.add(Material.DRAGON_EGG);
interactableBlocks.add(Material.BEACON);
if (interactableBlocks.contains(b.getType())) {
return true;
} else {
return false;
}
}
public static String itemStackArrayToBase64(ItemStack[] itemArray) throws IllegalStateException {
try {
byte[] iss = ItemStack.serializeItemsAsBytes(itemArray);
return Base64Coder.encodeLines(iss);
} catch (Exception e) {
throw new IllegalStateException("Error whilst saving items, Please contact the developer", e);
}
}
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
try {
ItemStack[] is = ItemStack.deserializeItemsFromBytes(Base64Coder.decodeLines(data));
return is;
} catch (IllegalStateException e) {
throw new IOException("Error whilst loading items, Please contact the developer", e);
}
}
}

View File

@@ -7,10 +7,13 @@ group = "de.hessj.pokeballs"
version = "1.0-SNAPSHOT"
description = "pokeballs"
tasks.withType<Jar> {
destinationDirectory.set(file("../"))
}
dependencies {
implementation(files("/Users/janik/Desktop/MCPlugins/craftbukkit.jar"))
implementation(files("/Users/janik/Desktop/helper-1.0-SNAPSHOT.jar"))
implementation(files("../craftbukkit.jar"))
implementation(files("../helper-1.0-SNAPSHOT.jar"))
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT")
}

View File

@@ -97,7 +97,7 @@ public class PokeballsListeners implements Listener {
if (e.getClickedBlock() != null && e.getClickedBlock().getBlockData() != null
&& (e.getClickedBlock().getBlockData() instanceof Stairs
|| e.getClickedBlock().getBlockData() instanceof Fence)) {
} else if (e.getClickedBlock() != null && e.getClickedBlock().getType().isInteractable()) {
} else if (e.getClickedBlock() != null && helper.isInteractable(e.getClickedBlock())) {
return;
}
@@ -137,7 +137,7 @@ public class PokeballsListeners implements Listener {
if (e.getClickedBlock() != null && e.getClickedBlock().getBlockData() != null
&& (e.getClickedBlock().getBlockData() instanceof Stairs
|| e.getClickedBlock().getBlockData() instanceof Fence)) {
} else if (e.getClickedBlock() != null && e.getClickedBlock().getType().isInteractable()) {
} else if (e.getClickedBlock() != null && helper.isInteractable(e.getClickedBlock())) {
return;
}