Skip to content

Commit

Permalink
Merge pull request #23 from Sefiraat/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Sefiraat authored Nov 19, 2021
2 parents 48d4461 + 0a1e25d commit 34696cf
Show file tree
Hide file tree
Showing 19 changed files with 2,890 additions and 1,893 deletions.
41 changes: 29 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>mcmmo-repo</id>
<url>https://nexus.neetgames.com/repository/maven-public</url>
</repository>
</repositories>

<build>
Expand Down Expand Up @@ -101,6 +105,7 @@
</build>

<dependencies>
<!-- Core -->
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
Expand All @@ -113,18 +118,8 @@
<version>b8f7dc</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>ExoticGarden</artifactId>
<version>a2c4b6d</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.mooy1</groupId>
<artifactId>InfinityLib</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>

<!-- Tools etc. -->
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
Expand All @@ -142,6 +137,28 @@
<version>1.18.20</version>
<scope>provided</scope>
</dependency>

<!-- Supported Plugins -->
<dependency>
<groupId>com.github.TheBusyBiscuit</groupId>
<artifactId>ExoticGarden</artifactId>
<version>a2c4b6d</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.202</version>
<scope>provided</scope>
</dependency>

<!-- To be removed, do not use further -->
<dependency>
<groupId>io.github.mooy1</groupId>
<artifactId>InfinityLib</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.elmakers.mine.bukkit</groupId>
<artifactId>EffectLib</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.github.sefiraat.crystamaehistoria.commands.OpenSpellCompendium;
import io.github.sefiraat.crystamaehistoria.commands.OpenStoryCompendium;
import io.github.sefiraat.crystamaehistoria.commands.TestSpell;
import io.github.sefiraat.crystamaehistoria.commands.TestWand;
import io.github.sefiraat.crystamaehistoria.config.ConfigManager;
import io.github.sefiraat.crystamaehistoria.listeners.ListenerManager;
import io.github.sefiraat.crystamaehistoria.magic.CastInformation;
Expand All @@ -16,7 +17,6 @@
import io.github.sefiraat.crystamaehistoria.magic.spells.spellobjects.MagicSummon;
import io.github.sefiraat.crystamaehistoria.player.PlayerStatistics;
import io.github.sefiraat.crystamaehistoria.runnables.RunnableManager;
import io.github.sefiraat.crystamaehistoria.runnables.spells.SpellTickRunnable;
import io.github.sefiraat.crystamaehistoria.slimefun.Gadgets;
import io.github.sefiraat.crystamaehistoria.slimefun.ItemGroups;
import io.github.sefiraat.crystamaehistoria.slimefun.Materials;
Expand Down Expand Up @@ -46,6 +46,7 @@ public class CrystamaeHistoria extends AbstractAddon {
private RunnableManager runnableManager;
private SpellMemory spellMemory;
private EffectManager effectManager;
private SupportedPluginManager supportedPluginManager;

public CrystamaeHistoria() {
super("Sefiraat", "CrystamaeHistoria", "master", "auto-update");
Expand All @@ -55,6 +56,14 @@ public static CrystamaeHistoria getInstance() {
return instance;
}

public static ConfigManager getConfigManager() {
return instance.configManager;
}

public static StoriesManager getStoriesManager() {
return instance.storiesManager;
}

public static ListenerManager getListenerManager() {
return instance.listenerManager;
}
Expand All @@ -63,10 +72,6 @@ public static RunnableManager getRunnableManager() {
return instance.runnableManager;
}

public static StoriesManager getStoriesManager() {
return instance.storiesManager;
}

public static SpellMemory getSpellMemory() {
return instance.spellMemory;
}
Expand All @@ -75,8 +80,8 @@ public static EffectManager getEffectManager() {
return instance.effectManager;
}

public static ConfigManager getConfigManager() {
return instance.configManager;
public static SupportedPluginManager getSupportedPluginManager() {
return instance.supportedPluginManager;
}

public static PluginManager getPluginManager() {
Expand Down Expand Up @@ -127,11 +132,6 @@ public static CastInformation getStrikeCastInfo(UUID lightningStrike) {
return castInformation;
}

@Nonnull
public static Map<SpellTickRunnable, Integer> getTickingMap() {
return instance.spellMemory.getTickingCastables();
}

@Override
public void enable() {
instance = this;
Expand All @@ -145,6 +145,7 @@ public void enable() {
this.listenerManager = new ListenerManager();
this.runnableManager = new RunnableManager();
this.spellMemory = new SpellMemory();
this.supportedPluginManager = new SupportedPluginManager();
this.effectManager = new EffectManager(this);

configManager.loadConfig();
Expand All @@ -156,6 +157,7 @@ public void enable() {
setupBstats();

getAddonCommand().addSub(new TestSpell());
getAddonCommand().addSub(new TestWand());
getAddonCommand().addSub(new OpenSpellCompendium());
getAddonCommand().addSub(new OpenStoryCompendium());
getAddonCommand().addSub(new GetRanks());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package io.github.sefiraat.crystamaehistoria;

import com.gmail.nossr50.util.skills.CombatUtils;
import io.github.thebusybiscuit.exoticgarden.items.BonemealableItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import lombok.Getter;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;

import javax.annotation.Nullable;

@Getter
public class SupportedPluginManager {

private final boolean mcMMO;
private final boolean exoticGarden;
private final boolean slimeTinker;

public SupportedPluginManager() {
mcMMO = Bukkit.getPluginManager().isPluginEnabled("mcMMO");
exoticGarden = Bukkit.getPluginManager().isPluginEnabled("ExoticGarden");
slimeTinker = Bukkit.getPluginManager().isPluginEnabled("SlimeTinker");
}

/**
* Damaging an entity and attributing to a player will make mcMMO give exp based
* on the held item. If mcMMO is installed, we need to flag the entity to be ignored
* briefly.
*
* @param livingEntity The {@link LivingEntity} to be damaged
* @param player The {@link Player} to attribute the damage/drops to
* @param damage The damage to apply
*/
public void playerDamageWithoutMcMMO(LivingEntity livingEntity, Player player, double damage) {
markEntityMcMMOIgnoreDamage(livingEntity);
livingEntity.damage(damage, player);
clearEntityMcMMOIgnoreDamage(livingEntity);
}

public void markEntityMcMMOIgnoreDamage(LivingEntity livingEntity) {
if (mcMMO) CombatUtils.applyIgnoreDamageMetadata(livingEntity);
}

public void clearEntityMcMMOIgnoreDamage(LivingEntity livingEntity) {
if (mcMMO) CombatUtils.removeIgnoreDamageMetadata(livingEntity);
}

public boolean isExoticGardenPlant(Block block) {
return exoticGarden
&& BlockStorage.hasBlockInfo(block)
&& BlockStorage.check(block) instanceof BonemealableItem;
}

/**
* Gets the SlimefunItem for the ExoticPlant if it exists
*
* @param block The {@link Block} to check
* @return Returns null if there is not a plant (or Exotic is not installed) or the
* the SlimefunItem if applicable.
*/
@Nullable
public SlimefunItem getExoticGardenPlant(Block block) {
if (exoticGarden && BlockStorage.hasBlockInfo(block)) {
SlimefunItem slimefunItem = BlockStorage.check(block);
if (slimefunItem instanceof BonemealableItem) {
return slimefunItem;
}
}
return null;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package io.github.sefiraat.crystamaehistoria.commands;

import io.github.mooy1.infinitylib.commands.SubCommand;
import io.github.sefiraat.crystamaehistoria.magic.SpellType;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.InstancePlate;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.InstanceStave;
import io.github.sefiraat.crystamaehistoria.slimefun.Tools;
import io.github.sefiraat.crystamaehistoria.slimefun.tools.stave.SpellSlot;
import io.github.sefiraat.crystamaehistoria.utils.Keys;
import io.github.sefiraat.crystamaehistoria.utils.datatypes.DataTypeMethods;
import io.github.sefiraat.crystamaehistoria.utils.datatypes.PersistentStaveDataType;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.List;
import java.util.Map;

public class TestWand extends SubCommand {

public TestWand() {
super("test-wand", "gives a wand with the selected spell", true);
}

@Override
@ParametersAreNonnullByDefault
protected void execute(CommandSender sender, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (args.length != 2) {
return;
}
int power = Integer.parseInt(args[1]);
if (power <= 2) {
ItemStack stave;
if (power == 1) {
stave = Tools.getStaveBasic().getItem().clone();
} else if (power == 2) {
stave = Tools.getStaveAdvanced().getItem().clone();
} else {
return;
}

final InstanceStave staveInstance = new InstanceStave(stave);
final Map<SpellSlot, InstancePlate> map = staveInstance.getSpellInstanceMap();
final InstancePlate plateInstance = new InstancePlate(1, SpellType.valueOf(args[0]), 9999);
map.put(SpellSlot.LEFT_CLICK, plateInstance);
ItemMeta itemMeta = stave.getItemMeta();
DataTypeMethods.setCustom(
itemMeta,
Keys.PDC_STAVE_STORAGE,
PersistentStaveDataType.TYPE,
staveInstance.getSpellInstanceMap()
);
stave.setItemMeta(itemMeta);
staveInstance.buildLore();
player.getInventory().addItem(stave);
}
}
}

@Override
@ParametersAreNonnullByDefault
protected void complete(CommandSender commandSender, String[] strings, List<String> list) {
if (strings.length == 1) {
for (SpellType spell : SpellType.getEnabledSpells()) {
list.add(spell.name());
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Chaos extends Spell {
public Chaos() {
SpellCoreBuilder spellCoreBuilder = new SpellCoreBuilder(10, true, 6, false, 50, true)
.makeDamagingSpell(1, false, 0.2, false)
.makeProjectileSpell(this::cast, 0, false, 0.2, false)
.makeProjectileSpell(this::cast, 0, false, 0, false)
.makeProjectileVsEntitySpell(this::onHitEntity)
.makeProjectileVsBlockSpell(this::onHitBlock)
.makeTickingSpell(this::cast, 10, true, 5, false);
Expand Down Expand Up @@ -71,9 +71,7 @@ public void onHitEntity(CastInformation castInformation) {
GeneralUtils.damageEntity(
castInformation.getMainTarget(),
castInformation.getCaster(),
getDamage(castInformation),
castInformation.getDamageLocation(),
getProjectileKnockback(castInformation)
getDamage(castInformation)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryType;
import io.github.sefiraat.crystamaehistoria.utils.ParticleUtils;
import io.github.sefiraat.crystamaehistoria.utils.SpellUtils;
import io.github.sefiraat.crystamaehistoria.utils.mobgoals.FlyingPhantomGoal;
import io.github.sefiraat.crystamaehistoria.utils.mobgoals.FlyingBatGoal;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
Expand Down Expand Up @@ -41,7 +41,7 @@ public void cast(CastInformation castInformation) {
EntityType.BAT,
caster,
spawnLocation,
new FlyingPhantomGoal(caster),
new FlyingBatGoal(caster),
castInformation.getStaveLevel() * 300,
this::onTick
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class StarFall extends Spell {
public StarFall() {
SpellCoreBuilder spellCoreBuilder = new SpellCoreBuilder(100, true, 7, true, 40, true)
.makeDamagingSpell(2, true, 0.5, false)
.makeProjectileSpell(this::fireProjectiles, 1, true, 0.5, true)
.makeProjectileSpell(this::fireProjectiles, 1, true, 0, false)
.makeProjectileVsEntitySpell(this::projectileHits)
.makeProjectileVsBlockSpell(this::projectileHits)
.makeTickingSpell(this::fireProjectiles, 9, false, 10, false);
Expand Down Expand Up @@ -59,9 +59,7 @@ public void projectileHits(CastInformation castInformation) {
GeneralUtils.damageEntity(
livingEntity,
castInformation.getCaster(),
getDamage(castInformation),
castInformation.getDamageLocation(),
getProjectileKnockback(castInformation)
getDamage(castInformation)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public static BlockRank getBlockRank(UUID uuid, BlockDefinition definition) {
public static int getStoriesUnlocked(@Nonnull UUID uuid) {
String path = MessageFormat.format("{0}.{1}", uuid, StatType.STORY);
ConfigurationSection section = CrystamaeHistoria.getConfigManager().getPlayerStats().getConfigurationSection(path);
if (section == null) {
return 0;
}
int unlocked = 0;
for (String story : section.getKeys(false)) {
String storyPath = MessageFormat.format("{0}.{1}.{2}.UNLOCKED", uuid, StatType.STORY, story);
Expand Down Expand Up @@ -158,6 +161,9 @@ public static String getStoryRankString(@Nonnull UUID uuid) {
public static int getSpellsUnlocked(@Nonnull UUID uuid) {
String path = MessageFormat.format("{0}.{1}", uuid, StatType.SPELL);
ConfigurationSection section = CrystamaeHistoria.getConfigManager().getPlayerStats().getConfigurationSection(path);
if (section == null) {
return 0;
}
int unlocked = 0;
for (String spell : section.getKeys(false)) {
String storyPath = MessageFormat.format("{0}.{1}.{2}.UNLOCKED", uuid, StatType.SPELL, spell);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.github.sefiraat.crystamaehistoria.slimefun.gadgets.MobMat;
import io.github.sefiraat.crystamaehistoria.slimefun.gadgets.MysteriousTicker;
import io.github.sefiraat.crystamaehistoria.slimefun.gadgets.TrophyDisplay;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.DisplayStandHolder;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.DummyLiquefactionBasinCrafting;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasinCache;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.RecipeItem;
Expand Down
Loading

0 comments on commit 34696cf

Please sign in to comment.