mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 20:09:14 +00:00
1.3-beta-3
This commit is contained in:
@@ -4,7 +4,56 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class ModeThreeBar extends FishingBar {
|
||||
|
||||
private final String fish_image;
|
||||
private final int fish_icon_width;
|
||||
private final String[] strain;
|
||||
private final String[] struggling_fish_image;
|
||||
private final int bar_effective_width;
|
||||
private final int fish_offset;
|
||||
private final int fish_start_position;
|
||||
private final int success_position;
|
||||
|
||||
public ModeThreeBar(ConfigurationSection section) {
|
||||
super(section);
|
||||
this.fish_icon_width = section.getInt("arguments.fish-icon-width");
|
||||
this.fish_image = section.getString("subtitle.fish");
|
||||
this.strain = section.getStringList("strain").toArray(new String[0]);
|
||||
this.struggling_fish_image = section.getStringList("subtitle.struggling-fish").toArray(new String[0]);
|
||||
this.bar_effective_width = section.getInt("arguments.bar-effective-area-width");
|
||||
this.fish_offset = section.getInt("arguments.fish-offset");
|
||||
this.fish_start_position = section.getInt("arguments.fish-start-position");
|
||||
this.success_position = section.getInt("arguments.success-position");
|
||||
}
|
||||
|
||||
public String getFish_image() {
|
||||
return fish_image;
|
||||
}
|
||||
|
||||
public int getFish_icon_width() {
|
||||
return fish_icon_width;
|
||||
}
|
||||
|
||||
public String[] getStrain() {
|
||||
return strain;
|
||||
}
|
||||
|
||||
public int getBar_effective_width() {
|
||||
return bar_effective_width;
|
||||
}
|
||||
|
||||
public int getFish_offset() {
|
||||
return fish_offset;
|
||||
}
|
||||
|
||||
public int getFish_start_position() {
|
||||
return fish_start_position;
|
||||
}
|
||||
|
||||
public int getSuccess_position() {
|
||||
return success_position;
|
||||
}
|
||||
|
||||
public String[] getStruggling_fish_image() {
|
||||
return struggling_fish_image;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class Item {
|
||||
private String head64;
|
||||
private List<LeveledEnchantment> enchantment;
|
||||
private Map<String, Object> nbt;
|
||||
private String totem;
|
||||
|
||||
public Item(Material material, String key) {
|
||||
this.material = material;
|
||||
@@ -79,6 +80,9 @@ public class Item {
|
||||
if (section.contains("head64")) {
|
||||
this.setHead64(section.getString("head64"));
|
||||
}
|
||||
if (section.contains("totem")) {
|
||||
this.setTotem(section.getString("totem"));
|
||||
}
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
@@ -157,6 +161,14 @@ public class Item {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public String getTotem() {
|
||||
return totem;
|
||||
}
|
||||
|
||||
public void setTotem(String totem) {
|
||||
this.totem = totem;
|
||||
}
|
||||
|
||||
public Item cloneWithPrice(double price){
|
||||
Item newItem = new Item(this.material, this.key);
|
||||
if (this.lore != null){
|
||||
|
||||
@@ -1,13 +1,100 @@
|
||||
package net.momirealms.customfishing.fishing.mode;
|
||||
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.fishing.bar.FishingBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeThreeBar;
|
||||
import net.momirealms.customfishing.manager.FishingManager;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ModeThreeGame extends FishingGame {
|
||||
|
||||
public ModeThreeGame(CustomFishing plugin, FishingManager fishingManager, long deadline, Player player, int difficulty, FishingBar fishingBar) {
|
||||
super(plugin, fishingManager, deadline, player, difficulty, fishingBar);
|
||||
private final ModeThreeBar modeThreeBar;
|
||||
private int fish_position;
|
||||
private boolean success;
|
||||
private int timer;
|
||||
private final int timer_max;
|
||||
private double strain;
|
||||
private int struggling_time;
|
||||
|
||||
public ModeThreeGame(CustomFishing plugin, FishingManager fishingManager, long deadline, Player player, int difficulty, ModeThreeBar modeThreeBar) {
|
||||
super(plugin, fishingManager, deadline, player, difficulty, modeThreeBar);
|
||||
this.fish_position = modeThreeBar.getFish_start_position();
|
||||
this.success = false;
|
||||
this.modeThreeBar = modeThreeBar;
|
||||
this.timer_max = modeThreeBar.getStruggling_fish_image().length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (timeOut() || switchItem()) return;
|
||||
timer++;
|
||||
if (timer >= timer_max) {
|
||||
timer = 0;
|
||||
}
|
||||
if (struggling_time <= 0) {
|
||||
if (Math.random() < ((double) difficulty / 200)) {
|
||||
struggling_time = (int) (20 + Math.random() * difficulty * 3);
|
||||
}
|
||||
}
|
||||
else {
|
||||
struggling_time--;
|
||||
}
|
||||
if (player.isSneaking()) {
|
||||
if (struggling_time > 0) {
|
||||
strain += (2 + ((double) difficulty / 5));
|
||||
fish_position -= 1;
|
||||
}
|
||||
else {
|
||||
strain += 1;
|
||||
fish_position -= 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fish_position++;
|
||||
strain -= 2;
|
||||
}
|
||||
if (fish_position < modeThreeBar.getSuccess_position() - modeThreeBar.getFish_icon_width() - 1) {
|
||||
cancel();
|
||||
success = true;
|
||||
FishHook fishHook = fishingManager.getBobber(player);
|
||||
if (fishHook != null) {
|
||||
fishingManager.proceedReelIn(fishHook.getLocation(), player, this);
|
||||
fishingManager.removeBobber(player);
|
||||
}
|
||||
fishingManager.removeFishingPlayer(player);
|
||||
return;
|
||||
}
|
||||
if (fish_position + modeThreeBar.getFish_icon_width() > modeThreeBar.getBar_effective_width() || strain > 50) {
|
||||
cancel();
|
||||
FishHook fishHook = fishingManager.getBobber(player);
|
||||
if (fishHook != null) {
|
||||
fishingManager.proceedReelIn(fishHook.getLocation(), player, this);
|
||||
fishingManager.removeBobber(player);
|
||||
}
|
||||
fishingManager.removeFishingPlayer(player);
|
||||
return;
|
||||
}
|
||||
showBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showBar() {
|
||||
String bar = "<font:" + modeThreeBar.getFont() + ">" + modeThreeBar.getBarImage()
|
||||
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars(modeThreeBar.getFish_offset() + fish_position) + "</font>"
|
||||
+ (struggling_time > 0 ? modeThreeBar.getStruggling_fish_image()[timer] : modeThreeBar.getFish_image())
|
||||
+ "<font:" + offsetManager.getFont() + ">" + offsetManager.getOffsetChars(modeThreeBar.getBar_effective_width() - fish_position - modeThreeBar.getFish_icon_width()) + "</font>"
|
||||
+ "</font>";
|
||||
if (strain > 50) strain = 50;
|
||||
if (strain < 0) strain = 0;
|
||||
AdventureUtil.playerTitle(player,
|
||||
title.replace("{strain}", modeThreeBar.getStrain()[(int) ((strain / 50) * modeThreeBar.getStrain().length)])
|
||||
, bar,0,500,0
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
package net.momirealms.customfishing.integration.quest;
|
||||
|
||||
import com.electro2560.dev.cluescrolls.api.ClueDataPair;
|
||||
import com.electro2560.dev.cluescrolls.api.ClueScrollsAPI;
|
||||
import com.electro2560.dev.cluescrolls.api.CustomClue;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
@@ -33,20 +34,20 @@ public class ClueScrollCFQuest implements Listener {
|
||||
|
||||
public ClueScrollCFQuest() {
|
||||
commonClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "fish");
|
||||
fishClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "catch_fish");
|
||||
fishClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "catch_item");
|
||||
mobClue = ClueScrollsAPI.getInstance().registerCustomClue(CustomFishing.getInstance(), "catch_mob");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFish(FishResultEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (event.getResult() == FishResult.FAILURE) return;
|
||||
commonClue.handle(event.getPlayer(), event.isDouble() ? 2 : 1, new ClueDataPair("id", event.getLoot_id()));
|
||||
if (event.getResult() == FishResult.CATCH_SPECIAL_ITEM || event.getResult() == FishResult.CATCH_VANILLA_ITEM) {
|
||||
fishClue.handle(event.getPlayer(), 1);
|
||||
commonClue.handle(event.getPlayer(), 1);
|
||||
fishClue.handle(event.getPlayer(), event.isDouble() ? 2 : 1, new ClueDataPair("id", event.getLoot_id()));
|
||||
}
|
||||
if (event.getResult() == FishResult.CATCH_MOB) {
|
||||
mobClue.handle(event.getPlayer(), 1);
|
||||
commonClue.handle(event.getPlayer(), 1);
|
||||
mobClue.handle(event.getPlayer(), 1, new ClueDataPair("id", event.getLoot_id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.momirealms.customfishing.CustomFishing;
|
||||
import net.momirealms.customfishing.fishing.MiniGameConfig;
|
||||
import net.momirealms.customfishing.fishing.bar.FishingBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeOneBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeThreeBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeTwoBar;
|
||||
import net.momirealms.customfishing.object.Function;
|
||||
import net.momirealms.customfishing.util.AdventureUtil;
|
||||
@@ -77,10 +78,15 @@ public class BarMechanicManager extends Function {
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Bar " + bar + " doesn't exist");
|
||||
}
|
||||
}
|
||||
int[] difficulties = section.getIntegerList("difficulty").stream().mapToInt(Integer::intValue).toArray();
|
||||
if (difficulties.length == 0) {
|
||||
AdventureUtil.consoleMessage("<red>[CustomFishing] Game " + key + " doesn't have difficulties");
|
||||
continue;
|
||||
}
|
||||
MiniGameConfig miniGameConfig = new MiniGameConfig(
|
||||
section.getInt("time", 10),
|
||||
fishingBarList.toArray(new FishingBar[0]),
|
||||
section.getIntegerList("difficulty").stream().mapToInt(Integer::intValue).toArray()
|
||||
difficulties
|
||||
);
|
||||
miniGames.put(key, miniGameConfig);
|
||||
}
|
||||
@@ -111,6 +117,10 @@ public class BarMechanicManager extends Function {
|
||||
ModeTwoBar modeTwoBar = new ModeTwoBar(section);
|
||||
bars.put(key, modeTwoBar);
|
||||
}
|
||||
else if (type == 3) {
|
||||
ModeThreeBar modeThreeBar = new ModeThreeBar(section);
|
||||
bars.put(key, modeThreeBar);
|
||||
}
|
||||
}
|
||||
}
|
||||
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + bars.size() + " <gray>bar(s)");
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.momirealms.customfishing.data.PlayerBagData;
|
||||
import net.momirealms.customfishing.fishing.*;
|
||||
import net.momirealms.customfishing.fishing.bar.FishingBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeOneBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeThreeBar;
|
||||
import net.momirealms.customfishing.fishing.bar.ModeTwoBar;
|
||||
import net.momirealms.customfishing.fishing.competition.Competition;
|
||||
import net.momirealms.customfishing.fishing.competition.CompetitionGoal;
|
||||
@@ -38,6 +39,7 @@ import net.momirealms.customfishing.fishing.loot.Loot;
|
||||
import net.momirealms.customfishing.fishing.loot.Mob;
|
||||
import net.momirealms.customfishing.fishing.mode.FishingGame;
|
||||
import net.momirealms.customfishing.fishing.mode.ModeOneGame;
|
||||
import net.momirealms.customfishing.fishing.mode.ModeThreeGame;
|
||||
import net.momirealms.customfishing.fishing.mode.ModeTwoGame;
|
||||
import net.momirealms.customfishing.fishing.requirements.RequirementInterface;
|
||||
import net.momirealms.customfishing.fishing.totem.ActivatedTotem;
|
||||
@@ -378,14 +380,14 @@ public class FishingManager extends Function {
|
||||
else {
|
||||
vanillaLoot.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop()));
|
||||
}
|
||||
showPlayerBar(player, loot);
|
||||
showFishingBar(player, loot);
|
||||
}
|
||||
// Is vanilla loot
|
||||
else {
|
||||
if (ConfigManager.alwaysFishingBar) {
|
||||
event.setCancelled(true);
|
||||
vanillaLoot.put(player, new VanillaLoot(item.getItemStack(), event.getExpToDrop()));
|
||||
showPlayerBar(player, null);
|
||||
showFishingBar(player, null);
|
||||
}
|
||||
//else vanilla fishing mechanic
|
||||
}
|
||||
@@ -399,7 +401,7 @@ public class FishingManager extends Function {
|
||||
}
|
||||
else {
|
||||
event.setCancelled(true);
|
||||
showPlayerBar(player, loot);
|
||||
showFishingBar(player, loot);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -505,7 +507,7 @@ public class FishingManager extends Function {
|
||||
if (bobberCheckTask != null && bobberCheckTask.isHooked()) {
|
||||
Loot loot = nextLoot.get(player);
|
||||
if (loot == Loot.EMPTY) return;
|
||||
showPlayerBar(player, loot);
|
||||
showFishingBar(player, loot);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@@ -784,7 +786,7 @@ public class FishingManager extends Function {
|
||||
Loot loot = nextLoot.get(player);
|
||||
if (loot != null) {
|
||||
if (loot == Loot.EMPTY) return;
|
||||
showPlayerBar(player, loot);
|
||||
showFishingBar(player, loot);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -922,7 +924,7 @@ public class FishingManager extends Function {
|
||||
AdventureUtil.playerMessage(player, stringBuilder.substring(0, stringBuilder.length() - MessageManager.splitChar.length()));
|
||||
}
|
||||
|
||||
private void showPlayerBar(Player player, @Nullable Loot loot){
|
||||
private void showFishingBar(Player player, @Nullable Loot loot){
|
||||
MiniGameConfig game;
|
||||
if (loot != null && loot.getFishingGames() != null) {
|
||||
game = loot.getFishingGames()[new Random().nextInt(loot.getFishingGames().length)];
|
||||
@@ -948,14 +950,19 @@ public class FishingManager extends Function {
|
||||
FishingBar fishingBar = game.getRandomBar();
|
||||
if (fishingBar instanceof ModeOneBar modeOneBar) {
|
||||
ModeOneGame modeOneGame = new ModeOneGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, difficult, modeOneBar);
|
||||
modeOneGame.runTaskTimer(CustomFishing.getInstance(), 0, 1);
|
||||
modeOneGame.runTaskTimer(plugin, 0, 1);
|
||||
fishingPlayerMap.put(player, modeOneGame);
|
||||
}
|
||||
else if (fishingBar instanceof ModeTwoBar modeTwoBar) {
|
||||
ModeTwoGame modeTwoGame = new ModeTwoGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, difficult, modeTwoBar);
|
||||
modeTwoGame.runTaskTimer(CustomFishing.getInstance(), 0, 1);
|
||||
modeTwoGame.runTaskTimer(plugin, 0, 1);
|
||||
fishingPlayerMap.put(player, modeTwoGame);
|
||||
}
|
||||
else if (fishingBar instanceof ModeThreeBar modeThreeBar) {
|
||||
ModeThreeGame modeThreeGame = new ModeThreeGame(plugin, this, System.currentTimeMillis() + game.getTime() * 1000L, player, difficult, modeThreeBar);
|
||||
modeThreeGame.runTaskTimer(plugin, 0, 1);
|
||||
fishingPlayerMap.put(player, modeThreeGame);
|
||||
}
|
||||
if (vanillaLoot.get(player) == null && loot != null){
|
||||
for (ActionInterface action : loot.getHookActions()) {
|
||||
action.doOn(player, null);
|
||||
|
||||
@@ -93,10 +93,10 @@ public class SellManager extends Function {
|
||||
this.plugin = plugin;
|
||||
this.windowPacketListener = new WindowPacketListener(this);
|
||||
this.inventoryListener = new InventoryListener(this);
|
||||
this.inventoryMap = new HashMap<>();
|
||||
this.joinQuitListener = new JoinQuitListener(this);
|
||||
this.sellDataMap = new HashMap<>();
|
||||
this.triedTimes = new HashMap<>();
|
||||
this.inventoryMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -93,6 +93,9 @@ public class ItemStackUtil {
|
||||
NBTListCompound texture = nbtCompound.addCompound("Properties").getCompoundList("textures").addCompound();
|
||||
texture.setString("Value", item.getHead64());
|
||||
}
|
||||
if (item.getTotem() != null) {
|
||||
nbtItem.setString("Totem", item.getTotem());
|
||||
}
|
||||
if (item.getNbt() != null) NBTUtil.setTags(item.getNbt(), nbtItem);
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user