Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Begin multiversion support #70

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
239 changes: 239 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
<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>
<parent>
<groupId>dev.pgm</groupId>
<artifactId>Community</artifactId>
<version>0.2-SNAPSHOT</version>
</parent>
<artifactId>core</artifactId>

<dependencies>
<dependency>
<groupId>dev.pgm</groupId>
<artifactId>platform-all</artifactId>
<version>0.2-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>dev.pgm</groupId>
<artifactId>util</artifactId>
<version>0.2-SNAPSHOT</version>
</dependency>

<!-- Depend on the lowest common denominator -->
<dependency>
<groupId>dev.pgm.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.8_1.21-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>6.0.54</version>
<scope>provided</scope>
</dependency>

<!-- Database Operations -->
<dependency>
<groupId>co.aikar</groupId>
<artifactId>idb-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>co.aikar</groupId>
<artifactId>idb-bukkit</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

<!-- Redis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.5.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>

<!-- Smart Invs - https://github.com/MinusKube/SmartInvs -->
<dependency>
<groupId>fr.minuskube.inv</groupId>
<artifactId>smart-invs</artifactId>
<version>1.2.7</version>
</dependency>

<!-- Environment -->
<dependency>
<groupId>tc.oc.occ</groupId>
<artifactId>Environment</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

<!-- Apache commons -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<finalName>Community</finalName>
<resources>
<!-- Include the required plugin.yml and config.yml for Bukkit -->
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.incendo</groupId>
<artifactId>cloud-annotations</artifactId>
<version>2.0.0-rc.2</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>net.kyori:*:*</include>
<include>co.aikar:*</include>
<include>tc.oc.pgm:util</include>
<include>redis.clients:jedis</include>
<include>org.apache.commons:commons-pool2</include>
<include>fr.minuskube.inv:smart-invs</include>
<include>com.zaxxer:HikariCP</include>
<include>org.slf4j:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>dev.pgm:platform-all:*</artifact>
<includes>
<include>**</include>
</includes>
</filter>
<filter>
<artifact>dev.pgm:util:*</artifact>
<includes>
<include>**</include>
</includes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Exposes git information to the build environment -->
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>

