This commit is contained in:
Brandon 2023-05-03 15:21:03 +01:00
commit 37f08be28b
258 changed files with 15932 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Project exclude paths
/target/

104
Bridge.iml Normal file
View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>BUNGEECORD</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="McpModuleSettings">
<option name="srgType" value="SRG" />
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
<orderEntry type="library" name="Maven: com.google.auth:google-auth-library-oauth2-http:0.25.3" level="project" />
<orderEntry type="library" name="Maven: com.google.auto.value:auto-value-annotations:1.8" level="project" />
<orderEntry type="library" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
<orderEntry type="library" name="Maven: com.google.auth:google-auth-library-credentials:0.25.3" level="project" />
<orderEntry type="library" name="Maven: com.google.http-client:google-http-client:1.39.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.14" level="project" />
<orderEntry type="library" name="Maven: com.google.j2objc:j2objc-annotations:1.3" level="project" />
<orderEntry type="library" name="Maven: io.opencensus:opencensus-api:0.28.0" level="project" />
<orderEntry type="library" name="Maven: io.grpc:grpc-context:1.27.2" level="project" />
<orderEntry type="library" name="Maven: io.opencensus:opencensus-contrib-http-util:0.28.0" level="project" />
<orderEntry type="library" name="Maven: com.google.http-client:google-http-client-gson:1.39.2" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:guava:30.1.1-android" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:failureaccess:1.0.1" level="project" />
<orderEntry type="library" name="Maven: com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava" level="project" />
<orderEntry type="library" name="Maven: org.checkerframework:checker-compat-qual:2.5.5" level="project" />
<orderEntry type="library" name="Maven: com.google.errorprone:error_prone_annotations:2.5.1" level="project" />
<orderEntry type="module-library">
<library name="Maven: net.md_5.bungee:bungee:1.7.10-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/BungeeCord.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module" module-name="mspigot-server" scope="PROVIDED" />
<orderEntry type="module" module-name="mspigot-api" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.8-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:minecraft-server:1.7.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.jopt-simple:jopt-simple:3.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: jline:jline:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.fusesource.jansi:jansi:1.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.jafama:jafama:2.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.xerial:sqlite-jdbc:3.7.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: mysql:mysql-connector-java:5.1.14" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: io.netty:netty-all:4.0.10.Final" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:7.2.1" level="project" />
<orderEntry type="module" module-name="qLib" scope="PROVIDED" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.reflections:reflections:0.9.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.javassist:javassist:3.19.0-GA" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: mkremins:fanciful:0.4.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: javax.mail:mail:1.4" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
<orderEntry type="library" name="Maven: commons-validator:commons-validator:1.7" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.4" level="project" />
<orderEntry type="library" name="Maven: commons-digester:commons-digester:2.1" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" />
<orderEntry type="library" name="Maven: redis.clients:jedis:2.10.2" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.22" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.3" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.10.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.16" level="project" />
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.10" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="module-library">
<library name="Maven: com.comphenix.protocol:ProtocolLib-v1_7_R4:3.7.0-BETA">
<CLASSES>
<root url="jar://$MODULE_DIR$/../qLib/lib/ProtocolLib-v1_7_R4-3.7.0-BETA.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.1" level="project" />
<orderEntry type="library" name="Maven: com.warrenstrange:googleauth:1.4.0" level="project" />
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.3" level="project" />
</component>
</module>

18
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,18 @@
node {
stage('Clone') {
checkout scm
}
stage('Build') {
sh "mvn clean install -U"
}
stage('Archive') {
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
}
stage('Uploading to Nexus') {
pom = readMavenPom file: 'pom.xml'
nexusPublisher nexusInstanceId: 'prnex', nexusRepositoryId: 'bridge', packages: [[$class: 'MavenPackage', mavenAssetList: [[classifier: '', extension: 'jar', filePath: "target/${pom.name}.jar"]], mavenCoordinate: [artifactId: pom.artifactId, groupId: 'rip.bridge', packaging: 'jar', version: pom.version]]]
}
}

1
README.md Normal file
View File

@ -0,0 +1 @@
"# Bridge"

160
dependency-reduced-pom.xml Normal file
View File

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rip.bridge</groupId>
<artifactId>Bridge</artifactId>
<name>Bridge</name>
<version>1.0</version>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>plugin.yml</exclude>
</excludes>
</resource>
</resources>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>scriptus</artifactId>
<version>0.2</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>describe</goal>
</goals>
<configuration>
<format>%s</format>
<descriptionProperty>bridge.desc</descriptionProperty>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>lunarclient-public</id>
<url>https://maven.moonsworth.com/repository/lunarclient-public/</url>
</repository>
<repository>
<id>zeroturnaround-repo</id>
<url>https://repos.zeroturnaround.com/nexus/content/repositories/zt-public-releases/</url>
</repository>
<repository>
<id>depends</id>
<url>redacted</url>
</repository>
<repository>
<id>bridge</id>
<url>redacted</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>rip.bridge</groupId>
<artifactId>mspigot-server</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>rip.bridge</groupId>
<artifactId>qLib</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md_5.bungee</groupId>
<artifactId>bungee</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/BungeeCord.jar</systemPath>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib-v1_7_R4</artifactId>
<version>3.7.0-BETA</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ProtocolLib-v1_7_R4-3.7.0-BETA.jar</systemPath>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

257
pom.xml Normal file
View File

@ -0,0 +1,257 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rip.bridge</groupId>
<artifactId>Bridge</artifactId>
<name>Bridge</name>
<version>${git.commit.id.abbrev}</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>${project.name}</finalName>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<pluginRepositories>
<pluginRepository>
<id>sonatype-snapshots</id>
<name>Sonatype Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>lunarclient-public</id>
<url>https://maven.moonsworth.com/repository/lunarclient-public/</url>
</repository>
<repository>
<id>zeroturnaround-repo</id>
<url>https://repos.zeroturnaround.com/nexus/content/repositories/zt-public-releases/</url>
</repository>
<repository>
<id>depends</id>
<url>redacted</url>
<layout>default</layout>
</repository>
<repository>
<id>bridge</id>
<url>redacted</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.auth</groupId>
<artifactId>google-auth-library-oauth2-http</artifactId>
<version>0.25.3</version>
</dependency>
<!-- Bungee Jars -->
<dependency>
<groupId>net.md_5.bungee</groupId>
<artifactId>bungee</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/BungeeCord.jar</systemPath>
</dependency>
<!-- Spigot Jars -->
<dependency>
<groupId>rip.bridge</groupId>
<artifactId>mspigot-server</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- Misc. Jars -->
<dependency>
<groupId>rip.bridge</groupId>
<artifactId>qLib</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.10.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.10.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib-v1_7_R4</artifactId>
<version>3.7.0-BETA</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ProtocolLib-v1_7_R4-3.7.0-BETA.jar</systemPath>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.warrenstrange</groupId>
<artifactId>googleauth</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,327 @@
package rip.bridge.bridge;
import com.google.common.collect.Lists;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.bukkit.listener.GeneralListener;
import rip.bridge.bridge.bungee.BridgeBungee;
import rip.bridge.bridge.bungee.listener.GeneralBungeeListener;
import rip.bridge.bridge.global.disguise.DisguiseManager;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.handlers.PrefixHandler;
import rip.bridge.bridge.global.status.BridgeServer;
import rip.bridge.bridge.global.status.ServerHandler;
import rip.bridge.bridge.global.status.threads.StatusUpdateThread;
import rip.bridge.bridge.global.updater.UpdaterManager;
import rip.bridge.bridge.global.util.SystemType;
import lombok.Getter;
import lombok.Setter;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import rip.bridge.bridge.global.handlers.*;
import java.util.*;
public class BridgeGlobal {
@Getter @Setter public static SystemType systemType = SystemType.UNKNOWN;
@Getter private static boolean mongoAuth, redisAuth, allowBannedJoins;
@Getter private static int mongoPort, redisPort, redisDB;
@Getter private static String mongoHost, mongoUsername, mongoPassword, mongoDatabase, redisHost, redisPassword, redisChannel, screenName, screenPath, serverName, serverDisplayName, serverWebsite, pluginUpdateDir ="%user_home%/Bridge/updater", groupName = "N/A";
private static List<String> updaterGroups;
private static String serverDeploymentDir;
private static String serverTemplateDir;
private static boolean handleServerDeployment;
@Getter private static long startTime = -1L;
@Getter private static MongoHandler mongoHandler;
@Getter private static RankHandler rankHandler;
@Getter private static PacketLogHandler packetLogHandler;
@Getter private static PrefixHandler prefixHandler;
@Getter private static ProfileHandler profileHandler;
@Getter private static UpdaterManager updaterManager;
@Getter private static FilterHandler filterHandler;
@Getter private static ServerHandler serverHandler;
@Getter private static JedisPool jedisPool;
@Getter private static JsonParser parser = new JsonParser();
@Getter private static DisguiseManager disguiseManager;
@Getter @Setter private static boolean shutdown;
public BridgeGlobal() {
this("", "", "", "", 27017, false, "", "", "", 0, 6379, false, true);
}
public BridgeGlobal(String mongoHost, String mongoUsername, String mongoPassword, String mongoDatabase, int mongoPort, boolean mongoAuth, String redisHost, String redisPassword, String redisChannelKek, int redisDB, int redisPort, boolean redisAuth, boolean getFromConfig) {
this(mongoHost, mongoUsername, mongoPassword, mongoDatabase, mongoPort, mongoAuth, redisHost, redisPassword, redisChannelKek, redisDB, redisPort, redisAuth, getFromConfig, null);
}
public BridgeGlobal(String mongoHost, String mongoUsername, String mongoPassword, String mongoDatabase, int mongoPort, boolean mongoAuth, String redisHost, String redisPassword, String redisChannelKek, int redisDB, int redisPort, boolean redisAuth, boolean getFromConfig, String customServerName) {
setSystemType(currentSystemType());
sendLog("We have detected that Bridge is running on System Type: " + getSystemType().name());
if (customServerName != null)
serverName = customServerName;
if(getFromConfig) {
setupConfigValues();
}else {
BridgeGlobal.mongoAuth = mongoAuth;
BridgeGlobal.mongoPort = mongoPort;
BridgeGlobal.mongoHost = mongoHost;
BridgeGlobal.mongoUsername = mongoUsername;
BridgeGlobal.mongoPassword = mongoPassword;
BridgeGlobal.mongoDatabase = mongoDatabase;
BridgeGlobal.redisAuth = redisAuth;
BridgeGlobal.redisHost = redisHost;
BridgeGlobal.redisPort = redisPort;
BridgeGlobal.redisPassword = redisPassword;
BridgeGlobal.redisChannel = redisChannelKek;
BridgeGlobal.redisDB = redisDB;
}
sendLog("Loading Mongo backend...");
mongoHandler = new MongoHandler();
sendLog("Loading Ranks");
rankHandler = new RankHandler();
rankHandler.init();
profileHandler = new ProfileHandler();
profileHandler.init();
sendLog("Successfully loaded the Profile Handler");
prefixHandler = new PrefixHandler();
prefixHandler.init();
sendLog("Successfully loaded the Prefix Handler");
packetLogHandler = new PacketLogHandler();
sendLog("Successfully loaded the PacketLog Handler");
filterHandler = new FilterHandler();
filterHandler.init();
sendLog("Successfully loaded the Filter Handler");
jedisPool = new JedisPool(new JedisPoolConfig(), BridgeGlobal.getRedisHost(), BridgeGlobal.getRedisPort(), 0, (BridgeGlobal.isRedisAuth() ? BridgeGlobal.getRedisPassword() : null), BridgeGlobal.getRedisDB());
PacketHandler.init(jedisPool, redisChannel);
// sendLog("Setting up status handler");
// StatusHandler.init();
serverHandler = new ServerHandler();
serverHandler.init();
sendLog("Successfully setup the Server Handler");
if(pluginUpdateDir != null && !pluginUpdateDir.isEmpty()) {
sendLog("Setting up the update handler");
updaterManager = new UpdaterManager();
}
startTime = System.currentTimeMillis();
sendLog("Completed Bridge Backend - loaded " + getSystemType() + " system type.");
}
public static void loadDisguise(boolean bungee) {
disguiseManager = new DisguiseManager(bungee);
sendLog("Successfully loaded the Disguise Handler");
}
private void setupConfigValues() {
mongoAuth = Boolean.parseBoolean(getFromConfig("mongo.auth.enabled"));
mongoPort = Integer.parseInt(getFromConfig("mongo.port"));
mongoHost = getFromConfig("mongo.host");
mongoUsername = getFromConfig("mongo.auth.username");
mongoPassword = getFromConfig("mongo.auth.password");
mongoDatabase = getFromConfig("mongo.database");
redisAuth = !getFromConfig("redis.password").equals("");
redisHost = getFromConfig("redis.host");
redisPort = Integer.parseInt(getFromConfig("redis.port"));
redisPassword = getFromConfig("redis.password");
redisChannel = getFromConfig("redis.channel");
redisDB = Integer.parseInt(getFromConfig("redis.db"));
screenName = getFromConfig("screenName");
screenPath = getFromConfig("screenPath");
serverName = getFromConfig("serverName");
allowBannedJoins = Boolean.parseBoolean(getFromConfig("AllowBannedJoins"));
serverDisplayName = getFromConfig("serverDisplayName");
serverWebsite = getFromConfig("serverWebsite");
pluginUpdateDir = getFromConfig("pluginUpdateDirectory");
groupName = getFromConfig("serverGroup");
handleServerDeployment = Boolean.parseBoolean(BridgeGlobal.getFromConfig("handleServerDeployment"));
serverDeploymentDir = BridgeGlobal.getFromConfig("serverDeploymentDirectory");
serverTemplateDir = BridgeGlobal.getFromConfig("serverTemplateDirectory");
if(getSystemType() == SystemType.BUKKIT) updaterGroups = Bridge.getInstance().getConfig().getStringList("updaterGroups");
}
public static void shutdown() {
shutdown = true;
StatusUpdateThread.saveShutdown();
getProfileHandler().saveDisable();
getRankHandler().saveDisable();
getMongoHandler().getMongoClient().close();
getJedisPool().close();
}
private static SystemType currentSystemType() {
try {
Class.forName("net.md_5.bungee.BungeeCord");
return SystemType.BUNGEE;
} catch (ClassNotFoundException ignored) {}
try {
Class.forName("org.bukkit.Bukkit");
return SystemType.BUKKIT;
} catch (ClassNotFoundException ignored) {}
return SystemType.UNKNOWN;
}
public static String getSystemName() {
switch (getSystemType()) {
case BUNGEE:
case BUKKIT: {
return serverName;
}
default: {
if (serverName != null && !serverName.isEmpty())
return serverName;
return "Custom Java Applet";
}
}
}
public static void sendLog(String msg, boolean packetIncoming) {
String logMessage = "%prefix% §r" + msg;
switch (systemType) {
case BUNGEE:
GeneralBungeeListener.logMessages(msg.replace("%prefix%", "[Bridge]"));
return;
case BUKKIT:
GeneralListener.logMessages(msg.replace("%prefix%", "[Bridge]"), packetIncoming);
return;
default:
System.out.println(logMessage.replace("%prefix%", "[Bridge]").replace("§", ""));
}
}
public static void sendLog(String msg) {
sendLog(msg, false);
}
public static String getFromConfig(String path) {
switch(systemType) {
case BUNGEE: {
return BridgeBungee.getConfig().getString(path);
}
case UNKNOWN: {
return null;
}
case BUKKIT: {
return Bridge.getInstance().getConfig().getString(path);
}
}
return null;
}
public static List<String> getUpdaterGroups() {
if(getSystemType() != SystemType.BUKKIT) return null;
List<String> list = new ArrayList<>(Collections.singletonList(getGroupName()));
if(!updaterGroups.isEmpty()) list.addAll(updaterGroups);
return list;
}
public static boolean isHandleServerDeployment() {
return handleServerDeployment;
}
public static void setHandleServerDeployment(boolean handleServerDeployment) {
BridgeGlobal.handleServerDeployment = handleServerDeployment;
}
public static String getServerDeploymentDir() {
return serverDeploymentDir.replace("%user_home%", System.getProperty("user.home"));
}
public static void setServerDeploymentDir(String serverDeploymentDir) {
BridgeGlobal.serverDeploymentDir = serverDeploymentDir;
}
public static String getServerTemplateDir() {
return serverTemplateDir.replace("%user_home%", System.getProperty("user.home"));
}
public static void setServerTemplateDir(String serverTemplateDir) {
BridgeGlobal.serverTemplateDir = serverTemplateDir;
}
public static void addUpdaterGroup(String group) {
updaterGroups.add(group);
}
public static void removeUpdaterGroup(String group) {
updaterGroups.remove(group);
}
public static void savePlayerData(String key, UUID uuid, JsonObject data) {
try (Jedis jedis = jedisPool.getResource()) {
jedis.hset(key, uuid.toString(), data.toString());
}
}
public static void deletePlayerData(String key, UUID uuid) {
try (Jedis jedis = jedisPool.getResource()) {
jedis.hdel(key, uuid.toString());
}
}
public static JsonObject getPlayerData(UUID uuid, String key) {
try (Jedis jedis = jedisPool.getResource()) {
String data = jedis.hget(key, uuid.toString());
if(data == null) {
return null;
}
try {
JsonObject object = parser.parse(data).getAsJsonObject();
if(object.has("data")) {
return object.get("data").getAsJsonObject();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
public static List<String> getUsedDisguisedNames() {
try (Jedis jedis = jedisPool.getResource()) {
Map<String, String> data = jedis.hgetAll("disguise");
if(data == null) {
return null;
}
List<String> names = Lists.newArrayList();
for(String dataStructure : data.values()) {
JsonObject object = parser.parse(dataStructure).getAsJsonObject();
if(object.has("data")) {
JsonObject values = object.get("data").getAsJsonObject();
if(values.has("disguiseName")) {
names.add(values.get("disguiseName").getAsString());
}
}
}
return names;
}
}
}

View File

@ -0,0 +1,65 @@
package rip.bridge.bridge.bukkit;
import lombok.Setter;
import net.minecraft.server.v1_7_R4.Packet;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.listener.BridgeListener;
import rip.bridge.bridge.bukkit.listener.FreezeListener;
import rip.bridge.bridge.bukkit.parameters.*;
import rip.bridge.bridge.bukkit.parameters.param.filter.FilterActionParameter;
import rip.bridge.bridge.bukkit.parameters.param.filter.FilterParameter;
import rip.bridge.bridge.bukkit.parameters.param.filter.FilterTypeParameter;
import rip.bridge.bridge.bukkit.util.BukkitUtils;
import rip.bridge.bridge.global.disguise.DisguiseProfile;
import rip.bridge.bridge.global.filter.Filter;
import rip.bridge.bridge.global.filter.FilterAction;
import rip.bridge.bridge.global.filter.FilterType;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import rip.bridge.qlib.command.FrozenCommandHandler;
import rip.bridge.qlib.nametag.FrozenNametagHandler;
import java.util.ArrayList;
public class Bridge extends JavaPlugin {
@Getter private static Bridge instance;
@Getter private boolean isBooted = false;
@Getter private ArrayList<Packet> blockedPackets = new ArrayList<>();
@Getter @Setter public boolean togglePacketLogger = false;
@Override
public void onLoad() {
(instance = this).saveDefaultConfig();
new BridgeGlobal();
BridgeGlobal.getServerHandler().registerProvider(new BukkitStatusImplementer());
}
@Override
public void onEnable() {
FrozenCommandHandler.registerAll(this);
FrozenCommandHandler.registerParameterType(Rank.class, new RankParamater());
FrozenCommandHandler.registerParameterType(DisguiseProfile.class, new DisguiseParameter());
FrozenCommandHandler.registerParameterType(Profile.class, new ProfileParamater());
FrozenCommandHandler.registerParameterType(Plugin.class, new PluginParameter());
FrozenCommandHandler.registerParameterType(FilterAction.class, new FilterActionParameter());
FrozenCommandHandler.registerParameterType(FilterType.class, new FilterTypeParameter());
FrozenCommandHandler.registerParameterType(Filter.class, new FilterParameter());
FrozenNametagHandler.registerProvider(new BridgeNameTagProvider());
BukkitUtils.registerListeners(BridgeListener.class);
BukkitUtils.registerListeners(FreezeListener.class);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> isBooted = true);
BridgeGlobal.loadDisguise(false);
}
@Override
public void onDisable() {
BridgeGlobal.shutdown();
}
}

View File

@ -0,0 +1,488 @@
package rip.bridge.bridge.bukkit;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.bridge.global.util.MojangUtils;
import net.minecraft.server.v1_7_R4.Packet;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.Warning;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.UUID;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class BukkitAPI {
private static Pattern uuidPattern = Pattern.compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");
public static String LINE = ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "---------------------------------------------";
public static String RED_LINE = ChatColor.RED.toString() + ChatColor.STRIKETHROUGH + "---------------------------------------------";
public static String BLUE_LINE = ChatColor.BLUE.toString() + ChatColor.STRIKETHROUGH + "---------------------------------------------";
private static final UUID ZERO_UUID = new UUID(0, 0);
public static boolean isUUID(String string) {
return uuidPattern.matcher(string).find();
}
public static Player getPlayer(String string) {
if (string == null) {
return null;
} else {
return isUUID(string) ? Bukkit.getPlayer(UUID.fromString(string)) : Bukkit.getPlayer(string);
}
}
public static Rank getRank(String name) {
return BridgeGlobal.getRankHandler().getRankByName(name);
}
public static Rank getRank(UUID uuid) {
return BridgeGlobal.getRankHandler().getRankByID(uuid);
}
public static Rank createRank(String name) {
if(BridgeGlobal.getRankHandler().getRankByName(name) != null) {
return null;
}
Rank r = new Rank(UUID.randomUUID(), name, false);
r.saveRank();
BridgeGlobal.getRankHandler().addRank(r);
return r;
}
public static Profile getProfile(UUID uuid) {
if(uuid == null) return Profile.getConsoleProfile();
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(uuid);
}
public static Profile getProfile(CommandSender sender) {
return (sender instanceof Player ? BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(((Player)sender).getUniqueId()) : Profile.getConsoleProfile());
}
public static Profile getProfile(Player player) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(player.getUniqueId());
}
public static Profile getProfile(OfflinePlayer offlinePlayer) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(offlinePlayer.getUniqueId());
}
public static Profile getProfile(String name) {
Profile disguisedProfile = BridgeGlobal.getProfileHandler().getProfiles().stream().filter(profile -> profile.getDisguise() != null && profile.getDisguise().getDisguiseName().equalsIgnoreCase(name)).findAny().orElse(null);
if(disguisedProfile != null) return disguisedProfile;
return BridgeGlobal.getProfileHandler().getProfileByUsernameOrCreate(name);
}
public static Profile getProfileNotCreate(UUID uuid) {
return BridgeGlobal.getProfileHandler().getProfileByUUID(uuid);
}
public static Profile getProfileNotCreate(Player player) {
return getProfileNotCreate(player.getUniqueId());
}
public static Profile getProfileNotCreate(OfflinePlayer player) {
return getProfileNotCreate(player.getUniqueId());
}
@Warning(reason = "This requires to be ran on a seperate thread, otherwise there will be lag on the main server thread.")
public static Profile getProfileOrCreateNew(UUID uuid) {
String name;
try {
name = MojangUtils.fetchName(uuid);
}catch(Exception e) {
return null;
}
return BridgeGlobal.getProfileHandler().getNewProfileOrCreate(name, uuid);
}
public static Profile getProfileOrCreateNew(String username, UUID uuid) {
return BridgeGlobal.getProfileHandler().getNewProfileOrCreate(username, uuid);
}
public static List<Profile> getOnlineProfiles() {
return Bukkit.getOnlinePlayers().stream().filter(player -> getProfile(player) != null).map(BukkitAPI::getProfile).collect(Collectors.toList());
}
public static Rank getDefaultRank() {
return BridgeGlobal.getRankHandler().getDefaultRank();
}
public static Rank getPlayerRank(CommandSender player, boolean ignoreDisguise) {
if(!(player instanceof Player)) {
return getRank("Owner");
}
if(getProfile(player) == null) {
return getDefaultRank();
}
if(ignoreDisguise) {
return getPlayerRank(((Player)player), true);
}else {
if(getProfile(player).getDisguisedRank() != null) {
return getProfile(player).getDisguisedRank();
}
}
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(((Player)player).getUniqueId()).getCurrentGrant().getRank();
}
public static Rank getPlayerRank(CommandSender player) {
return getPlayerRank(player, false);
}
public static Rank getPlayerRank(Player player) {
if(getProfile(player) == null) {
return getDefaultRank();
}
if(getProfile(player).getDisguisedRank() != null) {
return getProfile(player).getDisguisedRank();
}
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(player.getUniqueId()).getCurrentGrant().getRank();
}
public static Rank getPlayerRank(UUID uuid) {
if(getProfile(uuid) == null) {
return getDefaultRank();
}
if(getProfile(uuid).getDisguisedRank() != null) {
return getProfile(uuid).getDisguisedRank();
}
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(uuid).getCurrentGrant().getRank();
}
public static Rank getPlayerRank(OfflinePlayer offlinePlayer) {
if(getProfile(offlinePlayer) == null) {
return getDefaultRank();
}
if(getProfile(offlinePlayer).getDisguisedRank() != null) {
return getProfile(offlinePlayer).getDisguisedRank();
}
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(offlinePlayer.getUniqueId()).getCurrentGrant().getRank();
}
public static Rank getPlayerRank(Profile profile) {
if(profile == null) {
return getDefaultRank();
}
if(profile.getUuid().toString().equals(Profile.getConsoleProfile().getUuid().toString())) {
return getRank("Default");
}
if(profile.getDisguisedRank() != null) {
return profile.getDisguisedRank();
}
return profile.getCurrentGrant().getRank();
}
public boolean canPunish(CommandSender sender, Profile target) {
if(!(sender instanceof Player)) return true;
return (getPlayerRank(sender).isStaff() && getPlayerRank(target).isStaff()) && getPlayerRank(sender).getPriority() > getPlayerRank(target).getPriority();
}
@Deprecated
public static boolean canOverride(CommandSender sender, Profile on) {
return canOverride(getProfile(sender), on);
}
public static boolean canOverride(Profile sender, Profile on) {
if (compareUUID(sender.getUuid(), ZERO_UUID)) // Always allow to override console
return true;
if (compareUUID(sender.getUuid(), on.getUuid())) // Always allow to override own punishments
return true;
return getRankPriority(sender) >= getRankPriority(on);
}
public static boolean compareUUID(UUID first, UUID second) {
return first.getLeastSignificantBits() == second.getLeastSignificantBits() && first.getMostSignificantBits() == second.getMostSignificantBits();
}
public static int getRankPriority(Profile profile) {
if (profile == null)
return 0;
Rank rank = getPlayerRank(profile, true);
if (rank == null)
return 0;
return rank.getPriority();
}
public static Rank getPlayerRank(Player player, boolean ignoreDisguise) {
if(getProfile(player) == null) {
return getDefaultRank();
}
if(ignoreDisguise) return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(player.getUniqueId()).getCurrentGrant().getRank();
else if(getProfile(player).getDisguisedRank() != null) {
return getProfile(player).getDisguisedRank();
}
return null;
}
public static Rank getPlayerRank(UUID uuid, boolean ignoreDisguise) {
if(ignoreDisguise) return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(uuid).getCurrentGrant().getRank();
else if(getProfile(uuid).getDisguisedRank() != null) {
return getProfile(uuid).getDisguisedRank();
}
return null;
}
public static Rank getPlayerRank(OfflinePlayer offlinePlayer, boolean ignoreDisguise) {
if(getProfile(offlinePlayer) == null) {
return getDefaultRank();
}
if(ignoreDisguise) return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(offlinePlayer.getUniqueId()).getCurrentGrant().getRank();
else if(getProfile(offlinePlayer).getDisguisedRank() != null) {
return getProfile(offlinePlayer).getDisguisedRank();
}
return null;
}
public static Rank getPlayerRank(Profile profile, boolean ignoreDisguise) {
if(profile == null) {
return getDefaultRank();
}
if (profile.getUuid().getLeastSignificantBits() == 0 && profile.getUuid().getMostSignificantBits() == 0)
return null;
if(ignoreDisguise) return profile.getCurrentGrant().getRank();
else if(profile.getDisguisedRank() != null) {
return profile.getDisguisedRank();
}
return null;
}
public static String getColor(CommandSender sender) {
if(getProfile(sender) == null) {
return getDefaultRank().getColor();
}
if(!getProfile(sender).getColor().equals("")) {
return getProfile(sender).getColor();
}else {
return getPlayerRank(sender).getColor();
}
}
public static String getColor(Player player) {
if(getProfile(player) == null) {
return getDefaultRank().getColor();
}
if(!getProfile(player).getColor().equals("")) {
return getProfile(player).getColor();
}else {
return getPlayerRank(player).getColor();
}
}
public static String getColor(OfflinePlayer player) {
if(getProfile(player) == null) {
return getDefaultRank().getColor();
}
if(!getProfile(player).getColor().equals("")) {
return getProfile(player).getColor();
}else {
return getPlayerRank(player).getColor();
}
}
public static String getColor(UUID player) {
if(!getProfile(player).getColor().equals("")) {
return getProfile(player).getColor();
}else {
return getPlayerRank(player).getColor();
}
}
public static String getColor(Profile profile) {
if(!profile.getColor().equals("")) {
return profile.getColor();
}else {
return getPlayerRank(profile).getColor();
}
}
public static String getPrefix(Player player) {
if(getProfile(player) == null) {
return getDefaultRank().getPrefix();
}
if(!getProfile(player).getPrefix().equals("")) {
return getProfile(player).getPrefix();
}else {
return getPlayerRank(player).getPrefix();
}
}
public static String getPrefix(OfflinePlayer player) {
if(getProfile(player) == null) {
return getDefaultRank().getPrefix();
}
if(!getProfile(player).getPrefix().equals("")) {
return getProfile(player).getPrefix();
}else {
return getPlayerRank(player).getPrefix();
}
}
public static String getPrefix(UUID player) {
if(getProfile(player) == null) {
return getDefaultRank().getPrefix();
}
if(!getProfile(player).getPrefix().equals("")) {
return getProfile(player).getPrefix();
}else {
return getPlayerRank(player).getPrefix();
}
}
public static String getPrefix(Profile profile) {
if(profile == null) {
return getDefaultRank().getPrefix();
}
if(!profile.getPrefix().equals("")) {
return profile.getPrefix();
}else {
return getPlayerRank(profile).getPrefix();
}
}
public static String getSuffix(Player player) {
if(getProfile(player) == null) {
return getDefaultRank().getSuffix();
}
if(!getProfile(player).getSuffix().equals("")) {
return getProfile(player).getSuffix();
}else {
return getPlayerRank(player).getSuffix();
}
}
public static String getSuffix(OfflinePlayer player) {
if(getProfile(player) == null) {
return getDefaultRank().getSuffix();
}
if(!getProfile(player).getSuffix().equals("")) {
return getProfile(player).getSuffix();
}else {
return getPlayerRank(player).getSuffix();
}
}
public static String getSuffix(UUID player) {
if(getProfile(player) == null) {
return getDefaultRank().getSuffix();
}
if(!getProfile(player).getSuffix().equals("")) {
return getProfile(player).getSuffix();
}else {
return getPlayerRank(player).getSuffix();
}
}
public static String getSuffix(Profile profile) {
if(profile == null) {
return getDefaultRank().getSuffix();
}
if(!profile.getSuffix().equals("")) {
return profile.getSuffix();
}else {
return getPlayerRank(profile).getSuffix();
}
}
public static String getName(Profile profile, boolean ignoreDisguise) {
return (ignoreDisguise || profile.getDisguise() == null) ? profile.getUsername() : profile.getDisguise().getDisguiseName();
}
public static String getRealName(Profile profile) {
return profile.getDisguise() == null ? profile.getUsername() : profile.getDisguise().getName();
}
public static String getRealName(UUID uuid) {
return getRealName(getProfile(uuid));
}
public static String getRealName(Player player) {
return getRealName(getProfile(player));
}
public static void sendPacket(Player player, Packet packet){
CraftPlayer cp = (CraftPlayer) player;
cp.getHandle().playerConnection.sendPacket(packet);
}
public static List<Grant> getActiveGrants(Player player) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(player.getUniqueId()).getActiveGrants();
}
public static List<Grant> getActiveGrants(UUID uuid) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(uuid).getActiveGrants();
}
public static List<Grant> getActiveGrants(OfflinePlayer offlinePlayer) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(offlinePlayer.getUniqueId()).getActiveGrants();
}
public static List<Grant> getActiveGrants(Profile profile) {
return profile.getActiveGrants();
}
public static List<Grant> getCurrentScopeRanks(Player player) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(player.getUniqueId()).getActiveGrants().stream().filter(Grant::isGrantActiveOnScope).collect(Collectors.toList());
}
public static List<Grant> getCurrentScopeRanks(UUID uuid) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(uuid).getActiveGrants().stream().filter(Grant::isGrantActiveOnScope).collect(Collectors.toList());
}
public static List<Grant> getCurrentScopeRanks(OfflinePlayer offlinePlayer) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(offlinePlayer.getUniqueId()).getActiveGrants().stream().filter(Grant::isGrantActiveOnScope).collect(Collectors.toList());
}
public static List<Grant> getAllGrants(Player player) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(player.getUniqueId()).getGrants();
}
public static List<Grant> getAllGrants(UUID uuid) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(uuid).getGrants();
}
public static List<Grant> getAllGrants(OfflinePlayer offlinePlayer) {
return BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(offlinePlayer.getUniqueId()).getGrants();
}
public static void sendToStaff(String message) {
BridgeGlobal.sendLog(message);
Bukkit.getOnlinePlayers().stream().filter(p -> getPlayerRank(p, true).isStaff()).forEach(p -> {
((Player) p).sendMessage(ChatColor.translateAlternateColorCodes('&', message));
});
}
public static void sendToStaff(List<String> message) {
message.forEach(BridgeGlobal::sendLog);
Bukkit.getOnlinePlayers().stream().filter(p -> getPlayerRank(p, true).isStaff()).forEach(p -> {
message.forEach(string -> {
((Player) p).sendMessage(ChatColor.translateAlternateColorCodes('&', string));
});
});
}
}

