Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from FN-FAL113:main #158

Merged
merged 4 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>Unoffical-4.1.4</version>
<version>Unoffical-4.1.5</version>
<packaging>jar</packaging>

<name>FNAmplifications</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ public void onProjectileDamage(EntityDamageByEntityEvent event, Player shooter,
return;
}

if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId()) &&
(projectile.getLocation().getY() - entity.getLocation().getY()) < 0.5) {
event.setDamage(event.getDamage() * 2.0);
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())
&& (projectile.getLocation().getY() - entity.getLocation().getY()) < 0.5) {
event.setDamage(event.getDamage() * 3.5);

sendGemMessage(shooter, this.getItemName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemIte
public void onDurabilityChange(PlayerItemDamageEvent event) {
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(event.getItem(), this.getId())) {
event.setCancelled(true);

sendGemMessage(event.getPlayer(), this.getItemName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public ArmorImpairGem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType re
}

@Override
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket){
if ((WeaponArmorEnum.SWORDS.isTagged(itemStackToSocket.getType()) || WeaponArmorEnum.AXES.isTagged(itemStackToSocket.getType()))) {
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket) {
if((WeaponArmorEnum.SWORDS.isTagged(itemStackToSocket.getType()) || WeaponArmorEnum.AXES.isTagged(itemStackToSocket.getType()))) {
if(isUpgradeGem(gemItem, this.getId())) {
upgradeGem(slimefunGemItem, itemStackToSocket, gemItem, player);
} else {
Expand All @@ -39,7 +39,7 @@ public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemIte
}

@Override
public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack) {
if(!(event.getEntity() instanceof LivingEntity)) {
return;
}
Expand All @@ -48,16 +48,24 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
return;
}

if(event.getEntity().isInvulnerable()) {
return;
}

LivingEntity livingEntity = (LivingEntity) event.getEntity();
ItemStack[] armorContents = livingEntity.getEquipment().getArmorContents();

for(ItemStack entityEquipment : armorContents){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId()) && entityEquipment != null){
for(ItemStack entityEquipment : armorContents) {
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId()) && entityEquipment != null) {
ItemMeta meta = entityEquipment.getItemMeta();
if(meta instanceof Damageable){

if(meta instanceof Damageable) {
Damageable damageable = (Damageable) meta;
damageable.setDamage(damageable.getDamage() + 4);

damageable.setDamage(damageable.getDamage() + 8);

entityEquipment.setItemMeta(meta);

if(event.getDamager() instanceof Player) {
sendGemMessage((Player) event.getDamager(), this.getItemName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack) {
return;
}

if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId()) &&
event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())
&& event.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
if(event.getEntity() instanceof Player) {
sendGemMessage((Player) event.getEntity(), this.getItemName());
}

event.setCancelled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / tier) {
int level = Math.abs(tier - 4);

livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 80, level));
livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 120, level));
sendGemMessage(player, this.getItemName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ public void onPlayerDeath(PlayerDeathEvent event, ItemStack itemStack) {
Player player = event.getEntity();
Location loc = player.getLocation();
Creeper creeper = player.getWorld().spawn(loc.clone(), Creeper.class);

creeper.setPowered(true); // big boomer creeper
creeper.setExplosionRadius(3);
creeper.setExplosionRadius(4);

sendGemMessage(event.getEntity(), this.getItemName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,20 @@ public void onPlayerDeath(PlayerDeathEvent event, ItemStack itemStack) {
player.spigot().respawn();
player.teleport(loc.clone());
player.playSound(loc, Sound.ENTITY_VINDICATOR_CELEBRATE, 1.0F, 1.0F);

sendGemMessage(player, this.getItemName());

for (int d = 0; d <= 90; d++) {
int r = ThreadLocalRandom.current().nextInt(255);
int g = ThreadLocalRandom.current().nextInt(255);
int b = ThreadLocalRandom.current().nextInt(255);

Location particleLoc = new Location(loc.getWorld(), loc.getX(), loc.getY(), loc.getZ());

// calculate the angle of x, z and multiply it by the size
particleLoc.setX(loc.getX() + Math.cos(d) * 2);
particleLoc.setZ(loc.getZ() + Math.sin(d) * 2);

player.getWorld().spawnParticle(Particle.REDSTONE, particleLoc, 2,
new Particle.DustOptions(Color.fromRGB(r, g, b), 2));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / tier) {
int level = Math.abs(tier - 4);

livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 80, level));
livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 120, level));
sendGemMessage(player, this.getItemName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class BerserkGem extends AbstractGem implements OnDamageHandler, GemUpgra
tierDamageMap.put(4, 0.06);
tierDamageMap.put(3, 0.12);
tierDamageMap.put(2, 0.18);
tierDamageMap.put(1, 0.30);
tierDamageMap.put(1, 0.36);
}

public BerserkGem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
Expand Down Expand Up @@ -65,7 +65,7 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack) {
return;
}

if (playerCurrentHealth <= playerDefaultHealth * 0.30 && !damager.isDead()) {
if (playerCurrentHealth <= playerDefaultHealth * 0.40 && !damager.isDead()) {
double damage = event.getDamage();
double finalDamage = (tierDamageMap.get(tier) * damage) + damage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public void onProjectileDamage(EntityDamageByEntityEvent event, Player shooter,
}

if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())) {
entity.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 80, 2, true, false, false));
entity.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 120, 2, true, false, false));

