Skip to content
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ jobs:
run: ./gradlew publishAllPublicationsToTestingRepository
- name: Display directory structure of testing repo
run: ls -R build/testing-mvn-repo
- name: Upload info if failure
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: java-${{matrix.version}}-failed-build
path: build/*
- name: Save output from testing repo
uses: actions/upload-artifact@v2
with:
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*.tar.gz
*.rar


# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

Expand Down Expand Up @@ -51,5 +52,5 @@ bin
.idea
*.code-workspace

# Generated resources
common/src/main/resources/generated/*
# Generated files
**/generated/
42 changes: 37 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.nio.file.Paths

plugins {
id "io.freefair.lombok" version "5.3.3.3" apply false
// spotless for license headers and linting
Expand All @@ -7,12 +9,14 @@ plugins {

// pom packaging for root
id "java-platform"
id 'idea'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is up with all this spacing lul

}

allprojects {
group = "com.dumbdogdiner"
version = "3.0.3"

apply plugin: "idea"
// java plugin is applied in subprojects
apply plugin: "jacoco"

Expand Down Expand Up @@ -157,6 +161,7 @@ subprojects {

tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-XDignore.symbol.file"
dependsOn(processResources)
}

configurations {
Expand Down Expand Up @@ -185,6 +190,10 @@ subprojects {
forRepositories(dddResources)
filter { includeGroup("dumbdogdiner") }
}
maven {
name = "HeadDatabase-API"
url = uri("https://mvn.intellectualsites.com/content/repositories/thirdparty/")
}
}

dependencies {
Expand Down Expand Up @@ -231,7 +240,10 @@ subprojects {
delombok.encoding = "UTF-8"
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
javadoc.options.encoding = "UTF-8"
tasks.withType(Javadoc) {
options.addBooleanOption("quiet", true)
options.encoding = "UTF-8"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be specified if it's in allprojects {}, no?

}

// Javadoc: Add rootproject name in title for consistency
javadoc.title = "$rootProject.name-$project.name $project.version API"
Expand Down Expand Up @@ -275,6 +287,7 @@ task rootSources(type: Jar, dependsOn: subprojects.classes) {
dependsOn(":common:commonSources")

archiveClassifier.set("sources")
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
// Use source code from all subprojects for sources.
// TODO: Use certain subprojects only to allow for multiple jar outputs
from subprojects.sourceSets.main.allSource
Expand Down Expand Up @@ -344,15 +357,34 @@ aggregateJavadoc.options.encoding = "UTF-8"
// Root Javadoc: Set title and output dir
aggregateJavadoc.title = "StickyAPI $project.version API (Aggregated)"
aggregateJavadoc.destinationDir = file("$buildDir/docs/javadoc")
/*
Since JDK13 the javadoc html validator was changed, making it impossible to have javadocs
that are valid on both pre-13 and post-13 java versions.
The original workaround was suggested here: https://bugs.openjdk.java.net/browse/JDK-8223552
However, this workaround does not work for us since we are using aggregate-javadoc.
So, we are using a workaround for the workaround from:
original: https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
archived: https://web.archive.org/web/20210117193942/https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
which, in turn, references this: https://github.com/GPars/GPars/blob/7cddf7cf2fec1fd66ef800edccfc03315d078a2b/build.gradle#L209
*/

task browseJavadoc {
dependsOn aggregateJavadoc
allprojects {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth checking with @Prouser123 - not sure if you've done this already.

tasks.withType(Javadoc) {
options.addBooleanOption("Xdoclint:-html", JavaVersion.current().isJava11Compatible())
options.addBooleanOption("-frames", JavaVersion.current().isJava11())
options.memberLevel = JavadocMemberLevel.PRIVATE
options.encoding = "UTF-8"
}
task browseJavadoc {
dependsOn javadoc
description "Browse javadoc"
group = "documentation"
doLast {
java.awt.Desktop.desktop.browse new URI(("file:///" << System.getProperty("user.dir").replace('\\','/') << "/build/docs/javadoc/index.html").toString())
java.awt.Desktop.desktop.browse getProjectDir().toPath().resolve("build/docs/javadoc/index.html").toUri()
}
}
}


tasks.publish.dependsOn build

Expand All @@ -364,4 +396,4 @@ publishing {
artifact rootSources // Publish the output of the (root) sources task
}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

9 changes: 3 additions & 6 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ test.jvmArgs = ["--add-opens=java.base/java.lang.reflect=ALL-UNNAMED"]
These is also an accompanying test at (test src) com.dumbdogdiner.stickyapi.StickyAPITest
*/


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

// Set the timestamp format
def dataBuildTimestamp = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"

Expand Down Expand Up @@ -81,12 +82,8 @@ task processSourceTokens(type: Sync) {
// Use the filter task as the input for compileJava
compileJava.source = processSourceTokens.outputs


/*
Font Width Info
----------
This task serves to copy width data from the default Minecraft font into the final jar.
This data is generated by <https://github.com/DumbDogDiner/mc-font-extractor>.
/**
* Task to clean generated resources
*/

// Font Width Info
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2020-2021 DumbDogDiner <dumbdogdiner.com>. All rights reserved.
* Licensed under the MIT license, see LICENSE for more information...
*/
package com.dumbdogdiner.stickyapi.annotation;

/**
* Denotes a method, class, or interface that is currently broken. Optionally links to a page about the issue
*/
public @interface Broken {
public String issuepage() default "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2020-2021 DumbDogDiner <dumbdogdiner.com>. All rights reserved.
* Licensed under the MIT license, see LICENSE for more information...
*/
package com.dumbdogdiner.stickyapi.annotation;

import java.lang.annotation.Documented;


/**
* Do not call a method annotated with this, it will do bad things
*/
@Documented
public @interface DoNotCall {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this existtttt

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check where it's used

Copy link
Collaborator

@kaylendog kaylendog Mar 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point still stands? This isn't really something we need

Copy link
Collaborator Author

@aakatz3 aakatz3 Mar 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its needed because if any of the methods are called, it will crash, so its for documentation, and can be used with google's errorprone (or that can be used) to make sure they are not called

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but please don't add things unrelated to a PR without asking the rest of the team - for future reference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would also like to add that if you dont want a specific method to be called, please use the correct modifier for your use case instead of creating annotations that wont prevent the user from executing this method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be able to do stuff via refactor though

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cloned from previous PR:

Would prefer it if we can write things in a way where methods that are strictly internal can't be called externally.

So yes, would be nice if you can refactor this in a way that doesn't cause this issue.


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
*/
package com.dumbdogdiner.stickyapi.common.util;

import java.nio.charset.StandardCharsets;
import java.text.DecimalFormat;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -308,6 +310,43 @@ public static UUID hyphenateUUID(@NotNull String uuid) {
}
}

/**
* Remove hyphons from a UUID object and return a string
* <p>
* e.x. de8c89e1-2f25-424d-8078-c6ff58db7d6e -&gt;
* de8c89e12f25424d8078c6ff58db7d6e
*
* @param uuid the UUID to de-hyphenate
* @return a string representation of the UUID, without any hyphens
*/
public static @NotNull String unhyphenateUUID(@NotNull UUID uuid){
return unhyphenate(uuid.toString());
}

public static @NotNull String unhyphenate(@NotNull String str){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be its own method given it's such a tiny snippet? The snippet itself is a wonderful 3 characters longer...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a pair with hyphenate, for completeness

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imo it's not really necessary

return str.replace("-","");
}


/**
* Utility method to ensure Base64 encoding is done consistently.
* @param str The {@link String} to be encoded
* @return The encoded {@link String}
*/
public static @NotNull String encodeBase64(@NotNull String str) {
return new String(Base64.getEncoder().encode(str.getBytes(StandardCharsets.UTF_8)));
}

/**
* Utility method to ensure Base64 decoding is done consistently.
* @param str A {@link String} containing the Base64-encoded data
* @return A string of UTF-8 Text decoded from the input
* @throws IllegalArgumentException if the Base64 decoding fails
*/
public static @NotNull String decodeBase64(String str) throws IllegalArgumentException {
return new String(Base64.getDecoder().decode(str), StandardCharsets.UTF_8);
}

/**
* Creates a random string of "magic" characters of characters
*
Expand Down Expand Up @@ -369,5 +408,4 @@ public static String randomObfuscatedString(int min, int max, int minRunBeforeSp
public static String formatChatCodes(String input) {
return input.replaceAll("&(?=([a-f]|[0-9]|[klmnor]))", Character.toString(ChatColor.COLOR_CHAR));
}

}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
*/
package com.dumbdogdiner.stickyapi_tests_common;

import com.dumbdogdiner.stickyapi.StickyAPI;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Handler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.logging.StreamHandler;

public class TestsCommon {
// Enums are counted in code coverage for some reason - so this function just invlokes valueOf on all enums it can find in a enum class.
// https://stackoverflow.com/questions/4512358/emma-coverage-on-enum-types/4548912
Expand All @@ -16,4 +25,36 @@ public static void superficialEnumCodeCoverage(Class<? extends Enum<?>> enumClas
throw new RuntimeException(e);
}
}

private static Handler maskedHandler = new StreamHandler(System.out, new SimpleFormatter());
private static List<Handler> handlers = new ArrayList<>();

public static void disableHandlers() {
Logger l = StickyAPI.getLogger();
l.setUseParentHandlers(false);
for (Handler h : l.getHandlers()) {
handlers.add(h);
l.removeHandler(h);
}
}

public static void enableHandlers() {
Logger l = StickyAPI.getLogger();
l.setUseParentHandlers(true);
for(Handler h : handlers){
l.addHandler(h);
}


}

public static void addMaskedHandler(){
Logger l = StickyAPI.getLogger();
l.addHandler(maskedHandler);
}

public static void removeMaskedHandler(){
Logger l = StickyAPI.getLogger();
l.removeHandler(maskedHandler);
}
}
23 changes: 23 additions & 0 deletions heads/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
repositories {
mavenCentral()
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
}

dependencies {
implementation project(":common")
testImplementation project(":common").sourceSets.test.output

implementation project(":bukkit")
testImplementation project(":bukkit").sourceSets.test.output

implementation project(":webapi")
testImplementation project(":webapi").sourceSets.test.output

implementation project(":textures")
testImplementation project(":textures").sourceSets.test.output

compileOnly "com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT"

testImplementation 'com.github.seeseemelk:MockBukkit-v1.16:0.25.0'
testImplementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.2.1'
}
3 changes: 3 additions & 0 deletions heads/lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This file is generated by the 'io.freefair.lombok' Gradle plugin
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
Loading