Merge pull request #3 from xsmeths/development

fix EpicVouchers commands not working and some editor menu issues
This commit is contained in:
ceze88 2024-06-11 16:08:38 +02:00 committed by GitHub
commit f8e3da85f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 10 deletions

View File

@ -62,6 +62,9 @@
<filter> <filter>
<artifact>com.craftaro:CraftaroCore</artifact> <artifact>com.craftaro:CraftaroCore</artifact>
<excludeDefaults>false</excludeDefaults> <excludeDefaults>false</excludeDefaults>
<includes>
<include>**/nms/v*/**</include>
</includes>
<excludes> <excludes>
<exclude>**/third_party/org/apache/**</exclude> <exclude>**/third_party/org/apache/**</exclude>
<exclude>**/third_party/net/kyori/**</exclude> <exclude>**/third_party/net/kyori/**</exclude>

View File

@ -12,7 +12,7 @@ public class CommandEditor extends AbstractCommand {
final EpicVouchers instance; final EpicVouchers instance;
public CommandEditor(EpicVouchers instance) { public CommandEditor(EpicVouchers instance) {
super(CommandType.PLAYER_ONLY, "EpicVouchers"); super(CommandType.PLAYER_ONLY, "editor");
this.instance = instance; this.instance = instance;
} }

View File

@ -8,9 +8,11 @@ import com.craftaro.epicvouchers.libraries.ItemBuilder;
import com.craftaro.epicvouchers.libraries.inventory.IconInv; import com.craftaro.epicvouchers.libraries.inventory.IconInv;
import com.craftaro.epicvouchers.libraries.inventory.icons.Icon; import com.craftaro.epicvouchers.libraries.inventory.icons.Icon;
import com.craftaro.epicvouchers.voucher.Voucher; import com.craftaro.epicvouchers.voucher.Voucher;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import static org.bukkit.Material.PAPER; import static org.bukkit.Material.PAPER;
@ -25,7 +27,11 @@ public class VoucherMenu extends IconInv {
for (Voucher voucher : instance.getVoucherManager().getVouchers()) { for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
if (getInventory().firstEmpty() != -1) { if (getInventory().firstEmpty() != -1) {
addIcon(getInventory().firstEmpty(), voucher.toItemStack(), event -> new OptionMenu(instance, voucher).open(event.getPlayer())); ItemStack voucherItemStack = voucher.toItemStack();
ItemMeta voucherItemMeta = voucherItemStack.getItemMeta();
voucherItemMeta.setDisplayName(TextUtils.formatText(voucher.getName()));
voucherItemStack.setItemMeta(voucherItemMeta);
addIcon(getInventory().firstEmpty(), voucherItemStack, event -> new OptionMenu(instance, voucher).open(event.getPlayer()));
} }
} }
@ -36,19 +42,23 @@ public class VoucherMenu extends IconInv {
gui.setTitle("Insert id"); gui.setTitle("Insert id");
gui.setAction(aEvent -> { gui.setAction(aEvent -> {
final String msg = gui.getInputText().trim(); final String msg = gui.getInputText().trim();
aEvent.player.setLevel(aEvent.player.getLevel()+1);
aEvent.player.updateInventory();
aEvent.player.setLevel(aEvent.player.getLevel()-1);
aEvent.player.updateInventory();
if (instance.getVoucherManager().getVoucher(msg) != null) { if (instance.getVoucherManager().getVoucher(msg) != null) {
event.getPlayer().sendMessage(TextUtils.formatText("&cAlready a voucher registered with the id: " + msg)); event.getPlayer().sendMessage(TextUtils.formatText("&cAlready a voucher registered with the id: " + msg));
new VoucherMenu(instance).open(event.getPlayer()); new VoucherMenu(instance).open(event.getPlayer());
return; return;
} }
if (!msg.isEmpty()) {
Voucher voucher = new Voucher(msg, instance); Voucher voucher = new Voucher(msg, instance);
voucher.setMaterial(PAPER); voucher.setMaterial(PAPER);
voucher.setName("&f" + msg); voucher.setName("&f" + msg);
voucher.setTexture(""); voucher.setTexture("");
instance.getVoucherManager().addVoucher(voucher);
instance.getVoucherManager().addVoucher(voucher); event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully created voucher with id &r" + msg + "&7."));
event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully created voucher with id &r" + msg + "&7.")); }
new VoucherMenu(instance).open(event.getPlayer()); new VoucherMenu(instance).open(event.getPlayer());
}); });
instance.getGuiManager().showGUI(event.getPlayer(), gui); instance.getGuiManager().showGUI(event.getPlayer(), gui);
@ -59,3 +69,4 @@ public class VoucherMenu extends IconInv {
new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 7)).name(ChatColor.RESET.toString()).build())); new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 7)).name(ChatColor.RESET.toString()).build()));
} }
} }