update some deprecated

This commit is contained in:
Тимофей Бирюков 2021-02-25 20:49:27 +03:00
parent 1f6e267753
commit 915876f7d2
4 changed files with 51 additions and 24 deletions

2
META-INF/MANIFEST.MF Normal file
View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0

16
pom.xml
View File

@ -22,6 +22,10 @@
<!-- Repositories -->
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
@ -45,6 +49,18 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>

View File

@ -151,6 +151,11 @@ public class BlacksmithPlugin extends JavaPlugin {
case DIAMOND_HOE:
case DIAMOND_SWORD:
case DIAMOND_AXE:
case NETHERITE_SWORD:
case NETHERITE_SHOVEL:
case NETHERITE_PICKAXE:
case NETHERITE_AXE:
case NETHERITE_HOE:
case BOW:
case FLINT_AND_STEEL:
case FISHING_ROD:
@ -183,6 +188,10 @@ public class BlacksmithPlugin extends JavaPlugin {
case DIAMOND_CHESTPLATE:
case DIAMOND_LEGGINGS:
case DIAMOND_BOOTS:
case NETHERITE_HELMET:
case NETHERITE_CHESTPLATE:
case NETHERITE_LEGGINGS:
case NETHERITE_BOOTS:
return true;
default:
return false;
@ -190,16 +199,16 @@ public class BlacksmithPlugin extends JavaPlugin {
}
public boolean doesPlayerHaveEnough(Player player) {
return economy.getBalance((OfflinePlayer) player) - getCost(player.getItemInHand(), player) >= 0;
return economy.getBalance((OfflinePlayer) player) - getCost(player.getInventory().getItemInMainHand(), player) >= 0;
}
public String formatCost(Player player) {
double cost = getCost(player.getItemInHand(), player);
double cost = getCost(player.getInventory().getItemInMainHand(), player);
return economy.format(cost);
}
public void withdraw(Player player) {
economy.withdrawPlayer(((OfflinePlayer) player), getCost(player.getItemInHand(), player));
economy.withdrawPlayer(((OfflinePlayer) player), getCost(player.getInventory().getItemInMainHand(), player));
}
/* CitiTrader dependency outdated and broken.
public void deposit(NPC npc, Player player) {
@ -224,11 +233,11 @@ public class BlacksmithPlugin extends JavaPlugin {
// Total price would then be base_price + price per durablity point * current durability
double hyperPrice = 0;
HItemStack hi = hyperAPI.getHyperPlayer(player.getName()).getItemInHand();
ItemStack item2 = player.getItemInHand().clone();
ItemStack item2 = player.getInventory().getItemInMainHand().clone();
for (TradeObject enchant : hyperAPI.getEnchantmentHyperObjects(hi, player.getName())) {
hyperPrice = hyperPrice + enchant.getBuyPrice(1);
item2.removeEnchantment(Enchantment.getByName(enchant.getEnchantment().getEnchantmentName()));
item2.removeEnchantment(Enchantment.getByName(enchant.getEnchantment().getEnchantmentName ()));
}
ArrayList<Material> leathers = new ArrayList<Material>();
@ -238,15 +247,15 @@ public class BlacksmithPlugin extends JavaPlugin {
leathers.add(Material.LEATHER_LEGGINGS);
HItemStack hi3 = null;
if (leathers.contains(player.getItemInHand().getType())){
hi3 = bukCon.getBukkitCommon().getSerializableItemStack(new ItemStack(player.getItemInHand().getType()));
if (leathers.contains(player.getInventory().getItemInMainHand().getType())){
hi3 = bukCon.getBukkitCommon().getSerializableItemStack(new ItemStack(player.getInventory().getItemInMainHand().getType()));
}
TradeObject to = this.hyperAPI.getHyperObject(hi, "default");
if (to==null) {
to = hyperAPI.getHyperObject(hi3, "default");
if (to==null) {
HItemStack hi4 = bukCon.getBukkitCommon().getSerializableItemStack(new ItemStack(player.getItemInHand().getType()));
HItemStack hi4 = bukCon.getBukkitCommon().getSerializableItemStack(new ItemStack(player.getInventory().getItemInMainHand().getType()));
to = this.hyperAPI.getHyperObject(hi4, "default");
}
hyperPrice = hyperPrice+to.getSellPrice(1);

View File

@ -126,7 +126,7 @@ public class BlacksmithTrait extends Trait {
}
ItemStack hand = player.getItemInHand();
ItemStack hand = player.getInventory().getItemInMainHand();
if(session!=null){
//timeout
@ -206,10 +206,10 @@ public class BlacksmithTrait extends Trait {
plugin.withdraw(player);
session.beginReforge();
if (npc.getEntity() instanceof Player)
((Player) npc.getEntity()).setItemInHand(player.getItemInHand());
((Player) npc.getEntity()).getInventory().setItemInMainHand(player.getInventory().getItemInMainHand());
else
((LivingEntity) npc.getEntity()).getEquipment().setItemInHand(player.getItemInHand());
player.setItemInHand(null);
((LivingEntity) npc.getEntity()).getEquipment().setItemInMainHand(player.getInventory().getItemInMainHand());
player.getInventory().setItemInMainHand(null);
}
private class ReforgeSession implements Runnable {
@ -221,16 +221,16 @@ public class BlacksmithTrait extends Trait {
private ReforgeSession(Player player, NPC npc) {
this.player = player;
this.npc = npc;
reforge = player.getItemInHand();
reforge = player.getInventory().getItemInMainHand();
}
@Override
public void run() {
player.sendMessage( reforgeItemInHand() ? successMsg : failMsg);
if (npc.getEntity() instanceof Player)
((Player) npc.getEntity()).setItemInHand(null);
((Player) npc.getEntity()).getInventory().setItemInMainHand(null);
else
((LivingEntity) npc.getEntity()).getEquipment().setItemInHand(null);
((LivingEntity) npc.getEntity()).getEquipment().setItemInMainHand(null);
if (!disabledelay)
{
if (dropItem)
@ -246,7 +246,7 @@ public class BlacksmithTrait extends Trait {
}
else
{
player.setItemInHand(reforge);
player.getInventory().setItemInMainHand(reforge);
}
session = null;
// Start cooldown
@ -304,7 +304,7 @@ public class BlacksmithTrait extends Trait {
// Return if the session should end
private boolean handleClick() {
// Prevent player from switching items during session
if (!reforge.equals(player.getItemInHand())) {
if (!reforge.equals(player.getInventory().getItemInMainHand())) {
player.sendMessage( itemChangedMsg);
return true;
}