Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement new message system #266

Merged
merged 4 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/minevalley/core/api/ChatMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import minevalley.core.api.utils.ClickableMessage;

@Deprecated(forRemoval = true)
public interface ChatMenu {

/**
Expand Down
29 changes: 26 additions & 3 deletions src/main/java/minevalley/core/api/Core.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import minevalley.core.api.economy.BankAccount;
import minevalley.core.api.enums.DebugType;
import minevalley.core.api.enums.InterfaceItem;
import minevalley.core.api.enums.Server;
import minevalley.core.api.enums.ServerType;
import minevalley.core.api.gui.GuiBuilder;
import minevalley.core.api.gui.GuiItem;
import minevalley.core.api.gui.MultiPageGui;
Expand All @@ -27,6 +27,7 @@
import minevalley.core.api.regions.utils.Area;
import minevalley.core.api.regions.utils.Boundary;
import minevalley.core.api.regions.utils.FakeBlock;
import minevalley.core.api.team.Team;
import minevalley.core.api.timing.Reminder;
import minevalley.core.api.timing.RepeatingTimer;
import minevalley.core.api.timing.Timer;
Expand Down Expand Up @@ -331,11 +332,17 @@ public static UUID getUniqueId(@Nullable String name) {
return server.getUniqueId(name);
}

public static Team team() {
return server.team();
}

/**
* Sends a message to all online team-members
*
* @param message message as string
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
public static void sendTeamChatMessage(@Nonnull String message) {
server.sendTeamChatMessage(message);
}
Expand All @@ -345,7 +352,8 @@ public static void sendTeamChatMessage(@Nonnull String message) {
*
* @param message message as base-component (useful for clickable messages)
*/
@Deprecated
@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
public static void sendTeamChatMessage(@Nonnull BaseComponent[] message) {
server.sendTeamChatMessage(message);
}
Expand Down Expand Up @@ -867,6 +875,8 @@ public static HoverEvent createHoverText(@Nonnull String text) {
* @return new chat menu
*/
@Contract("_ -> new")
@SuppressWarnings("removal")
@Deprecated(forRemoval = true)
public static ChatMenu createChatMenu(ChatMenu.Option... options) {
return server.createChatMenu(options);
}
Expand All @@ -876,6 +886,8 @@ public static ChatMenu createChatMenu(ChatMenu.Option... options) {
*
* @return new chat menu
*/
@SuppressWarnings("removal")
@Deprecated(forRemoval = true)
public static ChatMenu createChatMenu() {
return server.createChatMenu();
}
Expand Down Expand Up @@ -1787,7 +1799,18 @@ public static FakeArmorStand getFakeArmorStand(int id) {
* @return server type
*/
@Nonnull
public static Server getServer() {
@Deprecated(forRemoval = true)
public static ServerType getServer() {
return server.getServerType();
}

/**
* Gets the server type.
*
* @return server type
*/
@Nonnull
public static ServerType getServerType() {
return server.getServerType();
}

Expand Down
33 changes: 26 additions & 7 deletions src/main/java/minevalley/core/api/CoreServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import minevalley.core.api.discord.Webhook;
import minevalley.core.api.economy.BankAccount;
import minevalley.core.api.enums.DebugType;
import minevalley.core.api.enums.Server;
import minevalley.core.api.enums.ServerType;
import minevalley.core.api.gui.GuiBuilder;
import minevalley.core.api.gui.GuiItem;
import minevalley.core.api.gui.MultiPageGui;
Expand All @@ -26,6 +26,7 @@
import minevalley.core.api.regions.utils.Area;
import minevalley.core.api.regions.utils.Boundary;
import minevalley.core.api.regions.utils.FakeBlock;
import minevalley.core.api.team.Team;
import minevalley.core.api.timing.Reminder;
import minevalley.core.api.timing.RepeatingTimer;
import minevalley.core.api.timing.Timer;
Expand Down Expand Up @@ -54,6 +55,7 @@
import org.bukkit.util.Vector;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;

import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
Expand Down Expand Up @@ -109,9 +111,12 @@ public interface CoreServer {
@Nullable
UUID getUniqueId(@Nullable String name);

Team team();

@Deprecated(forRemoval = true)
void sendTeamChatMessage(@Nonnull String message);

@Deprecated
@Deprecated(forRemoval = true)
void sendTeamChatMessage(@Nonnull BaseComponent[] message);

void sendDebug(@Nonnull DebugType type, @Nonnull String message);
Expand All @@ -124,21 +129,24 @@ public interface CoreServer {

double getStatistic(@Nonnull String key) throws IllegalArgumentException;

@Nullable
@Contract("null -> null")
String removeColorCodes(@Nullable String text);

@Nullable
@Contract("null -> null")
String convertColorCodes(@Nullable String text);

@Contract("null -> false")
boolean containsForForbiddenWords(@Nullable String string);

@Nonnull
Gson getGson();

int getRandomInteger(int chars) throws IllegalArgumentException;

@Contract("null -> false")
boolean isInteger(@Nullable String string);

@Contract("null -> false")
boolean isDouble(@Nullable String string);

@Nonnull
Expand All @@ -148,10 +156,10 @@ public interface CoreServer {
String formatRelativeTimestamp(long time);

@Nonnull
GuiBuilder createGui(int size) throws IllegalArgumentException;
GuiBuilder createGui(@Nonnegative int size) throws IllegalArgumentException;

@Nonnull
MultiPageGui createMultiPageGui(int size) throws IllegalArgumentException;
MultiPageGui createMultiPageGui(@Nonnegative int size) throws IllegalArgumentException;

GuiItem createGuiItem(@Nonnull ItemStack itemStack, @Nullable Consumer<OnlineUser> consumer);

Expand All @@ -174,28 +182,39 @@ public interface CoreServer {
FakeBlock createFakeBlock(@Nonnull Block block, @Nonnull Material material, int data) throws IllegalArgumentException;

@Nonnull
@Contract("_ -> new")
ItemBuilder createItem(@Nonnull ItemStack itemStack) throws IllegalArgumentException;

@Nonnull
@Contract("_ -> new")
ItemBuilder createItem(@Nonnull Material material) throws IllegalArgumentException;

@Nonnull
@Contract("_, _ -> new")
ItemBuilder createItem(@Nonnull Material material, int data) throws IllegalArgumentException;

@Nonnull
@Contract("_ -> new")
ItemBuilder createItem(@Nonnull Player player) throws IllegalArgumentException;

@Nonnull
@Contract("_ -> new")
ItemBuilder createItem(@Nonnull UUID uniqueId) throws IllegalArgumentException;

@Nonnull
@Contract("_, _ -> new")
ItemBuilder createItem(@Nonnull String value, @Nonnull String signature) throws IllegalArgumentException;

@Nonnull
@Contract("_ -> new")
ItemBuilder createItem(String url) throws IllegalArgumentException;

@SuppressWarnings("removal")
@Deprecated(forRemoval = true)
ChatMenu createChatMenu(ChatMenu.Option... options);

@SuppressWarnings("removal")
@Deprecated(forRemoval = true)
ChatMenu createChatMenu();

@Nonnull
Expand Down Expand Up @@ -370,7 +389,7 @@ Apartment createApartment(@Nonnull Region region, @Nonnull Registrant landlord,
FakeArmorStand getFakeArmorStand(int id);

@Nonnull
Server getServerType();
ServerType getServerType();

@Nullable
String convertToTransparent(@Nullable String text) throws IllegalArgumentException;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/minevalley/core/api/Module.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package minevalley.core.api;

import minevalley.core.api.enums.Server;
import minevalley.core.api.enums.ServerType;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand All @@ -15,5 +15,5 @@

String[] authors();

Server[] servers() default {};
ServerType[] servers() default {};
}
Loading
Loading