Skip to content

Commit

Permalink
Merge pull request #121 from FN-FAL113/Dev/mystery-stick-fixes
Browse files Browse the repository at this point in the history
fixed mystery sticks unchecked cast
  • Loading branch information
FN-FAL113 authored Feb 15, 2024
2 parents db4457d + 7f8944c commit 679a6b2
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 66 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>Unoffical-4.1.8</version>
<version>Unoffical-4.1.9</version>
<packaging>jar</packaging>

<name>FNAmplifications</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MysteryStick(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci
}

@Override
public Map<Enchantment, Integer> enchantments(){
public Map<Enchantment, Integer> enchantments() {
Map<Enchantment, Integer> enchantments = new HashMap<>();
enchantments.put(Enchantment.SWEEPING_EDGE, 2);
enchantments.put(Enchantment.DAMAGE_ALL, 3);
Expand All @@ -44,12 +44,12 @@ public Map<Enchantment, Integer> enchantments(){
}

@Override
public String weaponLore(){
public String weaponLore() {
return ChatColor.GOLD + "What is this sorcery?";
}

@Override
public String stickLore(){
public String stickLore() {
return ChatColor.WHITE + "I wonder what this stick does";
}

Expand All @@ -59,17 +59,23 @@ public Material getStickMaterial() {
}

@Override
public void onSwing(EntityDamageByEntityEvent event){
public void onSwing(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Player)) {
return;
}

Player player = (Player) event.getDamager();
ItemStack item = player.getInventory().getItemInMainHand();

if(item.getType() != getMaterial()){
if(item.getType() != getMaterial()) {
return;
}

if(getStickTask().onSwing(item, player, event.getDamage(), 27, 1)) {
if(getStickTask().onSwing(item, player, event.getDamage(), 20, 1)) {
LivingEntity victim = (LivingEntity) event.getEntity();

victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 80, 0, false, false, false));

player.sendMessage(Utils.colorTranslator("&cMystery effects was applied to your enemy"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public Map<Enchantment, Integer> enchantments(){
}

@Override
public String weaponLore(){
public String weaponLore() {
return ChatColor.GOLD + "Why is this stick too good";
}

@Override
public String stickLore(){
public String stickLore() {
return ChatColor.WHITE + "Deadly or creepy stick";
}

Expand All @@ -63,27 +63,34 @@ public Material getStickMaterial() {
}

@Override
public void onSwing(EntityDamageByEntityEvent event){
public void onSwing(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Player)) {
return;
}

Player player = (Player) event.getDamager();
ItemStack item = player.getInventory().getItemInMainHand();

if(item.getType() != getMaterial()){
if(item.getType() != getMaterial()) {
return;
} // if item material is not a weapon, don't continue further

if(getStickTask().onSwing(item, player, event.getDamage(), 13, 4)) {
if(getStickTask().onSwing(item, player, event.getDamage(), 28, 4)) {
LivingEntity victim = (LivingEntity) event.getEntity();

victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 80, 2, false, true, false));
victim.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 80, 2, false, true, false));
victim.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 80, 2, false, true, false));

int playerDefaultHealth = (int) Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue();
if(player.getHealth() < playerDefaultHealth - 2) {

if(player.getHealth() < playerDefaultHealth - 2) {
player.setHealth(player.getHealth() + 2);
victim.setHealth(victim.getHealth() < 2 ? victim.getHealth() + (victim.getHealth() * (-1)) : victim.getHealth() - 2);
} else {
player.sendMessage(ChatColor.RED + "Make sure your hearts are not full for Lifesteal to proc!");
}

player.sendMessage(Utils.colorTranslator("&cMystery effects was applied to your enemy"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MysteryStick11(ItemGroup itemGroup, SlimefunItemStack item, RecipeType re
}

@Override
public Map<Enchantment, Integer> enchantments(){
public Map<Enchantment, Integer> enchantments() {
Map<Enchantment, Integer> enchantments = new HashMap<>();
enchantments.put(Enchantment.DAMAGE_ARTHROPODS, 10);
enchantments.put(Enchantment.DAMAGE_ALL, 7);
Expand All @@ -46,12 +46,12 @@ public Map<Enchantment, Integer> enchantments(){
}

@Override
public String weaponLore(){
public String weaponLore() {
return ChatColor.GOLD + "Behind your enemies awaits danger";
}

@Override
public String stickLore(){
public String stickLore() {
return ChatColor.WHITE + "The stick of the nords";
}

Expand All @@ -61,24 +61,32 @@ public Material getStickMaterial() {
}

@Override
public void onSwing(EntityDamageByEntityEvent event){
public void onSwing(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Player)) {
return;
}

Player player = (Player) event.getDamager();
ItemStack item = player.getInventory().getItemInMainHand();

if(item.getType() != getMaterial()){
if(item.getType() != getMaterial()) {
return;
}

if(getStickTask().onSwing(item, player, event.getDamage(), 13, 4)) {
if(getStickTask().onSwing(item, player, event.getDamage(), 28, 4)) {
LivingEntity victim = (LivingEntity) event.getEntity();
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 80, 2, false, true, false));

victim.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 80, 2, false, true, false));
victim.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, 100, 2, false, true, false));

Location loc = victim.getLocation();

loc.setYaw(loc.getYaw() + 180);

victim.teleport(loc);
victim.sendMessage(ChatColor.DARK_RED + "You have been disoriented! your opponent's mysterious stick is deadly");

player.sendMessage(Utils.colorTranslator("&cMystery effects was applied to your enemy"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MysteryStick2(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec
}

@Override
public Map<Enchantment, Integer> enchantments(){
public Map<Enchantment, Integer> enchantments() {
Map<Enchantment, Integer> enchantments = new HashMap<>();
enchantments.put(Enchantment.DAMAGE_ARTHROPODS, 3);
enchantments.put(Enchantment.DAMAGE_ALL, 2);
Expand All @@ -44,32 +44,38 @@ public Map<Enchantment, Integer> enchantments(){
}

@Override
public String weaponLore(){
public String weaponLore() {
return ChatColor.GOLD + "Another stick of wrecking";
}

@Override
public String stickLore(){
public String stickLore() {
return ChatColor.WHITE + "Another stick of no matter what is it";
}

@Override
public Material getStickMaterial(){
public Material getStickMaterial() {
return getMaterial();
}

@Override
public void onSwing(EntityDamageByEntityEvent event){
public void onSwing(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Player)) {
return;
}

Player player = (Player) event.getDamager();
ItemStack item = player.getInventory().getItemInMainHand();

if(item.getType() != getMaterial()){
return;
}

if(getStickTask().onSwing(item, player, event.getDamage(), 27, 1)) {
if(getStickTask().onSwing(item, player, event.getDamage(), 20, 1)) {
LivingEntity victim = (LivingEntity) event.getEntity();

victim.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 80, 0, false, false, false));

player.sendMessage(Utils.colorTranslator("&cMystery effects was applied to your enemy"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MysteryStick3(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec
}

@Override
public Map<Enchantment, Integer> enchantments(){
public Map<Enchantment, Integer> enchantments() {
Map<Enchantment, Integer> enchantments = new HashMap<>();
enchantments.put(Enchantment.ARROW_DAMAGE, 2);
enchantments.put(Enchantment.ARROW_INFINITE, 1);
Expand All @@ -44,12 +44,12 @@ public Map<Enchantment, Integer> enchantments(){
}

@Override
public String weaponLore(){
public String weaponLore() {
return ChatColor.GOLD + "I knew it was something about shooting arrows";
}

@Override
public String stickLore(){
public String stickLore() {
return ChatColor.WHITE + "I feel coordinated when holding this stick";
}

Expand All @@ -59,10 +59,15 @@ public Material getStickMaterial() {
}

@Override
public void onSwing(EntityDamageByEntityEvent event){
public void onSwing(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Arrow)) {
return;
}

Arrow arrow = (Arrow) event.getDamager();
Player player = ((Player) arrow.getShooter());
if(player == null){

if(player == null) {
return;
}

Expand All @@ -72,9 +77,11 @@ public void onSwing(EntityDamageByEntityEvent event){
return;
}

if(getStickTask().onSwing(item, player, event.getDamage(), 27, 1)) {
if(getStickTask().onSwing(item, player, event.getDamage(), 20, 1)) {
LivingEntity victim = (LivingEntity) event.getEntity();

victim.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 80, 0, false, false));

player.sendMessage(Utils.colorTranslator("&cMystery effects was applied to your enemy"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MysteryStick4(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec
}

@Override
public Map<Enchantment, Integer> enchantments(){
public Map<Enchantment, Integer> enchantments() {
Map<Enchantment, Integer> enchantments = new HashMap<>();
enchantments.put(Enchantment.SWEEPING_EDGE, 3);
enchantments.put(Enchantment.DAMAGE_ALL, 3);
Expand All @@ -44,12 +44,12 @@ public Map<Enchantment, Integer> enchantments(){
}

@Override
public String weaponLore(){
public String weaponLore() {
return ChatColor.GOLD + "It was indeed a magical improvement";
}

@Override
public String stickLore(){
public String stickLore() {
return ChatColor.WHITE + "Did I use this before or maybe not";
}

Expand All @@ -59,18 +59,24 @@ public Material getStickMaterial() {
}

@Override
public void onSwing(EntityDamageByEntityEvent event){
public void onSwing(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Player)) {
return;
}

Player player = (Player) event.getDamager();
ItemStack item = player.getInventory().getItemInMainHand();

if(item.getType() != getMaterial()){
return;
}

if(getStickTask().onSwing(item, player, event.getDamage(), 20, 2)) {
if(getStickTask().onSwing(item, player, event.getDamage(), 24, 2)) {
LivingEntity victim = (LivingEntity) event.getEntity();

victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 100, 1, false, false, false));
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 40, 0, false, false, false));

player.sendMessage(Utils.colorTranslator("&cMystery effects was applied to your enemy"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MysteryStick5(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec
}

@Override
public Map<Enchantment, Integer> enchantments(){
public Map<Enchantment, Integer> enchantments() {
Map<Enchantment, Integer> enchantments = new HashMap<>();
enchantments.put(Enchantment.DAMAGE_ARTHROPODS, 4);
enchantments.put(Enchantment.DAMAGE_ALL, 3);
Expand All @@ -44,12 +44,12 @@ public Map<Enchantment, Integer> enchantments(){
}

@Override
public String weaponLore(){
public String weaponLore() {
return ChatColor.GOLD + "Another stick of somewhat reckoning";
}

@Override
public String stickLore(){
public String stickLore() {
return ChatColor.WHITE + "I know you are tired of this stick thing";
}

Expand All @@ -59,18 +59,24 @@ public Material getStickMaterial() {
}

@Override
public void onSwing(EntityDamageByEntityEvent event){
public void onSwing(EntityDamageByEntityEvent event) {
if(!(event.getDamager() instanceof Player)) {
return;
}

Player player = (Player) event.getDamager();
ItemStack item = player.getInventory().getItemInMainHand();

if(item.getType() != getMaterial()){
if(item.getType() != getMaterial()) {
return;
}

if(getStickTask().onSwing(item, player, event.getDamage(), 20, 2)) {
if(getStickTask().onSwing(item, player, event.getDamage(), 24, 2)) {
LivingEntity victim = (LivingEntity) event.getEntity();

victim.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 100, 1, false, false, false));
victim.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 40, 0, false, false, false));

player.sendMessage(Utils.colorTranslator("&cMystery effects was applied to your enemy"));
}

Expand Down
Loading

0 comments on commit 679a6b2

Please sign in to comment.