Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
buiawpkgew1 committed May 12, 2022
2 parents 0513ccf + 63fd409 commit dcb706a
Show file tree
Hide file tree
Showing 63 changed files with 561 additions and 1,091 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ne.fnfal113</groupId>
<artifactId>FNAmplifications</artifactId>
<version>3.2.4-UNOFFICIAL</version>
<version>3.2.5-UNOFFICIAL</version>
<packaging>jar</packaging>

<name>FNAmplifications</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,26 @@
import ne.fnfal113.fnamplifications.FNAmplifications;
import ne.fnfal113.fnamplifications.staffs.abstracts.AbstractStaff;
import ne.fnfal113.fnamplifications.staffs.implementations.AirStriderTask;
import ne.fnfal113.fnamplifications.staffs.implementations.MainStaff;
import ne.fnfal113.fnamplifications.utils.Keys;
import ne.fnfal113.fnamplifications.utils.Utils;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitTask;

import javax.annotation.Nonnull;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

public class StaffOfAirStrider extends AbstractStaff {

private final NamespacedKey defaultUsageKey;

private final Map<UUID, BukkitTask> taskMap = new HashMap<>();

private final MainStaff mainStaff;

public StaffOfAirStrider(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(itemGroup, item, recipeType, recipe, 10);

this.defaultUsageKey = new NamespacedKey(FNAmplifications.getInstance(), "airstriderstaff");
this.mainStaff = new MainStaff(getStorageKey(), this.getId());
}

protected @Nonnull
NamespacedKey getStorageKey() {
return defaultUsageKey;
super(itemGroup, item, recipeType, recipe, 10, Keys.createKey("airstriderstaff"));
}

@Override
Expand All @@ -64,7 +50,7 @@ public void onClick(PlayerInteractEvent event){

ItemMeta meta = item.getItemMeta();

mainStaff.updateMeta(item, meta, player);
getMainStaff().updateMeta(item, meta, player);

AtomicInteger i = new AtomicInteger(10);
Bukkit.getScheduler().runTaskTimer(FNAmplifications.getInstance(), task -> {
Expand All @@ -78,7 +64,7 @@ public void onClick(PlayerInteractEvent event){
task.cancel();
}
i.getAndDecrement();
},0L, 23L);
},0L, 21L);

}
}
20 changes: 1 addition & 19 deletions src/main/java/ne/fnfal113/fnamplifications/gears/FnBoots.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@SuppressWarnings("ConstantConditions")
Expand All @@ -41,7 +39,7 @@ public FnBoots(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTyp
this.defaultUsageKey = Keys.FN_GEAR_BOOTS;
this.defaultUsageKey2 = Keys.FN_GEAR_BOOTS_LEVEL;
this.defaultUsageKey3 = Keys.FN_GEAR_BOOTS_FINAL;
this.mainGears = new MainGears(getStorageKey(), getStorageKey2(), getStorageKey3(), defaultLore(), item, 25, 100);
this.mainGears = new MainGears(getStorageKey(), getStorageKey2(), getStorageKey3(), item, 25, 100);
}

protected @Nonnull
Expand All @@ -59,22 +57,6 @@ NamespacedKey getStorageKey3() {
return defaultUsageKey3;
}

