Update custom model data
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-10-09 13:35:16 +02:00
Ursprung f944fbd8cd
Commit a57cd0287a
6 geänderte Dateien mit 25 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.bausystem;
import de.steamwar.inventory.SWItem;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.UtilityClass;
@ -29,6 +30,7 @@ import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import java.util.function.Function;
@ -59,6 +61,13 @@ public class SWUtils {
}
}
public static SWItem setCustomModelData(SWItem item, int customModelData) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setCustomModelData(customModelData);
item.setItemMeta(itemMeta);
return item;
}
public static void sendToActionbar(Player p, String message) {
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.loader;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
@ -30,6 +31,7 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
@ -42,7 +44,7 @@ public class LoaderBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)).getItemStack();
return SWUtils.setCustomModelData(new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)), 1).getItemStack();
}
@Override

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.region.items;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
@ -43,9 +44,9 @@ public class ProtectBauGuiItem extends BauGuiItem {
public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation());
if (region.getPlain(Flag.PROTECT, ProtectMode.class) == ProtectMode.ACTIVE) {
return new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)).getItemStack();
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
} else {
return new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)).getItemStack();
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
}
}

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.region.items;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.region.ResetCommand;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWItem;
@ -44,7 +45,7 @@ public class ResetBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
return new SWItem(Material.HEAVY_WEIGHTED_PRESSURE_PLATE, BauSystem.MESSAGE.parse("REGION_ITEM_RESET", player)).getItemStack();
return SWUtils.setCustomModelData(new SWItem(Material.HEAVY_WEIGHTED_PRESSURE_PLATE, BauSystem.MESSAGE.parse("REGION_ITEM_RESET", player)), 1).getItemStack();
}
@Override

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.tracer.record.*;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.bausystem.region.Region;
@ -46,11 +47,11 @@ public class TracerBauGuiItem extends BauGuiItem {
public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Collections.emptyList(), false, clickType -> {
}).getItemStack();
return SWUtils.setCustomModelData(new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Collections.emptyList(), false, clickType -> {
}), 1).getItemStack();
}
return new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, Recorder.INSTANCE.get(region).scoreboard(player))), false, clickType -> {
}).getItemStack();
return SWUtils.setCustomModelData(new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, Recorder.INSTANCE.get(region).scoreboard(player))), false, clickType -> {
}), 1).getItemStack();
}
private static void open(Player p) {

Datei anzeigen

@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.util.items;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
@ -47,10 +48,11 @@ public class NightVisionBauGuiItem extends BauGuiItem {
meta.setColor(PotionEffectType.NIGHT_VISION.getColor());
meta.setDisplayName(BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_ON", player));
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
meta.setCustomModelData(1);
itemStack.setItemMeta(meta);
return itemStack;
} else {
return new SWItem(Material.GLASS_BOTTLE, BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_OFF", player)).getItemStack();
return SWUtils.setCustomModelData(new SWItem(Material.GLASS_BOTTLE, BauSystem.MESSAGE.parse("NIGHT_VISION_ITEM_OFF", player)), 1).getItemStack();
}
}