mirror of
https://github.com/songoda/UltimateRepairing.git
synced 2024-11-29 22:13:47 +01:00
Fix for effects 1.13
This commit is contained in:
parent
0942ef4dd8
commit
1bc90f55ac
@ -253,12 +253,12 @@ public class RepairHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void finish(boolean answer, Player p) {
|
public void finish(boolean answer, Player player) {
|
||||||
try {
|
try {
|
||||||
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(p.getUniqueId(), uuid -> new PlayerAnvilData());
|
PlayerAnvilData playerData = playerAnvilData.computeIfAbsent(player.getUniqueId(), uuid -> new PlayerAnvilData());
|
||||||
if (!answer) {
|
if (!answer) {
|
||||||
removeItem(playerData, p);
|
removeItem(playerData, player);
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.cancelled")));
|
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.cancelled")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RepairType type = playerData.getType();
|
RepairType type = playerData.getType();
|
||||||
@ -271,8 +271,8 @@ public class RepairHandler {
|
|||||||
net.milkbowl.vault.economy.Economy econ = rsp.getProvider();
|
net.milkbowl.vault.economy.Economy econ = rsp.getProvider();
|
||||||
int price = playerData.getPrice();
|
int price = playerData.getPrice();
|
||||||
|
|
||||||
if (econ.has(p, price)) {
|
if (econ.has(player, price)) {
|
||||||
econ.withdrawPlayer(p, price);
|
econ.withdrawPlayer(player, price);
|
||||||
sold = true;
|
sold = true;
|
||||||
}
|
}
|
||||||
economy = true;
|
economy = true;
|
||||||
@ -281,54 +281,56 @@ public class RepairHandler {
|
|||||||
int cost = Methods.getCost(type, players);
|
int cost = Methods.getCost(type, players);
|
||||||
ItemStack item2 = new ItemStack(Methods.getType(players), cost);
|
ItemStack item2 = new ItemStack(Methods.getType(players), cost);
|
||||||
String name = (item2.getType().name().substring(0, 1).toUpperCase() + item2.getType().name().toLowerCase().substring(1)).replace("_", " ");
|
String name = (item2.getType().name().substring(0, 1).toUpperCase() + item2.getType().name().toLowerCase().substring(1)).replace("_", " ");
|
||||||
if (type == RepairType.ITEM && Arconix.pl().getApi().getGUI().inventoryContains(p.getInventory(), item2)) {
|
if (type == RepairType.ITEM && Arconix.pl().getApi().getGUI().inventoryContains(player.getInventory(), item2)) {
|
||||||
Arconix.pl().getApi().getGUI().removeFromInventory(p.getInventory(), item2);
|
Arconix.pl().getApi().getGUI().removeFromInventory(player.getInventory(), item2);
|
||||||
sold = true;
|
sold = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == RepairType.XP && p.getLevel() >= playerData.getPrice() || sold || p.getGameMode() == GameMode.CREATIVE) {
|
if (type == RepairType.XP && player.getLevel() >= playerData.getPrice() || sold || player.getGameMode() == GameMode.CREATIVE) {
|
||||||
playerData.setBeingRepaired(true);
|
playerData.setBeingRepaired(true);
|
||||||
|
|
||||||
|
Effect effect = Effect.STEP_SOUND;
|
||||||
|
|
||||||
Location location = playerData.getLocations();
|
Location location = playerData.getLocations();
|
||||||
p.getWorld().playEffect(location, Effect.STEP_SOUND, 152);
|
player.getWorld().playEffect(location, effect, Material.REDSTONE_BLOCK);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> p.getWorld().playEffect(location, Effect.STEP_SOUND, 152), 5L);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.getWorld().playEffect(location, effect, Material.REDSTONE_BLOCK), 5L);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||||
p.getWorld().playEffect(location, Effect.STEP_SOUND, 152);
|
player.getWorld().playEffect(location, effect, Material.REDSTONE_BLOCK);
|
||||||
p.getWorld().playEffect(location, Effect.STEP_SOUND, 1);
|
player.getWorld().playEffect(location, effect, Material.STONE);
|
||||||
Arconix.pl().getApi().getPlayer(p).playSound(Sound.valueOf("BLOCK_ANVIL_LAND"));
|
Arconix.pl().getApi().getPlayer(player).playSound(Sound.valueOf("BLOCK_ANVIL_LAND"));
|
||||||
}, 10L);
|
}, 10L);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> p.getWorld().playEffect(location, Effect.STEP_SOUND, 152), 15L);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.getWorld().playEffect(location, effect, Material.REDSTONE_BLOCK), 15L);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> p.getWorld().playEffect(location, Effect.STEP_SOUND, 152), 20L);
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.getWorld().playEffect(location, effect, Material.REDSTONE_BLOCK), 20L);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||||
Arconix.pl().getApi().getPlayer(p).playSound(Sound.valueOf("BLOCK_ANVIL_LAND"));
|
Arconix.pl().getApi().getPlayer(player).playSound(Sound.valueOf("BLOCK_ANVIL_LAND"));
|
||||||
p.getWorld().playEffect(location, Effect.STEP_SOUND, 152);
|
player.getWorld().playEffect(location, effect, Material.REDSTONE_BLOCK);
|
||||||
p.getWorld().playEffect(location, Effect.STEP_SOUND, 145);
|
player.getWorld().playEffect(location, effect, Material.ANVIL);
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.success")));
|
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.success")));
|
||||||
ItemStack repairedi = playerData.getToBeRepaired();
|
ItemStack repairedi = playerData.getToBeRepaired();
|
||||||
repairedi.setDurability((short) 0);
|
repairedi.setDurability((short) 0);
|
||||||
Item repaired = p.getWorld().dropItemNaturally(p.getLocation(), repairedi);
|
Item repaired = player.getWorld().dropItemNaturally(player.getLocation(), repairedi);
|
||||||
repaired.remove();
|
repaired.remove();
|
||||||
p.getInventory().addItem(playerData.getToBeRepaired());
|
player.getInventory().addItem(playerData.getToBeRepaired());
|
||||||
playerData.getItem().remove();
|
playerData.getItem().remove();
|
||||||
if (p.getGameMode() != GameMode.CREATIVE &&
|
if (player.getGameMode() != GameMode.CREATIVE &&
|
||||||
type == RepairType.XP) {
|
type == RepairType.XP) {
|
||||||
p.setLevel(p.getLevel() - playerData.getPrice());
|
player.setLevel(player.getLevel() - playerData.getPrice());
|
||||||
}
|
}
|
||||||
this.playerAnvilData.remove(p.getUniqueId());
|
this.playerAnvilData.remove(player.getUniqueId());
|
||||||
p.closeInventory();
|
player.closeInventory();
|
||||||
}, 25L);
|
}, 25L);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == RepairType.ECONOMY) {
|
if (type == RepairType.ECONOMY) {
|
||||||
if (!economy)
|
if (!economy)
|
||||||
p.sendMessage("Vault is not installed.");
|
player.sendMessage("Vault is not installed.");
|
||||||
else
|
else
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", instance.getLocale().getMessage("interface.repair.eco"))));
|
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", instance.getLocale().getMessage("interface.repair.eco"))));
|
||||||
} else if (type == RepairType.XP)
|
} else if (type == RepairType.XP)
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", instance.getLocale().getMessage("interface.repair.xp"))));
|
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", instance.getLocale().getMessage("interface.repair.xp"))));
|
||||||
else
|
else
|
||||||
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", name)));
|
player.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + instance.getLocale().getMessage("event.repair.notenough", name)));
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user