-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added missing version-dependent code-branch; fixed version-comparison…
… in LangKeyedItemMaterial
- Loading branch information
1 parent
b49ea0a
commit 70519bb
Showing
5 changed files
with
73 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
...n/java/me/blvckbytes/item_predicate_parser/translation/version/ExpectedServerVersion.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
.../me/blvckbytes/item_predicate_parser/translation/version/VersionDependentCode_E_1_20.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package me.blvckbytes.item_predicate_parser.translation.version; | ||
|
||
import com.google.gson.JsonObject; | ||
import me.blvckbytes.item_predicate_parser.predicate.ItemPredicate; | ||
import me.blvckbytes.item_predicate_parser.predicate.MusicInstrumentPredicate; | ||
import me.blvckbytes.item_predicate_parser.token.Token; | ||
import me.blvckbytes.item_predicate_parser.translation.TranslatedLangKeyed; | ||
import me.blvckbytes.item_predicate_parser.translation.keyed.*; | ||
import org.bukkit.Material; | ||
import org.bukkit.Registry; | ||
import org.bukkit.potion.PotionEffectType; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Arrays; | ||
import java.util.logging.Logger; | ||
|
||
public class VersionDependentCode_E_1_20 implements IVersionDependentCode { | ||
|
||
private final Logger logger; | ||
private final DetectedServerVersion serverVersion; | ||
|
||
public VersionDependentCode_E_1_20(DetectedServerVersion serverVersion, Logger logger) { | ||
this.logger = logger; | ||
this.serverVersion = serverVersion; | ||
} | ||
|
||
@Override | ||
public Iterable<? extends LangKeyed<?>> getEnchantments() { | ||
return Registry.ENCHANTMENT.stream().map(LangKeyedEnchantment::new).toList(); | ||
} | ||
|
||
@Override | ||
public Iterable<? extends LangKeyed<?>> getEffects() { | ||
return Arrays.stream(PotionEffectType.values()).map(LangKeyedPotionEffectType::new).toList(); | ||
} | ||
|
||
@Override | ||
public Iterable<? extends LangKeyed<?>> getItemMaterials(JsonObject languageJson) { | ||
return Registry.MATERIAL.stream().filter(Material::isItem).map(it -> new LangKeyedItemMaterial(it, serverVersion, languageJson)).toList(); | ||
} | ||
|
||
@Override | ||
public @Nullable Iterable<? extends LangKeyed<?>> getInstruments() { | ||
return Registry.INSTRUMENT.stream().map(LangKeyedMusicInstrument::new).toList(); | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public @Nullable ItemPredicate makeInstrumentPredicate(Token token, TranslatedLangKeyed<?> translation) { | ||
if (!(translation.langKeyed instanceof LangKeyedMusicInstrument)) { | ||
logger.severe("Unexpected lang-keyed of non-MusicInstrument type; returning null!"); | ||
return null; | ||
} | ||
|
||
return new MusicInstrumentPredicate(token, (TranslatedLangKeyed<LangKeyedMusicInstrument>) translation); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters