9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00

初步完成1.1版本内容

This commit is contained in:
Xiao-MoMi
2022-10-17 18:28:38 +08:00
parent 1c74e63d7f
commit eb350a49a8
34 changed files with 1567 additions and 222 deletions

View File

@@ -21,11 +21,8 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.momirealms.customfishing.commands.PluginCommand;
import net.momirealms.customfishing.competition.CompetitionSchedule;
import net.momirealms.customfishing.helper.LibraryLoader;
import net.momirealms.customfishing.manager.FishingManager;
import net.momirealms.customfishing.manager.IntegrationManager;
import net.momirealms.customfishing.manager.MessageManager;
import net.momirealms.customfishing.manager.*;
import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.ConfigUtil;
import org.bstats.bukkit.Metrics;
@@ -40,7 +37,10 @@ public final class CustomFishing extends JavaPlugin {
private IntegrationManager integrationManager;
private FishingManager fishingManager;
private CompetitionSchedule competitionSchedule;
private CompetitionManager competitionManager;
private BonusManager bonusManager;
private LootManager lootManager;
private LayoutManager layoutManager;
// _ooOoo_
// o8888888o
@@ -76,7 +76,10 @@ public final class CustomFishing extends JavaPlugin {
protocolManager = ProtocolLibrary.getProtocolManager();
this.fishingManager = new FishingManager();
this.integrationManager = new IntegrationManager();
this.competitionSchedule = new CompetitionSchedule();
this.competitionManager = new CompetitionManager();
this.bonusManager = new BonusManager();
this.lootManager = new LootManager();
this.layoutManager = new LayoutManager();
ConfigUtil.reload();
PluginCommand pluginCommand = new PluginCommand();
@@ -102,7 +105,19 @@ public final class CustomFishing extends JavaPlugin {
return fishingManager;
}
public CompetitionSchedule getCompetitionSchedule() {
return competitionSchedule;
public CompetitionManager getCompetitionManager() {
return competitionManager;
}
public BonusManager getBonusManager() {
return bonusManager;
}
public LootManager getLootManager() {
return lootManager;
}
public LayoutManager getLayoutManager() {
return layoutManager;
}
}

View File

@@ -1,6 +1,5 @@
package net.momirealms.customfishing.api.event;
import net.momirealms.customfishing.object.Difficulty;
import net.momirealms.customfishing.object.FishResult;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;

View File

@@ -10,7 +10,6 @@ import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class CompetitionCommand extends AbstractSubCommand {
@@ -41,7 +40,7 @@ public class CompetitionCommand extends AbstractSubCommand {
AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.forceEnd);
} else if (args.get(0).equals("cancel")) {
CompetitionSchedule.cancelCompetition();
AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.forceEnd);
AdventureUtil.sendMessage(sender, MessageManager.prefix + MessageManager.forceCancel);
}
return true;
}
@@ -49,7 +48,12 @@ public class CompetitionCommand extends AbstractSubCommand {
@Override
public List<String> onTabComplete(CommandSender sender, List<String> args) {
if (args.size() == 1) {
return List.of("start","end","cancel");
List<String> arrayList = new ArrayList<>();
for (String cmd : List.of("start","end","cancel")) {
if (cmd.startsWith(args.get(0)))
arrayList.add(cmd);
}
return arrayList;
}
if (args.size() == 2 && args.get(0).equals("start")) {
return competitions();

View File

@@ -2,7 +2,6 @@ package net.momirealms.customfishing.commands.subcmd;
import net.momirealms.customfishing.commands.AbstractSubCommand;
import net.momirealms.customfishing.commands.SubCommand;
import net.momirealms.customfishing.manager.BonusManager;
import net.momirealms.customfishing.manager.LootManager;
import net.momirealms.customfishing.manager.MessageManager;
import net.momirealms.customfishing.object.loot.DroppedItem;

View File

@@ -5,7 +5,6 @@ import net.momirealms.customfishing.competition.bossbar.BossBarManager;
import net.momirealms.customfishing.competition.ranking.LocalRankingImpl;
import net.momirealms.customfishing.competition.ranking.RankingInterface;
import net.momirealms.customfishing.competition.ranking.RedisRankingImpl;
import net.momirealms.customfishing.manager.CompetitionManager;
import net.momirealms.customfishing.manager.ConfigManager;
import net.momirealms.customfishing.manager.MessageManager;
import net.momirealms.customfishing.object.action.ActionInterface;
@@ -16,7 +15,6 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.time.Instant;
import java.time.LocalTime;
import java.util.*;
public class Competition {
@@ -30,7 +28,6 @@ public class Competition {
private long startTime;
private long remainingTime;
private float progress;
private BossBarManager bossBarManager;
public Competition(CompetitionConfig competitionConfig) {
@@ -38,6 +35,7 @@ public class Competition {
}
public void begin(boolean forceStart) {
this.goal = competitionConfig.getGoal();
if (this.goal == CompetitionGoal.RANDOM) {
this.goal = getRandomGoal();
}
@@ -64,7 +62,7 @@ public class Competition {
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), startCmd);
}
if (competitionConfig.isEnableBossBar()) {
bossBarManager = new BossBarManager(this);
bossBarManager = new BossBarManager();
bossBarManager.load();
}
}
@@ -224,5 +222,22 @@ public class Competition {
return ranking.getFirstPlayer();
}
public boolean isJoined(Player player) {
return ranking.getCompetitionPlayer(player.getName()) != null;
}
public BossBarManager getBossBarManager() {
return bossBarManager;
}
public void refreshData(Player player, float score, boolean doubleScore) {
if (this.goal == CompetitionGoal.CATCH_AMOUNT) {
score = 1f;
}
if (doubleScore) {
score *= 2;
}
ranking.refreshData(player.getName(), score);
}
}

View File

@@ -23,11 +23,11 @@ public class BossBarConfig {
private final String[] text;
private final int interval;
private final Overlay overlay;
private final BossBarOverlay overlay;
private final BarColor color;
private final int rate;
public BossBarConfig(String[] text, Overlay overlay, BarColor color, int rate, int interval) {
public BossBarConfig(String[] text, BossBarOverlay overlay, BarColor color, int rate, int interval) {
this.text = text;
this.overlay = overlay;
this.color = color;
@@ -43,7 +43,7 @@ public class BossBarConfig {
return interval;
}
public Overlay getOverlay() {
public BossBarOverlay getOverlay() {
return overlay;
}

View File

@@ -1,34 +1,76 @@
package net.momirealms.customfishing.competition.bossbar;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.Function;
import net.momirealms.customfishing.competition.Competition;
import net.momirealms.customfishing.listener.SimpleListener;
import net.momirealms.customfishing.manager.MessageManager;
import net.momirealms.customfishing.util.AdventureUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import java.util.HashMap;
public class BossBarManager extends Function {
private final Competition competition;
public static HashMap<Player, BossBarSender> cache = new HashMap<>();
private final SimpleListener simpleListener;
public BossBarManager(Competition competition) {
this.competition = competition;
public BossBarManager() {
this.simpleListener = new SimpleListener(this);
}
@Override
public void load() {
super.load();
Bukkit.getPluginManager().registerEvents(this.simpleListener, CustomFishing.plugin);
}
@Override
public void unload() {
super.unload();
if (this.simpleListener != null) HandlerList.unregisterAll(this.simpleListener);
for (BossBarSender bossBarSender : cache.values()) {
bossBarSender.hide();
}
cache.clear();
}
@Override
public void onQuit(Player player) {
super.onQuit(player);
BossBarSender sender = cache.get(player);
if (sender != null) {
if (sender.getStatus()) {
sender.hide();
}
cache.remove(player);
}
}
@Override
public void onJoin(Player player) {
super.onJoin(player);
if (Competition.currentCompetition != null){
if (Competition.currentCompetition.isJoined(player) && cache.get(player) == null){
BossBarSender sender = new BossBarSender(player, Competition.currentCompetition.getCompetitionConfig().getBossBarConfig(), this);
if (!sender.getStatus()) {
sender.show();
}
cache.put(player, sender);
} else {
AdventureUtil.playerMessage(player, MessageManager.competitionOn);
}
}
}
public void tryJoin(Player player) {
if (cache.get(player) == null) {
BossBarSender sender = new BossBarSender(player, Competition.currentCompetition.getCompetitionConfig().getBossBarConfig(), this);
if (!sender.getStatus()) {
sender.show();
}
cache.put(player, sender);
for (String joinCmd : Competition.currentCompetition.getCompetitionConfig().getJoinCommand()){
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), joinCmd.replace("{player}", player.getName()));
}
}
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.competition.bossbar;
public enum BossBarOverlay {
NOTCHED_6,
NOTCHED_10,
NOTCHED_12,
NOTCHED_20,
PROGRESS
}

View File

@@ -0,0 +1,155 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.competition.bossbar;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.InternalStructure;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.competition.Competition;
import net.momirealms.customfishing.object.Reflection;
import net.momirealms.customfishing.object.TextCache;
import net.momirealms.customfishing.util.AdventureUtil;
import org.bukkit.boss.BarColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.lang.reflect.InvocationTargetException;
import java.util.UUID;
public class BossBarSender {
private final Player player;
private int timer_1;
private int timer_2;
private int counter;
private final int size;
private final TextCache[] texts;
private TextCache text;
private BukkitTask bukkitTask;
private final UUID uuid;
private boolean force;
private final BossBarConfig config;
private boolean isShown;
private final BossBarManager bossBarManager;
public void setText(int position) {
this.text = texts[position];
this.force = true;
}
public BossBarSender(Player player, BossBarConfig config, BossBarManager bossBarManager){
this.bossBarManager = bossBarManager;
String[] str = config.getText();
this.size = str.length;
texts = new TextCache[str.length];
for (int i = 0; i < str.length; i++) {
texts[i] = new TextCache(player, str[i]);
}
text = texts[0];
this.player = player;
this.uuid = UUID.randomUUID();
this.config = config;
this.isShown = false;
}
public void show() {
this.isShown = true;
try {
CustomFishing.protocolManager.sendServerPacket(player, getPacket());
} catch (InvocationTargetException e){
AdventureUtil.consoleMessage("<red>[CustomFishing] Failed to display bossbar for " + player.getName());
}
this.bukkitTask = new BukkitRunnable() {
@Override
public void run() {
if (size != 1) {
timer_2++;
if (timer_2 > config.getInterval()) {
timer_2 = 0;
counter++;
if (counter == size) {
counter = 0;
}
setText(counter);
}
}
if (timer_1 < config.getRate()){
timer_1++;
}
else {
timer_1 = 0;
if (text.update() || force) {
force = false;
try{
CustomFishing.protocolManager.sendServerPacket(player, getPacket());
}
catch (InvocationTargetException e){
AdventureUtil.consoleMessage("<red>[CustomFishing] Failed to update bossbar for " + player.getName());
}
}
}
}
}.runTaskTimerAsynchronously(CustomFishing.plugin,1,1);
}
private PacketContainer getPacket() {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
packet.getModifier().write(0, uuid);
InternalStructure internalStructure = packet.getStructures().read(1);
internalStructure.getChatComponents().write(0, WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(text.getLatestValue()))));
internalStructure.getFloat().write(0, Competition.currentCompetition.getProgress());
internalStructure.getEnumModifier(BarColor.class, 2).write(0, config.getColor());
internalStructure.getEnumModifier(BossBarOverlay.class, 3).write(0, config.getOverlay());
internalStructure.getModifier().write(4, false);
internalStructure.getModifier().write(5, false);
internalStructure.getModifier().write(6, false);
return packet;
}
public void hide() {
remove();
if (bukkitTask != null) bukkitTask.cancel();
this.isShown = false;
}
private void remove() {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
packet.getModifier().write(0, uuid);
packet.getModifier().write(1, Reflection.removeBar);
try{
CustomFishing.protocolManager.sendServerPacket(player, packet);
}catch (InvocationTargetException e){
AdventureUtil.consoleMessage("<red>[CustomFishing] Failed to remove bossbar for " + player.getName());
}
}
public boolean getStatus() {
return this.isShown;
}
public BossBarConfig getConfig() {
return config;
}
}

View File

@@ -1,6 +1,7 @@
package net.momirealms.customfishing.integration.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customfishing.competition.Competition;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -29,6 +30,27 @@ public class CompetitionPapi extends PlaceholderExpansion {
@Override
public @Nullable String onPlaceholderRequest(Player player, @NotNull String params) {
return super.onPlaceholderRequest(player, params);
if (Competition.currentCompetition == null) return "null";
switch (params) {
case "rank" -> {
return Competition.currentCompetition.getPlayerRank(player);
}
case "time" -> {
return String.valueOf(Competition.currentCompetition.getRemainingTime());
}
case "minute" -> {
return String.format("%02d", Competition.currentCompetition.getRemainingTime() / 60);
}
case "second" -> {
return String.format("%02d", Competition.currentCompetition.getRemainingTime() % 60);
}
case "1st_score" -> {
return String.format("%.1f", Competition.currentCompetition.getFirstScore());
}
case "1st_player" -> {
return Competition.currentCompetition.getFirstPlayer();
}
}
return "null";
}
}

View File

@@ -1,6 +1,7 @@
package net.momirealms.customfishing.manager;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.Function;
import net.momirealms.customfishing.object.Bonus;
import net.momirealms.customfishing.object.Item;
import net.momirealms.customfishing.object.LeveledEnchantment;
@@ -16,7 +17,7 @@ import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.*;
public class BonusManager {
public class BonusManager extends Function {
public static HashMap<String, ItemStack> BAITITEMS;
public static HashMap<String, Bonus> BAIT;
@@ -26,7 +27,8 @@ public class BonusManager {
public static HashMap<String, ItemStack> UTILITEMS;
public static void load() {
@Override
public void load() {
BAIT = new HashMap<>();
BAITITEMS = new HashMap<>();
ROD = new HashMap<>();
@@ -38,7 +40,16 @@ public class BonusManager {
loadUtil();
}
private static void loadUtil() {
@Override
public void unload() {
if (BAIT != null) BAIT.clear();
if (BAITITEMS != null) BAITITEMS.clear();
if (ROD != null) ROD.clear();
if (RODITEMS != null) RODITEMS.clear();
if (ENCHANTS != null) ENCHANTS.clear();
}
private void loadUtil() {
UTILITEMS = new HashMap<>();
File util_file = new File(CustomFishing.plugin.getDataFolder() + File.separator + "utils");
if (!util_file.exists()) {
@@ -60,7 +71,7 @@ public class BonusManager {
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + UTILITEMS.size() + " <gray>utils");
}
private static void loadEnchant() {
private void loadEnchant() {
ENCHANTS = new HashMap<>();
YamlConfiguration config = ConfigUtil.getConfig("enchant-bonus.yml");
Set<String> keys = config.getKeys(false);
@@ -95,7 +106,7 @@ public class BonusManager {
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + ENCHANTS.size() + " <gray>enchantments");
}
private static void loadBait() {
private void loadBait() {
BAITITEMS = new HashMap<>();
BAIT = new HashMap<>();
File bait_file = new File(CustomFishing.plugin.getDataFolder() + File.separator + "baits");
@@ -120,7 +131,7 @@ public class BonusManager {
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + BAITITEMS.size() + " <gray>baits");
}
private static Bonus getBonus(YamlConfiguration config, String key) {
private Bonus getBonus(YamlConfiguration config, String key) {
Bonus bonus = new Bonus();
config.getConfigurationSection(key + ".modifier").getKeys(false).forEach(modifier -> {
switch (modifier) {
@@ -147,7 +158,7 @@ public class BonusManager {
return bonus;
}
private static void loadRod() {
private void loadRod() {
ROD = new HashMap<>();
RODITEMS = new HashMap<>();
File rod_file = new File(CustomFishing.plugin.getDataFolder() + File.separator + "rods");

View File

@@ -3,15 +3,15 @@ package net.momirealms.customfishing.manager;
import net.momirealms.customfishing.Function;
import net.momirealms.customfishing.competition.CompetitionConfig;
import net.momirealms.customfishing.competition.CompetitionGoal;
import net.momirealms.customfishing.competition.CompetitionSchedule;
import net.momirealms.customfishing.competition.bossbar.BossBarConfig;
import net.momirealms.customfishing.competition.bossbar.Overlay;
import net.momirealms.customfishing.competition.bossbar.BossBarOverlay;
import net.momirealms.customfishing.object.action.ActionInterface;
import net.momirealms.customfishing.object.action.CommandActionImpl;
import net.momirealms.customfishing.object.action.MessageActionImpl;
import net.momirealms.customfishing.util.ConfigUtil;
import org.bukkit.boss.BarColor;
import org.bukkit.configuration.file.YamlConfiguration;
import org.checkerframework.checker.units.qual.C;
import java.util.*;
@@ -19,31 +19,37 @@ public class CompetitionManager extends Function {
public static HashMap<String, CompetitionConfig> competitionsT;
public static HashMap<String, CompetitionConfig> competitionsC;
private CompetitionSchedule competitionSchedule;
@Override
public void load() {
competitionsC = new HashMap<>();
competitionsT = new HashMap<>();
if (ConfigManager.enableCompetition) loadCompetitions();
if (ConfigManager.enableCompetition) {
competitionsC = new HashMap<>();
competitionsT = new HashMap<>();
loadCompetitions();
this.competitionSchedule = new CompetitionSchedule();
this.competitionSchedule.load();
}
}
@Override
public void unload() {
if (competitionsC != null) competitionsC.clear();
if (competitionsT != null) competitionsT.clear();
if (competitionSchedule != null) competitionSchedule.unload();
}
public void loadCompetitions(){
public void loadCompetitions() {
YamlConfiguration config = ConfigUtil.getConfig("competition.yml");
Set<String> keys = config.getKeys(false);
keys.forEach(key -> {
boolean enableBsb = config.getBoolean(key + ".bossbar.enable", false);
BossBarConfig bossBarConfig = new BossBarConfig(
config.getStringList(key + ".bossbar.text").toArray(new String[0]),
Overlay.valueOf(config.getString(key + ".bossbar.overlay","SOLID").toUpperCase()),
BossBarOverlay.valueOf(config.getString(key + ".bossbar.overlay","SOLID").toUpperCase()),
BarColor.valueOf(config.getString(key + ".bossbar.color","WHITE").toUpperCase()),
config.getInt(key + ".bossbar.refresh-rate",10),
config.getInt(key + ".bossbar.switch-interval", 15)
config.getInt(key + ".bossbar.switch-interval", 200)
);
HashMap<String, ActionInterface[]> rewardsMap = new HashMap<>();

View File

@@ -1,7 +1,5 @@
package net.momirealms.customfishing.manager;
import com.gamingmesh.jobs.CMILib.ConfigReader;
import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.ConfigUtil;
import net.momirealms.customfishing.util.JedisUtil;
import org.bukkit.Bukkit;

View File

@@ -13,6 +13,7 @@ import net.momirealms.customfishing.api.event.FishFinderEvent;
import net.momirealms.customfishing.api.event.FishHookEvent;
import net.momirealms.customfishing.api.event.FishResultEvent;
import net.momirealms.customfishing.api.event.RodCastEvent;
import net.momirealms.customfishing.competition.Competition;
import net.momirealms.customfishing.integration.MobInterface;
import net.momirealms.customfishing.integration.item.McMMOTreasure;
import net.momirealms.customfishing.listener.*;
@@ -326,7 +327,7 @@ public class FishingManager extends Function {
return;
}
if (loot instanceof Mob mob) {
summonMob(player, loot, location, mob);
summonMob(player, loot, location, mob, fishingPlayer.getScoreMultiplier());
return;
}
if (loot instanceof DroppedItem droppedItem){
@@ -335,7 +336,7 @@ public class FishingManager extends Function {
return;
}
}
dropCustomFishingLoot(player, location, droppedItem, fishingPlayer.isDouble());
dropCustomFishingLoot(player, location, droppedItem, fishingPlayer.isDouble(), fishingPlayer.getScoreMultiplier());
}
}
else {
@@ -350,7 +351,7 @@ public class FishingManager extends Function {
proceedReelIn(event, player, fishingPlayer);
}
private void dropCustomFishingLoot(Player player, Location location, DroppedItem droppedItem, boolean isDouble) {
private void dropCustomFishingLoot(Player player, Location location, DroppedItem droppedItem, boolean isDouble, double scoreMultiplier) {
ItemStack drop = getCustomFishingLootItemStack(droppedItem, player);
FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_LOOT, isDouble, drop);
Bukkit.getPluginManager().callEvent(fishResultEvent);
@@ -358,6 +359,12 @@ public class FishingManager extends Function {
return;
}
if (Competition.currentCompetition != null){
float score = (float) (droppedItem.getScore() * scoreMultiplier);
Competition.currentCompetition.refreshData(player, score, isDouble);
Competition.currentCompetition.getBossBarManager().tryJoin(player);
}
dropItem(player, location, fishResultEvent.isDouble(), drop);
for (ActionInterface action : droppedItem.getSuccessActions())
action.doOn(player);
@@ -389,6 +396,11 @@ public class FishingManager extends Function {
return true;
}
if (Competition.currentCompetition != null){
Competition.currentCompetition.refreshData(player, 0, isDouble);
Competition.currentCompetition.getBossBarManager().tryJoin(player);
}
player.giveExp(new Random().nextInt(24), true);
dropItem(player, location, fishResultEvent.isDouble(), itemStack);
sendSuccessTitle(player, itemStack);
@@ -425,13 +437,18 @@ public class FishingManager extends Function {
return;
}
if (Competition.currentCompetition != null){
Competition.currentCompetition.refreshData(player, 0, isDouble);
Competition.currentCompetition.getBossBarManager().tryJoin(player);
}
player.giveExp(vanillaLoot.getXp(), true);
AdventureUtil.playerSound(player, Sound.Source.PLAYER, Key.key("minecraft:entity.experience_orb.pickup"), 1, 1);
dropItem(player, location, isDouble, itemStack);
sendSuccessTitle(player, itemStack);
}
private void summonMob(Player player, Loot loot, Location location, Mob mob) {
private void summonMob(Player player, Loot loot, Location location, Mob mob, double scoreMultiplier) {
MobInterface mobInterface = CustomFishing.plugin.getIntegrationManager().getMobInterface();
if (mobInterface == null) return;
@@ -440,6 +457,12 @@ public class FishingManager extends Function {
return;
}
if (Competition.currentCompetition != null){
float score = (float) (loot.getScore() * scoreMultiplier);
Competition.currentCompetition.refreshData(player, score, false);
Competition.currentCompetition.getBossBarManager().tryJoin(player);
}
mobInterface.summon(player.getLocation(), location, mob);
for (ActionInterface action : loot.getSuccessActions())
action.doOn(player);
@@ -672,7 +695,7 @@ public class FishingManager extends Function {
}
else {
//Not null
layout = LayoutManager.LAYOUTS.values().stream().findAny().get();
layout = (Layout) LayoutManager.LAYOUTS.values().stream().toArray()[new Random().nextInt(LayoutManager.LAYOUTS.values().size())];
}
int speed;
@@ -690,10 +713,12 @@ public class FishingManager extends Function {
}
Bonus bonus = nextBonus.get(player);
boolean isDouble =false;
boolean isDouble = false;
double scoreMultiplier = 0;
if (bonus != null) {
speed += bonus.getDifficulty();
isDouble = Math.random() < bonus.getDoubleLoot();
scoreMultiplier = bonus.getScore() + 1;
}
if (speed < 1){
@@ -708,7 +733,7 @@ public class FishingManager extends Function {
return;
}
FishingPlayer fishingPlayer = new FishingPlayer(System.currentTimeMillis() + time, player, layout, difficult, this, isDouble);
FishingPlayer fishingPlayer = new FishingPlayer(System.currentTimeMillis() + time, player, layout, difficult, this, isDouble, scoreMultiplier);
fishingPlayer.runTaskTimerAsynchronously(CustomFishing.plugin, 0, 1);
fishingPlayerCache.put(player, fishingPlayer);

View File

@@ -1,6 +1,8 @@
package net.momirealms.customfishing.manager;
import net.momirealms.customfishing.Function;
import net.momirealms.customfishing.object.Layout;
import net.momirealms.customfishing.util.AdventureUtil;
import net.momirealms.customfishing.util.ConfigUtil;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -8,11 +10,12 @@ import java.util.HashMap;
import java.util.Objects;
import java.util.Set;
public class LayoutManager {
public class LayoutManager extends Function {
public static HashMap<String, Layout> LAYOUTS;
public static void load() {
@Override
public void load() {
LAYOUTS = new HashMap<>();
YamlConfiguration config = ConfigUtil.getConfig("bars.yml");
Set<String> keys = config.getKeys(false);
@@ -37,5 +40,11 @@ public class LayoutManager {
);
LAYOUTS.put(key, layout);
}
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + LAYOUTS.size() + " <gray>bars");
}
@Override
public void unload() {
if (LAYOUTS != null) LAYOUTS.clear();
}
}

View File

@@ -1,6 +1,7 @@
package net.momirealms.customfishing.manager;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.Function;
import net.momirealms.customfishing.object.*;
import net.momirealms.customfishing.object.action.*;
import net.momirealms.customfishing.object.loot.DroppedItem;
@@ -20,26 +21,25 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
public class LootManager {
public class LootManager extends Function {
public static HashMap<String, Loot> WATERLOOTS;
public static HashMap<String, Loot> LAVALOOTS;
public static HashMap<String, ItemStack> LOOTITEMS;
@Nullable
public static Loot getLoot(String key) {
return WATERLOOTS.get(key);
}
@Nullable
public static ItemStack build(String key) {
ItemStack itemStack = LOOTITEMS.get(key);
return itemStack == null ? null : itemStack.clone();
}
public static void load() {
@Override
public void load() {
WATERLOOTS = new HashMap<>();
LAVALOOTS = new HashMap<>();
LOOTITEMS = new HashMap<>();
@@ -48,7 +48,14 @@ public class LootManager {
AdventureUtil.consoleMessage("[CustomFishing] Loaded <green>" + (LAVALOOTS.size() + WATERLOOTS.size()) + " <gray>loots");
}
private static void loadMobs() {
@Override
public void unload() {
if (WATERLOOTS != null) WATERLOOTS.clear();
if (LAVALOOTS != null) LAVALOOTS.clear();
if (LOOTITEMS != null) LOOTITEMS.clear();
}
private void loadMobs() {
if (Bukkit.getPluginManager().getPlugin("MythicMobs") == null) return;
File mob_file = new File(CustomFishing.plugin.getDataFolder() + File.separator + "mobs");
if (!mob_file.exists()) {
@@ -79,14 +86,18 @@ public class LootManager {
config.getDouble(key + ".vector.vertical",1.3)
));
if (config.contains(key + ".nick")) loot.setNick(config.getString(key + ".nick"));
else loot.setNick(ChatColor.stripColor(config.getString(key + ".mythicmobsID", key)));
else loot.setNick(ChatColor.stripColor(config.getString(key + ".mobID", key)));
setActionsAndRequirements(config, loot, key);
WATERLOOTS.put(key, loot);
if (config.getBoolean(key + ".in-lava", false)) {
LAVALOOTS.put(key, loot);
} else {
WATERLOOTS.put(key, loot);
}
}
}
}
private static void loadItems() {
private void loadItems() {
File loot_file = new File(CustomFishing.plugin.getDataFolder() + File.separator + "loots");
if (!loot_file.exists()) {
if (!loot_file.mkdir()) return;
@@ -134,8 +145,6 @@ public class LootManager {
} else {
WATERLOOTS.put(key, loot);
}
// Construct ItemStack
if (material.contains(":")) {
continue;
@@ -148,7 +157,7 @@ public class LootManager {
}
}
private static void setActionsAndRequirements(YamlConfiguration config, Loot loot, String key) {
private void setActionsAndRequirements(YamlConfiguration config, Loot loot, String key) {
if (config.contains(key + ".layout")) {
List<Layout> layoutList = new ArrayList<>();

View File

@@ -76,9 +76,9 @@ public class Bonus {
this.weightMD.put(group, Optional.ofNullable(this.weightMD.get(group)).orElse(1d) + en.getValue());
}
}
if (anotherBonus.getTime() != 0) this.time *= anotherBonus.getTime();
if (anotherBonus.getTime() != 0) this.time += (anotherBonus.getTime() - 1);
if (anotherBonus.getDoubleLoot() != 0) this.doubleLoot += anotherBonus.getDoubleLoot();
if (anotherBonus.getDifficulty() != 0) this.difficulty += anotherBonus.getDifficulty();
if (anotherBonus.getScore() != 0) this.score *= anotherBonus.getScore();
if (anotherBonus.getScore() != 0) this.score += (anotherBonus.getScore() - 1);
}
}

View File

@@ -31,8 +31,9 @@ public class FishingPlayer extends BukkitRunnable {
private final double[] successRate;
private final int range;
private final boolean isDouble;
private final double scoreMultiplier;
public FishingPlayer(long deadline, Player player, Layout layout, Difficulty difficulty, FishingManager fishingManager, boolean isDouble) {
public FishingPlayer(long deadline, Player player, Layout layout, Difficulty difficulty, FishingManager fishingManager, boolean isDouble, double scoreMultiplier) {
this.deadline = deadline;
this.player = player;
this.difficulty = difficulty;
@@ -48,6 +49,7 @@ public class FishingPlayer extends BukkitRunnable {
this.range = layout.getRange();
this.successRate = layout.getSuccessRate();
this.isDouble = isDouble;
this.scoreMultiplier = scoreMultiplier;
}
@Override
@@ -60,23 +62,18 @@ public class FishingPlayer extends BukkitRunnable {
return;
}
int timer = difficulty.timer() - 1;
int speed = difficulty.speed();
if (progress <= speed - 1) {
face = true;
} else if (progress >= size - speed + 1) {
face = false;
}
if (internalTimer < timer) {
if (internalTimer < difficulty.timer() - 1) {
internalTimer++;
return;
} else {
if (face) {
internalTimer -= timer;
progress += speed;
} else {
internalTimer -= timer;
progress -= speed;
progress = getNextProgress(progress, face);
if (progress > size) {
face = !face;
progress = 2 * size - progress;
}
else if (progress < 0) {
face = !face;
progress = -progress;
}
}
StringBuilder stringBuilder = new StringBuilder(start + bar + pointerOffset);
@@ -98,6 +95,15 @@ public class FishingPlayer extends BukkitRunnable {
}
}
private int getNextProgress(int i, boolean face) {
if (face) {
return i + difficulty.speed();
}
else {
return i - difficulty.speed();
}
}
public boolean isSuccess() {
int last = progress / range;
return (Math.random() < successRate[last]);
@@ -106,4 +112,8 @@ public class FishingPlayer extends BukkitRunnable {
public boolean isDouble() {
return isDouble;
}
public double getScoreMultiplier() {
return scoreMultiplier;
}
}

View File

@@ -18,6 +18,7 @@
package net.momirealms.customfishing.object;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.competition.Competition;
import net.momirealms.customfishing.integration.papi.PlaceholderManager;
import org.bukkit.entity.Player;
@@ -70,20 +71,29 @@ public class TextCache {
//返回更新结果是否不一致
public boolean update() {
if (ownerPlaceholders.length == 0) return false;
PlaceholderManager placeholderManager = CustomFishing.plugin.getIntegrationManager().getPlaceholderManager();
if (placeholderManager == null) return false;
String string;
if ("%s".equals(originalValue)) {
string = placeholderManager.parse(owner, ownerPlaceholders[0]);
}
else {
Object[] values = new String[ownerPlaceholders.length];
for (int i = 0; i < ownerPlaceholders.length; i++) {
values[i] = placeholderManager.parse(owner, ownerPlaceholders[i]);
String string = originalValue;
if (ownerPlaceholders.length != 0) {
PlaceholderManager placeholderManager = CustomFishing.plugin.getIntegrationManager().getPlaceholderManager();
if (placeholderManager != null) {
if ("%s".equals(originalValue)) {
string = placeholderManager.parse(owner, ownerPlaceholders[0]);
}
else {
Object[] values = new String[ownerPlaceholders.length];
for (int i = 0; i < ownerPlaceholders.length; i++) {
values[i] = placeholderManager.parse(owner, ownerPlaceholders[i]);
}
string = String.format(originalValue, values);
}
}
string = String.format(originalValue, values);
}
string = string.replace("{rank}", Competition.currentCompetition.getPlayerRank(owner))
.replace("{time}", String.valueOf(Competition.currentCompetition.getRemainingTime()))
.replace("{minute}", String.format("%02d", Competition.currentCompetition.getRemainingTime() / 60))
.replace("{second}",String.format("%02d", Competition.currentCompetition.getRemainingTime() % 60))
.replace("{score}", String.format("%.1f", Competition.currentCompetition.getScore(owner)))
.replace("{1st_score}", String.format("%.1f", Competition.currentCompetition.getFirstScore()))
.replace("{1st_player}", Competition.currentCompetition.getFirstPlayer());
if (!latestValue.equals(string)) {
latestValue = string;
return true;

View File

@@ -18,7 +18,6 @@
package net.momirealms.customfishing.object.requirements;
import net.momirealms.customfishing.object.FishingCondition;
import net.momirealms.customfishing.object.requirements.RequirementInterface;
import org.apache.commons.lang.StringUtils;
import java.util.List;

View File

@@ -18,7 +18,6 @@
package net.momirealms.customfishing.object.requirements;
import net.momirealms.customfishing.object.FishingCondition;
import net.momirealms.customfishing.object.requirements.RequirementInterface;
import org.apache.commons.lang.StringUtils;
import java.util.List;

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.object.totem;
public class CorePos {
private final int x;
private final int y;
private final int z;
public CorePos(int x, int z, int y) {
this.x = x;
this.z = z;
this.y = y;
}
public int getX() {
return this.x;
}
public int getY() {
return this.y;
}
public int getZ() {
return this.z;
}
}

View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.object.totem;
public class FinalModel {
private final int length;
private final int width;
private final int height;
private final String[][][] model;
private CorePos corePos;
public FinalModel(int length, int width, int height) {
this.length = length;
this.width = width;
this.height = height;
this.model = new String[length][width][height];
}
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder("FinalModel:");
for (int i = 0; i < height; i++) {
stringBuilder.append("\nlayer: "+ (i+1));
for (int j = 0; j < width; j++) {
stringBuilder.append("\n");
for (int k = 0; k < height; k++) {
stringBuilder.append(model[k][j][i]).append("\t");
}
}
}
return stringBuilder.toString();
}
public CorePos getCorePos() {
return corePos;
}
public void setCorePos(CorePos corePos) {
this.corePos = corePos;
}
public int getLength() {
return length;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void setElement(String element, int length, int width, int height) {
this.model[length][width][height] = element;
}
public String getElement(int length, int width, int height) {
return this.model[length][width][height];
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.object.totem;
import java.util.Arrays;
public class OriginalModel {
private final int length;
private final int width;
private final int height;
private final String[][][][] model;
private CorePos corePos;
public OriginalModel(int length, int width, int height) {
this.length = length;
this.width = width;
this.height = height;
this.model = new String[length][width][height][];
}
@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder("TotemModel:");
for (int i = 0; i < height; i++) {
stringBuilder.append("\nlayer: "+ (i+1));
for (int j = 0; j < width; j++) {
stringBuilder.append("\n");
for (int k = 0; k < height; k++) {
stringBuilder.append(Arrays.toString(model[k][j][i])).append("\t");
}
}
}
return stringBuilder.toString();
}
public CorePos getCorePos() {
return corePos;
}
public void setCorePos(CorePos corePos) {
this.corePos = corePos;
}
public int getLength() {
return length;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void setElement(String[] element, int length, int width, int height) {
this.model[length][width][height] = element;
}
public String[] getElement(int length, int width, int height) {
return this.model[length][width][height];
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customfishing.object.totem;
import java.util.List;
public class Totem {
private final OriginalModel originalModel;
private FinalModel finalModel;
private List<String> commands;
private List<String> messages;
private final boolean cItem;
private final boolean rItem;
public Totem(OriginalModel originalModel, boolean rItem, boolean cItem) {
this.originalModel = originalModel;
this.rItem = rItem;
if (rItem) this.cItem = cItem;
else this.cItem = false;
}
public OriginalModel getOriginalModel() {
return originalModel;
}
public List<String> getMessages() {
return messages;
}
public void setMessages(List<String> messages) {
this.messages = messages;
}
public FinalModel getFinalModel() {
return finalModel;
}
public void setFinalModel(FinalModel finalModel) {
this.finalModel = finalModel;
}
public void setCommands(List<String> commands) {
this.commands = commands;
}
public boolean isrItem() {
return rItem;
}
public List<String> getCommands() {
return commands;
}
public boolean iscItem() {
return cItem;
}
}

View File

@@ -7,6 +7,8 @@ public class ArmorStandUtil {
public static int entityID = 654321234;
public static void showNotice(Player player) {
entityID++;
}

View File

@@ -8,7 +8,9 @@ import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.helper.Log;
import net.momirealms.customfishing.manager.*;
import net.momirealms.customfishing.manager.ConfigManager;
import net.momirealms.customfishing.manager.MessageManager;
import net.momirealms.customfishing.object.Reflection;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
@@ -24,14 +26,23 @@ public class ConfigUtil {
public static void reload() {
ConfigManager.load();
LayoutManager.load();
MessageManager.load();
LootManager.load();
BonusManager.load();
CustomFishing.plugin.getLayoutManager().unload();
CustomFishing.plugin.getLayoutManager().load();
CustomFishing.plugin.getLootManager().unload();
CustomFishing.plugin.getLootManager().load();
CustomFishing.plugin.getBonusManager().unload();
CustomFishing.plugin.getBonusManager().load();
CustomFishing.plugin.getFishingManager().unload();
CustomFishing.plugin.getFishingManager().load();
CustomFishing.plugin.getCompetitionSchedule().unload();
CustomFishing.plugin.getCompetitionSchedule().load();
CustomFishing.plugin.getCompetitionManager().unload();
CustomFishing.plugin.getCompetitionManager().load();
try {
Reflection.load();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void update(String fileName){

View File

@@ -4,7 +4,6 @@ import de.tr7zw.changeme.nbtapi.NBTCompound;
import de.tr7zw.changeme.nbtapi.NBTItem;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.momirealms.customfishing.CustomFishing;
import net.momirealms.customfishing.manager.BonusManager;
import net.momirealms.customfishing.manager.LootManager;
@@ -192,7 +191,8 @@ public class ItemStackUtil {
try {
yamlConfiguration.save(file);
LootManager.load();
CustomFishing.plugin.getLootManager().unload();
CustomFishing.plugin.getLootManager().load();
} catch (IOException e) {
e.printStackTrace();
}

View File

@@ -0,0 +1,348 @@
///*
// * Copyright (C) <2022> <XiaoMoMi>
// *
// * This program is free software: you can redistribute it and/or modify
// * it under the terms of the GNU General Public License as published by
// * the Free Software Foundation, either version 3 of the License, or
// * any later version.
// *
// * This program is distributed in the hope that it will be useful,
// * but WITHOUT ANY WARRANTY; without even the implied warranty of
// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// * GNU General Public License for more details.
// *
// * You should have received a copy of the GNU General Public License
// * along with this program. If not, see <https://www.gnu.org/licenses/>.
// */
//
//package net.momirealms.customfishing.util;
//
//import net.momirealms.customfishing.object.totem.CorePos;
//import net.momirealms.customfishing.object.totem.FinalModel;
//import net.momirealms.customfishing.object.totem.OriginalModel;
//import org.bukkit.Location;
//
//public class TotemUtil {
//
// public static int checkLocationModel(OriginalModel model, Location location){
//
// CorePos corePos = model.getCorePos();
// int xOffset = corePos.getX();
// int yOffset = corePos.getY();
// int zOffset = corePos.getZ();
//
// int height = model.getHeight();
// int length = model.getLength();
// int width = model.getWidth();
//
// //从第一层开始逐层扫描,只有一层满足要求才能扫描上一层,否则跳入下一个方向检测
// Location startLoc = location.clone().subtract(0, yOffset, 0);
//
// Label_1:
// {
// for(int i = 0; i< height; i++) {
// //起点定于左下角,向右上遍历
// Location loc = startLoc.clone().add(-xOffset, i, -zOffset);
// for (int z = 0; z < width; z++) {
// inner: for (int x = 0; x < length; x++) {
// String[] elements = model.getElement(x, z, i);
// String id = BlockUtil.getId(loc.clone().add(x, 0, z));
// for (String element : elements) {
// if (element.equals("*")) continue inner;
// if (id == null) break;
// if (id.equals(element)) continue inner;
// }
// break Label_1;
// }
// }
// }
// return 1;
// }
//
// Label_2:
// {
// for (int i = 0; i < height; i++) {
// //起点定于右上角,向左下遍历
// Location loc = startLoc.clone().add(xOffset, i, zOffset);
// for (int z = 0; z < width; z++) {
// inner: for (int x = 0; x < length; x++) {
// String[] elements = model.getElement(x, z, i);
// String id = BlockUtil.getId(loc.clone().add(-x, 0, -z));
// for (String element : elements) {
// if (element.equals("*")) continue inner;
// if (id == null) break;
// if (id.equals(element)) continue inner;
// }
// break Label_2;
// }
// }
// }
// return 2;
// }
//
// Label_3:
// {
// for (int i = 0; i < height; i++) {
// //起点定于左上角,向右下遍历
// Location loc = startLoc.clone().add(-zOffset, i, xOffset);
// for (int z = 0; z < width; z++) {
// inner: for (int x = 0; x < length; x++) {
// String[] elements = model.getElement(x, z, i);
// String id = BlockUtil.getId(loc.clone().add(z, 0, -x));
// for (String element : elements) {
// if (element.equals("*")) continue inner;
// if (id == null) break;
// if (id.equals(element)) continue inner;
// }
// break Label_3;
// }
// }
// }
// return 3;
// }
//
// Label_4:
// {
// for (int i = 0; i < height; i++) {
// //起点定于右下角,向左上遍历
// Location loc = startLoc.clone().add(zOffset, i, -xOffset);
// for (int z = 0; z < width; z++) {
// inner: for (int x = 0; x < length; x++) {
// String[] elements = model.getElement(x, z, i);
// String id = BlockUtil.getId(loc.clone().add(-z, 0, x));
// for (String element : elements) {
// if (element.equals("*")) continue inner;
// if (id == null) break;
// if (id.equals(element)) continue inner;
// }
// break Label_4;
// }
// }
// }
// return 4;
// }
//
// Label_5:
// {
// for (int i = 0; i < height; i++) {
// //起点定于左下角(镜像),向上左遍历
// Location loc = startLoc.clone().add(-zOffset, i, -xOffset);
// for (int z = 0; z < width; z++) {
// inner: for (int x = 0; x < length; x++) {
// String[] elements = model.getElement(x, z, i);
// String id = BlockUtil.getId(loc.clone().add(z, 0, x));
// for (String element : elements) {
// if (element.equals("*")) continue inner;
// if (id == null) break;
// if (id.equals(element)) continue inner;
// }
// break Label_5;
// }
// }
// }
// return 5;
// }
//
// Label_6:
// {
// for (int i = 0; i < height; i++) {
// //起点定于右上角(镜像),向下左遍历
// Location loc = startLoc.clone().add(zOffset, i, xOffset);
// for (int z = 0; z < width; z++) {
// inner: for (int x = 0; x < length; x++) {
// String[] elements = model.getElement(x, z, i);
// String id = BlockUtil.getId(loc.clone().add(-z, 0, -x));
// for (String element : elements) {
// if (element.equals("*")) continue inner;
// if (id == null) break;
// if (id.equals(element)) continue inner;
// }
// break Label_6;
// }
// }
// }
// return 6;
// }
//
// Label_7:
// {
// for (int i = 0; i < height; i++) {
// //起点定于左上角(镜像),向右下遍历
// Location loc = startLoc.clone().add(-xOffset, i, zOffset);
// for (int z = 0; z < width; z++) {
// inner: for (int x = 0; x < length; x++) {
// String[] elements = model.getElement(x, z, i);
// String id = BlockUtil.getId(loc.clone().add(x, 0, -z));
// for (String element : elements) {
// if (element.equals("*")) continue inner;
// if (id == null) break;
// if (id.equals(element)) continue inner;
// }
// break Label_7;
// }
// }
// }
// return 7;
// }
// Label_8:
// {
// for (int i = 0; i < height; i++) {
// //起点定于右下角(镜像),向左上遍历
// Location loc = startLoc.clone().add(xOffset, i, -zOffset);
// for (int z = 0; z < width; z++) {
// inner: for (int x = 0; x < length; x++) {
// String[] elements = model.getElement(x, z, i);
// String id = BlockUtil.getId(loc.clone().add(-x, 0, z));
// for (String element : elements) {
// if (element.equals("*")) continue inner;
// if (id == null) break;
// if (id.equals(element)) continue inner;
// }
// break Label_8;
// }
// }
// }
// return 8;
// }
// return 0;
// }
//
//
// public static void removeModel(FinalModel model, Location location, int id) {
//
// CorePos corePos = model.getCorePos();
// int xOffset = corePos.getX();
// int yOffset = corePos.getY();
// int zOffset = corePos.getZ();
//
// int height = model.getHeight();
// int length = model.getLength();
// int width = model.getWidth();
//
// //从第一层开始逐层扫描,只有一层满足要求才能扫描上一层,否则跳入下一个方向检测
// Location startLoc = location.clone().subtract(0, yOffset, 0);
//
// switch (id) {
// case 1:
// for (int i = 0; i < height; i++) {
// //起点定于左下角,向右上遍历
// Location loc = startLoc.clone().add(-xOffset, i, -zOffset);
// for (int z = 0; z < width; z++)
// for (int x = 0; x < length; x++) {
// if (model.getElement(x, z, i) == null) {
// BlockUtil.remove(loc.clone().add(x, 0, z));
// }
// else if (!model.getElement(x, z, i).equals("*")){
// BlockUtil.replace(loc.clone().add(x, 0, z), model.getElement(x, z, i));
// }
// }
// }
// break;
// case 2:
// for (int i = 0; i < height; i++) {
// //起点定于右上角,向左下遍历
// Location loc = startLoc.clone().add(xOffset, i, zOffset);
// for (int z = 0; z < width; z++)
// for (int x = 0; x < length; x++) {
// if (model.getElement(x, z, i) == null) {
// BlockUtil.remove(loc.clone().add(-x, 0, -z));
// }
// else if (!model.getElement(x, z, i).equals("*")){
// BlockUtil.replace(loc.clone().add(-x, 0, -z), model.getElement(x, z, i));
// }
// }
// }
// break;
// case 3:
// for (int i = 0; i < height; i++) {
// //起点定于左上角,向右下遍历
// Location loc = startLoc.clone().add(-zOffset, i, xOffset);
// for (int z = 0; z < width; z++)
// for (int x = 0; x < length; x++) {
// if (model.getElement(x, z, i) == null) {
// BlockUtil.remove(loc.clone().add(z, 0, -x));
// }
// else if (!model.getElement(x, z, i).equals("*")){
// BlockUtil.replace(loc.clone().add(z, 0, -x), model.getElement(x, z, i));
// }
// }
// }
// break;
// case 4:
// for (int i = 0; i < height; i++) {
// //起点定于右下角,向左上遍历
// Location loc = startLoc.clone().add(zOffset, i, -xOffset);
// for (int z = 0; z < width; z++)
// for (int x = 0; x < length; x++) {
// if (model.getElement(x, z, i) == null) {
// BlockUtil.remove(loc.clone().add(-z, 0, x));
// }
// else if (!model.getElement(x, z, i).equals("*")){
// BlockUtil.replace(loc.clone().add(-z, 0, x), model.getElement(x, z, i));
// }
// }
// }
// break;
// case 5:
// for (int i = 0; i < height; i++) {
// //起点定于左下角(镜像),向上左遍历
// Location loc = startLoc.clone().add(-zOffset, i, -xOffset);
// for (int z = 0; z < width; z++)
// for (int x = 0; x < length; x++) {
// if (model.getElement(x, z, i) == null) {
// BlockUtil.remove(loc.clone().add(z, 0, x));
// }
// else if (!model.getElement(x, z, i).equals("*")){
// BlockUtil.replace(loc.clone().add(z, 0, x), model.getElement(x, z, i));
// }
// }
// }
// break;
// case 6:
// for (int i = 0; i < height; i++) {
// //起点定于右上角(镜像),向下左遍历
// Location loc = startLoc.clone().add(zOffset, i, xOffset);
// for (int z = 0; z < width; z++)
// for (int x = 0; x < length; x++) {
// if (model.getElement(x, z, i) == null) {
// BlockUtil.remove(loc.clone().add(-z, 0, -x));
// }
// else if (!model.getElement(x, z, i).equals("*")){
// BlockUtil.replace(loc.clone().add(-z, 0, -x), model.getElement(x, z, i));
// }
// }
// }
// break;
// case 7:
// for (int i = 0; i < height; i++) {
// //起点定于左上角(镜像),向右下遍历
// Location loc = startLoc.clone().add(-xOffset, i, zOffset);
// for (int z = 0; z < width; z++)
// for (int x = 0; x < length; x++) {
// if (model.getElement(x, z, i) == null) {
// BlockUtil.remove(loc.clone().add(x, 0, -z));
// }
// else if (!model.getElement(x, z, i).equals("*")){
// BlockUtil.replace(loc.clone().add(x, 0, -z), model.getElement(x, z, i));
// }
// }
// }
// break;
// case 8:
// for (int i = 0; i < height; i++) {
// //起点定于右下角(镜像),向左上遍历
// Location loc = startLoc.clone().add(xOffset, i, -zOffset);
// for (int z = 0; z < width; z++)
// for (int x = 0; x < length; x++) {
// if (model.getElement(x, z, i) == null) {
// BlockUtil.remove(loc.clone().add(-x, 0, z));
// }
// else if (!model.getElement(x, z, i).equals("*")){
// BlockUtil.replace(loc.clone().add(-x, 0, z), model.getElement(x, z, i));
// }
// }
// }
// break;
// }
// }
//}

View File

@@ -1,37 +1,122 @@
bar1:
rainbow_1:
range: 16
title: 'The fish is hooked, focus on it!'
title: '<#B22222>RED!'
subtitle:
# <font:Namespace:Font>
# It's not recommended to use minecraft:default
# If you insist on doing that, use <font:minecraft:default>
start: '<font:customfishing:default>'
bar: '뀄'
pointer_offset: '뀂'
pointer: ''
offset: ''
# unicodes are not in minecraft:default font
# So they would not affect player's chatting
bar: ''
pointer_offset: ''
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 1
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
rainbow_2:
range: 16
title: '<#FFA500>ORANGE!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀋'
pointer_offset: '넂'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 1
3: 0
4: 0
5: 0
6: 0
7: 0
rainbow_3:
range: 16
title: '<#808000>YELLOW!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀋'
pointer_offset: '넂'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 0
3: 1
4: 0
5: 0
6: 0
7: 0
rainbow_4:
range: 16
title: '<#3CB371>GREEN!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀋'
pointer_offset: '넂'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 0
3: 0
4: 0.1
5: 0.5
6: 1
7: 0.5
8: 0.1
9: 0
10: 0
11: 0
bar2:
range: 8
title: 'The fish is hooked, focus on it!'
4: 1
5: 0
6: 0
7: 0
rainbow_5:
range: 16
title: '<#00FFFF>AQUA!'
subtitle:
start: '<font:customfishing:default>'
bar: ''
pointer_offset: ''
pointer: ''
offset: ''
bar: ''
pointer_offset: ''
pointer: ''
offset: ''
end: '</font>'
layout:
1: 0
2: 0
3: 0
4: 0
5: 1
6: 0
7: 0
rainbow_6:
range: 16
title: '<#1E90FF>BLUE!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀋'
pointer_offset: '넂'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 0
3: 0
4: 0
5: 0
6: 1
7: 0
rainbow_7:
range: 16
title: '<#9400D3>PURPLE!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀋'
pointer_offset: '넂'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
@@ -40,85 +125,336 @@ bar2:
4: 0
5: 0
6: 0
7: 0.1
8: 0.1
9: 0.3
10: 0.3
11: 1
12: 0.3
13: 0.1
14: 0
15: 0.1
16: 0.3
17: 1
18: 0.3
19: 0.1
20: 0
21: 0
22: 0
bar3:
range: 8 #frame pixels, all must be the same
7: 1
bar_1:
range: 16
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '' #bar unicode
pointer_offset: ''
pointer: ''
offset: ''
bar: ''
pointer_offset: ''
pointer: ''
offset: ''
end: '</font>'
layout:
1: 1 #green
2: 0.3 #yellow
3: 0.1 #orange
4: 0 #red
5: 0 #red
6: 0.1 #orange
7: 0.3 #yellow
8: 0 #red
9: 0.3 #yellow
10: 0.1 #orange
11: 0 #red
12: 0.1 #orange
13: 0.3 #yellow
14: 1 #green
15: 0.3 #yellow
16: 1 #green
17: 0.1
18: 0 #red
19: 0.1 #orange
20: 0.3 #yellow
21: 0.1 #orange
22: 0 #red
bar4:
1: 0
2: 0
3: 0
4: 0.2
5: 0.6
6: 1
7: 0.6
8: 0.2
9: 0
10: 0
11: 0
bar_2:
range: 16
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀃'
pointer_offset: '넁'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 0.2
3: 0.6
4: 1
5: 0.6
6: 0.2
7: 0
8: 0
9: 0
10: 0
11: 0
bar_3:
range: 16
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀄'
pointer_offset: '넁'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 0
3: 0
4: 0
5: 0
6: 0.2
7: 0.6
8: 1
9: 0.6
10: 0.2
11: 0
bar_4:
range: 8
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀅'
pointer_offset: '넁'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 0
3: 0.1
4: 0.1
5: 0
6: 0
7: 0.2
8: 0.2
9: 0.6
10: 0.6
11: 1
12: 0.6
13: 0.2
14: 0
15: 0.2
16: 0.6
17: 1
18: 0.6
19: 0.2
20: 0.1
21: 0
22: 0
bar_5:
range: 8
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀆'
pointer_offset: '넁'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 1
2: 0
3: 0.1
4: 0.2
5: 0.2
6: 0.6
7: 0.6
8: 1
9: 0.6
10: 0.2
11: 0
12: 0.2
13: 0.6
14: 1
15: 0.6
16: 0.2
17: 0
18: 1
19: 0.2
20: 0.1
21: 0
22: 0
bar_6:
range: 8
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀇'
pointer_offset: ''
pointer: ''
offset: ''
pointer_offset: ''
pointer: ''
offset: ''
end: '</font>'
layout:
1: 0.1
2: 0.1
3: 0.1
4: 0.1
5: 0.1
6: 0.1
7: 0.1
8: 0.1
9: 1
10: 0
11: 1
12: 0
13: 1
14: 0
15: 0.1
16: 0.1
17: 0.1
18: 0.1
19: 0.1
20: 0.1
21: 0.1
22: 0.1
bar_7:
range: 4
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀈'
pointer_offset: '넁'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 0.3
3: 0.1
4: 0.3
5: 1
6: 0.3
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 1
9: 0.1
8: 0
9: 0
10: 0
11: 1
12: 0.1
13: 0.3
14: 1
11: 0
12: 0
13: 0
14: 0
15: 0
16: 1
16: 0
17: 0
18: 0.3
19: 0.1
18: 0
19: 0
20: 0
21: 0
22: 0
23: 0
24: 0
25: 0
26: 0
27: 0
28: 0
29: 0
30: 0
31: 0
32: 0
33: 0
34: 0
35: 0.1
36: 0.1
37: 0
38: 0
39: 1
40: 0
41: 0
42: 0.3
43: 0.3
44: 0.3
bar_8:
range: 4
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀉'
pointer_offset: '넁'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 0
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0
13: 0
14: 0
15: 0
16: 0
17: 0.2
18: 0.2
19: 0.2
20: 0.6
21: 1
22: 0
22: 0.6
23: 0.2
24: 0.2
25: 0.2
26: 0.2
27: 0
28: 0
29: 0
30: 0
31: 0
32: 0
33: 0
34: 0
35: 0
36: 0
37: 0
38: 0
39: 0
40: 0
41: 0
42: 0
43: 0
44: 0
bar_9:
range: 4
title: 'The fish is hooked, focus on it!'
subtitle:
start: '<font:customfishing:default>'
bar: '뀊'
pointer_offset: '넁'
pointer: '뀁'
offset: '넀'
end: '</font>'
layout:
1: 1
2: 0
3: 0
4: 0
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0
13: 0
14: 0
15: 0
16: 0
17: 0
18: 0
19: 0
20: 0
21: 0
22: 0
23: 0
24: 0
25: 0
26: 0
27: 0
28: 0
29: 0
30: 0
31: 0
32: 0
33: 0
34: 0
35: 0
36: 0
37: 0
38: 0
39: 0
40: 0
41: 0
42: 0
43: 0
44: 1

View File

@@ -8,8 +8,8 @@ example:
# optional
# Fishing competition can also be started with a command
start-time:
- '5:30'
- '17:30'
- '12:30'
- '18:30'
#seconds
duration: 300
@@ -19,53 +19,53 @@ example:
# Competition information (it will only be shown to participants)
bossbar:
enable: true
color: YELLOW
color: WHITE
overlay: PROGRESS
# https://docs.adventure.kyori.net/minimessage/format.html
text:
- '<gray>Time Left: <gold>{time}s <gray>Rank: <gold>{rank}'
- '<gray>Time Left: <gold>{minute}m{second}s <gray>Points: <gold>{point}'
# seconds
switch-interval: 15
# ticks
- '<gray>[<#87CEFA>🎣<gray>] <gradient:#F0F8FF:#87CEFA:#F0F8FF>Time Left: <#E6E6FA>{time}s <gray>| <gradient:#F0F8FF:#87CEFA:#F0F8FF>Your Rank: <#E6E6FA>{rank} <gray>| <gradient:#F0F8FF:#87CEFA:#F0F8FF>No.1 Player: <#E6E6FA>{1st_player}'
- '<gray>[<#87CEFA>🎣<gray>] <gradient:#F0F8FF:#87CEFA:#F0F8FF>Time Left: <#E6E6FA>{minute}m{second}s <gray>| <gradient:#F0F8FF:#87CEFA:#F0F8FF>Your Score: <#E6E6FA>{score} <gray>| <gradient:#F0F8FF:#87CEFA:#F0F8FF>No.1 Score: <#E6E6FA>{1st_score}'
refresh-rate: 10
switch-interval: 200
command:
start:
- 'say competition started!'
- 'say [🎣] Competition started! It''s time to fish'
end:
- 'say competition ended!'
- 'say [🎣] Competition ended! Let''s see the results'
join:
- 'money give {player} 10'
broadcast:
start:
- '<red> <red>⚠<aqua><bold>Fishing competition<red>⚠'
- '<red>'
- '<blue>----------------------------------------'
- '<#D4F2E7>◤─────────────────────────◥'
- ''
- '<gray>The competition has started. Start <gold>Fishing<gray> to join!'
- ' <gray>[<#87CEFA>🎣<gray>] <gradient:#F0F8FF:#87CEFA:#F0F8FF>Fishing Competition'
- ''
- '<blue>----------------------------------------'
- ' <#E1FFFF>Objectives:'
- ' <#B0C4DE>Catch as many fish as possible'
- ' <#B0C4DE>Start fishing to participate!'
- ''
- '<#D4F2E7>◣─────────────────────────◢'
end:
- '<red> <red>⚠<aqua><bold>Fishing competition<red>⚠'
- '<red>'
- '<blue>----------------------------------------'
- '<#D4F2E7>◤─────────────────────────◥'
- ''
- '<gray>The competition has ended!'
- ' <gold>① <gray>{1st} {1st_points}points'
- ' <gray>② <gray>{2nd} {2nd_points}points'
- ' <white>③ <gray>{3rd} {3rd_points}points'
- ' <gray>[<#87CEFA>🎣<gray>] <gradient:#F0F8FF:#87CEFA:#F0F8FF>Fishing Competition'
- ''
- '<blue>----------------------------------------'
- ' <#E1FFFF>Results:'
- ' <gradient:#FFF8DC:#FFD700:#FFF8DC>No.①: {1st} - {1st_points}'
- ' <gradient:#F5FFFA:#F5F5F5:#F5FFFA>No.②: {2nd} - {2nd_points}'
- ' <gradient:#D2B48C:#CD853F:#D2B48C>No.③: {3rd} - {3rd_points}'
- ''
- '<#D4F2E7>◣─────────────────────────◢'
# You can customize unlimited ranks' rewards by adding ranks like 4,5,6...
prize:
1:
commands:
- 'say {player} got the 1st place'
- 'money give {player} 200'
messages:
- 'You got the first prize lol!'
- '<#FF4500>[!] Congratulations! You got the first prize!'
2:
commands:
- 'money give {player} 100'
@@ -73,5 +73,7 @@ example:
commands:
- 'money give {player} 50'
participation:
messages:
- '<#FF4500>[!] Thanks for participation! This is the reward!'
commands:
- 'money give {player} 10'

View File

@@ -0,0 +1,16 @@
# Vanilla blocks should be in capital format
AIR: 'air'
COBBLESTONE: 'c'
NETHERRACK: 'n'
CRIMSON_HYPHAE: 'h'
BEACON: 'b'
EMERALD_BLOCK: 'e'
DIAMOND_BLOCK: 'd'
GOLD_BLOCK: 'g'
IRON_BLOCK: 'i'
#ItemsAdder Block support
nether:reactor: 'r'

View File

@@ -1,8 +1,12 @@
example:
primary_fishing_totem:
# Totem Core Block ID
core:
- b
- r
activator:
- totem_stone
radius: 10
# seconds
duration: 300

View File

@@ -4,4 +4,4 @@ fishfinder:
name: '<gray>Fish Finder'
lore:
- '<white>Right click to see what fish can be caught in this place!'
custom-model-data: 647
custom-model-data: 647