added Fleischerchest

This commit is contained in:
Lars Neuhaus 2024-07-20 22:32:25 +02:00
parent 71c413673d
commit c1cfb0c856
3 changed files with 45 additions and 1 deletions
src/main/java/eu/mhsl/craftattack/spawn

@ -4,6 +4,7 @@ import eu.mhsl.craftattack.spawn.aggregates.displayName.DisplayName;
import eu.mhsl.craftattack.spawn.api.HttpServer;
import eu.mhsl.craftattack.spawn.appliance.Appliance;
import eu.mhsl.craftattack.spawn.appliances.adminMarker.AdminMarker;
import eu.mhsl.craftattack.spawn.appliances.fleischerchest.Fleischerchest;
import eu.mhsl.craftattack.spawn.appliances.kick.Kick;
import eu.mhsl.craftattack.spawn.appliances.chatMessages.ChatMessages;
import eu.mhsl.craftattack.spawn.appliances.outlawed.Outlawed;
@ -55,7 +56,8 @@ public final class Main extends JavaPlugin {
new PanicBan(),
new Outlawed(),
new DisplayName(),
new Debug()
new Debug(),
new Fleischerchest()
);
Bukkit.getLogger().info("Loading appliances...");

@ -0,0 +1,24 @@
package eu.mhsl.craftattack.spawn.appliances.fleischerchest;
import eu.mhsl.craftattack.spawn.appliance.Appliance;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class Fleischerchest extends Appliance {
public void renameItem(ItemStack item) {
ItemMeta meta = item.getItemMeta();
meta.displayName(Component.text("Fleischerchest").color(TextColor.color(235, 20, 28)));
item.setItemMeta(meta);
}
@Override
protected @NotNull List<Listener> eventHandlers() {
return List.of(new FleischerchestCraftItemListener());
}
}

@ -0,0 +1,18 @@
package eu.mhsl.craftattack.spawn.appliances.fleischerchest;
import eu.mhsl.craftattack.spawn.appliance.ApplianceListener;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.inventory.ItemStack;
public class FleischerchestCraftItemListener extends ApplianceListener<Fleischerchest> {
@EventHandler
public void onPrepareItemCraft(PrepareItemCraftEvent event) {
ItemStack result = event.getInventory().getResult();
if(result == null) return;
if(result.getType() == Material.RED_SHULKER_BOX) {
getAppliance().renameItem(event.getInventory().getResult());
}
}
}