Skip to content

Commit 1e19114

Browse files
committed
init
0 parents  commit 1e19114

File tree

61 files changed

+8092
-0
lines changed

Some content is hidden

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

61 files changed

+8092
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: publish-on-master-push
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
paths-ignore:
7+
- '**/README.md'
8+
9+
jobs:
10+
build-and-publish:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up JDK 16
15+
uses: actions/setup-java@v2
16+
with:
17+
distribution: 'adopt'
18+
java-version: '16'
19+
- name: Build with Gradle
20+
run: ./gradlew build
21+
- name: Archive test reports
22+
if: ${{ failure() }}
23+
uses: actions/upload-artifact@v2
24+
with:
25+
name: test-reports
26+
path: |
27+
build/reports/**/*
28+
- name: Publish to GitHub Packages
29+
run: ./gradlew publish
30+
env:
31+
GITHUB_ACTOR: ${{ github.actor }}
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: test-on-pr-or-dev-push
2+
3+
on:
4+
pull_request:
5+
paths-ignore:
6+
- '**/README.md'
7+
push:
8+
branches: [ dev ]
9+
paths-ignore:
10+
- '**/README.md'
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Set up JDK 16
17+
uses: actions/setup-java@v2
18+
with:
19+
distribution: 'adopt'
20+
java-version: '16'
21+
- name: Test with Gradle
22+
run: ./gradlew test
23+
- name: Archive test reports
24+
if: ${{ failure() }}
25+
uses: actions/upload-artifact@v2
26+
with:
27+
name: test-reports
28+
path: |
29+
build/reports/**/*

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
**/.idea
2+
**/out
3+
**/build
4+
5+
**/.gradle

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
language: java
2+
jdk:
3+
- oraclejdk8
4+
- oraclejdk9
5+
- oraclejdk10
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package de.exlll.configlib;
2+
3+
import org.bukkit.plugin.java.JavaPlugin;
4+
5+
public class ConfigLib extends JavaPlugin {}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package de.exlll.configlib.configs.yaml;
2+
3+
import org.bukkit.configuration.file.YamlConstructor;
4+
import org.bukkit.configuration.file.YamlRepresenter;
5+
6+
import java.nio.file.Path;
7+
8+
/**
9+
* A {@code BukkitYamlConfiguration} is a specialized form of a
10+
* {@code YamlConfiguration} that uses better default values.
11+
*/
12+
public abstract class BukkitYamlConfiguration extends YamlConfiguration {
13+
protected BukkitYamlConfiguration(Path path, BukkitYamlProperties properties) {
14+
super(path, properties);
15+
}
16+
17+
protected BukkitYamlConfiguration(Path path) {
18+
this(path, BukkitYamlProperties.DEFAULT);
19+
}
20+
21+
public static class BukkitYamlProperties extends YamlProperties {
22+
public static final BukkitYamlProperties DEFAULT = builder().build();
23+
24+
private BukkitYamlProperties(Builder<?> builder) {
25+
super(builder);
26+
}
27+
28+
public static Builder<?> builder() {
29+
return new Builder() {
30+
@Override
31+
protected Builder<?> getThis() {
32+
return this;
33+
}
34+
};
35+
}
36+
37+
public static abstract class
38+
Builder<B extends BukkitYamlProperties.Builder<B>>
39+
extends YamlProperties.Builder<B> {
40+
41+
protected Builder() {
42+
setConstructor(new YamlConstructor());
43+
setRepresenter(new YamlRepresenter());
44+
}
45+
46+
/**
47+
* Builds a new {@code BukkitYamlProperties} instance using the values set.
48+
*
49+
* @return new {@code BukkitYamlProperties} instance
50+
*/
51+
public BukkitYamlProperties build() {
52+
return new BukkitYamlProperties(this);
53+
}
54+
}
55+
}
56+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: ConfigLib
2+
author: Exlll
3+
4+
version: 2.2.0
5+
main: de.exlll.configlib.ConfigLib
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package de.exlll.configlib;
2+
3+
import net.md_5.bungee.api.plugin.Plugin;
4+
5+
public class ConfigLib extends Plugin {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: ConfigLib
2+
author: Exlll
3+
4+
version: 2.2.0
5+
main: de.exlll.configlib.ConfigLib
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package de.exlll.configlib;
2+
3+
import de.exlll.configlib.annotation.Comment;
4+
5+
import java.lang.reflect.AnnotatedElement;
6+
import java.lang.reflect.Field;
7+
import java.util.Arrays;
8+
import java.util.Collections;
9+
import java.util.List;
10+
import java.util.Map;
11+
12+
import static java.util.stream.Collectors.toMap;
13+
14+
/**
15+
* Instances of this class contain all comments of a {@link Configuration} class
16+
* and its fields.
17+
*/
18+
public final class Comments {
19+
private final List<String> classComments;
20+
private final Map<String, List<String>> fieldComments;
21+
22+
private Comments(List<String> classComments,
23+
Map<String, List<String>> fieldComments) {
24+
this.classComments = classComments;
25+
this.fieldComments = fieldComments;
26+
}
27+
28+
static Comments ofClass(Class<?> cls) {
29+
List<String> classComments = getComments(cls);
30+
Map<String, List<String>> fieldComments = Arrays
31+
.stream(cls.getDeclaredFields())
32+
.filter(Comments::isCommented)
33+
.collect(toMap(Field::getName, Comments::getComments));
34+
return new Comments(classComments, fieldComments);
35+
}
36+
37+
private static boolean isCommented(AnnotatedElement element) {
38+
return element.isAnnotationPresent(Comment.class);
39+
}
40+
41+
private static List<String> getComments(AnnotatedElement element) {
42+
Comment comment = element.getAnnotation(Comment.class);
43+
return (comment != null)
44+
? Arrays.asList(comment.value())
45+
: Collections.emptyList();
46+
}
47+
48+
/**
49+
* Returns if the {@code Configuration} this {@code Comments} object belongs to
50+
* has class comments.
51+
*
52+
* @return true, if {@code Configuration} has class comments.
53+
*/
54+
public boolean hasClassComments() {
55+
return !classComments.isEmpty();
56+
}
57+
58+
/**
59+
* Returns if the {@code Configuration} this {@code Comments} object belongs to
60+
* has field comments.
61+
*
62+
* @return true, if {@code Configuration} has field comments.
63+
*/
64+
public boolean hasFieldComments() {
65+
return !fieldComments.isEmpty();
66+
}
67+
68+
/**
69+
* Returns a list of class comments.
70+
*
71+
* @return list of class comments
72+
*/
73+
public List<String> getClassComments() {
74+
return classComments;
75+
}
76+
77+
/**
78+
* Returns lists of field comments mapped by field name.
79+
*
80+
* @return lists of field comments by field name
81+
*/
82+
public Map<String, List<String>> getFieldComments() {
83+
return fieldComments;
84+
}
85+
}

0 commit comments

Comments
 (0)