merged chestEx into environmentex
All checks were successful
Gitea Actions Demo / Build-Gradle (push) Successful in 3m39s

This commit is contained in:
Your Name
2025-07-28 23:19:05 +02:00
parent e5edef0716
commit 7905dc816c
22 changed files with 344 additions and 438 deletions

View File

@@ -1,2 +1,2 @@
Command: /opt/homebrew/Cellar/openjdk/23.0.2/libexec/openjdk.jdk/Contents/Home/bin/java -Xmx1G -classpath /Users/janik/.gradle/caches/modules-2/files-2.1/net.fabricmc/tiny-remapper/0.11.1/6c1f29838864ba8f495855edfc8ef17706fedb5d/tiny-remapper-0.11.1-fat.jar net.fabricmc.tinyremapper.Main /Users/janik/Desktop/MCPlugins/environmentex-1.0-SNAPSHOT.jar /Users/janik/Desktop/MCPlugins/environmentex/build/libs/environmentex-1.0-SNAPSHOT-reobf.jar /Users/janik/Desktop/MCPlugins/environmentex/.gradle/caches/paperweight/taskCache/reobfMappings.tiny mojang spigot /Users/janik/Desktop/MCPlugins/environmentex/.gradle/caches/paperweight/taskCache/mappedServerJar.jar --threads=1
[INFO] Finished after 880,98 ms.
[INFO] Finished after 974,94 ms.

View File

@@ -650,7 +650,7 @@ code + .copy-button {
<script type="text/javascript">
function configurationCacheProblems() { return (
// begin-report-data
{"diagnostics":[{"locations":[{"path":"/Users/janik/Desktop/MCPlugins/environmentex/src/main/java/de/hessj/environmentex/App.java"},{"taskPath":":compileJava"}],"problem":[{"text":"/Users/janik/Desktop/MCPlugins/environmentex/src/main/java/de/hessj/environmentex/App.java verwendet oder überschreibt eine veraltete API."}],"severity":"ADVICE","problemDetails":[{"text":"Hinweis: /Users/janik/Desktop/MCPlugins/environmentex/src/main/java/de/hessj/environmentex/App.java verwendet oder überschreibt eine veraltete API."}],"contextualLabel":"/Users/janik/Desktop/MCPlugins/environmentex/src/main/java/de/hessj/environmentex/App.java verwendet oder überschreibt eine veraltete API.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.filename","displayName":"/Users/janik/Desktop/MCPlugins/environmentex/src/main/java/de/hessj/environmentex/App.java verwendet oder überschreibt eine veraltete API."}]},{"locations":[{"path":"/Users/janik/Desktop/MCPlugins/environmentex/src/main/java/de/hessj/environmentex/App.java"},{"taskPath":":compileJava"}],"problem":[{"text":"Wiederholen Sie die Kompilierung mit -Xlint:deprecation, um Details zu erhalten."}],"severity":"ADVICE","problemDetails":[{"text":"Hinweis: Wiederholen Sie die Kompilierung mit -Xlint:deprecation, um Details zu erhalten."}],"contextualLabel":"Wiederholen Sie die Kompilierung mit -Xlint:deprecation, um Details zu erhalten.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.recompile","displayName":"Wiederholen Sie die Kompilierung mit -Xlint:deprecation, um Details zu erhalten."}]}],"problemsReport":{"totalProblemCount":2,"buildName":"environmentex","requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14.2/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
{"diagnostics":[{"locations":[{"path":"/Users/janik/Desktop/MCPlugins/environmentex/src/main/java/de/hessj/environmentex/MobHeads.java"},{"taskPath":":compileJava"}],"problem":[{"text":"Einige Eingabedateien verwenden oder überschreiben eine veraltete API."}],"severity":"ADVICE","problemDetails":[{"text":"Hinweis: Einige Eingabedateien verwenden oder überschreiben eine veraltete API."}],"contextualLabel":"Einige Eingabedateien verwenden oder überschreiben eine veraltete API.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.plural","displayName":"Einige Eingabedateien verwenden oder überschreiben eine veraltete API."}]},{"locations":[{"path":"/Users/janik/Desktop/MCPlugins/environmentex/src/main/java/de/hessj/environmentex/MobHeads.java"},{"taskPath":":compileJava"}],"problem":[{"text":"Wiederholen Sie die Kompilierung mit -Xlint:deprecation, um Details zu erhalten."}],"severity":"ADVICE","problemDetails":[{"text":"Hinweis: Wiederholen Sie die Kompilierung mit -Xlint:deprecation, um Details zu erhalten."}],"contextualLabel":"Wiederholen Sie die Kompilierung mit -Xlint:deprecation, um Details zu erhalten.","problemId":[{"name":"java","displayName":"Java compilation"},{"name":"compilation","displayName":"Compilation"},{"name":"compiler.note.deprecated.recompile","displayName":"Wiederholen Sie die Kompilierung mit -Xlint:deprecation, um Details zu erhalten."}]}],"problemsReport":{"totalProblemCount":2,"buildName":"environmentex","requestedTasks":"build","documentationLink":"https://docs.gradle.org/8.14.2/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
// end-report-data
);}
</script>