View File

@ -0,0 +1,22 @@
package rip.bridge.bridge.bukkit.auth;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapView;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import java.awt.image.BufferedImage;
public class TotpMapCreator {
public ItemStack createMap(Player player, BufferedImage bufferedImage) {
MapView mapView = Bridge.getInstance().getServer().createMap(player.getWorld());
mapView.getRenderers().forEach(mapView::removeRenderer);
mapView.addRenderer(new TotpMapRenderer(player.getUniqueId(), bufferedImage));
player.sendMap(mapView);
return new ItemStack(Material.MAP, 0, mapView.getId());
}
}

View File

@ -0,0 +1,29 @@
package rip.bridge.bridge.bukkit.auth;
import org.bukkit.entity.Player;
import org.bukkit.map.MapCanvas;
import org.bukkit.map.MapRenderer;
import org.bukkit.map.MapView;
import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.UUID;
public class TotpMapRenderer extends MapRenderer {
private final UUID targetPlayer;
private BufferedImage image;
public TotpMapRenderer(UUID targetPlayer, BufferedImage image) {
this.targetPlayer = targetPlayer;
this.image = image;
}
public void render(MapView mapView, MapCanvas mapCanvas, Player player) {
if(player.getUniqueId().equals(this.targetPlayer)) {
mapCanvas.drawImage(0, 0, this.image);
this.image = null;
}
}
}

View File

@ -0,0 +1,26 @@
package rip.bridge.bridge.bukkit.auth.prompt;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
public class InitialDisclaimerPrompt extends StringPrompt {
public String getPromptText(ConversationContext context) {
return ChatColor.RED.toString() + ChatColor.BOLD + "Take a minute to read over this, it's important. "
+ ChatColor.RED + "2FA can be enabled to protect against hackers getting into your Minecraft account. " +
"If you enable 2FA, you'll be required to enter a code every time you log in. If you lose your 2FA device, you wont be able to log into the Bridge Network."
+ ChatColor.GRAY + " If you have read the above and would like to proceed, type \"yes\" in the chat. Otherwise, type anything else.";
}
public Prompt acceptInput(ConversationContext context, String s) {
if(s.equalsIgnoreCase("yes")) {
return new ScanMapPrompt();
} else {
context.getForWhom().sendRawMessage(ChatColor.GREEN + "Aborted 2FA setup.");
return Prompt.END_OF_CONVERSATION;
}
}
}

View File

@ -0,0 +1,124 @@
package rip.bridge.bridge.bukkit.auth.prompt;
import com.google.common.escape.Escaper;
import com.google.common.net.UrlEscapers;
import com.warrenstrange.googleauth.GoogleAuthenticator;
import net.minecraft.util.org.apache.commons.codec.binary.Base32;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.conversations.ConversationContext;
import org.bukkit.conversations.Prompt;
import org.bukkit.conversations.StringPrompt;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.bukkit.auth.TotpMapCreator;
import rip.bridge.bridge.global.profile.Profile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.net.URLEncoder;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
public class ScanMapPrompt extends StringPrompt {
private static final String totptImageUrlFormat = "https://www.google.com/chart?chs=130x130&chld=M%%7C0&cht=qr&chl=%s";
private static final TotpMapCreator totpMapCreator = new TotpMapCreator();
private static final Base32 base32Encoder = new Base32();
private static SecureRandom secureRandom;
int failures = 0;
public String getPromptText(ConversationContext context) {
Player player = (Player) context.getForWhom();
if(this.failures == 0) {
Bukkit.getScheduler().runTaskAsynchronously(Bridge.getInstance(), () -> {
String totpSecret = generateTotpSecret();
BufferedImage totpImage = createTotpImage(player, totpSecret);
Bukkit.getScheduler().runTask(Bridge.getInstance(), () -> {
ItemStack map = totpMapCreator.createMap(player, totpImage);
context.setSessionData("totpSecret", totpSecret);
context.setSessionData("totpMap", map);
player.getInventory().addItem(map);
});
});
}
return ChatColor.RED + "On your 2FA device, scan the map given to you. Once you've scanned the map, type the code displayed on your device in chat.";
}
public Prompt acceptInput(ConversationContext context, String s) {
Player player = (Player) context.getForWhom();
Profile profile = BridgeGlobal.getProfileHandler().getProfileByUUID(player.getUniqueId());
ItemStack totpMap = (ItemStack) context.getSessionData("totpMap");
player.getInventory().remove(totpMap);
String totpSecret = (String) context.getSessionData("totpSecret");
if(this.failures >= 3) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Cancelling 2FA setup due to too many incorrect codes.");
context.getForWhom().sendRawMessage(ChatColor.RED + "Contact the Bridge Network staff team for any questions you may have about 2FA.");
return Prompt.END_OF_CONVERSATION;
}
int totpCode;
try {
totpCode = Integer.parseInt(s.replaceAll(" ", ""));
} catch(NumberFormatException ex) {
context.getForWhom().sendRawMessage(" ");
context.getForWhom().sendRawMessage(ChatColor.RED + s + " isn't a valid totp code. Let's try that again");
return this;
}
Bukkit.getScheduler().runTaskAsynchronously(Bridge.getInstance(), () -> {
GoogleAuthenticator gAuth = new GoogleAuthenticator();
boolean isValid = gAuth.authorize(totpSecret, totpCode);
if(isValid) {
profile.setSecretKey(totpSecret);
profile.saveProfile();
player.removeMetadata("Locked", Bridge.getInstance());
player.sendMessage(ChatColor.GREEN + "2FA setup completed successfully.");
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + s + " isn't a valid totp code. Let's try that again");
failures++;
}
});
return Prompt.END_OF_CONVERSATION;
}
private static String generateTotpSecret() {
byte[] secretKey = new byte[10];
secureRandom.nextBytes(secretKey);
return base32Encoder.encodeToString(secretKey);
}
private static BufferedImage createTotpImage(Player player, String secret) {
Escaper urlEscaper = UrlEscapers.urlFragmentEscaper();
String totpUrl = "otpauth://totp/" + urlEscaper.escape(player.getName()) + "?secret=" + secret + "&issuer=" + urlEscaper.escape("Bridge Network");
String totpImageUrl = String.format(totptImageUrlFormat, URLEncoder.encode(totpUrl));
try {
return ImageIO.read(new URL(totpImageUrl));
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
}
static {
try {
secureRandom = SecureRandom.getInstance("SHA1PRNG", "SUN");
} catch (GeneralSecurityException ex) {
ex.printStackTrace();
}
}
}

View File

@ -0,0 +1,20 @@
package rip.bridge.bridge.bukkit.commands;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.bukkit.parameters.AlertPacket;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import rip.bridge.qlib.xpacket.FrozenXPacketHandler;
public class AlertCommand {
@Command(names = "alert", permission = "bridge.alert", description = "Alert a message to the network", async = true)
public static void alert(CommandSender sender, @Param(name = "message", wildcard = true) String msg) {
FrozenXPacketHandler.sendToAll(new AlertPacket(msg, false));
}
@Command(names = "rawalert", permission = "bridge.alert", description = "Alert a raw message to the network", async = true)
public static void rawalert(CommandSender sender, @Param(name = "message", wildcard = true) String msg) {
FrozenXPacketHandler.sendToAll(new AlertPacket(msg, true));
}
}

View File

@ -0,0 +1,19 @@
package rip.bridge.bridge.bukkit.commands;
import net.minecraft.server.v1_7_R4.PacketPlayOutGameStateChange;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class DemoCommand {
@Command(names = "demo", permission = "op", hidden = true)
public static void demo(Player player, @Param(name = "target") Player target) {
PacketPlayOutGameStateChange packet = new PacketPlayOutGameStateChange(5, 0);
((CraftPlayer)target).getHandle().playerConnection.sendPacket(packet);
player.sendMessage(ChatColor.YELLOW + "Demo screened " + target.getDisplayName() + ChatColor.YELLOW + "!");
}
}

View File

@ -0,0 +1,19 @@
package rip.bridge.bridge.bukkit.commands;
import net.minecraft.server.v1_7_R4.PacketPlayOutGameStateChange;
import org.bukkit.ChatColor;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class EndScreenCommand {
@Command(names = "endscreen", permission = "op", hidden = true)
public static void endscreen(Player player, @Param(name = "target") Player target) {
PacketPlayOutGameStateChange packet = new PacketPlayOutGameStateChange(4, 0.0F);
((CraftPlayer)target).getHandle().playerConnection.sendPacket(packet);
player.sendMessage(ChatColor.YELLOW + "End screened " + target.getDisplayName() + ChatColor.YELLOW + "!");
}
}

View File

@ -0,0 +1,72 @@
package rip.bridge.bridge.bukkit.commands;
import org.bukkit.ChatColor;
import org.bukkit.conversations.*;
import org.bukkit.entity.Player;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.NetworkBroadcastPacket;
import rip.bridge.bridge.global.packet.types.ServerCommandPacket;
import rip.bridge.bridge.global.packet.types.ServerGroupCommandPacket;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class ExecuteCommands {
@Command(names = {"execcmd server", "executecommands server"}, permission = "bridge.execute", hidden = true, async = true)
public static void server(Player sender, @Param(name = "server") String server, @Param(name = "command", wildcard = true) String command) {
promptExecute(sender, server, command);
}
@Command(names = {"execcmd global", "executecommands global"}, permission = "bridge.execute", hidden = true, async = true)
public static void global(Player sender, @Param(name = "command", wildcard = true) String command) {
promptExecute(sender, "globally", command);
}
@Command(names = {"execcmd group", "executecommands group"}, permission = "bridge.execute", hidden = true, async = true)
public static void group(Player sender, @Param(name = "group") String serverGroup, @Param(name = "command", wildcard = true) String command) {
promptExecute2(sender, serverGroup, command);
}
private static void promptExecute(Player player, String server, String command) {
ConversationFactory factory = (new ConversationFactory(Bridge.getInstance())).withModality(true).withPrefix(new NullConversationPrefix()).withFirstPrompt(new StringPrompt() {
public String getPromptText(ConversationContext context) {
return ChatColor.translateAlternateColorCodes('&', "&eYou are about to execute the command &c\"" + command + "\" &c" + server + " &eare you sure you want to do this? If so type &ayes&c.");
}
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("yes")) {
context.getForWhom().sendRawMessage(ChatColor.GREEN + "Sending cross-bungee command...");
PacketHandler.sendToAll(new ServerCommandPacket(server, command));
PacketHandler.sendToAll(new NetworkBroadcastPacket("bridge.execute.view", "&8[&eServer Monitor&8] " + player.getDisplayName() + " &fexecuted command &d" + command + (server.equals("globally") ? " &f" : " &fon ") + server));
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + "Executing canclled.");
}
return Prompt.END_OF_CONVERSATION;
}
}).withEscapeSequence("/no").withLocalEcho(false).withTimeout(10).thatExcludesNonPlayersWithMessage("Go away evil console!");
Conversation con = factory.buildConversation(player);
player.beginConversation(con);
}
private static void promptExecute2(Player player, String serverGroup, String command) {
ConversationFactory factory = (new ConversationFactory(Bridge.getInstance())).withModality(true).withPrefix(new NullConversationPrefix()).withFirstPrompt(new StringPrompt() {
public String getPromptText(ConversationContext context) {
return ChatColor.translateAlternateColorCodes('&', "&eYou are about to execute the command &c\"" + command + "\" to the server group &c" + serverGroup + " &eare you sure you want to do this? If so type &ayes&c.");
}
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("yes")) {
context.getForWhom().sendRawMessage(ChatColor.GREEN + "Sending cross-bungee command...");
PacketHandler.sendToAll(new ServerGroupCommandPacket(serverGroup, command));
PacketHandler.sendToAll(new NetworkBroadcastPacket("bridge.execute.view", "&8[&eServer Monitor&8] " + player.getDisplayName() + " &fexecuted command &d" + command + " &fon the server group " + serverGroup));
} else {
context.getForWhom().sendRawMessage(ChatColor.RED + "Executing canclled.");
}
return Prompt.END_OF_CONVERSATION;
}
}).withEscapeSequence("/no").withLocalEcho(false).withTimeout(10).thatExcludesNonPlayersWithMessage("Go away evil console!");
Conversation con = factory.buildConversation(player);
player.beginConversation(con);
}
}

View File

@ -0,0 +1,29 @@
package rip.bridge.bridge.bukkit.commands;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.status.BridgeServer;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class FindCommand {
@Command(names = { "find" }, permission = "bridge.find", description = "See the server a player is currently playing on", async = true)
public static void find(CommandSender sender, @Param(name = "player", extraData = "get") Profile profile) {
findresponse(sender, profile);
}
public static void findresponse(CommandSender sender, Profile profile) {
BridgeServer server = BridgeGlobal.getServerHandler().findPlayerServer(profile.getUuid());
BridgeServer proxy = BridgeGlobal.getServerHandler().findPlayerProxy(profile.getUuid());
if (server == null) {
sender.sendMessage(ChatColor.RED + (profile.getDisguise() != null ? profile.getDisguise().getDisguiseName() : profile.getUsername()) + " is currently not on the network.");
return;
}
sender.sendMessage(ChatColor.YELLOW + (profile.getDisguise() != null ? profile.getDisguise().getDisguiseName() : profile.getUsername()) + " is on " + ChatColor.GREEN + server.getName() + (proxy != null ? ChatColor.YELLOW + " (" + ChatColor.GREEN + proxy.getName() + " Proxy" + ChatColor.YELLOW + ")" : ""));
}
}

View File

@ -0,0 +1,70 @@
package rip.bridge.bridge.bukkit.commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.visibility.FrozenVisibilityHandler;
import java.util.*;
import java.util.stream.Collectors;
public class ListCommand {
@Command(names = { "list", "who", "players" }, permission = "", description = "See a list of online players", async = true)
public static void list(CommandSender sender) {
Map<Rank, List<String>> sorted = new TreeMap<>(Comparator.comparingInt(Rank::getPriority).reversed());
int online = 0;
for (Player player : Bukkit.getOnlinePlayers()) {
if(!sender.hasPermission("basic.staff") && !canSee(sender, player)) continue;
++online;
Profile profile = BukkitAPI.getProfile(player.getUniqueId());
Rank rank = BukkitAPI.getPlayerRank(profile);
String displayName = player.getDisplayName() + ChatColor.WHITE;
if (player.hasMetadata("invisible")) {
displayName = ChatColor.GRAY + "*" + displayName + ChatColor.WHITE;
}
sorted.putIfAbsent(rank, new LinkedList<>());
sorted.get(rank).add(displayName);
}
List<String> merged = new LinkedList<>();
for (List<String> part : sorted.values()) {
part.sort(String.CASE_INSENSITIVE_ORDER);
merged.addAll(part);
}
sender.sendMessage(getHeader(sender));
sender.sendMessage("(" + online + "/" + Bukkit.getMaxPlayers() + ") " + merged);
}
private static String getHeader(CommandSender sender) {
StringBuilder builder = new StringBuilder();
List<Rank> ranks = BridgeGlobal.getRankHandler().getRanks().parallelStream().sorted(Comparator.comparingInt(Rank::getPriority).reversed()).collect(Collectors.toList());
for (Rank rank : ranks) {
boolean displayed = rank.getPriority() >= 0;
if (displayed) {
if(rank.isHidden() && sender.hasPermission("bridge.hiddenranks")) {
builder.append(ChatColor.GRAY + "*").append(rank.getColor()).append(rank.getDisplayName()).append(ChatColor.RESET).append(", ");
}else if(!rank.isHidden()){
builder.append(rank.getColor()).append(rank.getDisplayName()).append(ChatColor.RESET).append(", ");
}
}
}
if (builder.length() > 2) {
builder.setLength(builder.length() - 2);
}
return builder.toString();
}
private static boolean canSee(CommandSender sender, CommandSender target) {
if(!(sender instanceof Player)) return true;
return FrozenVisibilityHandler.treatAsOnline((Player)target, (Player)sender);
}
}

