Skip to content

Commit

Permalink
Merge pull request #140 from Nookure/dev
Browse files Browse the repository at this point in the history
Release 1.5.0
  • Loading branch information
Angelillo15 authored Dec 26, 2024
2 parents 19d7de1 + 2c0f725 commit 066e50e
Show file tree
Hide file tree
Showing 53 changed files with 1,491 additions and 174 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/modrinth-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: NookureStaff Modrinth Publish

on:
push:
branches: [ release/*, dev, feature/*, fix/* ]
jobs:
build-on-ubuntu:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout main branch from GitHub
uses: actions/checkout@v4

- name: Execute Gradle build & publish
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: |
chmod +x gradlew
./gradlew :modrinth

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.nookure.staff.api.command;


import com.google.inject.Inject;
import com.nookure.staff.api.PlayerWrapper;
import com.nookure.staff.api.StaffPlayerWrapper;
import com.nookure.staff.api.config.ConfigurationContainer;
import com.nookure.staff.api.config.bukkit.BukkitMessages;
import com.nookure.staff.api.util.transformer.PlayerTransformer;
import org.jetbrains.annotations.NotNull;

import java.util.List;
Expand All @@ -14,15 +19,32 @@
* </p>
*/
public abstract class StaffCommand extends Command {
private final PlayerTransformer transformer;
private final ConfigurationContainer<BukkitMessages> messages;

@Inject
public StaffCommand(
@NotNull final PlayerTransformer transformer,
@NotNull final ConfigurationContainer<BukkitMessages> messages
) {
this.transformer = transformer;
this.messages = messages;
}

@Override
public void onCommand(@NotNull CommandSender sender, @NotNull String label, @NotNull List<String> args) {
if (sender instanceof StaffPlayerWrapper) {
onStaffCommand((StaffPlayerWrapper) sender, label, args);
return;
}

if (sender.hasPermission("nookure.staff") && sender instanceof PlayerWrapper player) {
transformer.player2Staff(player.getUniqueId());
player.sendMiniMessage(messages.get().youAreNowAnStaff());
return;
}

sender.sendMiniMessage("<red>Only staff members can execute this command.");
sender.sendMiniMessage(messages.get().onlyStaffMembersCanExecuteThisCommand());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.nookure.staff.api.config.bukkit;

import com.nookure.staff.api.config.bukkit.partials.PermissionConfigPartial;
import com.nookure.staff.api.config.bukkit.partials.config.*;
import com.nookure.staff.api.config.partials.DatabaseConfig;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
Expand All @@ -25,6 +26,9 @@ public class BukkitConfig {
""")
public StaffModePartial staffMode = new StaffModePartial();

@Setting
public PermissionConfigPartial permission = new PermissionConfigPartial();

@Setting
@Comment("""
Here you can configure some settings for the freeze module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class BukkitMessages {
"""
The prefix for all staff messages.
If you want to use the prefix in a message, use {prefix}.
"""
"""
)
private String prefix = "<b><red>Staff</red> <gray>»</gray></b>";
@Setting
Expand All @@ -43,6 +43,18 @@ public class BukkitMessages {
""")
private String noPermission = "{prefix} <red>You don't have permission to do that.";

@Setting
@Comment("The message when a player has been registered as a staff member during the command execution.")
private String youAreNowAnStaffDuringCommandExecution = "{prefix} <green>You have been just registered as a staff member, please redo the command in order to use it.";

@Setting
@Comment("The message when a player has been registered as a staff member during the permission interceptor.")
private String youAreNowAnStaffDuringPermissionInterceptor = "{prefix} <green>Congratulations!, welcome to the Staff members.";

@Setting
@Comment("The message when only staff members can execute a command.")
private String onlyStaffMembersCanExecuteThisCommand = "{prefix} <red>Only staff members can execute this command.";

public String prefix() {
return prefix;
}
Expand All @@ -58,4 +70,16 @@ public String playerNotFound() {
public String noPermission() {
return noPermission;
}

public String youAreNowAnStaff() {
return youAreNowAnStaffDuringCommandExecution;
}

public String youAreNowAnStaffDuringPermissionInterceptor() {
return youAreNowAnStaffDuringPermissionInterceptor;
}

public String onlyStaffMembersCanExecuteThisCommand() {
return onlyStaffMembersCanExecuteThisCommand;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.nookure.staff.api.config.bukkit;

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

import java.util.Map;

@ConfigSerializable
public class GlowConfig {
@Setting
@Comment("Enable or disable the glow feature")
public boolean enabled = true;

@Setting
@Comment("Change the prefix color of the player's name")
public boolean tabIntegration = true;

@Setting
@Comment("The default color for the glow")
public String defaultColor = "<white>";

@Setting
@Comment("This colors must follow the format: <color> or <#hex>")
public Map<String, String> glowColors = Map.of(
"staff", "<red>",
"admin", "<yellow>",
"mod", "<green>"
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.nookure.staff.api.config.bukkit;

import com.nookure.staff.api.config.bukkit.partials.CustomItemPartial;
import com.nookure.staff.api.config.bukkit.partials.CustomItemType;
import com.nookure.staff.api.config.bukkit.partials.ItemPartial;
import com.nookure.staff.api.item.Items;
import org.bukkit.Material;
Expand All @@ -19,6 +21,9 @@ public static class StaffItems {
@Setting
private Map<String, ItemPartial> items = new HashMap<>();

@Setting
private Map<String, CustomItemPartial> customItems = new HashMap<>();

public StaffItems() {
items.put(Items.RANDOM_PLAYER_TELEPORT.toString(), new ItemPartial(
true,
Expand Down Expand Up @@ -82,10 +87,36 @@ public StaffItems() {
List.of("<gray>Click to teleport through", "<gray>The block you are looking at"),
"nookurestaff.item.thru"
));

customItems.put("custom_item", new CustomItemPartial(
false,
"<blue>Custom Item",
Material.DIAMOND,
2,
List.of("<gray>Click to send hello world to the player that you are looking at"),
"nookurestaff.item.custom",
CustomItemType.COMMAND_TARGET_AS_PLAYER,
"msg {target} Hello, world!"
));

customItems.put("custom_item_2", new CustomItemPartial(
false,
"<blue>Custom Item 2",
Material.REDSTONE_BLOCK,
6,
List.of("<gray>Click to kick the player that you are looking at"),
"nookurestaff.item.custom2",
CustomItemType.COMMAND_TARGET_AS_CONSOLE,
"kick {target} Hello, world!"
));
}

public Map<String, ItemPartial> getItems() {
return items;
}

public Map<String, CustomItemPartial> getCustomItems() {
return customItems;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.nookure.staff.api.config.bukkit.partials;

import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;

import java.util.List;

@ConfigSerializable
public class CustomItemPartial extends ItemPartial {
@Setting
@Comment("""
The type of the custom item.
- COMMAND_AS_PLAYER: The command will be executed as the player who clicked the item.
- COMMAND_AS_CONSOLE: The command will be executed as the console.
- COMMAND_TARGET_AS_PLAYER: The command will be executed
as the player who is staff but with the placeholder of {target} replaced by the player that
have been clicked.
- COMMAND_TARGET_AS_CONSOLE: The command will be executed as the console but with the placeholder
of {target} replaced by the player that have been clicked.
""")
private CustomItemType type;

@Setting
@Comment("""
The command to execute when the item is clicked.
You can use the placeholder {player} to get the player who clicked the item.
You can use the placeholder {target} to get the player who have been clicked.
""")
private String command;

public CustomItemPartial() {
}

public CustomItemPartial(
final boolean enabled,
@NotNull final String name,
@NotNull final Material material,
final int slot,
@NotNull final List<String> lore,
@NotNull final String permission,
@NotNull final CustomItemType type,
@NotNull final String command
) {
super(enabled, name, material, slot, lore, permission);
this.type = type;
this.command = command;
}

public CustomItemType getType() {
return type;
}

public void setType(CustomItemType type) {
this.type = type;
}

public String getCommand() {
return command;
}

public void setCommand(String command) {
this.command = command;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.nookure.staff.api.config.bukkit.partials;

public enum CustomItemType {
COMMAND_AS_PLAYER,
COMMAND_AS_CONSOLE,
COMMAND_TARGET_AS_PLAYER,
COMMAND_TARGET_AS_CONSOLE,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.nookure.staff.api.config.bukkit.partials;

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

@ConfigSerializable
public class PermissionConfigPartial {
@Setting
@Comment("Listen when a player gets `nookure.staff` permission to reconstruct the player wrapper.")
public boolean watchLuckPermsPermissions = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,42 @@
import org.spongepowered.configurate.objectmapping.meta.Comment;
import org.spongepowered.configurate.objectmapping.meta.Setting;

import java.util.UUID;

@ConfigSerializable
public class MessengerConfig {
@Setting
@Comment(
"""
The configuration for the Redis messenger.
"""
"""
)
public final RedisPartial redis = new RedisPartial();
public RedisPartial redis = new RedisPartial();

@Setting
@Comment("This UUID represents the server in SQL databases, ensure it's unique.")
public UUID serverId = UUID.randomUUID();

@Setting
@Comment(
"""
The type of messenger to use.
Here are the options:
- REDIS: Use Redis to send messages between servers (recommended)
- REDIS: Use Redis to send messages between servers, the most
reliable way to send messages between servers, but it requires
a Redis server to be installed and configured, it's the fastest.
- PM: Use plugin messages to send messages between servers this
will only work if all the servers are under the same proxy and
in the proxy is installed the bridge plugin.
will only work if all the servers are under the same proxy and
in the proxy is installed the bridge plugin, it's not the most
reliable way to send messages between servers.
- MYSQL: Use MySQL to send messages between servers, a bit more
reliable than PM but much more slower than Redis.
- NONE: Disable the sync, useful when you don't have a network
and you only have 1 server.
"""
"""
)
private MessengerType type = MessengerType.NONE;

Expand All @@ -35,6 +50,7 @@ public MessengerType getType() {
public enum MessengerType {
REDIS,
PM,
MYSQL,
NONE
}
}
Loading

0 comments on commit 066e50e

Please sign in to comment.