9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-23 17:09:21 +00:00
This commit is contained in:
Xiao-MoMi
2023-02-23 23:03:22 +08:00
parent ee74a48dd0
commit 978433f9ec
21 changed files with 324 additions and 73 deletions

View File

@@ -4,76 +4,47 @@ plugins {
}
group = 'net.momirealms'
version = '2.2.4'
version = '2.2.5'
repositories {
mavenCentral()
maven {
name = 'papermc-repo'
url = 'https://papermc.io/repo/repository/maven-public/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
maven {
name = "sonatype-oss-snapshots1"
url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name = "dmulloy2-repo"
url = "https://repo.dmulloy2.net/repository/public/"
}
maven {
name = "clip-repo"
url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}
maven {
name = "NBT-API"
url = "https://repo.codemc.org/repository/maven-public/"
}
maven {
name = "sk89q-repo"
url = "https://maven.enginehub.org/repo/"
}
maven {
name = "Lumine Releases"
url = "https://mvn.lumine.io/repository/maven-public"
}
maven {
name = "jitpack-repo"
url = "https://jitpack.io"
}
maven {
name = 'glaremasters repo'
url = 'https://repo.glaremasters.me/repository/towny/'
}
maven {
name = 'superior skyblock repo'
url 'https://repo.bg-software.com/repository/api/'
}
maven {name = 'papermc-repo'; url = 'https://papermc.io/repo/repository/maven-public/'}
maven {name = 'sonatype'; url = 'https://oss.sonatype.org/content/groups/public/'}
maven {name = "sonatype-oss-snapshots1"; url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"}
maven {name = "dmulloy2-repo"; url = "https://repo.dmulloy2.net/repository/public/"}
maven {name = "clip-repo"; url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'}
maven {name = "NBT-API"; url = "https://repo.codemc.org/repository/maven-public/"}
maven {name = "sk89q-repo"; url = "https://maven.enginehub.org/repo/"}
maven {name = "Lumine Releases"; url = "https://mvn.lumine.io/repository/maven-public"}
maven {name = "jitpack-repo"; url = "https://jitpack.io"}
maven {name = 'glaremasters repo'; url = 'https://repo.glaremasters.me/repository/towny/'}
maven {name = 'superior skyblock repo'; url = 'https://repo.bg-software.com/repository/api/'}
maven {name = 'bg-repo'; url = 'https://repo.bg-software.com/repository/api/'}
maven {name = "Lumine Releases"; url = "https://mvn.lumine.io/repository/maven-public"}
}
dependencies {
compileOnly 'dev.dejvokep:boosted-yaml:1.3'
compileOnly 'com.github.Archy-X:AureliumSkills:Beta1.3.6'
compileOnly 'commons-io:commons-io:2.11.0'
compileOnly 'com.github.angeschossen:LandsAPI:6.26.18'
compileOnly 'com.github.TechFortress:GriefPrevention:16.18'
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'me.clip:placeholderapi:2.11.2'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.7'
compileOnly 'com.github.LoneDev6:api-itemsadder:3.2.3-r8'
compileOnly 'com.palmergames.bukkit.towny:towny:0.98.2.0'
compileOnly 'com.willfp:EcoSkills:1.72.0'
compileOnly 'com.willfp:eco:6.38.3'
compileOnly 'com.github.Zrips:Jobs:4.17.2'
compileOnly ('dev.dejvokep:boosted-yaml:1.3')
compileOnly ('com.github.Archy-X:AureliumSkills:Beta1.3.6')
compileOnly ('commons-io:commons-io:2.11.0')
compileOnly ('com.github.angeschossen:LandsAPI:6.26.18')
compileOnly ('com.github.TechFortress:GriefPrevention:16.18')
compileOnly ('io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT')
compileOnly ('me.clip:placeholderapi:2.11.2')
compileOnly ('com.sk89q.worldguard:worldguard-bukkit:7.0.7')
compileOnly ('com.github.LoneDev6:api-itemsadder:3.2.3-r8')
compileOnly ('io.lumine:Mythic-Dist:5.0.3-SNAPSHOT')
compileOnly ('com.palmergames.bukkit.towny:towny:0.98.2.0')
compileOnly ('com.willfp:EcoSkills:1.72.0')
compileOnly ('com.willfp:eco:6.38.3')
compileOnly ('com.bgsoftware:SuperiorSkyblockAPI:2022.9')
compileOnly ('com.github.Zrips:Jobs:4.17.2')
compileOnly fileTree(dir:'libs',includes:['*.jar'])
implementation('net.kyori:adventure-api:4.12.0')
implementation('net.kyori:adventure-platform-bukkit:4.2.0')
implementation('net.kyori:adventure-text-minimessage:4.12.0')
implementation("de.tr7zw:item-nbt-api:2.11.1")
implementation("org.bstats:bstats-bukkit:3.0.0")
implementation ('net.kyori:adventure-api:4.12.0')
implementation ('net.kyori:adventure-platform-bukkit:4.2.0')
implementation ('net.kyori:adventure-text-minimessage:4.12.0')
implementation ("de.tr7zw:item-nbt-api:2.11.1")
implementation ("org.bstats:bstats-bukkit:3.0.0")
implementation fileTree(dir:'libs',includes:['BiomeAPI.jar'])
}

View File

@@ -19,9 +19,18 @@ package net.momirealms.customcrops.api.utils;
import net.momirealms.customcrops.CustomCrops;
import net.momirealms.customcrops.api.crop.Crop;
import net.momirealms.customcrops.config.BasicItemConfig;
import net.momirealms.customcrops.config.CropConfig;
import net.momirealms.customcrops.config.MainConfig;
import net.momirealms.customcrops.managers.CropManager;
import net.momirealms.customcrops.managers.CustomWorld;
import net.momirealms.customcrops.objects.GrowingCrop;
import net.momirealms.customcrops.objects.Sprinkler;
import net.momirealms.customcrops.objects.fertilizer.Fertilizer;
import net.momirealms.customcrops.utils.FurnitureUtil;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.Nullable;
public class CropUtils {
@@ -32,7 +41,7 @@ public class CropUtils {
* @return crop config
*/
@Nullable
public static Crop getCrop(String crop) {
public static Crop getCropConfig(String crop) {
return CropConfig.CROPS.get(crop);
}
@@ -46,6 +55,61 @@ public class CropUtils {
return CustomCrops.plugin.getCropManager().getHandler().plantSeed(location, crop, null, null);
}
/**
* Oraxen & ItemsAdder handle item frame hitbox in different ways
* If you want to remove a crop at a certain location, use location.getBlock() method as the param
* @param block block
* @return success or not
*/
public static boolean removeCrop(Block block) {
Location location = block.getLocation();
CustomCrops.plugin.getCropManager().getHandler().onBreakUnripeCrop(location);
if (MainConfig.cropMode) {
CustomCrops.plugin.getCropManager().getCustomInterface().removeBlock(location);
}
else {
if (MainConfig.OraxenHook) {CustomCrops.plugin.getCropManager().getCustomInterface().removeFurniture(FurnitureUtil.getItemFrame(location.clone().add(0.5,0.03125,0.5)));}
else {CustomCrops.plugin.getCropManager().getCustomInterface().removeFurniture(FurnitureUtil.getItemFrame(location.clone().add(0.5,0.5,0.5)));}
}
return true;
}
/**
* get the growing crop
* @param location crop location
* @return growing crop
*/
@Nullable
public static GrowingCrop getGrowingCrop(Location location) {
CustomWorld customWorld = CustomCrops.plugin.getCropManager().getCustomWorld(location.getWorld());
if (customWorld != null) {
return customWorld.getCropCache(location);
}
return null;
}
/**
* [Only works in tripwire mode]
* @param block block
* @return the block is crop or not
*/
public static boolean isCropBlock(Block block) {
String block_id = CustomCrops.plugin.getCropManager().getCustomInterface().getBlockID(block.getLocation());
if (block_id == null) return false;
return block_id.contains("_stage_") || block_id.equals(BasicItemConfig.deadCrop);
}
/**
* [Only works in item_frame mode]
* @param entity entity
* @return the entity is crop or not
*/
public static boolean isCropEntity(Entity entity) {
String entity_id = CustomCrops.plugin.getCropManager().getCustomInterface().getEntityID(entity);
if (entity_id == null) return false;
return entity_id.contains("_stage_") || entity_id.equals(BasicItemConfig.deadCrop);
}
/**
* get the cropManager
* @return cropManager
@@ -53,4 +117,62 @@ public class CropUtils {
public static CropManager getCropManager() {
return CustomCrops.plugin.getCropManager();
}
/**
* get the fertilizer
* @param location pot location
* @return fertilizer
*/
@Nullable
public static Fertilizer getFertilizer(Location location) {
CustomWorld customWorld = CustomCrops.plugin.getCropManager().getCustomWorld(location.getWorld());
if (customWorld != null) {
return customWorld.getFertilizerCache(location);
}
return null;
}
/**
* get the wet state
* @param location pot location
* @return wet or not
*/
public static boolean isPotWet(Location location) {
String block_id = CustomCrops.plugin.getCropManager().getCustomInterface().getBlockID(location);
if (block_id == null) return false;
return block_id.equals(BasicItemConfig.wetPot);
}
/**
* Make a pot dry
* @param location pot location
*/
public static void makePotDry(Location location) {
CustomCrops.plugin.getCropManager().makePotDry(location);
}
/**
* If the block is a pot
* @param location pot location
* @return the block is a pot or not
*/
public static boolean isPotBlock(Location location) {
String block_id = CustomCrops.plugin.getCropManager().getCustomInterface().getBlockID(location);
if (block_id == null) return false;
return block_id.equals(BasicItemConfig.wetPot) || block_id.equals(BasicItemConfig.dryPot);
}
/**
* get the sprinkler data
* @param location sprinkler location
* @return sprinkler data
*/
@Nullable
public static Sprinkler getSprinkler(Location location) {
CustomWorld customWorld = CustomCrops.plugin.getCropManager().getCustomWorld(location.getWorld());
if (customWorld != null) {
return customWorld.getSprinklerCache(location);
}
return null;
}
}

View File

@@ -51,12 +51,18 @@ public class SeasonUtils {
CustomCrops.plugin.getCropManager().getSeasonAPI().unloadWorld(world);
}
/**
* Get a season's localization
* @param season season
* @return localization
*/
public static String getSeasonText(CCSeason season) {
return switch (season) {
case SPRING -> MessageConfig.spring;
case SUMMER -> MessageConfig.summer;
case AUTUMN -> MessageConfig.autumn;
case WINTER -> MessageConfig.winter;
case UNKNOWN -> "Error";
default -> throw new IllegalStateException("Unexpected value: " + season);
};
}

View File

@@ -19,8 +19,11 @@
package net.momirealms.customcrops.api.utils;
import net.momirealms.customcrops.CustomCrops;
import net.momirealms.customcrops.config.MainConfig;
import org.bukkit.World;
import java.util.List;
public class WorldUtils {
/**
@@ -39,4 +42,34 @@ public class WorldUtils {
public static void unloadCropWorld(World world, boolean sync) {
CustomCrops.plugin.getCropManager().onWorldUnload(world, sync);
}
/**
* Add a world to the world list
* @param world world
*/
public static void addWorldToWorldList(World world) {
MainConfig.worldList.add(world);
MainConfig.worlds = MainConfig.worldList.toArray(new World[0]);
}
/**
* Remove a world from world list
* @param world world
* @return success or not
*/
public static boolean removeWorldFromWorldList(World world) {
boolean success = MainConfig.worldList.remove(world);
if (success) {
MainConfig.worlds = MainConfig.worldList.toArray(new World[0]);
}
return success;
}
/**
* get the world list
* @return world list
*/
public static List<World> getWorldList() {
return MainConfig.worldList;
}
}

View File

@@ -61,7 +61,6 @@ public class ConfigUtil {
}
public static void reloadConfigs() {
MainConfig.load();
BasicItemConfig.load();
CropConfig.load();
@@ -71,7 +70,6 @@ public class ConfigUtil {
SprinklerConfig.load();
WaterCanConfig.load();
SoundConfig.load();
// would not be activated when enabling
if (CustomCrops.plugin.getPlaceholderManager() != null) {
CustomCrops.plugin.getPlaceholderManager().unload();
CustomCrops.plugin.getPlaceholderManager().load();

View File

@@ -369,6 +369,13 @@ public class MainConfig {
hookMessage("IridiumSkyblock");
}
}
if (config.getBoolean("integration.SuperiorSkyBlock",false)){
if (Bukkit.getPluginManager().getPlugin("SuperiorSkyBlock2") == null) Log.warn("Failed to initialize SuperiorSkyBlock!");
else {
internalAntiGriefs.add(new SuperiorSkyBlockHook());
hookMessage("SuperiorSkyBlock");
}
}
if (config.getBoolean("integration.AureliumSkills")) {
if (Bukkit.getPluginManager().getPlugin("AureliumSkills") == null) Log.warn("Failed to initialize AureliumSkills!");

View File

@@ -1,7 +1,6 @@
package net.momirealms.customcrops.helper;
import org.bukkit.Bukkit;
import org.bukkit.Location;
public class VersionHelper {

View File

@@ -60,4 +60,7 @@ public interface CustomInterface {
void addFrameStage(ItemFrame itemFrame, String stage, boolean rotate);
void addWireStage(Location seedLoc, String stage);
@Nullable
String getEntityID(Entity entity);
}

View File

@@ -143,4 +143,12 @@ public class ItemsAdderHook implements CustomInterface {
placeWire(seedLoc, stage);
});
}
@Override
@Nullable
public String getEntityID(Entity entity) {
CustomFurniture customFurniture = CustomFurniture.byAlreadySpawned(entity);
if (customFurniture == null) return null;
return customFurniture.getNamespacedID();
}
}

View File

@@ -17,14 +17,11 @@
package net.momirealms.customcrops.integrations.customplugin.oraxen;
import dev.lone.itemsadder.api.CustomBlock;
import dev.lone.itemsadder.api.CustomStack;
import io.th0rgal.oraxen.api.OraxenBlocks;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.api.events.OraxenFurnitureBreakEvent;
import io.th0rgal.oraxen.api.events.OraxenFurnitureInteractEvent;
import io.th0rgal.oraxen.api.events.OraxenNoteBlockBreakEvent;
import io.th0rgal.oraxen.api.events.OraxenNoteBlockInteractEvent;
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory;
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic;
@@ -40,6 +37,7 @@ import net.momirealms.customcrops.objects.Sprinkler;
import net.momirealms.customcrops.utils.AdventureUtil;
import net.momirealms.customcrops.utils.FurnitureUtil;
import net.momirealms.customcrops.utils.MiscUtils;
import org.bukkit.BanList;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;

View File

@@ -136,6 +136,8 @@ public abstract class OraxenHandler extends HandlerP {
if (block == null) return;
if (!CCAntiGrief.testPlace(player, block.getLocation())) return;
if (event.getBlockFace() == BlockFace.UP && placeSprinkler(id, block.getLocation(), player, item)) {
return;
}

View File

@@ -37,6 +37,7 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ItemFrame;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.Nullable;
@@ -139,4 +140,11 @@ public class OraxenHook implements CustomInterface {
public void addWireStage(Location seedLoc, String stage) {
Bukkit.getScheduler().runTask(CustomCrops.plugin, () -> placeWire(seedLoc, stage));
}
@Override
@Nullable
public String getEntityID(Entity entity) {
PersistentDataContainer pdc = entity.getPersistentDataContainer();
return pdc.get(FURNITURE, PersistentDataType.STRING);
}
}

View File

@@ -17,9 +17,11 @@
package net.momirealms.customcrops.integrations.customplugin.oraxen;
import io.th0rgal.oraxen.api.OraxenBlocks;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.api.events.*;
import io.th0rgal.oraxen.api.events.OraxenFurnitureBreakEvent;
import io.th0rgal.oraxen.api.events.OraxenFurnitureInteractEvent;
import io.th0rgal.oraxen.api.events.OraxenNoteBlockBreakEvent;
import io.th0rgal.oraxen.api.events.OraxenStringBlockBreakEvent;
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureFactory;
import io.th0rgal.oraxen.mechanics.provided.gameplay.furniture.FurnitureMechanic;
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanic;

View File

@@ -0,0 +1,17 @@
package net.momirealms.customcrops.integrations.item;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import org.apache.commons.lang.StringUtils;
import org.bukkit.inventory.ItemStack;
public class MMOItemsHook {
public static ItemStack get(String id) {
id = id.substring(9);
String[] split = StringUtils.split(id, ":");
MMOItem mmoItem = MMOItems.plugin.getMMOItem(Type.get(split[0]), split[1]);
return mmoItem == null ? null : mmoItem.newBuilder().build();
}
}

View File

@@ -0,0 +1,20 @@
package net.momirealms.customcrops.integrations.item;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.core.items.ItemExecutor;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
public class MythicMobsHook {
private static ItemExecutor itemManager;
@Nullable
public static ItemStack get(String id) {
id = id.substring(11);
if (itemManager == null) {
itemManager = MythicBukkit.inst().getItemManager();
}
return itemManager.getItemStack(id);
}
}

View File

@@ -0,0 +1,47 @@
/*
* 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.customcrops.integrations.protection;
import com.bgsoftware.superiorskyblock.api.SuperiorSkyblockAPI;
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.island.IslandPrivilege;
import net.momirealms.customcrops.integrations.CCAntiGrief;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class SuperiorSkyBlockHook implements CCAntiGrief {
@Override
public String getName() {
return "SuperiorSkyBlock";
}
@Override
public boolean canBreak(Location location, Player player) {
Island island = SuperiorSkyblockAPI.getIslandAt(location);
if (island == null) return true;
return island.hasPermission(SuperiorSkyblockAPI.getPlayer(player), IslandPrivilege.getByName("BREAK"));
}
@Override
public boolean canPlace(Location location, Player player) {
Island island = SuperiorSkyblockAPI.getIslandAt(location);
if (island == null) return true;
return island.hasPermission(SuperiorSkyblockAPI.getPlayer(player), IslandPrivilege.getByName("BUILD"));
}
}

View File

@@ -31,6 +31,8 @@ import net.momirealms.customcrops.integrations.customplugin.itemsadder.ItemsAdde
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenFrameHandler;
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenHook;
import net.momirealms.customcrops.integrations.customplugin.oraxen.OraxenWireHandler;
import net.momirealms.customcrops.integrations.item.MMOItemsHook;
import net.momirealms.customcrops.integrations.item.MythicMobsHook;
import net.momirealms.customcrops.integrations.season.InternalSeason;
import net.momirealms.customcrops.integrations.season.RealisticSeasonsHook;
import net.momirealms.customcrops.integrations.season.SeasonInterface;
@@ -400,6 +402,8 @@ public class CropManager extends Function {
private ItemStack getLoot(String id) {
if (id == null) return null;
if (MiscUtils.isVanillaItem(id)) return new ItemStack(Material.valueOf(id));
else if (id.startsWith("MMOItems:")) return MMOItemsHook.get(id);
else if (id.startsWith("MythicMobs:")) return MythicMobsHook.get(id);
else return customInterface.getItemStack(id);
}

View File

@@ -1,6 +1,6 @@
# Don't change
# 请不要修改
config-version: '22'
config-version: '23'
metrics: true
# lang: english / spanish / chinese
lang: english
@@ -19,6 +19,7 @@ integration:
CrashClaim: false
BentoBox: false
IridiumSkyblock: false
SuperiorSkyBlock: false
# Skill Xp
# 技能经验
AureliumSkills: false

View File

@@ -9,6 +9,8 @@ tomato:
quality-loots:
amount: 1~4
quality:
# MMOItems:TYPE:ID
# MythicMobs:id
1: customcrops:tomato
2: customcrops:tomato_silver_star
3: customcrops:tomato_golden_star

View File

@@ -7,6 +7,8 @@ tomato:
quality-loots:
amount: 1~4
quality:
# MMOItems:TYPE:ID
# MythicMobs:id
1: tomato
2: tomato_silver_star
3: tomato_golden_star

View File

@@ -25,6 +25,7 @@ softdepend:
- RealisticSeasons
- Jobs
- IridiumSkyblock
- SuperiorSkyBlock2
commands:
customcrops:
usage: /customcrops <args>