View File

@ -0,0 +1,62 @@
package rip.bridge.bridge.bukkit.commands;
import com.google.common.collect.Maps;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packetlogger.PacketLog;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import java.util.Map;
public class PacketLoggerCommands {
@Command(names = {"packetlogger info"}, permission = "op", hidden = true, async = true)
public static void packetloggerinfo(CommandSender sender, @Param(name = "target", defaultValue = "self") Player target) {
sender.sendMessage(ChatColor.GREEN + "Getting Packet Log for " + target.getDisplayName() + ChatColor.GREEN + "...");
sender.sendMessage(BukkitAPI.LINE);
Map<String, Integer> packetInfo = Maps.newHashMap();
Map<String, Integer> canceled = Maps.newHashMap();
for (PacketLog packetLog : BridgeGlobal.getPacketLogHandler().getLog(target.getUniqueId())) {
int amount = 1;
if (packetInfo.containsKey(packetLog.getPacket().getClass().getSimpleName())) {
amount = packetInfo.get(packetLog.getPacket().getClass().getSimpleName());
amount++;
}
int amountFlagged = 1;
if (canceled.containsKey(packetLog.getPacket().getClass().getSimpleName())) {
amountFlagged = canceled.get(packetLog.getPacket().getClass().getSimpleName());
amountFlagged++;
}
canceled.put(packetLog.getPacket().getClass().getSimpleName(), amount);
}
if (packetInfo.size() == 0) {
sender.sendMessage(ChatColor.RED + target.getName() + " has no packet logs.");
} else {
for (Map.Entry<String, Integer> entry : packetInfo.entrySet()) {
sender.sendMessage(BukkitAPI.LINE);
sender.sendMessage(ChatColor.YELLOW + entry.getKey() + ChatColor.GRAY + " (" + ChatColor.RED + entry.getValue() + ChatColor.GRAY + ") " +
ChatColor.YELLOW + "Times Flagged: " + canceled.get(entry.getKey()));
}
sender.sendMessage(BukkitAPI.LINE);
}
}
@Command(names = {"packetlogger toggle "}, permission = "op", hidden = true, async = true)
public static void packetloggertoggle(CommandSender sender) {
boolean toogled = Bridge.getInstance().togglePacketLogger;
Bridge.getInstance().setTogglePacketLogger(!Bridge.getInstance().togglePacketLogger);
sender.sendMessage(ChatColor.YELLOW + "PacketLogger: " + (!toogled ? ChatColor.RED + "Disabled" : ChatColor.GREEN + "Enabled") + ChatColor.YELLOW + ".");
}
}

View File

@ -0,0 +1,45 @@
package rip.bridge.bridge.bukkit.commands;
import com.google.common.collect.Lists;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.util.PaginatedResult;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Optional;
public class PermsCommand {
@Command(names = { "perms" }, permission = "bridge.viewperms", description = "View an player's permissions", async = true)
public static void perms(CommandSender sender, @Param(name = "player", defaultValue = "self") Player player, @Param(name = "page", defaultValue = "1") int page) {
Optional<Profile> optionalProfile = Optional.ofNullable(BridgeGlobal.getProfileHandler().getProfileByUUID(player.getUniqueId()));
if (!optionalProfile.isPresent()) {
sender.sendMessage(ChatColor.RED + player.getName() + "'s profile isn't loaded.");
return;
}
Rank rank = optionalProfile.get().getCurrentGrant().getRank();
List<String> toSend = Lists.newArrayList();
for (String permission : rank.getPermissions().keySet()) {
toSend.add((player.hasPermission(permission) ? (ChatColor.GREEN + " + ") : (ChatColor.RED + " - ")) + ChatColor.WHITE + permission + " (" + rank.getPermissions().get(permission) + ")");
}
new PaginatedResult<String>() {
@Override
public String getHeader(int page, int maxPages) {
return ChatColor.translateAlternateColorCodes('&', "&c" + StringUtils.repeat('-', 3) + " &r" + player.getDisplayName() + "&7(&r" + rank.getColor() + rank.getDisplayName() + "&7)'s Permissions (&e" + page + "&7/&e" + maxPages + "&7) &c" + StringUtils.repeat('-', 3));
}
@Override
public String format(String entry, int index) {
return entry;
}
}.display(sender, toSend, page);
}
}

View File

@ -0,0 +1,34 @@
package rip.bridge.bridge.bukkit.commands;
import mkremins.fanciful.FancyMessage;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.util.TimeUtil;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import rip.bridge.qlib.util.TimeUtils;
import java.util.Date;
public class SeenCommand {
@Command(names = {"lastseen", "seen"}, permission = "bridge.seen", description = "See when a player was last on", async = true)
public static void lastseen(CommandSender sender, @Param(name = "player", extraData = "get") Profile profile) {
if (profile.isOnline()) {
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 36));
sender.sendMessage((ChatColor.RED + profile.getUsername() + ChatColor.YELLOW + " is currently on " + ChatColor.RED + profile.getConnectedServer() + ChatColor.YELLOW + "."));
sender.sendMessage(ChatColor.GOLD + "Check out their info on the website: bridge.rip/u/" + profile.getUsername());
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 36));
} else {
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 36));
sender.sendMessage((ChatColor.RED + profile.getUsername() + ChatColor.YELLOW + " is currently " + ChatColor.RED + "offline" + ChatColor.YELLOW + "."));
sender.sendMessage(ChatColor.YELLOW + "Last seen at " + ChatColor.RED + TimeUtils.formatIntoCalendarString(new Date(profile.getLastJoined())) + ChatColor.YELLOW + " on " + ChatColor.RED + profile.getConnectedServer() + ChatColor.YELLOW + ".");
sender.sendMessage(ChatColor.GOLD + "Check out their info on the website: bridge.rip/u/" + profile.getUsername());
sender.sendMessage(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 36));
}
}
}

View File

@ -0,0 +1,66 @@
package rip.bridge.bridge.bukkit.commands;
import com.google.common.collect.Maps;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
import rip.bridge.qlib.command.Command;
import java.util.HashMap;
import java.util.Set;
import static org.spigotmc.TicksPerSecondCommand.format;
public class ThreadProfilerCommands {
@Command(names = {"threadprofiler list"}, permission = "op", hidden = true, async = true)
public static void threadprofilerlist(CommandSender sender) {
Set<Thread> threads = Thread.getAllStackTraces().keySet();
for (Thread thread : threads) {
sender.sendMessage(ChatColor.translateAlternateColorCodes
('&', " &6* &e"
+ thread.getName() + " &d(State: "
+ (thread.getState()) + ", Priority: "
+ thread.getPriority() + ")"));
}
}
@Command(names = {"threadprofiler gc"}, permission = "op", hidden = true, async = true)
public static void threadprofilergc(CommandSender sender) {
Runtime runtime = Runtime.getRuntime();
sender.sendMessage(ChatColor.YELLOW + "Trying to run Java garbage collector to free up memory.");
long before = System.currentTimeMillis();
runtime.gc();
long after = System.currentTimeMillis();
sender.sendMessage(ChatColor.GOLD
+ "* "
+ ChatColor.YELLOW + "Finished! Took "
+ ChatColor.LIGHT_PURPLE
+ (after - before)
+ "ms");
}
@Command(names = {"threadprofiler threads"}, permission = "op", hidden = true, async = true)
public static void threadprofilerthreads(CommandSender sender) {
Set<Thread> threads = Thread.getAllStackTraces().keySet();
Runtime runtime = Runtime.getRuntime();
HashMap<Plugin, Integer> pending = Maps.newHashMap();
for (BukkitTask worker : Bukkit.getScheduler().getPendingTasks()) {
pending.put(worker.getOwner(), pending.getOrDefault(worker.getOwner(), 0) + 1);
}
sender.sendMessage(ChatColor.GOLD + "Alive Threads: " + ChatColor.LIGHT_PURPLE + Thread.getAllStackTraces().keySet().parallelStream().filter(Thread::isAlive).count());
sender.sendMessage(ChatColor.GOLD + "Daemon Threads: " + ChatColor.LIGHT_PURPLE + Thread.getAllStackTraces().keySet().parallelStream().filter(Thread::isDaemon).count());
sender.sendMessage(ChatColor.GOLD + "Interrupted Threads: " + ChatColor.LIGHT_PURPLE + Thread.getAllStackTraces().keySet().parallelStream().filter(Thread::isInterrupted).count());
sender.sendMessage(ChatColor.GOLD + "Active Workers: " + ChatColor.LIGHT_PURPLE + Bukkit.getScheduler().getActiveWorkers().size());
sender.sendMessage(ChatColor.GOLD + "Pending Tasks: " + ChatColor.LIGHT_PURPLE + Bukkit.getScheduler().getPendingTasks().size());
sender.sendMessage(ChatColor.GOLD + "Threads: " + ChatColor.YELLOW + "(" + threads.size() + " Active) (Ram " + ChatColor.LIGHT_PURPLE + format(runtime.freeMemory()) + " free out of " + ChatColor.LIGHT_PURPLE + format(runtime.maxMemory()) + " " + ChatColor.LIGHT_PURPLE + format(runtime.maxMemory() - runtime.freeMemory()) + " used" + ChatColor.GOLD + ")");
sender.sendMessage("");
pending.keySet().stream().sorted((o1, o2) -> pending.get(o2) - pending.get(o1)).forEachOrdered(plugin -> sender.sendMessage(ChatColor.RED + "* " + ChatColor.YELLOW + plugin.getName() + ": " + ChatColor.WHITE + pending.get(plugin)));
}
}

View File

@ -0,0 +1,98 @@
package rip.bridge.bridge.bukkit.commands;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import rip.bridge.qlib.util.TimeUtil;
import rip.bridge.qlib.util.TimeUtils;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class TimelineCommand {
public static String blockColors = "";
@Command(names = {"timeline"}, permission = "basic.staff", description = "Check for how long you've been staff!", async = true)
public static void timeline(Player sender, @Param(name = "target", defaultValue = "self") Profile target) {
if (!target.getCurrentGrant().getRank().isStaff() && target.getRemovedStaffOn() == 0) {
sender.sendMessage(ChatColor.RED + "That player has never been apart of the staff team.");
} else {
sender.sendMessage(BukkitAPI.RED_LINE);
List<Grant> grants = new ArrayList<>(target.getGrants());
List<String> blockLines = new ArrayList<>();
grants.sort(new SortByDate());
boolean isFirst = false;
for(Grant grant : grants) {
if(!grant.getRank().isStaff()) continue;
// Random randie = new Random();
//
// int random = randie.nextInt(15);
blockLines.add(grant.getRank().getColor().replace("§o", "") + ChatColor.STRIKETHROUGH + blockColors + "" + ChatColor.RESET);
for (int i = 0; i < Math.abs(TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - grant.getInitialTime()) / 7); ++i) {
blockLines.add(ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH.toString() + blockColors + ChatColor.RESET);
}
if(!isFirst) {
sender.sendMessage(ChatColor.GOLD + target.getUsername() + ChatColor.YELLOW + " joined the team on " + ChatColor.LIGHT_PURPLE + grant.getDate()
+ ChatColor.YELLOW + " and was given " + grant.getRank().getColor() + grant.getRank().getDisplayName()
+ ChatColor.YELLOW + " by " + ChatColor.LIGHT_PURPLE + grant.getGrantedByColorless());
isFirst = true;
continue;
}
if(grant.getRank().getPriority() > 70) {
sender.sendMessage(ChatColor.GOLD + target.getUsername() + ChatColor.YELLOW + " was" + ChatColor.GREEN + " promoted " + ChatColor.YELLOW + "to " + grant.getRank().getColor() + grant.getRank().getDisplayName() + ChatColor.YELLOW +
" on " + ChatColor.LIGHT_PURPLE + grant.getDate()
+ ChatColor.YELLOW + " by " + ChatColor.LIGHT_PURPLE + grant.getGrantedByColorless());
} else {
sender.sendMessage(ChatColor.GOLD + target.getUsername() + ChatColor.YELLOW + " was granted " + grant.getRank().getColor() + grant.getRank().getDisplayName() + ChatColor.YELLOW +
" on " + ChatColor.LIGHT_PURPLE + grant.getDate()
+ ChatColor.YELLOW + " by " + ChatColor.LIGHT_PURPLE + grant.getGrantedByColorless());
}
}
sender.sendMessage(" ");
sender.sendMessage(ChatColor.AQUA + "Timeline:");
String result = StringUtils.join(blockLines, "");
sender.sendMessage(result + ChatColor.GOLD + ChatColor.STRIKETHROUGH + "");
sender.sendMessage(" ");
if(target.getRemovedStaffOn() != 0) {
Date timeAdded = new Date(target.getBecameStaffOn());
Date timeRemoved = new Date(target.getRemovedStaffOn());
long diffInM = Math.abs(timeRemoved.getTime() - timeAdded.getTime());
long diff = TimeUnit.DAYS.convert(diffInM, TimeUnit.MILLISECONDS);
sender.sendMessage(ChatColor.GOLD + target.getUsername() + ChatColor.YELLOW + " parted ways with the staff team on " + ChatColor.LIGHT_PURPLE + TimeUtils.formatIntoCalendarStringNoTime(new Date(target.getRemovedStaffOn())) + ChatColor.YELLOW + ".");
sender.sendMessage(ChatColor.GOLD + target.getUsername() + ChatColor.GREEN + " helped the staff team for " + ChatColor.LIGHT_PURPLE + TimeUtil.millisToRoundedTime(timeRemoved.getTime() - timeAdded.getTime()) + ChatColor.YELLOW + ".");
} else {
sender.sendMessage(ChatColor.GOLD + target.getUsername() + ChatColor.YELLOW + " has been helping the staff team for " + ChatColor.LIGHT_PURPLE + TimeUtil.millisToRoundedTime(System.currentTimeMillis() - target.getBecameStaffOn()) + ChatColor.YELLOW + ".");
}
sender.sendMessage(BukkitAPI.RED_LINE);
}
}
static class SortByDate implements Comparator<Grant> {
@Override
public int compare(Grant a, Grant b) {
return a.getDate().compareTo(b.getDate());
}
}
}

View File

@ -0,0 +1,49 @@
package rip.bridge.bridge.bukkit.commands.auth;
import com.warrenstrange.googleauth.GoogleAuthenticator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class AuthCommand {
@Command(names = {"auth", "authenticate", "2fa", "otp"}, permission = "basic.staff", description = "Authenticate with the API, verifying your identity", hidden = true)
public static void auth(Player sender, @Param(name = "code", wildcard = true) String input) {
Profile profile = BridgeGlobal.getProfileHandler().getProfileByUUID(sender.getUniqueId());
if(!sender.hasMetadata("Locked")) {
sender.sendMessage(ChatColor.RED + "You don't need to authenticate at the moment.");
} else {
input = input.replace(" ", "");
int code = Integer.parseInt(input);
Bukkit.getScheduler().runTask(Bridge.getInstance(), () -> {
if (profile == null) {
sender.sendMessage(ChatColor.DARK_RED.toString() + ChatColor.BOLD + "Your profile hasn't yet been loaded.");
} else {
if(profile.getSecretKey().isEmpty()) {
sender.sendMessage(ChatColor.RED + "You need to setup your 2FA first using: /2fasetup.");
return;
}
GoogleAuthenticator gAuth = new GoogleAuthenticator();
boolean isValid = gAuth.authorize(profile.getSecretKey(), code);
if(isValid) {
sender.removeMetadata("Locked", Bridge.getInstance());
sender.sendMessage(ChatColor.DARK_GREEN + "" + ChatColor.GREEN + "Authenticated");
} else {
sender.sendMessage(ChatColor.RED + "Invalid auth code.");
}
}
});
}
}
}

View File

@ -0,0 +1,20 @@
package rip.bridge.bridge.bukkit.commands.auth;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class ForceAuthCommand {
@Command(names = {"forceauth"}, permission = "op", description = "Forcefully authenticate a player", hidden = true)
public static void forceAuth(CommandSender sender, @Param(name = "player") Player player) {
player.removeMetadata("Locked", Bridge.getInstance());
player.setMetadata("ForceAuth", new FixedMetadataValue(Bridge.getInstance(), true));
sender.sendMessage(ChatColor.YELLOW + player.getName() + " has been forcefully authenticated.");
}
}

View File

@ -0,0 +1,24 @@
package rip.bridge.bridge.bukkit.commands.auth;
import org.bukkit.ChatColor;
import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationFactory;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.bukkit.auth.prompt.InitialDisclaimerPrompt;
import rip.bridge.qlib.command.Command;
public class Setup2faCommand {
@Command(names = {"setup2fa", "2fasetup"}, permission = "basic.staff", description = "Sign up to use 2FA to verify your identity", hidden = true)
public static void setup2fa(Player sender) {
if (!BridgeGlobal.getProfileHandler().getProfileByUUIDOrCreate(sender.getUniqueId()).getSecretKey().isEmpty()) {
sender.sendMessage(ChatColor.RED + "You already have 2FA setup!");
} else {
ConversationFactory factory = (new ConversationFactory(Bridge.getInstance())).withFirstPrompt(new InitialDisclaimerPrompt()).withLocalEcho(false).thatExcludesNonPlayersWithMessage("Go away evil console!");
Conversation con = factory.buildConversation(sender);
sender.beginConversation(con);
}
}
}

View File

@ -0,0 +1,52 @@
package rip.bridge.bridge.bukkit.commands.disguise;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.bukkit.commands.disguise.menu.DisguiseRankMenu;
import rip.bridge.bridge.global.util.mojang.GameProfileUtil;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import java.util.Objects;
import java.util.regex.Pattern;
public class DisguiseCommand {
@Command(names = {"disguise", "dis", "d", "nick"}, permission = "bridge.disguise", description = "Disguise as another player", hidden = true)
public static void disguise(Player player, @Flag(value = {"cc"}, description = "Disable case-correction of the name") boolean caseCorrection, @Param(name = "name") String name) {
if (!Pattern.compile("^\\w{1,16}$").matcher(name).matches()) {
player.sendMessage(ChatColor.RED + "Invalid username: " + name);
return;
}
String finalName = name;
if (Bukkit.getPlayerExact(name) != null || Objects.requireNonNull(BridgeGlobal.getUsedDisguisedNames()).stream().anyMatch(n -> n.equalsIgnoreCase(finalName))) {
player.sendMessage(ChatColor.RED + "The name \"" + name + "\" is unavailable.");
return;
} // try this
if (BukkitAPI.getProfile(name) != null && BukkitAPI.getPlayerRank(BukkitAPI.getProfile(name)).isStaff()) {
player.sendMessage(ChatColor.RED + name + " exists as a Bridge player. You cannot impersonate others, please choose another name.");
return;
}
if (BukkitAPI.getProfile(name) != null) {
player.sendMessage(ChatColor.RED + name + " exists as a Bridge player. You cannot impersonate others, please choose another name.");
return;
}
String realName = GameProfileUtil.getRealName(name);
if (!caseCorrection && realName != null && !name.equals(realName)) {
name = realName;
}
new DisguiseRankMenu(name, realName != null).openMenu(player);
}
}

View File

@ -0,0 +1,52 @@
package rip.bridge.bridge.bukkit.commands.disguise;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.disguise.DisguisePlayer;
import rip.bridge.bridge.global.disguise.DisguiseProfile;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class RealNameCommand {
@Command(names = {"realname", "realnick", "checkdisguise"}, permission = "basic.staff", description = "Check who the person is!", hidden = true)
public static void check(Player sender, @Param(name = "name") String name) {
Player player = Bukkit.getPlayer(name);
if (player == null) {
for (DisguisePlayer disguisePlayer : BridgeGlobal.getDisguiseManager().getDisguisePlayers().values()) {
if (name.equalsIgnoreCase(disguisePlayer.getName())) {
Player dPlayer = Bukkit.getPlayer(disguisePlayer.getDisguiseName());
if (dPlayer != null) {
player = dPlayer;
break;
}
}
}
}
if (player == null) {
sender.sendMessage("§cNo player with the name" + " \"" + name + "\" found.");
return;
}
DisguisePlayer disguisePlayer = BridgeGlobal.getDisguiseManager().getDisguisePlayers().get(player.getUniqueId());
Profile data = BridgeGlobal.getProfileHandler().getProfileByUUID(player.getUniqueId());
DisguiseProfile profile = disguisePlayer != null ? BridgeGlobal.getDisguiseManager().getDisguiseProfiles().values()
.stream()
.filter(dp -> disguisePlayer.getDisguiseSkin() != null && dp.getSkinName().equalsIgnoreCase(disguisePlayer.getDisguiseSkin()))
.findFirst()
.orElse(null) : null;
sender.sendMessage(data.getCurrentGrant().getRank().getColor() + data.getUsername() + ChatColor.GOLD + (disguisePlayer != null ? " is disguised" : ChatColor.RED + " is NOT disguised") + '.');
if (disguisePlayer != null) {
sender.sendMessage(ChatColor.GRAY.toString() + ' ' + "*" + ' ' + ChatColor.GOLD + "Disguise Name: " + ChatColor.RESET + disguisePlayer.getDisguiseName());
sender.sendMessage(ChatColor.GRAY.toString() + ' ' + "*" + ' ' + ChatColor.GOLD + "Disguise Skin: " + ChatColor.WHITE + ChatColor.stripColor((profile != null ? profile.getDisplayName() : disguisePlayer.getDisguiseSkin())));
sender.sendMessage(ChatColor.GRAY.toString() + ' ' + "*" + ' ' + ChatColor.GOLD + "Disguise Rank: " + disguisePlayer.getDisguiseRank().getColor() + disguisePlayer.getDisguiseRank().getName());
}
}
}

View File

@ -0,0 +1,119 @@
package rip.bridge.bridge.bukkit.commands.disguise;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.commands.disguise.menu.DisguiseSkinMenu;
import rip.bridge.bridge.global.disguise.DisguisePlayer;
import rip.bridge.bridge.global.disguise.DisguisePlayerSkin;
import rip.bridge.bridge.global.disguise.runnable.DisguiseRunnable;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.bridge.global.util.Tasks;
import rip.bridge.bridge.global.util.mojang.GameProfileUtil;
import rip.bridge.bridge.global.util.mojang.UUIDFetcher;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import rip.bridge.qlib.nametag.FrozenNametagHandler;
import java.util.*;
public class SkinCommand {
@Command(names = {"skin"}, permission = "bridge.disguise", async = true, hidden = true)
public static void skin(Player player, @Param(name = "skin", defaultValue = "N/A") String skin) {
DisguisePlayer disguisePlayer = BridgeGlobal.getDisguiseManager().getDisguisePlayers().get(player.getUniqueId());
Profile playerProfile = BridgeGlobal.getProfileHandler().getProfileByUUID(player.getUniqueId());
Rank current = playerProfile.getCurrentGrant().getRank();
if (skin.equals("N/A")) {
skin = disguisePlayer != null ? disguisePlayer.getDisguiseName() : player.getName();
new DisguiseSkinMenu(skin, disguisePlayer != null ? disguisePlayer.getDisguiseRank() : current != null ? current : BridgeGlobal.getRankHandler().getDefaultRank(), true, true).openMenu(player);
return;
}
if (disguisePlayer != null) {
disguisePlayer.setDisguiseSkin(skin);
GameProfile profile = GameProfileUtil.getSkinCache().get(skin.toLowerCase());
if (profile == null) {
Map<String, UUID> fetched = null;
try {
fetched = new UUIDFetcher(Collections.singletonList(skin)).call();
} catch (Exception e) {
e.printStackTrace();
}
Optional<UUID> fetchedUuid = Objects.requireNonNull(fetched).values().stream().findFirst();
if (!fetchedUuid.isPresent()) {
player.sendMessage(ChatColor.RED + "Skin by that name doesn't exist.");
return;
}
profile = GameProfileUtil.loadGameProfile(fetchedUuid.get(), skin);
}
DisguisePlayerSkin fakeSkin = BridgeGlobal.getDisguiseManager().setupDisguiseSkin(profile);
if (fakeSkin == null) {
player.sendMessage(ChatColor.RED + "Failed to setup skin.");
return;
}
disguisePlayer.setFakeSkin(fakeSkin);
Tasks.run(new DisguiseRunnable(player, profile, disguisePlayer.getDisguiseName()));
Tasks.run(() -> {
FrozenNametagHandler.reloadPlayer(player);
FrozenNametagHandler.reloadOthersFor(player);
});
Rank rank = disguisePlayer.getDisguiseRank();
String nickName = disguisePlayer.getDisguiseName();
player.sendMessage(ChatColor.GREEN + "Success! You now look like " + rank.getPrefix() + rank.getColor() + nickName + ChatColor.GREEN + (!nickName.equals(skin) && !nickName.equals(ChatColor.stripColor(skin)) ? " (in the skin of " + ChatColor.YELLOW + ChatColor.stripColor(skin) + ChatColor.GREEN + ")" : "") + "!");
String realName = GameProfileUtil.getRealName(nickName);
if (realName != null) {
player.sendMessage(ChatColor.RED + nickName + " is an existing Minecraft player, so if they log on for the first time as you're disguised, you will be kicked.");
}
String realSkin = GameProfileUtil.getRealName(skin);
String finalSkin = skin;
if (realSkin == null && BridgeGlobal.getDisguiseManager().getDisguiseProfiles().values().stream().noneMatch(p -> p.getSkinName().equalsIgnoreCase(finalSkin)) || skin.equals("Steve") || skin.equals("Alex")) {
player.sendMessage(ChatColor.YELLOW + "Note: You will look like " + (skin.equals("Alex") ? "Alex" : "Steve") + " since the account \"" + skin + "\" does not exist.");
}
} else {
try {
disguisePlayer = new DisguisePlayer(player.getName());
disguisePlayer.setDisguiseRank(current != null ? current : BridgeGlobal.getRankHandler().getDefaultRank());
disguisePlayer.setDisguiseName(player.getName());
disguisePlayer.setDisguiseSkin(skin);
Rank rank = disguisePlayer.getDisguiseRank();
String nickName = disguisePlayer.getDisguiseName();
if (BridgeGlobal.getDisguiseManager().disguise(player, disguisePlayer, null, false, true, false)) {
player.sendMessage(ChatColor.GREEN + "Success! You now look like " + rank.getPrefix() + rank.getColor() + nickName + ChatColor.GREEN + (!nickName.equals(skin) && !nickName.equals(ChatColor.stripColor(skin)) ? " (in the skin of " + ChatColor.YELLOW + ChatColor.stripColor(skin) + ChatColor.GREEN + ")" : "") + "!");
String realName = GameProfileUtil.getRealName(nickName);
if (realName != null) {
player.sendMessage(ChatColor.RED + nickName + " is an existing Minecraft player, so if they log on for the first time as you're disguised, you will be kicked.");
}
String realSkin = GameProfileUtil.getRealName(skin);
String finalSkin = skin;
if (realSkin == null && BridgeGlobal.getDisguiseManager().getDisguiseProfiles().values().stream().noneMatch(p -> p.getSkinName().equalsIgnoreCase(finalSkin)) || skin.equals("Steve") || skin.equals("Alex")) {
player.sendMessage(ChatColor.YELLOW + "Note: You will look like " + (skin.equals("Alex") ? "Alex" : "Steve") + " since the account \"" + skin + "\" does not exist.");
}
}
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(ChatColor.RED + "Something went wrong while disguising you! Please contact a staff member or any online developer.");
}
}
}
}

