Snapshot 3

This commit is contained in:
JaTiTV 2022-04-18 23:12:50 +02:00
parent 31a4f2d2ad
commit 65a01513ce
7 changed files with 78 additions and 91 deletions

View File

@ -6,7 +6,7 @@
<groupId>net.t2code</groupId>
<artifactId>CommandGUI_V2</artifactId>
<version>2.6.10_Snapshot-1</version>
<version>2.6.10_Snapshot-3</version>
<packaging>jar</packaging>
<name>CommandGUI</name>

View File

@ -124,18 +124,13 @@ public class GUI_Listener implements Listener {
}
private static void openGUI(Slot slot, Player player) {
player.closeInventory();
new BukkitRunnable() {
@Override
public void run() {
player.closeInventory();
OpenGUI.openGUI(player, slot.openGUI);
}
}.runTaskLater(plugin, 1L);
new BukkitRunnable() {
@Override
public void run() {
OpenGUI.openGUI(player, Main.guiHashMap.get(slot.openGUI), slot.openGUI);
}
}.runTaskLater(plugin, 2L);
}
private static void message(Slot slot, Player player) {
@ -251,6 +246,4 @@ public class GUI_Listener implements Listener {
Commands.itemOff(player);
} else Commands.itemOn(player);
}
}
}

View File

@ -203,7 +203,7 @@ public class Events implements Listener {
}
}
if (!SelectConfig.UseItem_Permission || p.hasPermission("commandgui.useitem")) {
OpenGUI.openGUI(p, Main.guiHashMap.get(SelectConfig.UseItem_OpenGUI), SelectConfig.UseItem_OpenGUI);
OpenGUI.openGUI(p, SelectConfig.UseItem_OpenGUI);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
p.playSound(p.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}

View File

@ -218,7 +218,7 @@ public class Commands {
Object gui = Main.guiHashMap.get(SelectConfig.DefaultGUI);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command") || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, gui, SelectConfig.DefaultGUI);
OpenGUI.openGUI(player, SelectConfig.DefaultGUI);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}
@ -233,7 +233,7 @@ public class Commands {
Object gui = Main.guiHashMap.get(arg);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + gui.Command_Command) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, gui, arg);
OpenGUI.openGUI(player, arg);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}

View File

