Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/cargo-simpl…
Browse files Browse the repository at this point in the history
…e-opt
  • Loading branch information
Xzavier0722 committed Mar 11, 2022
2 parents db6dc0e + c21c0bd commit 582fe66
Show file tree
Hide file tree
Showing 25 changed files with 795 additions and 177 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
* Added Spore Blossom as a fuel type for the Bio-Generator
* Added a new item setting for Freezers to allow them to use a 9:1 "vanilla" ratio instead of 1:1 (1:1 by default, like before)
* (API) Added `PlayerProfile#hasUnlockedEverything()` to check if a player has unlocked all researches
* (API) Added `Research#getUnlocalizedName()`
* Added support for the plugin "HuskTowns"
* Added support for Minecraft 1.18.2
* You can now pick up Slimefun blocks in creative mode using the middle mouse button
* `/sf search` no longer shows items in hidden item groups (can be overidden by a config setting)
* Fluid Pumps can now fill bottles with water

#### Changes
* (API) `BiomeMapParser` is now `public`
Expand All @@ -61,6 +66,10 @@
* Fixed "LogBlock" integration
* Fixed "Lands" integration
* Fixed #3133
* Fixed #3483
* Fixed #3469
* Fixed #3476
* Fixed #3487

## Release Candidate 30 (31 Dec 2021)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#30
Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
<dependency>
<groupId>io.github.baked-libs</groupId>
<artifactId>dough-api</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -267,13 +267,13 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.3.1</version>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.18</artifactId>
<version>1.15.5</version>
<version>1.18.1</version>
<scope>test</scope>

<exclusions>
Expand Down Expand Up @@ -360,7 +360,7 @@
<dependency>
<groupId>com.github.LoneDev6</groupId>
<artifactId>itemsadder-api</artifactId>
<version>2.5.5</version>
<version>3.0.0</version>
<scope>provided</scope>

<exclusions>
Expand All @@ -374,7 +374,7 @@
<dependency>
<groupId>net.imprex</groupId>
<artifactId>orebfuscator-api</artifactId>
<version>5.2.4</version>
<version>5.2.6</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@ protected SlimefunItem(ItemGroup itemGroup, ItemStack item, String id, RecipeTyp
return itemGroup;
}

/**
* Retrieve the recipe for this {@link SlimefunItem}.
*
* @return An {@link ItemStack} array of 9 which represents the recipe for this {@link SlimefunItem}
*/
public @Nonnull ItemStack[] getRecipe() {
return recipe;
}
Expand Down Expand Up @@ -655,14 +660,26 @@ public void setResearch(@Nullable Research research) {
this.research = research;
}

