Skip to content

Commit 64f5589

Browse files
authored
Merge pull request #20 from Sefiraat/dev
Bug fixes
2 parents ed6cda2 + 711576a commit 64f5589

File tree

6 files changed

+175
-120
lines changed

6 files changed

+175
-120
lines changed

src/main/java/io/github/sefiraat/crystamaehistoria/CrystamaeHistoria.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ public void enable() {
146146
this.spellMemory = new SpellMemory();
147147
this.effectManager = new EffectManager(this);
148148

149+
configManager.loadConfig();
150+
151+
SpellType.setupEnabledSpells();
152+
149153
setupSlimefun();
150-
configManager.setupConfigs();
151154

152155
setupBstats();
153156

src/main/java/io/github/sefiraat/crystamaehistoria/config/ConfigManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import io.github.sefiraat.crystamaehistoria.CrystamaeHistoria;
44
import io.github.sefiraat.crystamaehistoria.magic.SpellType;
55
import io.github.sefiraat.crystamaehistoria.magic.spells.core.Spell;
6+
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasinCache;
67
import lombok.Getter;
78
import org.bukkit.configuration.InvalidConfigurationException;
89
import org.bukkit.configuration.file.FileConfiguration;
@@ -56,7 +57,7 @@ public boolean spellEnabled(Spell spell) {
5657
return spells.getBoolean(spell.getId());
5758
}
5859

59-
public void setupConfigs() {
60+
public void loadConfig() {
6061
// Spells
6162
for (SpellType spellType : SpellType.getCachedValues()) {
6263
Spell spell = spellType.getSpell();
@@ -69,6 +70,11 @@ public void setupConfigs() {
6970
exception.printStackTrace();
7071
}
7172
}
73+
boolean enabled = spells.getBoolean(spell.getId());
74+
spell.setEnabled(enabled);
75+
if (enabled) {
76+
LiquefactionBasinCache.addSpellRecipe(spellType, spell.getRecipe());
77+
}
7278
}
7379
}
7480

src/main/java/io/github/sefiraat/crystamaehistoria/magic/SpellType.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,12 @@ public enum SpellType {
155155
@Getter
156156
protected static final SpellType[] cachedValues = values();
157157
@Getter
158-
protected static final SpellType[] enabledSpells = Arrays.stream(values())
159-
.filter(spellType -> spellType.getSpell().isEnabled())
160-
.toArray(SpellType[]::new);
158+
protected static SpellType[] enabledSpells;
161159
@Getter
162160
private final Spell spell;
163161

164162
@ParametersAreNonnullByDefault
165163
SpellType(Spell spell) {
166-
spell.setEnabled(CrystamaeHistoria.getConfigManager().spellEnabled(spell));
167-
if (spell.isEnabled()) {
168-
LiquefactionBasinCache.addSpellRecipe(this, spell.getRecipe());
169-
}
170164
this.spell = spell;
171165
}
172166

@@ -196,4 +190,10 @@ public void cast(CastInformation castInformation) {
196190
this.spell.castSpell(castInformation);
197191
}
198192

193+
public static void setupEnabledSpells() {
194+
enabledSpells = Arrays.stream(values())
195+
.filter(spellType -> spellType.getSpell().isEnabled())
196+
.toArray(SpellType[]::new);
197+
}
198+
199199
}

src/main/java/io/github/sefiraat/crystamaehistoria/magic/spells/tier1/Chaos.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public void cast(CastInformation castInformation) {
5555
if (location.getBlock().isEmpty()) {
5656
final MagicProjectile projectile = SpellUtils.summonMagicProjectile(castInformation, EntityType.SPECTRAL_ARROW, pointLocation, this::onTick);
5757
projectile.getProjectile().setGravity(false);
58-
projectile.setVelocity(location.getDirection(), 1);
58+
projectile.setVelocity(caster.getEyeLocation().getDirection(), 1);
5959
}
6060
}
6161
}

src/main/java/io/github/sefiraat/crystamaehistoria/utils/CrystaTag.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ public enum CrystaTag implements Tag<Material> {
3434
CrystaTag() {
3535
final String name = this.name().toLowerCase(Locale.ROOT);
3636
final String fileLocation = "/tags/" + name + ".json";
37+
final JsonParser parser = new JsonParser();
3738

3839
try {
3940
final InputStream stream = CrystamaeHistoria.class.getResourceAsStream(fileLocation);
4041
final JsonReader reader = new JsonReader(new InputStreamReader(stream));
41-
final JsonObject object = (JsonObject) JsonParser.parseReader(reader);
42+
final JsonObject object = (JsonObject) parser.parse(reader);
4243

4344
for (JsonElement element : object.get("values").getAsJsonArray()) {
4445
final String tagString = element.getAsString();

0 commit comments

Comments
 (0)