Skip to content

Commit

Permalink
Merge pull request #8 from SlimefunGuguProject/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ybw0014 authored Apr 7, 2022
2 parents 996ebdd + 2a39c2e commit 80ef887
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 115 deletions.
1 change: 1 addition & 0 deletions src/main/java/bxx2004/bump/Bump.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public final class Bump extends AbstractAddon {

public Bump() {
super("SlimefunGuguProject", "Bump", "main", "options.auto-update");
setupMetrics(14870);
}

@Override
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/bxx2004/bump/abstracts/BumpBow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package bxx2004.bump.abstracts;

import bxx2004.bump.handlers.BowUseHandler;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import org.bukkit.inventory.ItemStack;

public abstract class BumpBow extends SimpleSlimefunItem<BowUseHandler> implements DamageableItem {
protected BumpBow(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(itemGroup, item, recipeType, recipe);
}

@Override
public boolean isDamageable() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bxx2004.bump.slimefun.items.food;
package bxx2004.bump.abstracts;

import bxx2004.bump.Bump;
import bxx2004.bump.slimefun.BumpItemGroups;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package bxx2004.bump.slimefun.items.food;
package bxx2004.bump.abstracts;

import bxx2004.bump.Bump;
import bxx2004.bump.slimefun.BumpItemGroups;
Expand Down
99 changes: 0 additions & 99 deletions src/main/java/bxx2004/bump/event/MachineEvent.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.util.Optional;

public interface BowShootHandler extends ItemHandler {
public interface BowUseHandler extends ItemHandler {

void onShoot(EntityShootBowEvent e, Player p, ItemStack item);

Expand All @@ -25,6 +25,6 @@ default Optional<IncompatibleItemHandlerException> validate(SlimefunItem item) {

@Override
default Class<? extends ItemHandler> getIdentifier() {
return BowShootHandler.class;
return BowUseHandler.class;
}
}
4 changes: 2 additions & 2 deletions src/main/java/bxx2004/bump/listeners/BowShootListener.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package bxx2004.bump.listeners;

import bxx2004.bump.handlers.BowShootHandler;
import bxx2004.bump.handlers.BowUseHandler;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -22,7 +22,7 @@ public void onBowShoot(EntityShootBowEvent e) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);

if (sfItem != null && sfItem.canUse(p, true)) {
sfItem.callItemHandler(BowShootHandler.class, handler -> handler.onShoot(e, p, item));
sfItem.callItemHandler(BowUseHandler.class, handler -> handler.onShoot(e, p, item));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bxx2004.bump.slimefun.items.food;

import bxx2004.bump.abstracts.ItemFood;
import bxx2004.bump.slimefun.BumpItems;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/bxx2004/bump/slimefun/items/food/Kele.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bxx2004.bump.slimefun.items.food;

import bxx2004.bump.abstracts.ConsumableFood;
import bxx2004.bump.slimefun.BumpItems;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bxx2004.bump.slimefun.items.food;

import bxx2004.bump.abstracts.ItemFood;
import bxx2004.bump.slimefun.BumpItems;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/bxx2004/bump/slimefun/items/food/Latiao.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bxx2004.bump.slimefun.items.food;

import bxx2004.bump.abstracts.ConsumableFood;
import bxx2004.bump.slimefun.BumpItems;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/bxx2004/bump/slimefun/items/food/Xuebi.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package bxx2004.bump.slimefun.items.food;

import bxx2004.bump.abstracts.ConsumableFood;
import bxx2004.bump.slimefun.BumpItems;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import org.bukkit.Material;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package bxx2004.bump.slimefun.items.weapon;

import bxx2004.bump.Bump;
import bxx2004.bump.handlers.BowShootHandler;
import bxx2004.bump.abstracts.BumpBow;
import bxx2004.bump.handlers.BowUseHandler;
import bxx2004.bump.slimefun.BumpItemGroups;
import bxx2004.bump.slimefun.BumpItems;
import bxx2004.bump.util.Utils;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;

public class LightBow extends SimpleSlimefunItem<BowShootHandler> {
public class LightBow extends BumpBow {

public LightBow() {
super(BumpItemGroups.WEAPON, BumpItems.LIGHT_BOW, RecipeType.ARMOR_FORGE, new ItemStack[] {
Expand All @@ -24,11 +24,12 @@ public LightBow() {

@Nonnull
@Override
public BowShootHandler getItemHandler() {
public BowUseHandler getItemHandler() {
return (e, p, item) -> {
e.setCancelled(true);
if (p.getFoodLevel() >= 10) {
Utils.changeFoodLevel(p, p.getFoodLevel() - 10);
damageItem(p, item);

Bump.getLocalization().sendActionbarMessage(p, "weapon.light_bow");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package bxx2004.bump.slimefun.items.weapon;

import bxx2004.bump.Bump;
import bxx2004.bump.handlers.BowShootHandler;
import bxx2004.bump.abstracts.BumpBow;
import bxx2004.bump.handlers.BowUseHandler;
import bxx2004.bump.slimefun.BumpItemGroups;
import bxx2004.bump.slimefun.BumpItems;
import bxx2004.bump.util.Utils;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import org.bukkit.entity.WitherSkull;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;

public class WitherSkullBow extends SimpleSlimefunItem<BowShootHandler> {
public class WitherSkullBow extends BumpBow {

public WitherSkullBow() {
super(BumpItemGroups.WEAPON, BumpItems.WITHERSKULL_ROW, RecipeType.ARMOR_FORGE, new ItemStack[] {
Expand All @@ -25,11 +25,12 @@ public WitherSkullBow() {

@Nonnull
@Override
public BowShootHandler getItemHandler() {
public BowUseHandler getItemHandler() {
return (e, p, item) -> {
e.setCancelled(true);
if (p.getFoodLevel() >= 5) {
Utils.changeFoodLevel(p, p.getFoodLevel() - 5);
damageItem(p, item);

e.setCancelled(true);
Bump.getLocalization().sendActionbarMessage(p, "weapon.wither_skull_bow");
Expand Down
1 change: 0 additions & 1 deletion src/main/java/bxx2004/bump/util/AppraiseUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.util.logging.Level;

/**
* Utility methods for appraise
Expand Down
1 change: 0 additions & 1 deletion src/main/java/bxx2004/bump/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.text.MessageFormat;
import java.util.ArrayList;
Expand Down

0 comments on commit 80ef887

Please sign in to comment.