@Override
public List<String> defaultLore(){
List<String> lore = new ArrayList<>();
lore.add(0, ChatColor.RED + "◬◬◬◬◬◬| "+ ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Lore " + ChatColor.GOLD + "|◬◬◬◬◬◬");
lore.add(1, "");
lore.add(2, ChatColor.WHITE + "Soldiers from FN's army only wants to posses");
lore.add(3, ChatColor.WHITE + "this historical boots but it was kept");
lore.add(4, ChatColor.WHITE + "hidden under the hands of the zion people");
lore.add(5, "");
lore.add(6, ChatColor.RED + "◬◬◬◬◬◬| "+ ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Stats " + ChatColor.GOLD + "|◬◬◬◬◬◬");

return lore;
}

@Override
public void onHit(EntityDamageByEntityEvent event){
if(!(event.getEntity() instanceof Player)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@SuppressWarnings("ConstantConditions")
Expand All @@ -41,7 +39,7 @@ public FnChestPlate(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci
this.defaultUsageKey = Keys.FN_GEAR_CHEST;
this.defaultUsageKey2 = Keys.FN_GEAR_CHEST_LEVEL;
this.defaultUsageKey3 = Keys.FN_GEAR_CHEST_FINAL;
this.mainGears = new MainGears(getStorageKey(), getStorageKey2(), getStorageKey3(), defaultLore(), item, 30, 120);
this.mainGears = new MainGears(getStorageKey(), getStorageKey2(), getStorageKey3(), item, 30, 120);
}

protected @Nonnull
Expand All @@ -59,22 +57,6 @@ NamespacedKey getStorageKey3() {
return defaultUsageKey3;
}

@Override
public List<String> defaultLore(){
List<String> lore = new ArrayList<>();
lore.add(0, ChatColor.RED + "◬◬◬◬◬◬| "+ ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Lore " + ChatColor.GOLD + "|◬◬◬◬◬◬");
lore.add(1, "");
lore.add(2, ChatColor.WHITE + "The armor from the past brought to life");
lore.add(3, ChatColor.WHITE + "once again. It becomes more powerful during");
lore.add(4, ChatColor.WHITE + "times of war and conflict");
lore.add(5, "");
lore.add(6, ChatColor.RED + "◬◬◬◬◬◬| "+ ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Stats " + ChatColor.GOLD + "|◬◬◬◬◬◬");

return lore;
}

@Override
public void onHit(EntityDamageByEntityEvent event){
if(!(event.getEntity() instanceof Player)){
Expand Down
20 changes: 1 addition & 19 deletions src/main/java/ne/fnfal113/fnamplifications/gears/FnHelmet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@SuppressWarnings("ConstantConditions")
Expand All @@ -41,7 +39,7 @@ public FnHelmet(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTy
this.defaultUsageKey = Keys.FN_GEAR_HELMET;
this.defaultUsageKey2 = Keys.FN_GEAR_HELMET_LEVEL;
this.defaultUsageKey3 = Keys.FN_GEAR_HELMET_FINAL;
this.mainGears = new MainGears(getStorageKey(), getStorageKey2(), getStorageKey3(), defaultLore(), item, 20, 100);
this.mainGears = new MainGears(getStorageKey(), getStorageKey2(), getStorageKey3(), item, 20, 100);
}

protected @Nonnull
Expand All @@ -59,22 +57,6 @@ NamespacedKey getStorageKey3() {
return defaultUsageKey3;
}

@Override
public List<String> defaultLore(){
List<String> lore = new ArrayList<>();
lore.add(0, ChatColor.RED + "◬◬◬◬◬◬| "+ ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Lore " + ChatColor.GOLD + "|◬◬◬◬◬◬");
lore.add(1, "");
lore.add(2, ChatColor.WHITE + "Wear this helmet in the name of FN and");
lore.add(3, ChatColor.WHITE + "every battle should make it become more");
lore.add(4, ChatColor.WHITE + "stronger with bonus attributes and enchants");
lore.add(5, "");
lore.add(6, ChatColor.RED + "◬◬◬◬◬◬| "+ ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Stats " + ChatColor.GOLD + "|◬◬◬◬◬◬");

return lore;
}

@Override
public void onHit(EntityDamageByEntityEvent event){
if(!(event.getEntity() instanceof Player)){
Expand Down
20 changes: 1 addition & 19 deletions src/main/java/ne/fnfal113/fnamplifications/gears/FnLeggings.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@SuppressWarnings("ConstantConditions")
Expand All @@ -41,7 +39,7 @@ public FnLeggings(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
this.defaultUsageKey = Keys.FN_GEAR_LEGGINGS;
this.defaultUsageKey2 = Keys.FN_GEAR_LEGGINGS_LEVEL;
this.defaultUsageKey3 = Keys.FN_GEAR_LEGGINGS_FINAL;
this.mainGears = new MainGears(getStorageKey(), getStorageKey2(), getStorageKey3(), defaultLore(), item, 30, 105);
this.mainGears = new MainGears(getStorageKey(), getStorageKey2(), getStorageKey3(), item, 30, 105);
}

protected @Nonnull
Expand All @@ -59,22 +57,6 @@ NamespacedKey getStorageKey3() {
return defaultUsageKey3;
}

@Override
public List<String> defaultLore(){
List<String> lore = new ArrayList<>();
lore.add(0, ChatColor.RED + "◬◬◬◬◬◬| "+ ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Lore " + ChatColor.GOLD + "|◬◬◬◬◬◬");
lore.add(1, "");
lore.add(2, ChatColor.WHITE + "Glorious leggings worn by FN during war");
lore.add(3, ChatColor.WHITE + "and was glorified on every victory against");
lore.add(4, ChatColor.WHITE + "his foes");
lore.add(5, "");
lore.add(6, ChatColor.RED + "◬◬◬◬◬◬| "+ ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Stats " + ChatColor.GOLD + "|◬◬◬◬◬◬");

return lore;
}

@Override
public void onHit(EntityDamageByEntityEvent event) {
if(!(event.getEntity() instanceof Player)){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.bukkit.inventory.meta.ItemMeta;

import java.io.IOException;
import java.util.List;

public abstract class AbstractGears extends SlimefunItem {

Expand All @@ -35,12 +34,6 @@ public final void setUnbreakable() {
this.getItem().setItemMeta(meta);
}

/**
* the lore used for rebuilding the item lore on update
* @return the default lore associated with the gear
*/
public abstract List<String> defaultLore();

/**
* This is where player gets the progress by being hit by living entities
* @param event the entity damage event where progress are added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,62 +28,54 @@ public class MainGears {
@Getter
private final NamespacedKey storageKey3;
@Getter
public final List<String> defaultLore;
@Getter
private final int startingProgress;
@Getter
private final int incrementProgress;
@Getter final ItemStack itemStack;
@Getter
private final ItemStack itemStack;

@Getter
@Setter
private int level;

public MainGears(NamespacedKey key1, NamespacedKey key2, NamespacedKey key3, List<String> lore, ItemStack item, int startingProgress, int incrementProgress){
public MainGears(NamespacedKey key1, NamespacedKey key2, NamespacedKey key3, ItemStack item, int startingProgress, int incrementProgress){
this.storageKey = key1;
this.storageKey2 = key2;
this.storageKey3 = key3;
this.defaultLore = lore;
this.itemStack = item;
this.startingProgress = startingProgress;
this.incrementProgress = incrementProgress;
}

public String getProgressBar(int current, int max, int totalBars, char symbol, ChatColor completedColor,
ChatColor notCompletedColor) {
float percent = (float) current / max;
int progressBars = (int) (totalBars * percent);
float percent = (float) current / max; // divide the current progress to the max value to get the percent
int progressBars = (int) (totalBars * percent); // multiply the percent value to total progress bars to get initial value

// repeat the progress bar icon with the initial value
// then get the difference between the initial value and total progress bars to get not completed bars
return Strings.repeat("" + completedColor + symbol, progressBars)
+ Strings.repeat("" + notCompletedColor + symbol, totalBars - progressBars);
}

public void updateLore(List<String> lore){
for(int i = 0; i < getDefaultLore().size(); i++){
lore.set(i , getDefaultLore().get(i));
}
}

public boolean onHit(EntityDamageByEntityEvent event, Player p, ItemStack item){
ItemMeta meta = item.getItemMeta();

PersistentDataContainer progress = meta.getPersistentDataContainer();
PersistentDataContainer level = meta.getPersistentDataContainer();
PersistentDataContainer max = meta.getPersistentDataContainer();

int amount = progress.getOrDefault(getStorageKey(), PersistentDataType.INTEGER, 0);
int armorLevel = level.getOrDefault(getStorageKey2(), PersistentDataType.INTEGER, 0);
int maxReq = max.getOrDefault(getStorageKey3(), PersistentDataType.INTEGER, getStartingProgress());
int armorLevel = progress.getOrDefault(getStorageKey2(), PersistentDataType.INTEGER, 0);
int maxReq = progress.getOrDefault(getStorageKey3(), PersistentDataType.INTEGER, getStartingProgress());
int total = amount + 1;

progress.set(getStorageKey(), PersistentDataType.INTEGER, total);

List<String> lore = meta.getLore();

if (total >= 0) {
updateLore(lore);
lore.set(7, ChatColor.YELLOW + "Level: " + armorLevel);
lore.set(8, ChatColor.YELLOW + "Progress:");
lore.set(9, ChatColor.GRAY + "[" + getProgressBar(total, maxReq, 10, '■', ChatColor.YELLOW, ChatColor.GRAY) + ChatColor.GRAY + "]");
if(WeaponArmorEnum.CHESTPLATE.isTagged(itemStack.getType()) && armorLevel == 30 && total == 1){
lore.set(7, Utils.colorTranslator("&eLevel: ") + armorLevel);
lore.set(8, Utils.colorTranslator("&eProgress:"));
lore.set(9, Utils.colorTranslator("&7[&r" + getProgressBar(total, maxReq, 10, '■', ChatColor.YELLOW, ChatColor.GRAY) + "&7]"));
if(WeaponArmorEnum.CHESTPLATE.isTagged(getItemStack().getType()) && armorLevel == 30 && total == 1){
lore.add(10,"");
lore.add(11, ChatColor.RED + "◬◬◬◬◬◬| " + ChatColor.LIGHT_PURPLE + ""
+ ChatColor.BOLD + "Effects " + ChatColor.GOLD + "|◬◬◬◬◬◬");
Expand All @@ -95,13 +87,14 @@ public boolean onHit(EntityDamageByEntityEvent event, Player p, ItemStack item){

if (total == maxReq) {
int totalLevel = armorLevel + 1;

progress.set(getStorageKey(), PersistentDataType.INTEGER, 0);
level.set(getStorageKey2(), PersistentDataType.INTEGER, totalLevel);
updateLore(lore);
lore.set(7, ChatColor.YELLOW + "Level: " + totalLevel);
lore.set(8, ChatColor.YELLOW + "Progress:");
lore.set(9, ChatColor.GRAY + "[" + getProgressBar(total, maxReq, 10, '■', ChatColor.YELLOW, ChatColor.GRAY) + ChatColor.GRAY + "]");
max.set(getStorageKey3(), PersistentDataType.INTEGER, maxReq + getIncrementProgress());
progress.set(getStorageKey2(), PersistentDataType.INTEGER, totalLevel);

lore.set(7, Utils.colorTranslator("&eLevel: ") + totalLevel);
lore.set(8, Utils.colorTranslator("&eProgress:"));
lore.set(9, Utils.colorTranslator("&7[&r" + getProgressBar(total, maxReq, 10, '■', ChatColor.YELLOW, ChatColor.GRAY) + "&7]"));
progress.set(getStorageKey3(), PersistentDataType.INTEGER, maxReq + getIncrementProgress());
meta.setLore(lore);
item.setItemMeta(meta);
levelUp(p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void onEntityDamage(EntityDamageByEntityEvent event){

Player p = (Player) event.getEntity();

if(ThreadLocalRandom.current().nextInt(100) < 12) {
if(ThreadLocalRandom.current().nextInt(100) < 23) {
for(ItemStack armour : p.getInventory().getArmorContents()) {
if (armour != null) {
SlimefunItem armor = SlimefunItem.getByItem(armour);
Expand All @@ -50,7 +50,7 @@ public void onEntityDamage(EntityDamageByEntityEvent event){
}
Player p = (Player) event.getEntity();

if(ThreadLocalRandom.current().nextInt(100) < 12) {
if(ThreadLocalRandom.current().nextInt(100) < 25) {
for(ItemStack armour : p.getInventory().getArmorContents()) {
if (armour != null) {
SlimefunItem armor = SlimefunItem.getByItem(armour);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import ne.fnfal113.fnamplifications.FNAmplifications;
import ne.fnfal113.fnamplifications.gears.FnChestPlate;
import ne.fnfal113.fnamplifications.utils.Keys;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
Expand Down Expand Up @@ -48,7 +48,7 @@ public int getArmorLevel(ItemStack itemStack){
ItemMeta meta = itemStack.getItemMeta();
PersistentDataContainer pdc = meta.getPersistentDataContainer();

return pdc.getOrDefault(new NamespacedKey(FNAmplifications.getInstance(), "armorlevel"), PersistentDataType.INTEGER, 0);
return pdc.getOrDefault(Keys.createKey("armorlevel"), PersistentDataType.INTEGER, 0);
}

}
Loading

0 comments on commit dcb706a

Please sign in to comment.