View File

@ -0,0 +1,67 @@
package rip.bridge.bridge.bukkit.commands.disguise;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.disguise.DisguisePlayer;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import rip.bridge.qlib.nametag.FrozenNametagHandler;
public class TagCommand {
@Command(names = {"tag"}, permission = "bridge.disguise", async = true, hidden = true)
public static void tag(Player player, @Param(name = "rank") String rank) {
Profile profile = BridgeGlobal.getProfileHandler().getProfileByUUID(player.getUniqueId());
Rank current = profile.getCurrentGrant().getRank();
Rank select = BridgeGlobal.getRankHandler().getRankByName(rank);
if (rank.equalsIgnoreCase("clear")) {
select = current;
BridgeGlobal.getDisguiseManager().undisguise(player, false, false);
}
if (select == null) {
select = BridgeGlobal.getRankHandler().getDefaultRank();
}
if (select.getPriority() > current.getPriority()) {
player.sendMessage(ChatColor.RED + "You are not allowed to set your tag to " + select.getColor() + select.getDisplayName() + ChatColor.RED + ".");
return;
}
DisguisePlayer disguisePlayer = BridgeGlobal.getDisguiseManager().getDisguisePlayers().get(player.getUniqueId());
if (disguisePlayer != null) {
disguisePlayer.setDisguiseRank(select);
player.setPlayerListName(select.getColor() + disguisePlayer.getDisguiseName());
player.setDisplayName(select.getColor() + disguisePlayer.getDisguiseName());
player.setCustomName(select.getColor() + disguisePlayer.getDisguiseName());
profile.updateColor();
profile.saveProfile();
BridgeGlobal.getDisguiseManager().save(player.getUniqueId(), false);
} else {
try {
disguisePlayer = new DisguisePlayer(player.getName());
disguisePlayer.setDisguiseRank(select);
disguisePlayer.setDisguiseName(player.getName());
disguisePlayer.setDisguiseSkin(player.getName());
BridgeGlobal.getDisguiseManager().disguise(player, disguisePlayer, null,false, false, false);
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(ChatColor.RED + "Something went wrong while disguising you! Please contact a staff member or any online developer.");
}
}
FrozenNametagHandler.reloadPlayer(player);
FrozenNametagHandler.reloadOthersFor(player);
player.sendMessage(ChatColor.GREEN + "Setting your tag to " + select.getColor() + select.getDisplayName() + ChatColor.GREEN + "...");
}
}

View File

@ -0,0 +1,23 @@
package rip.bridge.bridge.bukkit.commands.disguise;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.disguise.DisguisePlayer;
import rip.bridge.qlib.command.Command;
public class UnDisguiseCommand {
@Command(names = {"undisguise", "undis", "ud", "unnick", "und"}, permission = "bridge.disguise", description = "Reveal yourself once again!", hidden = true)
public static void undisguise(Player player) {
DisguisePlayer disguisePlayer = BridgeGlobal.getDisguiseManager().getDisguisePlayers().get(player.getUniqueId());
if (disguisePlayer == null) {
player.sendMessage(ChatColor.RED + "You're not disguised!");
return;
}
player.sendMessage(ChatColor.GREEN + "Removing the disguise...");
BridgeGlobal.getDisguiseManager().undisguise(player, true, false);
}
}

View File

@ -0,0 +1,23 @@
package rip.bridge.bridge.bukkit.commands.disguise;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.disguise.DisguisePlayer;
import rip.bridge.qlib.command.Command;
public class UnTagCommand {
@Command(names = {"untag"}, permission = "bridge.disguise", hidden = true)
public static void untag(Player player) {
DisguisePlayer disguisePlayer = BridgeGlobal.getDisguiseManager().getDisguisePlayers().get(player.getUniqueId());
if (disguisePlayer == null) {
player.sendMessage(ChatColor.RED + "You're not tagged!");
return;
}
player.sendMessage(ChatColor.GREEN + "Removing the tag...");
BridgeGlobal.getDisguiseManager().undisguise(player, true, false);
}
}

View File

@ -0,0 +1,38 @@
package rip.bridge.bridge.bukkit.commands.disguise.disguiseprofile;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.disguise.DisguiseProfile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import java.util.regex.Pattern;
public class DisguiseProfileCreateCommand {
@Command(names = {"disguiseprofile create"}, permission = "bridge.disguise.admin", description = "Create a disguise profile", hidden = true)
public static void disguise(Player player, @Param(name = "name") String name, @Param(name = "skin") String skin) {
if (!Pattern.compile("^\\w{1,16}$").matcher(name).matches()) {
player.sendMessage(ChatColor.RED + "That is not a valid username.");
return;
}
if (!Pattern.compile("^\\w{1,16}$").matcher(skin).matches()) {
player.sendMessage(ChatColor.RED + "That is not a valid skin.");
return;
}
boolean added = BridgeGlobal.getDisguiseManager().addProfile(name, skin);
if (!added) {
player.sendMessage(ChatColor.RED + "Failed to add disguise profile with name " + name + " and skin " + skin + '.');
return;
}
DisguiseProfile profile = BridgeGlobal.getDisguiseManager().getProfile(name);
profile.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
player.sendMessage(ChatColor.GREEN + "You have created a disguise profile with name " + ChatColor.RESET + name + ChatColor.GREEN + " and skin " + ChatColor.RESET + skin + ChatColor.GREEN + '.');
}
}

View File

@ -0,0 +1,22 @@
package rip.bridge.bridge.bukkit.commands.disguise.disguiseprofile;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class DisguiseProfileDeleteCommand {
@Command(names = {"disguiseprofile delete", "disguiseprofile remove"}, permission = "bridge.disguise.admin", description = "Remove disguise profiles", hidden = true)
public static void disguise(Player player, @Param(name = "name") String name) {
boolean removed = BridgeGlobal.getDisguiseManager().removeProfile(name);
if (!removed) {
player.sendMessage(ChatColor.RED + "Failed to remove disguise profile with name " + name + '.');
return;
}
player.sendMessage(ChatColor.GREEN + "You have deleted a disguise profile with name " + ChatColor.RESET + name + ChatColor.GREEN + '.');
}
}

View File

