├── .gitattributes ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── libs.versions.toml ├── .github ├── renovate.json5 ├── ISSUE_TEMPLATE │ ├── config.yml │ ├── feature_request.yml │ └── bug_report.yml ├── CODEOWNERS ├── workflows │ ├── gradle.yml │ ├── snapshot.yml │ └── release.yml ├── release.yml └── PULL_REQUEST_TEMPLATE.md ├── src └── main │ ├── resources │ ├── bungee.yml │ └── config.yml │ └── java │ └── dev │ └── hypera │ └── ultrastaffchat │ ├── listeners │ ├── Listener.java │ ├── ListenerManager.java │ └── impl │ │ ├── SwitchListener.java │ │ ├── JoinLeaveListener.java │ │ └── ChatListener.java │ ├── commands │ ├── Command.java │ ├── CommandManager.java │ └── impl │ │ ├── StaffChatCommand.java │ │ ├── StaffListCommand.java │ │ ├── MuteStaffChatCommand.java │ │ ├── StaffChatMuteCommand.java │ │ ├── StaffChatToggleCommand.java │ │ ├── StaffAfkCommand.java │ │ └── UltraStaffChatCommand.java │ ├── events │ └── staff │ │ ├── StaffLeaveEvent.java │ │ ├── StaffToggleAFKEvent.java │ │ ├── StaffChatEvent.java │ │ ├── StaffJoinEvent.java │ │ └── StaffSwitchServerEvent.java │ ├── utils │ ├── TimeUtils.java │ ├── Debug.java │ ├── PasteUtils.java │ ├── StaffChat.java │ ├── MD_.java │ ├── Common.java │ ├── DiscordWebhook.java │ └── Discord.java │ ├── objects │ └── ErrorCode.java │ ├── config │ └── Config.java │ ├── UltraStaffChat.java │ └── managers │ ├── DebugManager.java │ └── StaffChatManager.java ├── AUTHORS ├── license_header.txt ├── gradle.properties ├── settings.gradle.kts ├── README.md ├── .gitignore ├── SECURITY.md ├── gradlew.bat ├── CODE_OF_CONDUCT.md ├── gradlew └── LICENSE /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | *.bat text eol=crlf 3 | *.jar binary 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperadev/UltraStaffChat/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.github/renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | $schema: 'https://docs.renovatebot.com/renovate-schema.json', 3 | extends: [ 4 | 'github>HyperaDev/actions', 5 | ], 6 | } 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Discord 4 | url: https://discord.hypera.dev/ 5 | about: Need help? Discord is the best place to ask questions or receive support. 6 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # All contributions, including contributions by the Hypera developers, require review. 2 | # Before a pull request can be merged, it must be reviewed by at least two of the following accounts: 3 | * @joshuasing @LooFifteen 4 | -------------------------------------------------------------------------------- /src/main/resources/bungee.yml: -------------------------------------------------------------------------------- 1 | name: "UltraStaffChat" 2 | version: "@version@" 3 | author: "Joshua Sing, LooFifteen, Christian F" 4 | main: "dev.hypera.ultrastaffchat.UltraStaffChat" 5 | description: "A fully customisable staff communication plugin for BungeeCord!" 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions workflow to build a Gradle project. 2 | name: "Gradle" 3 | on: 4 | push: 5 | branches: [ "main", "releases/**" ] 6 | tags-ignore: ["**"] 7 | pull_request: 8 | branches: [ "main" ] 9 | merge_group: 10 | 11 | jobs: 12 | build: 13 | name: "Build" 14 | uses: HyperaDev/actions/.github/workflows/gradle-build.yml@main 15 | with: 16 | codecov_enabled: false 17 | upload_artifacts: | 18 | build/libs/UltraStaffChat-*.jar 19 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # UltraStaffChat Copyright Holders (the "UltraStaffChat Authors") 2 | # This is a list of entities who own copyright for portions of UltraStaffChat's code. 3 | # 4 | # Acceptable formats for entries in this file: 5 | # Organisation Name 6 | # Individual Name 7 | # Individual Name 8 | # 9 | # Please keep this list sorted alphabetically. 10 | 11 | Christian Fitzgerald 12 | Joshua Sing 13 | LooFifteen 14 | -------------------------------------------------------------------------------- /.github/release.yml: -------------------------------------------------------------------------------- 1 | changelog: 2 | exclude: 3 | categories: 4 | - title: "⚠️ Breaking changes" 5 | labels: 6 | - "status: breaking" 7 | - title: "✨ Additions" 8 | labels: 9 | - "type: feature" 10 | - title: "🐛 Fixes" 11 | labels: 12 | - "type: bug: fix" 13 | - title: "🔧 Improvements" 14 | labels: 15 | - "type: enhancement" 16 | - "type: refactor" 17 | - "type: performance" 18 | - "type: removal" 19 | - title: "📖 Documentation" 20 | labels: 21 | - "type: documentation" 22 | - title: "🧪 Test coverage" 23 | labels: 24 | - "type: test" 25 | - title: "⚙️ Other" 26 | labels: 27 | - "*" 28 | -------------------------------------------------------------------------------- /license_header.txt: -------------------------------------------------------------------------------- 1 | This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 2 | 3 | Copyright (C) 2021-2023 The UltraStaffChat Authors. 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 . 17 | -------------------------------------------------------------------------------- /.github/workflows/snapshot.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions workflow to publish unstable snapshots. 2 | # Snapshots are published from the 'main' branch, and should always be considered 3 | # unstable and unfit for production usage. 4 | name: "Snapshot" 5 | on: 6 | push: 7 | branches: [ "main" ] 8 | 9 | concurrency: 10 | group: "gradle-snapshot-${{ github.ref }}" 11 | cancel-in-progress: true 12 | 13 | jobs: 14 | snapshot: 15 | name: "Snapshot" 16 | uses: HyperaDev/actions/.github/workflows/gradle-snapshot.yml@main 17 | secrets: 18 | HYPERA_SIGNING_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" 19 | HYPERA_SIGNING_PASSWORD: "${{ secrets.GPG_PASSPHRASE }}" 20 | HYPERA_SNAPSHOTS_USERNAME: "${{ secrets.HYPERA_SNAPSHOTS_USERNAME }}" 21 | HYPERA_SNAPSHOTS_PASSWORD: "${{ secrets.HYPERA_SNAPSHOTS_PASSWORD }}" 22 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # GitHub Actions workflow to publish releases. 2 | # Releases are published from the 'releases/' branches. 3 | name: "Release" 4 | on: 5 | push: 6 | branches: [ "releases/**" ] 7 | 8 | concurrency: 9 | group: "gradle-release-${{ github.ref }}" 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | release: 14 | name: "Release" 15 | uses: HyperaDev/actions/.github/workflows/gradle-release.yml@main 16 | with: 17 | project_name: "UltraStaffChat" 18 | release_files: | 19 | build/libs/UltraStaffChat-*.jar 20 | secrets: 21 | HYPERA_SIGNING_KEY: "${{ secrets.GPG_PRIVATE_KEY }}" 22 | HYPERA_SIGNING_PASSWORD: "${{ secrets.GPG_PASSPHRASE }}" 23 | HYPERA_RELEASES_USERNAME: "${{ secrets.HYPERA_RELEASES_USERNAME }}" 24 | HYPERA_RELEASES_PASSWORD: "${{ secrets.HYPERA_RELEASES_PASSWORD }}" 25 | GITHUB_RELEASE_TOKEN: "${{ secrets.HYPERA_BOT_TOKEN }}" 26 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | # 4 | # Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | # 6 | # This program is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program. If not, see . 18 | # 19 | 20 | org.gradle.jvmargs=-Xmx4G 21 | org.gradle.parallel=true 22 | org.gradle.daemon=true 23 | org.gradle.configureondemand=true 24 | org.gradle.caching=true 25 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | pluginManagement { 20 | includeBuild("build-logic") 21 | repositories { 22 | gradlePluginPortal() 23 | } 24 | } 25 | 26 | rootProject.name = "ultrastaffchat" 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 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) 8 | 9 | ## Download 10 | Click [here](https://www.spigotmc.org/resources/68956/) to download UltraStaffChat Bungeecord. 11 | 12 | ## License 13 | UltraStaffChat is licensed under the GNU General Public License v3.0.
14 | Check [LICENSE](https://github.com/HyperaOfficial/UltraStaffChat/tree/main/LICENSE) for more information. 15 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/listeners/Listener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.listeners; 20 | 21 | public class Listener implements net.md_5.bungee.api.plugin.Listener { 22 | 23 | public Listener() { 24 | 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Summary** 2 | 3 | 4 | 5 | **Changes** 6 | 7 | 8 | **Checklist** 9 | - [ ] I acknowledge and agree to the terms of the [Developer Certificate of Origin](https://developercertificate.org/). 10 | - [ ] All contributed code can be distributed under the terms of the [GNU General Public License v3 or later](https://github.com/HyperaDev/UltraStaffChat/blob/main/LICENSE). 11 | - [ ] I have read and agree to follow the [Code of Conduct](https://github.com/HyperaDev/.github/blob/main/CODE_OF_CONDUCT.md). 12 | - [ ] I have checked the ["Allow edit from maintainers"](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) option. 13 | - [ ] I have added appropriate unit tests for my changes. 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/Command.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.commands; 20 | 21 | public abstract class Command extends net.md_5.bungee.api.plugin.Command { 22 | 23 | public Command(String name, String permission, String... aliases) { 24 | super(name, permission, aliases); 25 | } 26 | 27 | public abstract boolean isDisabled(); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Intellij 2 | .idea/ 3 | *.iml 4 | *.ipr 5 | 6 | # CMake 7 | cmake-build-*/ 8 | 9 | # File-based project format 10 | *.iws 11 | 12 | # IntelliJ 13 | out/ 14 | 15 | # mpeltonen/sbt-idea plugin 16 | .idea_modules/ 17 | 18 | # JIRA plugin 19 | atlassian-ide-plugin.xml 20 | 21 | # Crashlytics plugin (for Android Studio and IntelliJ) 22 | com_crashlytics_export_strings.xml 23 | crashlytics.properties 24 | crashlytics-build.properties 25 | fabric.properties 26 | 27 | ### Java 28 | # Compiled class file 29 | *.class 30 | 31 | # Log file 32 | *.log 33 | 34 | # BlueJ files 35 | *.ctxt 36 | 37 | # Mobile Tools for Java (J2ME) 38 | .mtj.tmp/ 39 | 40 | # Package Files # 41 | *.jar 42 | *.war 43 | *.nar 44 | *.ear 45 | *.zip 46 | *.tar.gz 47 | *.rar 48 | 49 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 50 | hs_err_pid* 51 | replay_pid* 52 | 53 | ### Gradle 54 | .gradle 55 | **/build/ 56 | !src/**/build/ 57 | 58 | # Ignore Gradle GUI config 59 | gradle-app.setting 60 | 61 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 62 | !gradle-wrapper.jar 63 | 64 | # Avoid ignore Gradle wrappper properties 65 | !gradle-wrapper.properties 66 | 67 | # Cache of project 68 | .gradletasknamecache 69 | 70 | # Eclipse Gradle plugin generated files 71 | # Eclipse Core 72 | .project 73 | # JDT-specific (Eclipse Java Development Tools) 74 | .classpath 75 | 76 | run/ 77 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: Feature Request 2 | description: Create a feature request to suggest a feature that we can add. 3 | labels: [ "status: triage", "type: enhancement" ] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Please do **not** use the 'Feature Request' template for questions, instead ask in our [Discord Server](https://discord.hypera.dev/) 9 | - type: checkboxes 10 | attributes: 11 | label: Confirmation 12 | description: Please confirm that you have done the following before creating this issue. 13 | options: 14 | - label: I have checked for similar issues. 15 | required: true 16 | - type: textarea 17 | attributes: 18 | label: Problem 19 | description: A clear and concise description of what the problem is. 20 | placeholder: I'm always frustrated when [...] 21 | validations: 22 | required: true 23 | - type: textarea 24 | attributes: 25 | label: Suggested solution 26 | description: Please provide a clear and concise description of what you suggest a solution to this problem would be. 27 | placeholder: It would be helpful if UltraStaffChat could ... 28 | validations: 29 | required: true 30 | - type: textarea 31 | attributes: 32 | label: Additional information 33 | description: | 34 | Please provide any additional information about this feature request. 35 | Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. 36 | validations: 37 | required: false 38 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/events/staff/StaffLeaveEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.events.staff; 20 | 21 | import net.md_5.bungee.api.connection.ProxiedPlayer; 22 | import net.md_5.bungee.api.event.PlayerDisconnectEvent; 23 | import net.md_5.bungee.api.plugin.Cancellable; 24 | 25 | /** 26 | * Called when a player with the permission `staffchat.leave` leaves the proxy. When cancelled, the staff leave message 27 | * is not shown. 28 | */ 29 | public class StaffLeaveEvent extends PlayerDisconnectEvent implements Cancellable { 30 | 31 | private boolean cancelled = false; 32 | 33 | public StaffLeaveEvent(ProxiedPlayer player) { 34 | super(player); 35 | } 36 | 37 | @Override 38 | public boolean isCancelled() { 39 | return cancelled; 40 | } 41 | 42 | @Override 43 | public void setCancelled(boolean cancel) { 44 | this.cancelled = cancel; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/listeners/ListenerManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.listeners; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.listeners.impl.ChatListener; 23 | import dev.hypera.ultrastaffchat.listeners.impl.JoinLeaveListener; 24 | import dev.hypera.ultrastaffchat.listeners.impl.SwitchListener; 25 | import net.md_5.bungee.api.ProxyServer; 26 | import net.md_5.bungee.api.plugin.PluginManager; 27 | 28 | public class ListenerManager { 29 | 30 | public static void setup() { 31 | PluginManager pluginManager = ProxyServer.getInstance().getPluginManager(); 32 | pluginManager.registerListener(UltraStaffChat.getInstance(), new ChatListener()); 33 | pluginManager.registerListener(UltraStaffChat.getInstance(), new JoinLeaveListener()); 34 | pluginManager.registerListener(UltraStaffChat.getInstance(), new SwitchListener()); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/utils/TimeUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.utils; 20 | 21 | import java.text.SimpleDateFormat; 22 | import java.util.Date; 23 | import java.util.TimeZone; 24 | 25 | public class TimeUtils { 26 | 27 | private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 28 | private static final SimpleDateFormat fileDateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); 29 | 30 | public static String formatDateTime(Date date) { 31 | if(!dateFormat.getTimeZone().getID().equalsIgnoreCase("UTC")) 32 | dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); 33 | return dateFormat.format(date); 34 | } 35 | 36 | public static String formatFileDateTime(Date date) { 37 | if(!fileDateFormat.getTimeZone().getID().equalsIgnoreCase("UTC")) 38 | fileDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); 39 | return fileDateFormat.format(date); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/utils/Debug.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.utils; 20 | 21 | import java.util.Date; 22 | 23 | public class Debug { 24 | 25 | private static Date startDate; 26 | 27 | private static long startTime; 28 | private static long startFinishTime; 29 | private static long startLength; 30 | 31 | public static void start() { 32 | startTime = System.currentTimeMillis(); 33 | } 34 | 35 | public static void finishStart() { 36 | startFinishTime = System.currentTimeMillis(); 37 | startLength = startFinishTime - startTime; 38 | 39 | startDate = new Date(); 40 | } 41 | 42 | public static Date getStartDate() { 43 | return startDate; 44 | } 45 | 46 | public static long getStartTime() { 47 | return startTime; 48 | } 49 | 50 | public static long getStartFinishTime() { 51 | return startFinishTime; 52 | } 53 | 54 | public static long getStartLength() { 55 | return startLength; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/events/staff/StaffToggleAFKEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.events.staff; 20 | 21 | import net.md_5.bungee.api.connection.ProxiedPlayer; 22 | import net.md_5.bungee.api.plugin.Cancellable; 23 | import net.md_5.bungee.api.plugin.Event; 24 | 25 | public class StaffToggleAFKEvent extends Event implements Cancellable { 26 | 27 | private final ProxiedPlayer player; 28 | private final boolean afk; 29 | private boolean cancelled = false; 30 | 31 | public StaffToggleAFKEvent(ProxiedPlayer player, boolean afk) { 32 | this.player = player; 33 | this.afk = afk; 34 | } 35 | 36 | public ProxiedPlayer getPlayer() { 37 | return player; 38 | } 39 | 40 | public boolean isAfk() { 41 | return afk; 42 | } 43 | 44 | @Override 45 | public boolean isCancelled() { 46 | return cancelled; 47 | } 48 | 49 | @Override 50 | public void setCancelled(boolean cancel) { 51 | this.cancelled = cancel; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [metadata] 2 | version = "1.0" 3 | 4 | [versions] 5 | # Adventure 6 | adventure = "4.17.0" 7 | adventure-platform = "4.3.3" 8 | 9 | # Platforms 10 | platform-bungeecord = "1.20-R0.3-SNAPSHOT" 11 | 12 | # Dependencies 13 | updatelib = "4.0.0" 14 | bstats = "3.0.2" 15 | 16 | # Code safety 17 | annotations = "24.1.0" 18 | 19 | # Build 20 | build-indra = "3.1.3" 21 | build-errorprone = "2.27.1" 22 | build-errorprone-plugin = "3.1.0" 23 | build-shadow = "8.1.1" 24 | 25 | [libraries] 26 | # Adventure 27 | adventure-api = { module = "net.kyori:adventure-api", version.ref = "adventure" } 28 | adventure-platform-bungeecord = { module = "net.kyori:adventure-platform-bungeecord", version.ref = "adventure-platform" } 29 | 30 | # Platforms 31 | platform-bungeecord = { module = "net.md-5:bungeecord-api", version.ref = "platform-bungeecord" } 32 | 33 | # Dependencies 34 | updatelib = { module = "dev.hypera:UpdateLib", version.ref = "updatelib" } 35 | bstats-bungeecord = { module = "org.bstats:bstats-bungeecord", version.ref = "bstats" } 36 | 37 | # Code safety 38 | annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" } 39 | 40 | # Build 41 | build-indra-common = { module = "net.kyori:indra-common", version.ref = "build-indra" } 42 | build-indra-publishing = { module = "net.kyori:indra-publishing-gradle-plugin", version.ref = "build-indra" } 43 | build-errorprone-plugin = { module = "net.ltgt.gradle:gradle-errorprone-plugin", version.ref = "build-errorprone-plugin" } 44 | build-errorprone-core = { module = "com.google.errorprone:error_prone_core", version.ref = "build-errorprone" } 45 | build-errorprone-annotations = { module = "com.google.errorprone:error_prone_annotations", version.ref = "build-errorprone" } 46 | 47 | [plugins] 48 | shadow = { id = "com.github.johnrengelman.shadow", version.ref = "build-shadow" } 49 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/objects/ErrorCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.objects; 20 | 21 | public enum ErrorCode { 22 | 23 | UNKNOWN("UNKNOWN", 1, "An unexpected error occurred."), 24 | CONFIG_GENERATE_FAILED("CONFIG_GENERATE", 4, "An error occurred while trying to generate a configuration file."), 25 | CONFIG_LOAD_FAILED("CONFIG_LOAD", 5, "An error occurred while trying to load a configuration file. This may be caused by the YAML being invalid."), 26 | OUTDATED_CONFIG("CONFIG_OUTDATED", 6, "The configuration file is too old for UltraStaffChat to read."); 27 | 28 | private final String code; 29 | private final int id; 30 | private final String message; 31 | 32 | ErrorCode(String code, int id, String message) { 33 | this.code = code; 34 | this.id = id; 35 | this.message = message; 36 | } 37 | 38 | public String getCode() { 39 | return code; 40 | } 41 | 42 | public int getId() { 43 | return id; 44 | } 45 | 46 | public String getMessage() { 47 | return message; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/listeners/impl/SwitchListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.listeners.impl; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.listeners.Listener; 23 | import dev.hypera.ultrastaffchat.managers.StaffChatManager; 24 | import dev.hypera.ultrastaffchat.utils.Common; 25 | import net.md_5.bungee.api.event.ServerSwitchEvent; 26 | import net.md_5.bungee.event.EventHandler; 27 | 28 | public class SwitchListener extends Listener { 29 | 30 | @EventHandler 31 | public void onServerSwitch(ServerSwitchEvent event) { 32 | if (event.getFrom() != null && Common.hasPermission(event.getPlayer(), UltraStaffChat.getConfig().getString("permission-switch"))) StaffChatManager.broadcastSwitch(event.getPlayer(), event.getFrom(), event.getPlayer().getServer()); 33 | else if (event.getFrom() == null && Common.hasPermission(event.getPlayer(), UltraStaffChat.getConfig().getString("permission-join"))) StaffChatManager.broadcastJoin(event.getPlayer(), event.getPlayer().getServer()); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/events/staff/StaffChatEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.events.staff; 20 | 21 | import net.md_5.bungee.api.CommandSender; 22 | import net.md_5.bungee.api.plugin.Cancellable; 23 | import net.md_5.bungee.api.plugin.Event; 24 | 25 | public class StaffChatEvent extends Event implements Cancellable { 26 | 27 | private final CommandSender sender; 28 | private final CommandSender receiver; 29 | private String message; 30 | private boolean cancelled = false; 31 | 32 | public StaffChatEvent(CommandSender sender, CommandSender receiver, String message) { 33 | this.sender = sender; 34 | this.receiver = receiver; 35 | this.message = message; 36 | } 37 | 38 | public CommandSender getSender() { 39 | return sender; 40 | } 41 | 42 | public CommandSender getReceiver() { 43 | return receiver; 44 | } 45 | 46 | public String getMessage() { 47 | return message; 48 | } 49 | 50 | public void setMessage(String message) { 51 | this.message = message; 52 | } 53 | 54 | @Override 55 | public boolean isCancelled() { 56 | return cancelled; 57 | } 58 | 59 | @Override 60 | public void setCancelled(boolean cancel) { 61 | this.cancelled = cancel; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | ## UltraStaffChat Security Policy 2 | 3 | The purpose of this document is to outline how UltraStaffChat's maintainers will handle any Security 4 | Vulnerabilities discovered. 5 | 6 | ### Supported Versions 7 | 8 | We provide security patches for the latest release of UltraStaffChat. This means that we will only 9 | address security vulnerabilities that affect the most recent version of this plugin. 10 | 11 | | Version | Supported | 12 | |-----------|--------------------| 13 | | `5.2.x` | :white_check_mark: | 14 | | < `5.2.x` | :x: | 15 | 16 | ### Reporting a Vulnerability 17 | 18 | If you discover a security vulnerability in UltraStaffChat, we encourage you to report it to us as soon 19 | as possible so that we can investigate and address the issue. 20 | 21 | You can report a security vulnerability in UltraStaffChat by: 22 | - [Create a vulnerability report on our GitHub repository](https://github.com/HyperaDev/UltraStaffChat/security/advisories/new). 23 | - Send an email to [security@hypera.dev](mailto:security@hypera.dev). 24 | 25 | When reporting a security vulnerability, please provide as much detail as possible about the issue, 26 | including how it can be reproduced and what the potential impact of the vulnerability may be. 27 | 28 | ### Responsible Disclosure and Credit 29 | 30 | We take the security of UltraStaffChat very seriously. As such, we encourage responsible disclosure of 31 | security vulnerabilities in UltraStaffChat. If you report a security vulnerability to us responsibly, we 32 | will credit you when we publish a Security Advisory. 33 | 34 | We define responsible disclosure as follows: 35 | - Disclosing the vulnerability directly to us, rather than publicly disclosing it. 36 | - Allowing us a reasonable amount of time to address the vulnerability before publicly disclosing 37 | it. 38 | - Not exploiting the vulnerability or any related vulnerabilities to gain unauthorised access to 39 | systems or data. 40 | 41 | ### Conclusion 42 | 43 | By following this Security Policy, we aim to maintain the security of UltraStaffChat and our users. 44 | If you have any questions or concerns about this policy or UltraStaffChat's security practices, please do 45 | not hesitate to contact us at [security@hypera.dev](mailto:security@hypera.dev). 46 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/CommandManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.commands; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.commands.impl.MuteStaffChatCommand; 23 | import dev.hypera.ultrastaffchat.commands.impl.StaffAfkCommand; 24 | import dev.hypera.ultrastaffchat.commands.impl.StaffChatCommand; 25 | import dev.hypera.ultrastaffchat.commands.impl.StaffChatMuteCommand; 26 | import dev.hypera.ultrastaffchat.commands.impl.StaffChatToggleCommand; 27 | import dev.hypera.ultrastaffchat.commands.impl.StaffListCommand; 28 | import dev.hypera.ultrastaffchat.commands.impl.UltraStaffChatCommand; 29 | import net.md_5.bungee.api.ProxyServer; 30 | import org.jetbrains.annotations.NotNull; 31 | 32 | public class CommandManager { 33 | 34 | public static void setup() { 35 | registerCommand(new MuteStaffChatCommand()); 36 | registerCommand(new StaffAfkCommand()); 37 | registerCommand(new StaffChatCommand()); 38 | registerCommand(new StaffChatMuteCommand()); 39 | registerCommand(new StaffChatToggleCommand()); 40 | registerCommand(new StaffListCommand()); 41 | registerCommand(new UltraStaffChatCommand()); 42 | } 43 | 44 | private static void registerCommand(@NotNull Command command) { 45 | if (!command.isDisabled()) { 46 | ProxyServer.getInstance().getPluginManager() 47 | .registerCommand(UltraStaffChat.getInstance(), command); 48 | } 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/events/staff/StaffJoinEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.events.staff; 20 | 21 | import net.md_5.bungee.api.connection.ProxiedPlayer; 22 | import net.md_5.bungee.api.connection.Server; 23 | import net.md_5.bungee.api.plugin.Cancellable; 24 | import net.md_5.bungee.api.plugin.Event; 25 | import org.jetbrains.annotations.ApiStatus; 26 | import org.jetbrains.annotations.NotNull; 27 | 28 | /** 29 | * Called when a player with the permission `staffchat.join` joins the proxy. When cancelled, the staff join message is 30 | * not shown. 31 | */ 32 | public class StaffJoinEvent extends Event implements Cancellable { 33 | 34 | private boolean cancelled = false; 35 | private final ProxiedPlayer player; 36 | private final Server server; 37 | 38 | @Deprecated 39 | public StaffJoinEvent(@NotNull ProxiedPlayer player) { 40 | this(player, player.getServer()); 41 | } 42 | 43 | public StaffJoinEvent(@NotNull ProxiedPlayer player, Server server) { 44 | this.player = player; 45 | this.server = server; 46 | } 47 | 48 | public @NotNull ProxiedPlayer getPlayer() { 49 | return player; 50 | } 51 | 52 | @ApiStatus.Experimental 53 | public Server getServer() { 54 | return server; 55 | } 56 | 57 | @Override 58 | public boolean isCancelled() { 59 | return cancelled; 60 | } 61 | 62 | @Override 63 | public void setCancelled(boolean cancel) { 64 | this.cancelled = cancel; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/listeners/impl/JoinLeaveListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.listeners.impl; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.listeners.Listener; 23 | import dev.hypera.ultrastaffchat.managers.StaffChatManager; 24 | import dev.hypera.ultrastaffchat.utils.Common; 25 | import net.md_5.bungee.api.event.PlayerDisconnectEvent; 26 | import net.md_5.bungee.api.event.PostLoginEvent; 27 | import net.md_5.bungee.event.EventHandler; 28 | 29 | public class JoinLeaveListener extends Listener { 30 | 31 | @EventHandler 32 | public void onPostJoin(PostLoginEvent event) { 33 | if(UltraStaffChat.getConfig().getBoolean("update-enabled") && Common.hasPermission(event.getPlayer(), Common.messageRaw("permission-update"))) { 34 | if(null != UltraStaffChat.getInstance().getUpdateLib().getLastStatus() && UltraStaffChat.getInstance().getUpdateLib().getLastStatus().isAvailable()) { 35 | UltraStaffChat.getInstance().getAdventure().player(event.getPlayer()).sendMessage(Common.adventurise(Common.messageRaw("update-message").replace("{version}", UltraStaffChat.getInstance().getUpdateLib().getLastStatus().getDistributedVersion()).replace("{current}", UltraStaffChat.getInstance().getDescription().getVersion()))); 36 | } 37 | } 38 | } 39 | 40 | @EventHandler 41 | public void onDisconnect(PlayerDisconnectEvent event) { 42 | if(Common.hasPermission(event.getPlayer(), UltraStaffChat.getConfig().getString("permission-leave"))) { 43 | StaffChatManager.broadcastLeave(event.getPlayer()); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/events/staff/StaffSwitchServerEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.events.staff; 20 | 21 | import net.md_5.bungee.api.ProxyServer; 22 | import net.md_5.bungee.api.config.ServerInfo; 23 | import net.md_5.bungee.api.connection.ProxiedPlayer; 24 | import net.md_5.bungee.api.connection.Server; 25 | import net.md_5.bungee.api.plugin.Cancellable; 26 | import net.md_5.bungee.api.plugin.Event; 27 | import org.jetbrains.annotations.ApiStatus; 28 | 29 | public class StaffSwitchServerEvent extends Event implements Cancellable { 30 | 31 | private final ProxiedPlayer player; 32 | private final ServerInfo from; 33 | private final Server to; 34 | private boolean cancelled = false; 35 | 36 | @Deprecated 37 | public StaffSwitchServerEvent(ProxiedPlayer player, String from, String to) { 38 | this(player, ProxyServer.getInstance().getServerInfo(from), player.getServer()); 39 | } 40 | 41 | public StaffSwitchServerEvent(ProxiedPlayer player, ServerInfo from, Server to) { 42 | this.player = player; 43 | this.from = from; 44 | this.to = to; 45 | } 46 | 47 | public ProxiedPlayer getPlayer() { 48 | return player; 49 | } 50 | 51 | @Deprecated 52 | public String getFrom() { 53 | return from.getName(); 54 | } 55 | 56 | @Deprecated 57 | public String getTo() { 58 | return to.getInfo().getName(); 59 | } 60 | 61 | @ApiStatus.Experimental 62 | public ServerInfo getFromServer() { 63 | return from; 64 | } 65 | 66 | @ApiStatus.Experimental 67 | public Server getToServer() { 68 | return to; 69 | } 70 | 71 | @Override 72 | public boolean isCancelled() { 73 | return cancelled; 74 | } 75 | 76 | @Override 77 | public void setCancelled(boolean cancel) { 78 | this.cancelled = cancel; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/impl/StaffChatCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 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.managers.StaffChatManager; 24 | import dev.hypera.ultrastaffchat.utils.Common; 25 | import dev.hypera.ultrastaffchat.utils.StaffChat; 26 | import net.kyori.adventure.audience.Audience; 27 | import net.md_5.bungee.api.CommandSender; 28 | 29 | public class StaffChatCommand extends Command { 30 | 31 | public StaffChatCommand() { 32 | super("staffchat", null, "sc"); 33 | } 34 | 35 | @Override 36 | public void execute(CommandSender sender, String[] args) { 37 | Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender); 38 | 39 | if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-talk"))) { 40 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission"))); 41 | return; 42 | } 43 | 44 | if(args.length == 0) { 45 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("staffchat-usage"))); 46 | return; 47 | } 48 | 49 | if(StaffChat.staffChatIsMuted()) { 50 | if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-bypass"))) { 51 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("staffchat-muted"))); 52 | return; 53 | } 54 | } 55 | 56 | StringBuilder message = new StringBuilder(); 57 | for(String word : args) { 58 | message.append(word).append(" "); 59 | } 60 | message.deleteCharAt(message.length() - 1); 61 | StaffChatManager.broadcastMessage(sender, message.toString()); 62 | } 63 | 64 | @Override 65 | public boolean isDisabled() { 66 | return false; 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/impl/StaffListCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 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.ProxyServer; 27 | 28 | import java.util.concurrent.atomic.AtomicInteger; 29 | 30 | public class StaffListCommand extends Command { 31 | 32 | public StaffListCommand() { 33 | super("stafflist", null, "sclist", "slist"); 34 | } 35 | 36 | @Override 37 | public void execute(CommandSender sender, String[] args) { 38 | Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender); 39 | 40 | if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-list"))) { 41 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission"))); 42 | return; 43 | } 44 | 45 | AtomicInteger count = new AtomicInteger(0); 46 | StringBuilder stringBuilder = new StringBuilder(); 47 | ProxyServer.getInstance().getPlayers().stream().filter(player -> player.hasPermission(UltraStaffChat.getConfig().getString("permission-staff"))).forEach(player -> { 48 | count.getAndIncrement(); 49 | stringBuilder.append(UltraStaffChat.getConfig().getString("stafflist-line").replace("{player}", player.getName()).replace("{server}", player.getServer().getInfo().getName())).append("\n"); 50 | }); 51 | 52 | if(count.get() < 1) { 53 | audience.sendMessage(Common.message("stafflist-offline")); 54 | return; 55 | } 56 | 57 | audience.sendMessage(Common.adventurise(Common.messageRaw("stafflist-header").replace("{count}", String.valueOf(count.get())) + "\n" + stringBuilder.deleteCharAt(stringBuilder.length() - 1))); 58 | } 59 | 60 | @Override 61 | public boolean isDisabled() { 62 | return !UltraStaffChat.getConfig().getBoolean("stafflist-enabled"); 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug Report 2 | description: Create a bug report to help us improve. 3 | labels: [ "status: triage", "type: bug: unconfirmed" ] 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Please do **not** use the 'Bug Report' template for questions, instead ask in our [Discord Server](https://discord.hypera.dev/) 9 | - type: checkboxes 10 | attributes: 11 | label: Confirmation 12 | description: Please confirm that you have done the following before creating this issue. 13 | options: 14 | - label: I have checked for similar issues. 15 | required: true 16 | - label: I using the latest version of UltraStaffChat. 17 | required: true 18 | - type: textarea 19 | attributes: 20 | label: Describe the bug 21 | description: Please provide a clear and concise description of what the bug is. 22 | placeholder: When I ..., ... happens. 23 | validations: 24 | required: true 25 | - type: textarea 26 | attributes: 27 | label: Expected behaviour 28 | description: What did you expect to happen? 29 | placeholder: UltraStaffChat should have ... 30 | validations: 31 | required: true 32 | - type: textarea 33 | attributes: 34 | label: Reproduction steps 35 | description: Please provide steps to take to reproduce this bug. 36 | placeholder: "Steps to reproduce the behaviour" 37 | validations: 38 | required: true 39 | - type: textarea 40 | attributes: 41 | label: Exception 42 | description: If an exception was printed, please provide it here. 43 | placeholder: "java.lang.NullPointerException: null" 44 | render: Java 45 | validations: 46 | required: false 47 | - type: textarea 48 | attributes: 49 | label: Environment 50 | description: | 51 | Please provide information about your operating environment here. 52 | Make sure to include your operating system name and version, the platform(s) the bug occurs on and the version of the platform(s). 53 | value: | 54 | Operating System: 55 | Platform: 56 | UltraStaffChat Version: 57 | render: Markdown 58 | validations: 59 | required: true 60 | - type: textarea 61 | attributes: 62 | label: Advanced Debug Log 63 | description: | 64 | Please provide an advanced debug log here. 65 | You can get this by using the command `/usc debug --a` 66 | placeholder: "https://paste.hypera.dev/... link or contents of file in `/plugins/UltraStaffChat/debug/`" 67 | render: Markdown 68 | validations: 69 | required: true 70 | - type: textarea 71 | attributes: 72 | label: Additional information 73 | description: | 74 | Please provide any additional information that may improve the chance of us being able to reproduce and fix this bug. 75 | Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in. 76 | validations: 77 | required: false 78 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/utils/PasteUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.utils; 20 | 21 | import com.google.gson.JsonElement; 22 | import com.google.gson.JsonObject; 23 | import com.google.gson.JsonParser; 24 | import dev.hypera.ultrastaffchat.UltraStaffChat; 25 | 26 | import javax.net.ssl.HttpsURLConnection; 27 | import java.io.BufferedReader; 28 | import java.io.InputStreamReader; 29 | import java.io.OutputStream; 30 | import java.net.HttpURLConnection; 31 | import java.net.URL; 32 | 33 | public class PasteUtils { 34 | 35 | private static final String PASTE_BASE = "https://paste.hypera.dev/"; 36 | 37 | 38 | /** 39 | * Create a new paste. It is recommended to run this async to avoid slowing down the main thread. 40 | * 41 | * @param content Paste content. 42 | * 43 | * @return Paste Url. 44 | * @throws Exception Anything that goes wrong while creating the paste. 45 | */ 46 | public static String createPaste(String... content) throws Exception { 47 | URL url = new URL(PASTE_BASE + "/documents"); 48 | HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection(); 49 | httpsURLConnection.setRequestMethod("POST"); 50 | httpsURLConnection.setRequestProperty("User-Agent", "UltraStaffChat v" + UltraStaffChat.getInstance().getDescription().getVersion() + " Paste Generator"); 51 | httpsURLConnection.setRequestProperty("Content-Type", "text/plain"); 52 | httpsURLConnection.setDoOutput(true); 53 | 54 | OutputStream outputStream = httpsURLConnection.getOutputStream(); 55 | outputStream.write(String.join("\n", content).getBytes()); 56 | outputStream.flush(); 57 | outputStream.close(); 58 | 59 | if(httpsURLConnection.getResponseCode() == HttpURLConnection.HTTP_OK) { 60 | InputStreamReader inputStreamReader = new InputStreamReader(httpsURLConnection.getInputStream()); 61 | BufferedReader bufferedReader = new BufferedReader(inputStreamReader); 62 | 63 | JsonElement jsonElement = new JsonParser().parse(bufferedReader); 64 | JsonObject object = jsonElement.getAsJsonObject(); 65 | if(!object.has("key")) 66 | throw new IllegalStateException("Server did not response with a paste key"); 67 | 68 | String pasteUrl = PASTE_BASE + object.get("key").getAsString() + ".txt"; 69 | 70 | inputStreamReader.close(); 71 | bufferedReader.close(); 72 | 73 | return pasteUrl; 74 | } 75 | 76 | return null; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/impl/MuteStaffChatCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 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 dev.hypera.ultrastaffchat.utils.StaffChat; 25 | import net.kyori.adventure.audience.Audience; 26 | import net.md_5.bungee.api.CommandSender; 27 | 28 | public class MuteStaffChatCommand extends Command { 29 | 30 | public MuteStaffChatCommand() { 31 | super("mutestaffchat", null, "mutesc"); 32 | 33 | } 34 | 35 | @Override 36 | public void execute(CommandSender sender, String[] args) { 37 | 38 | Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender); 39 | 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 | } 45 | 46 | if(args.length > 1) { 47 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-usage"))); 48 | return; 49 | } 50 | 51 | if(args.length == 0) { 52 | boolean toggled = StaffChat.toggleStaffChatMute(); 53 | if(toggled) { 54 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message-on"))); 55 | } else 56 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-staffchat-message-off"))); 57 | return; 58 | } 59 | 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-off"))); 63 | return; 64 | } 65 | 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-on"))); 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 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/listeners/impl/ChatListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.listeners.impl; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.listeners.Listener; 23 | import dev.hypera.ultrastaffchat.managers.StaffChatManager; 24 | import dev.hypera.ultrastaffchat.utils.Common; 25 | import dev.hypera.ultrastaffchat.utils.StaffChat; 26 | import net.md_5.bungee.api.connection.ProxiedPlayer; 27 | import net.md_5.bungee.api.event.ChatEvent; 28 | import net.md_5.bungee.event.EventHandler; 29 | 30 | public class ChatListener extends Listener { 31 | 32 | @EventHandler 33 | public void onChat(ChatEvent e) { 34 | if(e.isCommand() || e.isProxyCommand()) 35 | return; 36 | if((e.getSender() instanceof ProxiedPlayer) && StaffChat.hasChatStaffChatEnabled((ProxiedPlayer) e.getSender())) { 37 | e.setCancelled(true); 38 | if(StaffChat.staffChatIsMuted()) { 39 | if(!((ProxiedPlayer) e.getSender()).hasPermission(UltraStaffChat.getConfig().getString("permission-bypass"))) { 40 | UltraStaffChat.getInstance().getAdventure().sender((ProxiedPlayer) e.getSender()).sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("staffchat-muted"))); 41 | return; 42 | } 43 | } 44 | StaffChatManager.broadcastMessage((ProxiedPlayer) e.getSender(), e.getMessage()); 45 | return; 46 | } 47 | 48 | if(!(e.getSender() instanceof ProxiedPlayer)) 49 | return; 50 | 51 | ProxiedPlayer p = (ProxiedPlayer) e.getSender(); 52 | 53 | if(p.hasPermission(UltraStaffChat.getConfig().getString("permission-talk"))) { 54 | String prefix = UltraStaffChat.getConfig().getString("staffchat-prefix"); 55 | if(!prefix.equals("") && e.getMessage().startsWith(prefix) && e.getMessage().replaceFirst(prefix, "").length() > 0) { 56 | e.setCancelled(true); 57 | if(StaffChat.staffChatIsMuted()) { 58 | if(!((ProxiedPlayer) e.getSender()).hasPermission(UltraStaffChat.getConfig().getString("permission-bypass"))) { 59 | UltraStaffChat.getInstance().getAdventure().sender((ProxiedPlayer) e.getSender()).sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("staffchat-muted"))); 60 | return; 61 | } 62 | } 63 | String message = e.getMessage().substring(prefix.length()); 64 | StaffChatManager.broadcastMessage((ProxiedPlayer) e.getSender(), message); 65 | e.setCancelled(true); 66 | } 67 | } 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/impl/StaffChatMuteCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 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 dev.hypera.ultrastaffchat.utils.StaffChat; 25 | import net.kyori.adventure.audience.Audience; 26 | import net.md_5.bungee.api.CommandSender; 27 | import net.md_5.bungee.api.connection.ProxiedPlayer; 28 | 29 | public class StaffChatMuteCommand extends Command { 30 | 31 | public StaffChatMuteCommand() { 32 | super("staffchatmute", null, "scmute"); 33 | } 34 | 35 | @Override 36 | public void execute(CommandSender sender, String[] args) { 37 | Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender); 38 | 39 | if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-mute"))) { 40 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission"))); 41 | return; 42 | } 43 | 44 | if(!(sender instanceof ProxiedPlayer)) { 45 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("ingame-only"))); 46 | return; 47 | } 48 | 49 | if(args.length > 1) { 50 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-usage"))); 51 | return; 52 | } 53 | 54 | 55 | ProxiedPlayer p = (ProxiedPlayer) sender; 56 | if(args.length == 0) { 57 | boolean toggled = StaffChat.toggleMessages(p); 58 | if(toggled) { 59 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-message-on"))); 60 | } else 61 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-message-off"))); 62 | return; 63 | } 64 | 65 | if(args[0].matches("(?i:(off|false|disable(d)?|unmute(d)?))")) { 66 | StaffChat.enableMessages(p); 67 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-message-off"))); 68 | return; 69 | } 70 | 71 | if(args[0].matches("(?i:(on|true|enable(d)?|mute(d)?))")) { 72 | StaffChat.disableMessages(p); 73 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-message-on"))); 74 | return; 75 | } 76 | 77 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("mute-usage"))); 78 | } 79 | 80 | @Override 81 | public boolean isDisabled() { 82 | return !UltraStaffChat.getConfig().getBoolean("mute-enabled"); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/impl/StaffChatToggleCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 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 dev.hypera.ultrastaffchat.utils.StaffChat; 25 | import net.kyori.adventure.audience.Audience; 26 | import net.md_5.bungee.api.CommandSender; 27 | import net.md_5.bungee.api.connection.ProxiedPlayer; 28 | 29 | public class StaffChatToggleCommand extends Command { 30 | 31 | public StaffChatToggleCommand() { 32 | super("staffchattoggle", null, "sctoggle"); 33 | } 34 | 35 | @Override 36 | public void execute(CommandSender sender, String[] args) { 37 | Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender); 38 | 39 | if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-toggle"))) { 40 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission"))); 41 | return; 42 | } 43 | 44 | if(!(sender instanceof ProxiedPlayer)) { 45 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("ingame-only"))); 46 | return; 47 | } 48 | 49 | if(args.length > 1) { 50 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("toggle-usage"))); 51 | return; 52 | } 53 | 54 | 55 | ProxiedPlayer p = (ProxiedPlayer) sender; 56 | if(args.length == 0) { 57 | boolean toggled = StaffChat.toggleChatStaffChat(p); 58 | if(toggled) { 59 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("toggle-message-on"))); 60 | } else 61 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("toggle-message-off"))); 62 | return; 63 | } 64 | 65 | if(args[0].matches("(?i:(off|false|disable(d)?))")) { 66 | StaffChat.disableChatStaffChat(p); 67 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("toggle-message-off"))); 68 | return; 69 | } 70 | 71 | if(args[0].matches("(?i:(on|true|enable(d)?))")) { 72 | StaffChat.enableChatStaffChat(p); 73 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("toggle-message-on"))); 74 | return; 75 | } 76 | 77 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("toggle-usage"))); 78 | } 79 | 80 | @Override 81 | public boolean isDisabled() { 82 | return !UltraStaffChat.getConfig().getBoolean("toggle-enabled"); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/impl/StaffAfkCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 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 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 | } 80 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/config/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.config; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.objects.ErrorCode; 23 | import dev.hypera.ultrastaffchat.utils.Common; 24 | import net.md_5.bungee.config.Configuration; 25 | import net.md_5.bungee.config.ConfigurationProvider; 26 | import net.md_5.bungee.config.YamlConfiguration; 27 | 28 | import java.io.File; 29 | import java.io.InputStream; 30 | import java.nio.file.Files; 31 | import java.util.List; 32 | 33 | public class Config { 34 | 35 | private String fileName = null; 36 | private Configuration configuration; 37 | private File configurationFile; 38 | private File dataFolder; 39 | 40 | public boolean load(String fileName) { 41 | this.fileName = fileName; 42 | this.dataFolder = UltraStaffChat.getInstance().getDataFolder(); 43 | 44 | if(!dataFolder.exists()) 45 | dataFolder.mkdirs(); 46 | 47 | configurationFile = new File(dataFolder, fileName); 48 | 49 | if(!configurationFile.exists()) { 50 | try { 51 | InputStream inputStream = UltraStaffChat.getInstance().getResourceAsStream(fileName); 52 | Files.copy(inputStream, configurationFile.toPath()); 53 | inputStream.close(); 54 | } catch (Exception ex) { 55 | Common.error(ErrorCode.CONFIG_GENERATE_FAILED, "Failed to generate " + fileName + ".", ex); 56 | return false; 57 | } 58 | } 59 | 60 | try { 61 | configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configurationFile); 62 | } catch (Exception ex) { 63 | Common.error(ErrorCode.CONFIG_LOAD_FAILED, "Failed to load " + fileName + ".", ex); 64 | return false; 65 | } 66 | 67 | return true; 68 | } 69 | 70 | public boolean reload() { 71 | return load(fileName); 72 | } 73 | 74 | public String getString(String path) { 75 | if(null == configuration) 76 | return null; 77 | return configuration.getString(path); 78 | } 79 | 80 | public Boolean getBoolean(String path) { 81 | if(null == configuration) 82 | return null; 83 | return configuration.getBoolean(path); 84 | } 85 | 86 | public Integer getInteger(String path) { 87 | if(null == configuration) 88 | return null; 89 | return configuration.getInt(path); 90 | } 91 | 92 | public List getStringList(String path) { 93 | if(null == configuration) 94 | return null; 95 | return configuration.getStringList(path); 96 | } 97 | 98 | public int getVersion() { 99 | if(null == configuration) 100 | return -1; 101 | return configuration.getInt("version"); 102 | } 103 | 104 | public String getFileName() { 105 | return fileName; 106 | } 107 | 108 | public Configuration getConfiguration() { 109 | return configuration; 110 | } 111 | 112 | public File getConfigurationFile() { 113 | return configurationFile; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/utils/StaffChat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.utils; 20 | 21 | import net.md_5.bungee.api.connection.ProxiedPlayer; 22 | 23 | import java.util.HashMap; 24 | import java.util.UUID; 25 | 26 | public class StaffChat { 27 | 28 | private static HashMap mutedPlayers = new HashMap<>(); 29 | private static HashMap toggledPlayers = new HashMap<>(); 30 | private static boolean staffChatMuted = false; 31 | 32 | public static void disableMessages(ProxiedPlayer p) { 33 | if(!mutedPlayers.containsKey(p.getUniqueId())) { 34 | mutedPlayers.put(p.getUniqueId(), true); 35 | return; 36 | } 37 | if(mutedPlayers.get(p.getUniqueId()).equals(false)) 38 | mutedPlayers.replace(p.getUniqueId(), false, true); 39 | } 40 | 41 | public static void enableMessages(ProxiedPlayer p) { 42 | if(mutedPlayers.containsKey(p.getUniqueId()) && mutedPlayers.get(p.getUniqueId()).equals(true)) 43 | mutedPlayers.replace(p.getUniqueId(), true, false); 44 | } 45 | 46 | public static boolean toggleMessages(ProxiedPlayer p) { 47 | if(hasMessagesDisabled(p)) { 48 | enableMessages(p); 49 | } else { 50 | disableMessages(p); 51 | } 52 | return hasMessagesDisabled(p); 53 | } 54 | 55 | public static boolean hasMessagesDisabled(ProxiedPlayer p) { 56 | return mutedPlayers.containsKey(p.getUniqueId()) && mutedPlayers.get(p.getUniqueId()).equals(true); 57 | } 58 | 59 | public static boolean staffChatIsMuted() { 60 | return staffChatMuted; 61 | } 62 | 63 | public static void muteStaffChat() { 64 | staffChatMuted = true; 65 | } 66 | 67 | public static void unmuteStaffChat() { 68 | staffChatMuted = false; 69 | } 70 | 71 | public static boolean toggleStaffChatMute() { 72 | if(staffChatIsMuted()) { 73 | unmuteStaffChat(); 74 | return false; 75 | } else 76 | muteStaffChat(); 77 | return true; 78 | } 79 | 80 | public static boolean toggleChatStaffChat(ProxiedPlayer p) { 81 | if (!toggledPlayers.containsKey(p.getUniqueId())) { 82 | toggledPlayers.put(p.getUniqueId(), true); 83 | return true; 84 | } else { 85 | boolean oldToggled = toggledPlayers.get(p.getUniqueId()); 86 | toggledPlayers.replace(p.getUniqueId(), !oldToggled); 87 | return !oldToggled; 88 | } 89 | } 90 | 91 | public static void enableChatStaffChat(ProxiedPlayer p) { 92 | if(toggledPlayers.containsKey(p.getUniqueId()) && toggledPlayers.get(p.getUniqueId()).equals(false)) 93 | toggledPlayers.replace(p.getUniqueId(), false, true); 94 | if(!toggledPlayers.containsKey(p.getUniqueId())) 95 | toggledPlayers.put(p.getUniqueId(), true); 96 | } 97 | 98 | public static void disableChatStaffChat(ProxiedPlayer p) { 99 | if(!toggledPlayers.containsKey(p.getUniqueId())) { 100 | toggledPlayers.put(p.getUniqueId(), false); 101 | return; 102 | } 103 | if(toggledPlayers.get(p.getUniqueId()).equals(true)) 104 | toggledPlayers.replace(p.getUniqueId(), true, false); 105 | } 106 | 107 | public static boolean hasChatStaffChatEnabled(ProxiedPlayer p) { 108 | return toggledPlayers.containsKey(p.getUniqueId()) && toggledPlayers.get(p.getUniqueId()).equals(true); 109 | } 110 | 111 | } -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/UltraStaffChat.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat; 20 | 21 | import dev.hypera.ultrastaffchat.commands.CommandManager; 22 | import dev.hypera.ultrastaffchat.config.Config; 23 | import dev.hypera.ultrastaffchat.listeners.ListenerManager; 24 | import dev.hypera.ultrastaffchat.objects.ErrorCode; 25 | import dev.hypera.ultrastaffchat.utils.Common; 26 | import dev.hypera.ultrastaffchat.utils.Debug; 27 | import dev.hypera.ultrastaffchat.utils.Discord; 28 | import dev.hypera.updatelib.UpdateLib; 29 | import net.kyori.adventure.platform.bungeecord.BungeeAudiences; 30 | import net.md_5.bungee.api.plugin.Plugin; 31 | import org.bstats.bungeecord.Metrics; 32 | 33 | import java.util.logging.Level; 34 | import java.util.logging.Logger; 35 | 36 | public final class UltraStaffChat extends Plugin { 37 | 38 | private static UltraStaffChat instance; 39 | private static final Config config = new Config(); 40 | 41 | private BungeeAudiences adventure; 42 | private Metrics metrics; 43 | private UpdateLib updateLib; 44 | 45 | @Override 46 | public void onEnable() { 47 | try { 48 | Debug.start(); 49 | 50 | instance = this; 51 | Common.logPrefix("&aStarting..."); 52 | 53 | metrics = new Metrics(this, Common.getbStatsId()); 54 | 55 | if(!config.load("config.yml")) { 56 | return; 57 | } 58 | 59 | if(config.getVersion() < Common.getConfigVersion()) { 60 | Common.error(ErrorCode.OUTDATED_CONFIG, "Outdated configuration file - View https://docs.hypera.dev/docs/ultrastaffchat-bungeecord/updating/" + Common.getConfigVersion() + " for more information on updating", new IllegalStateException("Outdated configuration file")); 61 | onDisable(); 62 | return; 63 | } 64 | 65 | adventure = BungeeAudiences.create(this); 66 | updateLib = UpdateLib.builder() 67 | .version(getDescription().getVersion()) 68 | .resource(Common.getResourceId()) 69 | .handler(status -> { 70 | if (status.isAvailable()) 71 | Common.logPrefix("&cAn update is available! " + getDescription().getVersion() + " -> " + status.getDistributedVersion()); 72 | }).build(); 73 | 74 | ListenerManager.setup(); 75 | CommandManager.setup(); 76 | Discord.setup(); 77 | 78 | Debug.finishStart(); 79 | 80 | Common.log( 81 | "&r &r &r", 82 | "&c __ ___________", 83 | "&c / / / / __/ ___/ &r &c&lUltraStaffChat&r &8BungeeCord", 84 | "&c/ /_/ /\\ \\/ /__&c &r &c &r &8Running Version &c" + getDescription().getVersion(), 85 | "&c\\____/___/\\___/", 86 | "&r &r &r" 87 | ); 88 | Common.logPrefix("&aSuccessfully started. &8Took " + Debug.getStartLength() + "ms"); 89 | } catch (Exception ex) { 90 | Common.error(ErrorCode.UNKNOWN, "Error while starting.", ex); 91 | } 92 | } 93 | 94 | @Override 95 | public void onDisable() { 96 | if(adventure != null) { 97 | adventure.close(); 98 | adventure = null; 99 | } 100 | Common.log("&cDisabled"); 101 | } 102 | 103 | public static UltraStaffChat getInstance() { 104 | return instance; 105 | } 106 | 107 | public static Config getConfig() { 108 | return config; 109 | } 110 | 111 | public BungeeAudiences getAdventure() { 112 | if(adventure == null) 113 | throw new IllegalStateException("Cannot retrieve audience provider while plugin is not enabled"); 114 | return adventure; 115 | } 116 | 117 | public Metrics getMetrics() { 118 | return metrics; 119 | } 120 | 121 | public UpdateLib getUpdateLib() { 122 | if(updateLib == null) 123 | throw new IllegalStateException("Cannot retrieve UpdateLib while the plugin is not enabled"); 124 | return updateLib; 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/managers/DebugManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.managers; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.utils.Debug; 23 | import dev.hypera.ultrastaffchat.utils.TimeUtils; 24 | import net.md_5.bungee.api.ProxyServer; 25 | import net.md_5.bungee.api.plugin.Plugin; 26 | import org.bstats.bungeecord.Metrics; 27 | 28 | import java.lang.reflect.Field; 29 | import java.util.Date; 30 | 31 | public class DebugManager { 32 | 33 | public static String generateDebugLog() { 34 | return String.join("\n", new String[] { 35 | "&c&lUltraStaffChat &7Debug Log", 36 | "&7 - Version: &f" + UltraStaffChat.getInstance().getDescription().getVersion(), 37 | "&7 - &7Config Version: &f" + UltraStaffChat.getConfig().getVersion(), 38 | "&7> &cRunning on&7: &fBungeeCord", 39 | "&7 - Version: &f" + ProxyServer.getInstance().getVersion() 40 | }); 41 | } 42 | 43 | public static String generateAdvancedDebugLog() { 44 | Date created = new Date(); 45 | 46 | StringBuilder stringBuilder = new StringBuilder(); 47 | ProxyServer.getInstance().getPluginManager().getPlugins().forEach(plugin -> stringBuilder.append(getPluginInfo(plugin)).append("\n\n")); 48 | 49 | String[] log = { 50 | "# UltraStaffChat Advanced Debug Log", 51 | "# Generated " + TimeUtils.formatDateTime(created) + ".", 52 | " ", 53 | "# UltraStaffChat Information", 54 | "Version: " + UltraStaffChat.getInstance().getDescription().getVersion(), 55 | "Config Version: " + UltraStaffChat.getConfig().getVersion(), 56 | "Running since: " + TimeUtils.formatDateTime(Debug.getStartDate()), 57 | "Start time: " + Debug.getStartLength() + "ms", 58 | " ", 59 | "# BungeeCord Information", 60 | "Version: " + ProxyServer.getInstance().getVersion(), 61 | "Online Mode: " + ProxyServer.getInstance().getConfig().isOnlineMode(), 62 | "Players Online: " + ProxyServer.getInstance().getPlayers().size(), 63 | "Managed Servers: " + ProxyServer.getInstance().getServers().size(), 64 | "Plugin Count: " + ProxyServer.getInstance().getPluginManager().getPlugins().size(), 65 | " ", 66 | "# Java Information", 67 | "Version: " + System.getProperty("java.version"), 68 | " ", 69 | "# Operating System Information", 70 | "Name: " + System.getProperty("os.name"), 71 | "Arch: " + System.getProperty("os.arch"), 72 | "Version: " + System.getProperty("os.version"), 73 | " ", 74 | "# System Information", 75 | "Total Memory: " + Runtime.getRuntime().totalMemory(), 76 | "Max Memory: " + Runtime.getRuntime().maxMemory(), 77 | "Free Memory: " + Runtime.getRuntime().freeMemory(), 78 | "Cores: " + Runtime.getRuntime().availableProcessors(), 79 | " ", 80 | "# Enabled Plugins", 81 | stringBuilder.toString(), 82 | " ", 83 | "# Miscellaneous Information", 84 | "bStats Enabled: " + getbStatsEnabled() 85 | 86 | }; 87 | 88 | return String.join("\n", log); 89 | } 90 | 91 | private static String getPluginInfo(Plugin plugin) { 92 | return String.join("\n", new String[] { 93 | plugin.getDescription().getName() + " [" + plugin.getDescription().getVersion() + "]", 94 | " - Main: " + plugin.getDescription().getMain(), 95 | " - Author: " + (null == plugin.getDescription().getAuthor() ? "Unknown" : plugin.getDescription().getAuthor()), 96 | " - Dependencies: " + (null == plugin.getDescription().getDepends() || plugin.getDescription().getDepends().size() < 1 ? "None" : plugin.getDescription().getDepends().toString()), 97 | " - Soft Dependencies: " + (null == plugin.getDescription().getSoftDepends() || plugin.getDescription().getSoftDepends().size() < 1 ? "None" : plugin.getDescription().getSoftDepends().toString()) 98 | }); 99 | } 100 | 101 | private static boolean getbStatsEnabled() { 102 | try { 103 | Metrics metrics = UltraStaffChat.getInstance().getMetrics(); 104 | Field enabled = metrics.getClass().getDeclaredField("enabled"); 105 | enabled.setAccessible(true); 106 | return (boolean) enabled.get(metrics); 107 | } catch (Exception ex) { 108 | return false; 109 | } 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | contact@hypera.dev. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/managers/StaffChatManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.managers; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.events.staff.*; 23 | import dev.hypera.ultrastaffchat.utils.Discord; 24 | import dev.hypera.ultrastaffchat.utils.MD_; 25 | import dev.hypera.ultrastaffchat.utils.StaffChat; 26 | import net.kyori.adventure.audience.Audience; 27 | import net.md_5.bungee.api.CommandSender; 28 | import net.md_5.bungee.api.ProxyServer; 29 | import net.md_5.bungee.api.config.ServerInfo; 30 | import net.md_5.bungee.api.connection.ProxiedPlayer; 31 | import net.md_5.bungee.api.connection.Server; 32 | 33 | import static dev.hypera.ultrastaffchat.utils.Common.adventurise; 34 | import static dev.hypera.ultrastaffchat.utils.Common.messageRaw; 35 | 36 | public class StaffChatManager { 37 | 38 | public static void broadcastMessage(CommandSender sender, String m) { 39 | String message = (sender.hasPermission(UltraStaffChat.getConfig().getString("permission-chat-format")) ? MD_.parseMarkdown(m) : m); 40 | UltraStaffChat.getInstance().getAdventure().filter(person -> { 41 | if(!person.hasPermission(messageRaw("permission-read"))) 42 | return false; 43 | if(person instanceof ProxiedPlayer && StaffChat.hasMessagesDisabled((ProxiedPlayer) person)) 44 | return false; 45 | StaffChatEvent staffChatEvent = new StaffChatEvent(sender, person, message); 46 | ProxyServer.getInstance().getPluginManager().callEvent(staffChatEvent); 47 | return !staffChatEvent.isCancelled(); 48 | }).sendMessage(adventurise(messageRaw("staffchat-format").replace("{player}", getName(sender)).replace("{server}", getServerSafe(sender)).replace("{message}", message))); 49 | Discord.broadcastDiscordStaffChatMessage(sender, m); 50 | } 51 | 52 | public static void broadcastAFK(ProxiedPlayer player, boolean afk) { 53 | if(!UltraStaffChat.getConfig().getBoolean("afk-enabled")) 54 | return; 55 | StaffToggleAFKEvent staffToggleAFKEvent = new StaffToggleAFKEvent(player, afk); 56 | ProxyServer.getInstance().getPluginManager().callEvent(staffToggleAFKEvent); 57 | if(staffToggleAFKEvent.isCancelled()) 58 | return; 59 | Audience audience = UltraStaffChat.getInstance().getAdventure().permission(messageRaw("permission-afk")); 60 | audience.sendMessage(adventurise((afk ? messageRaw("afk-broadcast") : messageRaw("no-afk-broadcast")).replace("{player}", player.getName()))); 61 | if(afk) { 62 | Discord.broadcastDiscordAFKEnable(player); 63 | } else { 64 | Discord.broadcastDiscordAFKDisable(player); 65 | } 66 | } 67 | 68 | @Deprecated 69 | public static void broadcastJoin(ProxiedPlayer player) { 70 | broadcastJoin(player, player.getServer()); 71 | } 72 | 73 | public static void broadcastJoin(ProxiedPlayer player, Server server) { 74 | if(!UltraStaffChat.getConfig().getBoolean("join-enabled")) 75 | return; 76 | StaffJoinEvent staffJoinEvent = new StaffJoinEvent(player, server); 77 | ProxyServer.getInstance().getPluginManager().callEvent(staffJoinEvent); 78 | if(staffJoinEvent.isCancelled()) 79 | return; 80 | Audience audience = UltraStaffChat.getInstance().getAdventure().permission(messageRaw("permission-join")); 81 | audience.sendMessage(adventurise(messageRaw("join-message").replace("{player}", player.getName()).replace("{server}", server.getInfo().getName()))); 82 | Discord.broadcastDiscordJoin(player); 83 | } 84 | 85 | public static void broadcastLeave(ProxiedPlayer player) { 86 | if(!UltraStaffChat.getConfig().getBoolean("leave-enabled")) 87 | return; 88 | StaffLeaveEvent staffLeaveEvent = new StaffLeaveEvent(player); 89 | ProxyServer.getInstance().getPluginManager().callEvent(staffLeaveEvent); 90 | if(staffLeaveEvent.isCancelled()) 91 | return; 92 | Audience audience = UltraStaffChat.getInstance().getAdventure().permission(messageRaw("permission-leave")); 93 | audience.sendMessage(adventurise(messageRaw("leave-message").replace("{player}", player.getName()))); 94 | Discord.broadcastDiscordLeave(player); 95 | } 96 | 97 | @Deprecated 98 | public static void broadcastSwitch(ProxiedPlayer player, String from, String to) { 99 | broadcastSwitch(player, ProxyServer.getInstance().getServerInfo(from), player.getServer()); 100 | } 101 | 102 | public static void broadcastSwitch(ProxiedPlayer player, ServerInfo from, Server to) { 103 | if(!UltraStaffChat.getConfig().getBoolean("switch-enabled")) 104 | return; 105 | StaffSwitchServerEvent staffSwitchServerEvent = new StaffSwitchServerEvent(player, from, to); 106 | ProxyServer.getInstance().getPluginManager().callEvent(staffSwitchServerEvent); 107 | if(staffSwitchServerEvent.isCancelled()) 108 | return; 109 | Audience audience = UltraStaffChat.getInstance().getAdventure().permission(messageRaw("permission-switch")); 110 | String fromName = from.getName(); 111 | String toName = to.getInfo().getName(); 112 | Discord.broadcastDiscordSwitch(player, fromName, toName); 113 | audience.sendMessage(adventurise(messageRaw("switch-message").replace("{player}", player.getName()).replace("{from}", fromName).replace("{to}", toName))); 114 | } 115 | 116 | private static String getName(CommandSender sender) { 117 | if(sender instanceof ProxiedPlayer) 118 | return ((ProxiedPlayer) sender).getName(); 119 | else 120 | return "Console"; 121 | } 122 | 123 | private static String getServerSafe(CommandSender sender) { 124 | if(sender instanceof ProxiedPlayer) 125 | return (null == ((ProxiedPlayer) sender).getServer() ? "Unknown" : ((ProxiedPlayer) sender).getServer().getInfo().getName()); 126 | else 127 | return "Global"; 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/utils/MD_.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Aeternum Network 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package dev.hypera.ultrastaffchat.utils; 25 | 26 | import java.util.ArrayList; 27 | import java.util.List; 28 | import java.util.regex.Matcher; 29 | import java.util.regex.Pattern; 30 | import net.md_5.bungee.api.ChatColor; 31 | 32 | public final class MD_ { 33 | 34 | public static String parseMarkdown(String message) { 35 | String translated = message; 36 | 37 | translated = replaceWith(translated, "(? 1) { 82 | builder.append(part.substring(1)); 83 | } 84 | } 85 | 86 | private static String parseColours(char colorCharacter, StringBuilder builder, String c) { 87 | String colors = c; 88 | if (colorCharacter == 'z') builder.append(ChatColor.BOLD); 89 | else if (colorCharacter == 'x') builder.append(ChatColor.ITALIC); 90 | else if (colorCharacter == 'v') builder.append(ChatColor.UNDERLINE); 91 | else if (colorCharacter == 'q') builder.append(ChatColor.ITALIC); 92 | else if (colorCharacter == 'm') builder.append(ChatColor.STRIKETHROUGH); 93 | else if (colorCharacter == 'w') builder.append(ChatColor.MAGIC); 94 | else if (colorCharacter == 'Z') colors = colors.replace(ChatColor.BOLD.toString(), ""); 95 | else if (colorCharacter == 'X') colors = colors.replace(ChatColor.ITALIC.toString(), ""); 96 | else if (colorCharacter == 'V') colors = colors.replace(ChatColor.UNDERLINE.toString(), ""); 97 | else if (colorCharacter == 'Q') colors = colors.replace(ChatColor.ITALIC.toString(), ""); 98 | else if (colorCharacter == 'M') colors = colors.replace(ChatColor.STRIKETHROUGH.toString(), ""); 99 | else if (colorCharacter == 'W') colors = colors.replace(ChatColor.MAGIC.toString(), ""); 100 | if (Character.isUpperCase(colorCharacter)) builder.append(ChatColor.RESET).append(colors); 101 | return colors; 102 | } 103 | 104 | private static String replaceWith(String message, String quot, String pre, String suf) { 105 | String part = message; 106 | for (String str : getMatches(message, quot + "(.+?)" + quot)) { 107 | part = part.replaceFirst(quot + Pattern.quote(str) + quot, pre + str + suf); 108 | } 109 | return part; 110 | } 111 | 112 | public static List getMatches(String string, String regex) { 113 | Pattern pattern = Pattern.compile(regex); 114 | Matcher matcher = pattern.matcher(string); 115 | List matches = new ArrayList<>(); 116 | while (matcher.find()) { 117 | matches.add(matcher.group(1)); 118 | } 119 | return matches; 120 | } 121 | 122 | private static boolean isFormat(ChatColor color) { 123 | return color == ChatColor.MAGIC || color == ChatColor.BOLD || color == ChatColor.STRIKETHROUGH || color == ChatColor.ITALIC || color == ChatColor.UNDERLINE; 124 | } 125 | 126 | private static String getLastColors(String input) { 127 | String result = ""; 128 | int length = input.length(); 129 | 130 | // Search backwards from the end as it is faster 131 | for (int index = length - 1; index > -1; index--) { 132 | char section = input.charAt(index); 133 | if (section == ChatColor.COLOR_CHAR && index < length - 1) { 134 | char c = input.charAt(index + 1); 135 | ChatColor color = ChatColor.getByChar(c); 136 | 137 | if (color != null) { 138 | result = color + result; 139 | 140 | // Once we find a color or reset we can stop searching 141 | if (!isFormat(color) || color.equals(ChatColor.RESET)) { 142 | break; 143 | } 144 | } 145 | } 146 | } 147 | 148 | return result; 149 | } 150 | 151 | } 152 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/utils/Common.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.utils; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.config.Config; 23 | import dev.hypera.ultrastaffchat.objects.ErrorCode; 24 | import net.kyori.adventure.text.Component; 25 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 26 | import net.md_5.bungee.api.ChatColor; 27 | import net.md_5.bungee.api.CommandSender; 28 | import net.md_5.bungee.api.ProxyServer; 29 | import net.md_5.bungee.api.chat.BaseComponent; 30 | import net.md_5.bungee.api.chat.TextComponent; 31 | import net.md_5.bungee.api.connection.ProxiedPlayer; 32 | 33 | import java.io.PrintWriter; 34 | import java.io.StringWriter; 35 | 36 | public class Common { 37 | 38 | private static final String logPrefix = "&7[&c&lUltraStaffChat&7] &f"; 39 | private static final String errorPrefix = "&7[&4&lError&7] &4"; 40 | private static final Component logPrefixAdventure = adventurise(logPrefix); 41 | private static final Component errorPrefixAdventure = adventurise(errorPrefix); 42 | 43 | private static final int bStatsId = 5040; 44 | private static final long resourceId = 68956; 45 | private static final int configVersion = 37; 46 | private static final String[] contributors = new String[] { "Joshua Sing", "LooFifteen", "Christian F" }; 47 | 48 | /** 49 | * Logs messages to console. 50 | * 51 | * @param messages The messages to be logged. 52 | */ 53 | public static void log(String... messages) { 54 | for(String message : messages) 55 | ProxyServer.getInstance().getConsole().sendMessage(colour(message)); 56 | } 57 | 58 | /** 59 | * Logs messages to console with a prefix. 60 | * 61 | * @param messages The messages to be logged. 62 | */ 63 | public static void logPrefix(String... messages) { 64 | for(String message : messages) 65 | ProxyServer.getInstance().getConsole().sendMessage(colour(logPrefix + message)); 66 | } 67 | 68 | /** 69 | * Logs an error log to console. 70 | * 71 | * @param errorCode Error code. 72 | * @param message Any information about the error. 73 | * @param throwable Throwable. 74 | */ 75 | public static void error(ErrorCode errorCode, String message, Throwable throwable) { 76 | StringWriter stringWriter = new StringWriter(); 77 | PrintWriter printWriter = new PrintWriter(stringWriter); 78 | throwable.printStackTrace(printWriter); 79 | 80 | logPrefix(errorPrefix + errorCode.getMessage(), errorPrefix + "Error code: " + errorCode.getCode(), errorPrefix + "Message: " + message, errorPrefix + "Stack trace:\n" + stringWriter.toString()); 81 | 82 | try { 83 | printWriter.close(); 84 | stringWriter.close(); 85 | } catch (Exception ignored) { 86 | 87 | } 88 | } 89 | 90 | /** 91 | * Colourises a message and converts it to a BaseComponent. 92 | * 93 | * @param message The message to be colourised. 94 | * 95 | * @return BaseComponent Colourised message. 96 | */ 97 | public static BaseComponent[] colour(String message) { 98 | return TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', message)); 99 | } 100 | 101 | /** 102 | * Colourises a message. 103 | * 104 | * @param message The message to be colourised. 105 | * 106 | * @return Colourised message. 107 | */ 108 | public static String basicColour(String message) { 109 | return ChatColor.translateAlternateColorCodes('&', message); 110 | } 111 | 112 | /** 113 | * Checks if a CommandSender has a permission. 114 | * 115 | * @param sender The CommandSender to be checked. 116 | * @param permission The permission. 117 | * 118 | * @return If the CommandSender has the permission. 119 | */ 120 | public static boolean hasPermission(CommandSender sender, String permission) { 121 | return sender.hasPermission(permission) || sender.hasPermission("*"); 122 | } 123 | 124 | /** 125 | * Get SpigotMC Resource ID. 126 | * 127 | * @return Resource ID. 128 | */ 129 | public static long getResourceId() { 130 | return resourceId; 131 | } 132 | 133 | /** 134 | * Get bStats ID. 135 | * 136 | * @return bStats ID. 137 | */ 138 | public static int getbStatsId() { 139 | return bStatsId; 140 | } 141 | 142 | /** 143 | * Get current configuration version. 144 | * 145 | * @return Current config version. 146 | */ 147 | public static int getConfigVersion() { 148 | return configVersion; 149 | } 150 | 151 | /** 152 | * Returns a list of people that have contributed to UltraStaffChat. 153 | * 154 | * @return contributors. 155 | */ 156 | public static String[] getContributors() { 157 | return contributors; 158 | } 159 | 160 | /** 161 | * Get a Component message from the config. 162 | * 163 | * @return (Adventure Component) message. 164 | */ 165 | public static Component message(String key) { 166 | return adventurise(messageRaw(key)); 167 | } 168 | 169 | /** 170 | * Get the legacy ampersand log prefix 171 | * 172 | * @return (String) prefix. 173 | */ 174 | public static String getLogPrefix() { 175 | return logPrefix; 176 | } 177 | 178 | /** 179 | * Get the legacy ampersand error prefix 180 | * 181 | * @return (String) error prefix. 182 | */ 183 | public static String getErrorPrefix() { 184 | return errorPrefix; 185 | } 186 | 187 | /** 188 | * Get the component log prefix 189 | * 190 | * @return (Component) prefix. 191 | */ 192 | public static Component getLogPrefixAdventure() { 193 | return logPrefixAdventure; 194 | } 195 | 196 | /** 197 | * Get the component error prefix 198 | * 199 | * @return (Component) error prefix. 200 | */ 201 | public static Component getErrorPrefixAdventure() { 202 | return errorPrefixAdventure; 203 | } 204 | 205 | /** 206 | * Turns a message into an Adventure Component. 207 | * 208 | * @return (Adventure Component) message. 209 | */ 210 | public static Component adventurise(String message) { 211 | return LegacyComponentSerializer.legacyAmpersand().deserialize(message); 212 | } 213 | 214 | /** 215 | * Get a raw message from the config. 216 | * 217 | * @return (String) message. 218 | */ 219 | public static String messageRaw(String key) { 220 | Config config = UltraStaffChat.getConfig(); 221 | String message = config.getString(key); 222 | if(message == null) 223 | return "&7undefined"; 224 | return message; 225 | } 226 | 227 | public static String getDisplayNameSafe(CommandSender s) { 228 | if((s instanceof ProxiedPlayer)) { 229 | return ((ProxiedPlayer) s).getDisplayName(); 230 | } else { 231 | return "Console"; 232 | } 233 | } 234 | 235 | public static String getServerSafe(CommandSender s) { 236 | if((s instanceof ProxiedPlayer)) { 237 | return ((ProxiedPlayer) s).getServer().getInfo().getName(); 238 | } else { 239 | return "Undefined"; 240 | } 241 | } 242 | 243 | } 244 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/commands/impl/UltraStaffChatCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 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 dev.hypera.ultrastaffchat.utils.Discord; 25 | import dev.hypera.ultrastaffchat.utils.PasteUtils; 26 | import dev.hypera.ultrastaffchat.utils.TimeUtils; 27 | import net.kyori.adventure.audience.Audience; 28 | import net.kyori.adventure.text.Component; 29 | import net.kyori.adventure.text.event.ClickEvent; 30 | import net.kyori.adventure.text.event.HoverEvent; 31 | import net.kyori.adventure.text.format.NamedTextColor; 32 | import net.kyori.adventure.text.format.TextDecoration; 33 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; 34 | import net.md_5.bungee.api.CommandSender; 35 | import net.md_5.bungee.api.connection.ProxiedPlayer; 36 | 37 | import java.io.File; 38 | import java.io.FileWriter; 39 | import java.sql.Date; 40 | import java.time.Instant; 41 | 42 | import static dev.hypera.ultrastaffchat.managers.DebugManager.generateAdvancedDebugLog; 43 | import static dev.hypera.ultrastaffchat.managers.DebugManager.generateDebugLog; 44 | 45 | public class UltraStaffChatCommand extends Command { 46 | 47 | public UltraStaffChatCommand() { 48 | super("ultrastaffchat", null, "usc"); 49 | } 50 | 51 | @Override 52 | public void execute(CommandSender sender, String[] args) { 53 | Audience audience = UltraStaffChat.getInstance().getAdventure().sender(sender); 54 | 55 | if(args.length > 0) { 56 | if(args[0].matches("(?i:(ab(t|out)|credit(s)?|contibutor(s)?))")) { 57 | audience.sendMessage(Component.text().append(Component.text().content("UltraStaffChat").color(NamedTextColor.RED).decorate(TextDecoration.BOLD).clickEvent(ClickEvent.openUrl("https://www.spigotmc.org/resources/" + Common.getResourceId() + "/")), Component.text().content(" Version ").color(NamedTextColor.GRAY).build(), Component.text().content(UltraStaffChat.getInstance().getDescription().getVersion()).color(NamedTextColor.RED).build(), Component.text().content(" was created by:\n").color(NamedTextColor.GRAY).build(), LegacyComponentSerializer.legacyAmpersand().deserialize("&7 - &c" + String.join("\n &7- &c", Common.getContributors())))); 58 | return; 59 | } 60 | 61 | if(args[0].matches("(?i:(r(eload)?))")) { 62 | reload(sender, audience); 63 | return; 64 | } 65 | 66 | if(args[0].matches("(?i:(debug))")) { 67 | debug(sender, args, audience); 68 | } 69 | } 70 | 71 | audience.sendMessage(Component.text().append(Component.text().content("UltraStaffChat").color(NamedTextColor.RED).decorate(TextDecoration.BOLD).clickEvent(ClickEvent.openUrl("https://www.spigotmc.org/resources/" + Common.getResourceId() + "/")), Component.text().content(" Version ").color(NamedTextColor.GRAY).build(), Component.text().content(UltraStaffChat.getInstance().getDescription().getVersion()).color(NamedTextColor.RED).build(), Component.text().content("\nSupport").color(NamedTextColor.RED).build(), Component.text().content(": ").color(NamedTextColor.GRAY).build(), Component.text().content("https://discord.hypera.dev").color(NamedTextColor.AQUA).clickEvent(ClickEvent.openUrl("https://discord.hypera.dev")).build())); 72 | } 73 | 74 | @Override 75 | public boolean isDisabled() { 76 | return false; 77 | } 78 | 79 | private void reload(CommandSender sender, Audience audience) { 80 | if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-reload"))) { 81 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission"))); 82 | return; 83 | } 84 | 85 | audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Reloading configuration files...").color(NamedTextColor.GREEN))); 86 | 87 | UltraStaffChat.getConfig().reload(); 88 | Discord.reload(); 89 | 90 | audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Successfully reloaded configuration files").color(NamedTextColor.GREEN))); 91 | } 92 | 93 | private void debug(CommandSender sender, String[] args, Audience audience) { 94 | if(!sender.hasPermission(UltraStaffChat.getConfig().getString("permission-debug"))) { 95 | audience.sendMessage(Common.adventurise(UltraStaffChat.getConfig().getString("no-permission"))); 96 | return; 97 | } 98 | 99 | boolean isPlayer = sender instanceof ProxiedPlayer; 100 | String log; 101 | 102 | boolean advanced = false; 103 | if(args.length > 1) { 104 | for(String arg : args) { 105 | if(arg.matches("(?i:(--a(dv(anced)?)?))")) { 106 | advanced = true; 107 | break; 108 | } 109 | } 110 | } 111 | 112 | if(advanced) { 113 | audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Generating advanced debug log...").color(NamedTextColor.WHITE))); 114 | log = generateAdvancedDebugLog(); 115 | } else { 116 | audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Generating debug log...").color(NamedTextColor.WHITE))); 117 | log = generateDebugLog(); 118 | } 119 | 120 | logDebug(audience, isPlayer, log, advanced); 121 | } 122 | 123 | private void logDebug(Audience audience, boolean isPlayer, String log, boolean advanced) { 124 | try { 125 | String filename = "USC-" + TimeUtils.formatFileDateTime(Date.from(Instant.now())) + "-Debug.txt"; 126 | File logFolder = new File(UltraStaffChat.getInstance().getDataFolder() + "/logs"); 127 | if(!logFolder.exists()) 128 | logFolder.mkdirs(); 129 | 130 | File logFile = new File(logFolder + "/" + filename); 131 | if(logFile.createNewFile()) { 132 | FileWriter logWriter = new FileWriter(logFile); 133 | logWriter.write(log); 134 | logWriter.close(); 135 | } else { 136 | throw new Exception(); 137 | } 138 | 139 | String pasteURL = PasteUtils.createPaste(log); 140 | if(pasteURL == null) 141 | throw new Exception(); 142 | 143 | Component component; 144 | if (advanced) { 145 | component = Common.getLogPrefixAdventure().append(Component.text("Successfully generated debug log").color(NamedTextColor.GREEN)); 146 | if (isPlayer) component = component.append(Component.text(" [View]").color(NamedTextColor.GRAY).clickEvent(ClickEvent.openUrl(pasteURL)).hoverEvent(HoverEvent.showText(Component.text(pasteURL)))); 147 | } else { 148 | component = Common.adventurise(log); 149 | if (isPlayer) component = component.clickEvent(ClickEvent.openUrl(pasteURL)); 150 | } 151 | audience.sendMessage(component); 152 | if (!isPlayer) audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text(pasteURL).color(NamedTextColor.GRAY))); 153 | } catch (Exception e) { 154 | Common.logPrefix("Failed to generate debug log!"); 155 | audience.sendMessage(Common.getLogPrefixAdventure().append(Component.text("Failed to generate debug log").color(NamedTextColor.RED))); 156 | } 157 | } 158 | 159 | } 160 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/utils/DiscordWebhook.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by k3kdude (https://github.com/k3kdude) Original: https://gist.github.com/k3kdude/fba6f6b37594eae3d6f9475330733bdb 3 | */ 4 | package dev.hypera.ultrastaffchat.utils; 5 | 6 | import java.nio.charset.StandardCharsets; 7 | import javax.net.ssl.HttpsURLConnection; 8 | import java.awt.Color; 9 | import java.io.IOException; 10 | import java.io.OutputStream; 11 | import java.lang.reflect.Array; 12 | import java.net.URL; 13 | import java.util.ArrayList; 14 | import java.util.HashMap; 15 | import java.util.List; 16 | import java.util.Map; 17 | import java.util.Set; 18 | 19 | /** 20 | * Class used to execute Discord Webhooks with low effort 21 | */ 22 | @SuppressWarnings("all") 23 | public class DiscordWebhook { 24 | 25 | private final String url; 26 | private String content; 27 | private String username; 28 | private String avatarUrl; 29 | private boolean tts; 30 | private List embeds = new ArrayList<>(); 31 | 32 | /** 33 | * Constructs a new DiscordWebhook instance 34 | * 35 | * @param url The webhook URL obtained in Discord 36 | */ 37 | public DiscordWebhook(String url) { 38 | this.url = url; 39 | } 40 | 41 | public void setContent(String content) { 42 | this.content = content; 43 | } 44 | 45 | public void setUsername(String username) { 46 | this.username = username; 47 | } 48 | 49 | public void setAvatarUrl(String avatarUrl) { 50 | this.avatarUrl = avatarUrl; 51 | } 52 | 53 | public void setTts(boolean tts) { 54 | this.tts = tts; 55 | } 56 | 57 | public void addEmbed(EmbedObject embed) { 58 | this.embeds.add(embed); 59 | } 60 | 61 | public void execute() throws IOException { 62 | if(this.content == null && this.embeds.isEmpty()) { 63 | throw new IllegalArgumentException("Set content or add at least one EmbedObject"); 64 | } 65 | 66 | JSONObject json = new JSONObject(); 67 | 68 | json.put("content", this.content); 69 | json.put("username", this.username); 70 | json.put("avatar_url", this.avatarUrl); 71 | json.put("tts", this.tts); 72 | 73 | if(!this.embeds.isEmpty()) { 74 | List embedObjects = new ArrayList<>(); 75 | 76 | for(EmbedObject embed : this.embeds) { 77 | JSONObject jsonEmbed = new JSONObject(); 78 | 79 | jsonEmbed.put("title", embed.getTitle()); 80 | jsonEmbed.put("description", embed.getDescription()); 81 | jsonEmbed.put("url", embed.getUrl()); 82 | 83 | if(embed.getColor() != null) { 84 | Color color = embed.getColor(); 85 | int rgb = color.getRed(); 86 | rgb = (rgb << 8) + color.getGreen(); 87 | rgb = (rgb << 8) + color.getBlue(); 88 | 89 | jsonEmbed.put("color", rgb); 90 | } 91 | 92 | EmbedObject.Footer footer = embed.getFooter(); 93 | EmbedObject.Image image = embed.getImage(); 94 | EmbedObject.Thumbnail thumbnail = embed.getThumbnail(); 95 | EmbedObject.Author author = embed.getAuthor(); 96 | List fields = embed.getFields(); 97 | 98 | if(footer != null) { 99 | JSONObject jsonFooter = new JSONObject(); 100 | 101 | jsonFooter.put("text", footer.getText()); 102 | jsonFooter.put("icon_url", footer.getIconUrl()); 103 | jsonEmbed.put("footer", jsonFooter); 104 | } 105 | 106 | if(image != null) { 107 | JSONObject jsonImage = new JSONObject(); 108 | 109 | jsonImage.put("url", image.getUrl()); 110 | jsonEmbed.put("image", jsonImage); 111 | } 112 | 113 | if(thumbnail != null) { 114 | JSONObject jsonThumbnail = new JSONObject(); 115 | 116 | jsonThumbnail.put("url", thumbnail.getUrl()); 117 | jsonEmbed.put("thumbnail", jsonThumbnail); 118 | } 119 | 120 | if(author != null) { 121 | JSONObject jsonAuthor = new JSONObject(); 122 | 123 | jsonAuthor.put("name", author.getName()); 124 | jsonAuthor.put("url", author.getUrl()); 125 | jsonAuthor.put("icon_url", author.getIconUrl()); 126 | jsonEmbed.put("author", jsonAuthor); 127 | } 128 | 129 | List jsonFields = new ArrayList<>(); 130 | for(EmbedObject.Field field : fields) { 131 | JSONObject jsonField = new JSONObject(); 132 | 133 | jsonField.put("name", field.getName()); 134 | jsonField.put("value", field.getValue()); 135 | jsonField.put("inline", field.isInline()); 136 | 137 | jsonFields.add(jsonField); 138 | } 139 | 140 | jsonEmbed.put("fields", jsonFields.toArray()); 141 | embedObjects.add(jsonEmbed); 142 | } 143 | 144 | json.put("embeds", embedObjects.toArray()); 145 | } 146 | 147 | URL url = new URL(this.url); 148 | HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); 149 | connection.addRequestProperty("Content-Type", "application/json"); 150 | connection.addRequestProperty("User-Agent", "Java-DiscordWebhook-BY-Gelox_"); 151 | connection.setDoOutput(true); 152 | connection.setRequestMethod("POST"); 153 | 154 | OutputStream stream = connection.getOutputStream(); 155 | stream.write(json.toString().getBytes(StandardCharsets.UTF_8)); 156 | stream.flush(); 157 | stream.close(); 158 | 159 | connection.getInputStream().close(); //I'm not sure why but it doesn't work without getting the InputStream 160 | connection.disconnect(); 161 | } 162 | 163 | public static class EmbedObject { 164 | 165 | private String title; 166 | private String description; 167 | private String url; 168 | private Color color; 169 | 170 | private Footer footer; 171 | private Thumbnail thumbnail; 172 | private Image image; 173 | private Author author; 174 | private List fields = new ArrayList<>(); 175 | 176 | public String getTitle() { 177 | return title; 178 | } 179 | 180 | public String getDescription() { 181 | return description; 182 | } 183 | 184 | public String getUrl() { 185 | return url; 186 | } 187 | 188 | public Color getColor() { 189 | return color; 190 | } 191 | 192 | public Footer getFooter() { 193 | return footer; 194 | } 195 | 196 | public Thumbnail getThumbnail() { 197 | return thumbnail; 198 | } 199 | 200 | public Image getImage() { 201 | return image; 202 | } 203 | 204 | public Author getAuthor() { 205 | return author; 206 | } 207 | 208 | public List getFields() { 209 | return fields; 210 | } 211 | 212 | public EmbedObject setTitle(String title) { 213 | this.title = title; 214 | return this; 215 | } 216 | 217 | public EmbedObject setDescription(String description) { 218 | this.description = description; 219 | return this; 220 | } 221 | 222 | public EmbedObject setUrl(String url) { 223 | this.url = url; 224 | return this; 225 | } 226 | 227 | public EmbedObject setColor(Color color) { 228 | this.color = color; 229 | return this; 230 | } 231 | 232 | public EmbedObject setFooter(String text, String icon) { 233 | this.footer = new Footer(text, icon); 234 | return this; 235 | } 236 | 237 | public EmbedObject setThumbnail(String url) { 238 | this.thumbnail = new Thumbnail(url); 239 | return this; 240 | } 241 | 242 | public EmbedObject setImage(String url) { 243 | this.image = new Image(url); 244 | return this; 245 | } 246 | 247 | public EmbedObject setAuthor(String name, String url, String icon) { 248 | this.author = new Author(name, url, icon); 249 | return this; 250 | } 251 | 252 | public EmbedObject addField(String name, String value, boolean inline) { 253 | this.fields.add(new Field(name, value, inline)); 254 | return this; 255 | } 256 | 257 | private class Footer { 258 | 259 | private String text; 260 | private String iconUrl; 261 | 262 | private Footer(String text, String iconUrl) { 263 | this.text = text; 264 | this.iconUrl = iconUrl; 265 | } 266 | 267 | private String getText() { 268 | return text; 269 | } 270 | 271 | private String getIconUrl() { 272 | return iconUrl; 273 | } 274 | 275 | } 276 | 277 | private class Thumbnail { 278 | 279 | private String url; 280 | 281 | private Thumbnail(String url) { 282 | this.url = url; 283 | } 284 | 285 | private String getUrl() { 286 | return url; 287 | } 288 | 289 | } 290 | 291 | private class Image { 292 | 293 | private String url; 294 | 295 | private Image(String url) { 296 | this.url = url; 297 | } 298 | 299 | private String getUrl() { 300 | return url; 301 | } 302 | 303 | } 304 | 305 | private class Author { 306 | 307 | private String name; 308 | private String url; 309 | private String iconUrl; 310 | 311 | private Author(String name, String url, String iconUrl) { 312 | this.name = name; 313 | this.url = url; 314 | this.iconUrl = iconUrl; 315 | } 316 | 317 | private String getName() { 318 | return name; 319 | } 320 | 321 | private String getUrl() { 322 | return url; 323 | } 324 | 325 | private String getIconUrl() { 326 | return iconUrl; 327 | } 328 | 329 | } 330 | 331 | private class Field { 332 | 333 | private String name; 334 | private String value; 335 | private boolean inline; 336 | 337 | private Field(String name, String value, boolean inline) { 338 | this.name = name; 339 | this.value = value; 340 | this.inline = inline; 341 | } 342 | 343 | private String getName() { 344 | return name; 345 | } 346 | 347 | private String getValue() { 348 | return value; 349 | } 350 | 351 | private boolean isInline() { 352 | return inline; 353 | } 354 | 355 | } 356 | 357 | } 358 | 359 | private class JSONObject { 360 | 361 | private final HashMap map = new HashMap<>(); 362 | 363 | void put(String key, Object value) { 364 | if(value != null) { 365 | map.put(key, value); 366 | } 367 | } 368 | 369 | @Override 370 | public String toString() { 371 | StringBuilder builder = new StringBuilder(); 372 | Set> entrySet = map.entrySet(); 373 | builder.append("{"); 374 | 375 | int i = 0; 376 | for(Map.Entry entry : entrySet) { 377 | Object val = entry.getValue(); 378 | builder.append(quote(entry.getKey())).append(":"); 379 | 380 | if(val instanceof String) { 381 | builder.append(quote(String.valueOf(val))); 382 | } else if(val instanceof Integer) { 383 | builder.append(Integer.valueOf(String.valueOf(val))); 384 | } else if(val instanceof Boolean) { 385 | builder.append(val); 386 | } else if(val instanceof JSONObject) { 387 | builder.append(val.toString()); 388 | } else if(val.getClass().isArray()) { 389 | builder.append("["); 390 | int len = Array.getLength(val); 391 | for(int j = 0; j < len; j++) { 392 | builder.append(Array.get(val, j).toString()).append(j != len - 1 ? "," : ""); 393 | } 394 | builder.append("]"); 395 | } 396 | 397 | builder.append(++i == entrySet.size() ? "}" : ","); 398 | } 399 | 400 | return builder.toString(); 401 | } 402 | 403 | private String quote(String string) { 404 | return "\"" + string + "\""; 405 | } 406 | 407 | } 408 | 409 | } -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | # __ ______ _____ __ ________________ __ 2 | # / / / / / /__________ _/ ___// /_____ _/ __/ __/ ____/ /_ ____ _/ /_ 3 | # / / / / / __/ ___/ __ `/\__ \/ __/ __ `/ /_/ /_/ / / __ \/ __ `/ __/ 4 | # / /_/ / / /_/ / / /_/ /___/ / /_/ /_/ / __/ __/ /___/ / / / /_/ / /_ 5 | # \____/_/\__/_/ \__,_//____/\__/\__,_/_/ /_/ \____/_/ /_/\__,_/\__/ 6 | # 7 | # UltraStaffChat v@version@ - Main configuration file (config.yml) 8 | # Copyright (C) 2021-2023 The UltraStaffChat Authors (https://github.com/HyperaDev/UltraStaffChat/blob/main/AUTHORS) 9 | # 10 | # This program is free software: you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation, either version 3 of the License, or 13 | # (at your option) any later version. 14 | # 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | # 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | # 23 | # Helpful Links: 24 | # Wiki | https://wiki.hypera.dev/ultrastaffchat/ 25 | # Support | https://support.hypera.dev/ 26 | # Source Code | https://github.com/HyperaDev/UltraStaffChat 27 | # 28 | # Thank you for using UltraStaffChat! 29 | # If you have any questions or problems, please contact us: 30 | # https://support.hypera.dev/ 31 | # 32 | # If you wish to support our work, and receive even more features at the same time, 33 | # please consider taking the time to look at UltraStaffChatPro: 34 | # https://www.spigotmc.org/resources/80461/ 35 | # - Joshua Sing (@joshuasing) 36 | # 37 | 38 | # [ UltraStaffChat | General Configuration ] 39 | 40 | # General | No Permission Message 41 | no-permission: "&cNo Permission." 42 | 43 | # General | In-game Only Message 44 | ingame-only: "&cThis command can only be used in-game." 45 | 46 | 47 | # [ UltraStaffChat | Discord Configuration ] 48 | 49 | # Discord | Enabled 50 | # Should we send messages to Discord? 51 | discord-enabled: false 52 | 53 | # Discord | Webhook URL 54 | discord-webhook: "https://discord.com/api/webhooks/XXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" 55 | 56 | # Discord | Webhook Username 57 | # What name do you want the webhook to use? 58 | discord-username: "UltraStaffChat" 59 | 60 | # Discord | Webhook Image 61 | # What image do you want the webhook to use? 62 | discord-image: "https://cdn.discordapp.com/icons/639666139747581955/fa3ffcc73fd3a47054fc575736c812f6.png" 63 | 64 | # Discord | Embed 65 | # Should we use embeds? 66 | discord-embed: true 67 | 68 | # Discord | StaffChat Format 69 | # - Placeholders: Player - {player}, Server - {server}, Message - {message} 70 | discord-format: 71 | text: "[StaffChat] {server} - **{player}**: {message}" # Only used if 'discord-embed' is disabled. 72 | embed: # Only used if 'discord-embed' is enabled. 73 | author: # Embed Author 74 | name: "" 75 | url: "" 76 | image: "" 77 | title: "" # Embed Title 78 | title-url: "" # Enbed Title URL 79 | description: "**{player}**: {message}" # Embed Description 80 | color: "#5555FF" # Embed Color 81 | footer: # Upgrade to UltraStaffChatPro to change the embed Footer 82 | image: "" # Embed Image URL 83 | thumbnail: "" # Embed Thumbnail URL 84 | fields: # Embed Fields (Remove all to have no fields) 85 | # 1: 86 | # name: "{player}" 87 | # value: "{message}" 88 | # inline: true 89 | # 2: 90 | # name: "Server" 91 | # value: "{server}" 92 | # inline: true 93 | # 3: 94 | # name: "Example" 95 | # value: "You can keep making more fields" 96 | # inline: false 97 | 98 | # Discord | Staff Join Messages 99 | # Should Staff Join messages be sent to Discord? 100 | discord-join-messages: true 101 | 102 | # Discord | Join Format 103 | # - Placeholders: Player - {player}, Server - {server} 104 | discord-join-format: 105 | text: "**{player}** connected to **{server}**" # Only used if 'discord-embed' is disabled. 106 | embed: # Only used if 'discord-embed' is enabled. 107 | author: # Embed Author 108 | name: "" 109 | url: "" 110 | image: "" 111 | title: "{player}" # Embed Title 112 | title-url: "" # Enbed Title URL 113 | description: "** + {server} **" # Embed Description 114 | color: "#5555FF" # Embed Color 115 | footer: # Upgrade to UltraStaffChatPro to change the embed Footer 116 | image: "" # Embed Image URL 117 | thumbnail: "" # Embed Thumbnail URL 118 | fields: # Embed Fields (Remove all to have no fields) 119 | # 1: 120 | # name: "Example" 121 | # value: "You can keep making more fields" 122 | # inline: false 123 | 124 | # Discord | Staff Leave Messages 125 | # Should Staff Leave messages be sent to Discord? 126 | discord-leave-messages: true 127 | 128 | # Discord | Leave Format 129 | # - Placeholders: Player - {player}, Server - {server} 130 | discord-leave-format: 131 | text: "**{player}** disconnected from **{server}**" # Only used if 'discord-embed' is disabled. 132 | embed: # Only used if 'discord-embed' is enabled. 133 | author: # Embed Author 134 | name: "" 135 | url: "" 136 | image: "" 137 | title: "{player}" # Embed Title 138 | title-url: "" # Enbed Title URL 139 | description: "** - {server} **" # Embed Description 140 | color: "#5555FF" # Embed Color 141 | footer: # Upgrade to UltraStaffChatPro to change the embed Footer 142 | image: "" # Embed Image URL 143 | thumbnail: "" # Embed Thumbnail URL 144 | fields: # Embed Fields (Remove all to have no fields) 145 | # 1: 146 | # name: "Example" 147 | # value: "You can keep making more fields" 148 | # inline: false 149 | 150 | # Discord | Staff Switch Messages 151 | # Should Staff Switch messages be sent to Discord? 152 | discord-switch-messages: true 153 | 154 | # Discord | Switch Format 155 | # - Placeholders: Player - {player}, From - {from}, To - {to} 156 | discord-switch-format: 157 | text: "**{player}** switched from **{from}** -> **{to}**" # Only used if 'discord-embed' is disabled. 158 | embed: # Only used if 'discord-embed' is enabled. 159 | author: # Embed Author 160 | name: "" 161 | url: "" 162 | image: "" 163 | title: "{player}" # Embed Title 164 | title-url: "" # Enbed Title URL 165 | description: "** {from} -> {to} **" # Embed Description 166 | color: "#5555FF" # Embed Color 167 | footer: # Upgrade to UltraStaffChatPro to change the embed Footer 168 | image: "" # Embed Image URL 169 | thumbnail: "" # Embed Thumbnail URL 170 | fields: # Embed Fields (Remove all to have no fields) 171 | # 1: 172 | # name: "Example" 173 | # value: "You can keep making more fields" 174 | # inline: false 175 | 176 | # Discord | AFK Messages 177 | # Should Staff AFK enable messages be sent to Discord? 178 | discord-afk-enable-messages: true 179 | 180 | # Discord | AFK Enable Format 181 | # - Placeholders: Player - {player} 182 | discord-afk-enable-format: 183 | text: "**{player}** is now AFK" # Only used if 'discord-embed' is disabled. 184 | embed: # Only used if 'discord-embed' is enabled. 185 | author: # Embed Author 186 | name: "" 187 | url: "" 188 | image: "" 189 | title: "{player}" # Embed Title 190 | title-url: "" # Enbed Title URL 191 | description: "has gone AFK" # Embed Description 192 | color: "#5555FF" # Embed Color 193 | footer: # Upgrade to UltraStaffChatPro to change the embed Footer 194 | image: "" # Embed Image URL 195 | thumbnail: "" # Embed Thumbnail URL 196 | fields: # Embed Fields (Remove all to have no fields) 197 | # 1: 198 | # name: "Example" 199 | # value: "You can keep making more fields" 200 | # inline: false 201 | 202 | # Discord | AFK Messages 203 | # Should Staff AFK disable messages be sent to Discord? 204 | discord-afk-disable-messages: true 205 | 206 | # Discord | AFK Disable Format 207 | # - Placeholders: Player - {player} 208 | discord-afk-disable-format: 209 | text: "**{player}** is no longer AFK" # Only used if 'discord-embed' is disabled. 210 | embed: # Only used if 'discord-embed' is enabled. 211 | author: # Embed Author 212 | name: "" 213 | url: "" 214 | image: "" 215 | title: "{player}" # Embed Title 216 | title-url: "" # Enbed Title URL 217 | description: "is no longer AFK" # Embed Description 218 | color: "#5555FF" # Embed Color 219 | footer: # Upgrade to UltraStaffChatPro to change the embed Footer 220 | image: "" # Embed Image URL 221 | thumbnail: "" # Embed Thumbnail URL 222 | fields: # Embed Fields (Remove all to have no fields) 223 | # 1: 224 | # name: "Example" 225 | # value: "You can keep making more fields" 226 | # inline: false 227 | 228 | 229 | 230 | # [ UltraStaffChat | StaffChat Configuration ] 231 | 232 | # StaffChat | Format 233 | # - Placeholders: Player - {player}, Server - {server}, Message - {message} 234 | staffchat-format: "&8[&4&lStaffChat&8] &4{player}&c: &c{message}" 235 | 236 | # StaffChat | Usage 237 | staffchat-usage: "&cUsage: /staffchat " 238 | 239 | # StaffChat | Muted 240 | staffchat-muted: "&cStaffChat is currently Muted" 241 | 242 | # StaffChat | Prefix 243 | # Allows Staff members to send messages to StaffChat using a prefix before their message. 244 | # Set to "" to disable. 245 | staffchat-prefix: "#" 246 | 247 | 248 | 249 | # [ UltraStaffChat | Toggle Configuration ] 250 | 251 | # Toggle | Enabled 252 | toggle-enabled: true 253 | 254 | # Toggle On | Message 255 | toggle-message-on: "&8[&4&lStaffChat&8] &cStaffChat Toggled &aOn&c!" 256 | 257 | # Toggle Off | Message 258 | toggle-message-off: "&8[&4&lStaffChat&8] &cStaffChat Toggled &cOff&c!" 259 | 260 | # Toggle | Usage 261 | toggle-usage: "&cUsage: /sctoggle " 262 | 263 | 264 | # [ UltraStaffChat | Mute Configuration ] 265 | 266 | # Mute | Enabled 267 | mute-enabled: true 268 | 269 | # Mute On | Message 270 | mute-message-on: "&8[&4&lStaffChat&8] &cStaffChat &cMuted&c!" 271 | 272 | # Mute Off | Message 273 | mute-message-off: "&8[&4&lStaffChat&8] &cStaffChat &aUnmuted&c!" 274 | 275 | # Mute | Usage 276 | mute-usage: "&cUsage: /scmute " 277 | 278 | # [ UltraStaffChat | Mute StaffChat Configuration ] 279 | 280 | # Mute | Enabled 281 | mute-staffchat-enabled: true 282 | 283 | # Mute On | Message 284 | mute-staffchat-message-on: "&8[&4&lStaffChat&8] &cStaffChat has been &cMuted&c!" 285 | 286 | # Mute Off | Message 287 | mute-staffchat-message-off: "&8[&4&lStaffChat&8] &cStaffChat has been &aUnmuted&c!" 288 | 289 | # Mute | Usage 290 | mute-staffchat-usage: "&cUsage: /mutesc " 291 | 292 | 293 | 294 | # [ UltraStaffChat | AFK Configuration ] 295 | 296 | # AFK | Enabled 297 | afk-enabled: true 298 | 299 | # AFK | Message 300 | # - Placeholders: Player - {player} 301 | afk-broadcast: "&7{player} is now &c&lAFK&7." 302 | 303 | # AFK | No longer AFK Message 304 | # - Placeholders: Player - {player} 305 | no-afk-broadcast: "&7{player} is no longer &c&lAFK&7." 306 | 307 | 308 | 309 | # [ UltraStaffChat | Join Message Configuration ] 310 | 311 | # Join Message | Enabled 312 | join-enabled: true 313 | 314 | # Join Message | Message 315 | # - Placeholders: Player - {player}, Server - {server} 316 | join-message: "&7[&a&l+&7] &7[{server}] &a{player}" 317 | 318 | 319 | 320 | # [ UltraStaffChat | Leave Message Configuration ] 321 | 322 | # Leave Message | Enabled 323 | leave-enabled: true 324 | 325 | # Leave Message | Message 326 | # - Placeholders: Player - {player} 327 | leave-message: "&7[&c&l-&7] &c{player}" 328 | 329 | 330 | 331 | # [ UltraStaffChat | Switch Message Configuration ] 332 | 333 | # Switch Message | Enabled 334 | switch-enabled: true 335 | 336 | # Switch Message | Message 337 | # - Placeholders: Player - {player}, From - {from}, To - {to} 338 | switch-message: "&8[&4&lStaffChat&8] &c{player} switched from {from} to {to}" 339 | 340 | 341 | 342 | # [ UltraStaffChat | StaffList Configuration ] 343 | 344 | # StaffList | Enabled 345 | stafflist-enabled: true 346 | 347 | # StaffList | Header 348 | # - Placeholders: Staff Count - {count} 349 | stafflist-header: "&7({count}) &c&lOnline Staff Members&7:" 350 | 351 | # StaffList | Format 352 | # - Placeholders: Player - {player}, Server - {server} 353 | stafflist-line: "&4{player} &7- &4{server}" 354 | 355 | # StaffList | No staff online 356 | stafflist-offline: "&cNo staff members are online." 357 | 358 | 359 | 360 | # [ UltraStaffChat | Update Notification Configuration ] 361 | 362 | # Update Notification | Enabled 363 | update-enabled: true 364 | 365 | # Update Notification | Message 366 | # - Placeholders: New Version - {version}, Current Version - {current} 367 | update-message: "&8[&c&lUltraStaffChat&8] &aVersion {version} is now available." 368 | 369 | 370 | 371 | # [ UltraStaffChat | Permissions ] 372 | 373 | # Permission | StaffChat Talk 374 | permission-talk: "staffchat.talk" 375 | 376 | # Permission | StaffChat Read 377 | permission-read: "staffchat.read" 378 | 379 | # Permission | Toggle 380 | permission-toggle: "staffchat.toggle" 381 | 382 | # Permission | Mute 383 | permission-mute: "staffchat.mute" 384 | 385 | # Permission | Mute Global 386 | permission-globalmute: "staffchat.globalmute" 387 | 388 | # Permission | StaffChat Global Mute Bypass 389 | permission-bypass: "staffchat.mutebypass" 390 | 391 | # Permission | AFK 392 | permission-afk: "staffchat.afk" 393 | 394 | # Permission | Staff Join 395 | permission-join: "staffchat.join" 396 | 397 | # Permission | Staff Leave 398 | permission-leave: "staffchat.leave" 399 | 400 | # Permission | Switch 401 | permission-switch: "staffchat.switch" 402 | 403 | # Permission | Staff List 404 | permission-list: "staffchat.list" 405 | 406 | # Permission | Staff (Permission needed to display on Staff List) 407 | permission-staff: "staffchat.staff" 408 | 409 | # Permission | Chat Formatting 410 | permission-chat-format: "staffchat.format" 411 | 412 | # Permission | Update Notification 413 | permission-update: "ultrastaffchat.update" 414 | 415 | # Permission | Configuration Reload 416 | permission-reload: "ultrastaffchat.reload" 417 | 418 | # Permission | Debug 419 | permission-debug: "ultrastaffchat.debug" 420 | 421 | 422 | 423 | # [ UltraStaffChat | System Configuration ] 424 | 425 | # System | Configuration Version 426 | # Used for Internal purposes - Don't edit! 427 | version: 37 428 | 429 | # - You're done! 430 | # Thanks for using UltraStaffChat BungeeCord! 431 | -------------------------------------------------------------------------------- /src/main/java/dev/hypera/ultrastaffchat/utils/Discord.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is a part of UltraStaffChat (https://github.com/HyperaDev/UltraStaffChat). 3 | * 4 | * Copyright (C) 2021-2023 The UltraStaffChat Authors. 5 | * 6 | * This program is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program. If not, see . 18 | */ 19 | package dev.hypera.ultrastaffchat.utils; 20 | 21 | import dev.hypera.ultrastaffchat.UltraStaffChat; 22 | import dev.hypera.ultrastaffchat.utils.DiscordWebhook.EmbedObject; 23 | import net.md_5.bungee.api.CommandSender; 24 | import net.md_5.bungee.api.ProxyServer; 25 | import net.md_5.bungee.api.connection.ProxiedPlayer; 26 | import net.md_5.bungee.config.Configuration; 27 | 28 | import java.awt.*; 29 | import java.io.IOException; 30 | 31 | public class Discord { 32 | 33 | private static final String footer = "UltraStaffChat - BungeeCord v" + UltraStaffChat.getInstance().getDescription().getVersion(); 34 | private static final String footerUrl = "https://i.hypera.dev/assets/hypera-icon-white.png"; 35 | private static boolean enabled = false; 36 | private static String hookURL = ""; 37 | 38 | public static void setup() { 39 | Configuration config = UltraStaffChat.getConfig().getConfiguration(); 40 | if(!config.getBoolean("discord-enabled")) 41 | return; 42 | if(config.getString("discord-webhook") == null || config.getString("discord-webhook").contains("XXXXXXXXXXXXXXXXXX")) { 43 | Common.logPrefix("&cError: Discord messages are enabled but the webhook URL has not been configured!"); 44 | return; 45 | } 46 | 47 | if (config.getSection("discord-format.embed.fields").getKeys().size() > 25 48 | || config.getSection("discord-join-format.embed.fields").getKeys().size() > 25 49 | || config.getSection("discord-leave-format.embed.fields").getKeys().size() > 25 50 | || config.getSection("discord-switch-format.embed.fields").getKeys().size() > 25 51 | || config.getSection("discord-afk-enable-format.embed.fields").getKeys().size() > 25 52 | || config.getSection("discord-afk-disable-format.embed.fields").getKeys().size() > 25) { 53 | Common.logPrefix("&cError: You can have a max of 25 fields in an embed."); 54 | return; 55 | } 56 | 57 | hookURL = config.getString("discord-webhook"); 58 | enabled = true; 59 | } 60 | 61 | public static void reload() { 62 | enabled = false; 63 | setup(); 64 | } 65 | 66 | public static boolean isEnabled() { 67 | return enabled; 68 | } 69 | 70 | public static void broadcastDiscordJoin(ProxiedPlayer p) { 71 | if(!isEnabled() || !UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-join-messages")) 72 | return; 73 | ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> { 74 | try { 75 | DiscordWebhook hook = getHook(); 76 | if(!UltraStaffChat.getConfig().getBoolean("discord-embed")) { 77 | Configuration textFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-join-format"); 78 | hook.setContent(join_leavePlaceholders(textFormat.getString("text"), p)); 79 | hook.execute(); 80 | return; 81 | } 82 | 83 | EmbedObject embed = createEmbed(); 84 | Configuration embedFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-join-format.embed"); 85 | embed.setColor(Color.decode(embedFormat.getString("color"))); 86 | embed.setDescription(join_leavePlaceholders(embedFormat.getString("description"), p)); 87 | embed.setTitle(join_leavePlaceholders(embedFormat.getString("title"), p)); 88 | embed.setThumbnail(embedFormat.getString("thumbnail")); 89 | embed.setImage(embedFormat.getString("image")); 90 | embed.setAuthor(embedFormat.getString("author.name"), embedFormat.getString("author.url"), embedFormat.getString("image")); 91 | embed.setUrl(embedFormat.getString("url")); 92 | for(String key : embedFormat.getSection("fields").getKeys()) { 93 | Configuration sec = UltraStaffChat.getConfig().getConfiguration().getSection("discord-join-format.embed.fields." + key); 94 | embed.addField(join_leavePlaceholders(sec.getString("name"), p), join_leavePlaceholders(sec.getString("value"), p), sec.getBoolean("inline")); 95 | } 96 | hook.addEmbed(embed); 97 | hook.execute(); 98 | } catch (Exception e) { 99 | Common.log(e.toString()); 100 | } 101 | }); 102 | } 103 | 104 | public static void broadcastDiscordLeave(ProxiedPlayer p) { 105 | if(!isEnabled() || !UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-leave-messages")) 106 | return; 107 | ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> { 108 | try { 109 | DiscordWebhook hook = getHook(); 110 | 111 | if(!UltraStaffChat.getConfig().getBoolean("discord-embed")) { 112 | Configuration textFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-leave-format"); 113 | hook.setContent(join_leavePlaceholders(textFormat.getString("text"), p)); 114 | hook.execute(); 115 | return; 116 | } 117 | 118 | EmbedObject embed = createEmbed(); 119 | Configuration embedFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-leave-format.embed"); 120 | embed.setColor(Color.decode(embedFormat.getString("color"))); 121 | embed.setDescription(join_leavePlaceholders(embedFormat.getString("description"), p)); 122 | embed.setTitle(join_leavePlaceholders(embedFormat.getString("title"), p)); 123 | embed.setThumbnail(embedFormat.getString("thumbnail")); 124 | embed.setImage(embedFormat.getString("image")); 125 | embed.setAuthor(embedFormat.getString("author.name"), embedFormat.getString("author.url"), embedFormat.getString("image")); 126 | embed.setUrl(embedFormat.getString("url")); 127 | for(String key : embedFormat.getSection("fields").getKeys()) { 128 | Configuration sec = UltraStaffChat.getConfig().getConfiguration().getSection("discord-leave-format.embed.fields." + key); 129 | embed.addField(join_leavePlaceholders(sec.getString("name"), p), join_leavePlaceholders(sec.getString("value"), p), sec.getBoolean("inline")); 130 | } 131 | hook.addEmbed(embed); 132 | hook.execute(); 133 | } catch (Exception e) { 134 | Common.log(e.toString()); 135 | } 136 | }); 137 | } 138 | 139 | public static void broadcastDiscordSwitch(ProxiedPlayer p, String from, String to) { 140 | if(!isEnabled() || !UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-switch-messages")) 141 | return; 142 | ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> { 143 | try { 144 | DiscordWebhook hook = getHook(); 145 | 146 | if(!UltraStaffChat.getConfig().getBoolean("discord-embed")) { 147 | Configuration textFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-switch-format"); 148 | hook.setContent(switchPlaceholders(textFormat.getString("text"), p, from, to)); 149 | try { 150 | hook.execute(); 151 | } catch (IOException e) { 152 | Common.log(e.toString()); 153 | } 154 | return; 155 | } 156 | 157 | EmbedObject embed = createEmbed(); 158 | Configuration embedFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-switch-format.embed"); 159 | embed.setColor(Color.decode(embedFormat.getString("color"))); 160 | embed.setDescription(switchPlaceholders(embedFormat.getString("description"), p, from, to)); 161 | embed.setTitle(switchPlaceholders(embedFormat.getString("title"), p, from, to)); 162 | embed.setThumbnail(embedFormat.getString("thumbnail")); 163 | embed.setImage(embedFormat.getString("image")); 164 | embed.setAuthor(embedFormat.getString("author.name"), embedFormat.getString("author.url"), embedFormat.getString("image")); 165 | embed.setUrl(embedFormat.getString("url")); 166 | for(String key : embedFormat.getSection("fields").getKeys()) { 167 | Configuration sec = UltraStaffChat.getConfig().getConfiguration().getSection("discord-switch-format.embed.fields." + key); 168 | embed.addField(switchPlaceholders(sec.getString("name"), p, from, to), switchPlaceholders(sec.getString("value"), p, from, to), sec.getBoolean("inline")); 169 | } 170 | hook.addEmbed(embed); 171 | hook.execute(); 172 | } catch (Exception e) { 173 | Common.log(e.toString()); 174 | } 175 | }); 176 | } 177 | 178 | public static void broadcastDiscordStaffChatMessage(CommandSender s, String message) { 179 | if(!isEnabled()) 180 | return; 181 | ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> { 182 | try { 183 | DiscordWebhook hook = getHook(); 184 | 185 | if(!UltraStaffChat.getConfig().getBoolean("discord-embed")) { 186 | Configuration textFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-format"); 187 | hook.setContent(messagePlaceholders(textFormat.getString("text"), s, message)); 188 | try { 189 | hook.execute(); 190 | } catch (IOException e) { 191 | Common.log(e.toString()); 192 | } 193 | return; 194 | } 195 | 196 | EmbedObject embed = createEmbed(); 197 | Configuration embedFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-format.embed"); 198 | embed.setColor(Color.decode(embedFormat.getString("color"))); 199 | embed.setDescription(messagePlaceholders(embedFormat.getString("description"), s, message)); 200 | embed.setTitle(messagePlaceholders(embedFormat.getString("title"), s, message)); 201 | embed.setThumbnail(embedFormat.getString("thumbnail")); 202 | embed.setImage(embedFormat.getString("image")); 203 | embed.setAuthor(embedFormat.getString("author.name"), embedFormat.getString("author.url"), embedFormat.getString("image")); 204 | embed.setUrl(embedFormat.getString("url")); 205 | for(String key : embedFormat.getSection("fields").getKeys()) { 206 | Configuration sec = UltraStaffChat.getConfig().getConfiguration().getSection("discord-format.embed.fields." + key); 207 | embed.addField(messagePlaceholders(sec.getString("name"), s, message), messagePlaceholders(sec.getString("value"), s, message), sec.getBoolean("inline")); 208 | } 209 | hook.addEmbed(embed); 210 | hook.execute(); 211 | } catch (Exception e) { 212 | Common.log(e.toString()); 213 | } 214 | }); 215 | } 216 | 217 | public static void broadcastDiscordAFKEnable(ProxiedPlayer p) { 218 | if(!isEnabled() || !UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-afk-enable-messages")) 219 | return; 220 | ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> { 221 | try { 222 | DiscordWebhook hook = getHook(); 223 | 224 | if(!UltraStaffChat.getConfig().getBoolean("discord-embed")) { 225 | Configuration textFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-afk-enable-format"); 226 | hook.setContent(afkPlaceholders(textFormat.getString("text"), p)); 227 | hook.execute(); 228 | return; 229 | } 230 | 231 | EmbedObject embed = createEmbed(); 232 | Configuration embedFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-afk-enable-format.embed"); 233 | embed.setColor(Color.decode(embedFormat.getString("color"))); 234 | embed.setDescription(afkPlaceholders(embedFormat.getString("description"), p)); 235 | embed.setTitle(afkPlaceholders(embedFormat.getString("title"), p)); 236 | embed.setThumbnail(embedFormat.getString("thumbnail")); 237 | embed.setImage(embedFormat.getString("image")); 238 | embed.setAuthor(embedFormat.getString("author.name"), embedFormat.getString("author.url"), embedFormat.getString("image")); 239 | embed.setUrl(embedFormat.getString("url")); 240 | for(String key : embedFormat.getSection("fields").getKeys()) { 241 | Configuration sec = UltraStaffChat.getConfig().getConfiguration().getSection("discord-afk-enable-format.embed.fields." + key); 242 | embed.addField(afkPlaceholders(sec.getString("name"), p), afkPlaceholders(sec.getString("value"), p), sec.getBoolean("inline")); 243 | } 244 | hook.addEmbed(embed); 245 | hook.execute(); 246 | } catch (Exception e) { 247 | Common.log(e.toString()); 248 | } 249 | }); 250 | } 251 | 252 | public static void broadcastDiscordAFKDisable(ProxiedPlayer p) { 253 | if(!isEnabled() || !UltraStaffChat.getConfig().getConfiguration().getBoolean("discord-afk-disable-messages")) 254 | return; 255 | ProxyServer.getInstance().getScheduler().runAsync(UltraStaffChat.getInstance(), () -> { 256 | try { 257 | DiscordWebhook hook = getHook(); 258 | 259 | if(!UltraStaffChat.getConfig().getBoolean("discord-embed")) { 260 | Configuration textFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-afk-disable-format"); 261 | hook.setContent(afkPlaceholders(textFormat.getString("text"), p)); 262 | hook.execute(); 263 | return; 264 | } 265 | 266 | EmbedObject embed = createEmbed(); 267 | Configuration embedFormat = UltraStaffChat.getConfig().getConfiguration().getSection("discord-afk-disable-format.embed"); 268 | embed.setColor(Color.decode(embedFormat.getString("color"))); 269 | embed.setDescription(afkPlaceholders(embedFormat.getString("description"), p)); 270 | embed.setTitle(afkPlaceholders(embedFormat.getString("title"), p)); 271 | embed.setThumbnail(embedFormat.getString("thumbnail")); 272 | embed.setImage(embedFormat.getString("image")); 273 | embed.setAuthor(embedFormat.getString("author.name"), embedFormat.getString("author.url"), embedFormat.getString("image")); 274 | embed.setUrl(embedFormat.getString("url")); 275 | for(String key : embedFormat.getSection("fields").getKeys()) { 276 | Configuration sec = UltraStaffChat.getConfig().getConfiguration().getSection("discord-afk-disable-format.embed.fields." + key); 277 | embed.addField(afkPlaceholders(sec.getString("name"), p), afkPlaceholders(sec.getString("value"), p), sec.getBoolean("inline")); 278 | } 279 | hook.addEmbed(embed); 280 | hook.execute(); 281 | } catch (Exception e) { 282 | Common.log(e.toString()); 283 | } 284 | }); 285 | } 286 | 287 | private static String messagePlaceholders(String string, CommandSender s, String m) { 288 | return escape(string.replaceAll("\\{message}", stripColor(m)).replaceAll("\\{player}", Common.getDisplayNameSafe(s)).replaceAll("\\{server}", Common.getServerSafe(s))); 289 | } 290 | 291 | private static String join_leavePlaceholders(String string, ProxiedPlayer p) { 292 | return escape(string.replaceAll("\\{player}", Common.getDisplayNameSafe(p)).replaceAll("\\{server}", Common.getServerSafe(p))); 293 | } 294 | 295 | private static String switchPlaceholders(String string, ProxiedPlayer p, String from, String to) { 296 | return escape(string.replaceAll("\\{player}", Common.getDisplayNameSafe(p)).replaceAll("\\{to}", to).replaceAll("\\{from}", from)); 297 | } 298 | 299 | private static String afkPlaceholders(String string, ProxiedPlayer p) { 300 | return escape(string.replaceAll("\\{player}", Common.getDisplayNameSafe(p))); 301 | } 302 | 303 | private static DiscordWebhook getHook() { 304 | DiscordWebhook hook = new DiscordWebhook(hookURL); 305 | hook.setAvatarUrl(UltraStaffChat.getConfig().getString("discord-image")); 306 | hook.setUsername(UltraStaffChat.getConfig().getString("discord-username")); 307 | return hook; 308 | } 309 | 310 | private static DiscordWebhook.EmbedObject createEmbed() { 311 | return new DiscordWebhook.EmbedObject().setFooter(footer, footerUrl); 312 | } 313 | 314 | private static String escape(String input) { 315 | return input.replaceAll("\"", "\\\\\""); 316 | } 317 | 318 | private static String stripColor(String input) { 319 | return input.replaceAll("(?i)[§&][0-9A-FK-ORX]", ""); 320 | } 321 | 322 | } 323 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------