Skip to content

Commit

Permalink
UltraStaffChat BungeeCord - Version 5.0.1
Browse files Browse the repository at this point in the history
- Fixed prefix not disabling
- Added /staffchatafk
- Added embed field cap
- Made the code A+ rating on Codefactor
  • Loading branch information
LooFifteen authored May 5, 2021
2 parents da7bee3 + 9b9d8c5 commit 6599335
Show file tree
Hide file tree
Showing 34 changed files with 1,486 additions and 1,307 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: build

on: [ push ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Maven Dependencies
uses: actions/cache@v2
with:
path: ~/.m2
key: ubuntu-latest-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ubuntu-latest-m2
- name: Build with Maven
run: mvn -B package --file pom.xml

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
path: target/UltraStaffChat-*.jar
retention-days: 7
24 changes: 0 additions & 24 deletions .github/workflows/maven.yml

This file was deleted.

9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<div align="center"><img src="https://i.hypera.dev/assets/ultrastaffchat-logo.png" width="300" /></div>

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

## Download
Click [here](https://www.spigotmc.org/resources/68956/) to download UltraStaffChat Bungeecord.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<groupId>dev.hypera</groupId>
<artifactId>UltraStaffChat</artifactId>
<version>5.0.0</version>
<version>5.0.1</version>
<packaging>jar</packaging>

<name>UltraStaffChat</name>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dev/hypera/ultrastaffchat/UltraStaffChat.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@

import dev.hypera.ultrastaffchat.commands.CommandManager;
import dev.hypera.ultrastaffchat.config.Config;
import dev.hypera.ultrastaffchat.listeners.ListenerManager;
import dev.hypera.ultrastaffchat.objects.ErrorCode;
import dev.hypera.ultrastaffchat.utils.Common;
import dev.hypera.ultrastaffchat.utils.Debug;
import dev.hypera.ultrastaffchat.listeners.ListenerManager;
import dev.hypera.ultrastaffchat.utils.Discord;

import dev.hypera.updatelib.UpdateLibBuilder;
import dev.hypera.updatelib.internal.UpdateLib;
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
Expand Down Expand Up @@ -123,4 +122,5 @@ public UpdateLib getUpdateLib() {
throw new IllegalStateException("Cannot retrieve UpdateLib while the plugin is not enabled");
return updateLib;
}

}
10 changes: 6 additions & 4 deletions src/main/java/dev/hypera/ultrastaffchat/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
package dev.hypera.ultrastaffchat.commands;

public abstract class Command extends net.md_5.bungee.api.plugin.Command {
public Command(String name, String permission, String... aliases) {
super(name, permission, aliases);
}

public abstract boolean isDisabled();
public Command(String name, String permission, String... aliases) {
super(name, permission, aliases);
}

public abstract boolean isDisabled();

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@

public class CommandManager {

public static void setup() {
Reflections reflections = new Reflections("dev.hypera.ultrastaffchat.commands.impl");

Set<Class<? extends Command>> allCommands =
reflections.getSubTypesOf(Command.class);

for (Class<? extends Command> commandClass : allCommands) {
try {
Constructor<? extends Command> constructor = commandClass.getConstructor();
constructor.setAccessible(true);
Command c = constructor.newInstance();
if (!c.isDisabled()) ProxyServer.getInstance().getPluginManager().registerCommand(UltraStaffChat.getInstance(), c);
} catch (Exception ex) {
Common.error(ErrorCode.REGISTER_FAILED_COMMAND, "Failed to register command.", ex);
}
}
}
public static void setup() {
Reflections reflections = new Reflections("dev.hypera.ultrastaffchat.commands.impl");

Set<Class<? extends Command>> allCommands = reflections.getSubTypesOf(Command.class);

for(Class<? extends Command> commandClass : allCommands) {
try {
Constructor<? extends Command> constructor = commandClass.getConstructor();
constructor.setAccessible(true);
Command c = constructor.newInstance();
if(!c.isDisabled())
ProxyServer.getInstance().getPluginManager().registerCommand(UltraStaffChat.getInstance(), c);
} catch (Exception ex) {
Common.error(ErrorCode.REGISTER_FAILED_COMMAND, "Failed to register command.", ex);
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,53 +26,55 @@
import net.md_5.bungee.api.CommandSender;

public class MuteStaffChatCommand extends Command {
public MuteStaffChatCommand() {
super("mutestaffchat", null, "mutesc");

}
public MuteStaffChatCommand() {
super("mutestaffchat", null, "mutesc");

@Override
public void execute(CommandSender sender, String[] args) {
}

Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender);
@Override
public void execute(CommandSender sender, String[] args) {

if (!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-globalmute"))) {
Common.logPrefix(UltraStaffChat.getConfig().getString("permission-globalmute"));
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission")));
return;
}
Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender);

if (args.length > 1) {
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage")));
return;
}
if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-globalmute"))) {
Common.logPrefix(UltraStaffChat.getConfig().getString("permission-globalmute"));
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission")));
return;
}

if (args.length == 0) {
boolean toggled = StaffChat.toggleStaffChatMute();
if (toggled) {
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&cmuted")));
} else
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&aunmuted")));
return;
}
if(args.length > 1) {
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage")));
return;
}

if (args[0].matches("(?i:(off|false|disable(d)?|unmute(d)?))")) {
StaffChat.unmuteStaffChat();
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&aunmuted")));
return;
}
if(args.length == 0) {
boolean toggled = StaffChat.toggleStaffChatMute();
if(toggled) {
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&cmuted")));
} else
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&aunmuted")));
return;
}

if (args[0].matches("(?i:(on|true|enable(d)?|mute(d)?))")) {
StaffChat.muteStaffChat();
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&cmuted")));
return;
}
if(args[0].matches("(?i:(off|false|disable(d)?|unmute(d)?))")) {
StaffChat.unmuteStaffChat();
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&aunmuted")));
return;
}

audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage")));
}
if(args[0].matches("(?i:(on|true|enable(d)?|mute(d)?))")) {
StaffChat.muteStaffChat();
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message").replaceAll("\\{mute}", "&cmuted")));
return;
}

audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage")));
}

@Override
public boolean isDisabled() {
return !UltraStaffChat.getConfig().getBoolean("mute-staffchat-enabled");
}

@Override
public boolean isDisabled() {
return !UltraStaffChat.getConfig().getBoolean("mute-staffchat-enabled");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* UltraStaffChat BungeeCord - A 100% Customizable StaffChat Plugin for BungeeCord!
* Copyright (C) 2021 SLLCoding
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package dev.hypera.ultrastaffchat.commands.impl;

import dev.hypera.ultrastaffchat.UltraStaffChat;
import dev.hypera.ultrastaffchat.commands.Command;
import dev.hypera.ultrastaffchat.utils.Common;
import net.kyori.adventure.audience.Audience;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class StaffAfkCommand extends Command {

public StaffAfkCommand() {
super("staffchatafk", null, "scafk");
}

@Override
public void execute(CommandSender sender, String[] args) {
Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender);

if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-afk"))) {
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission")));
return;
}

if(!(sender instanceof ProxiedPlayer)) {
audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("ingame-only")));
return;
}

ProxiedPlayer p = (ProxiedPlayer) sender;
boolean toggled = toggleAfk(p);
Audience all = UltraStaffChat.getInstance().getAdventure().permission(UltraStaffChat.getConfig().getString("permission-read"));
if(toggled) {
all.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("afk-broadcast").replaceAll("\\{player}", p.getName())));
} else
all.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-afk-broadcast").replaceAll("\\{player}", p.getName())));
}

@Override
public boolean isDisabled() {
return !UltraStaffChat.getConfig().getBoolean("afk-enabled");
}

private final Map<UUID, Boolean> afkStatus = new HashMap<>();

private boolean toggleAfk(ProxiedPlayer player) {
if (!afkStatus.containsKey(player.getUniqueId())) {
afkStatus.put(player.getUniqueId(), true);
return true;
} else {
boolean oldAfk = afkStatus.get(player.getUniqueId());
afkStatus.replace(player.getUniqueId(), !oldAfk);
return !oldAfk;
}
}

}
Loading

0 comments on commit 6599335

Please sign in to comment.