@ -0,0 +1,89 @@
package rip.bridge.bridge.bukkit.commands.disguise.disguiseprofile;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.disguise.DisguisePlayer;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import java.util.Objects;
import java.util.regex.Pattern;
public class DisguiseProfileDisguiseCommand {
@Command(names = {"disguiseprofile disguise"}, permission = "bridge.disguise.admin", description = "Disguise other players", hidden = true)
public static void odisguise(Player sender, @Param(name = "player") String playerName, @Param(name = "rank") String rank, @Param(name = "name") String name, @Param(name = "skin") String skin) {
Player player = Bukkit.getPlayer(playerName);
if (player == null) {
for (DisguisePlayer disguisePlayer : BridgeGlobal.getDisguiseManager().getDisguisePlayers().values()) {
if (playerName.equalsIgnoreCase(disguisePlayer.getName())) {
Player dPlayer = Bukkit.getPlayer(disguisePlayer.getDisguiseName());
if (dPlayer != null) {
sender.sendMessage(ChatColor.RED + "That player is already disguised.");
return;
}
}
}
}
if (player == null) {
sender.sendMessage("§cNo player with the name" + " \"" + name + "\" found.");
return;
}
if (!Pattern.compile("^\\w{1,16}$").matcher(name).matches()) {
player.sendMessage(ChatColor.RED + "Invalid username: " + name);
return;
}
if (Bukkit.getPlayerExact(name) != null || Objects.requireNonNull(BridgeGlobal.getUsedDisguisedNames()).stream().anyMatch(n -> n.equalsIgnoreCase(name))) {
player.sendMessage(ChatColor.RED + "The name \"" + name + "\" is unavailable.");
return;
}
if (BukkitAPI.getProfile(name) != null && BukkitAPI.getPlayerRank(BukkitAPI.getProfile(name)).isStaff()) {
sender.sendMessage(ChatColor.RED + name + " exists as a Bridge player. You cannot impersonate others, please choose another name.");
return;
}
if (BukkitAPI.getProfile(name) != null) {
sender.sendMessage(ChatColor.RED + name + " exists as a Bridge player. You cannot impersonate others, please choose another name.");
return;
}
if (!Pattern.compile("^\\w{1,16}$").matcher(skin).matches()) {
sender.sendMessage(ChatColor.RED + "That is not a valid username.");
return;
}
Profile profile = BridgeGlobal.getProfileHandler().getProfileByUUID(sender.getUniqueId());
Rank current = profile.getCurrentGrant().getRank();
Rank select = BridgeGlobal.getRankHandler().getRankByName(rank);
if (select.getPriority() > current.getPriority()) {
sender.sendMessage(ChatColor.RED + "You are not allowed to set " + playerName + "'s tag to " + select.getColor() + select.getDisplayName() + ChatColor.RED + ".");
return;
}
DisguisePlayer disguisePlayer = new DisguisePlayer(player.getName());
disguisePlayer.setDisguiseRank(select);
disguisePlayer.setDisguiseName(name);
disguisePlayer.setDisguiseSkin(skin);
try {
if (BridgeGlobal.getDisguiseManager().disguise(player, disguisePlayer, null,false, true, false)) {
player.sendMessage(ChatColor.GREEN + "You have been manually disguised by a staff member.");
player.sendMessage(ChatColor.GREEN + "Success! You now look like " + select.getPrefix() + select.getColor() + name + ChatColor.GREEN + " (in the skin of " + ChatColor.YELLOW + skin + ChatColor.GREEN + ")!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,21 @@
package rip.bridge.bridge.bukkit.commands.disguise.disguiseprofile;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.disguise.DisguiseProfile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class DisguiseProfileInfoCommand {
@Command(names = {"disguiseprofile info"}, permission = "bridge.disguise.admin", description = "Get information about a disguise profile", hidden = true)
public static void disguiseprofileinfo(CommandSender s, @Param(name = "name") DisguiseProfile disguiseProfile) {
s.sendMessage(BukkitAPI.LINE);
s.sendMessage(disguiseProfile.getDisplayName() + " Disguise Profile §7❘ §fInformation");
s.sendMessage(BukkitAPI.LINE);
s.sendMessage("§6Name: §f" + disguiseProfile.getName() + " §7(" + net.md_5.bungee.api.ChatColor.stripColor(disguiseProfile.getDisplayName().replaceAll("§", "&")) + ")");
s.sendMessage("§6Display Name: §f" + disguiseProfile.getDisplayName() + " §7(" + net.md_5.bungee.api.ChatColor.stripColor(disguiseProfile.getDisplayName().replaceAll("§", "&")) + ")");
s.sendMessage("§6Skin: §f" + disguiseProfile.getSkinName());
s.sendMessage("");
}
}

View File

@ -0,0 +1,52 @@
package rip.bridge.bridge.bukkit.commands.disguise.disguiseprofile;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.disguise.DisguiseProfile;
import rip.bridge.qlib.command.Command;
import java.util.ArrayList;
public class DisguiseProfileListCommand {
@Command(names = {"disguiseprofile list"}, permission = "bridge.disguise.admin", description = "List all created disguise profiles", hidden = true)
public static void disguiseprofilelist(CommandSender s) {
s.sendMessage(BukkitAPI.LINE);
s.sendMessage("§6§lDisguise Profiles §f(" + BridgeGlobal.getDisguiseManager().getDisguiseProfiles().size() + ")");
s.sendMessage(BukkitAPI.LINE);
if (BridgeGlobal.getDisguiseManager().getDisguiseProfiles().isEmpty()) {
s.sendMessage(ChatColor.RESET + "No disguise profiles were created yet");
} else {
ArrayList<DisguiseProfile> disguiseProfiles = new ArrayList<>(BridgeGlobal.getDisguiseManager().getDisguiseProfiles().values());
disguiseProfiles.forEach(disguiseProfile -> {
if (s instanceof Player) {
ComponentBuilder cp = new ComponentBuilder(disguiseProfile.getDisplayName() + " §7❘ §f" + disguiseProfile.getName()).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
"§6Name: §f" + disguiseProfile.getName() + " §7(" + ChatColor.stripColor(disguiseProfile.getDisplayName().replaceAll("§", "&")) + ")" + "\n" +
"§6Display Name: §f" + disguiseProfile.getDisplayName() + " §7(" + ChatColor.stripColor(disguiseProfile.getDisplayName().replaceAll("§", "&")) + ")" + "\n" +
"§6Skin: §f" + disguiseProfile.getSkinName() + "\n\n" +
"§7§oClick for more information"
))).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/disguiseprofile info " + disguiseProfile.getName()));
((Player) s).spigot().sendMessage(cp.create());
} else {
s.sendMessage(disguiseProfile.getDisplayName() + " §7❘ §f" + disguiseProfile.getName());
s.sendMessage("§6Name: §f" + disguiseProfile.getName() + " §7(" + ChatColor.stripColor(disguiseProfile.getDisplayName().replaceAll("§", "&")) + ")");
s.sendMessage("§6Display Name: §f" + disguiseProfile.getDisplayName() + " §7(" + ChatColor.stripColor(disguiseProfile.getDisplayName().replaceAll("§", "&")) + ")");
s.sendMessage("§6Skin: §f" + disguiseProfile.getSkinName());
s.sendMessage("");
}
});
s.sendMessage("");
s.sendMessage(s instanceof Player ? "§7§oHover over the disguise profiles for more information." : "§7§oType /disguise profileinfo <disguiseProfile> for more information.");
s.sendMessage(BukkitAPI.LINE);
}
}
}

View File

@ -0,0 +1,21 @@
package rip.bridge.bridge.bukkit.commands.disguise.disguiseprofile;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.disguise.DisguiseProfile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class DisguiseProfileSetDisplayNameCommand {
@Command(names = {"disguiseprofile setdisplayname"}, permission = "bridge.disguise.admin", description = "Set a disguise profile display name", hidden = true)
public static void disguised(Player player, @Param(name = "name") String name, @Param(name = "displayName", wildcard = true) String displayName) {
DisguiseProfile profile = BridgeGlobal.getDisguiseManager().getProfile(name);
profile.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
BridgeGlobal.getDisguiseManager().saveProfiles(true);
player.sendMessage(ChatColor.GREEN + "You've changed display name of " + ChatColor.RESET + profile.getName() + ChatColor.GREEN + " to " + displayName + ChatColor.GREEN + '.');
}
}

View File

@ -0,0 +1,28 @@
package rip.bridge.bridge.bukkit.commands.disguise.disguiseprofile;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.disguise.DisguisePlayer;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class DisguiseProfileUnDisguiseCommand {
@Command(names = {"disguiseprofile undisguise"}, permission = "bridge.undisguise.admin", description = "UnDisguise other players", hidden = true)
public static void undisguiseprofile(Player player, @Param(name = "player") Player target) {
DisguisePlayer disguisePlayer = BridgeGlobal.getDisguiseManager().getDisguisePlayers().get(target.getUniqueId());
Profile target2 = BridgeGlobal.getProfileHandler().getProfileByUUID(target.getUniqueId());
if (disguisePlayer == null) {
player.sendMessage(ChatColor.RED + target2.getUsername() + " is not disguised!");
return;
}
player.sendMessage(ChatColor.GREEN + "You have removed the disguise of " + target2.getColor() + target2.getUsername() + ChatColor.GREEN + ".");
target.sendMessage(ChatColor.RED + "You have been manually undisguised by a staff member.");
target.sendMessage(ChatColor.GREEN + "Removing the disguise...");
BridgeGlobal.getDisguiseManager().undisguise(target, true, false);
}
}

View File

@ -0,0 +1,99 @@
package rip.bridge.bridge.bukkit.commands.disguise.menu;
import com.google.common.collect.Maps;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.bukkit.commands.grant.menu.grant.RankButton;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.Menu;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
public class DisguiseRankMenu extends Menu {
private String nickName;
private boolean real;
public DisguiseRankMenu(String nickName, boolean real) {
super(ChatColor.DARK_GRAY + "Pick a rank");
this.nickName = nickName;
this.real = real;
this.setPlaceholder(true);
}
@Override
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
List<Rank> ranks = BridgeGlobal.getRankHandler().getRanks().stream()
.filter(rank -> {
Profile profile = BukkitAPI.getProfile(player);
if(rank.isHidden() || !rank.isGrantable()) return false;
if(profile.hasPermission("bridge.disguise.all")) return true;
if(profile.hasPermission("bridge.disguise." + rank.getName().toLowerCase())) return true;
return Objects.requireNonNull(BukkitAPI.getPlayerRank(profile, true)).getPriority() >= rank.getPriority();
})
.sorted(Comparator.comparingInt(Rank::getPriority))
.collect(Collectors.toList());
int slot = 1;
for(Rank rank : ranks) {
buttons.put(slot, new Button() {
@Override
public String getName(Player player) {
return rank.getColor() + rank.getDisplayName();
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return Material.LEATHER_CHESTPLATE;
}
@Override
public byte getDamageValue(Player player) {
return 0;
}
@Override
public ItemStack getButtonItem(Player player) {
ItemStack item = super.getButtonItem(player);
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
meta.setColor(RankButton.getColor(rank.getColor().charAt(1)).getColor());
item.setItemMeta(meta);
return item;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
player.closeInventory();
Button.playSuccess(player);
new DisguiseSkinMenu(nickName, rank, false, real).openMenu(player);
}
});
slot += slot == 7 || slot == 16 || slot == 25 || slot == 34
|| slot == 43 || slot == 52 || slot == 61 || slot == 70 ? 3 : 2;
}
return buttons;
}
}

View File

@ -0,0 +1,464 @@
package rip.bridge.bridge.bukkit.commands.disguise.menu;
import com.google.common.collect.Maps;
import lombok.RequiredArgsConstructor;
import net.minecraft.server.v1_7_R4.GameProfileSerializer;
import net.minecraft.server.v1_7_R4.NBTTagCompound;
import net.minecraft.util.com.mojang.authlib.GameProfile;
import net.minecraft.util.com.mojang.authlib.properties.Property;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.conversations.*;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.disguise.DisguisePlayer;
import rip.bridge.bridge.global.disguise.DisguiseProfile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.bridge.global.util.mojang.GameProfileUtil;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.pagination.PaginatedMenu;
import rip.bridge.qlib.util.ItemBuilder;
import java.util.*;
import java.util.regex.Pattern;
@RequiredArgsConstructor
public class DisguiseSkinMenu extends PaginatedMenu {
private final String nickName;
private final Rank rank;
private final boolean skinCmd;
private final boolean real;
private static final GameProfile QUESTION_MARK_SKIN, STEVE_SKIN, ALEX_SKIN, DSKIN;
static {
QUESTION_MARK_SKIN = new GameProfile(UUID.randomUUID(), "__Q_MARK__");
QUESTION_MARK_SKIN.getProperties().put("textures", new Property("textures", "ewogICJ0aW1lc3RhbXAiIDogMTYzMjM1NTQwMTk5MSwKICAicHJvZmlsZUlkIiA6ICJkNTI0NjJmOTZlZjA0OThmODhhYzg4ZDI3ZjMyOGEzMCIsCiAgInByb2ZpbGVOYW1lIiA6ICJuaWd3YWciLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvY2ViYjQ3YTY1NDcyYjI4MjRmNDNjNDY0Yzc0NmI2Y2I3NGNmYmU5NWJkODk1MTM2Yjg3MWQ3ZTk3ZGM1NDY4MyIKICAgIH0sCiAgICAiQ0FQRSIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjM0MGMwZTAzZGQyNGExMWIxNWE4YjMzYzJhN2U5ZTMyYWJiMjA1MWIyNDgxZDBiYTdkZWZkNjM1Y2E3YTkzMyIKICAgIH0KICB9Cn0=", "jCNxGyWZtXrpgp9iA9z9/cpAkPcbXUz3QyQbBL9y58QaAvwpCC5t/0UReOBppIwS3Kye5JNf4W/sgk37+dSwej9ioiXAGQNQo56jCqaioaq4kKlaFls+dgbw2AJticzWsJicT70omH9O/NHV2kLP1RxPSQBQwkgnmmYBUtMYENf5S/zzUddZtbr3g0G5elpgwGuDaIJiNNdNTGwatUNfUlNLV/a9Z1nAniwfOUWul2U0tGTLnmrSyMLQe6auLyF/ddMneU1ecVTqjqUQZ8USOjva8N9tryRVGgkHujmMgd8zkOlU/FPxdLZeJoii4KQoSHznHx5IJplGvwEwUDR2cgNnzAzl7utMMRTC715TiLtcayqG3VJj1qRERt3uzDCBAidDcghwB+7GWkzZQ5Fq3P+pOGQdaOLyfiOoJojcKskPjAeGyLMq1rZd9VQ1RT/CuCCTgNhuIH8Ro4uyXXi18r63AMuHEhbzsD5wP+Okm6Z3SGzPJPOWQwQxHnmnO+6l11FZaMyJx68w90QCbmbiWXBDC89MVVLkl3rvUXmXKTr2N0HdjRY2uo4myqKugfR4ltT5jNMHLBy2yAg/dt/RminWB3SFbqFaK9iNam2XpOBW+q9Ihrmd81dfLhl663ORN+ikkiZzO2AZozvWCNx36snAPpMeBhs4f4Aehux+DH4="));
GameProfileUtil.getSkinCache().put(QUESTION_MARK_SKIN.getName().toLowerCase(), QUESTION_MARK_SKIN);
DSKIN = new GameProfile(UUID.randomUUID(), "__D_SKIN__");
DSKIN.getProperties().put("textures", new Property("textures", "ewogICJ0aW1lc3RhbXAiIDogMTYwNTgwNjE3MDgyNSwKICAicHJvZmlsZUlkIiA6ICIzY2FjYjhkY2YyMzk0ZDgwOTZiMWIyMmUzNjQ2MDlmYyIsCiAgInByb2ZpbGVOYW1lIiA6ICJjcmVlcGVyX2dvZDIiLAogICJzaWduYXR1cmVSZXF1aXJlZCIgOiB0cnVlLAogICJ0ZXh0dXJlcyIgOiB7CiAgICAiU0tJTiIgOiB7CiAgICAgICJ1cmwiIDogImh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWE2ZTRjNTY1NDhiZmM0NjRmZGQ1NmJkMGViMmE2NGEzZWNiMTY4MWVhMDk5MWM0ZWY3NzFmNmQxMThiNGMzYyIKICAgIH0KICB9Cn0=", "FpKriqMG97l8aCmUfsa0Dq8ArVPCFiw6Mt2HwIwxHKUXKfhEK074MyeZwV5MQKaK/kEkqgYrCVK1Upm4y+SIp1znmoz9Qdb9lfdctXwznjwNW6x60qP9u5Wadg9T2CBw3KkogSTlFJpeiKnOb9bT4IezQgu8fL1Or5yX5LGkxrcZpDpCGJgENmLPdwoSaZxfZbOEnEGKRNrhqnPm29ScuUAf3JtQGccElXlJ4wBH02ZbuoFA75mnbCMixNmgiBpBIhqzAq7at+YrFqU1Nn6MYokFP91EbQvfxHP9vNN5ANJVDuhUPHNAvwK3M4XYthJ01Vm0oCRO/WqKDZCepV5j3pAZHKGA9ubeKAA2zTWwILxjgx1BaKBYO9idTdhI5RgsK78hg2ICD6ySZ7S+WFLYx7gTHSgp+TFaMsqeHHy5XGUHFUj7FOAktTu/lMs9KjK8n1FM5V3JDvAU5c7xuuErQ3HoYc5wO+Wm2gj9i5LBucU9qWlVSO51W1guwTSD9U8kzuw8Z4xoikF6of0/ZtmMjUneOGnzDqV2wNKnDbV/V5ASSVDjERvQCyK44YS1w9oO/p3ROjdhuN+JWP4zPCmfFdDxhgLcEhrTBcm7kBNx+b6agudfz4i6i7dAPN2W5AZ2RKbc60kkJncxtgfvfLk3Gw1j8TLAT1EjyDnhcMRitXY="));
STEVE_SKIN = new GameProfile(UUID.randomUUID(), "Steve");
STEVE_SKIN.getProperties().put("textures", new Property("textures", "ewogICJ0aW1lc3RhbXAiIDogMTYwNTYxMTkyMjAyNywKICAicHJvZmlsZUlkIiA6ICJiOTgzZmU5YWJjMWI0MTkwYjIxZTUxZmU0Yjg3OTcxNCIsCiAgInByb2ZpbGVOYW1lIiA6ICI5Z3lhciIsCiAgInNpZ25hdHVyZVJlcXVpcmVkIiA6IHRydWUsCiAgInRleHR1cmVzIiA6IHsKICAgICJTS0lOIiA6IHsKICAgICAgInVybCIgOiAiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS82ZDNiMDZjMzg1MDRmZmMwMjI5Yjk0OTIxNDdjNjlmY2Y1OWZkMmVkNzg4NWY3ODUwMjE1MmY3N2I0ZDUwZGUxIiwKICAgICAgIm1ldGFkYXRhIiA6IHsKICAgICAgICAibW9kZWwiIDogInNsaW0iCiAgICAgIH0KICAgIH0KICB9Cn0=", "nquy5XsHlcsQn0QTFW0vOVnodhCizG3VlfPtqgkqmTliNsuWd+GxdUV6u00eOhmYrkHOtD52eWF0tYG+j/BYUBwE2SvZHt3V7OjAO3OzMy8sNzuyymEfzoqFXB2+IBAAbWi54TZHI4l03wtDFuUNBhPZ/q0h9KmasFv8zTfCht+TEThmp7gjCkmAs6Tkr1jqAQyQfCQCQwBN0a8Rx0NzsGJAOvQFmfdksxuLzckR8abt9Qb39QXulFAKqkNoVYajvRxG21WTELgJEM+nuVInt0QT91t6Al1E7xExCbrOJITomk2CLAHSJzTx0QBYmKMbPeuXcR1jT50FA4qzqY5LsmmVWb1PkaucFQ2+tHHKncNg44XMju2PaNNLFek39AhOp4FnyLHBK5RuCJEcv0ybcNyCxFmKBSb5Ryv+XxsQQjzcT0fSc5png0NvBVknk4KnWkuimMJp84nBSzJ9htS38mOZWdFcj61ulqk99+7wJfqO8OgtOlfn4Hpk6rbVcFtARnW8TQIPcNzX6/B385fARO5VwFmts7UVxRGenQOJwzbezGPKBTfQyODpPxX2DYTR4v8fGfVpaO3ZReq0vDLvl/x5CpyFISJhorfZSIiAXJeRRKj8qHr6eM1lqzkzwu6tUV8nITzg/QxVuOddik01HJritR/iTgfrCQNI2fjhJY8="));
GameProfileUtil.getSkinCache().put(STEVE_SKIN.getName().toLowerCase(), STEVE_SKIN);
ALEX_SKIN = new GameProfile(UUID.randomUUID(), "Alex");
ALEX_SKIN.getProperties().put("textures", new Property("textures", "ewogICJ0aW1lc3RhbXAiIDogMTYwNTYxMTgxNjQ1NiwKICAicHJvZmlsZUlkIiA6ICIwNDQ4NzNiYTMzZDI0Y2Q4YTQ1M2M4ODkwYTFjODM4MCIsCiAgInByb2ZpbGVOYW1lIiA6ICJMQVNEIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzNiNjBhMWY2ZDU2MmY1MmFhZWJiZjE0MzRmMWRlMTQ3OTMzYTNhZmZlMGU3NjRmYTQ5ZWEwNTc1MzY2MjNjZDMiLAogICAgICAibWV0YWRhdGEiIDogewogICAgICAgICJtb2RlbCIgOiAic2xpbSIKICAgICAgfQogICAgfQogIH0KfQ==", "u0w6ba9InsC1Nj1xRxO5Jl6XsiuKEP0oMDQEBGoEEZJ8+thETE2Ics2lRY0jTKkboJV+7FwJunkYCJyoR6sRKYsXW6z5FOxsvCu9biAwIEcmRXljBUnIMzhefCqovZJ07AjA0rM8aKSH9V47BbpfGzBgSaLukdem0VpvV4LfZFIGTvqEZD6QnlYDQUJNEDaIac1X4xOJlPXzXV0d7EwSZSa6zKv6nswgbsp3aWleJoUoXhjqB3Em5wbdJbbvDdr0v7PPPYVzgS2sqD+RpUap21jG8teb4Wan4qjZQLTbmRxJE68IMaaylygwJFinxViZw3ubV7uTz26BSAhvOQ2wLpcNtTqqr+8atIA1+C5ijhBmQLEH6U2aYb7K+qF83YhxTzFeeoHcdoDNHC+7LDgEFEnM0hpIuHPTho2uTJtvAHx2iuLd/Kzau+EFyZDlKHowN7UW6LwNXRldTPr5DHBEuAMTiSGBivYZi778Hx8b3fpb6I7rUN5o4l3RdktCPlrElPnmEYXBGH+4ZLkeNxajCMxvm0WJFEouQcpnxKmON4z9Q6bduFdSqgm+huGACPhMG41J2f6fsnTOFKQDluyekF1ur3KoNCdqEYMDqXHmSobRaaKhvoclQuO1oxjFkFAiKox5cOAOf+pmhwbgq9a26n6MzvYvLb+tVXkbN9V6ewQ="));
GameProfileUtil.getSkinCache().put(ALEX_SKIN.getName().toLowerCase(), ALEX_SKIN);
}
@Override
public String getPrePaginatedTitle(Player player) {
return ChatColor.DARK_GRAY + "Pick a skin";
}
@Override
public int getMaxItemsPerPage(Player player) {
return 36;
}
@Override
public Map<Integer, Button> getAllPagesButtons(Player player) {
HashMap<Integer, Button> buttons = Maps.newHashMap();
int slot = 0;
for(DisguiseProfile profile : BridgeGlobal.getDisguiseManager().getDisguiseProfiles().values()) {
buttons.put(slot++, new Button() {
@Override
public String getName(Player player) {
return null;
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return null;
}
@Override
public ItemStack getButtonItem(Player player) {
ItemStack stack = ItemBuilder.of(Material.SKULL_ITEM)
.data((short) 3)
.name(profile.getDisplayName() != null ? ChatColor.translateAlternateColorCodes('&', profile.getDisplayName()) : ChatColor.BLUE + profile.getName())
.setLore(Collections.singletonList("")).build();
net.minecraft.server.v1_7_R4.ItemStack item = CraftItemStack.asNMSCopy(stack);
GameProfile gameProfile = GameProfileUtil.getSkinCache().get(profile.getName().toLowerCase());
NBTTagCompound nbtTagCompound = new NBTTagCompound();
if (gameProfile == null) {
gameProfile = new GameProfile(profile.getSkin().getProfileUuid(), profile.getName());
gameProfile.getProperties().put("textures", profile.getSkin().getProperty());
GameProfileUtil.getSkinCache().put(profile.getName().toLowerCase(), gameProfile);
}
GameProfileSerializer.serialize(nbtTagCompound, gameProfile);
NBTTagCompound itemNbtTag = item.getTag();
itemNbtTag.set("SkullOwner", nbtTagCompound);
stack = CraftItemStack.asCraftMirror(item);
return stack;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
player.closeInventory();
Button.playSuccess(player);
disguise(player, rank, profile.getSkinName(), nickName, profile.getDisplayName() != null ? ChatColor.translateAlternateColorCodes('&', profile.getDisplayName()) : profile.getSkinName(), profile.getName());
}
});
}
return buttons;
}
@Override
public Map<Integer, Button> getGlobalButtons(Player player) {
HashMap<Integer, Button> buttons = Maps.newHashMap();
buttons.put(1, new Button() {
@Override
public String getName(Player player) {
return null;
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return null;
}
@Override
public ItemStack getButtonItem(Player player) {
ItemStack stack = ItemBuilder.of(Material.SKULL_ITEM)
.data((short) 3)
.name(ChatColor.BLUE + "Your Own")
.setLore(Collections.singletonList("")).build();
net.minecraft.server.v1_7_R4.ItemStack item = CraftItemStack.asNMSCopy(stack);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
GameProfileSerializer.serialize(nbtTagCompound, ((CraftPlayer) player).getProfile());
NBTTagCompound itemNbtTag = item.getTag();
itemNbtTag.set("SkullOwner", nbtTagCompound);
stack = CraftItemStack.asCraftMirror(item);
return stack;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
player.closeInventory();
Button.playSuccess(player);
DisguisePlayer disguisePlayer = BridgeGlobal.getDisguiseManager().getDisguisePlayers().get(player.getUniqueId());
disguise(player, rank, player.getName(), nickName, disguisePlayer != null ? disguisePlayer.getName() : player.getName());
}
});
buttons.put(2, new Button() {
@Override
public String getName(Player player) {
return null;
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return null;
}
@Override
public ItemStack getButtonItem(Player player) {
ItemStack stack = ItemBuilder.of(Material.SKULL_ITEM)
.data((short) 3)
.name(ChatColor.BLUE + "Random")
.setLore(Collections.singletonList("")).build();
net.minecraft.server.v1_7_R4.ItemStack item = CraftItemStack.asNMSCopy(stack);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
GameProfileSerializer.serialize(nbtTagCompound, QUESTION_MARK_SKIN);
NBTTagCompound itemNbtTag = item.getTag();
itemNbtTag.set("SkullOwner", nbtTagCompound);
stack = CraftItemStack.asCraftMirror(item);
return stack;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
player.closeInventory();
Button.playSuccess(player);
DisguiseProfile profile = BridgeGlobal.getDisguiseManager().getRandomDisguiseProfile();
if(profile == null) {
player.sendMessage(ChatColor.RED + "Failed to find random disguise profile.");
return;
}
disguise(player, rank, profile.getSkinName(), nickName, profile.getDisplayName() != null ? ChatColor.translateAlternateColorCodes('&', profile.getDisplayName()) : profile.getSkinName());
}
});
buttons.put(3, new Button() {
@Override
public String getName(Player player) {
return ChatColor.BLUE + "Pick a Name";
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return Material.SIGN;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
player.closeInventory();
Button.playSuccess(player);
ConversationFactory factory = new ConversationFactory(Bridge.getInstance())
.withModality(true)
.withPrefix(new NullConversationPrefix())
.withFirstPrompt(new StringPrompt() {
@Override
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Enter a name of a player using your desired skin:";
}
@Override
public Prompt acceptInput(ConversationContext context, String input) {
if(!Pattern.compile("^\\w{1,16}$").matcher(input).matches()) {
player.sendMessage(ChatColor.RED + "Invalid username: " + input);
String realName = GameProfileUtil.getRealName(input);
new DisguiseSkinMenu(nickName, rank, skinCmd, realName != null).openMenu(player);
return Prompt.END_OF_CONVERSATION;
}
disguise(player, rank, input, nickName, input);
return Prompt.END_OF_CONVERSATION;
}
})
.withLocalEcho(false)
.withEscapeSequence("/no")
.withTimeout(10)
.thatExcludesNonPlayersWithMessage("Go away evil console!");
player.beginConversation(factory.buildConversation(player));
}
});
buttons.put(4, Button.placeholder(Material.STAINED_GLASS_PANE, (byte) 7, " "));
buttons.put(5, new Button() {
@Override
public String getName(Player player) {
return null;
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return null;
}
@Override
public ItemStack getButtonItem(Player player) {
ItemStack stack = ItemBuilder.of(Material.SKULL_ITEM)
.data((short) 3)
.name(ChatColor.BLUE + nickName)
.setLore(Collections.singletonList("")).build();
net.minecraft.server.v1_7_R4.ItemStack item = CraftItemStack.asNMSCopy(stack);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
GameProfileSerializer.serialize(nbtTagCompound, DSKIN);
NBTTagCompound itemNbtTag = item.getTag();
itemNbtTag.set("SkullOwner", nbtTagCompound);
stack = CraftItemStack.asCraftMirror(item);
return stack;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
player.closeInventory();
Button.playSuccess(player);
int version = ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion();
disguise(player, rank, real ? nickName : version == 47 ? ALEX_SKIN.getName() : STEVE_SKIN.getName(), nickName, nickName);
}
});
buttons.put(6, new Button() {
@Override
public String getName(Player player) {
return null;
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return null;
}
@Override
public ItemStack getButtonItem(Player player) {
ItemStack stack = ItemBuilder.of(Material.SKULL_ITEM)
.data((short) 3)
.name(ChatColor.BLUE + "Steve")
.setLore(Collections.singletonList("")).build();
net.minecraft.server.v1_7_R4.ItemStack item = CraftItemStack.asNMSCopy(stack);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
GameProfileSerializer.serialize(nbtTagCompound, STEVE_SKIN);
NBTTagCompound itemNbtTag = item.getTag();
itemNbtTag.set("SkullOwner", nbtTagCompound);
stack = CraftItemStack.asCraftMirror(item);
return stack;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
player.closeInventory();
Button.playSuccess(player);
disguise(player, rank, STEVE_SKIN.getName(), nickName, "Steve");
}
});
buttons.put(7, new Button() {
@Override
public String getName(Player player) {
return null;
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return null;
}
@Override
public ItemStack getButtonItem(Player player) {
ItemStack stack = ItemBuilder.of(Material.SKULL_ITEM)
.data((short) 3)
.name(ChatColor.BLUE + "Alex")
.setLore(Collections.singletonList("")).build();
net.minecraft.server.v1_7_R4.ItemStack item = CraftItemStack.asNMSCopy(stack);
NBTTagCompound nbtTagCompound = new NBTTagCompound();
GameProfileSerializer.serialize(nbtTagCompound, ALEX_SKIN);
NBTTagCompound itemNbtTag = item.getTag();
itemNbtTag.set("SkullOwner", nbtTagCompound);
stack = CraftItemStack.asCraftMirror(item);
return stack;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
player.closeInventory();
Button.playSuccess(player);
disguise(player, rank, ALEX_SKIN.getName(), nickName, "Alex");
}
});
return buttons;
}
private void disguise(Player player, Rank rank, String skin, String name, String skinName) {
this.disguise(player, rank, skin, name, skinName, null);
}
private void disguise(Player player, Rank rank, String skin, String name, String skinName, String profileName) {
try {
// disguise(player, rank, player.getName(), nickName, disguisePlayer != null ? disguisePlayer.getName() : player.getName());
DisguisePlayer disguisePlayer = new DisguisePlayer(player.getName());
disguisePlayer.setDisguiseRank(rank);
disguisePlayer.setDisguiseName(name);
disguisePlayer.setDisguiseSkin(skin);
if(BridgeGlobal.getDisguiseManager().disguise(player, disguisePlayer, profileName,false, true, !this.skinCmd)) {
player.sendMessage(ChatColor.GREEN + "Success! You now look like " + this.rank.getPrefix() + this.rank.getColor() + this.nickName + ChatColor.GREEN + (!name.equals(skin) && !name.equals(ChatColor.stripColor(skinName)) ? " (in the skin of " + ChatColor.YELLOW + ChatColor.stripColor(skinName) + ChatColor.GREEN + ")" : "") + "!");
String realName = GameProfileUtil.getRealName(this.nickName);
if (realName != null) {
player.sendMessage(ChatColor.RED + this.nickName + " is an existing Minecraft player, so if they log on for the first time as you're disguised, you will be kicked.");
}
String realSkin = GameProfileUtil.getRealName(skin);
if (realSkin == null && BridgeGlobal.getDisguiseManager().getDisguiseProfiles().values().stream().noneMatch(p -> p.getSkinName().equalsIgnoreCase(skin)) || skin.equals(STEVE_SKIN.getName()) || skin.equals(ALEX_SKIN.getName())) {
player.sendMessage(ChatColor.YELLOW + "Note: You will look like " + (skin.equals("Alex") ? "Alex" : "Steve") + " since the account \"" + skin + "\" does not exist.");
}
/*
String realName = GameProfileUtil.getRealName(this.nickName);
if (realName != null) {
player.sendMessage(ChatColor.RED + this.nickName + " is an existing Minecraft player, so if they log on for the first time as you're disguised, you will be kicked.");
} else {
String realSkin = GameProfileUtil.getRealName(skin);
if (realSkin != null) {
player.sendMessage(ChatColor.YELLOW + "Note: You will look like Steve since the account \"" + skin + "\" does not exist.");
}
}
*/
}
} catch (Exception e) {
e.printStackTrace();
player.sendMessage(ChatColor.RED + "Something went wrong while disguising you! Please contact a staff member or any online developer.");
}
}
}

View File

@ -0,0 +1,27 @@
package rip.bridge.bridge.bukkit.commands.filter;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.parameters.packets.filter.FilterCreatePacket;
import rip.bridge.bridge.global.filter.Filter;
import rip.bridge.bridge.global.filter.FilterType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import rip.bridge.qlib.xpacket.FrozenXPacketHandler;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class FilterCreateCommand {
@Command(names = "filter create", permission = "bridge.filter", description = "Create a filter", hidden = true)
public static void create(CommandSender sender, @Param(name = "filterType") FilterType filterType, @Param(name = "pattern", wildcard = true) String pattern) {
Filter filter = BridgeGlobal.getFilterHandler().getFilter(pattern);
if (filter != null) {
sender.sendMessage(ChatColor.RED + "This filter already exists");
return;
}
(filter = new Filter(filterType, pattern)).save();
BridgeGlobal.getFilterHandler().addFilter(filter);
FrozenXPacketHandler.sendToAll(new FilterCreatePacket(filter, Bukkit.getServerName()));
sender.sendMessage(ChatColor.GREEN + "Successfully created the filter.");
}
}

View File

@ -0,0 +1,30 @@
package rip.bridge.bridge.bukkit.commands.filter;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.parameters.packets.filter.FilterCreatePacket;
import rip.bridge.bridge.global.filter.Filter;
import rip.bridge.bridge.global.filter.FilterType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import rip.bridge.qlib.xpacket.FrozenXPacketHandler;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class FilterCreateMuteCommand {
@Command(names = "filter create mute", permission = "bridge.filter", description = "Create a mute filter", hidden = true)
public static void create(CommandSender sender, @Param(name = "filterType") FilterType filterType, @Param(name = "duration") Long duration, @Param(name = "pattern", wildcard = true) String pattern) {
Filter filter = BridgeGlobal.getFilterHandler().getFilter(pattern);
if (filter != null) {
sender.sendMessage(ChatColor.RED + "This filter already exists");
return;
}
(filter = new Filter(filterType, pattern, duration)).save();
BridgeGlobal.getFilterHandler().addFilter(filter);
FrozenXPacketHandler.sendToAll(new FilterCreatePacket(filter, Bukkit.getServerName()));
sender.sendMessage(ChatColor.GREEN + "Successfully created the filter.");
}
}

View File

@ -0,0 +1,20 @@
package rip.bridge.bridge.bukkit.commands.filter;
import rip.bridge.bridge.bukkit.parameters.packets.filter.FilterDeletePacket;
import rip.bridge.bridge.global.filter.Filter;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import rip.bridge.qlib.xpacket.FrozenXPacketHandler;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class FilterDeleteCommand {
@Command(names = "filter delete", permission = "bridge.filter", description = "Delete a filter", hidden = true)
public static void delete(CommandSender sender, @Param(name = "filter", wildcard = true) Filter filter) {
filter.delete();
FrozenXPacketHandler.sendToAll(new FilterDeletePacket(filter, Bukkit.getServerName()));
sender.sendMessage(ChatColor.GREEN + "Successfully deleted the filter.");
}
}

View File

@ -0,0 +1,40 @@
package rip.bridge.bridge.bukkit.commands.filter;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.filter.FilterAction;
import rip.bridge.bridge.global.util.TimeUtil;
import rip.bridge.qlib.command.Command;
import mkremins.fanciful.FancyMessage;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.List;
public class FilterListCommand {
@Command(names = "filter list", permission = "bridge.filter", description = "List all created filters", hidden = true)
public static void filter(CommandSender sender) {
sender.sendMessage(ChatColor.BLUE.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 34));
BridgeGlobal.getFilterHandler().getFilters().forEach(filter -> {
FancyMessage fancyMessage = new FancyMessage(ChatColor.RED + (isLong(filter.getPattern()) ? filter.getPattern().substring(0, 20) + "..." : filter.getPattern()));
if (isLong(filter.getPattern())) {
List<String> lore = new ArrayList<>();
int index = 0;
while (index < filter.getPattern().length()) {
lore.add(filter.getPattern().substring(index, Math.min(index + 40, filter.getPattern().length())));
index += 40;
}
fancyMessage.tooltip(lore);
}
fancyMessage.then(ChatColor.GRAY + " - " + "[" + filter.getFilterType().name() + "]" + (filter.getFilterAction() == FilterAction.MUTE ? " - Mute: " + TimeUtil.millisToTimer(filter.getMuteTime()) : ""));
fancyMessage.send(sender);
});
sender.sendMessage(ChatColor.BLUE.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 34));
}
private static boolean isLong(String filter) {
return filter.length() > 20;
}
}

View File

@ -0,0 +1,25 @@
package rip.bridge.bridge.bukkit.commands.filter;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.filter.Filter;
import rip.bridge.bridge.global.filter.FilterAction;
import rip.bridge.bridge.global.util.TimeUtil;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class FilterTestCommand {
@Command(names = "filter test", permission = "bridge.filter", description = "Test a filter", hidden = true)
public static void test(CommandSender sender, @Param(name = "message", wildcard = true) String message) {
Filter filter = BridgeGlobal.getFilterHandler().isViolatingFilter(message);
if(filter == null) {
sender.sendMessage(ChatColor.GREEN + "This message is not filtered.");
return;
}
sender.sendMessage(ChatColor.RED + "Your message currently flags for the filter: " + filter.getPattern());
if(filter.getFilterAction() == FilterAction.MUTE) sender.sendMessage(ChatColor.RED + "This message would of caused you to be muted for " + TimeUtil.millisToTimer(filter.getMuteTime()));
}
}

View File

@ -0,0 +1,37 @@
package rip.bridge.bridge.bukkit.commands.filter;
import lombok.Getter;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.qlib.command.Command;
import java.util.*;
public class ToggleFilterCommand {
@Getter
private final static Map<UUID, String> filter = new HashMap<>();
@Command(names = "togglefilter", permission = "basic.staff", description = "Toggle filter alerts", hidden = true)
public static void toggle(Player player) {
String value = filter.getOrDefault(player.getUniqueId(), "global");
switch (value) {
case "global": {
filter.put(player.getUniqueId(), "server");
player.sendMessage(ChatColor.YELLOW + "You have now limited your filter messages to " + ChatColor.LIGHT_PURPLE + "local server" + ChatColor.YELLOW + ".");
return;
}
case "server": {
filter.put(player.getUniqueId(), "off");
player.sendMessage(ChatColor.RED + "You have disabled your filter messages.");
return;
}
case "off": {
filter.put(player.getUniqueId(), "global");
player.sendMessage(ChatColor.YELLOW + "You have now limited your filter messages to " + ChatColor.LIGHT_PURPLE + "global network" + ChatColor.YELLOW + ".");
}
}
}
}

View File

@ -0,0 +1,27 @@
package rip.bridge.bridge.bukkit.commands.grant;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.bridge.bridge.bukkit.commands.punishment.menu.MainPunishmentMenu;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
public class ClearGrantsCommand {
@Command(names = {"cleargrants"}, permission = "bridge.cleargrants", description = "Clear player's grants from the entire network", async = true)
public static void clearGrants(CommandSender s, @Param(name = "target") Profile target) {
if (target.getGrants().isEmpty()) {
s.sendMessage(ChatColor.RED + target.getUsername() + " does not have any grants.");
return;
}
s.sendMessage(ChatColor.GREEN + "Successfully cleared " + target.getCurrentGrant().getRank().getColor() + target.getUsername() + ChatColor.GREEN + "'s grants.");
target.getGrants().clear();
target.saveProfile();
}
}

