Skip to content
This repository was archived by the owner on Feb 18, 2021. It is now read-only.

Commit 769ee5c

Browse files
committed
Make example better
1 parent ecbbcdd commit 769ee5c

File tree

6 files changed

+114
-64
lines changed

6 files changed

+114
-64
lines changed

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2+
Version 2, December 2004
3+
4+
Copyright (C) 2004 Sam Hocevar <[email protected]>
5+
6+
Everyone is permitted to copy and distribute verbatim or modified
7+
copies of this license document, and changing it is allowed as long
8+
as the name is changed.
9+
10+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12+
13+
0. You just DO WHAT THE FUCK YOU WANT TO.

README.md

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,67 @@
11
# Orion example Mod
22

3-
This is example mod overriding EULA check on 1.12 Paper server using Mixin
4-
5-
API is not done yet, hence library jar sits in repository as well
3+
## Description
4+
This is example mod demonstrating configuration API and overriding EULA check on 1.12 Paper server using Mixin
65

76
Put this into mods dir, remove eula.txt and see how it works :smile:
87

9-
(See Releases for precompiled mod)
8+
## Requirements
9+
- Paper 1.12
10+
11+
## Configuration
12+
See `modconfigs/examplemod.cfg`, it has one option named `restore-the-check`. Setting that to `true` makes mod not apply
13+
mixin to the server
14+
15+
## I want to create mod like this!
16+
Sure, here's appropriate Maven/Gradle configuration
17+
18+
### Maven
19+
```xml
20+
<repositories>
21+
<repository>
22+
<id>mikroskeem-repo</id>
23+
<url>https://repo.wut.ee/repository/mikroskeem-repo/</url>
24+
</repository>
25+
</repositories>
26+
27+
<dependencies>
28+
<!-- Note: `./paper j` and `mvn install` in Paper-Server directory -->
29+
<dependency>
30+
<groupId>com.destroystokyo.paper</groupId>
31+
<artifactId>paper</artifactId>
32+
<version>1.12-R0.1-SNAPSHOT</version>
33+
<scope>provided</scope>
34+
</dependency>
35+
36+
<!-- Orion API -->
37+
<dependency>
38+
<groupId>eu.mikroskeem</groupId>
39+
<artifactId>orion.api</artifactId>
40+
<version>0.0.1</version>
41+
<scope>provided</scope>
42+
</dependency>
43+
</dependencies>
44+
```
45+
46+
47+
### Gradle
48+
```groovy
49+
repositories {
50+
maven {
51+
name = 'mikroskeem-repo'
52+
url = 'https://repo.wut.ee/repository/mikroskeem-repo'
53+
}
54+
}
55+
56+
dependencies {
57+
compileOnly group: 'com.destroystokyo.paper', name: 'paper', version: '1.12-R0.1-SNAPSHOT'
58+
compileOnly group: 'eu.mikroskeem', name: 'orion.api', version: '0.0.1'
59+
}
60+
```
61+
62+
63+
## I want this mod!
64+
See [releases](https://github.com/OrionMinecraft/ExampleMod/releases)
1065

11-
WTFPL
66+
## I want to steal your mod's code!
67+
Go ahead, this mod is [WTFPL](http://www.wtfpl.net/about/)

lib/OrionAPI-0.0.1.jar

-3.4 KB
Binary file not shown.

pom.xml

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,13 @@
1919
</configuration>
2020
</plugin>
2121
</plugins>
22+
<defaultGoal>clean compile package</defaultGoal>
2223
</build>
2324

2425
<repositories>
25-
<!-- SpongePowered repo -->
26-
<repository>
27-
<id>sponge-repo</id>
28-
<url>https://repo.spongepowered.org/maven</url>
29-
</repository>
30-
31-
<!-- Minecraft libraries -->
32-
<repository>
33-
<id>minecraft</id>
34-
<url>https://libraries.minecraft.net</url>
35-
</repository>
36-
37-
<!-- Own repository -->
3826
<repository>
3927
<id>mikroskeem-repo</id>
40-
<name>mikroskeem Maven Repository</name>
4128
<url>https://repo.wut.ee/repository/mikroskeem-repo/</url>
42-
<releases>
43-
<enabled>true</enabled>
44-
</releases>
45-
<snapshots>
46-
<enabled>true</enabled>
47-
</snapshots>
4829
</repository>
4930
</repositories>
5031

@@ -58,42 +39,9 @@
5839

5940
<!-- Orion API -->
6041
<dependency>
61-
<groupId>eu.mikroskeem.orion</groupId>
62-
<artifactId>api</artifactId>
42+
<groupId>eu.mikroskeem</groupId>
43+
<artifactId>orion.api</artifactId>
6344
<version>0.0.1</version>
64-
<scope>system</scope>
65-
<systemPath>${project.basedir}/lib/OrionAPI-0.0.1.jar</systemPath>
66-
</dependency>
67-
68-
<!-- Orion API dependencies -->
69-
<dependency>
70-
<groupId>ninja.leaping.configurate</groupId>
71-
<artifactId>configurate-hocon</artifactId>
72-
<version>3.3</version>
73-
<scope>provided</scope>
74-
</dependency>
75-
<dependency>
76-
<groupId>com.google.guava</groupId>
77-
<artifactId>guava</artifactId>
78-
<version>21.0</version>
79-
<scope>provided</scope>
80-
</dependency>
81-
<dependency>
82-
<groupId>javax.inject</groupId>
83-
<artifactId>javax.inject</artifactId>
84-
<version>1</version>
85-
<scope>provided</scope>
86-
</dependency>
87-
<dependency>
88-
<groupId>org.apache.logging.log4j</groupId>
89-
<artifactId>log4j-api</artifactId>
90-
<version>2.8.1</version>
91-
<scope>provided</scope>
92-
</dependency>
93-
<dependency>
94-
<groupId>org.spongepowered</groupId>
95-
<artifactId>mixin</artifactId>
96-
<version>0.6.15-SNAPSHOT</version>
9745
<scope>provided</scope>
9846
</dependency>
9947
</dependencies>
Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,58 @@
11
package eu.mikroskeem.orion.examplemod;
22

33
import com.google.common.eventbus.Subscribe;
4-
import eu.mikroskeem.orion.api.OrionAPI;
4+
import eu.mikroskeem.orion.api.Orion;
55
import eu.mikroskeem.orion.api.annotations.OrionMod;
66
import eu.mikroskeem.orion.api.events.ModConstructEvent;
7+
import eu.mikroskeem.orion.api.events.ModLoadEvent;
8+
import eu.mikroskeem.shuriken.common.streams.ByteArrays;
9+
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
10+
import ninja.leaping.configurate.loader.ConfigurationLoader;
711
import org.apache.logging.log4j.Logger;
812

913
import javax.inject.Inject;
14+
import javax.inject.Named;
15+
import java.nio.file.Files;
16+
import java.nio.file.Path;
17+
import java.nio.file.StandardOpenOption;
1018

1119

1220
/**
13-
* Orion sample mod
21+
* Orion example mod
1422
*
1523
* @author Mark Vainomaa
1624
*/
17-
@OrionMod(id = "samplemod")
25+
@OrionMod(id = "examplemod")
1826
public final class ExampleMod {
1927
@Inject private Logger logger;
28+
@Inject private Orion orion;
29+
@Inject @Named("configurationPath") private Path configurationPath;
30+
@Inject private ConfigurationLoader<CommentedConfigurationNode> configurationLoader;
31+
private boolean restoreCheck = false;
2032

2133
@Subscribe
2234
public void on(ModConstructEvent e) throws Exception {
2335
logger.info("Hello world!");
24-
OrionAPI.getInstance().registerMixinConfig("mixins.examplemod.json");
36+
if(Files.notExists(configurationPath)) {
37+
Files.write(
38+
configurationPath,
39+
ByteArrays.fromInputStream(
40+
ExampleMod.class.getResourceAsStream("/assets/examplemod/examplemod.cfg")),
41+
StandardOpenOption.CREATE_NEW,
42+
StandardOpenOption.WRITE
43+
);
44+
}
45+
CommentedConfigurationNode baseNode = configurationLoader.load();
46+
restoreCheck = baseNode.getNode("restore-the-check").getBoolean(false);
47+
configurationLoader.save(baseNode);
48+
}
49+
50+
@Subscribe
51+
public void on(ModLoadEvent e) throws Exception {
52+
if(restoreCheck) {
53+
logger.info("Not applying EULA remover mixin, as user requested not to do so.");
54+
return;
55+
}
56+
orion.registerMixinConfig("mixins.examplemod.json");
2557
}
2658
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
restore-the-check = false

0 commit comments

Comments
 (0)