Skip to content

Commit

Permalink
Merge pull request #134 from Nookure/dev
Browse files Browse the repository at this point in the history
realase/v1.4.4
  • Loading branch information
Angelillo15 authored Dec 2, 2024
2 parents 604678e + 15e34cb commit 19105e6
Show file tree
Hide file tree
Showing 46 changed files with 1,192 additions and 610 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/javadoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
cp -r NookureStaff/NookureStaff-API/build/docs/javadoc javadocs/javadocs/NookureStaff/
ls javadocs/javadocs/NookureStaff
cd javadocs
git config --global user.email [email protected]
git config --global user.email [email protected]
git config --global user.name Angelillo15
git add .
git commit -m "Update javadocs"
Expand Down
3 changes: 2 additions & 1 deletion NookureStaff-API/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ dependencies {

compileOnly(libs.auto.service.annotations)
compileOnly(rootProject.libs.liblyBukkit)
compileOnly(rootProject.libs.storm)
annotationProcessor(libs.auto.service)
annotationProcessor(libs.google.auto.value.processor)
implementation(libs.google.auto.value.annotations)
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,19 @@ default void toggleStaffMode() {
* Set the player's staff chat mode.
*
* @param staffChatAsDefault if true, the player will be in staff chat mode
* by default
* @param saveInDB if true, the player's staff chat mode will be saved
*/
void setStaffChatAsDefault(boolean staffChatAsDefault);
void setStaffChatAsDefault(boolean staffChatAsDefault, boolean saveInDB);

/**
* Set the player's staff chat mode.
*
* @param staffChatAsDefault if true, the player will be in staff chat mode
*/
default void setStaffChatAsDefault(boolean staffChatAsDefault) {
setStaffChatAsDefault(staffChatAsDefault, true);
}

/**
* Reload/load the player's items.
Expand Down Expand Up @@ -138,4 +149,6 @@ default void disableVanish() {
* @return the player's items
*/
@NotNull Map<Integer, StaffItem> getItems();

@NotNull Map<Class<? extends StaffPlayerExtension>, StaffPlayerExtension> getExtensions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nookure.staff.api.annotation.staff;

import com.google.inject.BindingAnnotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
public @interface StaffChatAsDefaultBool {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.nookure.staff.api.annotation.staff;

import com.google.inject.BindingAnnotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.FIELD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
public @interface StaffModeBool {
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.nookure.staff.api.config.bukkit;

import com.nookure.staff.api.config.bukkit.partials.config.FreezePartial;
import com.nookure.staff.api.config.bukkit.partials.config.ModulesPartials;
import com.nookure.staff.api.config.bukkit.partials.config.PlayerActions;
import com.nookure.staff.api.config.bukkit.partials.config.StaffModePartial;
import com.nookure.staff.api.config.bukkit.partials.config.*;
import com.nookure.staff.api.config.partials.DatabaseConfig;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
Expand All @@ -12,33 +9,36 @@
@ConfigSerializable
public class BukkitConfig {
@Setting
public final DatabaseConfig database = new DatabaseConfig();
public DatabaseConfig database = new DatabaseConfig();

@Setting
@Comment("""
Here you can enable or disable any part of the plugin.
If you disable a module, the commands and the features
of that module will be disabled.
""")
public final ModulesPartials modules = new ModulesPartials();
public ModulesPartials modules = new ModulesPartials();

@Setting
@Comment("""
Here you can configure some settings for the staffmode
""")
public final StaffModePartial staffMode = new StaffModePartial();
public StaffModePartial staffMode = new StaffModePartial();

@Setting
@Comment("""
Here you can configure some settings for the freeze module
""")
public final FreezePartial freeze = new FreezePartial();
public FreezePartial freeze = new FreezePartial();

@Setting
@Comment("""
Here you can configure some settings for the player actions
""")
public final PlayerActions playerActions = new PlayerActions();
public PlayerActions playerActions = new PlayerActions();

@Setting
public StaffChatPartial staffChat = new StaffChatPartial();

@Setting
@Comment("""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.nookure.staff.api.config.bukkit.partials.config;

import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;

@ConfigSerializable
public class StaffChatPartial {
@Setting
@Comment("If this is enabled, the staff chat will be logged in the console.")
public boolean logStaffChatInConsole = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ public class RedisPartial {
)
private int port = 6379;

@Setting
@Comment(
"""
The username to use when connecting to the Redis server.
If the server does not require a username, leave this empty.
"""
)
private String username = "";

@Setting
@Comment(
"""
Expand Down Expand Up @@ -82,4 +91,8 @@ public int getTimeout() {
public int getDatabase() {
return database;
}

public String getUsername() {
return username;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.nookure.staff.api.database;

import com.craftmend.storm.Storm;
import com.nookure.staff.api.config.partials.DatabaseConfig;
import io.ebean.Database;
import org.jetbrains.annotations.NotNull;
Expand All @@ -13,6 +12,7 @@
*/
public abstract class AbstractPluginConnection {
public static final String DATABASE_NAME = "nkstaff";

/**
* Connects to the database.
* <p>
Expand Down Expand Up @@ -40,18 +40,6 @@ public abstract class AbstractPluginConnection {
*/
public abstract void close();

/**
* Returns the Storm instance.
* This should be called after {@link #connect(DatabaseConfig, ClassLoader)}.
* <p>
* If the connection is not established, this method should throw an exception.
* If the connection is established, this method should return the Storm instance.
* </p>
*
* @return the Storm instance
*/
public abstract @NotNull Storm getStorm();

/**
* Returns the connection to the database.
* this should be called after {@link #connect(DatabaseConfig, ClassLoader)}.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
package com.nookure.staff.api.database.model;

import com.google.auto.value.AutoBuilder;
import org.jetbrains.annotations.NotNull;

import java.util.UUID;

/**
* The StaffStateModel class.
* <p>
* This class is used to represent the state of a staff member.
* It contains the UUID of the player, whether the player is in staff mode, and whether the player is vanished.
* This class is immutable, in order to change the state of a player, a new instance of the StaffStateModel must be created.
*/
public record StaffStateModel(
@NotNull UUID uuid,
boolean staffMode,
boolean vanished,
boolean staffChatEnabled
) {
/**
* Constructor for the StaffStateModel.
*
* @param uuid The UUID of the player.
*/
public StaffStateModel(UUID uuid) {
this(uuid, false, false, false);
}

/**
* Builder for the StaffStateModel.
*/
@AutoBuilder(ofClass = StaffStateModel.class)
public abstract static class Builder {
/**
* Returns a new instance of the StaffStateModel Builder.
*
* @return A new instance of the StaffStateModel Builder.
*/
public static Builder builder() {
return new AutoBuilder_StaffStateModel_Builder();
}

/**
* Returns a new instance of the StaffStateModel Builder.
*
* @param staffStateModel The StaffStateModel to copy.
* @return A new instance of the StaffStateModel Builder.
*/
public static Builder builder(StaffStateModel staffStateModel) {
return builder()
.uuid(staffStateModel.uuid())
.staffMode(staffStateModel.staffMode())
.staffChatEnabled(staffStateModel.staffChatEnabled())
.vanished(staffStateModel.vanished());
}

/**
* Sets the UUID of the player.
*
* @param uuid The UUID of the player.
* @return The Builder instance.
*/
public abstract Builder uuid(@NotNull UUID uuid);

/**
* Sets whether the player is in staff mode.
*
* @param staffMode Whether the player is in staff mode.
* @return The Builder instance.
*/
public abstract Builder staffMode(boolean staffMode);

/**
* Sets whether the player is vanished.
*
* @param vanished Whether the player is vanished.
* @return The Builder instance.
*/
public abstract Builder vanished(boolean vanished);

/**
* Sets whether the player is vanished.
*
* @param staffChatEnabled Whether the player is vanished.
* @return The Builder instance.
*/
public abstract Builder staffChatEnabled(boolean staffChatEnabled);

/**
* Builds the StaffStateModel.
*
* @return The StaffStateModel.
*/
public abstract StaffStateModel build();
}

public static Builder builder() {
return Builder.builder();
}

public static Builder builder(StaffStateModel staffStateModel) {
return Builder.builder(staffStateModel);
}

public UUID uuid() {
return uuid;
}

public boolean staffMode() {
return staffMode;
}

public boolean vanished() {
return vanished;
}

@Override
public String toString() {
return "StaffStateModel{" +
"uuid=" + uuid +
", staffMode=" + staffMode +
", vanished=" + vanished +
", staffChatEnabled=" + staffChatEnabled +
'}';
}
}
Loading

0 comments on commit 19105e6

Please sign in to comment.