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 -->
<repositories> <repositories>
<repository>
<id>papermc-repo</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
@ -45,6 +49,18 @@
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
</dependency> </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> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>

View File

@ -151,6 +151,11 @@ public class BlacksmithPlugin extends JavaPlugin {
case DIAMOND_HOE: case DIAMOND_HOE:
case DIAMOND_SWORD: case DIAMOND_SWORD:
case DIAMOND_AXE: case DIAMOND_AXE:
case NETHERITE_SWORD:
case NETHERITE_SHOVEL:
case NETHERITE_PICKAXE:
case NETHERITE_AXE:
case NETHERITE_HOE:
case BOW: case BOW:
case FLINT_AND_STEEL: case FLINT_AND_STEEL:
case FISHING_ROD: case FISHING_ROD:
@ -183,6 +188,10 @@ public class BlacksmithPlugin extends JavaPlugin {
case DIAMOND_CHESTPLATE: case DIAMOND_CHESTPLATE:
case DIAMOND_LEGGINGS: case DIAMOND_LEGGINGS:
case DIAMOND_BOOTS: case DIAMOND_BOOTS:
case NETHERITE_HELMET:
case NETHERITE_CHESTPLATE:
case NETHERITE_LEGGINGS:
case NETHERITE_BOOTS:
return true; return true;
default: default:
return false; return false;
@ -190,16 +199,16 @@ public class BlacksmithPlugin extends JavaPlugin {
} }
public boolean doesPlayerHaveEnough(Player player) { 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) { public String formatCost(Player player) {
double cost = getCost(player.getItemInHand(), player); double cost = getCost(player.getInventory().getItemInMainHand(), player);
return economy.format(cost); return economy.format(cost);
} }
public void withdraw(Player player) { 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. /* CitiTrader dependency outdated and broken.
public void deposit(NPC npc, Player player) { public void deposit(NPC npc, Player player) {
@ -224,7 +233,7 @@ public class BlacksmithPlugin extends JavaPlugin {
// Total price would then be base_price + price per durablity point * current durability // Total price would then be base_price + price per durablity point * current durability
double hyperPrice = 0; double hyperPrice = 0;
HItemStack hi = hyperAPI.getHyperPlayer(player.getName()).getItemInHand(); 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())) { for (TradeObject enchant : hyperAPI.getEnchantmentHyperObjects(hi, player.getName())) {
hyperPrice = hyperPrice + enchant.getBuyPrice(1); hyperPrice = hyperPrice + enchant.getBuyPrice(1);
@ -238,15 +247,15 @@ public class BlacksmithPlugin extends JavaPlugin {
leathers.add(Material.LEATHER_LEGGINGS); leathers.add(Material.LEATHER_LEGGINGS);
HItemStack hi3 = null; HItemStack hi3 = null;
if (leathers.contains(player.getItemInHand().getType())){ if (leathers.contains(player.getInventory().getItemInMainHand().getType())){
hi3 = bukCon.getBukkitCommon().getSerializableItemStack(new ItemStack(player.getItemInHand().getType())); hi3 = bukCon.getBukkitCommon().getSerializableItemStack(new ItemStack(player.getInventory().getItemInMainHand().getType()));
} }
TradeObject to = this.hyperAPI.getHyperObject(hi, "default"); TradeObject to = this.hyperAPI.getHyperObject(hi, "default");
if (to==null) { if (to==null) {
to = hyperAPI.getHyperObject(hi3, "default"); to = hyperAPI.getHyperObject(hi3, "default");
if (to==null) { 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"); to = this.hyperAPI.getHyperObject(hi4, "default");
} }
hyperPrice = hyperPrice+to.getSellPrice(1); 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){ if(session!=null){
//timeout //timeout
@ -206,10 +206,10 @@ public class BlacksmithTrait extends Trait {
plugin.withdraw(player); plugin.withdraw(player);
session.beginReforge(); session.beginReforge();
if (npc.getEntity() instanceof Player) if (npc.getEntity() instanceof Player)
((Player) npc.getEntity()).setItemInHand(player.getItemInHand()); ((Player) npc.getEntity()).getInventory().setItemInMainHand(player.getInventory().getItemInMainHand());
else else
((LivingEntity) npc.getEntity()).getEquipment().setItemInHand(player.getItemInHand()); ((LivingEntity) npc.getEntity()).getEquipment().setItemInMainHand(player.getInventory().getItemInMainHand());
player.setItemInHand(null); player.getInventory().setItemInMainHand(null);
} }
private class ReforgeSession implements Runnable { private class ReforgeSession implements Runnable {
@ -221,16 +221,16 @@ public class BlacksmithTrait extends Trait {
private ReforgeSession(Player player, NPC npc) { private ReforgeSession(Player player, NPC npc) {
this.player = player; this.player = player;
this.npc = npc; this.npc = npc;
reforge = player.getItemInHand(); reforge = player.getInventory().getItemInMainHand();
} }
@Override @Override
public void run() { public void run() {
player.sendMessage( reforgeItemInHand() ? successMsg : failMsg); player.sendMessage( reforgeItemInHand() ? successMsg : failMsg);
if (npc.getEntity() instanceof Player) if (npc.getEntity() instanceof Player)
((Player) npc.getEntity()).setItemInHand(null); ((Player) npc.getEntity()).getInventory().setItemInMainHand(null);
else else
((LivingEntity) npc.getEntity()).getEquipment().setItemInHand(null); ((LivingEntity) npc.getEntity()).getEquipment().setItemInMainHand(null);
if (!disabledelay) if (!disabledelay)
{ {
if (dropItem) if (dropItem)
@ -246,7 +246,7 @@ public class BlacksmithTrait extends Trait {
} }
else else
{ {
player.setItemInHand(reforge); player.getInventory().setItemInMainHand(reforge);
} }
session = null; session = null;
// Start cooldown // Start cooldown
@ -304,7 +304,7 @@ public class BlacksmithTrait extends Trait {
// Return if the session should end // Return if the session should end
private boolean handleClick() { private boolean handleClick() {
// Prevent player from switching items during session // Prevent player from switching items during session
if (!reforge.equals(player.getItemInHand())) { if (!reforge.equals(player.getInventory().getItemInMainHand())) {
player.sendMessage( itemChangedMsg); player.sendMessage( itemChangedMsg);
return true; return true;
} }