public void setRecipe(ItemStack[] recipe) {
/**
* Sets the recipe for this {@link SlimefunItem}.
*
* @param recipe
* The recipe for this {@link ItemStack}
*/
public void setRecipe(@Nonnull ItemStack[] recipe) {
if (recipe == null || recipe.length != 9) {
throw new IllegalArgumentException("Recipes must be of length 9");
}

this.recipe = recipe;
}

/**
* Sets the {@link RecipeType} for this {@link SlimefunItem}.
*
* @param type
* The {@link RecipeType} for this {@link SlimefunItem}
*/
public void setRecipeType(@Nonnull RecipeType type) {
Validate.notNull(type, "The RecipeType is not allowed to be null!");
this.recipeType = type;
Expand Down Expand Up @@ -1119,10 +1136,24 @@ public final int hashCode() {
return getId().hashCode();
}

/**
* Retrieve a {@link SlimefunItem} by its id.
*
* @param id
* The id of the {@link SlimefunItem}
* @return The {@link SlimefunItem} associated with that id. Null if non-existent
*/
public static @Nullable SlimefunItem getById(@Nonnull String id) {
return Slimefun.getRegistry().getSlimefunItemIds().get(id);
}

/**
* Retrieve a {@link SlimefunItem} from an {@link ItemStack}.
*
* @param item
* The {@link ItemStack} to check
* @return The {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise null
*/
public static @Nullable SlimefunItem getByItem(@Nullable ItemStack item) {
if (item == null || item.getType() == Material.AIR) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
Expand Down Expand Up @@ -120,6 +121,15 @@ public int getID() {
return localized != null ? localized : name;
}

/**
* Retrieve the name of this {@link Research} without any localization nor coloring.
*
* @return The unlocalized, decolorized name for this {@link Research}
*/
public @Nonnull String getUnlocalizedName() {
return ChatColor.stripColor(name);
}

/**
* Gets the cost in XP levels to unlock this {@link Research}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public void load(@Nonnull Slimefun plugin, @Nonnull Config cfg) {
guideKey = new NamespacedKey(plugin, "slimefun_guide_mode");

boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes));
boolean showHiddenItemGroupsInSearch = cfg.getBoolean("guide.show-hidden-item-groups-in-search");
guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes, showHiddenItemGroupsInSearch));
guides.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide());

researchRanks.addAll(cfg.getStringList("research-ranks"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public Language(@Nonnull String id, @Nonnull String hash) {
*
* @return The identifier of this {@link Language}
*/
@Nonnull
public String getId() {
public @Nonnull String getId() {
return id;
}

Expand Down Expand Up @@ -101,8 +100,7 @@ public void setFile(@Nonnull LanguageFile file, @Nonnull FileConfiguration confi
*
* @return The {@link ItemStack} used to display this {@link Language}
*/
@Nonnull
public ItemStack getItem() {
public @Nonnull ItemStack getItem() {
return item;
}

Expand All @@ -114,8 +112,7 @@ public ItemStack getItem() {
* The {@link Player} to localize the name for
* @return The localized name of this {@link Language}
*/
@Nonnull
public String getName(@Nonnull Player p) {
public @Nonnull String getName(@Nonnull Player p) {
return Slimefun.getLocalization().getMessage(p, "languages." + id);
}

Expand All @@ -136,7 +133,11 @@ public String toString() {

@Nonnull
FileConfiguration[] getFiles() {
return Arrays.stream(LanguageFile.valuesCached).map(this::getFile).toArray(FileConfiguration[]::new);
// @formatter:off
return Arrays.stream(LanguageFile.valuesCached)
.map(this::getFile)
.toArray(FileConfiguration[]::new);
// @formatter:on
}

}
Original file line number Diff line number Diff line change
@@ -1,78 +1,95 @@
package io.github.thebusybiscuit.slimefun4.core.services.localization;

import org.bukkit.inventory.ItemStack;

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

import org.bukkit.inventory.ItemStack;

/**
* This enum holds info about a {@link Language} that is embedded in our resources folder.
* Every enum constant holds the key of that {@link Language} as well as a texture hash
* for the {@link ItemStack} to display.
*
*
* @author TheBusyBiscuit
*
*
* @see Language
*
*/
public enum LanguagePreset {

ENGLISH("en", true, "a1701f21835a898b20759fb30a583a38b994abf60d3912ab4ce9f2311e74f72"),
GERMAN("de", true, "5e7899b4806858697e283f084d9173fe487886453774626b24bd8cfecc77b3f"),
FRENCH("fr", true, "51269a067ee37e63635ca1e723b676f139dc2dbddff96bbfef99d8b35c996bc"),
ITALIAN("it", true, "85ce89223fa42fe06ad65d8d44ca412ae899c831309d68924dfe0d142fdbeea4"),
SPANISH("es", true, "32bd4521983309e0ad76c1ee29874287957ec3d96f8d889324da8c887e485ea8"),
RUSSIAN("ru", true, "16eafef980d6117dabe8982ac4b4509887e2c4621f6a8fe5c9b735a83d775ad"),
ENGLISH("en", "a1701f21835a898b20759fb30a583a38b994abf60d3912ab4ce9f2311e74f72"),
GERMAN("de", "5e7899b4806858697e283f084d9173fe487886453774626b24bd8cfecc77b3f"),
FRENCH("fr", "51269a067ee37e63635ca1e723b676f139dc2dbddff96bbfef99d8b35c996bc"),
ITALIAN("it", "85ce89223fa42fe06ad65d8d44ca412ae899c831309d68924dfe0d142fdbeea4"),
SPANISH("es", "32bd4521983309e0ad76c1ee29874287957ec3d96f8d889324da8c887e485ea8"),
RUSSIAN("ru", "16eafef980d6117dabe8982ac4b4509887e2c4621f6a8fe5c9b735a83d775ad"),
POLISH("pl", false, "921b2af8d2322282fce4a1aa4f257a52b68e27eb334f4a181fd976bae6d8eb"),
UKRAINIAN("uk", true, "28b9f52e36aa5c7caaa1e7f26ea97e28f635e8eac9aef74cec97f465f5a6b51"),
UKRAINIAN("uk", "28b9f52e36aa5c7caaa1e7f26ea97e28f635e8eac9aef74cec97f465f5a6b51"),
BELARUSIAN("be", false, "8c12eaf0d83e97e2bace652d0d23e74908ee766894361271f00c22ea82d25b02"),
SWEDISH("sv", true, "e910904bff9c86f6ed47688e9429c26e8d9c5d5743bd3ebb8e6f5040be192998"),
SWEDISH("sv", "e910904bff9c86f6ed47688e9429c26e8d9c5d5743bd3ebb8e6f5040be192998"),
DUTCH("nl", false, "c23cf210edea396f2f5dfbced69848434f93404eefeabf54b23c073b090adf"),
DANISH("da", false, "10c23055c392606f7e531daa2676ebe2e348988810c15f15dc5b3733998232"),
FINNISH("fi", false, "59f2349729a7ec8d4b1478adfe5ca8af96479e983fbad238ccbd81409b4ed"),
NORWEGIAN("no", false, "e0596e165ec3f389b59cfdda93dd6e363e97d9c6456e7c2e123973fa6c5fda"),
CZECH("cs", true, "48152b7334d7ecf335e47a4f35defbd2eb6957fc7bfe94212642d62f46e61e"),
CZECH("cs", "48152b7334d7ecf335e47a4f35defbd2eb6957fc7bfe94212642d62f46e61e"),
ROMANIAN("ro", false, "dceb1708d5404ef326103e7b60559c9178f3dce729007ac9a0b498bdebe46107"),
BULGARIAN("bg", false, "19039e1fd88c78d9d7adc5aad5ab16e356be13464934ed9e2b0cef2051c5b534"),
BULGARIAN("bg", "19039e1fd88c78d9d7adc5aad5ab16e356be13464934ed9e2b0cef2051c5b534"),
PORTUGUESE_PORTUGAL("pt", false, "ebd51f4693af174e6fe1979233d23a40bb987398e3891665fafd2ba567b5a53a"),
PORTUGUESE_BRAZIL("pt-BR", true, "9a46475d5dcc815f6c5f2859edbb10611f3e861c0eb14f088161b3c0ccb2b0d9"),
HUNGARIAN("hu", true, "4a9c3c4b6c5031332dd2bfece5e31e999f8deff55474065cc86993d7bdcdbd0"),
PORTUGUESE_BRAZIL("pt-BR", "9a46475d5dcc815f6c5f2859edbb10611f3e861c0eb14f088161b3c0ccb2b0d9"),
HUNGARIAN("hu", "4a9c3c4b6c5031332dd2bfece5e31e999f8deff55474065cc86993d7bdcdbd0"),
CROATIAN("hr", false, "b050c04ec8cabce71d7103f3e9ef4bb8819f9f365eb335a9139912bc07ed445"),
LATVIAN("lv", false, "f62a4938b59447f996b5ed94101df07429d1ad34776d591ffc6fd75b79473c"),
GREEK("el", false, "1514de6dd2b7682b1d3ebcd10291ae1f021e3012b5c8beffeb75b1819eb4259d"),
SLOVAK("sk", true, "6c72a8c115a1fb669a25715c4d15f22136ac4c2452784e4894b3d56bc5b0b9"),
VIETNAMESE("vi", true, "8a57b9d7dd04169478cfdb8d0b6fd0b8c82b6566bb28371ee9a7c7c1671ad0bb"),
INDONESIAN("id", true, "5db2678ccaba7934412cb97ee16d416463a392574c5906352f18dea42895ee"),
CHINESE_CHINA("zh-CN", true, "7f9bc035cdc80f1ab5e1198f29f3ad3fdd2b42d9a69aeb64de990681800b98dc"),
CHINESE_TAIWAN("zh-TW", true, "702a4afb2e1e2e3a1894a8b74272f95cfa994ce53907f9ac140bd3c932f9f"),
JAPANESE("ja", true, "d640ae466162a47d3ee33c4076df1cab96f11860f07edb1f0832c525a9e33323"),
KOREAN("ko", true, "fc1be5f12f45e413eda56f3de94e08d90ede8e339c7b1e8f32797390e9a5f"),
HEBREW("he", true, "1ba086a2cc7272cf5ba49c80248546c22e5ef1bab54120e8a8e5d9e75b6a"),
ARABIC("ar", true, "a4be759a9cf7f0a19a7e8e62f23789ad1d21cebae38af9d9541676a3db001572"),
TURKISH("tr", true, "9852b9aba3482348514c1034d0affe73545c9de679ae4647f99562b5e5f47d09"),
SLOVAK("sk", "6c72a8c115a1fb669a25715c4d15f22136ac4c2452784e4894b3d56bc5b0b9"),
VIETNAMESE("vi", "8a57b9d7dd04169478cfdb8d0b6fd0b8c82b6566bb28371ee9a7c7c1671ad0bb"),
INDONESIAN("id", "5db2678ccaba7934412cb97ee16d416463a392574c5906352f18dea42895ee"),
CHINESE_CHINA("zh-CN", "7f9bc035cdc80f1ab5e1198f29f3ad3fdd2b42d9a69aeb64de990681800b98dc"),
CHINESE_TAIWAN("zh-TW", "702a4afb2e1e2e3a1894a8b74272f95cfa994ce53907f9ac140bd3c932f9f"),
JAPANESE("ja", "d640ae466162a47d3ee33c4076df1cab96f11860f07edb1f0832c525a9e33323"),
KOREAN("ko", "fc1be5f12f45e413eda56f3de94e08d90ede8e339c7b1e8f32797390e9a5f"),
HEBREW("he", TextDirection.RIGHT_TO_LEFT, "1ba086a2cc7272cf5ba49c80248546c22e5ef1bab54120e8a8e5d9e75b6a"),
ARABIC("ar", TextDirection.RIGHT_TO_LEFT, "a4be759a9cf7f0a19a7e8e62f23789ad1d21cebae38af9d9541676a3db001572"),
TURKISH("tr", "9852b9aba3482348514c1034d0affe73545c9de679ae4647f99562b5e5f47d09"),
PERSIAN("fa", false, "5cd9badf1972583b663b44b1e027255de8f275aa1e89defcf77782ba6fcc652"),
SERBIA("sr", false, "5b0483a4f0ddf4fbbc977b127b3d294d7a869f995366e3f50f6b05a70f522510"),
SERBIAN("sr", false, "5b0483a4f0ddf4fbbc977b127b3d294d7a869f995366e3f50f6b05a70f522510"),
AFRIKAANS("af", false, "961a1eacc10524d1f45f23b0e487bb2fc33948d9676b418b19a3da0b109d0e3c"),
MALAY("ms", false, "754b9041dea6db6db44750f1385a743adf653767b4b8802cad4c585dd3f5be46"),
THAI("th", true, "2a7916e4a852f7e6f3f3de19c7fb57686a37bce834bd54684a7dbef8d53fb"),
MACEDONIAN("mk", false, "a0e0b0b5d87a855466980a101a757bcdb5f77d9f7287889f3efa998ee0472fc0"),
TAGALOG("tl", true, "9306c0c1ce6a9c61bb42a572c49e6d0ed20e0e6b3d122cc64c339cbf78e9e937");
THAI("th", "2a7916e4a852f7e6f3f3de19c7fb57686a37bce834bd54684a7dbef8d53fb"),
MACEDONIAN("mk", "a0e0b0b5d87a855466980a101a757bcdb5f77d9f7287889f3efa998ee0472fc0"),
TAGALOG("tl", "9306c0c1ce6a9c61bb42a572c49e6d0ed20e0e6b3d122cc64c339cbf78e9e937");

private final String id;
private final boolean releaseReady;
private final String textureHash;
private final TextDirection textDirection;

@ParametersAreNonnullByDefault
LanguagePreset(String id, boolean releaseReady, String textureHash) {
LanguagePreset(String id, boolean releaseReady, TextDirection direction, String textureHash) {
this.id = id;
this.releaseReady = releaseReady;
this.textureHash = textureHash;
this.textDirection = direction;
}

@ParametersAreNonnullByDefault
LanguagePreset(String id, boolean releaseReady, String textureHash) {
this(id, releaseReady, TextDirection.LEFT_TO_RIGHT, textureHash);
}

@ParametersAreNonnullByDefault
LanguagePreset(String id, TextDirection direction, String textureHash) {
this(id, true, direction, textureHash);
}

@ParametersAreNonnullByDefault
LanguagePreset(String id, String textureHash) {
this(id, true, textureHash);
}

/**
* This returns the id of this {@link Language}.
*
* @return Language ID
*
* @return The language code
*/
public @Nonnull String getLanguageCode() {
return id;
Expand All @@ -81,14 +98,32 @@ public enum LanguagePreset {
/**
* This returns whether this {@link LanguagePreset} is "release-ready".
* A release-ready {@link Language} will be available in RC builds of Slimefun.
*
*
* @return Whether this {@link Language} is "release-ready"
*/
boolean isReadyForRelease() {
return releaseReady;
}

/**
* This returns the texture hash for this language.
* This will be the flag of the corresponding country.
* (Not accurate I know, but better than having all languages
* look the same by using the same items)
*
* @return The texture hash of this language
*/
public @Nonnull String getTexture() {
return textureHash;
}

/**
* This returns the direction of text for
* this language.
*
* @return The direction of text for this language
*/
public @Nonnull TextDirection getTextDirection() {
return textDirection;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.github.thebusybiscuit.slimefun4.core.services.localization;

/**
* A simple enum to define the direction of text for a given {@link LanguagePreset}
*
* @author TheBusyBiscuit
*
*/
public enum TextDirection {

/**
* The text flows from left to right.
* This is true for most western languages,
* such as English, Spanish, German, French and more.
*/
LEFT_TO_RIGHT,

/**
* The text flows from right to left.
* Most common languages that use this direction
* of text are Hebrew and Arabic.
*/
RIGHT_TO_LEFT

}
Loading

0 comments on commit 582fe66

Please sign in to comment.