9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00
This commit is contained in:
XiaoMoMi
2024-12-16 03:42:13 +08:00
parent f2715e6bcf
commit 0bedc5d8ca
5 changed files with 98 additions and 0 deletions

View File

@@ -58,6 +58,7 @@ dependencies {
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT") compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
compileOnly("pers.neige.neigeitems:NeigeItems:1.17.13") compileOnly("pers.neige.neigeitems:NeigeItems:1.17.13")
compileOnly("io.th0rgal:oraxen:1.168.0") compileOnly("io.th0rgal:oraxen:1.168.0")
compileOnly("com.github.brcdev-minecraft:shopgui-api:3.0.0")
// entity // entity
compileOnly("io.lumine:Mythic-Dist:5.6.2") compileOnly("io.lumine:Mythic-Dist:5.6.2")
// eco // eco

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) <2024> <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.shop;
import net.brcdev.shopgui.ShopGuiPlusApi;
import net.brcdev.shopgui.event.ShopGUIPlusPostEnableEvent;
import net.brcdev.shopgui.provider.item.ItemProvider;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.mechanic.context.ContextKeys;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.Objects;
public class ShopGUICFItemProvider extends ItemProvider implements Listener {
private final BukkitCustomFishingPlugin plugin;
public ShopGUICFItemProvider(BukkitCustomFishingPlugin plugin) {
super("CustomFishing");
this.plugin = plugin;
}
@Override
public boolean isValidItem(ItemStack itemStack) {
return plugin.getItemManager().getCustomFishingItemID(itemStack) != null;
}
@Override
public ItemStack loadItem(ConfigurationSection configurationSection) {
String id = configurationSection.getString("customfishing");
if (id == null) return null;
return plugin.getItemManager().buildInternal(Context.player(null).arg(ContextKeys.ID, id), id);
}
@Override
public boolean compare(ItemStack i1, ItemStack i2) {
return Objects.equals(plugin.getItemManager().getCustomFishingItemID(i1), plugin.getItemManager().getCustomFishingItemID(i2));
}
@EventHandler
public void onShopGUIPlusPostEnable(ShopGUIPlusPostEnableEvent event) {
ShopGuiPlusApi.registerItemProvider(this);
}
}

View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) <2024> <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.shop;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import org.bukkit.Bukkit;
public class ShopGUIHook {
public static void register() {
Bukkit.getPluginManager().registerEvents(new ShopGUICFItemProvider(BukkitCustomFishingPlugin.getInstance()), BukkitCustomFishingPlugin.getInstance().getBootstrap());
}
}

View File

@@ -39,6 +39,8 @@ import net.momirealms.customfishing.bukkit.integration.region.WorldGuardRegion;
import net.momirealms.customfishing.bukkit.integration.season.AdvancedSeasonsProvider; import net.momirealms.customfishing.bukkit.integration.season.AdvancedSeasonsProvider;
import net.momirealms.customfishing.bukkit.integration.season.CustomCropsSeasonProvider; import net.momirealms.customfishing.bukkit.integration.season.CustomCropsSeasonProvider;
import net.momirealms.customfishing.bukkit.integration.season.RealisticSeasonsProvider; import net.momirealms.customfishing.bukkit.integration.season.RealisticSeasonsProvider;
import net.momirealms.customfishing.bukkit.integration.shop.ShopGUICFItemProvider;
import net.momirealms.customfishing.bukkit.integration.shop.ShopGUIHook;
import net.momirealms.customfishing.bukkit.item.BukkitItemManager; import net.momirealms.customfishing.bukkit.item.BukkitItemManager;
import net.momirealms.customfishing.common.util.Pair; import net.momirealms.customfishing.common.util.Pair;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -179,6 +181,9 @@ public class BukkitIntegrationManager implements IntegrationManager {
new CompetitionPapi(plugin).load(); new CompetitionPapi(plugin).load();
new StatisticsPapi(plugin).load(); new StatisticsPapi(plugin).load();
} }
if (isHooked("ShopGUIPlus")) {
ShopGUIHook.register();
}
} }
private boolean isHooked(String hooked) { private boolean isHooked(String hooked) {

View File

@@ -25,6 +25,7 @@ softdepend:
- EcoJobs - EcoJobs
- Zaphkiel - Zaphkiel
- WorldGuard - WorldGuard
- ShopGUIPlus
permissions: permissions:
fishingbag.user: fishingbag.user:
default: true default: true