Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
# Conflicts:
#	dependency-reduced-pom.xml
#	pom.xml
  • Loading branch information
ybw0014 committed Jun 16, 2022
2 parents 57a7ac7 + a47271d commit d8b77c4
Show file tree
Hide file tree
Showing 61 changed files with 900 additions and 235 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@
<version>0.9.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>

<!-- Supported Plugins -->

Expand Down
11 changes: 9 additions & 2 deletions src/main/java/dev/sefiraat/netheopoiesis/Netheopoiesis.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package dev.sefiraat.netheopoiesis;


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.SupportedPluginManager;
import dev.sefiraat.netheopoiesis.slimefun.Items;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import net.guizhanss.guizhanlib.updater.GuizhanBuildsUpdater;
import org.bstats.bukkit.Metrics;
Expand All @@ -32,6 +32,7 @@ public class Netheopoiesis extends JavaPlugin implements SlimefunAddon {
private SupportedPluginManager supportedPluginManager;
private ListenerManager listenerManager;
private RunnableManager runnableManager;
private MobManager mobManager;
private Purification purification;
private PlantRegistry plantRegistry;

Expand All @@ -56,6 +57,7 @@ public void onEnable() {
this.supportedPluginManager = new SupportedPluginManager();
this.listenerManager = new ListenerManager();
this.runnableManager = new RunnableManager();
this.mobManager = new MobManager();
this.purification = new Purification();
this.plantRegistry = new PlantRegistry();

Expand All @@ -66,6 +68,7 @@ public void onEnable() {

@Override
public void onDisable() {
this.mobManager.shutdown();
this.configManager.saveAll();
}

Expand Down Expand Up @@ -130,6 +133,10 @@ public static RunnableManager getRunnableManager() {
return Netheopoiesis.getInstance().runnableManager;
}

public static MobManager getMobManager() {
return Netheopoiesis.getInstance().mobManager;
}

public static Purification getPurificationMemory() {
return Netheopoiesis.getInstance().purification;
}
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/dev/sefiraat/netheopoiesis/PlantRegistry.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package dev.sefiraat.netheopoiesis;

import com.google.common.base.Preconditions;
import dev.sefiraat.netheopoiesis.core.plant.breeding.BreedResult;
import dev.sefiraat.netheopoiesis.core.plant.breeding.BreedResultType;
import dev.sefiraat.netheopoiesis.core.plant.breeding.BreedingPair;
import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.BiomeSpreadingSeed;
import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.CruxSpreadingSeed;
import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.DroppingSeed;
import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.EntitySpawningSeed;
import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.GenericTickingSeed;
import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.HarvestableSeed;
import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.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.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.utils.TextUtils;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;
Expand All @@ -34,7 +34,7 @@ public class PlantRegistry {
private final List<BreedingPair> breedingPairs = new ArrayList<>();

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

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/dev/sefiraat/netheopoiesis/Purification.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class Purification {
private final Map<ChunkPosition, Integer> chunkValues = new HashMap<>();

public Purification() {
Preconditions.checkNotNull(instance == null, "Cannot create a new instance of Purification");
Preconditions.checkArgument(instance == null, "Cannot create a new instance of Purification");
instance = this;
Bukkit.getScheduler().runTaskTimer(Netheopoiesis.getInstance(), this::collateChunkValues, 1, 100);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.sefiraat.netheopoiesis.slimefun;
package dev.sefiraat.netheopoiesis.api;

import dev.sefiraat.netheopoiesis.utils.Keys;
import dev.sefiraat.netheopoiesis.utils.Theme;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package dev.sefiraat.netheopoiesis.api.events;

import dev.sefiraat.netheopoiesis.api.items.NetherCrux;
import dev.sefiraat.netheopoiesis.api.items.NetherSeed;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

/**
* This event is fired when a Crux is due to spread to another block
*
* @see dev.sefiraat.netheopoiesis.api.items.CruxSpreadingSeed
* @see dev.sefiraat.netheopoiesis.implementation.flora.PurificationSeed
*/
public class CruxSpreadEvent extends Event implements Cancellable {

private static final HandlerList HANDLER_LIST = new HandlerList();

@Nonnull
private final Block block;
@Nonnull
private final NetherSeed growingPlant;
@Nonnull
private final NetherCrux crux;
private boolean cancelled;

@ParametersAreNonnullByDefault
public CruxSpreadEvent(Block block, NetherSeed growingPlant, NetherCrux crux) {
this.block = block;
this.growingPlant = growingPlant;
this.crux = crux;
}

@Override
public boolean isCancelled() {
return this.cancelled;
}

@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}

@Nonnull
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}

/**
* @return The {@link Block} of the potential new crux
*/
@Nonnull
public Block getBlock() {
return block;
}

/**
* @return The {@link NetherSeed} that the growth originated from
*/
@Nonnull
public NetherSeed getGrowingPlant() {
return growingPlant;
}

/**
* @return The crux type that will be spread
*/
@Nonnull
public NetherCrux getCrux() {
return crux;
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
package dev.sefiraat.netheopoiesis.events;
package dev.sefiraat.netheopoiesis.api.events;

import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.NetherSeed;
import dev.sefiraat.netheopoiesis.api.items.NetherSeed;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

/**
* This event is fired before a plant grows a stage. This event can be cancelled to stop growth
*
* @see NetherSeed
*/
public class PlantBeforeGrowthEvent extends Event implements Cancellable {

private static final HandlerList HANDLER_LIST = new HandlerList();

@Nonnull
private final Location location;
@Nonnull
private final NetherSeed growingPlant;
private final int growthStage;
private boolean cancelled;

@ParametersAreNonnullByDefault
public PlantBeforeGrowthEvent(Location location,
NetherSeed growingPlant,
int growthStage
) {
public PlantBeforeGrowthEvent(Location location, NetherSeed growingPlant, int growthStage) {
this.location = location;
this.growingPlant = growingPlant;
this.growthStage = growthStage;
Expand All @@ -40,6 +42,7 @@ public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}

@Nonnull
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
Expand All @@ -48,13 +51,15 @@ public HandlerList getHandlers() {
/**
* @return The {@link Location} of the currently growing plant
*/
@Nonnull
public Location getLocation() {
return location;
}

/**
* @return The {@link NetherSeed} that is about to grow
*/
@Nonnull
public NetherSeed getGrowingPlant() {
return growingPlant;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.sefiraat.netheopoiesis.core.plant;
package dev.sefiraat.netheopoiesis.api.interfaces;

import dev.sefiraat.netheopoiesis.core.purification.PurifyingObject;
import dev.sefiraat.netheopoiesis.slimefun.flora.blocks.NetherCrux;
import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.NetherSeed;
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.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
@@ -1,4 +1,4 @@
package dev.sefiraat.netheopoiesis.core.purification;
package dev.sefiraat.netheopoiesis.api.interfaces;

import dev.sefiraat.netheopoiesis.Purification;
import org.bukkit.block.Block;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dev.sefiraat.netheopoiesis.core.plant;
package dev.sefiraat.netheopoiesis.api.interfaces;

import dev.sefiraat.netheopoiesis.slimefun.flora.seeds.NetherSeed;
import dev.sefiraat.netheopoiesis.api.items.CruxSpreadingSeed;
import dev.sefiraat.netheopoiesis.api.items.NetherSeed;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import org.bukkit.Location;
import org.bukkit.block.Block;
Expand All @@ -10,7 +11,7 @@
/**
* This interface represents a plant that spreads out into BlockStorage
*
* @see dev.sefiraat.netheopoiesis.slimefun.flora.seeds.CruxSpreadingSeed
* @see CruxSpreadingSeed
*/
public interface SpreadingPlant {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.sefiraat.netheopoiesis.slimefun.flora.seeds;
package dev.sefiraat.netheopoiesis.api.items;

import dev.sefiraat.netheopoiesis.Netheopoiesis;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package dev.sefiraat.netheopoiesis.slimefun.flora.seeds;
package dev.sefiraat.netheopoiesis.api.items;

import com.google.common.base.Preconditions;
import dev.sefiraat.netheopoiesis.Netheopoiesis;
import dev.sefiraat.netheopoiesis.Purification;
import dev.sefiraat.netheopoiesis.core.plant.SpreadingPlant;
import dev.sefiraat.netheopoiesis.runnables.UpdateCruxTask;
import dev.sefiraat.netheopoiesis.slimefun.flora.blocks.NetherCrux;
import dev.sefiraat.netheopoiesis.api.events.CruxSpreadEvent;
import dev.sefiraat.netheopoiesis.api.interfaces.SpreadingPlant;
import dev.sefiraat.netheopoiesis.implementation.tasks.UpdateCruxTask;
import dev.sefiraat.netheopoiesis.utils.ProtectionUtils;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;

Expand Down Expand Up @@ -60,6 +62,20 @@ public void spread(Location sourceLocation, NetherSeed seed, Config data) {
&& getPlacements().contains(currentCrux.getId())
&& ProtectionUtils.hasPermission(getOwner(sourceLocation), block, Interaction.BREAK_BLOCK)
) {
final SlimefunItem slimefunItem = SlimefunItem.getByItem(convertTo);

if (!(slimefunItem instanceof NetherCrux crux)) {
// Not a crux, cannot spread - should not be reachable thanks to #setCrux()
return;
}

final CruxSpreadEvent event = new CruxSpreadEvent(block, this, crux);

Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
// Event cancelled - lets not spread
return;
}
BlockStorage.clearBlockInfo(block);
Purification.removeValue(block);
// Schedule a task to ensure the new block storage happens only AFTER deletion
Expand All @@ -77,6 +93,8 @@ public CruxSpreadingSeed setSpreadChance(double spreadChance) {

@Nonnull
public CruxSpreadingSeed setCrux(@Nonnull SlimefunItemStack crux) {
final SlimefunItem slimefunItem = SlimefunItem.getByItem(crux);
Preconditions.checkArgument(slimefunItem instanceof NetherCrux, "Set Crux MUST be a NetherCrux");
this.convertTo = crux;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.sefiraat.netheopoiesis.slimefun.flora.seeds;
package dev.sefiraat.netheopoiesis.api.items;

import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.sefiraat.netheopoiesis.slimefun.flora.seeds;
package dev.sefiraat.netheopoiesis.api.items;

import dev.sefiraat.netheopoiesis.Netheopoiesis;
import io.github.bakedlibs.dough.collections.RandomizedSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.sefiraat.netheopoiesis.slimefun.flora.seeds;
package dev.sefiraat.netheopoiesis.api.items;

import dev.sefiraat.netheopoiesis.Netheopoiesis;
import dev.sefiraat.netheopoiesis.utils.WorldUtils;
Expand Down Expand Up @@ -73,7 +73,7 @@ public EntitySpawningSeed setEntityType(@Nonnull EntityType entityType) {
return this;
}

@Nonnull
@Nullable
public EntityType getEntityType() {
return entityType;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package dev.sefiraat.netheopoiesis.slimefun.flora.seeds;
package dev.sefiraat.netheopoiesis.api.items;

import com.google.common.base.Preconditions;
import dev.sefiraat.netheopoiesis.Netheopoiesis;
import dev.sefiraat.netheopoiesis.implementation.GenericTickingMethods;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import org.bukkit.Location;
Expand Down
Loading

0 comments on commit d8b77c4

Please sign in to comment.