Merge branch 'development'

This commit is contained in:
Christian Koop 2022-03-18 17:54:15 +01:00
commit ce859401e5
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
4 changed files with 17 additions and 19 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.songoda</groupId>
<artifactId>EpicVouchers</artifactId>
<version>2.2.1</version>
<version>2.2.2</version>
<name>EpicVouchers</name>
<description>Enhance your server with awesome customizable vouchers with a lot of features.</description>
@ -114,7 +114,7 @@
<dependency>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId>
<version>2.6.11</version>
<version>2.6.12</version>
<scope>compile</scope>
</dependency>

View File

@ -1,7 +1,6 @@
package com.songoda.epicvouchers.listeners;
import com.songoda.core.nms.NmsManager;
import com.songoda.core.nms.nbt.NBTItem;
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.songoda.epicvouchers.EpicVouchers;
import com.songoda.epicvouchers.utils.CachedSet;
import com.songoda.epicvouchers.voucher.Voucher;
@ -27,9 +26,9 @@ public class PlayerInteractListener implements Listener {
ItemStack item = e.getItem();
if (item != null && (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
NBTItem itemNbt = NmsManager.getNbt().of(item);
NBTItem itemNbt = new NBTItem(item);
boolean itemHasVoucher = itemNbt.has("epicvouchers:voucher");
boolean itemHasVoucher = itemNbt.hasKey("epicvouchers:voucher");
String itemVoucherValue = itemNbt.getString("epicvouchers:voucher");
boolean legacyChecked = checkedLegacyVouchers.contains(item);

View File

@ -2,8 +2,7 @@ package com.songoda.epicvouchers.voucher;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.nms.NmsManager;
import com.songoda.core.nms.nbt.NBTItem;
import com.songoda.core.third_party.de.tr7zw.nbtapi.NBTItem;
import com.songoda.core.utils.ItemUtils;
import com.songoda.core.utils.TextUtils;
import com.songoda.epicvouchers.EpicVouchers;
@ -113,9 +112,10 @@ public class Voucher {
item.setItemMeta(meta);
} else {
item.setItemMeta(meta);
NBTItem nbtItem = NmsManager.getNbt().of(item);
nbtItem.set("Unbreakable", (byte) 1);
item = nbtItem.finish();
NBTItem nbtItem = new NBTItem(item);
nbtItem.setByte("Unbreakable", (byte) 1);
item = nbtItem.getItem();
}
}
@ -123,10 +123,10 @@ public class Voucher {
item = ItemUtils.getCustomHead(texture);
}
NBTItem nbtItem = NmsManager.getNbt().of(item);
nbtItem.set("epicvouchers:voucher", key);
NBTItem nbtItem = new NBTItem(item);
nbtItem.setString("epicvouchers:voucher", key);
return nbtItem.finish();
return nbtItem.getItem();
}
public String getName(boolean applyFormatting) {

View File

@ -2,7 +2,6 @@ package com.songoda.epicvouchers.voucher;
import com.songoda.core.compatibility.CompatibleSound;
import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.utils.TextUtils;
import com.songoda.epicvouchers.EpicVouchers;
import com.songoda.epicvouchers.events.VoucherRedeemEvent;
import com.songoda.epicvouchers.listeners.PlayerCommandListener;
@ -167,13 +166,13 @@ public class VoucherExecutor {
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(effect), duration, amplifier));
}
instance.getLogger().log(Level.INFO, TextUtils.formatText("&f" + player.getName() + " has successfully redeemed the voucher " + voucher.getKey() + "."));
instance.getLogger().log(Level.INFO, player.getName() + " has successfully redeemed the voucher " + voucher.getKey() + ".");
instance.getConnections().saveRedeem(player, voucher.getName(true));
} else {
instance.getLogger().log(Level.WARNING, TextUtils.formatText("&c" + player.getName() + " has failed to duplicate the voucher " + voucher.getKey() + "."));
instance.getLogger().log(Level.WARNING, player.getName() + " has failed to duplicate the voucher " + voucher.getKey() + ".");
}
} catch (Exception error) {
instance.getLogger().log(Level.SEVERE, TextUtils.formatText("&cFailed to redeem the voucher " + voucher.getKey() + " for the player " + player.getName() + "."));
instance.getLogger().log(Level.SEVERE, "Failed to redeem the voucher " + voucher.getKey() + " for the player " + player.getName() + ".");
instance.getLogger().log(Level.SEVERE, error.getMessage());
error.printStackTrace();
}
@ -202,4 +201,4 @@ public class VoucherExecutor {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
}
}
}
}