Skip to content

Commit 6599335

Browse files
authored
UltraStaffChat BungeeCord - Version 5.0.1
- Fixed prefix not disabling - Added /staffchatafk - Added embed field cap - Made the code A+ rating on Codefactor
2 parents da7bee3 + 9b9d8c5 commit 6599335

34 files changed

Lines changed: 1486 additions & 1307 deletions

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "daily"

.github/workflows/build.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: build
2+
3+
on: [ push ]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Set up JDK 1.8
11+
uses: actions/setup-java@v1
12+
with:
13+
java-version: 1.8
14+
- name: Cache Maven Dependencies
15+
uses: actions/cache@v2
16+
with:
17+
path: ~/.m2
18+
key: ubuntu-latest-m2-${{ hashFiles('**/pom.xml') }}
19+
restore-keys: ubuntu-latest-m2
20+
- name: Build with Maven
21+
run: mvn -B package --file pom.xml
22+
23+
- name: Upload artifacts
24+
uses: actions/upload-artifact@v2
25+
with:
26+
path: target/UltraStaffChat-*.jar
27+
retention-days: 7

.github/workflows/maven.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<div align="center"><img src="https://i.hypera.dev/assets/ultrastaffchat-logo.png" width="300" /></div>
22

3-
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/HyperaOfficial/UltraStaffChat/maven.yml?color=%232155CC&&style=for-the-badge)
4-
![GitHub Release Date](https://img.shields.io/github/release-date/HyperaOfficial/UltraStaffChat?color=%232155CC&&label=Last%20Release&&style=for-the-badge)
5-
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/HyperaOfficial/UltraStaffChat?color=%232155CC&&style=for-the-badge)
6-
![GitHub](https://img.shields.io/github/license/HyperaOfficial/UltraStaffChat?color=%232155CC&&style=for-the-badge)
3+
![Build Status](https://img.shields.io/github/workflow/status/HyperaOfficial/UltraStaffChat/build?color=%232155CC&&style=for-the-badge)
4+
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/HyperaOfficial/UltraStaffChat/main?style=for-the-badge)
5+
![Version](https://img.shields.io/github/v/tag/HyperaOfficial/UltraStaffChat?color=2155CC&label=Version&style=for-the-badge)
6+
![Code Size](https://img.shields.io/github/languages/code-size/HyperaOfficial/UltraStaffChat?color=%232155CC&&style=for-the-badge)
7+
![License](https://img.shields.io/github/license/HyperaOfficial/UltraStaffChat?color=%232155CC&&style=for-the-badge)
78

89
## Download
910
Click [here](https://www.spigotmc.org/resources/68956/) to download UltraStaffChat Bungeecord.

pom.xml

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

2525
<groupId>dev.hypera</groupId>
2626
<artifactId>UltraStaffChat</artifactId>
27-
<version>5.0.0</version>
27+
<version>5.0.1</version>
2828
<packaging>jar</packaging>
2929

3030
<name>UltraStaffChat</name>

src/main/java/dev/hypera/ultrastaffchat/UltraStaffChat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020

2121
import dev.hypera.ultrastaffchat.commands.CommandManager;
2222
import dev.hypera.ultrastaffchat.config.Config;
23+
import dev.hypera.ultrastaffchat.listeners.ListenerManager;
2324
import dev.hypera.ultrastaffchat.objects.ErrorCode;
2425
import dev.hypera.ultrastaffchat.utils.Common;
2526
import dev.hypera.ultrastaffchat.utils.Debug;
26-
import dev.hypera.ultrastaffchat.listeners.ListenerManager;
2727
import dev.hypera.ultrastaffchat.utils.Discord;
28-
2928
import dev.hypera.updatelib.UpdateLibBuilder;
3029
import dev.hypera.updatelib.internal.UpdateLib;
3130
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
@@ -123,4 +122,5 @@ public UpdateLib getUpdateLib() {
123122
throw new IllegalStateException("Cannot retrieve UpdateLib while the plugin is not enabled");
124123
return updateLib;
125124
}
125+
126126
}

src/main/java/dev/hypera/ultrastaffchat/commands/Command.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
package dev.hypera.ultrastaffchat.commands;
2020

2121
public abstract class Command extends net.md_5.bungee.api.plugin.Command {
22-
public Command(String name, String permission, String... aliases) {
23-
super(name, permission, aliases);
24-
}
2522

26-
public abstract boolean isDisabled();
23+
public Command(String name, String permission, String... aliases) {
24+
super(name, permission, aliases);
25+
}
26+
27+
public abstract boolean isDisabled();
28+
2729
}

src/main/java/dev/hypera/ultrastaffchat/commands/CommandManager.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@
2929

3030
public class CommandManager {
3131

32-
public static void setup() {
33-
Reflections reflections = new Reflections("dev.hypera.ultrastaffchat.commands.impl");
34-
35-
Set<Class<? extends Command>> allCommands =
36-
reflections.getSubTypesOf(Command.class);
37-
38-
for (Class<? extends Command> commandClass : allCommands) {
39-
try {
40-
Constructor<? extends Command> constructor = commandClass.getConstructor();
41-
constructor.setAccessible(true);
42-
Command c = constructor.newInstance();
43-
if (!c.isDisabled()) ProxyServer.getInstance().getPluginManager().registerCommand(UltraStaffChat.getInstance(), c);
44-
} catch (Exception ex) {
45-
Common.error(ErrorCode.REGISTER_FAILED_COMMAND, "Failed to register command.", ex);
46-
}
47-
}
48-
}
32+
public static void setup() {
33+
Reflections reflections = new Reflections("dev.hypera.ultrastaffchat.commands.impl");
34+
35+
Set<Class<? extends Command>> allCommands = reflections.getSubTypesOf(Command.class);
36+
37+
for(Class<? extends Command> commandClass : allCommands) {
38+
try {
39+
Constructor<? extends Command> constructor = commandClass.getConstructor();
40+
constructor.setAccessible(true);
41+
Command c = constructor.newInstance();
42+
if(!c.isDisabled())
43+
ProxyServer.getInstance().getPluginManager().registerCommand(UltraStaffChat.getInstance(), c);
44+
} catch (Exception ex) {
45+
Common.error(ErrorCode.REGISTER_FAILED_COMMAND, "Failed to register command.", ex);
46+
}
47+
}
48+
}
4949

5050
}

src/main/java/dev/hypera/ultrastaffchat/commands/impl/MuteStaffChatCommand.java

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -26,53 +26,55 @@
2626
import net.md_5.bungee.api.CommandSender;
2727

2828
public class MuteStaffChatCommand extends Command {
29-
public MuteStaffChatCommand() {
30-
super("mutestaffchat", null, "mutesc");
3129

32-
}
30+
public MuteStaffChatCommand() {
31+
super("mutestaffchat", null, "mutesc");
3332

34-
@Override
35-
public void execute(CommandSender sender, String[] args) {
33+
}
3634

37-
Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender);
35+
@Override
36+
public void execute(CommandSender sender, String[] args) {
3837

39-
if (!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-globalmute"))) {
40-
Common.logPrefix(UltraStaffChat.getConfig().getString("permission-globalmute"));
41-
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission")));
42-
return;
43-
}
38+
Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender);
4439

45-
if (args.length > 1) {
46-
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage")));
47-
return;
48-
}
40+
if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-globalmute"))) {
41+
Common.logPrefix(UltraStaffChat.getConfig().getString("permission-globalmute"));
42+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission")));
43+
return;
44+
}
4945

50-
if (args.length == 0) {
51-
boolean toggled = StaffChat.toggleStaffChatMute();
52-
if (toggled) {
53-
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&cmuted")));
54-
} else
55-
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&aunmuted")));
56-
return;
57-
}
46+
if(args.length > 1) {
47+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage")));
48+
return;
49+
}
5850

59-
if (args[0].matches("(?i:(off|false|disable(d)?|unmute(d)?))")) {
60-
StaffChat.unmuteStaffChat();
61-
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&aunmuted")));
62-
return;
63-
}
51+
if(args.length == 0) {
52+
boolean toggled = StaffChat.toggleStaffChatMute();
53+
if(toggled) {
54+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&cmuted")));
55+
} else
56+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&aunmuted")));
57+
return;
58+
}
6459

65-
if (args[0].matches("(?i:(on|true|enable(d)?|mute(d)?))")) {
66-
StaffChat.muteStaffChat();
67-
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&cmuted")));
68-
return;
69-
}
60+
if(args[0].matches("(?i:(off|false|disable(d)?|unmute(d)?))")) {
61+
StaffChat.unmuteStaffChat();
62+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&aunmuted")));
63+
return;
64+
}
7065

71-
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage")));
72-
}
66+
if(args[0].matches("(?i:(on|true|enable(d)?|mute(d)?))")) {
67+
StaffChat.muteStaffChat();
68+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&cmuted")));
69+
return;
70+
}
71+
72+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage")));
73+
}
74+
75+
@Override
76+
public boolean isDisabled() {
77+
return !UltraStaffChat.getConfig().getBoolean("mute-staffchat-enabled");
78+
}
7379

74-
@Override
75-
public boolean isDisabled() {
76-
return !UltraStaffChat.getConfig().getBoolean("mute-staffchat-enabled");
77-
}
7880
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* UltraStaffChat BungeeCord - A 100% Customizable StaffChat Plugin for BungeeCord!
3+
* Copyright (C) 2021 SLLCoding
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
package dev.hypera.ultrastaffchat.commands.impl;
20+
21+
import dev.hypera.ultrastaffchat.UltraStaffChat;
22+
import dev.hypera.ultrastaffchat.commands.Command;
23+
import dev.hypera.ultrastaffchat.utils.Common;
24+
import net.kyori.adventure.audience.Audience;
25+
import net.md_5.bungee.api.CommandSender;
26+
import net.md_5.bungee.api.connection.ProxiedPlayer;
27+
28+
import java.util.HashMap;
29+
import java.util.Map;
30+
import java.util.UUID;
31+
32+
public class StaffAfkCommand extends Command {
33+
34+
public StaffAfkCommand() {
35+
super("staffchatafk", null, "scafk");
36+
}
37+
38+
@Override
39+
public void execute(CommandSender sender, String[] args) {
40+
Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender);
41+
42+
if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-afk"))) {
43+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission")));
44+
return;
45+
}
46+
47+
if(!(sender instanceof ProxiedPlayer)) {
48+
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("ingame-only")));
49+
return;
50+
}
51+
52+
ProxiedPlayer p = (ProxiedPlayer) sender;
53+
boolean toggled = toggleAfk(p);
54+
Audience all = UltraStaffChat.getInstance().getAdventure().permission(UltraStaffChat.getConfig().getString("permission-read"));
55+
if(toggled) {
56+
all.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("afk-broadcast").replaceAll("\\{player}", p.getName())));
57+
} else
58+
all.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-afk-broadcast").replaceAll("\\{player}", p.getName())));
59+
}
60+
61+
@Override
62+
public boolean isDisabled() {
63+
return !UltraStaffChat.getConfig().getBoolean("afk-enabled");
64+
}
65+
66+
private final Map<UUID, Boolean> afkStatus = new HashMap<>();
67+
68+
private boolean toggleAfk(ProxiedPlayer player) {
69+
if (!afkStatus.containsKey(player.getUniqueId())) {
70+
afkStatus.put(player.getUniqueId(), true);
71+
return true;
72+
} else {
73+
boolean oldAfk = afkStatus.get(player.getUniqueId());
74+
afkStatus.replace(player.getUniqueId(), !oldAfk);
75+
return !oldAfk;
76+
}
77+
}
78+
79+
}

0 commit comments

Comments
 (0)