Skip to content

Commit 8f9a805

Browse files
committed
Lots of heads work
1 parent 98123df commit 8f9a805

File tree

55 files changed

+38844
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+38844
-19
lines changed

build.gradle

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ plugins {
22
id "io.freefair.lombok" version "5.3.0" apply false
33
id "com.github.hierynomus.license" version "0.15.0" apply false
44

5+
// root project - intellij
6+
7+
id 'idea'
8+
59
// root project - generate project-wide javadocs
610
id "io.freefair.aggregate-javadoc" version "5.3.0"
711
}
@@ -10,6 +14,8 @@ allprojects {
1014
group = "com.dumbdogdiner"
1115
version = "2.2.0"
1216

17+
apply plugin: "idea"
18+
1319
apply plugin: "java"
1420
apply plugin: "jacoco"
1521

@@ -62,6 +68,7 @@ subprojects {
6268

6369
tasks.withType(JavaCompile) {
6470
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-XDignore.symbol.file"
71+
dependsOn(processResources)
6572
}
6673

6774
configurations {
@@ -142,7 +149,10 @@ subprojects {
142149
delombok.encoding = "UTF-8"
143150
compileJava.options.encoding = "UTF-8"
144151
compileTestJava.options.encoding = "UTF-8"
145-
javadoc.options.encoding = "UTF-8"
152+
tasks.withType(Javadoc) {
153+
options.addBooleanOption("quiet", true)
154+
options.encoding = "UTF-8"
155+
}
146156

147157

148158
// Run the license formatter and font data copier before compiling the source code.

common/build.gradle

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ dependencies {
2828
These is also an accompanying test at (test src) com.dumbdogdiner.stickyapi.StickyAPITest
2929
*/
3030

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

@@ -58,25 +59,48 @@ task processSourceTokens(type: Sync) {
5859
// Use the filter task as the input for compileJava
5960
compileJava.source = processSourceTokens.outputs
6061

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

69-
// Font Width Info
70-
task copyMCFontExtractor(type: Copy) {
71-
def path = project.configurations.compile.find {it.name.startsWith("mc-font-extractor") }
72-
println("common: Found font data at: " + path)
73-
from file(path)
74-
// into file("src/main/resources")
75-
// - Please keep this comment for future reference.
76-
// - This is how we would do this if we weren't also adding build info (see processSourceTokens, above comments)
77-
destinationDir file("src/main/resources/generated/")
78-
rename "mc-font-extractor-main-mojangles_width_data.json", "mojangles_width_data.json"
66+
task cleanGeneratedResources(type: Delete) {
67+
delete("src/main/resources/generated/")
68+
}
69+
70+
clean {
71+
dependsOn(cleanGeneratedResources)
72+
}
73+
configure(cleanGeneratedResources){
74+
group = "Build"
75+
description = "Clean generated/downloaded resource files"
7976
}
8077

8178
// Run the license formatter and font data copier before compiling the source code.
82-
tasks.compileJava.dependsOn licenseFormatMain, licenseFormatTest, copyMCFontExtractor
79+
tasks.compileJava.dependsOn licenseFormatMain, licenseFormatTest, processResources
80+
81+
task downloadTextures(type: Download){
82+
sourceUrl = "https://dumbdogdiner.github.io/mc-heads-resource/textures.json"
83+
target = file("src/main/resources/generated/textures.json")
84+
}
85+
86+
task downloadFontWidths(type: Download){
87+
sourceUrl = "https://dumbdogdiner.github.io/mc-font-extractor/main/mojangles_width_data.json"
88+
target = file("src/main/resources/generated/mojangles_width_data.json")
89+
}
90+
91+
processResources {
92+
dependsOn(downloadTextures, downloadFontWidths)
93+
}
94+
95+
class Download extends DefaultTask {
96+
@Input
97+
String sourceUrl
98+
99+
@OutputFile
100+
File target
101+
102+
@TaskAction
103+
void download() {
104+
ant.get(src: sourceUrl, dest: target, verbose: true)
105+
}
106+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2020-2021 DumbDogDiner <dumbdogdiner.com>. All rights reserved.
3+
* Licensed under the MIT license, see LICENSE for more information...
4+
*/
5+
package com.dumbdogdiner.stickyapi.annotation;
6+
7+
/**
8+
* Denotes a method, class, or interface that is currently broken. Optionally links to a page about the issue
9+
*/
10+
public @interface Broken {
11+
public String issuepage() default "";
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2020-2021 DumbDogDiner <dumbdogdiner.com>. All rights reserved.
3+
* Licensed under the MIT license, see LICENSE for more information...
4+
*/
5+
package com.dumbdogdiner.stickyapi.annotation;
6+
7+
import java.lang.annotation.Documented;
8+
9+
10+
/**
11+
* Do not call a method annotated with this, it will do bad things
12+
*/
13+
@Documented
14+
public @interface DoNotCall {
15+
16+
}

common/src/main/java/com/dumbdogdiner/stickyapi/common/util/StringUtil.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
*/
55
package com.dumbdogdiner.stickyapi.common.util;
66

7+
import java.nio.charset.StandardCharsets;
78
import java.text.DecimalFormat;
9+
import java.util.Base64;
810
import java.util.HashMap;
911
import java.util.Map;
1012
import java.util.UUID;
@@ -307,6 +309,43 @@ public static UUID hyphenateUUID(@NotNull String uuid) {
307309
}
308310
}
309311

312+
/**
313+
* Remove hyphons from a UUID object and return a string
314+
* <p>
315+
* e.x. de8c89e1-2f25-424d-8078-c6ff58db7d6e -&gt;
316+
* de8c89e12f25424d8078c6ff58db7d6e
317+
*
318+
* @param uuid the UUID to de-hyphenate
319+
* @return a string representation of the UUID, without any hyphens
320+
*/
321+
public static @NotNull String unhyphenateUUID(@NotNull UUID uuid){
322+
return unhyphenate(uuid.toString());
323+
}
324+
325+
public static @NotNull String unhyphenate(@NotNull String str){
326+
return str.replace("-","");
327+
}
328+
329+
330+
/**
331+
* Utility method to ensure Base64 encoding is done consistently.
332+
* @param str The {@link String} to be encoded
333+
* @return The encoded {@link String}
334+
*/
335+
public static @NotNull String encodeBase64(@NotNull String str) {
336+
return new String(Base64.getEncoder().encode(str.getBytes(StandardCharsets.UTF_8)));
337+
}
338+
339+
/**
340+
* Utility method to ensure Base64 decoding is done consistently.
341+
* @param str A {@link String} containing the Base64-encoded data
342+
* @return A string of UTF-8 Text decoded from the input
343+
* @throws IllegalArgumentException if the Base64 decoding fails
344+
*/
345+
public static @NotNull String decodeBase64(String str) throws IllegalArgumentException {
346+
return new String(Base64.getDecoder().decode(str), StandardCharsets.UTF_8);
347+
}
348+
310349
/**
311350
* Creates a random string of "magic" characters of characters
312351
*
@@ -366,5 +405,4 @@ public static String randomObfuscatedString(int min, int max, int minRunBeforeSp
366405
public static String formatChatCodes(String input) {
367406
return input.replaceAll("&(?=([a-f]|[0-9]|[klmnor]))", Character.toString(ChatColor.COLOR_CHAR));
368407
}
369-
370408
}

common/src/test/java/com/dumbdogdiner/stickyapi_tests_common/TestsCommon.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
*/
55
package com.dumbdogdiner.stickyapi_tests_common;
66

7+
import com.dumbdogdiner.stickyapi.StickyAPI;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
import java.util.logging.Handler;
12+
import java.util.logging.Logger;
13+
import java.util.logging.SimpleFormatter;
14+
import java.util.logging.StreamHandler;
15+
716
public class TestsCommon {
817
// 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.
918
// https://stackoverflow.com/questions/4512358/emma-coverage-on-enum-types/4548912
@@ -16,4 +25,36 @@ public static void superficialEnumCodeCoverage(Class<? extends Enum<?>> enumClas
1625
throw new RuntimeException(e);
1726
}
1827
}
28+
29+
private static Handler maskedHandler = new StreamHandler(System.out, new SimpleFormatter());
30+
private static List<Handler> handlers = new ArrayList<>();
31+
32+
public static void disableHandlers() {
33+
Logger l = StickyAPI.getLogger();
34+
l.setUseParentHandlers(false);
35+
for (Handler h : l.getHandlers()) {
36+
handlers.add(h);
37+
l.removeHandler(h);
38+
}
39+
}
40+
41+
public static void enableHandlers() {
42+
Logger l = StickyAPI.getLogger();
43+
l.setUseParentHandlers(true);
44+
for(Handler h : handlers){
45+
l.addHandler(h);
46+
}
47+
48+
49+
}
50+
51+
public static void addMaskedHandler(){
52+
Logger l = StickyAPI.getLogger();
53+
l.addHandler(maskedHandler);
54+
}
55+
56+
public static void removeMaskedHandler(){
57+
Logger l = StickyAPI.getLogger();
58+
l.removeHandler(maskedHandler);
59+
}
1960
}

heads/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
group 'com.dumbdogdiner'
6+
version '2.2.0'
7+
8+
repositories {
9+
mavenCentral()
10+
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
11+
}
12+
13+
dependencies {
14+
compile project(":common")
15+
testCompile project(":common").sourceSets.test.output
16+
17+
compile project(":bukkit")
18+
testCompile project(":bukkit").sourceSets.test.output
19+
20+
compile project(":webapi")
21+
testCompile project(":webapi").sourceSets.test.output
22+
23+
compile project(":textures")
24+
testCompile project(":textures").sourceSets.test.output
25+
26+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
27+
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
28+
testImplementation 'com.github.seeseemelk:MockBukkit-v1.16:0.25.0'
29+
testImplementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.2.1'
30+
}
31+
32+
test {
33+
useJUnitPlatform()
34+
}

heads/lombok.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file is generated by the 'io.freefair.lombok' Gradle plugin
2+
config.stopBubbling = true
3+
lombok.addLombokGeneratedAnnotation = true

0 commit comments

Comments
 (0)