Skip to content

Commit

Permalink
Dev/v1 (#10)
Browse files Browse the repository at this point in the history
* Format, fixes and organisation

* Chaos and Break hardness + perms

* PhantomsFlight, Hearthstone, Tracer, Compass

* Gravity

* Crafting Recipes + tweaks

* Crafting fixes + Static loading

* Curifcation, New Textures, Fix Breaking Blocks

* Spell Disabling

* Imbue Void, PhilosophersStone, Fixes

* Cascada

* Strip mine

* Spells!
  • Loading branch information
Sefiraat authored Nov 4, 2021
1 parent 597fdc6 commit cf18ac7
Show file tree
Hide file tree
Showing 107 changed files with 2,913 additions and 731 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/textures/crystal_animal_sefi_blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/textures/crystal_celestial_sefi_white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/textures/crystal_elemental_sefi_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/textures/crystal_historical_sefi_green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/textures/crystal_human_sefi_teal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/textures/crystal_void_sefi_grey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
import io.github.sefiraat.crystamaehistoria.magic.spells.core.MagicSummon;
import io.github.sefiraat.crystamaehistoria.runnables.RunnableManager;
import io.github.sefiraat.crystamaehistoria.runnables.spells.SpellTickRunnable;
import io.github.sefiraat.crystamaehistoria.slimefun.Structure;
import io.github.sefiraat.crystamaehistoria.slimefun.ItemGroups;
import io.github.sefiraat.crystamaehistoria.slimefun.Machines;
import io.github.sefiraat.crystamaehistoria.slimefun.Materials;
import io.github.sefiraat.crystamaehistoria.slimefun.Tools;
import io.github.sefiraat.crystamaehistoria.stories.StoriesManager;
import io.github.sefiraat.crystamaehistoria.utils.CrystaTag;
import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair;
Expand All @@ -27,7 +30,6 @@ public class CrystamaeHistoria extends AbstractAddon {

private static CrystamaeHistoria instance;

private Structure structure;
private ConfigManager configManager;
private StoriesManager storiesManager;
private ListenerManager listenerManager;
Expand All @@ -43,10 +45,6 @@ public static CrystamaeHistoria getInstance() {
return instance;
}

public static Structure getStructure() {
return instance.structure;
}

public static ListenerManager getListenerManager() {
return instance.listenerManager;
}
Expand Down Expand Up @@ -119,15 +117,15 @@ public void enable() {
getLogger().info(" Crystamae Historia - By Sefiraat ");
getLogger().info("########################################");

this.structure = new Structure();
this.configManager = new ConfigManager();
this.storiesManager = new StoriesManager();
this.listenerManager = new ListenerManager();
this.runnableManager = new RunnableManager();
this.spellMemory = new SpellMemory();
this.effectManager = new EffectManager(this);

structure.setup();
setupSlimefun();
configManager.setupConfigs();

new Metrics(this, 12065);

Expand All @@ -141,4 +139,12 @@ protected void disable() {
saveConfig();
instance = null;
}

private void setupSlimefun() {
new ItemGroups();
new Materials();
new Machines();
new Tools();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void clearAll() {
removeBlocks(true);
blocksToRemove.clear();

// Remove all temporary blocks
// Remove and disable all players flight
removeFlight(true);
playersWithFlight.clear();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.github.sefiraat.crystamaehistoria.config;

import io.github.sefiraat.crystamaehistoria.CrystamaeHistoria;
import io.github.sefiraat.crystamaehistoria.magic.SpellType;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.Spell;
import lombok.Getter;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
Expand All @@ -16,6 +18,7 @@ public class ConfigManager {
private final FileConfiguration stories;
private final FileConfiguration research;
private final FileConfiguration blockColors;
private final FileConfiguration spells;

public ConfigManager() {
this.blocks = getConfig("blocks.yml");
Expand All @@ -26,13 +29,14 @@ public ConfigManager() {
this.research.options().copyDefaults(true);
this.blockColors = getConfig("block_colors.yml");
this.blockColors.options().copyDefaults(true);
this.spells = getConfig("spells.yml");
this.spells.options().copyDefaults(true);
}

/**
* @noinspection ResultOfMethodCallIgnored
*/
private FileConfiguration getConfig(String fileName) {
// Todo remove commented code and add config diff
CrystamaeHistoria plugin = CrystamaeHistoria.getInstance();
File file = new File(plugin.getDataFolder(), fileName);
if (!file.exists()) {
Expand All @@ -56,4 +60,25 @@ public void saveResearches() {
exception.printStackTrace();
}
}

public boolean spellEnabled(Spell spell) {
return spells.getBoolean(spell.getId());
}

public void setupConfigs() {
// Spells
for (SpellType spellType : SpellType.getCachedValues()) {
Spell spell = spellType.getSpell();
if (!spells.contains(spell.getId())) {
try {
final File file = new File(CrystamaeHistoria.getInstance().getDataFolder(), "spells.yml");
spells.set(spell.getId(), true);
spells.save(file);
} catch (IOException exception) {
exception.printStackTrace();
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.bukkit.event.entity.EntityInteractEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.weather.LightningStrikeEvent;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -56,6 +54,17 @@ public void onProjectileHit(ProjectileHitEvent event) {
final Entity hitEntity = event.getHitEntity();

event.setCancelled(true);

// We don't want magic projectiles to hit their own passengers.
List<Entity> passengers = magicProjectile.getProjectile().getPassengers();
if (event.getHitEntity() != null && !passengers.isEmpty()) {
for (Entity entity : passengers) {
if (entity.getUniqueId() == event.getHitEntity().getUniqueId()) {
return;
}
}
}

castInfo.setProjectileLocation(magicProjectile.getLocation());

if (entityHitAllowed(castInfo, hitEntity)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -34,6 +35,12 @@ public class CastInformation {
private Block hitBlock;
@Getter
@Setter
private Block targetedBlockOnCast;
@Getter
@Setter
private BlockFace targetedBlockFaceOnCast;
@Getter
@Setter
private Location projectileLocation;
@Getter
@Setter
Expand All @@ -56,6 +63,8 @@ public CastInformation(Player caster, int staveLevel) {
this.caster = caster.getUniqueId();
this.staveLevel = staveLevel;
this.castLocation = caster.getLocation().clone();
this.targetedBlockOnCast = caster.getTargetBlockExact(50);
this.targetedBlockFaceOnCast = caster.getTargetBlockFace(50);
}

public Player getCasterAsPlayer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ public enum CastResult {
CAST_SUCCESS("Successful"),
CAST_FAIL_NO_CRYSTA("Not enough Crystamae in plate"),
CAST_FAIL_SLOT_EMPTY("No plate in slot"),
ON_COOLDOWN("Spell on cooldown");
ON_COOLDOWN("Spell on cooldown"),
SPELL_DISABLED("This spell has been disabled");

@Getter
protected static final CastResult[] cachedValues = values();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
package io.github.sefiraat.crystamaehistoria.magic;

import io.github.sefiraat.crystamaehistoria.CrystamaeHistoria;
import io.github.sefiraat.crystamaehistoria.magic.spells.core.Spell;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.AirNova;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.AirSprite;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.AncientDefence;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Animaniacs;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.AntiPrism;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.BatteringRam;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.BloodMagics;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Bobulate;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Break;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Bright;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.CallLightning;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Cascada;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Chaos;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Compass;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.CurificationRitual;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Deity;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Gravity;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Hearthstone;
Expand All @@ -25,17 +29,23 @@
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Fireball;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.FlameSprite;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.FrostNova;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Gravity;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Gyroscopic;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.HarmonysSonata;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.HarvestMoon;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Heal;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.HealingMist;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Hearthstone;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Hellscape;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.HolyCow;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.ImbueVoid;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.KnowledgeShare;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.LavaLake;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.LeechBomb;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.LovePotion;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Oviparous;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.PhantomsFlight;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.PhilosophersStone;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.PoisonNova;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Prism;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Protectorate;
Expand All @@ -48,12 +58,14 @@
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.SpawnFiends;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Squall;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.StarFall;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.StripMine;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.SummonGolem;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Teleport;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Tempest;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.TimeCompression;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.TimeDilation;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Tracer;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.TunnelBore;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Vacuum;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.WitherWeather;
import io.github.sefiraat.crystamaehistoria.slimefun.machines.liquefactionbasin.LiquefactionBasinCache;
Expand All @@ -62,6 +74,7 @@
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Arrays;

public enum SpellType {

Expand All @@ -71,13 +84,16 @@ public enum SpellType {
ANCIENT_DEFENCE(new AncientDefence()),
ANIMANIACS(new Animaniacs()),
ANTI_PRISM(new AntiPrism()),
BATTERING_RAM(new BatteringRam()),
BLOOD_MAGICS(new BloodMagics()),
BOBULATE(new Bobulate()),
BREAK(new Break()),
BRIGHT(new Bright()),
CALL_LIGHTNING(new CallLightning()),
CASCADA(new Cascada()),
CHAOS(new Chaos()),
COMPASS(new Compass()),
CURIFICATION_RITUAL(new CurificationRitual()),
DEITY(new Deity()),
EARTH_NOVA(new EarthNova()),
ENDERMANS_VEIL(new EndermansVeil()),
Expand All @@ -93,14 +109,17 @@ public enum SpellType {
HEARTHSTONE(new Hearthstone()),
HELLSCAPE(new Hellscape()),
HOLY_COW(new HolyCow()),
IMBUE_VOID(new ImbueVoid()),
GYROSCOPIC(new Gyroscopic()),
HARMONYS_SONATA(new HarmonysSonata()),
HARVEST_MOON(new HarvestMoon()),
KNOWLEDGE_SHARE(new KnowledgeShare()),
LAVA_LAKE(new LavaLake()),
LEECH_BOMB(new LeechBomb()),
LOVE_POTION(new LovePotion()),
OVIPAROUS(new Oviparous()),
PHANTOMS_FLIGHT(new PhantomsFlight()),
PHILOSOPHERS_STONE(new PhilosophersStone()),
POISON_NOVA(new PoisonNova()),
PRISM(new Prism()),
PROTECTORATE(new Protectorate()),
Expand All @@ -113,24 +132,33 @@ public enum SpellType {
SPAWN_FIENDS(new SpawnFiends()),
SQUALL(new Squall()),
STAR_FALL(new StarFall()),
STRIP_MINE(new StripMine()),
SUMMON_GOLEM(new SummonGolem()),
TELEPORT(new Teleport()),
TEMPEST(new Tempest()),
TIME_COMPRESSION(new TimeCompression()),
TIME_DILATION(new TimeDilation()),
TRACER(new Tracer()),
TUNNEL_BORE(new TunnelBore()),
VACUUM(new Vacuum()),
WITHER_WEATHER(new WitherWeather());

@Getter
protected static final SpellType[] cachedValues = values();
@Getter
protected static final SpellType[] enabledSpells = Arrays.stream(values())
.filter(spellType -> spellType.getSpell().isEnabled())
.toArray(SpellType[]::new);
@Getter
private final Spell spell;

@ParametersAreNonnullByDefault
SpellType(Spell spell) {
spell.setEnabled(CrystamaeHistoria.getConfigManager().spellEnabled(spell));
if (spell.isEnabled()) {
LiquefactionBasinCache.addSpellRecipe(this, spell.getRecipe());
}
this.spell = spell;
LiquefactionBasinCache.addSpellRecipe(this, spell.getRecipe());
}

@Nullable
Expand Down
Loading

0 comments on commit cf18ac7

Please sign in to comment.