Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into merge-upstream
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/dev/sefiraat/netheopoiesis/Netheopoiesis.java
#	src/main/java/dev/sefiraat/netheopoiesis/implementation/Groups.java
#	src/main/java/dev/sefiraat/netheopoiesis/implementation/groups/PurificationFlexGroup.java
#	src/main/java/dev/sefiraat/netheopoiesis/utils/Theme.java
  • Loading branch information
ybw0014 committed Jun 17, 2022
2 parents 2377708 + eddcfe4 commit 7006a82
Show file tree
Hide file tree
Showing 45 changed files with 2,242 additions and 111 deletions.
26 changes: 13 additions & 13 deletions src/main/java/dev/sefiraat/netheopoiesis/Netheopoiesis.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package dev.sefiraat.netheopoiesis;

import dev.sefiraat.netheopoiesis.api.plant.netheos.NetheoBalls;
import dev.sefiraat.netheopoiesis.implementation.Items;
import dev.sefiraat.netheopoiesis.managers.ConfigManager;
import dev.sefiraat.netheopoiesis.managers.ListenerManager;
import dev.sefiraat.netheopoiesis.managers.MobManager;
import dev.sefiraat.netheopoiesis.managers.RunnableManager;
import dev.sefiraat.netheopoiesis.managers.TaskManager;
import dev.sefiraat.netheopoiesis.managers.SupportedPluginManager;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import net.guizhanss.guizhanlib.updater.GuizhanBuildsUpdater;
Expand All @@ -31,10 +32,10 @@ public class Netheopoiesis extends JavaPlugin implements SlimefunAddon {
private ConfigManager configManager;
private SupportedPluginManager supportedPluginManager;
private ListenerManager listenerManager;
private RunnableManager runnableManager;
private TaskManager taskManager;
private MobManager mobManager;
private Purification purification;
private PlantRegistry plantRegistry;
private Registry registry;

public Netheopoiesis() {
this.username = "SlimefunGuguProject";
Expand All @@ -51,17 +52,18 @@ public void onEnable() {
getLogger().info("########################################");

saveDefaultConfig();
this.configManager = new ConfigManager();
tryUpdate();

this.configManager = new ConfigManager();
this.supportedPluginManager = new SupportedPluginManager();
this.listenerManager = new ListenerManager();
this.runnableManager = new RunnableManager();
this.taskManager = new TaskManager();
this.mobManager = new MobManager();
this.purification = new Purification();
this.plantRegistry = new PlantRegistry();
this.registry = new Registry();

Items.setup(this);
NetheoBalls.setup();

setupStats();
}
Expand All @@ -73,9 +75,7 @@ public void onDisable() {
}

public void tryUpdate() {
if (getConfig().getBoolean("auto-update")
&& getDescription().getVersion().startsWith("Build")
) {
if (configManager.isAutoUpdate() && getDescription().getVersion().startsWith("Build")) {
new GuizhanBuildsUpdater(this, getFile(), username, repo, branch, false, "zh-CN").start();
}
}
Expand Down Expand Up @@ -129,8 +129,8 @@ public static ListenerManager getListenerManager() {
return Netheopoiesis.getInstance().listenerManager;
}

public static RunnableManager getRunnableManager() {
return Netheopoiesis.getInstance().runnableManager;
public static TaskManager getRunnableManager() {
return Netheopoiesis.getInstance().taskManager;
}

public static MobManager getMobManager() {
Expand All @@ -141,7 +141,7 @@ public static Purification getPurificationMemory() {
return Netheopoiesis.getInstance().purification;
}

public static PlantRegistry getPlantRegistry() {
return Netheopoiesis.getInstance().plantRegistry;
public static Registry getPlantRegistry() {
return Netheopoiesis.getInstance().registry;
}
}
1 change: 1 addition & 0 deletions src/main/java/dev/sefiraat/netheopoiesis/Purification.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class Purification {
public static final int SPAWN_TROPICAL_FISH = 1000;
public static final int SPAWN_AXOLOTL = 1000;
public static final int WANDERING_TRADER = 1500;
public static final int WANDERING_PIGLIN = 1500;

// Regeneration
public static final int REGEN_1 = 500;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
package dev.sefiraat.netheopoiesis;

import com.google.common.base.Preconditions;
import dev.sefiraat.netheopoiesis.api.plant.breeding.BreedResult;
import dev.sefiraat.netheopoiesis.api.plant.breeding.BreedResultType;
import dev.sefiraat.netheopoiesis.api.plant.breeding.BreedingPair;
import dev.sefiraat.netheopoiesis.api.items.BiomeSpreadingSeed;
import dev.sefiraat.netheopoiesis.api.items.CruxSpreadingSeed;
import dev.sefiraat.netheopoiesis.api.items.DroppingSeed;
import dev.sefiraat.netheopoiesis.api.items.EntitySpawningSeed;
import dev.sefiraat.netheopoiesis.api.items.GenericTickingSeed;
import dev.sefiraat.netheopoiesis.api.items.HarvestableSeed;
import dev.sefiraat.netheopoiesis.api.items.NetherSeed;
import dev.sefiraat.netheopoiesis.api.plant.breeding.BreedResult;
import dev.sefiraat.netheopoiesis.api.plant.breeding.BreedResultType;
import dev.sefiraat.netheopoiesis.api.plant.breeding.BreedingPair;
import dev.sefiraat.netheopoiesis.api.plant.netheos.Trade;
import dev.sefiraat.netheopoiesis.utils.TextUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Piglin;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;
Expand All @@ -23,18 +25,25 @@
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.UUID;

public class PlantRegistry {
public class Registry {

private static PlantRegistry instance;
private static Registry instance;

@Nonnull
private final List<NetherSeed> registeredPlants = new ArrayList<>();
@Nonnull
private final List<BreedingPair> breedingPairs = new ArrayList<>();
@Nonnull
private final List<Trade> trades = new ArrayList<>();

public PlantRegistry() {
Preconditions.checkArgument(instance == null, "Cannot create a new instance of the PlantRegistry");
public Registry() {
Preconditions.checkArgument(instance == null, "Cannot create a new instance of the Registry");
instance = this;
}

Expand All @@ -43,6 +52,10 @@ public void addPlant(@Nonnull NetherSeed netherSeed) {
this.breedingPairs.addAll(netherSeed.getBreedingPairs());
}

public void addTrade(@Nonnull Trade trade) {
this.trades.add(trade);
}

@Nonnull
public BreedResult getBreedResult(@Nonnull String seed1, @Nonnull String seed2) {
int matches = 0;
Expand All @@ -69,6 +82,11 @@ public List<BreedingPair> getBreedingPairs() {
return Collections.unmodifiableList(breedingPairs);
}

@Nonnull
public List<Trade> getTrades() {
return trades;
}

/**
* Should never be used in ac production environment - this method will output all plant details
* into .md files for GitBook
Expand Down Expand Up @@ -164,7 +182,7 @@ public void printRegistry() {
}
}

public static PlantRegistry getInstance() {
public static Registry getInstance() {
return instance;
}
}
75 changes: 75 additions & 0 deletions src/main/java/dev/sefiraat/netheopoiesis/api/RecipeTypes.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package dev.sefiraat.netheopoiesis.api;

import com.google.common.base.Preconditions;
import dev.sefiraat.netheopoiesis.api.interfaces.WorldCrushable;
import dev.sefiraat.netheopoiesis.listeners.DropListener;
import dev.sefiraat.netheopoiesis.utils.Keys;
import dev.sefiraat.netheopoiesis.utils.Theme;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;

Expand Down Expand Up @@ -70,4 +75,74 @@ private RecipeTypes() {
"通过破坏方块获得."
)
);

@Nonnull
public static final RecipeType CRUSHING = new RecipeType(
Keys.newKey("crushing"),
Theme.themedItemStack(
Material.ANVIL,
Theme.RECIPE_TYPE,
"Tough Crushing",
"This item is made by crushing it.",
"To crush items, from an Anvil on it from",
"a height."
)
);

@Nonnull
public static final RecipeType NETHEO_MIXING = new RecipeType(
Keys.newKey("netheo-mixing"),
Theme.themedItemStack(
Material.QUARTZ,
Theme.RECIPE_TYPE,
"Netheo Mixing",
"This item is made by mixing three",
"Netheo pastes together.",
"Throw the three pastes onto the ground",
"and then right click with a Mixing Quartz."
)
);

/**
* This method both registers the drop and returns an ItemStack array that can be used
* for Slimefun's recipe system. {@link RecipeTypes#VANILLA_DROP}
*
* @param stackToDrop The {@link ItemStack} to drop in the world
* @param dropFrom The {@link ItemStack} to drop from (#getType() is used) and the stack is used in the recipe.
* @param dropChance The chance (0-1) for the drop to occur
* @return A {@link ItemStack[]} used for Slimefun's Recipe registration with the dropFrom item in the middle.
*/
@Nonnull
public static ItemStack[] createWorldDropRecipe(@Nonnull ItemStack stackToDrop,
@Nonnull ItemStack dropFrom,
double dropChance
) {
final Material material = dropFrom.getType();
DropListener.getDropMap().put(material, new DropListener.BlockDrop(stackToDrop, material, dropChance));
return new ItemStack[]{
null, null, null,
null, dropFrom, null,
null, null, null
};
}

/**
* This method returns an ItemStack array that can be used for Slimefun's recipe system.
*
* @param dropFrom The {@link SlimefunItem} (must implement WorldCrushable) to drop from.
* @return A {@link ItemStack[]} used for Slimefun's Recipe registration with the dropFrom item in the middle.
* @see RecipeTypes#CRUSHING
*/
@Nonnull
public static ItemStack[] createCrushingRecipe(@Nonnull SlimefunItem dropFrom) {
Preconditions.checkArgument(
dropFrom instanceof WorldCrushable,
"A crushing recipe item must implement WorldCrushable"
);
return new ItemStack[]{
null, null, null,
null, dropFrom.getItem(), null,
null, null, null
};
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.sefiraat.netheopoiesis.api.interfaces;

import dev.sefiraat.netheopoiesis.implementation.plant.GrowthStages;
import dev.sefiraat.netheopoiesis.api.items.NetherCrux;
import dev.sefiraat.netheopoiesis.api.items.NetherSeed;
import dev.sefiraat.netheopoiesis.implementation.plant.GrowthStages;
import dev.sefiraat.netheopoiesis.utils.Skulls;
import dev.sefiraat.netheopoiesis.utils.Theme;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dev.sefiraat.netheopoiesis.api.interfaces;

import dev.sefiraat.netheopoiesis.api.plant.netheos.FlavourProfile;

import javax.annotation.Nullable;

/**
* A SeedPaste item a {@link WorldCrushable} item whose crushed variant can be used for making
* Malvin Cubes
*/
public interface SeedPaste extends WorldCrushable {

@Nullable
FlavourProfile getFlavourProfile();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package dev.sefiraat.netheopoiesis.api.interfaces;

import org.bukkit.inventory.ItemStack;

import javax.annotation.Nullable;

/**
* A WorldCrushable item is one that will be destroyed when crushed by a falling block
* but drop a 'crushed' version of itself.
*/
public interface WorldCrushable {

/**
* This is the {@link ItemStack} that should drop when this item is crushed
*
* @return The {@link ItemStack} to drop.
*/
@Nullable
ItemStack crushingDrop();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dev.sefiraat.netheopoiesis.api.items;

import dev.sefiraat.netheopoiesis.api.interfaces.PurifyingObject;
import dev.sefiraat.netheopoiesis.api.RecipeTypes;
import dev.sefiraat.netheopoiesis.api.interfaces.PurifyingObject;
import dev.sefiraat.netheopoiesis.implementation.Stacks;
import dev.sefiraat.netheopoiesis.implementation.plant.Placements;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
Expand Down Expand Up @@ -49,7 +49,8 @@ public void onPlayerBreak(BlockBreakEvent event, ItemStack item, List<ItemStack>
// We do not want crux' to be able to drop and placed elsewhere thus gaming the system
final Block block = event.getBlock();
final ItemStack heldItem = event.getPlayer().getInventory().getItemInMainHand();
if (!SlimefunItem.getByItem(heldItem).getId().equals(Stacks.CRUX_GATHERER.getItemId())) {
final SlimefunItem slimefunItem = SlimefunItem.getByItem(heldItem);
if (slimefunItem == null || !slimefunItem.getId().equals(Stacks.CRUX_GATHERER.getItemId())) {
event.setCancelled(true);
block.setType(Material.AIR);
BlockStorage.clearBlockInfo(block);
Expand Down
Loading

0 comments on commit 7006a82

Please sign in to comment.