Initial commit
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package com.alttd.fishingevent.fish;
|
||||
|
||||
import com.alttd.fishingevent.config.Config;
|
||||
import com.alttd.fishingevent.config.Fishes;
|
||||
import com.alttd.fishingevent.objects.Rarity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class Fish {
|
||||
|
||||
/**
|
||||
* Get an the fish item for a specific player
|
||||
* @param player Player to get the item for
|
||||
* @return ItemStack for that fish item if one exists
|
||||
*/
|
||||
protected abstract ItemStack getFishItem(Player player);
|
||||
|
||||
/**
|
||||
* Gives back a different result each call, it generates a length based on the min and max length values for a fish
|
||||
* @return a random length for this fish
|
||||
*/
|
||||
public abstract float getLength();
|
||||
|
||||
public abstract Component fishName();
|
||||
|
||||
public abstract String normalFishName();
|
||||
|
||||
protected List<Component> fishLore(TagResolver tagResolver) {
|
||||
MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
return Fishes.FORMAT.LORE.stream()
|
||||
.map(entry -> miniMessage.deserialize(entry, tagResolver))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public abstract Rarity getRarity();
|
||||
|
||||
public ItemStack createItem(Player player, double length) {
|
||||
ItemStack fishItem = getFishItem(player);
|
||||
ItemMeta itemMeta = fishItem.getItemMeta();
|
||||
TagResolver resolver = TagResolver.resolver(
|
||||
Placeholder.component("player", player.name()),
|
||||
Placeholder.parsed("length", String.format("%.2f", length)),
|
||||
Placeholder.parsed("rarity", getRarity().displayName())
|
||||
);
|
||||
|
||||
itemMeta.lore(fishLore(resolver));
|
||||
itemMeta.displayName(fishName());
|
||||
|
||||
fishItem.setItemMeta(itemMeta);
|
||||
return fishItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives back the amount of points for this type of fish with the specified length
|
||||
* @param length The length to calculate points for
|
||||
* @return points based on the length and rarity of this fish
|
||||
*/
|
||||
public int getPoints(float length) {
|
||||
return Math.round(Config.RARITY_MULTIPLIERS.multiplierMap.get(getRarity()) * length);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.alttd.fishingevent.fish;
|
||||
|
||||
|
||||
import com.alttd.fishingevent.objects.Rarity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
public class LavaFish extends Fish {
|
||||
|
||||
public LavaFish(float minLength, float maxLength, String fishName, Rarity rarity, ItemStack itemStack, ArrayList<Set<Particle>> particles) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFishItem(Player player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLength() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component fishName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String normalFishName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Rarity getRarity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void spawnParticles(Location location) {
|
||||
//TODO run async function in here
|
||||
//TODO color particles based on rarity?
|
||||
}
|
||||
|
||||
public boolean validRod(ItemStack fishingRod) {
|
||||
//TODO check data to see if its a lava rod
|
||||
return false;
|
||||
}
|
||||
|
||||
public Instant getSpawnTime(ItemStack fishingRod) {
|
||||
//TODO calc based on rod enchant level and check if the rod is valid maybe?
|
||||
return Instant.now();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.alttd.fishingevent.fish;
|
||||
|
||||
import com.alttd.fishingevent.config.Fishes;
|
||||
import com.alttd.fishingevent.objects.Rarity;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class WaterFish extends Fish {
|
||||
|
||||
private final float minLength;
|
||||
private final float maxLength;
|
||||
private final String fishName;
|
||||
private final Rarity rarity;
|
||||
private final ItemStack itemStack;
|
||||
|
||||
public WaterFish(float minLength, float maxLength, String fishName, Rarity rarity, ItemStack itemStack) {
|
||||
this.minLength = minLength;
|
||||
this.maxLength = maxLength;
|
||||
this.fishName = fishName;
|
||||
this.rarity = rarity;
|
||||
this.itemStack = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getFishItem(Player player) {
|
||||
return itemStack.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLength() {
|
||||
return new Random().nextFloat(minLength, maxLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.kyori.adventure.text.@NotNull Component fishName() {
|
||||
return MiniMessage.miniMessage().deserialize(Fishes.FORMAT.DISPLAY_NAME, Placeholder.parsed("fish_name", fishName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String normalFishName() {
|
||||
return fishName;
|
||||
}
|
||||
@Override
|
||||
public Rarity getRarity() {
|
||||
return rarity;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user