View File

@ -0,0 +1,15 @@
package rip.bridge.bridge.bukkit.commands.grant;
import rip.bridge.bridge.bukkit.commands.grant.menu.grant.RanksMenu;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import org.bukkit.entity.Player;
public class GrantCommand {
@Command(names = "grant", permission = "bridge.grant", description = "Add a grant to an player's account", async = true)
public static void grantCmd(Player p, @Param(name = "player") Profile target) {
new RanksMenu(target.getUsername(), target.getUuid()).openMenu(p);
}
}

View File

@ -0,0 +1,43 @@
package rip.bridge.bridge.bukkit.commands.grant;
import mkremins.fanciful.FancyMessage;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.bukkit.commands.grant.menu.grants.GrantsMenu;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.stream.Collectors;
public class GrantsCommand {
@Command(names = "grants", permission = "bridge.grants", description = "Check a player's grants", async = true)
public static void grantsCmd(Player sender, @Flag(value = {"w", "website"}, description = "Check a player's active grants through the website") boolean website, @Param(name = "player", extraData = "get") Profile profile) {
if (BukkitAPI.getPlayerRank(profile, true).getPriority() > BukkitAPI.getPlayerRank(sender, true).getPriority()) {
sender.sendMessage(ChatColor.RED + "You cannot view the grants of \"" + (profile.getDisguise() != null ? profile.getDisguise().getDisguiseName() : profile.getUsername()) + "\".");
return;
}
if (website) {
FancyMessage message = new FancyMessage(org.bukkit.ChatColor.GREEN + "[Click Here]" + org.bukkit.ChatColor.YELLOW + " to view all of " + profile.getUsername() + "'s grants");
message.tooltip(org.bukkit.ChatColor.GRAY + "Click here: https://www.bridge.rip/u/" + profile.getUsername() + "/grants").link("https://www.bridge.rip/u/" + profile.getUsername() + "/grants");
message.send(sender);
} else {
List<Grant> allGrants = profile.getGrants().stream().filter(grant -> !grant.getRank().isDefaultRank()).sorted((first, second) -> {
if (first.getInitialTime() > second.getInitialTime()) {
return -1;
} else {
return 1;
}
}).collect(Collectors.toList());
new GrantsMenu(profile, allGrants).openMenu(sender);
}
}
}

View File

@ -0,0 +1,30 @@
package rip.bridge.bridge.bukkit.commands.grant;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.bridge.global.util.TimeUtil;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import org.apache.commons.lang.StringUtils;
import org.bukkit.command.CommandSender;
import java.util.Arrays;
import java.util.List;
public class OGrantCommand {
@Command(names = {"ogrant"}, permission = "bridge.ogrant", description = "Add a grant to an player's account", async = true)
public static void consolegrantCmd(CommandSender s, @Param(name = "player") Profile pf, @Param(name = "rank") Rank r, @Param(name = "duration") String l, @Param(name = "scopes") String scope, @Param(name = "reason", wildcard = true) String reason) {
if (!r.isGrantable()) {
s.sendMessage("§cThis rank is not grantable.");
return;
}
List<String> scopes = Arrays.asList(scope.split(","));
long length = (l.equalsIgnoreCase("Permanent") ? Long.MAX_VALUE : TimeUtil.parseTime(l));
pf.applyGrant(new Grant(r, length, scopes, reason, Profile.getConsoleProfile().getUuid().toString(), BridgeGlobal.getSystemName()), null);
pf.saveProfile();
s.sendMessage("§aSuccessfully granted " + pf.getUsername() + " the rank " + r.getDisplayName() + " on the scopes: " + StringUtils.join(scopes, ", "));
}
}

View File

@ -0,0 +1,17 @@
package rip.bridge.bridge.bukkit.commands.grant.events;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.bukkit.util.BaseEvent;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.UUID;
@AllArgsConstructor
@Getter
public class GrantCreateEvent extends BaseEvent {
private UUID uuid;
private Grant grant;
}

View File

@ -0,0 +1,17 @@
package rip.bridge.bridge.bukkit.commands.grant.events;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.bukkit.util.BaseEvent;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.UUID;
@AllArgsConstructor
@Getter
public class GrantRemoveEvent extends BaseEvent {
private UUID uuid;
private Grant grant;
}

View File

@ -0,0 +1,17 @@
package rip.bridge.bridge.bukkit.commands.grant.events;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.bukkit.util.BaseEvent;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.UUID;
@AllArgsConstructor
@Getter
public class GrantUpdateEvent extends BaseEvent {
private UUID uuid;
private Grant grant;
}

View File

@ -0,0 +1,43 @@
package rip.bridge.bridge.bukkit.commands.grant.menu.grant;
import com.google.common.collect.ImmutableList;
import rip.bridge.qlib.menu.Button;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.List;
public class GlobalButton extends Button {
private ScopesMenu parent;
public String getName(Player player) {
return ChatColor.BLUE + "Global";
}
public List<String> getDescription(Player player) {
return ImmutableList.of();
}
public Material getMaterial(Player player) {
return Material.WOOL;
}
public byte getDamageValue(Player player) {
return this.parent.isGlobal() ? DyeColor.LIME.getWoolData() : DyeColor.GRAY.getWoolData();
}
public void clicked(Player player, int i, ClickType clickType) {
for (String key : this.parent.getStatus().keySet()) {
this.parent.getStatus().put(key, false);
}
this.parent.setGlobal(!this.parent.isGlobal());
}
public GlobalButton(ScopesMenu parent) {
this.parent = parent;
}
}

View File

@ -0,0 +1,84 @@
package rip.bridge.bridge.bukkit.commands.grant.menu.grant;
import com.google.common.collect.Lists;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.bukkit.commands.grant.events.GrantCreateEvent;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.GrantCreatePacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.util.TimeUtils;
import lombok.AllArgsConstructor;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
@AllArgsConstructor
public class GrantButton extends Button {
private Rank rank;
private String targetName;
private UUID targetUUID;
private String reason;
private ScopesMenu parent;
private List<String> scopes;
private long duration;
public String getName(Player player) {
return ChatColor.GREEN + "Confirm and Grant";
}
public List<String> getDescription(Player player) {
List<String> description = Lists.newArrayList();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 30));
description.add(ChatColor.BLUE + "Click to add the " + ChatColor.WHITE + this.rank.getColor() + this.rank.getDisplayName() + ChatColor.BLUE + " to " + ChatColor.WHITE + this.targetName + ChatColor.BLUE + ".");
if (this.parent.isGlobal()) {
description.add(ChatColor.BLUE + "This grant will be " + ChatColor.WHITE + "Global" + ChatColor.BLUE + ".");
}
else {
List<String> scopes = new ArrayList<>(this.scopes);
description.add(ChatColor.BLUE + "This grant will apply on: " + ChatColor.WHITE + scopes.toString());
}
description.add(ChatColor.BLUE + "Reasoning: " + ChatColor.WHITE + this.reason);
description.add(ChatColor.BLUE + "Duration: " + ChatColor.WHITE + ((this.duration < Long.MAX_VALUE) ? TimeUtils.formatIntoDetailedString((int) (this.duration / 1000)) : "Permanent"));
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 30));
return description;
}
public Material getMaterial(Player player) {
return Material.DIAMOND_SWORD;
}
public byte getDamageValue(Player player) {
return 0;
}
public void clicked(Player player, int i, ClickType clickType) {
this.grant(this.targetUUID, this.targetName, this.reason, this.scopes, this.rank, this.duration, player);
player.closeInventory();
}
private void grant(UUID user, String targetName, String reason, List<String> scopes, Rank rank, long duration, Player sender) {
List<String> finalScopes = (this.parent.isGlobal() || scopes.isEmpty() ? new ArrayList< >(Collections.singleton("Global")) : scopes.stream().map(s -> "GR-" + s).collect(Collectors.toList()));
Grant grant;
Profile pr = BukkitAPI.getProfile(user);
pr.applyGrant((grant=new Grant(rank, duration, finalScopes, reason, sender.getUniqueId().toString(), BridgeGlobal.getSystemName())), sender.getUniqueId());
pr.saveProfile();
PacketHandler.sendToAll(new GrantCreatePacket(grant, user, sender.getDisplayName(), BridgeGlobal.getSystemName()));
new GrantCreateEvent(pr.getUuid(), grant).call();
sender.sendMessage(ChatColor.GREEN + "Successfully granted " + ChatColor.WHITE + targetName + ChatColor.GREEN + " the " + ChatColor.WHITE + rank.getColor() + rank.getDisplayName() + ChatColor.GREEN + " rank.");
this.parent.setComplete(true);
}
}

View File

@ -0,0 +1,146 @@
package rip.bridge.bridge.bukkit.commands.grant.menu.grant;
import com.google.common.collect.Lists;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.bridge.global.util.TimeUtil;
import rip.bridge.qlib.menu.Button;
import lombok.AllArgsConstructor;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.conversations.*;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.UUID;
@AllArgsConstructor
public class RankButton extends Button
{
private String targetName;
private UUID targetUUID;
private Rank rank;
public String getName(Player player) {
return this.rank.getColor() + this.rank.getDisplayName();
}
public List<String> getDescription(Player player) {
List<String> description = Lists.newArrayList();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 30));
description.add(ChatColor.BLUE + "Click to grant " + ChatColor.WHITE + this.targetName + ChatColor.BLUE + " the " + ChatColor.WHITE + this.rank.getColor() + this.rank.getDisplayName() + ChatColor.BLUE + " rank.");
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 30));
return description;
}
public Material getMaterial(Player player) {
return Material.WOOL;
}
public byte getDamageValue(Player player) {
return getColor(this.rank.getColor().charAt(1)).getWoolData();
}
public void clicked(Player player, int i, ClickType clickType) {
player.closeInventory();
ConversationFactory factory = new ConversationFactory(Bridge.getInstance()).withModality(true).withPrefix(new NullConversationPrefix()).withFirstPrompt(new StringPrompt() {
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Please type a reason for this grant to be added, or type " + ChatColor.RED + "cancel" + ChatColor.YELLOW + " to cancel.";
}
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel")) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Granting cancelled.");
return Prompt.END_OF_CONVERSATION;
}
new BukkitRunnable() {
public void run() {
RankButton.this.promptTime(player, input);
}
}.runTask(Bridge.getInstance());
return Prompt.END_OF_CONVERSATION;
}
}).withEscapeSequence("/no").withLocalEcho(false).withTimeout(10).thatExcludesNonPlayersWithMessage("Go away evil console!");
Conversation con = factory.buildConversation(player);
player.beginConversation(con);
}
private void promptTime(Player player, String reason) {
ConversationFactory factory = new ConversationFactory(Bridge.getInstance()).withModality(true).withPrefix(new NullConversationPrefix()).withFirstPrompt(new StringPrompt() {
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Please type a duration for this grant, (\"perm\" for permanent) or type " + ChatColor.RED + "cancel" + ChatColor.YELLOW + " to cancel.";
}
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel")) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Granting cancelled.");
return Prompt.END_OF_CONVERSATION;
}
long duration = TimeUtil.parseTime(input);
if (duration != -1L) {
new BukkitRunnable() {
public void run() {
new ScopesMenu(false, false, RankButton.this.rank, RankButton.this.targetName, RankButton.this.targetUUID, reason, duration).openMenu(player);
}
}.runTask(Bridge.getInstance());
return Prompt.END_OF_CONVERSATION;
}
context.getForWhom().sendRawMessage(ChatColor.RED + "Invalid duration.");
return Prompt.END_OF_CONVERSATION;
}
}).withEscapeSequence("/no").withLocalEcho(false).withTimeout(10).thatExcludesNonPlayersWithMessage("Go away evil console!");
Conversation con = factory.buildConversation(player);
player.beginConversation(con);
}
public static DyeColor getColor(char str) {
ChatColor color = ChatColor.getByChar(str);
switch (color) {
case DARK_BLUE:
case BLUE: {
return DyeColor.BLUE;
}
case DARK_GREEN: {
return DyeColor.GREEN;
}
case DARK_AQUA:
case AQUA: {
return DyeColor.CYAN;
}
case DARK_RED:
case RED: {
return DyeColor.RED;
}
case DARK_PURPLE: {
return DyeColor.PURPLE;
}
case GOLD: {
return DyeColor.ORANGE;
}
case GRAY:
case DARK_GRAY: {
return DyeColor.GRAY;
}
case GREEN: {
return DyeColor.LIME;
}
case LIGHT_PURPLE: {
return DyeColor.PINK;
}
case YELLOW: {
return DyeColor.YELLOW;
}
case WHITE: {
return DyeColor.WHITE;
}
default: {
return DyeColor.BLACK;
}
}
}
}

View File

@ -0,0 +1,65 @@
package rip.bridge.bridge.bukkit.commands.grant.menu.grant;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.Menu;
import lombok.AllArgsConstructor;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@AllArgsConstructor
public class RanksMenu extends Menu {
private String targetName;
private UUID targetUUID;
public String getTitle(Player player) {
return ChatColor.YELLOW.toString() + ChatColor.BOLD + "Choose a Rank";
}
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
List<Rank> ranks = this.getAllowedRanks(player);
for (int i = 0; i < ranks.size(); ++i) {
buttons.put(i, new RankButton(this.targetName, this.targetUUID, ranks.get(i)));
}
return buttons;
}
private List<Rank> getAllowedRanks(Player player) {
List<Rank> allRanks = new ArrayList<>(BridgeGlobal.getRankHandler().getRanks());
List<Rank> ranks = Lists.newArrayList();
for (int i = 0; i < allRanks.size(); ++i) {
//if (i != 0) {
if(allRanks.get(i).isDefaultRank()) continue;
if (this.isAllowed(allRanks.get(i), player)) ranks.add(allRanks.get(i));
//}
}
ranks.sort((o1, o2) -> o2.getPriority() - o1.getPriority());
return ranks;
}
private boolean isAllowed(Rank rank, Player player) {
return BukkitAPI.getProfile(player).hasPermission("bridge.grant.create.*") || BukkitAPI.getProfile(player).hasPermission("bridge.grant.create." + rank.getName());
}
public void onClose(Player player) {
new BukkitRunnable() {
public void run() {
if (!Menu.currentlyOpenedMenus.containsKey(player.getName())) player.sendMessage(ChatColor.RED + "Granting cancelled.");
}
}.runTaskLater(Bridge.getInstance(), 1L);
}
}

View File

@ -0,0 +1,53 @@
package rip.bridge.bridge.bukkit.commands.grant.menu.grant;
import com.google.common.collect.Lists;
import rip.bridge.qlib.menu.Button;
import lombok.AllArgsConstructor;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.List;
@AllArgsConstructor
public class ScopeButton extends Button {
private ScopesMenu parent;
private String scope;
public String getName(Player player) {
boolean status = this.parent.getStatus().get(this.scope);
return (status ? ChatColor.GREEN : ChatColor.RED) + this.scope;
}
public List<String> getDescription(Player player) {
boolean status = this.parent.getStatus().get(this.scope);
List<String> description = Lists.newArrayList();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 30));
if (status) {
description.add(ChatColor.BLUE + "Click to " + ChatColor.RED + "remove " + ChatColor.YELLOW + this.scope + ChatColor.BLUE + " from this grant's scopes.");
}
else {
description.add(ChatColor.BLUE + "Click to " + ChatColor.GREEN + "add " + ChatColor.YELLOW + this.scope + ChatColor.BLUE + " to this grant's scopes.");
}
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 30));
return description;
}
public Material getMaterial(Player player) {
return Material.WOOL;
}
public byte getDamageValue(Player player) {
boolean status = this.parent.getStatus().get(this.scope);
return status ? DyeColor.LIME.getWoolData() : DyeColor.GRAY.getWoolData();
}
public void clicked(Player player, int i, ClickType clickType) {
this.parent.getStatus().put(this.scope, !this.parent.getStatus().getOrDefault(this.scope, false));
this.parent.setGlobal(false);
}
}

View File

@ -0,0 +1,78 @@
package rip.bridge.bridge.bukkit.commands.grant.menu.grant;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.Menu;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
@Getter @Setter
public class ScopesMenu extends Menu {
private Map<String, Boolean> status;
private boolean global;
private boolean complete;
private Rank rank;
private String targetName;
private UUID targetUUID;
private String reason;
private long duration;
public String getTitle(Player player) {
return ChatColor.YELLOW.toString() + ChatColor.BOLD + "Select the Scopes";
}
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
List<String> groups = Lists.newArrayList();
groups.addAll(BridgeGlobal.getServerHandler().getGroups());
int i = 0;
for (String scope : groups) {
if(scope == null) continue;
this.status.putIfAbsent(scope, false);
buttons.put(i, new ScopeButton(this, scope));
++i;
}
List<String> scopes = Lists.newArrayList();
scopes.addAll(this.status.keySet().stream().filter(this.status::get).collect(Collectors.toList()));
buttons.put(22, new GlobalButton(this));
buttons.put(31, new GrantButton(this.rank, this.targetName, this.targetUUID, this.reason, this, scopes, this.duration));
return buttons;
}
public void onClose(Player player) {
new BukkitRunnable() {
public void run() {
if (!Menu.currentlyOpenedMenus.containsKey(player.getName()) && !ScopesMenu.this.complete) {
player.sendMessage(ChatColor.RED + "Granting cancelled.");
}
}
}.runTaskLater(Bridge.getInstance(), 1L);
}
public ScopesMenu(boolean global, boolean complete, Rank rank, String targetName, UUID targetUUID, String reason, long duration) {
this.status = Maps.newHashMap();
this.global = false;
this.global = global;
this.complete = complete;
this.rank = rank;
this.targetName = targetName;
this.targetUUID = targetUUID;
this.reason = reason;
this.duration = duration;
}
}

View File

@ -0,0 +1,129 @@
package rip.bridge.bridge.bukkit.commands.grant.menu.grants;
import com.google.common.collect.Lists;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.util.TimeUtils;
import lombok.AllArgsConstructor;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.conversations.*;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.Date;
import java.util.List;
@AllArgsConstructor
public class GrantsButton extends Button {
private Profile profile;
private Grant grant;
public String getName(Player player) {
return ChatColor.YELLOW + TimeUtils.formatIntoCalendarString(new Date(this.grant.getInitialTime()));
}
public List<String> getDescription(Player player) {
List<String> description = Lists.newArrayList();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 25));
String by = this.grant.getGrantedBy();
description.add(ChatColor.YELLOW + "By: " + ChatColor.RED + by);
description.add(ChatColor.YELLOW + "Reason: " + ChatColor.RED + this.grant.getReason());
description.add(ChatColor.YELLOW + "Scopes: " + ChatColor.RED + (this.grant.getScope().isEmpty() ? "Global" : this.grant.getScope()));
description.add(ChatColor.YELLOW + "Rank: " + ChatColor.RED + this.grant.getRank().getDisplayName());
if (this.grant.isStillActive()) {
if (this.grant.getActiveUntil() != Long.MAX_VALUE) {
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 25));
description.add(ChatColor.YELLOW + "Time remaining: " + ChatColor.RED + TimeUtils.formatIntoDetailedString((int) ((this.grant.getActiveUntil() - System.currentTimeMillis()) / 1000)));
}
else {
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 25));
description.add(ChatColor.YELLOW + "This is a permanent grant.");
}
if (player.hasPermission("bridge.grant.remove." + this.grant.getRank())) {
description.add("");
description.add(ChatColor.RED.toString() + ChatColor.BOLD + "Click to remove");
description.add(ChatColor.RED.toString() + ChatColor.BOLD + "this grant");
}
}
else if (this.grant.isRemoved()) {
String removedBy = this.grant.getRemovedBy();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 25));
description.add(ChatColor.RED + "Removed:");
description.add(ChatColor.YELLOW + removedBy + ": " + ChatColor.RED + this.grant.getRemovedReason());
description.add(ChatColor.RED + "at " + ChatColor.YELLOW + TimeUtils.formatIntoCalendarString(new Date(this.grant.getRemovedAt())));
if (this.grant.getActiveUntil() != Long.MAX_VALUE) {
description.add("");
description.add(ChatColor.YELLOW + "Duration: " + TimeUtils.formatIntoDetailedString((int) (this.grant.getLength() / 1000)));
}
}
else if (!this.grant.isStillActive() && this.grant.getActiveUntil() <= Long.MAX_VALUE) {
description.add(ChatColor.YELLOW + "Duration: " + TimeUtils.formatIntoDetailedString((int)((this.grant.getLength()) / 1000L)));
description.add(ChatColor.GREEN + "Expired");
}
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 25));
return description;
}
public Material getMaterial(Player player) {
return Material.WOOL;
}
public byte getDamageValue(Player player) {
return this.grant.isStillActive() ? DyeColor.LIME.getWoolData() : DyeColor.RED.getWoolData();
}
public void clicked(Player player, int i, ClickType clickType) {
if (!player.hasPermission("bridge.grant.remove." + this.grant.getRank()) || !this.grant.isStillActive()) {
return;
}
player.closeInventory();
ConversationFactory factory = new ConversationFactory(Bridge.getInstance()).withModality(true).withPrefix(new NullConversationPrefix()).withFirstPrompt(new StringPrompt() {
public String getPromptText(ConversationContext context) {
return "§aType a reason to be used when removing this grant. Type §cno§a to quit.";
}
public Prompt acceptInput(ConversationContext cc, String s) {
if (s.equalsIgnoreCase("no")) {
cc.getForWhom().sendRawMessage(ChatColor.GREEN + "Grant removal aborted.");
}
else {
grant.setRemoved(true);
grant.setRemovedAt(System.currentTimeMillis());
grant.setRemovedBy(player.getUniqueId().toString());
grant.setRemovedOn(BridgeGlobal.getSystemName());
grant.setRemovedReason(s);
boolean isThereStaff = false;
for(Grant g : profile.getGrants()) {
if(g.getRank().isStaff() && !g.isRemoved()) {
isThereStaff = true;
break;
}
}
if(!isThereStaff) {
if(profile.getBecameStaffOn() != 0) {
profile.setRemovedStaffOn(System.currentTimeMillis());
}
}
profile.saveProfile();
cc.getForWhom().sendRawMessage(ChatColor.GREEN + "You have removed the grant.");
}
return Prompt.END_OF_CONVERSATION;
}
}).withLocalEcho(false).withEscapeSequence("/no").withTimeout(60).thatExcludesNonPlayersWithMessage("Go away evil console!");
Conversation con = factory.buildConversation(player);
player.beginConversation(con);
}
}

View File

@ -0,0 +1,68 @@
package rip.bridge.bridge.bukkit.commands.grant.menu.grants;
import com.google.common.collect.Maps;
import rip.bridge.bridge.global.grant.Grant;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.pagination.PaginatedMenu;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.List;
import java.util.Map;
public class GrantsMenu extends PaginatedMenu {
private Profile profile;
private List<Grant> grants;
public GrantsMenu(Profile profile, List<Grant> grants) {
this.profile = profile;
this.grants = grants;
setAutoUpdate(true);
}
public String getPrePaginatedTitle(final Player player) {
return ChatColor.RED + "Grants";
}
public Map<Integer, Button> getGlobalButtons(final Player player) {
final Map<Integer, Button> buttons = Maps.newHashMap();
buttons.put(4, new Button() {
public String getName(final Player player) {
return ChatColor.YELLOW + "Back";
}
public List<String> getDescription(final Player player) {
return null;
}
public Material getMaterial(final Player player) {
return Material.PAPER;
}
public byte getDamageValue(final Player player) {
return 0;
}
public void clicked(final Player player, final int i, final ClickType clickType) {
player.closeInventory();
}
});
return buttons;
}
public Map<Integer, Button> getAllPagesButtons(final Player player) {
final Map<Integer, Button> buttons = Maps.newHashMap();
int index = 0;
for (Grant g : grants) {
buttons.put(index, new GrantsButton(profile, g));
++index;
}
return buttons;
}
}

View File

