diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..509d1ab
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,73 @@
+### Intellij ###
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
+
+.idea/
+
+# CMake
+cmake-build-*/
+
+# File-based project format
+*.iws
+
+# IntelliJ
+out/
+
+# mpeltonen/sbt-idea plugin
+.idea_modules/
+
+# JIRA plugin
+atlassian-ide-plugin.xml
+
+# Crashlytics plugin (for Android Studio and IntelliJ)
+com_crashlytics_export_strings.xml
+crashlytics.properties
+crashlytics-build.properties
+fabric.properties
+
+### Java ###
+# Compiled class file
+*.class
+
+# Log file
+*.log
+
+# BlueJ files
+*.ctxt
+
+# Mobile Tools for Java (J2ME)
+.mtj.tmp/
+
+# Package Files #
+*.jar
+*.war
+*.nar
+*.ear
+*.zip
+*.tar.gz
+*.rar
+
+# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
+hs_err_pid*
+
+### Gradle ###
+.gradle
+gradle/
+build/
+
+# Ignore Gradle GUI config
+gradle-app.setting
+
+# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
+!gradle-wrapper.jar
+
+# Cache of project
+.gradletasknamecache
+
+# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
+# gradle/wrapper/gradle-wrapper.properties
+
+### Gradle Patch ###
+**/build/
+
+# End of https://www.toptal.com/developers/gitignore/api/java,gradle,intellij
diff --git a/README.md b/README.md
index 06c74b5..184c0f3 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..2c70aef
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,6 @@
+group 'net.berrygames'
+version '0.0.1'
+
+dependencies {
+ compile project(':CloudBerry')
+}
\ No newline at end of file
diff --git a/src/main/java/net/berrygames/bungee/GooseBerry.java b/src/main/java/net/berrygames/bungee/GooseBerry.java
new file mode 100644
index 0000000..6cfccd6
--- /dev/null
+++ b/src/main/java/net/berrygames/bungee/GooseBerry.java
@@ -0,0 +1,48 @@
+package net.berrygames.bungee;
+
+import net.berrygames.bungee.listener.PlayerConnect;
+import net.berrygames.bungee.listener.ProxyPing;
+import net.berrygames.cloudberry.proxy.BerryProxy;
+import net.berrygames.translation.ITranslatable;
+import net.berrygames.translation.Translatable;
+import net.md_5.bungee.api.ProxyServer;
+
+public class GooseBerry extends BerryProxy {
+
+ // - General Managers
+ private RedisService redisService;
+ private ITranslatable translatable;
+
+ @Override
+ public void onLoad() {
+ super.onLoad();
+ }
+
+ @Override
+ public void onEnable() {
+ super.onEnable();
+
+ // - Initialize General managers
+ this.redisService = new RedisServiceImpl("127.0.0.1", 6379, "Sunntitane2", 0);
+ this.translatable = new Translatable();
+
+ // - Register listeners
+ ProxyServer.getInstance().getPluginManager().registerListener(this, new PlayerConnect());
+ ProxyServer.getInstance().getPluginManager().registerListener(this, new ProxyPing());
+ }
+
+ @Override
+ public void onDisable() {
+ super.onDisable();
+ }
+
+ @Override
+ public RedisService getRedis() {
+ return redisService;
+ }
+
+ @Override
+ public ITranslatable getTranslatable() {
+ return translatable;
+ }
+}
diff --git a/src/main/java/net/berrygames/bungee/listener/PlayerConnect.java b/src/main/java/net/berrygames/bungee/listener/PlayerConnect.java
new file mode 100644
index 0000000..3530259
--- /dev/null
+++ b/src/main/java/net/berrygames/bungee/listener/PlayerConnect.java
@@ -0,0 +1,30 @@
+package net.berrygames.bungee.listener;
+
+import net.md_5.bungee.api.chat.TextComponent;
+import net.md_5.bungee.api.event.ServerConnectEvent;
+import net.md_5.bungee.api.plugin.Listener;
+import net.md_5.bungee.event.EventHandler;
+
+public class PlayerConnect implements Listener {
+
+ @EventHandler
+ public void onConnect(ServerConnectEvent event) {
+ final var player = event.getPlayer();
+ if(player.getServer() != null) return;
+
+ // - Detect player client version and disconnect him if it's lower than 47 (v1.9).
+ if(player.getPendingConnection().getVersion() <= 47) {
+ event.setCancelled(true);
+ player.disconnect(new TextComponent("player.disconnect.badVersion"));
+ return;
+ }
+
+ // - Send player to Hub.
+ //event.setTarget(null);
+ //redis.sendPlayer(player.getName(), ServerType.HUB);
+
+ // - Set tab header for player.
+ player.setTabHeader(new TextComponent(""), new TextComponent(("")));
+ // TODO: Until 30 seconds, disconnect player with no server message.
+ }
+}
diff --git a/src/main/java/net/berrygames/bungee/listener/ProxyPing.java b/src/main/java/net/berrygames/bungee/listener/ProxyPing.java
new file mode 100644
index 0000000..cc61445
--- /dev/null
+++ b/src/main/java/net/berrygames/bungee/listener/ProxyPing.java
@@ -0,0 +1,44 @@
+package net.berrygames.bungee.listener;
+
+import net.berrygames.bungee.utilities.CenteredMessage;
+import net.md_5.bungee.api.ProxyServer;
+import net.md_5.bungee.api.ServerPing;
+import net.md_5.bungee.api.event.ProxyPingEvent;
+import net.md_5.bungee.api.plugin.Listener;
+import net.md_5.bungee.event.EventHandler;
+
+public class ProxyPing implements Listener {
+
+ @EventHandler
+ public void onPing(ProxyPingEvent event){
+ ServerPing serverPing;
+ int maxSlot = 500;
+ int online = getOnlinePlayers();
+ // String line1 = "&2&l▪&a&l▪&e&l▪ &a&lBerryGames &7Game Server &2[1.9 »&2 1.13] &e&l▪&a&l▪&2&l▪";
+ //String line1 = "&5&lBerry&d&lGames &f❙ &b&lMINI GAMES &f❙ &91.9 ➟ 1.12.2";
+ //String line2 = "&a☆ &6The server is currently under development &a☆ ";
+ //String line2 = "&b☆ &aThe server is currently in development &b☆ ";
+ String line1 = "§6§lBerryGames &f❙ §a1.9 §8➟ §a1.12.2";
+ String line2 = "§b§lTwitter §f» §9@BerryGamesMC";
+
+ if (event.getConnection().getVersion() <= 47) {
+ serverPing = new ServerPing(
+ new ServerPing.Protocol("§4Use 1.9 ➟ 1.12.2 §f- §7" + online + "§8/§7" + maxSlot, 48),
+ new ServerPing.Players(maxSlot, online, null),
+ CenteredMessage.getCenteredMotd(line1) + "\n" + CenteredMessage.getCenteredMotd("§cUse 1.9 ➟ 1.12.2"),
+ ProxyServer.getInstance().getConfig().getFaviconObject());
+ } else {
+ serverPing = new ServerPing(
+ new ServerPing.Protocol("§7" + online + "§8/§7" + maxSlot, event.getConnection().getVersion()),
+ new ServerPing.Players(maxSlot, online, null),
+ CenteredMessage.getCenteredMotd(line1) + "\n" + CenteredMessage.getCenteredMotd(line2),
+ ProxyServer.getInstance().getConfig().getFaviconObject()
+ );
+ }
+ event.setResponse(serverPing);
+ }
+
+ private int getOnlinePlayers(){
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/berrygames/bungee/task/PingTask.java b/src/main/java/net/berrygames/bungee/task/PingTask.java
new file mode 100644
index 0000000..8141c94
--- /dev/null
+++ b/src/main/java/net/berrygames/bungee/task/PingTask.java
@@ -0,0 +1,21 @@
+package net.berrygames.bungee.task;
+
+import net.md_5.bungee.api.Callback;
+import net.md_5.bungee.api.ProxyServer;
+import net.md_5.bungee.api.ServerPing;
+
+/**
+ * This file is a part of BerryGames, located on net.berrygames.bungee.task
+ *
+ * @author SweetKebab_
+ * Created the 10/12/19 at 9:02 PM.
+ */
+public class PingTask implements Runnable {
+ @Override
+ public void run() {
+ ProxyServer.getInstance().getServers().forEach((ip, sese) -> sese.ping((result, error) -> {
+ if(result.getDescriptionComponent() == null)
+ ProxyServer.getInstance().getServers().remove(sese.getName());
+ }));
+ }
+}
diff --git a/src/main/java/net/berrygames/bungee/utilities/CenteredMessage.java b/src/main/java/net/berrygames/bungee/utilities/CenteredMessage.java
new file mode 100644
index 0000000..660dd28
--- /dev/null
+++ b/src/main/java/net/berrygames/bungee/utilities/CenteredMessage.java
@@ -0,0 +1,87 @@
+package net.berrygames.bungee.utilities;
+
+import net.md_5.bungee.api.ChatColor;
+
+public class CenteredMessage {
+ private final static int CENTER_PX_MSG = 154;
+ private final static int CENTER_PX_MOTD = 128;
+
+ public static String getCenteredMessage(String message){
+ if(message == null || message.equals("")) return "";
+
+ message = ChatColor.translateAlternateColorCodes('&', message);
+
+ int messagePxSize = 0;
+ boolean previousCode = false;
+ boolean isBold = false;
+
+ for(char c : message.toCharArray()){
+ if(c == '§'){
+ previousCode = true;
+ continue;
+ }else if(previousCode == true){
+ previousCode = false;
+ if(c == 'l' || c == 'L'){
+ isBold = true;
+ continue;
+ }else isBold = false;
+ }else{
+ DefaultFontInfo dFI = DefaultFontInfo.getDefaultFontInfo(c);
+ messagePxSize += isBold ? dFI.getBoldLength() : dFI.getLength();
+ messagePxSize++;
+ }
+ }
+
+ int halvedMessageSize = messagePxSize / 2;
+ int toCompensate = CENTER_PX_MSG - halvedMessageSize;
+ int spaceLength = DefaultFontInfo.SPACE.getLength() + 1;
+ int compensated = 0;
+ StringBuilder sb = new StringBuilder();
+ while(compensated < toCompensate){
+ sb.append(" ");
+ compensated += spaceLength;
+ }
+
+ return sb.toString() + message;
+ }
+
+ public static String getCenteredMotd(String message){
+ if(message == null || message.equals("")) return "";
+
+ message = ChatColor.translateAlternateColorCodes('&', message);
+
+ int messagePxSize = 0;
+ boolean previousCode = false;
+ boolean isBold = false;
+
+ for(char c : message.toCharArray()){
+ if(c == '§'){
+ previousCode = true;
+ continue;
+ }else if(previousCode == true){
+ previousCode = false;
+ if(c == 'l' || c == 'L'){
+ isBold = true;
+ continue;
+ }else isBold = false;
+ }else{
+ DefaultFontInfo dFI = DefaultFontInfo.getDefaultFontInfo(c);
+ messagePxSize += isBold ? dFI.getBoldLength() : dFI.getLength();
+ messagePxSize++;
+ }
+ }
+
+ int halvedMessageSize = messagePxSize / 2;
+ int toCompensate = CENTER_PX_MOTD - halvedMessageSize;
+ int spaceLength = DefaultFontInfo.SPACE.getLength() + 1;
+ int compensated = 0;
+ StringBuilder sb = new StringBuilder();
+ while(compensated < toCompensate){
+ sb.append(" ");
+ compensated += spaceLength;
+ }
+
+ return sb.toString() + message;
+ }
+
+}
diff --git a/src/main/java/net/berrygames/bungee/utilities/DefaultFontInfo.java b/src/main/java/net/berrygames/bungee/utilities/DefaultFontInfo.java
new file mode 100644
index 0000000..f5a8c8b
--- /dev/null
+++ b/src/main/java/net/berrygames/bungee/utilities/DefaultFontInfo.java
@@ -0,0 +1,129 @@
+package net.berrygames.bungee.utilities;
+
+public enum DefaultFontInfo {
+
+ A('A', 5),
+ a('a', 5),
+ B('B', 5),
+ b('b', 5),
+ C('C', 5),
+ c('c', 5),
+ D('D', 5),
+ d('d', 5),
+ E('E', 5),
+ e('e', 5),
+ F('F', 5),
+ f('f', 4),
+ G('G', 5),
+ g('g', 5),
+ H('H', 5),
+ h('h', 5),
+ I('I', 3),
+ i('i', 1),
+ J('J', 5),
+ j('j', 5),
+ K('K', 5),
+ k('k', 4),
+ L('L', 5),
+ l('l', 1),
+ M('M', 5),
+ m('m', 5),
+ N('N', 5),
+ n('n', 5),
+ O('O', 5),
+ o('o', 5),
+ P('P', 5),
+ p('p', 5),
+ Q('Q', 5),
+ q('q', 5),
+ R('R', 5),
+ r('r', 5),
+ S('S', 5),
+ s('s', 5),
+ T('T', 5),
+ t('t', 4),
+ U('U', 5),
+ u('u', 5),
+ V('V', 5),
+ v('v', 5),
+ W('W', 5),
+ w('w', 5),
+ X('X', 5),
+ x('x', 5),
+ Y('Y', 5),
+ y('y', 5),
+ Z('Z', 5),
+ z('z', 5),
+ NUM_1('1', 5),
+ NUM_2('2', 5),
+ NUM_3('3', 5),
+ NUM_4('4', 5),
+ NUM_5('5', 5),
+ NUM_6('6', 5),
+ NUM_7('7', 5),
+ NUM_8('8', 5),
+ NUM_9('9', 5),
+ NUM_0('0', 5),
+ EXCLAMATION_POINT('!', 1),
+ AT_SYMBOL('@', 6),
+ NUM_SIGN('#', 5),
+ DOLLAR_SIGN('$', 5),
+ PERCENT('%', 5),
+ UP_ARROW('^', 5),
+ AMPERSAND('&', 5),
+ ASTERISK('*', 5),
+ LEFT_PARENTHESIS('(', 4),
+ RIGHT_PERENTHESIS(')', 4),
+ MINUS('-', 5),
+ UNDERSCORE('_', 5),
+ PLUS_SIGN('+', 5),
+ EQUALS_SIGN('=', 5),
+ LEFT_CURL_BRACE('{', 4),
+ RIGHT_CURL_BRACE('}', 4),
+ LEFT_BRACKET('[', 3),
+ RIGHT_BRACKET(']', 3),
+ COLON(':', 1),
+ SEMI_COLON(';', 1),
+ DOUBLE_QUOTE('"', 3),
+ SINGLE_QUOTE('\'', 1),
+ LEFT_ARROW('<', 4),
+ RIGHT_ARROW('>', 4),
+ QUESTION_MARK('?', 5),
+ SLASH('/', 5),
+ BACK_SLASH('\\', 5),
+ LINE('|', 1),
+ TILDE('~', 5),
+ TICK('`', 2),
+ PERIOD('.', 1),
+ COMMA(',', 1),
+ SPACE(' ', 3),
+ DEFAULT('a', 4);
+
+ private char character;
+ private int length;
+
+ DefaultFontInfo(char character, int length) {
+ this.character = character;
+ this.length = length;
+ }
+
+ public char getCharacter(){
+ return this.character;
+ }
+
+ public int getLength(){
+ return this.length;
+ }
+
+ public int getBoldLength(){
+ if(this == DefaultFontInfo.SPACE) return this.getLength();
+ return this.length + 1;
+ }
+
+ public static DefaultFontInfo getDefaultFontInfo(char c){
+ for(DefaultFontInfo dFI : DefaultFontInfo.values()){
+ if(dFI.getCharacter() == c) return dFI;
+ }
+ return DefaultFontInfo.DEFAULT;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/berrygames/bungee/utilities/IPUtils.java b/src/main/java/net/berrygames/bungee/utilities/IPUtils.java
new file mode 100644
index 0000000..397305e
--- /dev/null
+++ b/src/main/java/net/berrygames/bungee/utilities/IPUtils.java
@@ -0,0 +1,37 @@
+package net.berrygames.bungee.utilities;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.URL;
+
+public class IPUtils {
+
+ public static String getIP(){
+ String systemipaddress = "";
+ try
+ {
+ URL url_name = new URL("http://bot.whatismyipaddress.com");
+ BufferedReader sc = new BufferedReader(new InputStreamReader(url_name.openStream()));
+ systemipaddress = sc.readLine().trim();
+ if (!(systemipaddress.length() > 0))
+ {
+ try
+ {
+ InetAddress localhost = InetAddress.getLocalHost();
+ systemipaddress = (localhost.getHostAddress()).trim();
+ }
+ catch(Exception e1)
+ {
+ systemipaddress = "localhost";
+ }
+ }
+ }
+ catch (Exception e2)
+ {
+ systemipaddress = "localhost";
+ }
+ return systemipaddress;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/resources/bungee.yml b/src/main/resources/bungee.yml
new file mode 100644
index 0000000..e6eb37e
--- /dev/null
+++ b/src/main/resources/bungee.yml
@@ -0,0 +1,5 @@
+main: net.berrygames.bungee.GooseBerry
+
+name: GooseBerry
+author: BerryGames
+version: 0.0.1
\ No newline at end of file