Skip to content

Commit 7119cc0

Browse files
Merge pull request #22 from ChillyCheesy/feat/controller
Feat/controller
2 parents dd562ca + 6d409e6 commit 7119cc0

File tree

103 files changed

+3876
-272
lines changed

Some content is hidden

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

103 files changed

+3876
-272
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: Bug
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Clue for a fix**
27+
28+
See :
29+
* [This file](https://www.youtube.com/watch?v=dQw4w9WgXcQ)

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ out/
3535

3636
### VS Code ###
3737
.vscode/
38+
39+
### Mac ###
40+
.DS_Store

LICENSE.md

Lines changed: 373 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ What is modulo...
4343
<dependency>
4444
<groupId>com.chillycheesy</groupId>
4545
<artifactId>modulo-api</artifactId>
46-
<version>0.1.2</version>
46+
<version>BINKS-0.3.0</version>
4747
</dependency>
4848
```
4949
* With Gradle add the following dependency to your build.gradle: *(recommended)*
5050
```gradle
5151
dependencies {
52-
implementation 'com.chillycheesy:modulo-api:0.1.2'
52+
implementation 'com.chillycheesy:modulo-api:BINKS-0.3.0'
5353
}
5454
```
5555
### Step 2:<a id="GettingStarted-2"></a>

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
modulo_modulename=ModuloServer
2-
modulo_version=BINKS-0.3.0
2+
modulo_version=BINKS-0.3.1

modulo-api/build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ sourceCompatibility = 16
99
targetCompatibility = JavaVersion.VERSION_16
1010

1111
dependencies {
12-
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.13.3'
13-
implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.39'
12+
api 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.13.3'
13+
api 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.39'
14+
api 'org.apache.tika:tika-core:1.26'
1415

1516
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
1617
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
@@ -70,3 +71,5 @@ publishing {
7071
}
7172
}
7273
}
74+
75+
compileTestJava.options.compilerArgs << '-parameters'

modulo-api/src/main/java/com/chillycheesy/modulo/ModuloAPI.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.chillycheesy.modulo;
22

3+
import com.chillycheesy.modulo.controllers.ControllerContainer;
34
import com.chillycheesy.modulo.events.EventContainer;
45
import com.chillycheesy.modulo.modules.ModuleContainer;
56
import com.chillycheesy.modulo.pages.PageContainer;
@@ -30,6 +31,10 @@ public class ModuloAPI {
3031
* Page manager.
3132
*/
3233
private static PageContainer page;
34+
/**
35+
* Controller container.
36+
*/
37+
private static ControllerContainer controller;
3338
/**
3439
* Logger section.
3540
*/
@@ -80,4 +85,12 @@ public static Logger getLogger() {
8085
return logger = logger == null ? new Logger(getEvent()) : logger;
8186
}
8287

88+
/**
89+
* Getter for Controller logic section.
90+
*
91+
* @return The Controller section.
92+
*/
93+
public static ControllerContainer getController() {
94+
return controller = controller == null ? new ControllerContainer() : controller;
95+
}
8396
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.chillycheesy.modulo.config;
2+
3+
import com.chillycheesy.modulo.modules.Module;
4+
import com.chillycheesy.modulo.modules.ModuleEntityAdapter;
5+
6+
import java.util.Objects;
7+
8+
public class ConfigurableEntity extends ModuleEntityAdapter {
9+
10+
private static final String DEFAULT_CONFIG_PATH = "config.yml";
11+
12+
protected ConfigurationFactory configurationFactory;
13+
protected ConfigurationLoaderStrategy loaderStrategy;
14+
protected Configuration defaultConfiguration;
15+
16+
protected boolean autoSave = true;
17+
18+
public ConfigurableEntity(ConfigurationLoaderStrategy loaderStrategy) {
19+
this.loaderStrategy = loaderStrategy;
20+
}
21+
22+
public ConfigurableEntity() {
23+
this(new YamlConfigurationStrategy());
24+
}
25+
26+
@Override
27+
public void load(Module module) {
28+
configurationFactory = Objects.isNull(configurationFactory) ? new FileConfigurationFactory(module, DEFAULT_CONFIG_PATH) : configurationFactory;
29+
defaultConfiguration = Objects.isNull(defaultConfiguration) ? configurationFactory.createConfiguration(loaderStrategy) : defaultConfiguration;
30+
}
31+
32+
@Override
33+
public void stop() {
34+
if (autoSave) configurationFactory.saveConfiguration(defaultConfiguration, loaderStrategy);
35+
}
36+
37+
public void enableAutoSave(boolean autoSave) {
38+
this.autoSave = autoSave;
39+
}
40+
41+
public Configuration getConfiguration() {
42+
return defaultConfiguration;
43+
}
44+
45+
public void setConfigurationFactory(ConfigurationFactory configurationFactory) {
46+
this.configurationFactory = configurationFactory;
47+
}
48+
49+
public void setConfiguration(Configuration configuration) {
50+
this.defaultConfiguration = configuration;
51+
}
52+
53+
public ConfigurationFactory getConfigurationFactory() {
54+
return configurationFactory;
55+
}
56+
57+
public ConfigurationLoaderStrategy getLoaderStrategy() {
58+
return loaderStrategy;
59+
}
60+
}

modulo-api/src/main/java/com/chillycheesy/modulo/config/Configuration.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ public Configuration(Map<String, Object> properties, Map<String, Object> default
1414
this.defaultProperties = defaultProperties;
1515
}
1616

17+
public Configuration(Configuration ...configurations) {
18+
this();
19+
for (Configuration configuration : configurations) {
20+
merge(configuration);
21+
}
22+
}
23+
1724
public Configuration() { this(new HashMap<>(), new HashMap<>()); }
1825

1926
public Object get(String key) {
@@ -256,9 +263,14 @@ public boolean isModified() {
256263
}
257264

258265
public void forEach(BiConsumer<String, String> setProperty) {
266+
forEach("", setProperty);
267+
}
268+
269+
public void forEach(String key, BiConsumer<String, String> setProperty) {
259270
getMergedProperties().entrySet().stream()
260-
.collect(Collectors.toMap(Map.Entry::getKey, e -> String.valueOf(e.getValue())))
261-
.forEach(setProperty);
271+
.filter(entry -> entry.getKey().startsWith(key))
272+
.collect(Collectors.toMap(keyEntry -> keyEntry.getKey().replaceFirst("properties\\.", ""), e -> String.valueOf(e.getValue())))
273+
.forEach(setProperty);
262274
}
263275

264276
@Override

modulo-api/src/main/java/com/chillycheesy/modulo/config/ConfigurationLoader.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)