Skip to content

Commit e04a7d0

Browse files
Make some classes sealed / final
1 parent df91b30 commit e04a7d0

File tree

11 files changed

+20
-16
lines changed

11 files changed

+20
-16
lines changed

invui/src/main/java/xyz/xenondevs/invui/InvUI.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,14 @@
1515
/**
1616
* Main class of InvUI, managing the plugin instance.
1717
*/
18-
public class InvUI implements Listener {
18+
public final class InvUI implements Listener {
1919

2020
private static final InvUI INSTANCE = new InvUI();
2121

2222
private final List<Runnable> disableHandlers = new ArrayList<>();
2323
private @Nullable Plugin plugin;
2424

25-
private InvUI() {
26-
}
25+
private InvUI() {}
2726

2827
/**
2928
* Returns the singleton instance of InvUI.

invui/src/main/java/xyz/xenondevs/invui/gui/AbstractIngredientMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.util.function.Supplier;
55

66
@SuppressWarnings("unchecked")
7-
abstract class AbstractIngredientMapper<S extends AbstractIngredientMapper<S>> implements IngredientMapper<S> {
7+
abstract sealed class AbstractIngredientMapper<S extends AbstractIngredientMapper<S>> implements IngredientMapper<S> permits IngredientPreset.Builder, Structure {
88

99
/**
1010
* Maps ingredient keys ({@link Character characters}) to their corresponding {@link Ingredient} instances.

invui/src/main/java/xyz/xenondevs/invui/gui/IngredientMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* @param <S> The type of the {@link IngredientMapper}
1616
*/
17-
public interface IngredientMapper<S extends IngredientMapper<S>> extends Cloneable {
17+
public sealed interface IngredientMapper<S extends IngredientMapper<S>> extends Cloneable permits AbstractIngredientMapper, Gui.Builder {
1818

1919
/**
2020
* Applies the given {@link IngredientPreset} to this {@link IngredientMapper}.

invui/src/main/java/xyz/xenondevs/invui/gui/IngredientPreset.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* A predefined set of ingredients that can be used in {@link Structure Structures}.
77
*/
8-
public class IngredientPreset {
8+
public final class IngredientPreset {
99

1010
private final Map<Character, Ingredient> ingredientMap;
1111

@@ -29,7 +29,7 @@ Map<Character, Ingredient> getIngredientMap() {
2929
/**
3030
* A builder for creating {@link IngredientPreset IngredientPresets}.
3131
*/
32-
public static class Builder extends AbstractIngredientMapper<Builder> {
32+
public static final class Builder extends AbstractIngredientMapper<Builder> {
3333

3434
private Builder() {}
3535

invui/src/main/java/xyz/xenondevs/invui/gui/Markers.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Contains markers
77
*/
8-
public class Markers {
8+
public final class Markers {
99

1010
/**
1111
* The marker for horizontal content list slots in {@link PagedGui PagedGuis},
@@ -41,4 +41,6 @@ void iterate(int width, int height, BiConsumer<? super Integer, ? super Integer>
4141

4242
};
4343

44+
private Markers() {}
45+
4446
}

invui/src/main/java/xyz/xenondevs/invui/gui/Structure.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Provides an easy way to design {@link Gui Guis} via a pattern string and ingredients.
1414
*/
15-
public class Structure extends AbstractIngredientMapper<Structure> {
15+
public final class Structure extends AbstractIngredientMapper<Structure> {
1616

1717
private static final HashMap<Character, Ingredient> globalIngredientMap = new HashMap<>();
1818
private static boolean globalIngredientsFrozen = false;

invui/src/main/java/xyz/xenondevs/invui/i18n/Languages.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
/**
2929
* Handles localization of items and window titles.
3030
*/
31-
public class Languages {
31+
public final class Languages {
3232

3333
private static final Languages INSTANCE = new Languages();
3434
private final Map<Locale, Map<? extends String, ? extends String>> translations = new HashMap<>();
@@ -54,8 +54,7 @@ protected String getMiniMessageString(String key, Locale locale) {
5454

5555
};
5656

57-
private Languages() {
58-
}
57+
private Languages() {}
5958

6059
/**
6160
* Gets the singleton instance of Languages.

invui/src/main/java/xyz/xenondevs/invui/inventory/VirtualInventoryManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* Automatically reads and writes {@link VirtualInventory VirtualInventories} to files when the server starts and stops.
1818
*/
19-
public class VirtualInventoryManager {
19+
public final class VirtualInventoryManager {
2020

2121
private static final File SAVE_DIR = new File("plugins/InvUI/VirtualInventory/" + InvUI.getInstance().getPlugin().getName() + "/");
2222
private static final VirtualInventoryManager INSTANCE = new VirtualInventoryManager();

invui/src/main/java/xyz/xenondevs/invui/util/ColorPalette.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* Utility for converting images into the color space used by maps in Minecraft.
1111
*/
12-
public class ColorPalette {
12+
public final class ColorPalette {
1313

1414
private static final byte[] colorCache;
1515

@@ -24,6 +24,8 @@ public class ColorPalette {
2424
colorCache = out.toByteArray();
2525
}
2626

27+
private ColorPalette() {}
28+
2729
/**
2830
* Gets the closest map color to the given RGB values.
2931
*

invui/src/main/java/xyz/xenondevs/invui/util/ItemUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
* Generic item-related utilities.
1414
*/
1515
@SuppressWarnings("UnstableApiUsage")
16-
public class ItemUtils {
16+
public final class ItemUtils {
1717

1818
private static @Nullable ItemStack placeholder;
1919
private static @Nullable ItemWrapper placeholderProvider;
2020

21+
private ItemUtils() {}
22+
2123
/**
2224
* Checks whether the given {@link ItemStack} is empty.
2325
* <p>

0 commit comments

Comments
 (0)