mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-25 18:09:26 +00:00
checkpoint - 10
This commit is contained in:
@@ -8,6 +8,7 @@ repositories {
|
||||
maven("https://repo.oraxen.com/releases/") // oraxen
|
||||
maven("https://repo.auxilor.io/repository/maven-public/") // eco
|
||||
maven("https://nexus.betonquest.org/repository/betonquest/") // betonquest
|
||||
maven("https://repo.dmulloy2.net/repository/public/") // betonquest needs packet wrapper?
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -48,7 +49,7 @@ dependencies {
|
||||
compileOnly("net.Indyuce:MMOItems-API:6.10-SNAPSHOT")
|
||||
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
|
||||
compileOnly("pers.neige.neigeitems:NeigeItems:1.17.13")
|
||||
compileOnly("io.th0rgal:oraxen:1.175.0")
|
||||
compileOnly("io.th0rgal:oraxen:1.168.0")
|
||||
// entity
|
||||
compileOnly("io.lumine:Mythic-Dist:5.6.2")
|
||||
// eco
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
package net.momirealms.customfishing.bukkit.integration.item;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.integration.ItemProvider;
|
||||
import net.momirealms.customfishing.api.mechanic.context.Context;
|
||||
import net.momirealms.customfishing.common.util.Key;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,7 +38,13 @@ public class CustomFishingItemProvider implements ItemProvider {
|
||||
@Override
|
||||
public ItemStack buildItem(@NotNull Player player, @NotNull String id) {
|
||||
String[] split = id.split(":", 2);
|
||||
ItemStack itemStack = BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(Context.player(player), Key.key(split[0], split[1]));
|
||||
String finalID;
|
||||
if (split.length != 2) {
|
||||
finalID = split[0];
|
||||
} else {
|
||||
finalID = split[1];
|
||||
}
|
||||
ItemStack itemStack = BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(Context.player(player), finalID);
|
||||
return requireNonNull(itemStack);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,144 +1,144 @@
|
||||
/*
|
||||
* 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.bukkit.integration.papi;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class CompetitionPapi extends PlaceholderExpansion {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
|
||||
public CompetitionPapi(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
super.register();
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
super.unregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return "cfcompetition";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return "XiaoMoMi";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return "2.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
switch (params) {
|
||||
case "goingon" -> {
|
||||
return String.valueOf(plugin.getCompetitionManager().getOnGoingCompetition() != null);
|
||||
}
|
||||
case "nextseconds" -> {
|
||||
return String.valueOf(plugin.getCompetitionManager().getNextCompetitionInSeconds());
|
||||
}
|
||||
case "nextsecond" -> {
|
||||
return plugin.getCompetitionManager().getNextCompetitionInSeconds() % 60 + CFLocale.FORMAT_Second;
|
||||
}
|
||||
case "nextminute" -> {
|
||||
int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
|
||||
int min = (sec % 3600) / 60;
|
||||
return sec < 60 ? "" : min + CFLocale.FORMAT_Minute;
|
||||
}
|
||||
case "nexthour" -> {
|
||||
int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
|
||||
int h = (sec % (3600 * 24)) / 3600;
|
||||
return sec < 3600 ? "" : h + CFLocale.FORMAT_Hour;
|
||||
}
|
||||
case "nextday" -> {
|
||||
int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
|
||||
int day = sec / (3600 * 24);
|
||||
return day == 0 ? "" : day + CFLocale.FORMAT_Day;
|
||||
}
|
||||
case "rank" -> {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (competition == null) return "";
|
||||
else return String.valueOf(competition.getRanking().getPlayerRank(player.getName()));
|
||||
}
|
||||
case "goal" -> {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (competition == null) return "";
|
||||
else return competition.getGoal().name();
|
||||
}
|
||||
case "seconds" -> {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (competition == null) return "";
|
||||
return competition.getCachedPlaceholder("{seconds}");
|
||||
}
|
||||
case "second" -> {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (competition == null) return "";
|
||||
return competition.getCachedPlaceholder("{second}");
|
||||
}
|
||||
case "minute" -> {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (competition == null) return "";
|
||||
return competition.getCachedPlaceholder("{minute}");
|
||||
}
|
||||
case "hour" -> {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (competition == null) return "";
|
||||
return competition.getCachedPlaceholder("{hour}");
|
||||
}
|
||||
}
|
||||
|
||||
String[] split = params.split("_", 2);
|
||||
switch (split[0]) {
|
||||
case "score" -> {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (competition == null) return "";
|
||||
if (split.length == 1) {
|
||||
return String.format("%.2f", competition.getRanking().getPlayerScore(player.getName()));
|
||||
} else {
|
||||
return String.format("%.2f", competition.getRanking().getScoreAt(Integer.parseInt(split[1])));
|
||||
}
|
||||
}
|
||||
case "player" -> {
|
||||
FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
if (competition == null) return "";
|
||||
if (split.length == 1) return "Invalid format";
|
||||
return Optional.ofNullable(competition.getRanking().getPlayerAt(Integer.parseInt(split[1]))).orElse("");
|
||||
}
|
||||
}
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * 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.bukkit.integration.papi;
|
||||
//
|
||||
//import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
//import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
//import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
|
||||
//import org.bukkit.OfflinePlayer;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//public class CompetitionPapi extends PlaceholderExpansion {
|
||||
//
|
||||
// private final BukkitCustomFishingPlugin plugin;
|
||||
//
|
||||
// public CompetitionPapi(BukkitCustomFishingPlugin plugin) {
|
||||
// this.plugin = plugin;
|
||||
// }
|
||||
//
|
||||
// public void load() {
|
||||
// super.register();
|
||||
// }
|
||||
//
|
||||
// public void unload() {
|
||||
// super.unregister();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getIdentifier() {
|
||||
// return "cfcompetition";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getAuthor() {
|
||||
// return "XiaoMoMi";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getVersion() {
|
||||
// return "2.0";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean persist() {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
// switch (params) {
|
||||
// case "goingon" -> {
|
||||
// return String.valueOf(plugin.getCompetitionManager().getOnGoingCompetition() != null);
|
||||
// }
|
||||
// case "nextseconds" -> {
|
||||
// return String.valueOf(plugin.getCompetitionManager().getNextCompetitionInSeconds());
|
||||
// }
|
||||
// case "nextsecond" -> {
|
||||
// return plugin.getCompetitionManager().getNextCompetitionInSeconds() % 60 + CFLocale.FORMAT_Second;
|
||||
// }
|
||||
// case "nextminute" -> {
|
||||
// int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
|
||||
// int min = (sec % 3600) / 60;
|
||||
// return sec < 60 ? "" : min + CFLocale.FORMAT_Minute;
|
||||
// }
|
||||
// case "nexthour" -> {
|
||||
// int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
|
||||
// int h = (sec % (3600 * 24)) / 3600;
|
||||
// return sec < 3600 ? "" : h + CFLocale.FORMAT_Hour;
|
||||
// }
|
||||
// case "nextday" -> {
|
||||
// int sec = plugin.getCompetitionManager().getNextCompetitionInSeconds();
|
||||
// int day = sec / (3600 * 24);
|
||||
// return day == 0 ? "" : day + CFLocale.FORMAT_Day;
|
||||
// }
|
||||
// case "rank" -> {
|
||||
// FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
// if (competition == null) return "";
|
||||
// else return String.valueOf(competition.getRanking().getPlayerRank(player.getName()));
|
||||
// }
|
||||
// case "goal" -> {
|
||||
// FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
// if (competition == null) return "";
|
||||
// else return competition.getGoal().name();
|
||||
// }
|
||||
// case "seconds" -> {
|
||||
// FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
// if (competition == null) return "";
|
||||
// return competition.getCachedPlaceholder("{seconds}");
|
||||
// }
|
||||
// case "second" -> {
|
||||
// FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
// if (competition == null) return "";
|
||||
// return competition.getCachedPlaceholder("{second}");
|
||||
// }
|
||||
// case "minute" -> {
|
||||
// FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
// if (competition == null) return "";
|
||||
// return competition.getCachedPlaceholder("{minute}");
|
||||
// }
|
||||
// case "hour" -> {
|
||||
// FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
// if (competition == null) return "";
|
||||
// return competition.getCachedPlaceholder("{hour}");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// String[] split = params.split("_", 2);
|
||||
// switch (split[0]) {
|
||||
// case "score" -> {
|
||||
// FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
// if (competition == null) return "";
|
||||
// if (split.length == 1) {
|
||||
// return String.format("%.2f", competition.getRanking().getPlayerScore(player.getName()));
|
||||
// } else {
|
||||
// return String.format("%.2f", competition.getRanking().getScoreAt(Integer.parseInt(split[1])));
|
||||
// }
|
||||
// }
|
||||
// case "player" -> {
|
||||
// FishingCompetition competition = plugin.getCompetitionManager().getOnGoingCompetition();
|
||||
// if (competition == null) return "";
|
||||
// if (split.length == 1) return "Invalid format";
|
||||
// return Optional.ofNullable(competition.getRanking().getPlayerAt(Integer.parseInt(split[1]))).orElse("");
|
||||
// }
|
||||
// }
|
||||
// return "null";
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,126 +1,126 @@
|
||||
/*
|
||||
* 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.bukkit.integration.papi;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CustomFishingPapi extends PlaceholderExpansion {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
|
||||
public CustomFishingPapi(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
super.register();
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
super.unregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return "customfishing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return "XiaoMoMi";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return "2.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) {
|
||||
String[] split = params.split("_");
|
||||
|
||||
Player player = offlinePlayer.getPlayer();
|
||||
if (player == null)
|
||||
return "";
|
||||
|
||||
switch (split[0]) {
|
||||
case "market" -> {
|
||||
if (split.length < 2)
|
||||
return null;
|
||||
switch (split[1]) {
|
||||
case "limit" -> {
|
||||
if (split.length < 3) {
|
||||
return String.format("%.2f", plugin.getMarketManager().earningLimit(player));
|
||||
} else {
|
||||
Player another = Bukkit.getPlayer(split[2]);
|
||||
if (another == null) {
|
||||
return "";
|
||||
}
|
||||
return String.format("%.2f", plugin.getMarketManager().earningLimit(another));
|
||||
}
|
||||
}
|
||||
case "earnings" -> {
|
||||
OnlineUserData user;
|
||||
if (split.length < 3) {
|
||||
user = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
} else {
|
||||
Player another = Bukkit.getPlayer(split[2]);
|
||||
if (another == null) {
|
||||
return "";
|
||||
}
|
||||
user = plugin.getStorageManager().getOnlineUser(another.getUniqueId());
|
||||
}
|
||||
if (user == null)
|
||||
return "";
|
||||
return String.format("%.2f", user.getEarningData().earnings);
|
||||
}
|
||||
case "canearn" -> {
|
||||
if (split.length < 3) {
|
||||
OnlineUserData user = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
if (user == null)
|
||||
return "";
|
||||
return String.format("%.2f", plugin.getMarketManager().earningLimit(player) - user.getEarningData().earnings);
|
||||
} else {
|
||||
Player another = Bukkit.getPlayer(split[2]);
|
||||
if (another == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
OnlineUserData user = plugin.getStorageManager().getOnlineUser(another.getUniqueId());
|
||||
if (user == null)
|
||||
return "";
|
||||
return String.format("%.2f", plugin.getMarketManager().earningLimit(another) - user.getEarningData().earnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * 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.bukkit.integration.papi;
|
||||
//
|
||||
//import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
//import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
//import org.bukkit.Bukkit;
|
||||
//import org.bukkit.OfflinePlayer;
|
||||
//import org.bukkit.entity.Player;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//
|
||||
//public class CustomFishingPapi extends PlaceholderExpansion {
|
||||
//
|
||||
// private final BukkitCustomFishingPlugin plugin;
|
||||
//
|
||||
// public CustomFishingPapi(BukkitCustomFishingPlugin plugin) {
|
||||
// this.plugin = plugin;
|
||||
// }
|
||||
//
|
||||
// public void load() {
|
||||
// super.register();
|
||||
// }
|
||||
//
|
||||
// public void unload() {
|
||||
// super.unregister();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getIdentifier() {
|
||||
// return "customfishing";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getAuthor() {
|
||||
// return "XiaoMoMi";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getVersion() {
|
||||
// return "2.0";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean persist() {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @Nullable String onRequest(OfflinePlayer offlinePlayer, @NotNull String params) {
|
||||
// String[] split = params.split("_");
|
||||
//
|
||||
// Player player = offlinePlayer.getPlayer();
|
||||
// if (player == null)
|
||||
// return "";
|
||||
//
|
||||
// switch (split[0]) {
|
||||
// case "market" -> {
|
||||
// if (split.length < 2)
|
||||
// return null;
|
||||
// switch (split[1]) {
|
||||
// case "limit" -> {
|
||||
// if (split.length < 3) {
|
||||
// return String.format("%.2f", plugin.getMarketManager().earningLimit(player));
|
||||
// } else {
|
||||
// Player another = Bukkit.getPlayer(split[2]);
|
||||
// if (another == null) {
|
||||
// return "";
|
||||
// }
|
||||
// return String.format("%.2f", plugin.getMarketManager().earningLimit(another));
|
||||
// }
|
||||
// }
|
||||
// case "earnings" -> {
|
||||
// OnlineUserData user;
|
||||
// if (split.length < 3) {
|
||||
// user = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
// } else {
|
||||
// Player another = Bukkit.getPlayer(split[2]);
|
||||
// if (another == null) {
|
||||
// return "";
|
||||
// }
|
||||
// user = plugin.getStorageManager().getOnlineUser(another.getUniqueId());
|
||||
// }
|
||||
// if (user == null)
|
||||
// return "";
|
||||
// return String.format("%.2f", user.getEarningData().earnings);
|
||||
// }
|
||||
// case "canearn" -> {
|
||||
// if (split.length < 3) {
|
||||
// OnlineUserData user = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
// if (user == null)
|
||||
// return "";
|
||||
// return String.format("%.2f", plugin.getMarketManager().earningLimit(player) - user.getEarningData().earnings);
|
||||
// } else {
|
||||
// Player another = Bukkit.getPlayer(split[2]);
|
||||
// if (another == null) {
|
||||
// return "";
|
||||
// }
|
||||
//
|
||||
// OnlineUserData user = plugin.getStorageManager().getOnlineUser(another.getUniqueId());
|
||||
// if (user == null)
|
||||
// return "";
|
||||
// return String.format("%.2f", plugin.getMarketManager().earningLimit(another) - user.getEarningData().earnings);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,112 +1,112 @@
|
||||
/*
|
||||
* 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.bukkit.integration.papi;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StatisticsPapi extends PlaceholderExpansion {
|
||||
|
||||
private final BukkitCustomFishingPlugin plugin;
|
||||
|
||||
public StatisticsPapi(BukkitCustomFishingPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
super.register();
|
||||
}
|
||||
|
||||
public void unload() {
|
||||
super.unregister();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdentifier() {
|
||||
return "fishingstats";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getAuthor() {
|
||||
return "XiaoMoMi";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return "2.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
OnlineUserData onlineUser = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
if (onlineUser == null) return "Data not loaded";
|
||||
Statistics statistics = onlineUser.getStatistics();
|
||||
String[] split = params.split("_", 2);
|
||||
switch (split[0]) {
|
||||
case "total" -> {
|
||||
return String.valueOf(statistics.getTotalCatchAmount());
|
||||
}
|
||||
case "hascaught" -> {
|
||||
if (split.length == 1) return "Invalid format";
|
||||
return String.valueOf(statistics.getLootAmount(split[1]) != 0);
|
||||
}
|
||||
case "amount" -> {
|
||||
if (split.length == 1) return "Invalid format";
|
||||
return String.valueOf(statistics.getLootAmount(split[1]));
|
||||
}
|
||||
case "size-record" -> {
|
||||
return String.format("%.2f", statistics.getSizeRecord(split[1]));
|
||||
}
|
||||
case "category" -> {
|
||||
if (split.length == 1) return "Invalid format";
|
||||
String[] categorySplit = split[1].split("_", 2);
|
||||
if (categorySplit.length == 1) return "Invalid format";
|
||||
List<String> category = plugin.getStatisticsManager().getCategory(categorySplit[1]);
|
||||
if (category == null) return "Category Not Exists";
|
||||
if (categorySplit[0].equals("total")) {
|
||||
int total = 0;
|
||||
for (String loot : category) {
|
||||
total += statistics.getLootAmount(loot);
|
||||
}
|
||||
return String.valueOf(total);
|
||||
} else if (categorySplit[0].equals("progress")) {
|
||||
int size = category.size();
|
||||
int unlocked = 0;
|
||||
for (String loot : category) {
|
||||
if (statistics.getLootAmount(loot) != 0) unlocked++;
|
||||
}
|
||||
double percent = ((double) unlocked * 100) / size;
|
||||
String progress = String.format("%.1f", percent);
|
||||
return progress.equals("100.0") ? "100" : progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
///*
|
||||
// * 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.bukkit.integration.papi;
|
||||
//
|
||||
//import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
//import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
|
||||
//import org.bukkit.OfflinePlayer;
|
||||
//import org.jetbrains.annotations.NotNull;
|
||||
//import org.jetbrains.annotations.Nullable;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//public class StatisticsPapi extends PlaceholderExpansion {
|
||||
//
|
||||
// private final BukkitCustomFishingPlugin plugin;
|
||||
//
|
||||
// public StatisticsPapi(BukkitCustomFishingPlugin plugin) {
|
||||
// this.plugin = plugin;
|
||||
// }
|
||||
//
|
||||
// public void load() {
|
||||
// super.register();
|
||||
// }
|
||||
//
|
||||
// public void unload() {
|
||||
// super.unregister();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getIdentifier() {
|
||||
// return "fishingstats";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getAuthor() {
|
||||
// return "XiaoMoMi";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @NotNull String getVersion() {
|
||||
// return "2.0";
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean persist() {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) {
|
||||
// OnlineUserData onlineUser = plugin.getStorageManager().getOnlineUser(player.getUniqueId());
|
||||
// if (onlineUser == null) return "Data not loaded";
|
||||
// Statistics statistics = onlineUser.getStatistics();
|
||||
// String[] split = params.split("_", 2);
|
||||
// switch (split[0]) {
|
||||
// case "total" -> {
|
||||
// return String.valueOf(statistics.getTotalCatchAmount());
|
||||
// }
|
||||
// case "hascaught" -> {
|
||||
// if (split.length == 1) return "Invalid format";
|
||||
// return String.valueOf(statistics.getLootAmount(split[1]) != 0);
|
||||
// }
|
||||
// case "amount" -> {
|
||||
// if (split.length == 1) return "Invalid format";
|
||||
// return String.valueOf(statistics.getLootAmount(split[1]));
|
||||
// }
|
||||
// case "size-record" -> {
|
||||
// return String.format("%.2f", statistics.getSizeRecord(split[1]));
|
||||
// }
|
||||
// case "category" -> {
|
||||
// if (split.length == 1) return "Invalid format";
|
||||
// String[] categorySplit = split[1].split("_", 2);
|
||||
// if (categorySplit.length == 1) return "Invalid format";
|
||||
// List<String> category = plugin.getStatisticsManager().getCategory(categorySplit[1]);
|
||||
// if (category == null) return "Category Not Exists";
|
||||
// if (categorySplit[0].equals("total")) {
|
||||
// int total = 0;
|
||||
// for (String loot : category) {
|
||||
// total += statistics.getLootAmount(loot);
|
||||
// }
|
||||
// return String.valueOf(total);
|
||||
// } else if (categorySplit[0].equals("progress")) {
|
||||
// int size = category.size();
|
||||
// int unlocked = 0;
|
||||
// for (String loot : category) {
|
||||
// if (statistics.getLootAmount(loot) != 0) unlocked++;
|
||||
// }
|
||||
// double percent = ((double) unlocked * 100) / size;
|
||||
// String progress = String.format("%.1f", percent);
|
||||
// return progress.equals("100.0") ? "100" : progress;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return "null";
|
||||
// }
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user