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

Commit 42008ff

Browse files
author
Giacomello Nathan
committed
Merge branch 'release/0.0.1'
2 parents c5df4c3 + cf4ef3a commit 42008ff

7 files changed

Lines changed: 184 additions & 7 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# FroxyGame
1+
# FroxyCore
22
Partie coeur qui sera sur les serveurs Spigot pour le projet Froxy-Network
33

4-
Ce dépôt contient les sources et la documentation pour la partie FroxyGame.
4+
Ce dépôt contient les sources et la documentation pour la partie FroxyCore.
55

66
## Librairies
77
- [slf4j](https://www.slf4j.org/)
88
- [lombok](https://github.com/rzwitserloot/lombok)
99
- [FroxyNetwork](https://github.com/froxynetwork/froxynetwork)
1010
- [FroxyGame](https://github.com/froxynetwork/froxygame)
11+
- [FroxyAPI](https://github.com/froxynetwork/froxyapi)
1112

1213
## License
1314
This software is available under the following licenses:

pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828

2929
<!-- Configuration of repositories -->
3030
<repositories>
31+
<repository>
32+
<id>spigot-repo</id>
33+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
34+
</repository>
35+
3136
<repository>
3237
<id>jitpack.io</id>
3338
<url>https://jitpack.io</url>
@@ -70,5 +75,20 @@
7075
<artifactId>froxygame</artifactId>
7176
<version>0.0.1</version>
7277
</dependency>
78+
79+
<!-- API -->
80+
<dependency>
81+
<groupId>com.github.froxynetwork</groupId>
82+
<artifactId>froxyapi</artifactId>
83+
<version>0.0.1</version>
84+
</dependency>
85+
86+
<!--Spigot API -->
87+
<dependency>
88+
<groupId>org.spigotmc</groupId>
89+
<artifactId>spigot-api</artifactId>
90+
<version>1.12.2-R0.1-SNAPSHOT</version>
91+
<scope>provided</scope>
92+
</dependency>
7393
</dependencies>
7494
</project>

src/main/java/com/froxynetwork/froxycore/FroxyCore.java

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

3-
import com.froxynetwork.froxynetwork.network.NetworkManager;
3+
import java.io.File;
4+
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
import com.froxynetwork.froxyapi.Froxy;
9+
import com.froxynetwork.froxycore.api.APIImpl;
10+
import com.froxynetwork.froxycore.api.language.LanguageManagerImpl;
411

512
/**
613
* MIT License
@@ -28,10 +35,29 @@
2835
* @author 0ddlyoko
2936
*/
3037
public class FroxyCore {
31-
public static void main(String[] args) {
32-
String clientId = "WEBSOCKET_045cfff18fe0ab8393178e7b7826f227";
33-
String clientSecret = "SECRET_ecfdc21a8d5022e2db64b1315b087aaf";
34-
NetworkManager nm = new NetworkManager("http://localhost/", clientId, clientSecret);
38+
39+
private Logger log = LoggerFactory.getLogger(getClass());
40+
41+
/**
42+
* TEST
43+
*/
44+
public FroxyCore() {
45+
// String clientId = "WEBSOCKET_045cfff18fe0ab8393178e7b7826f227";
46+
// String clientSecret = "SECRET_ecfdc21a8d5022e2db64b1315b087aaf";
47+
// NetworkManager nm = new NetworkManager("http://localhost/", clientId, clientSecret);
48+
49+
APIImpl impl = new APIImpl(null, null, "0.0.3", log, new LanguageManagerImpl());
50+
Froxy.setAPI(impl);
51+
File lang = new File(getClass().getClassLoader().getResource("lang").getFile());
52+
Froxy.register(lang);
53+
// Show "0.0.3"
54+
System.out.println(Froxy.getVersion());
55+
// Show "english"
56+
System.out.println(Froxy.$("test.test"));
3557
// TODO
3658
}
59+
60+
public static void main(String[] args) {
61+
new FroxyCore();
62+
}
3763
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright (c) Smals
3+
*/
4+
package com.froxynetwork.froxycore.api;
5+
6+
import org.bukkit.plugin.java.JavaPlugin;
7+
import org.slf4j.Logger;
8+
9+
import com.froxynetwork.froxyapi.API;
10+
import com.froxynetwork.froxyapi.language.LanguageManager;
11+
12+
/**
13+
* @author Nathan Giacomello (nagi)
14+
*
15+
*/
16+
public class APIImpl implements API {
17+
18+
private JavaPlugin corePlugin;
19+
20+
private JavaPlugin gamePlugin;
21+
22+
private String version;
23+
24+
private Logger logger;
25+
26+
private LanguageManager languageManager;
27+
28+
public APIImpl(JavaPlugin corePlugin, JavaPlugin gamePlugin, String version, Logger logger, LanguageManager languageManager) {
29+
this.corePlugin = corePlugin;
30+
this.gamePlugin = gamePlugin;
31+
this.version = version;
32+
this.logger = logger;
33+
this.languageManager = languageManager;
34+
}
35+
36+
@Override
37+
public JavaPlugin getCorePlugin() {
38+
return corePlugin;
39+
}
40+
41+
@Override
42+
public JavaPlugin getGamePlugin() {
43+
return gamePlugin;
44+
}
45+
46+
@Override
47+
public String getVersion() {
48+
return version;
49+
}
50+
51+
@Override
52+
public Logger getLogger() {
53+
return logger;
54+
}
55+
56+
@Override
57+
public LanguageManager getLanguageManager() {
58+
return languageManager;
59+
}
60+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.froxynetwork.froxycore.api.language;
2+
3+
import java.io.File;
4+
5+
import com.froxynetwork.froxyapi.language.LanguageManager;
6+
import com.froxynetwork.froxyapi.language.Languages;
7+
8+
/**
9+
* MIT License
10+
*
11+
* Copyright (c) 2019 FroxyNetwork
12+
*
13+
* Permission is hereby granted, free of charge, to any person obtaining a copy
14+
* of this software and associated documentation files (the "Software"), to deal
15+
* in the Software without restriction, including without limitation the rights
16+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
* copies of the Software, and to permit persons to whom the Software is
18+
* furnished to do so, subject to the following conditions:
19+
*
20+
* The above copyright notice and this permission notice shall be included in
21+
* all copies or substantial portions of the Software.
22+
*
23+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+
* SOFTWARE.
30+
*
31+
* @author 0ddlyoko
32+
*/
33+
/**
34+
*/
35+
public class LanguageManagerImpl implements LanguageManager {
36+
37+
@Override
38+
public Languages getDefaultLanguage() {
39+
return langGameToApi(com.froxynetwork.froxygame.languages.LanguageManager.DEFAULT);
40+
}
41+
42+
@Override
43+
public void register(File path) {
44+
com.froxynetwork.froxygame.languages.LanguageManager.register(path);
45+
}
46+
47+
@Override
48+
public String $(String id, Languages lang, String... params) {
49+
return com.froxynetwork.froxygame.languages.LanguageManager.$(id, langApiToGame(lang), params);
50+
}
51+
52+
@Override
53+
public String $_(String id, Languages lang, String... params) {
54+
return com.froxynetwork.froxygame.languages.LanguageManager.$_(id, langApiToGame(lang), params);
55+
}
56+
57+
private com.froxynetwork.froxygame.languages.Languages langApiToGame(Languages lang) {
58+
return com.froxynetwork.froxygame.languages.Languages.fromLang(lang.getLang());
59+
}
60+
61+
private Languages langGameToApi(com.froxynetwork.froxygame.languages.Languages lang) {
62+
return Languages.fromLang(lang.getLang());
63+
}
64+
}

src/main/resources/lang/en_US.lang

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test.test : english
2+
test.test3 : englishy
3+
test.test4 : Test {}, Hi {}

src/main/resources/lang/fr_FR.lang

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test.test : french
2+
test.test2 : frenchy
3+
test.test4 : Test {}, Salut {}

0 commit comments

Comments
 (0)