Skip to content

Commit

Permalink
Items now drop on the floor if unused & add glows option to config.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
xsmeths committed May 11, 2021
1 parent 54f5b9e commit f6b23ac
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,26 @@ public void run()
if ((progress > total) || (cancelled))
{
if (cancelled) {
p.getInventory().addItem(ItemLoader.getBandageItem());
p.getWorld().dropItem(p.getLocation(),ItemLoader.getBandageItem());
}
BandageHandler.bandagingPlayers.remove(p);
cancel();
} else if (this.progress == total) {
} else if (progress == total) {
if (MedCraft.getPlugin().getConfig().getBoolean("Bandage.PerformCMD") && MedCraft.getPlugin().getConfig().getBoolean("Bandage.ConsoleCMD") && p.getHealth() < Objects.requireNonNull(p.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue()) {
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, duration, amplifier));
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), String.valueOf(MedCraft.getPlugin().getConfig().get("Bandage.CMD")).replace("[playername]", p.getName()));
} else if (p.getPlayer() != null && MedCraft.getPlugin().getConfig().getBoolean("Bandage.PerformCMD") && !MedCraft.getPlugin().getConfig().getBoolean("Bandage.ConsoleCMD") && p.getHealth() < Objects.requireNonNull(p.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue()) {
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, duration, amplifier));
Bukkit.dispatchCommand(p.getPlayer(),String.valueOf(MedCraft.getPlugin().getConfig().get("Bandage.CMD")).replace("[playername]", p.getName()));
Bukkit.dispatchCommand(p.getPlayer(), String.valueOf(MedCraft.getPlugin().getConfig().get("Bandage.CMD")).replace("[playername]", p.getName()));
} else if (!MedCraft.getPlugin().getConfig().getBoolean("Bandage.PerformCMD") && p.getHealth() < Objects.requireNonNull(p.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue()) {
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, duration, amplifier));
} else {
p.getInventory().addItem(ItemLoader.getBandageItem());
p.getWorld().dropItem(p.getLocation(),ItemLoader.getBandageItem());
BandageHandler.bandagingPlayers.remove(p);
cancel();
}
}
int a = Math.round(this.progress / 60.0F * 10.0F);
int a = Math.round(progress / 60.0F * 10.0F);
int b = 10 - a;
StringBuilder sb = new StringBuilder();
sb.append(ChatColor.GREEN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void run()
if ((progress > total) || (cancelled))
{
if (cancelled) {
p.getInventory().addItem(ItemLoader.getMedKitItem());
p.getWorld().dropItem(p.getLocation(),ItemLoader.getMedKitItem());
}
MedKitHandler.MedKitPlayers.remove(p);
cancel();
Expand All @@ -56,7 +56,7 @@ public void run()
} else if (!MedCraft.getPlugin().getConfig().getBoolean("MedKit.PerformCMD") && p.getHealth() < Objects.requireNonNull(p.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue()) {
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, duration, amplifier));
} else {
p.getInventory().addItem(ItemLoader.getMedKitItem());
p.getWorld().dropItem(p.getLocation(),ItemLoader.getMedKitItem());
MedKitHandler.MedKitPlayers.remove(p);
cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ private void setupBandageItem() {
ItemMeta BandageMeta = BandageItem.getItemMeta();
BandageMeta.setCustomModelData(medCraft.getConfig().getInt("Bandage.ModelData"));
BandageMeta.setDisplayName(ChatColor.RESET + ChatColor.translateAlternateColorCodes('&',BandageName));
BandageMeta.addEnchant(Enchantment.DURABILITY,1,true);
BandageMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
if (MedCraft.getPlugin().getConfig().getBoolean("Bandage.Glows")) {
BandageMeta.addEnchant(Enchantment.DURABILITY, 1, true);
BandageMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
for (String bandagelorelines : MedCraft.getPlugin().getConfig().getStringList("Bandage.Lore")) {
Bandagelore.add(ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', bandagelorelines));
}
Expand Down Expand Up @@ -96,8 +98,10 @@ private void setupMedKitItem() {
ItemMeta MedKitMeta = MedKitItem.getItemMeta();
MedKitMeta.setCustomModelData(medCraft.getConfig().getInt("MedKit.ModelData"));
MedKitMeta.setDisplayName(ChatColor.RESET + ChatColor.translateAlternateColorCodes('&',MedKitName));
MedKitMeta.addEnchant(Enchantment.DURABILITY,1,true);
MedKitMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
if (MedCraft.getPlugin().getConfig().getBoolean("MedKit.Glows")) {
MedKitMeta.addEnchant(Enchantment.DURABILITY, 1, true);
MedKitMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
for (String medkitlorelines : MedCraft.getPlugin().getConfig().getStringList("MedKit.Lore")) {
Medkitlore.add(ChatColor.RESET + ChatColor.translateAlternateColorCodes('&', medkitlorelines));
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Bandage:
Material: PAPER
Glows: false
Warmup-Speed: 2
Result-Amount: 2
ModelData: 16
Expand Down Expand Up @@ -28,6 +29,7 @@ Bandage:
NoPermUse: 'No Permissions: you need bandage.use'
MedKit:
Material: PAPER
Glows: true
Warmup-Speed: 1
Result-Amount: 1
ModelData: 18
Expand Down

0 comments on commit f6b23ac

Please sign in to comment.