Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
SpraxDev committed Oct 2, 2024
2 parents 98b1aac + a50ccb9 commit 9a18ff1
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 43 deletions.
13 changes: 8 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.craftaro</groupId>
<artifactId>EpicVouchers-Plugin</artifactId>
<version>3.0.0</version>
<version>3.2.0</version>

<name>EpicVouchers</name>
<description>Create vouchers that players can claim for rewards with seemingly infinite possibilities</description>
Expand All @@ -25,7 +25,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>

<executions>
<execution>
Expand Down Expand Up @@ -62,9 +62,12 @@
<filter>
<artifact>com.craftaro:CraftaroCore</artifact>
<excludeDefaults>false</excludeDefaults>
<includes>
<include>**/nms/v*/**</include>
<include>**/third_party/net/kyori/**</include>
</includes>
<excludes>
<exclude>**/third_party/org/apache/**</exclude>
<exclude>**/third_party/net/kyori/**</exclude>
<exclude>**/third_party/com/zaxxer/**</exclude>
<exclude>**/third_party/org/jooq/**</exclude>
<exclude>**/third_party/org/mariadb/**</exclude>
Expand Down Expand Up @@ -105,7 +108,7 @@
<dependency>
<groupId>com.craftaro</groupId>
<artifactId>CraftaroCore</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>3.5.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>

Expand All @@ -119,7 +122,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/com/craftaro/epicvouchers/EpicVouchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import com.craftaro.core.SongodaPlugin;
import com.craftaro.core.commands.CommandManager;
import com.craftaro.core.configuration.Config;
import com.craftaro.core.dependency.Dependency;
import com.craftaro.core.gui.GuiManager;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.epicvouchers.commands.CommandEditor;
import com.craftaro.epicvouchers.commands.CommandEpicVouchers;
import com.craftaro.epicvouchers.commands.CommandForce;
Expand All @@ -27,6 +25,7 @@
import com.craftaro.epicvouchers.voucher.Voucher;
import com.craftaro.epicvouchers.voucher.VoucherExecutor;
import com.craftaro.epicvouchers.voucher.VoucherManager;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
Expand All @@ -35,9 +34,7 @@
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class EpicVouchers extends SongodaPlugin {
private final GuiManager guiManager = new GuiManager(this);
Expand All @@ -57,11 +54,6 @@ public static EpicVouchers getInstance() {
return getPlugin(EpicVouchers.class);
}

@Override
protected Set<Dependency> getDependencies() {
return new HashSet<>();
}

@Override
public void onPluginLoad() {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CommandEditor extends AbstractCommand {
final EpicVouchers instance;

public CommandEditor(EpicVouchers instance) {
super(CommandType.PLAYER_ONLY, "EpicVouchers");
super(CommandType.PLAYER_ONLY, "editor");
this.instance = instance;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.craftaro.epicvouchers.libraries.inventory;

import com.craftaro.third_party.com.cryptomorin.xseries.SkullUtils;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.core.utils.SkullItemCreator;
import com.craftaro.epicvouchers.EpicVouchers;
import com.craftaro.epicvouchers.libraries.ItemBuilder;
import com.craftaro.epicvouchers.menus.ActionMenu;
import com.craftaro.epicvouchers.voucher.Voucher;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -53,7 +53,7 @@ public void refresh() {

Player player = this.players.get(index);

ItemStack itemStack = SkullUtils.getSkull(player.getUniqueId());
ItemStack itemStack = SkullItemCreator.byPlayer(player);

ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(YELLOW + player.getName());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/craftaro/epicvouchers/menus/ConfirmMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@

public class ConfirmMenu extends FastInv {
public ConfirmMenu(EpicVouchers instance, Runnable success, Runnable failure) {
super(27, instance.getLocale().getMessage("interface.confirmsettings.title").getMessage());
super(27, instance.getLocale().getMessage("interface.confirmsettings.title").toText());

addItem(11, new ItemBuilder(Material.EMERALD)
.name(instance.getLocale().getMessage("interface.confirmsettings.confirmitemname").getMessage())
.lore(instance.getLocale().getMessage("interface.confirmsettings.confirmitemlore").getMessage())
.name(instance.getLocale().getMessage("interface.confirmsettings.confirmitemname").toText())
.lore(instance.getLocale().getMessage("interface.confirmsettings.confirmitemlore").toText())
.addGlow().build(), event -> {
event.getPlayer().closeInventory();
success.run();
});

addItem(15, new ItemBuilder(Material.REDSTONE_BLOCK)
.name(instance.getLocale().getMessage("interface.confirmsettings.cancelitemname").getMessage())
.lore(instance.getLocale().getMessage("interface.confirmsettings.cancelitemlore").getMessage())
.name(instance.getLocale().getMessage("interface.confirmsettings.cancelitemname").toText())
.lore(instance.getLocale().getMessage("interface.confirmsettings.cancelitemlore").toText())
.enchant(DURABILITY, 1)
.addFlags(HIDE_ENCHANTS)
.build(), event -> {
Expand Down
29 changes: 20 additions & 9 deletions src/main/java/com/craftaro/epicvouchers/menus/VoucherMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
import com.craftaro.epicvouchers.libraries.inventory.icons.Icon;
import com.craftaro.epicvouchers.voucher.Voucher;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import static org.bukkit.Material.PAPER;

Expand All @@ -25,7 +27,11 @@ public VoucherMenu(EpicVouchers instance) {

for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
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()));
}
}

Expand All @@ -36,19 +42,23 @@ public VoucherMenu(EpicVouchers instance) {
gui.setTitle("Insert id");
gui.setAction(aEvent -> {
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) {
event.getPlayer().sendMessage(TextUtils.formatText("&cAlready a voucher registered with the id: " + msg));
new VoucherMenu(instance).open(event.getPlayer());
return;
}

Voucher voucher = new Voucher(msg, instance);
voucher.setMaterial(PAPER);
voucher.setName("&f" + msg);
voucher.setTexture("");

instance.getVoucherManager().addVoucher(voucher);
event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully created voucher with id &r" + msg + "&7."));
if (!msg.isEmpty()) {
Voucher voucher = new Voucher(msg, instance);
voucher.setMaterial(PAPER);
voucher.setName("&f" + msg);
voucher.setTexture("");
instance.getVoucherManager().addVoucher(voucher);
event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully created voucher with id &r" + msg + "&7."));
}
new VoucherMenu(instance).open(event.getPlayer());
});
instance.getGuiManager().showGUI(event.getPlayer(), gui);
Expand All @@ -59,3 +69,4 @@ public VoucherMenu(EpicVouchers instance) {
new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 7)).name(ChatColor.RESET.toString()).build()));
}
}

12 changes: 7 additions & 5 deletions src/main/java/com/craftaro/epicvouchers/voucher/Voucher.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.craftaro.epicvouchers.voucher;

import com.craftaro.core.chat.AdventureUtils;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.core.third_party.net.kyori.adventure.text.Component;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.craftaro.core.utils.ItemUtils;
Expand Down Expand Up @@ -196,13 +198,13 @@ public void giveAll(CommandSender sender, int amount) {
}

public void give(CommandSender sender, List<Player> players, int amount) {
String giveMessage = this.instance.getLocale().getMessage("command.give.send")
Component giveMessage = this.instance.getLocale().getMessage("command.give.send")
.processPlaceholder("player", players.size() == 1 ? players.get(0).getName() : "everyone")
.processPlaceholder("voucher", getName(true))
.processPlaceholder("amount", String.valueOf(amount)).getPrefixedMessage();

for (Player player : players) {
String receiveMessage = this.instance.getLocale().getMessage("command.give.receive")
Component receiveMessage = this.instance.getLocale().getMessage("command.give.receive")
.processPlaceholder("voucher", getName(true))
.processPlaceholder("player", player.getName())
.processPlaceholder("amount", String.valueOf(amount)).getPrefixedMessage();
Expand All @@ -215,11 +217,11 @@ public void give(CommandSender sender, List<Player> players, int amount) {
continue;
}

player.sendMessage(receiveMessage);
AdventureUtils.sendMessage(EpicVouchers.getInstance(), receiveMessage, player);
player.getInventory().addItem(toItemStack(amount));
}

sender.sendMessage(giveMessage);
AdventureUtils.sendMessage(EpicVouchers.getInstance(), giveMessage, sender);
}

public void forceRedeem(CommandSender sender, List<Player> players, int amount) {
Expand All @@ -242,7 +244,7 @@ public void redeemVoucher(PlayerInteractEvent event) {

// does the player have permission to redeem this voucher?
if (!this.permission.isEmpty() && !player.hasPermission(this.permission)) {
player.sendMessage(this.instance.getLocale().getMessage("event.general.nopermission").getPrefixedMessage());
this.instance.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(player);
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.craftaro.epicvouchers.voucher;

import com.craftaro.core.compatibility.CompatibleSound;
import com.craftaro.core.compatibility.ServerVersion;
import com.craftaro.epicvouchers.EpicVouchers;
import com.craftaro.epicvouchers.events.VoucherRedeemEvent;
import com.craftaro.epicvouchers.listeners.PlayerCommandListener;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Effect;
Expand All @@ -15,6 +15,7 @@
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import java.util.Optional;
import java.util.logging.Level;

public class VoucherExecutor {
Expand Down Expand Up @@ -142,11 +143,8 @@ public void redeemVoucher(Player player, Voucher voucher, ItemStack item, boolea
}

if (voucher.getSound() != null && !voucher.getSound().isEmpty()) {
try {
CompatibleSound sound = CompatibleSound.valueOf(voucher.getSound());
sound.play(player, Integer.MAX_VALUE, voucher.getSoundPitch());
} catch (IllegalArgumentException ignored) {
}
Optional<XSound> sound = XSound.matchXSound(voucher.getSound());
sound.ifPresent(xSound -> xSound.play(player, 1.0f, voucher.getSoundPitch()));
}

String particle = voucher.getParticle();
Expand Down

0 comments on commit 9a18ff1

Please sign in to comment.