mirror of
https://github.com/songoda/EpicVouchers.git
synced 2025-01-18 05:21:38 +01:00
Merge branch 'development'
This commit is contained in:
commit
9a18ff1460
13
pom.xml
13
pom.xml
@ -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>
|
||||
@ -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>
|
||||
@ -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>
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
@ -4,9 +4,7 @@ import com.craftaro.core.SongodaCore;
|
||||
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;
|
||||
@ -27,6 +25,7 @@ import com.craftaro.epicvouchers.voucher.CoolDownManager;
|
||||
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;
|
||||
@ -35,9 +34,7 @@ import org.bukkit.plugin.PluginManager;
|
||||
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);
|
||||
@ -57,11 +54,6 @@ public class EpicVouchers extends SongodaPlugin {
|
||||
return getPlugin(EpicVouchers.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Dependency> getDependencies() {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -53,7 +53,7 @@ public abstract class PlayersMenu extends FastInv {
|
||||
|
||||
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());
|
||||
|
@ -13,19 +13,19 @@ import static org.bukkit.inventory.ItemFlag.HIDE_ENCHANTS;
|
||||
|
||||
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 -> {
|
||||
|
@ -8,9 +8,11 @@ import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
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;
|
||||
|
||||
@ -25,7 +27,11 @@ public class VoucherMenu extends IconInv {
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,19 +42,23 @@ public class VoucherMenu extends IconInv {
|
||||
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);
|
||||
@ -59,3 +69,4 @@ public class VoucherMenu extends IconInv {
|
||||
new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 7)).name(ChatColor.RESET.toString()).build()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -196,13 +198,13 @@ public class Voucher {
|
||||
}
|
||||
|
||||
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();
|
||||
@ -215,11 +217,11 @@ public class Voucher {
|
||||
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) {
|
||||
@ -242,7 +244,7 @@ public class Voucher {
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
@ -15,6 +15,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class VoucherExecutor {
|
||||
@ -142,11 +143,8 @@ public class VoucherExecutor {
|
||||
}
|
||||
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user