Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
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/
37 changes: 29 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ plugins {
id "io.freefair.lombok" version "5.3.0" apply false
id "com.github.hierynomus.license" version "0.15.0" apply false

// root project - intellij

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


// root project - generate project-wide javadocs
id "io.freefair.aggregate-javadoc" version "5.3.0"
}
Expand All @@ -10,6 +14,8 @@ allprojects {
group = "com.dumbdogdiner"
version = "2.2.0"

apply plugin: "idea"

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

apply plugin: "java"
apply plugin: "jacoco"

Expand Down Expand Up @@ -62,6 +68,7 @@ subprojects {

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

configurations {
Expand Down Expand Up @@ -142,7 +149,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?

}


// Run the license formatter and font data copier before compiling the source code.
Expand Down Expand Up @@ -231,12 +241,23 @@ aggregateJavadoc.options.encoding = "UTF-8"
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
*/
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
// options.addStringOption("Xdoclint:-html", "-quiet")
options.addBooleanOption("Xdoclint:-html", true)
}

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())
}
}

Expand All @@ -250,4 +271,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
}
}

58 changes: 41 additions & 17 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
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 @@ -58,25 +59,48 @@ 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
task copyMCFontExtractor(type: Copy) {
def path = project.configurations.compile.find {it.name.startsWith("mc-font-extractor") }
println("common: Found font data at: " + path)
from file(path)
// into file("src/main/resources")
// - Please keep this comment for future reference.
// - This is how we would do this if we weren't also adding build info (see processSourceTokens, above comments)
destinationDir file("src/main/resources/generated/")
rename "mc-font-extractor-main-mojangles_width_data.json", "mojangles_width_data.json"
task cleanGeneratedResources(type: Delete) {
delete("src/main/resources/generated/")
}

clean {
dependsOn(cleanGeneratedResources)
}
configure(cleanGeneratedResources){
group = "Build"
description = "Clean generated/downloaded resource files"
}

// Run the license formatter and font data copier before compiling the source code.
tasks.compileJava.dependsOn licenseFormatMain, licenseFormatTest, copyMCFontExtractor
tasks.compileJava.dependsOn licenseFormatMain, licenseFormatTest, processResources

task downloadTextures(type: Download){
sourceUrl = "https://dumbdogdiner.github.io/mc-heads-resource/textures.json"
target = file("src/main/resources/generated/textures.json")
}

task downloadFontWidths(type: Download){
sourceUrl = "https://dumbdogdiner.github.io/mc-font-extractor/main/mojangles_width_data.json"
target = file("src/main/resources/generated/mojangles_width_data.json")
}

processResources {
dependsOn(downloadTextures, downloadFontWidths)
}

class Download extends DefaultTask {
@Input
String sourceUrl

@OutputFile
File target

@TaskAction
void download() {
ant.get(src: sourceUrl, dest: target, verbose: true)
}
}
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 @@ -307,6 +309,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 @@ -366,5 +405,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);
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
Copy link
Collaborator

Choose a reason for hiding this comment

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

From previous PR:

For future reference: please don't change Gradle versions without asking one of us!

zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
compileJava.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.

Suggested change
compileJava.options.encoding=UTF-8
compileJava.options.encoding=UTF-8

34 changes: 34 additions & 0 deletions heads/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
plugins {
id 'java'
}

group 'com.dumbdogdiner'
version '2.2.0'

repositories {
mavenCentral()
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
}

dependencies {
compile project(":common")
testCompile project(":common").sourceSets.test.output

compile project(":bukkit")
testCompile project(":bukkit").sourceSets.test.output

compile project(":webapi")
testCompile project(":webapi").sourceSets.test.output

compile project(":textures")
testCompile project(":textures").sourceSets.test.output

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consistent "-ing pls

testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.16:0.25.0'
testImplementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.2.1'
}

test {
useJUnitPlatform()
}
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
}
}

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