View File

@@ -59,7 +59,9 @@ public class App extends JavaPlugin {
public File tpYml = new File(this.getDataFolder() + "/texturepack.yml");
public FileConfiguration tpConfig = YamlConfiguration.loadConfiguration(tpYml);
public NamespacedKey nskLockedChest = new NamespacedKey(this, "R3SLockedChest");
public NamespacedKey nskLockedChestRecipe = new NamespacedKey(this, "R3SLockedChestRecipe");
public ItemStack lockedChest;
@Override
@@ -76,6 +78,26 @@ public class App extends JavaPlugin {
}
SquidPrevention.removeSquidReceipes();
SquidPrevention.addCustomSquidRecipes();
main = this;
lockedChest = new ItemStack(Material.CHEST);
ItemMeta imlockedChest = lockedChest.getItemMeta();
imlockedChest.displayName(Component.translatable(ChatColor.AQUA + "Verschlossene Truhe"));
imlockedChest.getPersistentDataContainer().set(nskLockedChest, PersistentDataType.STRING, "R3S_LockedChest");
lockedChest.setItemMeta(imlockedChest);
ShapedRecipe safechestRecipe = new ShapedRecipe(nskLockedChestRecipe, lockedChest);
RecipeChoice rc = new RecipeChoice.MaterialChoice(Material.OAK_LOG, Material.SPRUCE_LOG, Material.BIRCH_LOG,
Material.JUNGLE_LOG, Material.ACACIA_LOG, Material.DARK_OAK_LOG);
safechestRecipe.shape("LLL", "LKL", "III");
safechestRecipe.setIngredient('L', rc);
safechestRecipe.setIngredient('K', Material.TRIPWIRE_HOOK);
safechestRecipe.setIngredient('I', Material.IRON_INGOT);
if (getServer().getRecipe(nskLockedChestRecipe) == null) {
App.main.getServer().addRecipe(safechestRecipe);
}
getServer().recipeIterator().forEachRemaining(recipe -> {
if (recipe instanceof ShapelessRecipe) {
ShapelessRecipe shapelessRecipe = (ShapelessRecipe) recipe;
@@ -94,7 +116,7 @@ public class App extends JavaPlugin {
}, 1000 * 20 / 1000, 1000 * 20 / 1000);
getLogger().info("Plugin enabled!");
main = this;
// if(App.main.getServer().getPort() == 25588){
@@ -460,6 +482,7 @@ public class App extends JavaPlugin {
pM.registerEvents(new SquidPrevention(), this);
pM.registerEvents(new EntityMuter(), this);
pM.registerEvents(new BetterHoes(), this);
pM.registerEvents(new ChestEx(), this);
getCommand("test").setExecutor(new EnvironmentExCommands());
getCommand("y").setExecutor(new EnvironmentExCommands());
getCommand("n").setExecutor(new EnvironmentExCommands());

View File

@@ -0,0 +1,318 @@
package de.hessj.environmentex;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
import de.hessj.helper.Helper.Type;
public class ChestEx implements Listener {
public Boolean lastPlacedIsSafeChest = false;
public de.hessj.helper.Helper helper= new de.hessj.helper.Helper();
@EventHandler
public void onJoin(PlayerJoinEvent e) {
e.getPlayer().discoverRecipe(App.main.nskLockedChestRecipe);
}
@EventHandler
public void onInteract(PlayerInteractEvent e) {
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) {
if (e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer()
.has(App.main.nskLockedChest, PersistentDataType.STRING)) {
lastPlacedIsSafeChest = true;
}
}
} 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())
.contains(locStr)) {
// is meine truhe
} else {
if (App.main.getConfig().getConfigurationSection("chests") != null) {
for (String uuid : App.main.getConfig().getConfigurationSection("chests").getKeys(false)) {
List<String> chestList = App.main.getConfig().getStringList("chests." + uuid);
if (chestList.contains(locStr)) {
e.setCancelled(true);
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Dies ist nicht deine Truhe!"));
return;
}
}
}
}
}
}
@EventHandler
public void onPlace(BlockPlaceEvent e) {
if (e.getBlockPlaced().getType().equals(Material.CHEST) && lastPlacedIsSafeChest) {
Chest chest = (Chest) e.getBlock().getState();
Bukkit.getScheduler().scheduleSyncDelayedTask(App.main, new Runnable() {
@Override
public void run() {
InventoryHolder holder = chest.getInventory().getHolder();
if (holder instanceof DoubleChest) {
DoubleChest doubleChest = ((DoubleChest) holder);
Chest leftChest = (Chest) doubleChest.getLeftSide();
Chest rightChest = (Chest) doubleChest.getRightSide();
// WENN HIER DIE EINE IN CONFIG GEHÖRT PLAYER
if (leftChest.getLocation().equals(e.getBlockPlaced().getLocation())) {
// rechte checken
Location loc = rightChest.getLocation();
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
if (!App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
.contains(locStr)) {
e.getBlockPlaced().setType(Material.AIR);
e.setCancelled(true);
// HIER
if (e.getHand() == EquipmentSlot.OFF_HAND) {
if (e.getPlayer().getInventory().getItemInOffHand().getAmount() > 0) {
e.getPlayer().getInventory().setItemInOffHand(
e.getPlayer().getInventory().getItemInOffHand().add(1));
} else {
e.getPlayer().getInventory().setItemInOffHand(App.main.lockedChest);
e.getPlayer().updateInventory();
}
} else if (e.getHand() == EquipmentSlot.HAND) {
if (e.getPlayer().getInventory().getItemInMainHand().getAmount() > 0) {
e.getPlayer().getInventory().setItemInMainHand(
e.getPlayer().getInventory().getItemInMainHand().add(1));
} else {
e.getPlayer().getInventory().setItemInMainHand(App.main.lockedChest);
e.getPlayer().updateInventory();
}
}
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Du kannst diese Truhe nicht mit einer verschlossenen Truhe erweitern!"));
return;
}
} else if (rightChest.getLocation().equals(e.getBlockPlaced().getLocation())) {
// linke checken
Location loc = leftChest.getLocation();
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
if (!App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
.contains(locStr)) {
e.getBlockPlaced().setType(Material.AIR);
e.setCancelled(true);
// HIER
if (e.getHand() == EquipmentSlot.OFF_HAND) {
if (e.getPlayer().getInventory().getItemInOffHand().getAmount() > 0) {
e.getPlayer().getInventory().setItemInOffHand(
e.getPlayer().getInventory().getItemInOffHand().add(1));
} else {
e.getPlayer().getInventory().setItemInOffHand(App.main.lockedChest);
e.getPlayer().updateInventory();
}
} else if (e.getHand() == EquipmentSlot.HAND) {
if (e.getPlayer().getInventory().getItemInMainHand().getAmount() > 0) {
e.getPlayer().getInventory().setItemInMainHand(
e.getPlayer().getInventory().getItemInMainHand().add(1));
} else {
e.getPlayer().getInventory().setItemInMainHand(App.main.lockedChest);
e.getPlayer().updateInventory();
}
}
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Du kannst diese Truhe nicht mit einer verschlossenen Truhe erweitern!"));
return;
}
}
}
// HIER IN DING EINTRAGEN
Location loc = e.getBlockPlaced().getLocation();
List<String> chestList = App.main.getConfig()
.getStringList("chests." + e.getPlayer().getUniqueId().toString());
chestList.add(loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ());
App.main.getConfig().set("chests." + e.getPlayer().getUniqueId().toString(), chestList);
App.main.saveConfig();
lastPlacedIsSafeChest = false;
}
}, 1L);
} else if (e.getBlockPlaced().getType().equals(Material.CHEST) && !lastPlacedIsSafeChest) {
Chest chest = (Chest) e.getBlock().getState();
Bukkit.getScheduler().scheduleSyncDelayedTask(App.main, new Runnable() {
@Override
public void run() {
InventoryHolder holder = chest.getInventory().getHolder();
if (holder instanceof DoubleChest) {
DoubleChest doubleChest = ((DoubleChest) holder);
Chest leftChest = (Chest) doubleChest.getLeftSide();
Chest rightChest = (Chest) doubleChest.getRightSide();
// WENN HIER DIE EINE IN CONFIG GEHÖRT PLAYER
if (leftChest.getLocation().equals(e.getBlockPlaced().getLocation())) {
// rechte checken
Location loc = rightChest.getLocation();
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
if (App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
.contains(locStr)) {
e.getBlockPlaced().setType(Material.AIR);
e.setCancelled(true);
// HIER
if (e.getHand() == EquipmentSlot.OFF_HAND) {
if (e.getPlayer().getInventory().getItemInOffHand().getAmount() > 0) {
e.getPlayer().getInventory().setItemInOffHand(
e.getPlayer().getInventory().getItemInOffHand().add(1));
} else {
e.getPlayer().getInventory().setItemInOffHand(App.main.lockedChest);
e.getPlayer().updateInventory();
}
} else if (e.getHand() == EquipmentSlot.HAND) {
if (e.getPlayer().getInventory().getItemInMainHand().getAmount() > 0) {
e.getPlayer().getInventory().setItemInMainHand(
e.getPlayer().getInventory().getItemInMainHand().add(1));
} else {
e.getPlayer().getInventory().setItemInMainHand(App.main.lockedChest);
e.getPlayer().updateInventory();
}
}
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Du kannst eine verschlossene Truhe nicht mit einer anderen Truhe erweitern!"));
}
} else if (rightChest.getLocation().equals(e.getBlockPlaced().getLocation())) {
// linke checken
Location loc = leftChest.getLocation();
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
if (App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString())
.contains(locStr)) {
e.getBlockPlaced().setType(Material.AIR);
e.setCancelled(true);
// HIER
if (e.getHand() == EquipmentSlot.OFF_HAND) {
if (e.getPlayer().getInventory().getItemInOffHand().getAmount() > 0) {
e.getPlayer().getInventory().setItemInOffHand(
e.getPlayer().getInventory().getItemInOffHand().add(1));
} else {
e.getPlayer().getInventory().setItemInOffHand(App.main.lockedChest);
e.getPlayer().updateInventory();
}
} else if (e.getHand() == EquipmentSlot.HAND) {
if (e.getPlayer().getInventory().getItemInMainHand().getAmount() > 0) {
e.getPlayer().getInventory().setItemInMainHand(
e.getPlayer().getInventory().getItemInMainHand().add(1));
} else {
e.getPlayer().getInventory().setItemInMainHand(App.main.lockedChest);
e.getPlayer().updateInventory();
}
}
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Du kannst eine verschlossene Truhe nicht mit einer anderen Truhe erweitern!"));
}
}
}
}
}, 1L);
}
}
@EventHandler
public void onEntityExplodeEvent(EntityExplodeEvent event) {
List<Block> safelist = new ArrayList<Block>();
for (Block block : event.blockList()) {
if (block.getType() == Material.CHEST) {
if (App.main.getConfig().getConfigurationSection("chests") != null) {
Location loc = block.getLocation();
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
for (String uuid : App.main.getConfig().getConfigurationSection("chests").getKeys(false)) {
List<String> chestList = App.main.getConfig().getStringList("chests." + uuid);
if (chestList.contains(locStr)) {
safelist.add(block);
}
}
}
}
}
for (Block b : safelist) {
event.blockList().remove(b);
}
}
@EventHandler
public void onDestroy(BlockBreakEvent e) {
if (!e.getBlock().getType().equals(Material.CHEST)) {
return;
}
Location loc = e.getBlock().getLocation();
String locStr = loc.getBlockX() + "~" + loc.getBlockY() + "~" + loc.getBlockZ();
if (App.main.getConfig().getStringList("chests." + e.getPlayer().getUniqueId().toString()).contains(locStr)) {
List<String> chestList = App.main.getConfig()
.getStringList("chests." + e.getPlayer().getUniqueId().toString());
chestList.remove(locStr);
App.main.getConfig().set("chests." + e.getPlayer().getUniqueId().toString(), chestList);
App.main.saveConfig();
e.setCancelled(true);
Chest c = (Chest) e.getBlock().getState();
for (ItemStack is : c.getBlockInventory()) {
if (is != null) {
e.getBlock().getWorld().dropItemNaturally(loc, is);
}
}
e.getBlock().setType(Material.AIR);
e.getBlock().getWorld().dropItem(loc, App.main.lockedChest);
} else {
if (App.main.getConfig().getConfigurationSection("chests") != null) {
for (String uuid : App.main.getConfig().getConfigurationSection("chests").getKeys(false)) {
List<String> chestList = App.main.getConfig().getStringList("chests." + uuid);
if (chestList.contains(locStr)) {
e.setCancelled(true);
e.getPlayer().sendMessage(helper.R3SMessage(Type.ERROR, "[ChestEx] Dies ist nicht deine Truhe!"));
return;
}
}
}
}
}
}