1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-20 07:01:22 +01:00

Same changes for giving items

This commit is contained in:
montlikadani 2019-08-14 16:06:44 +02:00
parent a2668474f4
commit a4b2b4e6b5
5 changed files with 24 additions and 12 deletions

View File

@ -15,7 +15,6 @@ import com.gamingmesh.jobs.container.ActionType;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent; import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityDeactivateEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
public class McMMO2_X_listener implements Listener { public class McMMO2_X_listener implements Listener {
@ -56,10 +55,6 @@ public class McMMO2_X_listener implements Listener {
Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR)); Jobs.action(jPlayer, new ItemActionInfo(resultStack, ActionType.REPAIR));
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void OnAbility(McMMOPlayerAbilityEvent event) {
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) { public void OnAbilityOn(McMMOPlayerAbilityActivateEvent event) {
HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId()); HashMap<String, Long> InfoMap = Jobs.getMcMMOManager().getMap().get(event.getPlayer().getUniqueId());

View File

@ -30,6 +30,7 @@ import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer; import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.PlayerPoints; import com.gamingmesh.jobs.container.PlayerPoints;
import com.gamingmesh.jobs.container.ShopItem; import com.gamingmesh.jobs.container.ShopItem;
import com.gamingmesh.jobs.stuff.GiveItem;
public class ShopManager { public class ShopManager {
private List<ShopItem> list = new ArrayList<>(); private List<ShopItem> list = new ArrayList<>();
@ -123,7 +124,7 @@ public class ShopManager {
for (JobItems one : item.getitems()) { for (JobItems one : item.getitems()) {
ItemStack itemStack = one.getItemStack(player); ItemStack itemStack = one.getItemStack(player);
player.getInventory().addItem(itemStack); GiveItem.GiveItemForPlayer(player, itemStack);
} }
pointsInfo.takePoints(item.getPrice()); pointsInfo.takePoints(item.getPrice());

View File

@ -42,6 +42,8 @@ public class JobsManager {
dao = startMysql(); dao = startMysql();
dao.setDbType(DbType); dao.setDbType(DbType);
break; break;
default:
break;
} }
File f = new File(Jobs.getFolder(), "generalConfig.yml"); File f = new File(Jobs.getFolder(), "generalConfig.yml");

View File

@ -14,7 +14,8 @@ import org.bukkit.inventory.meta.ItemMeta;
import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial; import com.gamingmesh.jobs.CMILib.ItemManager.CMIMaterial;
public class GiveItem { public class GiveItem {
public static boolean GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore, HashMap<Enchantment, Integer> hashMap) { public static void GiveItemForPlayer(Player player, int id, int meta, int qty, String name, List<String> lore,
HashMap<Enchantment, Integer> hashMap) {
ItemStack itemStack = CMIMaterial.get(id, meta).newItemStack(); ItemStack itemStack = CMIMaterial.get(id, meta).newItemStack();
itemStack.setAmount(qty); itemStack.setAmount(qty);
ItemMeta ItemMeta = itemStack.getItemMeta(); ItemMeta ItemMeta = itemStack.getItemMeta();
@ -24,22 +25,23 @@ public class GiveItem {
for (String oneLore : lore) { for (String oneLore : lore) {
TranslatedLore.add(ChatColor.translateAlternateColorCodes('&', oneLore.replace("[player]", player.getName()))); TranslatedLore.add(ChatColor.translateAlternateColorCodes('&', oneLore.replace("[player]", player.getName())));
} }
ItemMeta.setLore(TranslatedLore); ItemMeta.setLore(TranslatedLore);
} }
for (Entry<Enchantment, Integer> OneEnchant : hashMap.entrySet()) { for (Entry<Enchantment, Integer> OneEnchant : hashMap.entrySet()) {
ItemMeta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true); ItemMeta.addEnchant(OneEnchant.getKey(), OneEnchant.getValue(), true);
} }
if (name != null) if (name != null)
ItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); ItemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
itemStack.setItemMeta(ItemMeta); itemStack.setItemMeta(ItemMeta);
player.getInventory().addItem(itemStack); GiveItemForPlayer(player, itemStack);
player.updateInventory();
return true;
} }
public static boolean GiveItemForPlayer(Player player, ItemStack item) { public static void GiveItemForPlayer(Player player, ItemStack item) {
player.getInventory().addItem(item); player.getInventory().addItem(item);
player.updateInventory(); player.updateInventory();
return true;
} }
} }

View File

@ -32,6 +32,18 @@ public class blockLoc {
this.worldName = worldName; this.worldName = worldName;
} }
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public void setZ(int z) {
this.z = z;
}
@Override @Override
public String toString() { public String toString() {
return (w == null ? worldName : w.getName()) + ":" + x + ":" + y + ":" + z; return (w == null ? worldName : w.getName()) + ":" + x + ":" + y + ":" + z;