Skip to content

Commit 6ae4e68

Browse files
committed
Add broadcastmsg and reload command
1 parent 7d33e42 commit 6ae4e68

File tree

8 files changed

+155
-39
lines changed

8 files changed

+155
-39
lines changed

.github/workflows/maven.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Java CI with Maven
10+
11+
on:
12+
push:
13+
branches: [ "master" ]
14+
pull_request:
15+
branches: [ "master" ]
16+
17+
jobs:
18+
build:
19+
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-java@v4
25+
with:
26+
java-version: '17'
27+
distribution: 'temurin'
28+
cache: maven
29+
30+
# Build and verify
31+
- run: mvn --batch-mode --update-snapshots verify
32+
33+
# Prepare the artifact for upload
34+
- run: mkdir staging && cp target/*.jar staging
35+
36+
# Upload artifact
37+
- uses: actions/upload-artifact@v4
38+
with:
39+
name: Package
40+
path: staging
41+
42+
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
43+
- name: Update dependency graph
44+
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>simplexity</groupId>
88
<artifactId>AdminHax</artifactId>
9-
<version>1.0.0</version>
9+
<version>1.1.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>AdminHax</name>

src/main/java/simplexity/adminhax/AdminHax.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import net.kyori.adventure.text.minimessage.MiniMessage;
44
import org.bukkit.plugin.java.JavaPlugin;
5+
import simplexity.adminhax.commands.basic.BroadcastMsg;
6+
import simplexity.adminhax.commands.basic.ReloadPlugin;
57
import simplexity.adminhax.commands.withargs.GodMode;
68
import simplexity.adminhax.commands.hax.Feed;
79
import simplexity.adminhax.commands.hax.Fly;
@@ -32,6 +34,8 @@ public void onEnable() {
3234
this.getCommand("heal").setExecutor(new Heal(Util.HEAL_PERMISSION, Util.HEAL_OTHER_PERMISSION));
3335
this.getCommand("repair").setExecutor(new Repair(Util.REPAIR_HAND_PERMISSION, "hand"));
3436
this.getCommand("godmode").setExecutor(new GodMode(Util.GODMODE_PERMISSION, "toggle"));
37+
this.getCommand("broadcastmsg").setExecutor(new BroadcastMsg());
38+
this.getCommand("adminhaxreload").setExecutor(new ReloadPlugin());
3539
this.getServer().getPluginManager().registerEvents(new FlyListeners(), this);
3640
}
3741

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package simplexity.adminhax.commands.basic;
2+
3+
import org.bukkit.command.Command;
4+
import org.bukkit.command.CommandExecutor;
5+
import org.bukkit.command.CommandSender;
6+
import org.jetbrains.annotations.NotNull;
7+
import simplexity.adminhax.AdminHax;
8+
import simplexity.adminhax.config.LocaleHandler;
9+
10+
public class BroadcastMsg implements CommandExecutor {
11+
@Override
12+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
13+
if (args.length == 0) {
14+
sender.sendRichMessage(LocaleHandler.getInstance().getInvalidCommand());
15+
return false;
16+
}
17+
StringBuilder msg = new StringBuilder();
18+
for (String arg : args) {
19+
msg.append(arg).append(" ");
20+
}
21+
String message = msg.toString().trim();
22+
message = LocaleHandler.getInstance().getBroadcastServerPrefix() + message;
23+
AdminHax.getInstance().getServer().sendMessage(AdminHax.getMiniMessage().deserialize(message));
24+
return true;
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package simplexity.adminhax.commands.basic;
2+
3+
import org.bukkit.command.Command;
4+
import org.bukkit.command.CommandExecutor;
5+
import org.bukkit.command.CommandSender;
6+
import org.jetbrains.annotations.NotNull;
7+
import simplexity.adminhax.config.ConfigHandler;
8+
import simplexity.adminhax.config.LocaleHandler;
9+
10+
public class ReloadPlugin implements CommandExecutor {
11+
@Override
12+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
13+
ConfigHandler.getInstance().reloadConfigValues();
14+
LocaleHandler.getInstance().loadLocale();
15+
sender.sendRichMessage(LocaleHandler.getInstance().getConfigReloaded());
16+
return true;
17+
}
18+
}

src/main/java/simplexity/adminhax/config/LocaleHandler.java

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class LocaleHandler {
2828
private String repairSelf, repairOther, repairHeader, noItemsRepaired;
2929
//GodMode messages
3030
private String godmodeSelf, godmodeOther, godmodeGetSelf, godmodeGetOther;
31+
//Broadcast Message
32+
private String broadcastServerPrefix;
3133
//Errors
3234
private String invalidPlayer, noPermission, mustBePlayer, notEnoughArguments, invalidNumber, notInRange,
3335
invalidCommand, configReloaded, cannotBeRepaired;
@@ -55,44 +57,45 @@ public void loadLocale() {
5557
} catch (IOException | InvalidConfigurationException e) {
5658
e.printStackTrace();
5759
}
58-
prefix = localeConfig.getString("insertion.prefix");
59-
enabled = localeConfig.getString("insertion.enabled");
60-
disabled = localeConfig.getString("insertion.disabled");
61-
flyspeed = localeConfig.getString("insertion.flyspeed");
62-
walkspeed = localeConfig.getString("insertion.walkspeed");
63-
item = localeConfig.getString("insertion.item");
64-
flySetOwn = localeConfig.getString("fly.own");
65-
flySetOther = localeConfig.getString("fly.other");
66-
flySetByOther = localeConfig.getString("fly.by-other");
67-
speedGetOther = localeConfig.getString("speed.get.other");
68-
speedGetOwn = localeConfig.getString("speed.get.own");
69-
speedSetOwn = localeConfig.getString("speed.set.own");
70-
speedResetOwn = localeConfig.getString("speed.reset.own");
71-
speedSetOther = localeConfig.getString("speed.set.other");
72-
speedResetOther = localeConfig.getString("speed.reset.other");
73-
speedSetByOther = localeConfig.getString("speed.set.by-other");
74-
speedResetByOther = localeConfig.getString("speed.reset.by-other");
75-
feedSelf = localeConfig.getString("feed.self");
76-
feedOther = localeConfig.getString("feed.other");
77-
healSelf = localeConfig.getString("heal.self");
78-
healOther = localeConfig.getString("heal.other");
79-
repairSelf = localeConfig.getString("repair.self");
80-
repairOther = localeConfig.getString("repair.other");
81-
repairHeader = localeConfig.getString("repair.header");
82-
godmodeSelf = localeConfig.getString("godmode.self");
83-
godmodeOther = localeConfig.getString("godmode.other");
84-
godmodeGetSelf = localeConfig.getString("godmode.get.self");
85-
godmodeGetOther = localeConfig.getString("godmode.get.other");
86-
noItemsRepaired = localeConfig.getString("repair.no-items-repaired");
87-
invalidPlayer = localeConfig.getString("error.invalid-player");
88-
noPermission = localeConfig.getString("error.no-permission");
89-
mustBePlayer = localeConfig.getString("error.must-be-player");
90-
notEnoughArguments = localeConfig.getString("error.not-enough-arguments");
91-
invalidNumber = localeConfig.getString("error.invalid-number");
92-
notInRange = localeConfig.getString("error.not-in-range");
93-
invalidCommand = localeConfig.getString("error.invalid-command");
94-
cannotBeRepaired = localeConfig.getString("error.cannot-be-repaired");
95-
configReloaded = localeConfig.getString("plugin-messages.config-reloaded");
60+
prefix = localeConfig.getString("insertion.prefix", "<green>[<yellow>SF</yellow>]</green> ");
61+
enabled = localeConfig.getString("insertion.enabled", "<green>enabled</green>");
62+
disabled = localeConfig.getString("insertion.disabled", "<red>disabled</red>");
63+
flyspeed = localeConfig.getString("insertion.flyspeed", "<yellow>flyspeed</yellow>");
64+
walkspeed = localeConfig.getString("insertion.walkspeed", "<yellow>walkspeed</yellow>");
65+
item = localeConfig.getString("insertion.item", "\n<gray>• <lang:<item>></gray>");
66+
flySetOwn = localeConfig.getString("fly.own", "Your fly has been <value>");
67+
flySetOther = localeConfig.getString("fly.other", "<target>'s fly has been <value>");
68+
flySetByOther = localeConfig.getString("fly.by-other", "<green>Your fly has been <value></green>");
69+
speedGetOther = localeConfig.getString("speed.get.other", "<grey><target>'s current <speedtype> is <value></grey>");
70+
speedGetOwn = localeConfig.getString("speed.get.own","<grey>Your <speedtype> is currently set to <value></grey>");
71+
speedSetOwn = localeConfig.getString("speed.set.own", "<green>Your <speedtype> has been set to <value></green>");
72+
speedResetOwn = localeConfig.getString("speed.reset.own", "<green>Your <speedtype> has been reset</green>");
73+
speedSetOther = localeConfig.getString("speed.set.other", "<green>You set <target>'s <speedtype> to <value></green>");
74+
speedResetOther = localeConfig.getString("speed.reset.other", "<green><target>'s <speedtype> has been reset</green>");
75+
speedSetByOther = localeConfig.getString("speed.set.by-other", "<green>Your <speedtype> has been set to <value> by <initiator></green>");
76+
speedResetByOther = localeConfig.getString("speed.reset.by-other", "<green>Your <speedtype> has been reset by <initiator></green>");
77+
feedSelf = localeConfig.getString("feed.self", "<green>You have been fed</green>");
78+
feedOther = localeConfig.getString("feed.other", "<green>You have fed <target></green>");
79+
healSelf = localeConfig.getString("heal.self", "<green>You have been healed</green>");
80+
healOther = localeConfig.getString("heal.other", "<green>You have healed <target></green>");
81+
repairSelf = localeConfig.getString("repair.self", "<green><hover:show_text:'<items>'>Your items have been repaired!</hover></green>");
82+
repairOther = localeConfig.getString("repair.other", "<green><hover:show_text:'<items>'>You have repaired <target>'s items!</hover><green>");
83+
repairHeader = localeConfig.getString("repair.header", "<aqua><u>Repaired Items</u></aqua>");
84+
godmodeSelf = localeConfig.getString("godmode.self", "<yellow>God-Mode has been <value></yellow>");
85+
godmodeOther = localeConfig.getString("godmode.other", "<yellow>God-Mode has been <value> for <target></yellow>");
86+
godmodeGetSelf = localeConfig.getString("godmode.get.self", "<yellow>God-Mode is currently <value></yellow>");
87+
godmodeGetOther = localeConfig.getString("godmode.get.other", "<yellow><target>'s God-Mode is currently <value></yellow>");
88+
noItemsRepaired = localeConfig.getString("repair.no-items-repaired", "<gray>No items were able to be repaired</gray>");
89+
invalidPlayer = localeConfig.getString("error.invalid-player", "<red>That is not a valid player. Please check your spelling and try again</red>");
90+
noPermission = localeConfig.getString("error.no-permission", "<red>You do not have permission to run this command</red>");
91+
mustBePlayer = localeConfig.getString("error.must-be-player", "<red>You must be a player to run this command</red>");
92+
notEnoughArguments = localeConfig.getString("error.not-enough-arguments", "<red>You did not provide enough arguments. Please check your syntax and try again</red>");
93+
invalidNumber = localeConfig.getString("error.invalid-number", "<red>Sorry, you did not enter a valid flyspeed, please try again</red>");
94+
notInRange = localeConfig.getString("error.not-in-range", "<red>Sorry, you must provide a number between <min> and <max></red>");
95+
invalidCommand = localeConfig.getString("error.invalid-command", "<red>Sorry, that subcommand is invalid. Please check your syntax and try again</red>");
96+
cannotBeRepaired = localeConfig.getString("error.cannot-be-repaired", "<red>That item cannot be repaired</red>");
97+
configReloaded = localeConfig.getString("plugin-messages.config-reloaded", "<gold>Config Reloaded</gold>");
98+
broadcastServerPrefix = localeConfig.getString("broadcast.server-prefix", "<green>[Server]</green> » ");
9699
}
97100

98101
public String getPrefix() {
@@ -246,4 +249,8 @@ public String getGodmodeGetSelf() {
246249
public String getGodmodeGetOther() {
247250
return godmodeGetOther;
248251
}
252+
253+
public String getBroadcastServerPrefix() {
254+
return broadcastServerPrefix;
255+
}
249256
}

src/main/resources/locale.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,7 @@ error:
4747
not-in-range : "<red>Sorry, you must provide a number between <min> and <max></red>"
4848
invalid-command : "<red>Sorry, that subcommand is invalid. Please check your syntax and try again</red>"
4949
cannot-be-repaired: "<red>That item cannot be repaired</red>"
50+
broadcast:
51+
server-prefix: "<green>[Server]</green> » "
5052
plugin-messages:
5153
config-reloaded: "<gold>Config Reloaded</gold>"

src/main/resources/plugin.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ commands:
3535
permission: adminhax.commands.godmode
3636
description: allows you to toggle godmode/invincibility
3737
usage: /<command> [get|toggle] <player>
38+
broadcastmsg:
39+
permissions: adminhax.commands.broadcast
40+
description: allows you to broadcast a message server-wide
41+
usage: /broadcastmsg <message>
42+
aliases: [broadcast]
43+
adminhaxreload:
44+
permissions: adminhax.reload
45+
description: reloads the plugin
46+
usage: /adminhaxreload
3847
permissions:
3948
adminhax.commands.speed.walk:
4049
default: op
@@ -134,3 +143,9 @@ permissions:
134143
adminhax.commands.other.godmode.get:
135144
default: op
136145
description: allows you to see what others' godmode status is
146+
adminhax.commands.broadcast:
147+
default: op
148+
description: Allows you to broadcast a message to the server
149+
adminhax.reload:
150+
default: op
151+
description: Reloads the plugin

0 commit comments

Comments
 (0)