aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java3
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java9
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItem.java3
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItems.java27
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java92
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java21
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java27
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java12
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/PartyConstants.java19
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/BingoChatMessagePacket.java16
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/BroadcastMessagePacket.java3
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java10
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/DisconnectPacket.java11
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/DisplayTellrawMessagePacket.java4
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/InternalCommandPacket.java36
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/InvalidCommandFeedbackPacket.java17
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/MiningEventPacket.java15
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/PartyPacket.java15
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/PunishUserPacket.java12
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java9
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestConnectPacket.java15
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashNotifyPacket.java18
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashUpdatePacket.java10
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/SystemMessagePacket.java8
-rw-r--r--common/src/main/java/de/hype/bbsentials/common/packets/packets/WelcomeClientPacket.java9
25 files changed, 267 insertions, 154 deletions
diff --git a/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java b/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
index 9a5be33..817f94d 100644
--- a/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
+++ b/common/src/main/java/de/hype/bbsentials/common/communication/BBsentialConnection.java
@@ -445,7 +445,8 @@ public class BBsentialConnection {
public void onPartyPacket(PartyPacket packet) {
if (BBsentials.config.allowServerPartyInvite) {
- Chat.sendCommand("/p " + packet.type.toString().toLowerCase() + " " + String.join(" ", packet.users));
+ if (packet.type.equals(PartyConstants.DISBAND.toString().toLowerCase())) Chat.sendCommand("/p disband");
+ else Chat.sendCommand("/p " + packet.type.toString().toLowerCase() + String.join(" ", packet.users));
}
else {
Chat.sendPrivateMessageToSelfImportantInfo("Blocked a Party Command from the Server: " + packet.type + " : " + String.join(" ", packet.users));
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java
index ebc844c..619cbfd 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/AuthenticationConstants.java
@@ -1,8 +1,9 @@
package de.hype.bbsentials.common.constants.enviromentShared;
-public class AuthenticationConstants {
+public enum AuthenticationConstants {
//Authentication Types
- public static final String MOJANG = "MOJANG";
- public static final String DATABASE = "DATABASE";
- public static final String REGISTER = "REGISTER";
+ MOJANG,
+ DATABASE,
+ REGISTER;
+
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItem.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItem.java
index b937367..420b7fe 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItem.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItem.java
@@ -1,5 +1,8 @@
package de.hype.bbsentials.common.constants.enviromentShared;
+/**
+ * chchest Items. used to create custom ones which aren't in the {@link ChChestItems default list}
+ */
public class ChChestItem {
private String displayName;
private boolean custom;
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItems.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItems.java
index 0a12742..c803e14 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItems.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/ChChestItems.java
@@ -5,9 +5,31 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
+/**
+ * Enumeration representing various ChChest items in the game.
+ * These constants define specific ChChest items that players can obtain.
+ * Use these constants to refer to specific ChChest items. For non-listed use the Custom Value. Example usage below.
+ * <p>
+ * The available ChChest items are:
+ * <ul>
+ * <li>{@code PrehistoricEgg}: Represents a prehistoric egg item.</li>
+ * <li>{@code Pickonimbus2000}: Represents the Pickonimbus 2000 item.</li>
+ * <li>{@code ControlSwitch}: Represents a control switch item.</li>
+ * <li>{@code ElectronTransmitter}: Represents an electron transmitter item.</li>
+ * <li>{@code FTX3070}: Represents the FTX 3070 item.</li>
+ * <li>{@code RobotronReflector}: Represents the Robotron Reflector item.</li>
+ * <li>{@code SuperliteMotor}: Represents a Superlite Motor item.</li>
+ * <li>{@code SyntheticHeart}: Represents a synthetic heart item.</li>
+ * <li>{@code FlawlessGemstone}: Represents a flawless gemstone item.</li>
+ * <li>{@code JungleHeart}: Represents a Jungle Heart item.</li>
+ * </ul>
+ * How to create a Custom Enum:
+ * <pre>
+ * {@code new ChChestItem("(Your Item name)")}
+ * Make sure too use the EXACT display name!
+ * </pre>
+ */
public class ChChestItems {
- private static final List<ChChestItem> items = new ArrayList<>();
-
public static final ChChestItem PrehistoricEgg = new ChChestItem("Prehistoric Egg");
public static final ChChestItem Pickonimbus2000 = new ChChestItem("Pickonimbus 2000");
public static final ChChestItem ControlSwitch = new ChChestItem("Control Switch");
@@ -18,6 +40,7 @@ public class ChChestItems {
public static final ChChestItem SyntheticHeart = new ChChestItem("Synthetic Heart");
public static final ChChestItem FlawlessGemstone = new ChChestItem("Flawless Gemstone");
public static final ChChestItem JungleHeart = new ChChestItem("Jungle Heart");
+ private static final List<ChChestItem> items = new ArrayList<>();
// Automatically populate predefined items using reflection
static {
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java
index 5214f65..df0ff63 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/EnumUtils.java
@@ -1,7 +1,6 @@
package de.hype.bbsentials.common.constants.enviromentShared;
import de.hype.bbsentials.common.constants.BBDisplayNameProvider;
-import de.hype.bbsentials.common.constants.BBDisplayNameProviderWithCustom;
import java.util.ArrayList;
import java.util.Collection;
@@ -70,72 +69,6 @@ public class EnumUtils {
// }
// }
-
-
- // Methods for BBDisplayNameProviderWithCustom
-
- public static <T extends Enum<T> & BBDisplayNameProviderWithCustom> T getEnumByNameWithCustom(Class<T> enumClass, String enumName) {
- boolean found = false;
- for (T enumValue : enumClass.getEnumConstants()) {
- if (enumValue.name().equals(enumName)) {
- return (enumValue);
- }
- }
- return createCustomEnum(enumClass, enumName);
- }
-
- public static <T extends Enum<T> & BBDisplayNameProviderWithCustom> T getEnumByValueWithCustom(Class<T> enumClass, String value) {
- for (T enumValue : enumClass.getEnumConstants()) {
- if (enumValue.getDisplayName().equals(value)) {
- return enumValue;
- }
- }
- return (createCustomEnum(enumClass, value));
-
- }
-
- public static <T extends Enum<T> & BBDisplayNameProviderWithCustom> T[] getEnumsByNameWithCustom(Class<T> enumClass, String[] names) {
- List<T> matchingEnums = new ArrayList<>();
-
- for (String name : names) {
- boolean found = false;
- for (T enumValue : enumClass.getEnumConstants()) {
- if (enumValue.name().equals(name)) {
- matchingEnums.add(enumValue);
- found = true;
- break;
- }
- }
- if (!found) {
- matchingEnums.add(createCustomEnum(enumClass, name));
- }
- }
-
- return matchingEnums.toArray((T[]) java.lang.reflect.Array.newInstance(enumClass, 0));
- }
-
- public static <T extends Enum<T> & BBDisplayNameProviderWithCustom> T[] getEnumsByValueWithCustom(Class<T> enumClass, String[] values) {
- List<T> matchingEnums = new ArrayList<>();
-
- for (String value : values) {
- boolean found = false;
- for (T enumValue : enumClass.getEnumConstants()) {
- if (enumValue.toString().equals(value)) {
- matchingEnums.add(enumValue);
- found = true;
- break;
- }
- }
- if (!found) {
- matchingEnums.add(createCustomEnum(enumClass, value));
- }
- }
-
- return matchingEnums.toArray((T[]) java.lang.reflect.Array.newInstance(enumClass, 0));
- }
-
- // Methods for BBDisplayNameProvider
-
public static <T extends Enum<T> & BBDisplayNameProvider> T getEnumByName(Class<T> enumClass, String enumName) {
try {
return Enum.valueOf(enumClass, enumName);
@@ -143,14 +76,6 @@ public class EnumUtils {
return null; // Enum value not found
}
}
- public static <T extends Enum<T> & BBDisplayNameProvider, U extends Enum<U>> U getEnumByName(Class<T> enumClass, Class<U> enumType, String enumName) {
- try {
- return Enum.valueOf(enumType, enumName);
- } catch (IllegalArgumentException e) {
- return null; // Enum value not found
- }
- }
-
public static <T extends Enum<T> & BBDisplayNameProvider> T getEnumByValue(Class<T> enumClass, String value) {
for (T enumValue : enumClass.getEnumConstants()) {
@@ -194,23 +119,6 @@ public class EnumUtils {
return matchingEnums.toArray((T[]) java.lang.reflect.Array.newInstance(enumClass, 0));
}
-
- private static <T extends Enum<T> & BBDisplayNameProviderWithCustom> T createCustomEnum(Class<T> enumClass, String value) {
- T customEnum = null;
- try {
- customEnum = Enum.valueOf(enumClass, "Custom");
- } catch (Exception ignored) {
- try {
- customEnum = Enum.valueOf(enumClass, "CUSTOM");
- } catch (Exception ignored2) {
- }
- }
- if (customEnum == null) {
- }
- customEnum.setDisplayName(value);
- return customEnum;
-
- }
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java
index 9b9a976..6d8f897 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/InternalReasonConstants.java
@@ -1,5 +1,26 @@
package de.hype.bbsentials.common.constants.enviromentShared;
+/**
+ * Enumeration representing internal reasons constants for a specific functionality.
+ * These constants are used to provide detailed information about various scenarios or states.
+ * <p>
+ * The following are the possible reasons represented by this enumeration:
+ * <ul>
+ * <li>{@link #INVALID_PARAMETER}: Invalid parameter was provided.</li>
+ * <li>{@link #MISSING_PARAMETER}: Required parameter is missing.</li>
+ * <li>{@link #INSUFFICIENT_PRIVILEGES}: Insufficient privileges to perform the operation.</li>
+ * <li>{@link #MUTED}: User is muted.</li>
+ * <li>{@link #BANNED}: User is banned.</li>
+ * <li>{@link #API_UNSUPPORTED}: API feature is unsupported.</li>
+ * <li>{@link #INVALID_LOGIN}: Invalid login attempt.</li>
+ * <li>{@link #KICKED}: User was kicked from the server.</li>
+ * <li>{@link #ANOTHER_LOGIN}: Another login detected for the same user.</li>
+ * <li>{@link #SERVER_RESTART}: Server is restarting.</li>
+ * <li>{@link #NOT_REGISTERED}: User is not registered.</li>
+ * <li>{@link #ON_COOLDOWN}: Operation is on cooldown.</li>
+ * <li>{@link #OTHER}: Other unspecified reason.</li>
+ * </ul>
+ */
public enum InternalReasonConstants {
INVALID_PARAMETER,
MISSING_PARAMETER,
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java
index e2e914c..d88d79b 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/Islands.java
@@ -2,6 +2,24 @@ package de.hype.bbsentials.common.constants.enviromentShared;
import de.hype.bbsentials.common.constants.BBDisplayNameProvider;
+/**
+ * List of all Islands
+ * <li>{@link #CRYSTAL_HOLLOWS}
+ * <li>{@link #CRIMSON_ISLE}
+ * <li>{@link #DEEP_CAVERNS}
+ * <li>{@link #DUNGEON}
+ * <li>{@link #DUNGEON_HUB}
+ * <li>{@link #DWARVEN_MINES}
+ * <li>{@link #GOLD_MINE}
+ * <li>{@link #HUB}
+ * <li>{@link #KUUDRA}
+ * <li>{@link #PRIVATE_ISLAND}
+ * <li>{@link #SPIDERS_DEN}
+ * <li>{@link #THE_END}
+ * <li>{@link #THE_FARMING_ISLANDS}
+ * <li>{@link #JERRYS_WORKSHOP}
+ * <li>{@link #THE_RIFT}
+ */
public enum Islands implements BBDisplayNameProvider {
CRYSTAL_HOLLOWS("crystal_hollows", "Crystal Hollows"),
CRIMSON_ISLE("crimson_isle", "Crimson Isle"),
@@ -35,13 +53,4 @@ public enum Islands implements BBDisplayNameProvider {
public String getDisplayName() {
return displayName;
}
- public static Islands getByDisplayName(String displayName) {
- for (Islands island : values()) {
- if (island.getDisplayName().equals(displayName)) {
- return island;
- }
- }
- return null; // Return null if the display name doesn't match any enum value
- }
-
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java
index 5f6e99e..e364aab 100644
--- a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/MiningEvents.java
@@ -1,8 +1,18 @@
package de.hype.bbsentials.common.constants.enviromentShared;
+// Mining Events
+
import de.hype.bbsentials.common.constants.BBDisplayNameProvider;
-// Mining Events
+/**
+ * A List of all Mining Events
+ * <li>{@link #BETTER_TOGETHER}
+ * <li>{@link #DOUBLE_POWDER}
+ * <li>{@link #GONE_WITH_THE_WIND}
+ * <li>{@link #GOBLIN_RAID}
+ * <li>{@link #MITHRIL_GOURMAND}
+ * <li>{@link #RAFFLE}
+ */
public enum MiningEvents implements BBDisplayNameProvider {
BETTER_TOGETHER("Better Together"),
DOUBLE_POWDER("Double Powder"),
diff --git a/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/PartyConstants.java b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/PartyConstants.java
new file mode 100644
index 0000000..b66baf3
--- /dev/null
+++ b/common/src/main/java/de/hype/bbsentials/common/constants/enviromentShared/PartyConstants.java
@@ -0,0 +1,19 @@
+package de.hype.bbsentials.common.constants.enviromentShared;
+
+/**
+ * Allowed party operations.
+ * <p>
+ * The available enums are:
+ * <ul>
+ * <li>{@link #INVITE}: Represents the type for sending party invitations.</li>
+ * <li>{@link #ACCEPT}: Represents the type for accepting party invitations.</li>
+ * <li>{@link #DISBAND}: Represents the type for disbanding a party.</li>
+ * <li>{@link #KICK}: Represents the type for kicking a user from the party.</li>
+ * </ul>
+ */
+public enum PartyConstants {
+ INVITE, // Represents the type for party invites.
+ ACCEPT, // Represents the type for accepting party invitations.
+ DISBAND, // Represents the type for disbanding a party.
+ KICK // Represents the type for kicking a user from the party.
+}
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/BingoChatMessagePacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/BingoChatMessagePacket.java
index c7432da..21000fd 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/BingoChatMessagePacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/BingoChatMessagePacket.java
@@ -1,10 +1,17 @@
package de.hype.bbsentials.common.packets.packets;
-
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * Message in the BBsentials Environment. Shared Discord and Mod in-game
+ */
public class BingoChatMessagePacket extends AbstractPacket {
-
+ /**
+ * @param prefix the prefix the sender has.
+ * @param username the username the sender has. (In game name)
+ * @param message message
+ * @param bingo_cards the count of cards the user has.
+ */
public BingoChatMessagePacket(String prefix, String username, String message, int bingo_cards) {
super(1, 1); //Min and Max supported Version
this.message = message;
@@ -17,9 +24,4 @@ public class BingoChatMessagePacket extends AbstractPacket {
public final String username;
public final String prefix;
public final int bingo_cards;
-
- public boolean baseCheck() {
- boolean cancelPacket = false;
- return !cancelPacket;
- }
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/BroadcastMessagePacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/BroadcastMessagePacket.java
index bbd6d90..d08a791 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/BroadcastMessagePacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/BroadcastMessagePacket.java
@@ -3,6 +3,9 @@ package de.hype.bbsentials.common.packets.packets;
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * Used when a Message is broadcast. Requires Mod Privilege.
+ */
public class BroadcastMessagePacket extends AbstractPacket {
public final String message;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java
index 7355397..6aab4ce 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/ChChestPacket.java
@@ -1,10 +1,16 @@
package de.hype.bbsentials.common.packets.packets;
-import de.hype.bbsentials.common.constants.enviromentShared.ChChestItem;
import de.hype.bbsentials.common.packets.AbstractPacket;
+import de.hype.bbsentials.common.constants.enviromentShared.ChChestItem;
public class ChChestPacket extends AbstractPacket {
-
+ /**
+ * @param announcerUsername person who found the chest.
+ * @param items items contained in the chest. {@link de.hype.bbsentials.common.constants.enviromentShared.ChChestItems (available constants)}
+ * @param locationCoords coordinates of the chest.
+ * @param bbcommand command that shall be executed in game to get an invitation to the party.
+ * @param extraMessage a message that is optional to be provided by the announcer for custom additional info
+ */
public ChChestPacket(String announcerUsername, ChChestItem[] items, String locationCoords, String bbcommand, String extraMessage) {
super(1, 1); //Min and Max supported Version
this.announcerUsername = announcerUsername;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/DisconnectPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/DisconnectPacket.java
index ca60a49..d3afcd7 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/DisconnectPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/DisconnectPacket.java
@@ -3,8 +3,19 @@ package de.hype.bbsentials.common.packets.packets;
import de.hype.bbsentials.common.constants.enviromentShared.InternalReasonConstants;
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * Used to tell a client that they were disconnected by the Host.
+ */
public class DisconnectPacket extends AbstractPacket {
+ /**
+ * @param internalReason Reason for the disconnect {@link InternalReasonConstants}
+ * @param waitBeforeReconnect Time before client shall try to reconnect.
+ * @param randomExtraDelay Max random delay that is added to put less stress on the Server
+ * @param displayReason Reason to be displayed why Client was disconnected
+ * @param displayMessage Message is shown on the client.
+ */
+
public DisconnectPacket(InternalReasonConstants internalReason, int[] waitBeforeReconnect, int randomExtraDelay, String displayReason, String displayMessage) {
super(1, 1); //Min and Max supportet Version
this.internalReason = internalReason;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/DisplayTellrawMessagePacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/DisplayTellrawMessagePacket.java
index e3e7f70..5ed54c5 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/DisplayTellrawMessagePacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/DisplayTellrawMessagePacket.java
@@ -2,6 +2,10 @@ package de.hype.bbsentials.common.packets.packets;
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * Used to tell the client to generate a clientside tellraw message.
+ * Disabled as of now due to the potential security issue clickable commands are.
+ */
public class DisplayTellrawMessagePacket extends AbstractPacket {
public final String rawJson;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/InternalCommandPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/InternalCommandPacket.java
index fb7a774..fd18486 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/InternalCommandPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/InternalCommandPacket.java
@@ -3,22 +3,28 @@ package de.hype.bbsentials.common.packets.packets;
import de.hype.bbsentials.common.packets.AbstractPacket;
//Only used for small things which don't really need an own Packet.
+
+/**
+ * Several functions for the client to execute on included scripts.
+ * See the Constants in code for explanations.
+ */
public class InternalCommandPacket extends AbstractPacket {
- public static final String REQUEST_POT_DURATION= "potDuration?";
- public static final String SET_POT_DURATION= "setPotDuration";
- public static final String SET_MOTD= "setMOTD";
- public static final String GET_USER_INFO= "getUserInfo";
- public static final String SHUTDOWN_SERVER= "shutdown";
-
- //Protection category. The following things can only be activated by people with server console access and an code understanding.
- public static final String CRASH= "crash";
- public static final String INSTACRASH= "immediateCrash";
- public static final String HUB= "hub";
- public static final String PRIVATE_ISLAND= "is";
- public static final String HIDDEN_HUB= "hidden_Hub";
- public static final String HIDDEN_PRIVATE_ISLAND= "hidden_is";
- public static final String SELFDESTRUCT= "destroy"; //used when someone may not sue the mod in the future anymore
- public static final String PEACEFULLDESTRUCT= "silentDestroy"; //Used when The game should not crash, when the mod was removed
+ public static final String REQUEST_POT_DURATION = "potDuration?"; //Requests the left time of splash from the user.
+ public static final String SET_POT_DURATION = "setPotDuration"; //Used by the client to tell the server the remaining time. (On Splasher request)
+ public static final String SET_MOTD = "setMOTD"; //Admins can set the MOTD of the Network with this.
+ public static final String GET_USER_INFO = "getUserInfo"; //Requests info about a user from the Server
+ public static final String SHUTDOWN_SERVER = "shutdown"; //Shuts the Server down.
+
+ //Protection category. The following things can only be activated by people with server console access and a code understanding. → Developer
+ public static final String CRASH = "crash"; //Crash the client. Gives a countdown
+ public static final String INSTACRASH = "immediateCrash"; // Crash the Client with no countdown
+ public static final String HUB = "hub"; //Executes a /hub on the client. Tells the Client done by Server
+ public static final String PRIVATE_ISLAND = "is"; //Executes a /is on the client. Tells the Client done by Server
+ public static final String HIDDEN_HUB = "hidden_Hub"; //Like HUB but with no information done by server
+ public static final String HIDDEN_PRIVATE_ISLAND = "hidden_is"; //Like IS but with no information done by the Server
+ public static final String SELFDESTRUCT = "destroy"; //used when someone may not use the mod in the future anymore. Will crash the Client with no warning!
+ public static final String PEACEFULLDESTRUCT = "silentDestroy"; //Used when The game should not crash, when the mod was removed. Gives the User a countdown till crash for no harm.
+
public InternalCommandPacket(String command, String[] parameters) {
super(1, 1); //Min and Max supported Version
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/InvalidCommandFeedbackPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/InvalidCommandFeedbackPacket.java
index 2f4510e..b30786c 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/InvalidCommandFeedbackPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/InvalidCommandFeedbackPacket.java
@@ -1,10 +1,21 @@
package de.hype.bbsentials.common.packets.packets;
import de.hype.bbsentials.common.packets.AbstractPacket;
+import de.hype.bbsentials.common.constants.enviromentShared.InternalReasonConstants;
+/**
+ * Gives the User feedback that the command had a problem.
+ */
public class InvalidCommandFeedbackPacket extends AbstractPacket {
-
- public InvalidCommandFeedbackPacket(String internalReason, String command, String displayMessage, String argument, String permissionNeeded, String[] userPermissions) {
+ /**
+ * @param internalReason for options see {@link de.hype.bbsentials.common.constants.enviromentShared.InternalReasonConstants}
+ * @param command command which was executed by the client that caused the problem
+ * @param displayMessage message that shall be displayed on the client.
+ * @param argument argument in the command that caused the problem.
+ * @param permissionNeeded permission required for that command / argument
+ * @param userPermissions permissions the user has.
+ */
+ public InvalidCommandFeedbackPacket(InternalReasonConstants internalReason, String command, String displayMessage, String argument, String permissionNeeded, String[] userPermissions) {
super(1, 1); //Min and Max supportet Version
this.internalReason = internalReason;
this.argument = argument;
@@ -14,7 +25,7 @@ public class InvalidCommandFeedbackPacket extends AbstractPacket {
this.displayMessage = displayMessage;
}
- public final String internalReason;
+ public final InternalReasonConstants internalReason;
public final String argument;
public final String permissionNeeded;
public final String[] userPermissions;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/MiningEventPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/MiningEventPacket.java
index 9d9be62..20f38ae 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/MiningEventPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/MiningEventPacket.java
@@ -1,20 +1,29 @@
package de.hype.bbsentials.common.packets.packets;
+import de.hype.bbsentials.common.packets.AbstractPacket;
import de.hype.bbsentials.common.constants.enviromentShared.Islands;
import de.hype.bbsentials.common.constants.enviromentShared.MiningEvents;
-import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * used to announce a mining event network wide. Can be used by both Client and Server to announce to each other.
+ */
public class MiningEventPacket extends AbstractPacket {
-
-
public final MiningEvents event;
public final String username;
public final Islands island;
+ /**
+ * @param event Event happening {@link MiningEvents (available constants)}
+ * @param username username of the announcer
+ * @param island Island Event is happening on. Options: {@link Islands#DWARVEN_MINES} , {@link Islands#CRYSTAL_HOLLOWS}
+ * @throws Exception when the Island is invalid. Can be when the island is CH but event can only be in Dwarfen Mines
+ */
public MiningEventPacket(MiningEvents event, String username, Islands island) throws Exception {
super(1, 1); //Min and Max supported Version
this.event = event;
this.username = username;
+ if (island != Islands.CRYSTAL_HOLLOWS && island != Islands.DWARVEN_MINES)
+ throw new Exception("Invalid Island!");
if (island.equals(Islands.CRYSTAL_HOLLOWS)) {
if (event.equals(MiningEvents.MITHRIL_GOURMAND) || event.equals(MiningEvents.RAFFLE) || event.equals(MiningEvents.GOBLIN_RAID)) {
throw new Exception("The specified event can not happen on this Server");
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/PartyPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/PartyPacket.java
index 48a36f4..301a2ad 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/PartyPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/PartyPacket.java
@@ -1,16 +1,25 @@
package de.hype.bbsentials.common.packets.packets;
+import de.hype.bbsentials.common.constants.enviromentShared.PartyConstants;
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * sends the client the request to execute the party command.
+ *
+ * @see PartyPacket
+ */
public class PartyPacket extends AbstractPacket {
-
- public PartyPacket(String type, String[] users) {
+ /**
+ * @param type Party Command Type {@link PartyConstants}
+ * @param users users is just a reference for what behind the type.
+ */
+ public PartyPacket(PartyConstants type, String[] users) {
super(1, 1); //Min and Max supportet Version
this.type = type;
this.users = users;
}
- public final String type;
+ public final PartyConstants type;
public final String[] users;
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/PunishUserPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/PunishUserPacket.java
index dce052f..22f4e98 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/PunishUserPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/PunishUserPacket.java
@@ -2,11 +2,21 @@ package de.hype.bbsentials.common.packets.packets;
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * Send von Client to Server to punish a User in the Network with a Ban or Mute.
+ */
public class PunishUserPacket extends AbstractPacket {
public static final String PUNISHMENT_TYPE_BAN = "BAN";
public static final String PUNISHMENT_TYPE_MUTE = "MUTE";
- public PunishUserPacket(String punishmentType,int userId, String username, String duration, String reason) {
+ /**
+ * @param punishmentType {@link #PUNISHMENT_TYPE_BAN} or {@link #PUNISHMENT_TYPE_MUTE}
+ * @param userId optional with username. userid to punish
+ * @param username optional with userid. mc username to punish
+ * @param duration Duration of the punishment
+ * @param reason Reason for the punishment
+ */
+ public PunishUserPacket(String punishmentType, int userId, String username, String duration, String reason) {
super(1, 1);
this.type = punishmentType;
this.username = username;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java
index 81ea9fe..fc411a2 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestAuthentication.java
@@ -1,12 +1,19 @@
package de.hype.bbsentials.common.packets.packets;
+
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * From Server to client telling him to authenticate.
+ */
public class RequestAuthentication extends AbstractPacket {
-
public final String serverIdSuffix;
public final int serverVersion;
+ /**
+ * @param serverIdSuffix needed for Mojang Auth. "client" + "server" = serverid at mojang.
+ * @param serverVersion the version the server is on.
+ */
public RequestAuthentication(String serverIdSuffix, int serverVersion) {
super(1, 1); //Min and Max supported Version
this.serverIdSuffix = serverIdSuffix;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestConnectPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestConnectPacket.java
index 9ce468a..07a2dc6 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestConnectPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/RequestConnectPacket.java
@@ -1,11 +1,20 @@
package de.hype.bbsentials.common.packets.packets;
+import de.hype.bbsentials.common.constants.enviromentShared.AuthenticationConstants;
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * From Client to Server. Tell the Server they want to connect.
+ */
public class RequestConnectPacket extends AbstractPacket {
-
- public RequestConnectPacket(String mcuuid, String key, int clientApiVersion, String authType) {
+ /**
+ * @param mcuuid the mcuuid of the peron that wants to connect.
+ * @param key api key
+ * @param clientApiVersion
+ * @param authType
+ */
+ public RequestConnectPacket(String mcuuid, String key, int clientApiVersion, AuthenticationConstants authType) {
super(1, 1); //Min and Max supported Version
this.mcuuid = mcuuid;
this.key = key;
@@ -15,6 +24,6 @@ public class RequestConnectPacket extends AbstractPacket {
public final String mcuuid;
public final String key;
- public final String authType;
+ public final AuthenticationConstants authType;
public final int clientApiVersion;
}
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashNotifyPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashNotifyPacket.java
index 427e4f2..d3c4f37 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashNotifyPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashNotifyPacket.java
@@ -1,16 +1,26 @@
package de.hype.bbsentials.common.packets.packets;
-import de.hype.bbsentials.common.constants.enviromentShared.Islands;
import de.hype.bbsentials.common.packets.AbstractPacket;
+import de.hype.bbsentials.common.constants.enviromentShared.Islands;
+/**
+ * Server and Client. USed to announce to each other.
+ */
public class SplashNotifyPacket extends AbstractPacket {
-
+ /**
+ * @param splashId the id of the Splash. Only Server to Client
+ * @param hub hub number
+ * @param splasherUsername mc username of the splasher
+ * @param location location where is splashed.
+ * @param hubType {@link Islands#HUB} or {@link Islands#DUNGEON_HUB}
+ * @param extraMessage custom message
+ * @param lessWaste whether the less waste System shall be used.
+ */
public SplashNotifyPacket(int splashId, int hub, String splasherUsername, String location, Islands hubType, String extraMessage, boolean lessWaste) {
- super(1, 1); //Min and Max supported Version
+ super(1, 1); //Min and Max supportet Version
this.hub = hub;
this.splashId = splashId;
-
this.lessWaste = lessWaste;
this.splasherUsername = splasherUsername;
this.location = location;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashUpdatePacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashUpdatePacket.java
index 9645daf..fc08205 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashUpdatePacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/SplashUpdatePacket.java
@@ -1,16 +1,22 @@
package de.hype.bbsentials.common.packets.packets;
-
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * Client and Server. Updates Splash Status.
+ */
public class SplashUpdatePacket extends AbstractPacket {
+ //TODO convert to enum
public static final String STATUS_WAITING = "Waiting";
public static final String STATUS_FULL = "Full";
public static final String STATUS_SPLASHING = "Splashing";
public static final String STATUS_CANCELED = "Canceled";
public static final String STATUS_DONE = "Done";
-
+ /**
+ * @param splashId id of the splash
+ * @param status one of the following types: {@link #STATUS_WAITING}, {@link #STATUS_FULL}, {@link #STATUS_SPLASHING}, {@link #STATUS_CANCELED}, {@link #STATUS_DONE}
+ */
public SplashUpdatePacket(int splashId, String status) {
super(1, 1); //Min and Max supported Version
this.splashId = splashId;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/SystemMessagePacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/SystemMessagePacket.java
index 13b92d4..72efaf4 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/SystemMessagePacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/SystemMessagePacket.java
@@ -2,11 +2,19 @@ package de.hype.bbsentials.common.packets.packets;
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * Server to Client. Displays a message on the Client.
+ */
public class SystemMessagePacket extends AbstractPacket {
public final String message;
public final boolean important;
public final boolean ping;
+ /**
+ * @param message the Message
+ * @param important whether the message is important
+ * @param ping whether the client shall play the ping sound
+ */
public SystemMessagePacket(String message, boolean important, boolean ping) {
super(1, 1); //Min and Max supported Version
this.message = message;
diff --git a/common/src/main/java/de/hype/bbsentials/common/packets/packets/WelcomeClientPacket.java b/common/src/main/java/de/hype/bbsentials/common/packets/packets/WelcomeClientPacket.java
index 00aa003..1169a83 100644
--- a/common/src/main/java/de/hype/bbsentials/common/packets/packets/WelcomeClientPacket.java
+++ b/common/src/main/java/de/hype/bbsentials/common/packets/packets/WelcomeClientPacket.java
@@ -2,8 +2,15 @@ package de.hype.bbsentials.common.packets.packets;
import de.hype.bbsentials.common.packets.AbstractPacket;
+/**
+ * Server to Client. When Client authenticated.
+ */
public class WelcomeClientPacket extends AbstractPacket {
-
+ /**
+ * @param roles the User has
+ * @param motd Current MOTD message
+ * @param success Whether Auth was successful or not
+ */
public WelcomeClientPacket(String[] roles, String motd, boolean success) {
super(1, 1); //Min and Max supportet Version
this.roles = roles;