@ -26,7 +26,7 @@ public class RegisterCommand extends Command {
Object gui = Main.guiHashMap.get(alias);
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
if (!gui.Command_Permission_Enable || player.hasPermission("commandgui.command." + alias) || player.hasPermission("commandgui.bypass")) {
OpenGUI.openGUI(player, gui, alias);
OpenGUI.openGUI(player, alias);
if (SelectConfig.Sound_Enable && SelectConfig.Sound_OpenInventory_Enable) {
player.playSound(player.getLocation(), SelectConfig.Sound_OpenInventory, 3, 1);
}

View File

@ -3,10 +3,13 @@ package de.jatitv.commandguiv2.Spigot.gui;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import de.jatitv.commandguiv2.Spigot.Main;
import de.jatitv.commandguiv2.Spigot.Objekte.Object;
import de.jatitv.commandguiv2.Spigot.Objekte.Slot;
import de.jatitv.commandguiv2.Spigot.config.config.SelectConfig;
import de.jatitv.commandguiv2.Util;
import net.t2code.lib.Spigot.Lib.items.ItemVersion;
import net.t2code.lib.Spigot.Lib.messages.send;
import net.t2code.lib.Spigot.Lib.minecraftVersion.MCVersion;
import net.t2code.lib.Spigot.Lib.replace.Replace;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -25,7 +28,7 @@ public class GuiBuilder {
protected static void item(Slot slot, Player player, Inventory inventory) {
ItemStack item = new ItemStack(Material.valueOf(slot.item.toUpperCase().replace(".", "_")));
ItemMeta itemMeta = item.getItemMeta();
setMeta(itemMeta, player, slot);
setDisplayNameAndLore(itemMeta, player, slot);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
@ -38,7 +41,7 @@ public class GuiBuilder {
protected static void item(String material, Slot slot, Player player, Inventory inventory) {
ItemStack item = new ItemStack(Material.valueOf(material));
ItemMeta itemMeta = item.getItemMeta();
setMeta(itemMeta, player, slot);
setDisplayNameAndLore(itemMeta, player, slot);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
@ -48,66 +51,8 @@ public class GuiBuilder {
inventory.setItem(slot.slot, item);
}
protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) {
ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setMeta(itemMeta, player, slot);
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", base64Value));
Field profileField = null;
try {
profileField = itemMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(itemMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
}
protected static void base64(Slot slot, Player player, Inventory inventory) {
ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setMeta(itemMeta, player, slot);
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", slot.base64Value));
Field profileField = null;
try {
profileField = itemMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(itemMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
}
protected static void playerHead(Slot slot, Player player, Inventory inventory) {
ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setMeta(itemMeta, player, slot);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
}
private static void setMeta(ItemMeta itemMeta, Player player, Slot slot) {
private static void setDisplayNameAndLore(ItemMeta itemMeta, Player player, Slot slot) {
if (Main.PaPi) {
itemMeta.setDisplayName(Replace.replace(prefix, player, slot.name.replace("[player]", player.getName())));
itemMeta.setLore(Replace.replacePrice(prefix, player, slot.lore, slot.price + " " + SelectConfig.Currency));
@ -117,4 +62,62 @@ public class GuiBuilder {
}
}
protected static void base64(String base64Value, Slot slot, Player player, Inventory inventory) {
ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setBase64(itemMeta, base64Value);
setDisplayNameAndLore(itemMeta, player, slot);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
}
private static void setBase64(ItemMeta itemMeta, String base64Value) {
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", base64Value == null ? "" : base64Value));
Field profileField;
try {
profileField = itemMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(itemMeta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
}
protected static void base64(Slot slot, Player player, Inventory inventory) {
base64(slot.base64Value, slot, player, inventory);
}
protected static void playerHead(Slot slot, Player player, Inventory inventory, String skullName) {
ItemStack item = ItemVersion.getHeadIS();
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
setDisplayNameAndLore(itemMeta, player, slot);
itemMeta.setOwner(skullName);
item.setItemMeta(itemMeta);
Integer am;
if (slot.itemAmount == 0) {
am = 1;
} else am = slot.itemAmount;
item.setAmount(am);
inventory.setItem(slot.slot, item);
}
public static void fillItem(Inventory inventory, Object gui) {
ItemStack glass;
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.GUI_FillItem_Item));
} else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_")));
ItemMeta itemMetaglass = glass.getItemMeta();
itemMetaglass.setDisplayName(" ");
glass.setItemMeta(itemMetaglass);
glass.setAmount(1);
for (int i = 0; i < 9 * gui.GUI_Lines; i++) {
inventory.setItem(i, glass);
}
}
}

View File

@ -26,7 +26,8 @@ public class OpenGUI {
private static Plugin plugin = Main.plugin;
private static String prefix = Util.getPrefix();
public static void openGUI(Player player, Object gui, String guiString) {
public static void openGUI(Player player, String guiString) {
Object gui = Main.guiHashMap.get(guiString);
Long long_ = Long.valueOf(System.currentTimeMillis());
switch (guiString) {
//case "plugin.PlotSquaredGUI":
@ -67,21 +68,11 @@ public class OpenGUI {
if (gui.GUI_Enable || player.hasPermission("commandgui.bypass")) {
Inventory inventory;
if (Main.PaPi) {
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name)));
inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, player, GUI_Listener.GUICode + gui.GUI_Name)));
} else inventory = Bukkit.createInventory((InventoryHolder) null, 9 * gui.GUI_Lines, (Replace.replace(prefix, GUI_Listener.GUICode + gui.GUI_Name)));
if (gui.GUI_FillItem_Enable) {
ItemStack glass;
if (MCVersion.minecraft1_8 || MCVersion.minecraft1_9 || MCVersion.minecraft1_10 || MCVersion.minecraft1_11 || MCVersion.minecraft1_12) {
glass = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, Short.valueOf(gui.GUI_FillItem_Item));
} else glass = new ItemStack(Material.valueOf(gui.GUI_FillItem_Item.toUpperCase().replace(".", "_")));
ItemMeta itemMetaglass = glass.getItemMeta();
itemMetaglass.setDisplayName(" ");
glass.setItemMeta(itemMetaglass);
glass.setAmount(1);
for (int i = 0; i < 9 * gui.GUI_Lines; i++) {
inventory.setItem(i, glass);
}
GuiBuilder.fillItem(inventory, gui);
}
for (Slot slot : gui.GUI_Slots) {
if (!slot.perm
@ -116,9 +107,9 @@ public class OpenGUI {
GuiBuilder.base64(slot, player, inventory);
} else {
if (slot.playerWhoHasOpenedTheGUI) {
GuiBuilder.base64(slot, player, inventory);
GuiBuilder.playerHead(slot, player, inventory, player.getName());
} else {
GuiBuilder.playerHead(slot, player, inventory);
GuiBuilder.playerHead(slot, player, inventory,slot.playerName);
}
}
}