mirror of
https://github.com/songoda/EpicVouchers.git
synced 2024-11-22 01:56:21 +01:00
Merge pull request #3 from xsmeths/development
fix EpicVouchers commands not working and some editor menu issues
This commit is contained in:
commit
f8e3da85f4
3
pom.xml
3
pom.xml
@ -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>
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user