@ -0,0 +1,47 @@
package rip.bridge.bridge.bukkit.commands.punishment;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import java.util.ArrayList;
import java.util.List;
public class AltsCommand {
@Command(names = {"alts", "dupeip", "identities"}, permission = "bridge.alts", description = "View player's alt accounts", async = true)
public static void alts(CommandSender sender, @Param(name = "player") Profile profile) {
BridgeGlobal.getMongoHandler().getProfiles(profile.getCurrentIPAddress(), callback -> {
if (callback == null || callback.isEmpty() || callback.size() == 1) {
sender.sendMessage(BukkitAPI.getColor(profile) + profile.getUsername() + ChatColor.RED + " doesn't have any alts");
return;
}
sender.sendMessage(ChatColor.YELLOW + "Fetching identities of " + profile.getUsername() + "...");
sender.sendMessage(ChatColor.WHITE + "[" + ChatColor.GREEN + "Online" + ChatColor.WHITE + ", " + ChatColor.GRAY + "Offline" + ChatColor.WHITE + ", " + ChatColor.DARK_RED + "Blacklisted" + ChatColor.WHITE + ", " + ChatColor.RED + "Banned" + ChatColor.WHITE + ", " + ChatColor.WHITE + "Muted" + ChatColor.WHITE + "]");
sender.sendMessage(BukkitAPI.getColor(profile) + profile.getUsername() + ChatColor.YELLOW + "'s" + (callback.size() == 1 ? ChatColor.YELLOW + " alt" : ChatColor.YELLOW + " alts") + ChatColor.YELLOW + " (" + ChatColor.RED + callback.size() + ChatColor.YELLOW + ")" + ".");
List<String> formattedName = new ArrayList<>();
callback.forEach(alt -> {
if (Bukkit.getOfflinePlayer(alt.getUuid()).isOnline())
formattedName.add(ChatColor.GREEN + alt.getUsername());
else if (alt.getActivePunishments(PunishmentType.BLACKLIST).size() > 1)
formattedName.add(ChatColor.DARK_RED + alt.getUsername());
else if (alt.getActivePunishments(PunishmentType.BAN).size() > 1)
formattedName.add(ChatColor.RED + alt.getUsername());
else if (alt.getActivePunishments(PunishmentType.MUTE).size() > 1)
formattedName.add(ChatColor.GOLD + alt.getUsername());
else formattedName.add(ChatColor.GRAY + alt.getUsername());
});
sender.sendMessage(StringUtils.join(formattedName, ChatColor.WHITE + ", "));
}, false);
}
}

View File

@ -0,0 +1,25 @@
package rip.bridge.bridge.bukkit.commands.punishment;
import rip.bridge.bridge.bukkit.commands.punishment.menu.MainPunishmentMenu;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Flag;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class CheckPunishmentsCommand {
@Command(names = {"checkpunishments", "cp", "c", "history"}, permission = "bridge.checkpunishments", description = "Check a player's active punishments", async = true)
public static void checkPunishments(Player sender, @Flag(value = {"gui", "menu"}, description = "Check a player's active punishments ingame") boolean gui, @Param(name = "target", extraData = "get") Profile target) {
if (!gui) {
FancyMessage message = new FancyMessage(ChatColor.GREEN + "[Click Here]" + ChatColor.YELLOW + " to view all of " + target.getUsername() + "'s punishments");
message.tooltip(ChatColor.GRAY + "Click here: https://www.bridge.rip/u/" + target.getUsername() + "/punishments").link("https://www.bridge.rip/u/" + target.getUsername() + "/punishments");
message.send(sender);
} else {
new MainPunishmentMenu(target.getUuid().toString(), target.getUsername()).openMenu(sender);
}
}
}

View File

@ -0,0 +1,15 @@
package rip.bridge.bridge.bukkit.commands.punishment;
import rip.bridge.bridge.bukkit.commands.punishment.menu.staffhistory.MainStaffPunishmentListMenu;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import org.bukkit.entity.Player;
public class CheckStaffPunishmentsCommand {
@Command(names = {"staffpunishments", "checkstaffpunishments", "staffhistory", "staffhist"}, permission = "bridge.staffhistory", description = "Check a player's active punishments", async = true)
public static void staffPunishments(Player sender, @Param(name = "target") Profile target){
new MainStaffPunishmentListMenu(target.getUuid().toString(), target.getUsername()).openMenu(sender);
}
}

View File

@ -0,0 +1,35 @@
package rip.bridge.bridge.bukkit.commands.punishment;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.bukkit.commands.punishment.menu.MainPunishmentMenu;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Flag;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
import java.util.HashSet;
public class ClearPunishmentsCommand {
@Command(names = {"clearpunishments", "clearhistory"}, permission = "bridge.clearpunishments", description = "Clear player's punishments from the entire network", async = true)
public static void clearPunishments(CommandSender s, @Param(name = "target") Profile target) {
if (target.getPunishments().isEmpty()) {
s.sendMessage(ChatColor.RED + target.getUsername() + " does not have any punishments.");
return;
}
s.sendMessage(ChatColor.GREEN + "Successfully cleared " + target.getCurrentGrant().getRank().getColor() + target.getUsername() + ChatColor.GREEN + "'s punishments.");
target.getPunishments().clear();
target.saveProfile();
}
}

View File

@ -0,0 +1,28 @@
package rip.bridge.bridge.bukkit.commands.punishment;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class ClearStaffPunishmentsCommand {
@Command(names = {"clearstaffpunishments", "clearstaffhistory"}, permission = "bridge.clearstaffpunishments", description = "Clear staff member's punishments from the entire network", async = true)
public static void clearPunishments(CommandSender sender, @Param(name = "target") Profile target) {
if (!target.getCurrentGrant().getRank().isStaff() && target.getRemovedStaffOn() == 0) {
sender.sendMessage(ChatColor.RED + "That player has never been apart of the staff team.");
return;
}
if (target.getStaffPunishments().isEmpty()) {
sender.sendMessage(ChatColor.RED + target.getUsername() + " does not have any staff punishments.");
return;
}
sender.sendMessage(ChatColor.GREEN + "Successfully cleared " + target.getCurrentGrant().getRank().getColor() + target.getUsername() + ChatColor.GREEN + "'s Staff History.");
target.getStaffPunishments().clear();
target.saveProfile();
}
}

View File

@ -0,0 +1,41 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import java.util.HashSet;
public class BanCommand {
@Command(names = {"ban", "b", "banish"}, permission = "bridge.ban", description = "Ban a player from the network", async = true)
public static void banCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this ban to the server") boolean silent, @Flag(value = {"c", "clear"}, description = "Clear the player's inventory") boolean clear, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getActivePunishments(PunishmentType.BAN).size() > 1) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already banned.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
//empty list instead of int instantly as null
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.BAN, new HashSet<>(), false, !silent, clear, Long.MAX_VALUE);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,41 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.HashSet;
public class BanIPCommand {
@Command(names = {"banip", "bip", "baniship"}, permission = "bridge.banip", description = "Ban a player from the network", async = true)
public static void banIPCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this ban to the server") boolean silent, @Flag(value = {"c", "clear"}, description = "Clear the player's inventory") boolean clear, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getActivePunishments(PunishmentType.BAN).size() > 1) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already banned.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.BAN, new HashSet<>(), true, !silent, clear, Long.MAX_VALUE);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,45 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import java.util.HashSet;
public class BlacklistCommand {
@Command(names = {"blacklist", "bl"}, permission = "bridge.blacklist", description = "Blacklist an user from the network. This type of punishment cannot be appealed", async = true)
public static void blacklistCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this blacklist to the server") boolean silent, @Flag(value = {"c", "clear"}, description = "Clear the player's inventory") boolean clear, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getCurrentIPAddress() == null) {
s.sendMessage(ChatColor.RED + "We can't blacklist a player that never joined before.");
return;
}
if (target.getActivePunishments(PunishmentType.BLACKLIST).size() > 1) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already blacklisted.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.BLACKLIST, new HashSet<>(), true, !silent, clear, Long.MAX_VALUE);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,36 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.HashSet;
public class KickCommand
{
@Command(names = { "kick", "k" }, permission = "basic.staff", description = "Kick a player from the server")
public static void pMuteCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this kick to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", defaultValue = "Kicked by a staff member", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.KICK, new HashSet<>(),false, !silent, false, Long.MAX_VALUE);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,45 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import java.util.HashSet;
import java.util.concurrent.TimeUnit;
public class MuteCommand {
@Command(names = {"mute"}, permission = "bridge.mute", description = "Temporarily mute a player, stopping them from talking in public chat", async = true)
public static void muteCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this mute to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "time") Long length, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getActivePunishments(PunishmentType.MUTE).size() > 1) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already muted.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
if (!s.hasPermission("bridge.mute.permanent") && TimeUnit.DAYS.toMillis(31L) < length) {
s.sendMessage(ChatColor.RED + "You don't have permission to create a mute this long. Maximum time allowed: 30 days.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(),reason, PunishmentType.MUTE, new HashSet<>(), false, !silent, false, length);
target.getPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,47 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.HashSet;
import java.util.concurrent.TimeUnit;
public class MuteIPCommand {
@Command(names = {"muteip", "ipmute"}, permission = "bridge.muteip", description = "Temporarily mute an user, stopping them from talking in public chat", async = true)
public static void muteIPCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this mute to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "time") Long length, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (pf.getActivePunishments(PunishmentType.MUTE).size() > 0) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already muted.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
if (!s.hasPermission("bridge.muteip.permanent") && TimeUnit.DAYS.toMillis(31L) < length) {
s.sendMessage(ChatColor.RED + "You don't have permission to create a mute this long. Maximum time allowed: 30 days.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.MUTE, new HashSet<>(), true, !silent, false, length);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,41 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.HashSet;
public class PermMuteCommand {
@Command(names = {"pmute", "permmute"}, permission = "bridge.mute.permanent", description = "Permanently mute an user, stopping them from talking in public chat", async = true)
public static void pMuteCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this mute to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (pf.getActivePunishments(PunishmentType.MUTE).size() > 0) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already muted.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.MUTE, new HashSet<>(),false, !silent, false, Long.MAX_VALUE);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,41 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.HashSet;
public class PermMuteIPCommand {
@Command(names = {"pmuteip", "permmuteip"}, permission = "bridge.muteip.permanent", description = "Permanently mute an user, stopping them from talking in public chat", async = true)
public static void pMuteIPCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this mute to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (pf.getActivePunishments(PunishmentType.MUTE).size() > 0) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already muted.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.MUTE, new HashSet<>(), true, !silent, false, Long.MAX_VALUE);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,46 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.HashSet;
import java.util.concurrent.TimeUnit;
public class TempBanCommand {
@Command(names = {"tempban", "tban", "tb"}, permission = "bridge.tempban", description = "Temporarily ban a player from the network", async = true)
public static void tBanCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this ban to the server") boolean silent, @Flag(value = {"c", "clear"}, description = "Clear the player's inventory") boolean clear, @Param(name = "target") Profile target, @Param(name = "time") Long length, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getActivePunishments(PunishmentType.BAN).size() > 1) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already banned.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
if (!s.hasPermission("bridge.ban") && TimeUnit.DAYS.toMillis(31L) < length) {
s.sendMessage(ChatColor.RED + "You don't have permission to create a mute this long. Maximum time allowed: 30 days.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.BAN, new HashSet<>(), false, !silent, clear, length);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,46 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import java.util.HashSet;
import java.util.concurrent.TimeUnit;
public class TempBanIPCommand {
@Command(names = {"tempbanip", "tbanip", "tbip"}, permission = "bridge.tempbanip", description = "Temporarily ban a player from the network", async = true)
public static void tBanIPCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this ban to the server") boolean silent, @Flag(value = {"c", "clear"}, description = "Clear the player's inventory") boolean clear, @Param(name = "target") Profile target, @Param(name = "time") Long length, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getActivePunishments(PunishmentType.BAN).size() > 1) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is already banned.");
return;
}
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
if (!s.hasPermission("bridge.ban") && TimeUnit.DAYS.toMillis(31L) < length) {
s.sendMessage(ChatColor.RED + "You don't have permission to create a mute this long. Maximum time allowed: 30 days.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.BAN, new HashSet<>(), true, !silent, clear, length);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,36 @@
package rip.bridge.bridge.bukkit.commands.punishment.create;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.bridge.bukkit.BukkitAPI;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import java.util.HashSet;
public class WarnCommand {
@Command(names = {"warn"}, permission = "bridge.warn", description = "Add a warning to an player's account", async = true)
public static void warnCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this warn to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (!BukkitAPI.canOverride(pf, target)) {
s.sendMessage(ChatColor.RED + "You cannot punish this player.");
return;
}
Punishment punishment = new Punishment(target, pf, BridgeGlobal.getSystemName(), reason, PunishmentType.WARN, new HashSet<>(), false, !silent, false, Long.MAX_VALUE);
target.getPunishments().add(punishment);
pf.getStaffPunishments().add(punishment);
target.saveProfile();
pf.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,98 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu;
import com.google.common.collect.Maps;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.Menu;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.*;
public class MainPunishmentMenu extends Menu
{
private String targetUUID;
private String targetName;
public String getTitle(Player player) {
return ChatColor.BLUE + "Punishments - " + this.targetName;
}
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
if (player.hasPermission("bridge.punishments.view.blacklist")) {
buttons.put(0, this.button(PunishmentType.WARN));
buttons.put(2, this.button(PunishmentType.KICK));
buttons.put(4, this.button(PunishmentType.MUTE));
buttons.put(6, this.button(PunishmentType.BAN));
buttons.put(8, this.button(PunishmentType.BLACKLIST));
}
else {
buttons.put(1, this.button(PunishmentType.WARN));
buttons.put(3, this.button(PunishmentType.KICK));
buttons.put(5, this.button(PunishmentType.MUTE));
buttons.put(7, this.button(PunishmentType.BAN));
}
return buttons;
}
private Button button(PunishmentType type) {
return new Button() {
public String getName(Player player) {
return ChatColor.RED + type.getDisplayName() + "s";
}
public List<String> getDescription(Player player) {
return null;
}
public Material getMaterial(Player player) {
return Material.WOOL;
}
public byte getDamageValue(Player player) {
if (type == PunishmentType.WARN) {
return DyeColor.YELLOW.getWoolData();
}
if (type == PunishmentType.KICK) {
return DyeColor.GRAY.getWoolData();
}
if (type == PunishmentType.MUTE) {
return DyeColor.ORANGE.getWoolData();
}
if (type == PunishmentType.BAN) {
return DyeColor.RED.getWoolData();
}
return DyeColor.BLACK.getWoolData();
}
public void clicked(Player player, int i, ClickType clickType) {
player.closeInventory();
player.sendMessage(ChatColor.GREEN + "Loading " + MainPunishmentMenu.this.targetName + "'s " + type.getDisplayName() + "s...");
List<Punishment> allPunishments = new ArrayList<>(BukkitAPI.getProfile(UUID.fromString(targetUUID)).getPunishments());
Bukkit.getScheduler().scheduleAsyncDelayedTask(Bridge.getInstance(), () -> {
allPunishments.sort((first, second) -> Long.compare(second.getTime(), first.getTime()));
LinkedHashMap<Punishment, String> punishments = new LinkedHashMap<>();
allPunishments.stream().filter(punishment -> punishment.getPunishmentType() == type).forEach(punishment -> punishments.put(punishment, punishment.getTarget().getUsername()));
Bukkit.getScheduler().scheduleSyncDelayedTask(Bridge.getInstance(), () -> new PunishmentMenu(targetUUID, targetName, type, punishments).openMenu(player));
});
}
};
}
public MainPunishmentMenu(String targetUUID, String targetName) {
this.targetUUID = targetUUID;
this.targetName = targetName;
setAutoUpdate(true);
}
}

View File

@ -0,0 +1,81 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu;
import com.google.common.collect.Maps;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import rip.bridge.bridge.bukkit.commands.punishment.menu.button.ProofAddButton;
import rip.bridge.bridge.bukkit.commands.punishment.menu.button.ProofButton;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Evidence;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.pagination.PaginatedMenu;
import java.util.List;
import java.util.Map;
public class ProofMenu extends PaginatedMenu {
private final Punishment punishment;
private String targetUUID;
private String targetName;
private PunishmentType type;
private Map<Punishment, String> punishments;
Profile profile;
public ProofMenu(Punishment punishment, String targetUUID, PunishmentType type, String targetName, Map<Punishment, String> punishments){
this.punishment = punishment;
this.targetUUID = targetUUID;
this.targetName = targetName;
this.type = type;
this.punishments = punishments;
profile = punishment.getTarget();
}
public Map<Integer, Button> getGlobalButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
buttons.put(5, new ProofAddButton(punishment, profile));
buttons.put(4, new Button() {
public String getName(Player player) {
return ChatColor.YELLOW + "Back";
}
public List<String> getDescription(Player player) {
return null;
}
public Material getMaterial(Player player) {
return Material.PAPER;
}
public byte getDamageValue(Player player) {
return 0;
}
public void clicked(Player player, int i, ClickType clickType) {
player.closeInventory();
new PunishmentMenu(ProofMenu.this.targetUUID, ProofMenu.this.targetName, type, punishments).openMenu(player);
}
});
return buttons;
}
@Override
public String getPrePaginatedTitle(Player player) {
return "Proof Editor";
}
@Override
public Map<Integer, Button> getAllPagesButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
int index = 0;
for(Evidence entry : punishment.getProof()){
buttons.put(index, new ProofButton(punishment, profile, entry));
index++;
}
return buttons;
}
}

View File

@ -0,0 +1,72 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu;
import com.google.common.collect.Maps;
import rip.bridge.bridge.bukkit.commands.punishment.menu.button.PunishmentButton;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.pagination.PaginatedMenu;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.List;
import java.util.Map;
public class PunishmentMenu extends PaginatedMenu
{
private String targetUUID;
private String targetName;
private PunishmentType type;
private Map<Punishment, String> punishments;
public String getPrePaginatedTitle(Player player) {
return ChatColor.RED + this.type.getDisplayName() + "s";
}
public Map<Integer, Button> getGlobalButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
buttons.put(4, new Button() {
public String getName(Player player) {
return ChatColor.YELLOW + "Back";
}
public List<String> getDescription(Player player) {
return null;
}
public Material getMaterial(Player player) {
return Material.PAPER;
}
public byte getDamageValue(Player player) {
return 0;
}
public void clicked(Player player, int i, ClickType clickType) {
player.closeInventory();
new MainPunishmentMenu(PunishmentMenu.this.targetUUID, PunishmentMenu.this.targetName).openMenu(player);
}
});
return buttons;
}
public Map<Integer, Button> getAllPagesButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
int index = 0;
for (Map.Entry<Punishment, String> entry : this.punishments.entrySet()) {
buttons.put(index, new PunishmentButton(entry.getKey(), entry.getKey().getPunishmentType(), entry.getKey().getTarget().getUuid().toString(), entry.getKey().getTarget().getUsername(), punishments));
++index;
}
return buttons;
}
public PunishmentMenu(String targetUUID, String targetName, PunishmentType type, Map<Punishment, String> punishments) {
this.targetUUID = targetUUID;
this.targetName = targetName;
this.punishments = punishments;
this.type = type;
setAutoUpdate(true);
}
}

View File

@ -0,0 +1,88 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu.button;
import org.bukkit.scheduler.BukkitRunnable;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Evidence;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.qlib.menu.Button;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.conversations.*;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.List;
public class ProofAddButton extends Button {
private final Punishment punishment;
private final Profile profile;
public ProofAddButton(Punishment punishment, Profile profile) {
this.punishment = punishment;
this.profile = profile;
}
@Override
public String getName(Player player) {
return ChatColor.GREEN + ("Add Proof Entry");
}
@Override
public List<String> getDescription(Player player) {
return null;
}
@Override
public Material getMaterial(Player player) {
return Material.SIGN;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
startAddConversation(player);
}
private void startAddConversation(Player player) {
ConversationFactory factory = new ConversationFactory(Bridge.getInstance()).withFirstPrompt(new StringPrompt() {
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Please type a proof entry to submit, or type " + ChatColor.RED + "cancel " + ChatColor.YELLOW + "to cancel.";
}
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel")) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Proof entry submission process aborted.");
return Prompt.END_OF_CONVERSATION;
}
if (punishment.getProof().contains(new Evidence(player.getName(), input))) {
player.sendMessage(ChatColor.RED + "This punishment already has a proof entry similar to the one you input.");
return Prompt.END_OF_CONVERSATION;
}
new BukkitRunnable() {
@Override
public void run() {
punishment.getProof().add(new Evidence(player.getName(), input));
profile.saveProfile();
player.sendMessage(ChatColor.GREEN + "Successfully added proof entry: " + ChatColor.RESET + input);
}
}.runTask(Bridge.getInstance());
/*punishment.getProof().add(new Evidence(player.getName(), input));
profile.saveProfile();
Bridge.getInstance().getServer().getScheduler().runTaskLaterAsynchronously(Bridge.getInstance(), () -> {
player.sendMessage(ChatColor.GREEN + "Successfully added proof entry: " + ChatColor.RESET + input);
}, 1L);*/
return Prompt.END_OF_CONVERSATION;
}
}).withLocalEcho(false);
player.closeInventory();
player.beginConversation(factory.buildConversation(player));
}
}

View File

@ -0,0 +1,113 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu.button;
import com.google.common.collect.Lists;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.scheduler.BukkitRunnable;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Evidence;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.qlib.menu.Button;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.conversations.*;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import rip.bridge.qlib.util.TimeUtils;
import java.util.Date;
import java.util.List;
public class ProofButton extends Button {
private final Punishment punishment;
private final Profile profile;
private final Evidence entry;
public ProofButton(Punishment punishment, Profile profile, Evidence entry){
this.punishment = punishment;
this.profile = profile;
this.entry = entry;
}
@Override
public String getName(Player player) {
return ChatColor.YELLOW + TimeUtils.formatIntoCalendarString(new Date(punishment.getTime()));
}
@Override
public List<String> getDescription(Player player) {
List<String> description = Lists.newArrayList();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 25));
description.add(ChatColor.YELLOW + "Added by: " + ChatColor.RED + entry.getSender());
description.add(ChatColor.YELLOW + "Proof: " + ChatColor.RED + entry.getURL());
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 25));
description.add(ChatColor.GREEN.toString() + ChatColor.BOLD + "Left Click to view");
description.add(ChatColor.GREEN.toString() + ChatColor.BOLD + "this proof");
description.add(" ");
description.add(ChatColor.RED.toString() + ChatColor.BOLD + "Right Click to remove");
description.add(ChatColor.RED.toString() + ChatColor.BOLD + "this proof");
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat('-', 25));
return description;
}
@Override
public Material getMaterial(Player player) {
return Material.WOOL;
}
@Override
public byte getDamageValue(Player player) {
return (byte) 5;
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
switch(clickType){
case LEFT: {
player.sendMessage(ChatColor.YELLOW + entry.getURL());
break;
}case RIGHT: {
startRemoveConversation(player);
} default: {
}
}
}
private void startRemoveConversation(Player player){
player.closeInventory();
ConversationFactory factory = new ConversationFactory(Bridge.getInstance()).withModality(true).withPrefix(new NullConversationPrefix()).withFirstPrompt(new StringPrompt() {
public String getPromptText(ConversationContext context) {
return ChatColor.YELLOW + "Please type " + ChatColor.RED + "confirm" + ChatColor.YELLOW + " to confirm removal of this proof entry, or type " + ChatColor.RED + "cancel " + ChatColor.YELLOW + "to cancel.";
}
public Prompt acceptInput(ConversationContext context, String input) {
if (input.equalsIgnoreCase("cancel")) {
context.getForWhom().sendRawMessage(ChatColor.RED + "Proof entry removal process aborted.");
return Prompt.END_OF_CONVERSATION;
} else if (input.equalsIgnoreCase("confirm")) {
new BukkitRunnable() {
@Override
public void run() {
punishment.getProof().remove(entry);
profile.saveProfile();
player.sendMessage(ChatColor.GREEN + "Successfully removed the proof entry.");
}
}.runTask(Bridge.getInstance());
return Prompt.END_OF_CONVERSATION;
}else{
Bridge.getInstance().getServer().getScheduler().runTaskLaterAsynchronously(Bridge.getInstance(), () -> {
player.sendMessage(ChatColor.RED + "Invalid response; proof entry removal process aborted.");
}, 1L);
return Prompt.END_OF_CONVERSATION;
}
}
}).withEscapeSequence("/no").withLocalEcho(false).withTimeout(10).thatExcludesNonPlayersWithMessage("Go away evil console!");
Conversation con = factory.buildConversation(player);
player.beginConversation(con);
}
}

View File