sendGemMessage(shooter, this.getItemName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / tier) {
int level = Math.abs(tier - 4);

victim.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 80, level));
victim.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 120, level));

sendGemMessage(victim, this.getItemName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack) {
}

if(WeaponArmorEnum.AXES.isTagged(damager.getEquipment().getItemInMainHand().getType())) {
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())){
event.setDamage(event.getDamage() * 0.75);
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())) {
event.setDamage(event.getDamage() * 0.6);

if(event.getEntity() instanceof Player) {
sendGemMessage((Player) event.getEntity(), this.getItemName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / tier) {
int level = Math.abs(tier - 4);

livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 80, level));
livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 120, level));

sendGemMessage(player, this.getItemName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / tier) {
int level = Math.abs(tier - 4);

livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 80, level));
livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 120, level));
sendGemMessage(player, this.getItemName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack) {
int slot = victim.getInventory().firstEmpty(); // get first empty slot from left to right

victim.getInventory().setItemInMainHand(null);

if (slot != -1) {
victim.getInventory().setItem(slot, itemInMainHand.clone());
} else {
victim.getWorld().dropItem(victim.getLocation(), itemInMainHand.clone());
}

sendGemMessage(damager, this.getItemName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public DisruptedGem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci
}

@Override
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket){
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket) {
if ((WeaponArmorEnum.SWORDS.isTagged(itemStackToSocket.getType()))) {
if(isUpgradeGem(gemItem, this.getId())) {
upgradeGem(slimefunGemItem, itemStackToSocket, gemItem, player);
Expand All @@ -36,15 +36,17 @@ public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemIte
}

@Override
public void onGuardianSpawn(GuardianSpawnEvent event, ItemStack itemStack){
public void onGuardianSpawn(GuardianSpawnEvent event, ItemStack itemStack) {
if(event.isCancelled()) {
return;
}

if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())) {
event.setCancelled(true);

event.getDamager().sendMessage(Utils
.colorTranslator("&eYou have redeemed the guardian of your enemy and destroyed it upon spawn"));

event.getGuardianOwner().sendMessage(Utils
.colorTranslator("&6Your guardian has been redeemed by your attacker and was destroyed upon spawn!"));
event.getGuardianOwner().playSound(event.getGuardianOwner().getLocation(), Sound.ENTITY_ZOMBIE_DEATH, 1.0F, 1.0F);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ public void onBlockBreak(BlockBreakEvent event, Player player, ItemStack itemSta

if(SlimefunTag.ORES.isTagged(block.getType()) || SlimefunTag.STONE_VARIANTS.isTagged(block.getType())) {
if (ThreadLocalRandom.current().nextInt(100) < (getChance() / getTier(itemStack, this.getId()))) {
PotionEffect potionEffect = new PotionEffect(PotionEffectType.FAST_DIGGING, 80, 2, true, false, false);
PotionEffect potionEffect = new PotionEffect(PotionEffectType.FAST_DIGGING, 120, 2, true, false, false);

player.addPotionEffect(potionEffect);

player.spigot().sendMessage(ChatMessageType.ACTION_BAR,
TextComponent.fromLegacyText(Utils.colorTranslator("&eYou're too hasty now!")));
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/ne/fnfal113/fnamplifications/gems/InfernoGem.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public InfernoGem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipe
}

@Override
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket){
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket) {
if (WeaponArmorEnum.SWORDS.isTagged(itemStackToSocket.getType())) {
if(isUpgradeGem(gemItem, this.getId())) {
upgradeGem(slimefunGemItem, itemStackToSocket, gemItem, player);
Expand All @@ -37,7 +37,7 @@ public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemIte
}

@Override
public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack) {
if(event.isCancelled()) {
return;
}
Expand All @@ -50,17 +50,17 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){

int random = ThreadLocalRandom.current().nextInt(100);

if(random < getChance() / getTier(itemStack, this.getId())){
if(random < getChance() / getTier(itemStack, this.getId())){
livingEntity.setFireTicks(60);
if(event.getDamager() instanceof Player) {
sendGemMessage((Player) event.getDamager(), this.getItemName());
}
} // set the attacked entity on fire

for(Entity entity : livingEntity.getNearbyEntities(7, 4,7)){
if(random < getChance()){
if(entity.getUniqueId() != event.getDamager().getUniqueId()){
entity.setFireTicks(60);
for(Entity entity : livingEntity.getNearbyEntities(8, 4,8)) {
if(random < getChance()) {
if(entity.getUniqueId() != event.getDamager().getUniqueId()) {
entity.setFireTicks(80);
} // make sure entity is not the attacker
}
} // loop nearby entities in a 7 block bounding box and set them on fire
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())) {
Bukkit.getScheduler().runTaskLater(FNAmplifications.getInstance(), () -> { // delay getting the actual hp of the damager
int playerDefaultHealth = (int) Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue();
if (player.getHealth() <= playerDefaultHealth - 2 && !livingEntity.isDead()) {

if (player.getHealth() <= playerDefaultHealth - 2 && livingEntity.getHealth() > 2 && !livingEntity.isDead()) {
player.setHealth(player.getHealth() + 2);
livingEntity.setHealth(livingEntity.getHealth() < 2 ? livingEntity.getHealth() + (livingEntity.getHealth() * (-1)) :
livingEntity.getHealth() - 2);
livingEntity.setHealth(livingEntity.getHealth() - 2);

sendGemMessage(player, this.getItemName());
}
}, 3L);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ne/fnfal113/fnamplifications/gems/LootGem.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack){

int random = ThreadLocalRandom.current().nextInt(100);

if(random < getChance() / getTier(itemStack, this.getId())){
if(random < getChance() / getTier(itemStack, this.getId())) {
FNAmplifications.getVaultIntegration().getEconomy().withdrawPlayer(Bukkit.getOfflinePlayer(victim.getUniqueId()), 4.0D);
FNAmplifications.getVaultIntegration().getEconomy().depositPlayer(Bukkit.getOfflinePlayer(damager.getUniqueId()), 4.0D);

sendGemMessage(damager, this.getItemName());
sendGemMessage(victim, Utils.colorTranslator("&cEnemy ") + this.getItemName());
}
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/ne/fnfal113/fnamplifications/gems/ParryGem.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ParryGem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeTy
}

@Override
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket){
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket) {
if (WeaponArmorEnum.HELMET.isTagged(itemStackToSocket.getType()) || WeaponArmorEnum.CHESTPLATE.isTagged(itemStackToSocket.getType()) ||
WeaponArmorEnum.LEGGINGS.isTagged(itemStackToSocket.getType()) || WeaponArmorEnum.BOOTS.isTagged(itemStackToSocket.getType())) {
if(isUpgradeGem(gemItem, this.getId())) {
Expand All @@ -38,26 +38,29 @@ public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemIte

@Override
public void onDamage(EntityDamageByEntityEvent event, ItemStack itemStack) {
if(event.isCancelled()){
if(event.isCancelled()) {
return;
}
if(!(event.getDamager() instanceof LivingEntity)){

if(!(event.getDamager() instanceof LivingEntity)) {
return;
}
if(!(event.getEntity() instanceof Player)){

if(!(event.getEntity() instanceof Player)) {
return;
}

LivingEntity damager = (LivingEntity) event.getDamager();
Player player = (Player) event.getEntity();

if(damager.getEquipment() == null){
if(damager.getEquipment() == null) {
return;
}

if(WeaponArmorEnum.SWORDS.isTagged(damager.getEquipment().getItemInMainHand().getType())){
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())){
event.setDamage(event.getDamage() * 0.75);
if(WeaponArmorEnum.SWORDS.isTagged(damager.getEquipment().getItemInMainHand().getType())) {
if(ThreadLocalRandom.current().nextInt(100) < getChance() / getTier(itemStack, this.getId())) {
event.setDamage(event.getDamage() * 0.6);

if(event.getEntity() instanceof Player) {
sendGemMessage(player, this.getItemName());
}
Expand Down
Loading