<!-- Validates that code is properly formatted with Google's code style -->
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<configuration>
<ratchetFrom>origin/dev</ratchetFrom>
<java>
<removeUnusedImports/>
<palantirJavaFormat>
<version>2.47.0</version>
<style>GOOGLE</style>
<formatJavadoc>true</formatJavadoc>
</palantirJavaFormat>
</java>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Allows for building of java docs, although not used yet -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<failOnError>false</failOnError>
<includeDependencySources>true</includeDependencySources>
</configuration>
</plugin>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>jar</id>
<phase>package</phase>
<configuration>
<target>
<copy file="${basedir}/target/${project.build.finalName}.jar"
tofile="../target/Community.jar"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public void callEvent(CommunityEvent event) {
// REMOVE WHEN NOT IN DEV
public static void log(String format, Object... objects) {
Bukkit.getConsoleSender()
.sendMessage(
ChatColor.translateAlternateColorCodes(
'&', String.format("&7[&4Community&7]&r " + format, objects)));
.sendMessage(ChatColor.translateAlternateColorCodes(
'&', String.format("&7[&4Community&7]&r " + format, objects)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ public Set<Player> getPlayers() {
}

public Component getText() {
List<Component> names =
players.stream()
.map(p -> player(p, NameStyle.FANCY))
.limit(Math.min(players.size(), 10))
.collect(Collectors.toList());
List<Component> names = players.stream()
.map(p -> player(p, NameStyle.FANCY))
.limit(Math.min(players.size(), 10))
.collect(Collectors.toList());

Component hover = TextFormatter.list(names, NamedTextColor.GRAY);
if (getPlayers().size() > names.size()) {
Expand Down Expand Up @@ -101,10 +100,9 @@ protected PlayerSelection getPlayers(CommandAudience viewer, String input) {
input.equalsIgnoreCase("*") && viewer.hasPermission(CommunityPermissions.ALL_SELECTOR);
boolean isRandom =
input.startsWith("?") && viewer.hasPermission(CommunityPermissions.RANDOM_SELECTOR);
boolean isTeam =
input.startsWith("team=")
&& PGMUtils.isPGMEnabled()
&& viewer.hasPermission(CommunityPermissions.TEAM_SELECTOR);
boolean isTeam = input.startsWith("team=")
&& PGMUtils.isPGMEnabled()
&& viewer.hasPermission(CommunityPermissions.TEAM_SELECTOR);

String[] parts = input.split("=");

Expand All @@ -114,25 +112,23 @@ protected PlayerSelection getPlayers(CommandAudience viewer, String input) {
Component text;
if (isAll) {
targets.addAll(allOnline);
text =
text()
.append(text("everyone "))
.append(text("("))
.append(text(targets.size(), NamedTextColor.GREEN))
.append(text(")"))
.color(NamedTextColor.GRAY)
.build();
text = text()
.append(text("everyone "))
.append(text("("))
.append(text(targets.size(), NamedTextColor.GREEN))
.append(text(")"))
.color(NamedTextColor.GRAY)
.build();
} else if (isRandom) {
int randomCount = parts.length == 2 ? parseInputInt(input, 1) : 1;
for (int i = 0; i < randomCount; i++) {
targets.add(allOnline.get(Community.get().getRandom().nextInt(allOnline.size())));
}
String rdTxt = " randomly chosen player" + (targets.size() != 1 ? "s" : "");
text =
text()
.append(text(targets.size(), NamedTextColor.GREEN))
.append(text(rdTxt, NamedTextColor.GRAY))
.build();
text = text()
.append(text(targets.size(), NamedTextColor.GREEN))
.append(text(rdTxt, NamedTextColor.GRAY))
.build();
} else if (isTeam) {
Match match = PGMUtils.getMatch();
if (match.getModule(TeamMatchModule.class) != null) {
Expand All @@ -145,21 +141,19 @@ protected PlayerSelection getPlayers(CommandAudience viewer, String input) {
// Allow Observers to be selected
if (teamName.toLowerCase().startsWith("obs")) {
text = text("Observers", NamedTextColor.AQUA);
targets.addAll(
match.getObservers().stream()
.map(MatchPlayer::getBukkit)
.collect(Collectors.toList()));
targets.addAll(match.getObservers().stream()
.map(MatchPlayer::getBukkit)
.collect(Collectors.toList()));
} else {
Team team = teams.bestFuzzyMatch(teamName);
if (team == null) {
throw TextException.exception(teamName + " is not a valid team name");
}
targets.addAll(
team.getPlayers().stream().map(MatchPlayer::getBukkit).collect(Collectors.toList()));
text =
text()
.append(text(team.getNameLegacy(), TextFormatter.convert(team.getColor())))
.build();
text = text()
.append(text(team.getNameLegacy(), TextFormatter.convert(team.getColor())))
.build();
}
} else {
throw TextException.exception("There are no teams in this match to select");
Expand All @@ -172,12 +166,11 @@ protected PlayerSelection getPlayers(CommandAudience viewer, String input) {
targets.add(player);
}
}
text =
text()
.append(text(targets.size(), NamedTextColor.GREEN))
.append(text(" player" + (targets.size() != 1 ? "s" : "")))
.color(NamedTextColor.GRAY)
.build();
text = text()
.append(text(targets.size(), NamedTextColor.GREEN))
.append(text(" player" + (targets.size() != 1 ? "s" : "")))
.color(NamedTextColor.GRAY)
.build();

if (targets.size() > 1 && !viewer.hasPermission(CommunityPermissions.SELECTOR)) {
// If no permission for multiple, get a random single entry
Expand Down Expand Up @@ -239,9 +232,8 @@ protected UUID getOnlineTarget(String target, UsersFeature service) {
if (id == null) {
// TODO: Maybe use getStoredID and listen, that way we can account for EVERYONE. But not a
// priority now
Optional<UUID> cachedId =
service.getId(
target); // If user is online or was online recently, we will have their UUID.
Optional<UUID> cachedId = service.getId(
target); // If user is online or was online recently, we will have their UUID.
if (!cachedId.isPresent()) {
throw TextException.exception(formatNotFoundMsg(target));
} else {
Expand Down
Loading
Loading