@ -0,0 +1,98 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu.button;
import com.google.common.collect.Lists;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.bukkit.commands.punishment.menu.ProofMenu;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.util.TimeUtils;
import net.md_5.bungee.api.ChatColor;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class PunishmentButton extends Button
{
private Punishment punishment;
private String targetUUID;
private String targetName;
private PunishmentType type;
private Map<Punishment, String> punishments;
public PunishmentButton(Punishment punishment, PunishmentType type, String targetUUID, String targetName, Map<Punishment, String> punishments){
this.punishment = punishment;
this.targetUUID = targetUUID;
this.targetName = targetName;
this.type = type;
this.punishments = punishments;
}
public String getName(Player player) {
return ChatColor.YELLOW + TimeUtils.formatIntoCalendarString(new Date(this.punishment.getTime()));
}
public List<String> getDescription(Player player) {
List<String> description = Lists.newArrayList();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
String by = punishment.getExecutor().getUsername();
String actor = "Server" + ChatColor.YELLOW + " : " + ChatColor.RED + (this.punishment.getPunishedServer() != null ? this.punishment.getPunishedServer() : "Website");
final String randomID = ChatColor.MAGIC + UUID.randomUUID().toString().substring(0, 8);
description.add(ChatColor.YELLOW + "By: " + ChatColor.RED + (BukkitAPI.getProfile(player).hasPermission("bridge.punishments.view.punisher") ? by : randomID));
description.add(ChatColor.YELLOW + "Added on: " + ChatColor.RED + actor);
description.add(ChatColor.YELLOW + "Reason: " + ChatColor.RED + this.punishment.getReason());
if (this.punishment.isActive()) {
if (!this.punishment.isPermanent()) {
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
description.add(ChatColor.YELLOW + "Time remaining: " + ChatColor.RED + DurationFormatUtils.formatDurationWords(Math.abs(punishment.getRemainingTime()), true, true));
}
else {
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
description.add(ChatColor.YELLOW + "This is a permanent punishment.");
}
}
else if (this.punishment.isPardoned()) {
String removedBy = this.punishment.getPardonedBy().getUsername();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
description.add(ChatColor.RED + "Removed:");
description.add(ChatColor.YELLOW + (BukkitAPI.getProfile(player).hasPermission("bridge.punishments.view.punisher") ? removedBy : randomID) + ": " + ChatColor.RED + this.punishment.getPardonedReason());
description.add(ChatColor.RED + "at " + ChatColor.YELLOW + TimeUtils.formatIntoCalendarString(new Date(this.punishment.getPardonedAt())));
if (!this.punishment.isPermanent()) {
description.add("");
description.add(ChatColor.YELLOW + "Duration: " + TimeUtils.formatIntoDetailedString((int)((this.punishment.getRemainingTime()) / 1000L) + 1));
}
}
else if (!this.punishment.isPermanent() && this.punishment.getRemainingTime() <= 0) {
description.add(ChatColor.YELLOW + "Duration: " + TimeUtils.formatIntoDetailedString((int)((this.punishment.getRemainingTime()) / 1000L) + 1));
description.add(ChatColor.GREEN + "Expired");
}
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
return description;
}
@Override
public Material getMaterial(Player player) {
return Material.WOOL;
}
@Override
public byte getDamageValue(Player player) {
return !this.punishment.isActive() ? DyeColor.RED.getWoolData() : DyeColor.LIME.getWoolData();
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
// new ProofMenu(punishment, PunishmentButton.this.targetUUID,type, PunishmentButton.this.targetName, punishments).openMenu(player);
}
}

View File

@ -0,0 +1,97 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu.staffhistory;
import com.google.common.collect.Maps;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import rip.bridge.bridge.bukkit.Bridge;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.Menu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.*;
public class MainStaffPunishmentListMenu extends Menu {
private String targetUUID;
private String targetName;
public String getTitle(Player player) {
return ChatColor.BLUE + "Staff History - " + this.targetName;
}
public Map<Integer, Button> getButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
if (player.hasPermission("bridge.punishments.view.blacklist")) {
buttons.put(0, this.button(PunishmentType.WARN));
buttons.put(2, this.button(PunishmentType.KICK));
buttons.put(4, this.button(PunishmentType.MUTE));
buttons.put(6, this.button(PunishmentType.BAN));
buttons.put(8, this.button(PunishmentType.BLACKLIST));
}
else {
buttons.put(1, this.button(PunishmentType.WARN));
buttons.put(3, this.button(PunishmentType.KICK));
buttons.put(5, this.button(PunishmentType.MUTE));
buttons.put(7, this.button(PunishmentType.BAN));
}
return buttons;
}
private Button button(PunishmentType type) {
return new Button() {
public String getName(Player player) {
return ChatColor.RED + type.getDisplayName() + "s";
}
public List<String> getDescription(Player player) {
return null;
}
public Material getMaterial(Player player) {
return Material.WOOL;
}
public byte getDamageValue(Player player) {
if (type == PunishmentType.WARN) {
return DyeColor.YELLOW.getWoolData();
}
if (type == PunishmentType.KICK) {
return DyeColor.GRAY.getWoolData();
}
if (type == PunishmentType.MUTE) {
return DyeColor.ORANGE.getWoolData();
}
if (type == PunishmentType.BAN) {
return DyeColor.RED.getWoolData();
}
return DyeColor.BLACK.getWoolData();
}
public void clicked(Player player, int i, ClickType clickType) {
player.closeInventory();
player.sendMessage(ChatColor.GREEN + "Loading " + MainStaffPunishmentListMenu.this.targetName + "'s " + type.getDisplayName() + " Staff History...");
List<Punishment> allPunishments = new ArrayList<>(BukkitAPI.getProfile(UUID.fromString(targetUUID)).getStaffPunishments());
Bukkit.getScheduler().scheduleAsyncDelayedTask(Bridge.getInstance(), () -> {
allPunishments.sort((first, second) -> Long.compare(second.getTime(), first.getTime()));
LinkedHashMap<Punishment, String> punishments = new LinkedHashMap<>();
allPunishments.stream().filter(punishment -> punishment.getPunishmentType().equals(type)).forEach(punishment -> punishments.put(punishment, punishment.getTarget().getUsername()));
Bukkit.getScheduler().scheduleSyncDelayedTask(Bridge.getInstance(), () -> new StaffPunishmentListMenu(targetUUID, targetName, type, punishments).openMenu(player));
});
}
};
}
public MainStaffPunishmentListMenu(String targetUUID, String targetName) {
this.targetUUID = targetUUID;
this.targetName = targetName;
setAutoUpdate(true);
}
}

View File

@ -0,0 +1,87 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu.staffhistory;
import com.google.common.collect.Lists;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.util.TimeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class StaffPunishmentButton extends Button {
private final Punishment punishment;
public StaffPunishmentButton(Punishment punishment){
this.punishment = punishment;
}
@Override
public String getName(Player player) {
return ChatColor.YELLOW + TimeUtils.formatIntoCalendarString(new Date(punishment.getTime()));
}
public List<String> getDescription(Player player) {
List<String> description = Lists.newArrayList();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
String by = punishment.getExecutor().getUsername();
String actor = "Server" + ChatColor.YELLOW + " : " + ChatColor.RED + this.punishment.getPunishedServer();
final String randomID = ChatColor.MAGIC + UUID.randomUUID().toString().substring(0, 8);
description.add(ChatColor.YELLOW + "Target: " + ChatColor.RED + punishment.getTarget().getUsername());
description.add(ChatColor.YELLOW + "By: " + ChatColor.RED + (BukkitAPI.getProfile(player).hasPermission("bridge.punishments.view.punisher") ? by : randomID));
description.add(ChatColor.YELLOW + "Added on: " + ChatColor.RED + actor);
description.add(ChatColor.YELLOW + "Reason: " + ChatColor.RED + this.punishment.getReason());
if (this.punishment.isActive()) {
if (!this.punishment.isPermanent()) {
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
description.add(ChatColor.YELLOW + "Time remaining: " + ChatColor.RED + DurationFormatUtils.formatDurationWords(Math.abs(punishment.getRemainingTime()), true, true));
}
else {
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
description.add(ChatColor.YELLOW + "This is a permanent punishment.");
}
}
else if (this.punishment.isPardoned()) {
String removedBy = this.punishment.getPardonedBy().getUsername();
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
description.add(ChatColor.RED + "Removed:");
description.add(ChatColor.YELLOW + (BukkitAPI.getProfile(player).hasPermission("bridge.punishments.view.punisher") ? removedBy : randomID) + ": " + ChatColor.RED + this.punishment.getPardonedReason());
description.add(ChatColor.RED + "at " + ChatColor.YELLOW + TimeUtils.formatIntoCalendarString(new Date(this.punishment.getPardonedAt())));
if (!this.punishment.isPermanent()) {
description.add("");
description.add(ChatColor.YELLOW + "Duration: " + TimeUtils.formatIntoDetailedString((int)((this.punishment.getRemainingTime()) / 1000L) + 1));
}
}
else if (!this.punishment.isPermanent() && this.punishment.getRemainingTime() <= 0) {
description.add(ChatColor.YELLOW + "Duration: " + TimeUtils.formatIntoDetailedString((int)((this.punishment.getRemainingTime()) / 1000L) + 1));
description.add(ChatColor.GREEN + "Expired");
}
description.add(ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + StringUtils.repeat("-", 25));
return description;
}
public Material getMaterial(Player player) {
return Material.WOOL;
}
public byte getDamageValue(Player player) {
return !this.punishment.isActive() ? DyeColor.RED.getWoolData() : DyeColor.LIME.getWoolData();
}
@Override
public void clicked(Player player, int slot, ClickType clickType) {
// new ProofMenu(punishment, punishment.getTarget().getUuid().toString(), punishment.getPunishmentType(), punishment.getTarget().getUsername().toString(), null).openMenu(player);
}
}

View File

@ -0,0 +1,74 @@
package rip.bridge.bridge.bukkit.commands.punishment.menu.staffhistory;
import com.google.common.collect.Maps;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.menu.Button;
import rip.bridge.qlib.menu.pagination.PaginatedMenu;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Map;
public class StaffPunishmentListMenu extends PaginatedMenu {
private String targetName;
private String targetUUID;
private PunishmentType type;
private Map<Punishment, String> punishments;
public String getPrePaginatedTitle(Player player) {
return ChatColor.RED + this.type.getDisplayName() + "s";
}
public Map<Integer, Button> getGlobalButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
buttons.put(4, new Button() {
public String getName(Player player) {
return ChatColor.YELLOW + "Back";
}
public List<String> getDescription(Player player) {
return null;
}
public Material getMaterial(Player player) {
return Material.PAPER;
}
public byte getDamageValue(Player player) {
return 0;
}
public void clicked(Player player, int i, ClickType clickType) {
player.closeInventory();
new MainStaffPunishmentListMenu(StaffPunishmentListMenu.this.targetUUID, StaffPunishmentListMenu.this.targetName).openMenu(player);
}
});
return buttons;
}
public Map<Integer, Button> getAllPagesButtons(Player player) {
Map<Integer, Button> buttons = Maps.newHashMap();
int index = 0;
for (Map.Entry<Punishment, String> entry : this.punishments.entrySet()) {
buttons.put(index, new StaffPunishmentButton(entry.getKey()));
++index;
}
return buttons;
}
public StaffPunishmentListMenu(String targetUUID, String targetName, PunishmentType type, Map<Punishment, String> punishments) {
this.targetUUID = targetUUID;
this.targetName = targetName;
this.punishments = punishments;
this.type = type;
setAutoUpdate(true);
}
}

View File

@ -0,0 +1,43 @@
package rip.bridge.bridge.bukkit.commands.punishment.remove;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class UnBanCommand {
@Command(names = {"unban"}, permission = "bridge.unban", description = "Remove a player's ban", async = true)
public static void unbanCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this unban to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getActivePunishments(PunishmentType.BAN).isEmpty()) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is not currently banned.");
return;
}
Punishment punishment = (Punishment) target.getActivePunishments(PunishmentType.BAN).toArray()[0];
if (punishment.isIP() && !s.hasPermission("bridge.unbanip")) {
s.sendMessage(ChatColor.RED + "You cannot unban " + target.getUsername() + " because they are ip-banned.");
return;
}
if (!BukkitAPI.canOverride(pf, punishment.getExecutor())) {
s.sendMessage(ChatColor.RED + "You cannot undo this punishment.");
return;
}
punishment.pardon(pf, BridgeGlobal.getSystemName(), reason, !silent);
target.getPunishments().add(punishment);
target.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,39 @@
package rip.bridge.bridge.bukkit.commands.punishment.remove;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class UnBanIPCommand {
@Command(names = {"unbanip"}, permission = "bridge.unbanip", description = "Remove a player's ban", async = true)
public static void unbanIPCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Publicly unban the player") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getActivePunishments(PunishmentType.BAN).isEmpty()) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is not currently ip-banned.");
return;
}
Punishment punishment = (Punishment) target.getActivePunishments(PunishmentType.BAN).toArray()[0];
if (!BukkitAPI.canOverride(pf, punishment.getExecutor())) {
s.sendMessage(ChatColor.RED + "You cannot undo this punishment.");
return;
}
punishment.pardon(pf, BridgeGlobal.getSystemName(), reason, !silent);
target.getPunishments().add(punishment);
target.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,39 @@
package rip.bridge.bridge.bukkit.commands.punishment.remove;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class UnBlacklistCommand {
@Command(names = {"unblacklist", "unbl"}, permission = "bridge.unblacklist", description = "Remove a player's blacklist", async = true)
public static void unblacklistCmd(CommandSender s, @Flag(value = {"a", "announce"}, description = "Announce this blacklist to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if (target.getActivePunishments(PunishmentType.BLACKLIST).isEmpty()) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is not currently blacklisted.");
return;
}
Punishment punishment = (Punishment) target.getActivePunishments(PunishmentType.BLACKLIST).toArray()[0];
if (!BukkitAPI.canOverride(pf, punishment.getExecutor())) {
s.sendMessage(ChatColor.RED + "You cannot undo this punishment.");
return;
}
punishment.pardon(pf, BridgeGlobal.getSystemName(), reason, !silent);
target.getPunishments().add(punishment);
target.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,44 @@
package rip.bridge.bridge.bukkit.commands.punishment.remove;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class UnMuteCommand {
@Command(names = {"unmute"}, permission = "bridge.unmute", description = "Remove a player's mute", async = true)
public static void unmuteCmd(CommandSender s, @Flag(value = { "a", "announce" }, description = "Announce this unmute to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if(target.getActivePunishments(PunishmentType.MUTE).isEmpty()) {
s.sendMessage(ChatColor.RED + target.getUsername() + " is not currently muted.");
return;
}
Punishment punishment = (Punishment) target.getActivePunishments(PunishmentType.MUTE).toArray()[0];
if(punishment.isIP() && !s.hasPermission("bridge.unmuteip")) {
s.sendMessage(ChatColor.RED + "You cannot unmute " + target.getUsername() + " because they are ip-muted.");
return;
}
if (!BukkitAPI.canOverride(pf, punishment.getExecutor())) {
s.sendMessage(ChatColor.RED + "You cannot undo this punishment.");
return;
}
punishment.pardon(pf, BridgeGlobal.getSystemName(), reason, !silent);
target.getPunishments().add(punishment);
target.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,40 @@
package rip.bridge.bridge.bukkit.commands.punishment.remove;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.PunishmentPacket;
import rip.bridge.bridge.global.profile.Profile;
import rip.bridge.bridge.global.punishment.Punishment;
import rip.bridge.bridge.global.punishment.PunishmentType;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Flag;
import rip.bridge.qlib.command.Param;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
public class UnWarnCommand {
@Command(names = {"unwarn"}, permission = "bridge.unwarn", description = "Remove a player's warn", async = true)
public static void unbanCmd(CommandSender s, @Flag(value = { "a", "announce" }, description = "Announce this unwarn to the server") boolean silent, @Param(name = "target") Profile target, @Param(name = "reason", wildcard = true) String reason) {
Profile pf = BukkitAPI.getProfile(s);
if(target.getActivePunishments(PunishmentType.WARN).isEmpty()) {
s.sendMessage(ChatColor.RED + target.getUsername() + " does not have an active warning.");
return;
}
Punishment punishment = (Punishment) target.getActivePunishments(PunishmentType.WARN).toArray()[0];
if (!BukkitAPI.canOverride(pf, punishment.getExecutor())) {
s.sendMessage(ChatColor.RED + "You cannot undo this punishment.");
return;
}
punishment.pardon(pf, BridgeGlobal.getSystemName(), reason, !silent);
target.getPunishments().add(punishment);
target.saveProfile();
PacketHandler.sendToAll(new PunishmentPacket(punishment));
}
}

View File

@ -0,0 +1,27 @@
package rip.bridge.bridge.bukkit.commands.rank;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.NetworkBroadcastPacket;
import rip.bridge.bridge.global.packet.types.RankCreatePacket;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class RankCreateCommand {
@Command(names = {"rank create"}, permission = "bridge.rank", description = "Create a rank", hidden = true, async = true)
public static void RankCreateCmd(CommandSender s, @Param(name = "rank") String name) {
Rank r = BukkitAPI.getRank(name);
if (r != null) {
s.sendMessage("§cThere is already a rank with the name \"" + r.getName() + "\".");
return;
}
r = BukkitAPI.createRank(name);
PacketHandler.sendToAll(new RankCreatePacket(r, s.getName(), BridgeGlobal.getSystemName()));
PacketHandler.sendToAll(new NetworkBroadcastPacket("bridge.update.view", "&8[&eServer Monitor&8] &fCreated rank " + r.getColor() + r.getDisplayName()));
s.sendMessage("§aSuccessfully created the rank " + r.getColor() + r.getName() + "§a!");
}
}

View File

@ -0,0 +1,22 @@
package rip.bridge.bridge.bukkit.commands.rank;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.NetworkBroadcastPacket;
import rip.bridge.bridge.global.packet.types.RankDeletePacket;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class RankDeleteCommand {
@Command(names = {"rank delete", "rank remove"}, permission = "bridge.rank", description = "Delete a rank", hidden = true, async = true)
public static void RankDeleteCmd(CommandSender s, @Param(name = "rank") Rank r) {
s.sendMessage("§aSuccessfully deleted the rank " + r.getColor() + r.getName() + "§a!");
BridgeGlobal.getMongoHandler().removeRank(r.getUuid(), callback -> {
}, true);
PacketHandler.sendToAll(new RankDeletePacket(r, s.getName(), BridgeGlobal.getServerName()));
PacketHandler.sendToAll(new NetworkBroadcastPacket("bridge.update.view", "&8[&eServer Monitor&8] &fDeleted rank " + r.getColor() + r.getDisplayName()));
}
}

View File

@ -0,0 +1,36 @@
package rip.bridge.bridge.bukkit.commands.rank;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class RankInfoCommand {
@Command(names = {"rank info"}, permission = "bridge.rank", description = "Get information about a rank", hidden = true, async = true)
public static void RankInfoCmd(CommandSender s, @Param(name = "rank") Rank r) {
s.sendMessage(BukkitAPI.LINE);
s.sendMessage(r.getColor() + r.getDisplayName() + " Rank §7❘ §fInformation");
s.sendMessage(BukkitAPI.LINE);
s.sendMessage("§6Prefix: §f" + r.getPrefix() + " §7(" + ChatColor.stripColor(r.getPrefix().replaceAll("§", "&")) + ")");
s.sendMessage("§6Suffix: §f" + r.getSuffix() + " §7(" + ChatColor.stripColor(r.getSuffix().replaceAll("§", "&")) + ")");
s.sendMessage("§6Priority: §f" + r.getPriority());
s.sendMessage("§6Staff: §f" + r.isStaff());
s.sendMessage("§6Media: §f" + r.isMedia());
s.sendMessage("§6Builder: §f" + r.isBuilder());
s.sendMessage("§6Default: §f" + r.isDefaultRank());
s.sendMessage(ChatColor.GOLD + "Permissions (" + r.getPermissions().size() + ChatColor.GOLD + "): ");
if (r.getPermissions().isEmpty()) s.sendMessage(ChatColor.RED + "None...");
else r.getPermissions().keySet().forEach(str -> {
s.sendMessage(ChatColor.GRAY + " * " + ChatColor.WHITE + str + ChatColor.GRAY + " [" + r.getPermissions().get(str) + "]");
});
s.sendMessage("");
s.sendMessage("§6Inherits (" + r.getInherits().size() + ChatColor.GOLD + "): " + (r.getInherits().isEmpty() ? "§cNone..." : ""));
if (!r.getInherits().isEmpty())
r.getInherits().forEach(rank -> s.sendMessage(" §7* §f" + rank.getColor() + rank.getDisplayName()));
s.sendMessage(BukkitAPI.LINE);
}
}

View File

@ -0,0 +1,22 @@
package rip.bridge.bridge.bukkit.commands.rank;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.NetworkBroadcastPacket;
import rip.bridge.bridge.global.packet.types.RankUpdatePacket;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class RankInheritCommand {
@Command(names = {"rank inherit"}, permission = "bridge.rank", description = "Add/remove a rank inherit", hidden = true, async = true)
public static void RankPermissionCmd(CommandSender s, @Param(name = "rank") Rank r, @Param(name = "inherit") Rank inhr) {
boolean b = r.toggleInherit(inhr);
r.saveRank();
s.sendMessage("§aSuccessfully " + (b ? "added" : "removed") + " the inherit of " + inhr.getColor() + inhr.getDisplayName());
PacketHandler.sendToAll(new RankUpdatePacket(r, s.getName(), BridgeGlobal.getSystemName()));
PacketHandler.sendToAll(new NetworkBroadcastPacket("bridge.update.view", "&8[&eServer Monitor&8] &fRefreshed rank " + r.getColor() + r.getDisplayName()));
}
}

View File

@ -0,0 +1,57 @@
package rip.bridge.bridge.bukkit.commands.rank;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.BukkitAPI;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import java.util.ArrayList;
public class RankListCommand {
@Command(names = {"rank list"}, permission = "bridge.rank", description = "List all ranks", hidden = true, async = true)
public static void RankListCmd(CommandSender s) {
s.sendMessage(BukkitAPI.LINE);
s.sendMessage("§6§lRanks §f(" + BridgeGlobal.getRankHandler().getRanks().size() + ")");
s.sendMessage(BukkitAPI.LINE);
ArrayList<Rank> rankList = new ArrayList<>(BridgeGlobal.getRankHandler().getRanks());
rankList.sort((o1, o2) -> o2.getPriority() - o1.getPriority());
rankList.forEach(rank -> {
if (s instanceof Player) {
ComponentBuilder cp = new ComponentBuilder(rank.getColor() + rank.getDisplayName() + " §7❘ §f" + rank.getName() + (rank.isHidden() ? " §7[Hidden]" : "")).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
"§6Prefix: §f" + rank.getPrefix() + " §7(" + ChatColor.stripColor(rank.getPrefix().replaceAll("§", "&")) + ")" + "\n" +
"§6Suffix: §f" + rank.getSuffix() + " §7(" + ChatColor.stripColor(rank.getSuffix().replaceAll("§", "&")) + ")" + "\n" +
"§6Priority: §f" + rank.getPriority() + "\n" +
"§6Staff: §f" + rank.isStaff() + "\n" +
"§6Media: §f" + rank.isMedia() + "\n" +
"§6Builder: §f" + rank.isBuilder() + "\n" +
"§6Default: §f" + rank.isDefaultRank() + "\n\n" +
"§7§oClick for more information"
))).event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/rank info " + rank.getName()));
((Player) s).spigot().sendMessage(cp.create());
} else {
s.sendMessage(rank.getColor() + rank.getDisplayName() + " §7❘ §f" + rank.getName() + (rank.isHidden() ? " §7[Hidden]" : ""));
s.sendMessage("§6Prefix: §f" + rank.getPrefix() + " §7(" + ChatColor.stripColor(rank.getPrefix().replaceAll("§", "&")) + ")");
s.sendMessage("§6Suffix: §f" + rank.getSuffix() + " §7(" + ChatColor.stripColor(rank.getSuffix().replaceAll("§", "&")) + ")");
s.sendMessage("§6Priority: §f" + rank.getPriority());
s.sendMessage("§6Staff: §f" + rank.isStaff());
s.sendMessage("§6Media: §f" + rank.isMedia());
s.sendMessage("§6Builder: §f" + rank.isBuilder());
s.sendMessage("§6Default: §f" + rank.isDefaultRank());
s.sendMessage("");
}
});
s.sendMessage("");
s.sendMessage(s instanceof Player ? "§7§oHover over the ranks for more information." : "§7§oType /rank info <rank> for more information.");
s.sendMessage(BukkitAPI.LINE);
}
}

View File

@ -0,0 +1,23 @@
package rip.bridge.bridge.bukkit.commands.rank;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.bukkit.commands.rank.menu.RankMenu;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class RankManageCommand {
@Command(names = {"rank manage"}, permission = "bridge.rank", description = "Manage a rank", hidden = true, async = true)
public static void RankMangeCmd(CommandSender s, @Param(name = "rank") String name) {
Rank r = BridgeGlobal.getRankHandler().getRankByName(name);
if (r == null) {
s.sendMessage("§cThere is no such rank with the name \"" + name + "\".");
return;
}
new RankMenu(r).openMenu((Player) s);
}
}

View File

@ -0,0 +1,22 @@
package rip.bridge.bridge.bukkit.commands.rank;
import org.bukkit.command.CommandSender;
import rip.bridge.bridge.BridgeGlobal;
import rip.bridge.bridge.global.packet.PacketHandler;
import rip.bridge.bridge.global.packet.types.NetworkBroadcastPacket;
import rip.bridge.bridge.global.packet.types.RankUpdatePacket;
import rip.bridge.bridge.global.ranks.Rank;
import rip.bridge.qlib.command.Command;
import rip.bridge.qlib.command.Param;
public class RankPermissionCommand {
@Command(names = {"rank permission", "rank perm"}, permission = "bridge.rank", description = "Add/remove a permission", hidden = true, async = true)
public static void RankPermissionCmd(CommandSender s, @Param(name = "rank") Rank r, @Param(name = "permission") String perm, @Param(name = "group", defaultValue = "§") String serverGroup) {
String group = serverGroup.equals("§") ? "Global" : serverGroup;
boolean b = r.togglePerm(perm, group);
r.saveRank();
s.sendMessage("§aSuccessfully " + (b ? "added" : "removed") + " the permission " + perm + " to the scope: " + group);
PacketHandler.sendToAll(new RankUpdatePacket(r, s.getName(), BridgeGlobal.getSystemName()));
}
}

Some files were not shown because too many files have changed in this diff Show More