diff --git a/BlockServer.iml b/BlockServer.iml
index 4766edb..d33a5d3 100644
--- a/BlockServer.iml
+++ b/BlockServer.iml
@@ -5,10 +5,14 @@
+
+
+
+
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 987e8e0..365c799 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,7 +2,6 @@ BlockServer Contributing Guidelines
===
## Contributing code
Please fork the repo and [create a pull request](https://github.com/BlockServerProject/BlockServer/pulls). Please note the following before you start writing code:
-* The code should follow the format at [Syntax.md](Syntax.md).
* If you are adding new features, please make sure we want it in our repo currently. If you find it [here](https://github.com/BlockServerProject/BlockServer/issues/112), you can start working on it (if nobody else is assigned for that task).
## Creating issues
diff --git a/Syntax.md b/Syntax.md
deleted file mode 100644
index e70a83e..0000000
--- a/Syntax.md
+++ /dev/null
@@ -1,66 +0,0 @@
-Syntax of BlockServer (Java)
-===
-* Indents should be in tabs.
-* Open braces for block expressions (e.g. methods, classes, if-blocks, for-blocks, etc.) should not occupy an independent line.
-* There can be an empty line between methods and/or fields.
-* There can be an empty line between two different sections of code.
-* Packages must be of or of subpackages of `org.blockserver`.
-* The three main code sections in a file (package, import, class/interface/enum declaration) should be separated with empty lines.
-* Imports of Java classes and custom classes can have an empty line between.
-* Do not make redundant imports like `java.lang.*` imports and unused imports.
-* Use Lombok for Getters and Setters
-* Use the Apache Logger library to print out text to console, with the following exceptions:
- * It is for debug purposes and will not affect user interface.
- * The server or the logger is not initialized.
-* Constructors, as a good practice, should point to the same `this(...)` constructor in order to avoid bugs.
-* Do not add redundant `this.` tokens unless necessary.
-* Add the `@Override` and `@SuppressWarnings(...)` annotations if required.
-* Unless name duplicated, do not fully qualify class names in class/interface/enum body.
-
-Example code:
-
-```java
-package org.blockserver.examples;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import net.blockserver.Server;
-
-@SuppressWarnings("serial")
-class ExampleException extends Exception{
- private String ext;
-
- public ExampleException(){
- this("Hello world!");
- }
- public ExampleException(String message){
- this(message, "log");
- }
- public ExampleException(String message, String ext){
- super(message);
- this.ext = ext;
- }
-
- public FilenameFilter getFilter(Pattern pattern){
- return new Foo(pattern);
- }
-
- private class Foo implements FilenameFilter{
- private Pattern pattern;
-
- public Foo(Pattern pattern){
- this.pattern = pattern;
- }
-
- @Override
- public boolean accept(File dir, String name){
- return pattern.bar(ext);
- }
- }
-
- public abstract static class Pattern extends com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern{
- public abstract boolean bar(String ext);
- }
-}
-```
diff --git a/pom.xml b/pom.xml
index 3ddab06..dffa341 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,6 +45,17 @@
1.16.6
provided
+
+ org.slf4j
+ slf4j-simple
+ 1.7.5
+
+
+
+ io.github.jython234.jraklibplus
+ JRakLibPlus
+ 1.2-SNAPSHOT
+
@@ -72,6 +83,7 @@
src/main/java/**
src/test/java/**
+ license-definitions.xml
pom.xml
@@ -99,7 +111,7 @@
- org.blockserver.core.run
+ org.blockserver.server.core.run
diff --git a/src/main/BlockServer.iml b/src/main/BlockServer.iml
deleted file mode 100644
index 7f09f9c..0000000
--- a/src/main/BlockServer.iml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/Server.java b/src/main/java/org/blockserver/core/Server.java
deleted file mode 100644
index 54c16ee..0000000
--- a/src/main/java/org/blockserver/core/Server.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.event.EventManager;
-import org.blockserver.core.events.modules.ModuleDisableEvent;
-import org.blockserver.core.events.modules.ModuleEnableEvent;
-import org.blockserver.core.module.EnableableImplementation;
-import org.blockserver.core.module.ModuleLoader;
-import org.blockserver.core.module.ServerModule;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Represents the core server implementation.
- *
- * @author BlockServer Team
- */
-public class Server implements EnableableImplementation {
- //TODO Add YAML utils somewhere!!
- //Modules
- private final Map, ServerModule> modules = new HashMap<>();
- @Getter @Setter private EventManager eventManager = new EventManager();
-
- public Server(ModuleLoader... moduleLoaders) {
- for (ModuleLoader moduleLoader : moduleLoaders) {
- moduleLoader.setModules(modules, this);
- }
- }
-
- @SuppressWarnings("unchecked")
- public T getModule(Class moduleClass) {
- return (T) modules.get(moduleClass);
- }
-
- public void addModule(ServerModule module) {
- modules.put(module.getClass(), module);
- }
-
- @Override
- public void enable() {
- modules.values().forEach((module) -> {
- if (module.isEnabled())
- return;
- eventManager.fire(new ModuleEnableEvent(this, module), event -> {
- if (!event.isCancelled())
- module.enable();
- });
- });
- EnableableImplementation.super.enable();
- }
-
- @Override
- public void disable() {
- modules.values().forEach((module) -> {
- if (!module.isEnabled())
- return;
- eventManager.fire(new ModuleDisableEvent(this, module), event -> {
- if (!event.isCancelled())
- module.disable();
- });
- });
- EnableableImplementation.super.disable();
- }
-
- public Map, ServerModule> getModules() {
- return Collections.unmodifiableMap(modules);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/event/Cancellable.java b/src/main/java/org/blockserver/core/event/Cancellable.java
deleted file mode 100644
index 8c7ffa9..0000000
--- a/src/main/java/org/blockserver/core/event/Cancellable.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.event;
-
-/**
- * Written by Exerosis!
- */
-public interface Cancellable {
- boolean isCancelled();
-
- void setCancelled(boolean cancelled);
-}
diff --git a/src/main/java/org/blockserver/core/event/CancellableImplementation.java b/src/main/java/org/blockserver/core/event/CancellableImplementation.java
deleted file mode 100644
index fbc5f74..0000000
--- a/src/main/java/org/blockserver/core/event/CancellableImplementation.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.event;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-public interface CancellableImplementation extends Cancellable {
- Map instances = new WeakHashMap<>();
-
- @Override
- default boolean isCancelled() {
- return instances.getOrDefault(this, false);
- }
-
- @Override
- default void setCancelled(boolean cancelled) {
- instances.put(this, cancelled);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/event/EventExecutor.java b/src/main/java/org/blockserver/core/event/EventExecutor.java
deleted file mode 100644
index 16ca3f6..0000000
--- a/src/main/java/org/blockserver/core/event/EventExecutor.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.event;
-
-public interface EventExecutor {
- void execute(T event);
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/event/EventListener.java b/src/main/java/org/blockserver/core/event/EventListener.java
deleted file mode 100644
index ba18652..0000000
--- a/src/main/java/org/blockserver/core/event/EventListener.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.event;
-
-
-public class EventListener {
- private Class _listenerType;
- private Priority _priority = Priority.NORMAL;
- private boolean _post;
-
- public Class getListenerType() {
- return _listenerType;
- }
-
- public boolean isPost() {
- return _post;
- }
-
- public Priority getPriority() {
- return _priority;
- }
-
- public void onEvent(B event) {
- }
-
- public EventListener post() {
- _post = !_post;
- return this;
- }
-
- public EventListener priority(Priority priority) {
- _priority = priority;
- return this;
- }
-
- public EventListener register(Class listenerType, EventManager eventManager) {
- _listenerType = listenerType;
- eventManager.registerListener(this);
- return this;
- }
-
- public void unregister(EventManager eventManager) {
- eventManager.unregisterListener(this);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/event/EventManager.java b/src/main/java/org/blockserver/core/event/EventManager.java
deleted file mode 100644
index 7a32c15..0000000
--- a/src/main/java/org/blockserver/core/event/EventManager.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.event;
-
-
-import java.util.Set;
-import java.util.TreeSet;
-
-public class EventManager {
- private Set> instances = new TreeSet<>((o1, o2) -> Integer.compare(o2.getPriority().ordinal(), o1.getPriority().ordinal()));
-
- public EventManager() {
- }
-
- public void registerListener(EventListener, ?> listener) {
- instances.add(listener);
- }
-
- public void unregisterListener(EventListener listener) {
- instances.remove(listener);
- }
-
- @SuppressWarnings("unchecked")
- public B fire(Class listenerType, B event, EventExecutor executor) {
- instances.stream().filter(l -> l.getListenerType().isAssignableFrom(listenerType)).forEach(l -> {
- EventListener listener = (EventListener) l;
- if (listener.isPost())
- listener.onEvent(event);
- else {
- if (executor != null)
- executor.execute(event);
- listener.onEvent(event);
- }
- });
- return event;
- }
-
- public B fire(B event, EventExecutor executor) {
- return fire(event.getClass(), event, executor);
- }
-
- public B fire(Class listenerType, B event) {
- return fire(listenerType, event, null);
- }
-
- public B fire(B event) {
- return fire(event.getClass(), event, null);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/event/MessageEventListener.java b/src/main/java/org/blockserver/core/event/MessageEventListener.java
deleted file mode 100644
index 24076dc..0000000
--- a/src/main/java/org/blockserver/core/event/MessageEventListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.event;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.events.messages.MessageEvent;
-import org.blockserver.core.modules.message.Message;
-
-/**
- * Written by Exerosis!
- */
-public class MessageEventListener extends EventListener> {
- public MessageEventListener register(Class listenerType, Server server) {
- return (MessageEventListener) register(listenerType, server.getEventManager());
- }
-
- public void unregister(Server server) {
- unregister(server.getEventManager());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/event/Priority.java b/src/main/java/org/blockserver/core/event/Priority.java
deleted file mode 100644
index 3447bdb..0000000
--- a/src/main/java/org/blockserver/core/event/Priority.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.event;
-
-public enum Priority {
-
- LOWEST(0), LOW(1), NORMAL(2), HIGH(3), HIGHEST(4), INTERNAL(5);
-
- private final int slot;
-
- Priority(int slot) {
- this.slot = slot;
- }
-
- public int getSlot() {
- return this.slot;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/event/ServerEventListener.java b/src/main/java/org/blockserver/core/event/ServerEventListener.java
deleted file mode 100644
index 62b7665..0000000
--- a/src/main/java/org/blockserver/core/event/ServerEventListener.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.event;
-
-import org.blockserver.core.Server;
-
-/**
- * Written by Exerosis!
- */
-public class ServerEventListener extends EventListener {
- public void register(Class listenerType, Server server) {
- register(listenerType, server.getEventManager());
- }
-
- public void unregister(Server server) {
- unregister(server.getEventManager());
- }
-
- public ServerEventListener post() {
- super.post();
- return this;
- }
-
- public ServerEventListener priority(Priority priority) {
- super.priority(priority);
- return this;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/ServerEvent.java b/src/main/java/org/blockserver/core/events/ServerEvent.java
deleted file mode 100644
index 0aa7337..0000000
--- a/src/main/java/org/blockserver/core/events/ServerEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.Server;
-
-public class ServerEvent {
- @Getter @Setter private Server server;
-
- public ServerEvent(Server server) {
- this.server = server;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/messages/MessageEvent.java b/src/main/java/org/blockserver/core/events/messages/MessageEvent.java
deleted file mode 100644
index e735b83..0000000
--- a/src/main/java/org/blockserver/core/events/messages/MessageEvent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.messages;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.event.CancellableImplementation;
-import org.blockserver.core.modules.message.Message;
-
-/**
- * Written by Exerosis!
- */
-public class MessageEvent implements CancellableImplementation {
- @Getter @Setter private T message;
-
- public MessageEvent(T message) {
- this.message = message;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/messages/MessageReceiveEvent.java b/src/main/java/org/blockserver/core/events/messages/MessageReceiveEvent.java
deleted file mode 100644
index 209dc74..0000000
--- a/src/main/java/org/blockserver/core/events/messages/MessageReceiveEvent.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.messages;
-
-import org.blockserver.core.modules.message.Message;
-
-public class MessageReceiveEvent extends MessageEvent {
- public MessageReceiveEvent(T message) {
- super(message);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/messages/MessageSendEvent.java b/src/main/java/org/blockserver/core/events/messages/MessageSendEvent.java
deleted file mode 100644
index 42fbe4b..0000000
--- a/src/main/java/org/blockserver/core/events/messages/MessageSendEvent.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.messages;
-
-import org.blockserver.core.modules.message.Message;
-
-public class MessageSendEvent extends MessageEvent {
- public MessageSendEvent(T message) {
- super(message);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/modules/ModuleDisableEvent.java b/src/main/java/org/blockserver/core/events/modules/ModuleDisableEvent.java
deleted file mode 100644
index 6998ba4..0000000
--- a/src/main/java/org/blockserver/core/events/modules/ModuleDisableEvent.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.modules;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-
-public class ModuleDisableEvent extends ModuleEvent {
- public ModuleDisableEvent(Server server, ServerModule module) {
- super(server, module);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/modules/ModuleEnableEvent.java b/src/main/java/org/blockserver/core/events/modules/ModuleEnableEvent.java
deleted file mode 100644
index 6074c6a..0000000
--- a/src/main/java/org/blockserver/core/events/modules/ModuleEnableEvent.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.modules;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-
-public class ModuleEnableEvent extends ModuleEvent {
- public ModuleEnableEvent(Server server, ServerModule module) {
- super(server, module);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/modules/ModuleEvent.java b/src/main/java/org/blockserver/core/events/modules/ModuleEvent.java
deleted file mode 100644
index 4d32fee..0000000
--- a/src/main/java/org/blockserver/core/events/modules/ModuleEvent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.modules;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.Server;
-import org.blockserver.core.event.CancellableImplementation;
-import org.blockserver.core.events.ServerEvent;
-import org.blockserver.core.module.ServerModule;
-
-public class ModuleEvent extends ServerEvent implements CancellableImplementation {
- @Getter @Setter private ServerModule module;
-
- public ModuleEvent(Server server, ServerModule module) {
- super(server);
- this.module = module;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/packets/PacketEvent.java b/src/main/java/org/blockserver/core/events/packets/PacketEvent.java
deleted file mode 100644
index 581c8f3..0000000
--- a/src/main/java/org/blockserver/core/events/packets/PacketEvent.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.packets;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.event.CancellableImplementation;
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-/**
- * Written by Exerosis!
- */
-public class PacketEvent implements CancellableImplementation {
- @Getter @Setter private RawPacket packet;
-
- public PacketEvent(RawPacket packet) {
- this.packet = packet;
- }
-}
diff --git a/src/main/java/org/blockserver/core/events/packets/PacketReceiveEvent.java b/src/main/java/org/blockserver/core/events/packets/PacketReceiveEvent.java
deleted file mode 100644
index fd13543..0000000
--- a/src/main/java/org/blockserver/core/events/packets/PacketReceiveEvent.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.packets;
-
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-/**
- * Written by Exerosis!
- */
-public class PacketReceiveEvent extends PacketEvent {
- public PacketReceiveEvent(RawPacket packet) {
- super(packet);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/events/packets/PacketSendEvent.java b/src/main/java/org/blockserver/core/events/packets/PacketSendEvent.java
deleted file mode 100644
index 5e92b1c..0000000
--- a/src/main/java/org/blockserver/core/events/packets/PacketSendEvent.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.events.packets;
-
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-/**
- * Written by Exerosis!
- */
-public class PacketSendEvent extends PacketEvent {
- public PacketSendEvent(RawPacket packet) {
- super(packet);
- }
-}
diff --git a/src/main/java/org/blockserver/core/exceptions/BlockServerException.java b/src/main/java/org/blockserver/core/exceptions/BlockServerException.java
deleted file mode 100644
index 3eb49aa..0000000
--- a/src/main/java/org/blockserver/core/exceptions/BlockServerException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.exceptions;
-
-import org.blockserver.core.exceptions.node.ExceptionBuilder;
-
-public class BlockServerException extends RuntimeException {
- public BlockServerException(String message) {
- super(message);
- }
-
- public BlockServerException(ExceptionBuilder factory) {
- super(factory.toString());
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/exceptions/node/ExceptionBuilder.java b/src/main/java/org/blockserver/core/exceptions/node/ExceptionBuilder.java
deleted file mode 100644
index 8a6797f..0000000
--- a/src/main/java/org/blockserver/core/exceptions/node/ExceptionBuilder.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.exceptions.node;
-
-public class ExceptionBuilder {
- private StringBuilder builder = new StringBuilder("\t");
-
- public ExceptionBuilder(String name, ExceptionNode... nodes) {
- builder.append(name);
- for (ExceptionNode node : nodes)
- appendNode(node);
- }
-
- public ExceptionBuilder appendNode(ExceptionNode node) {
- if (node == null)
- return this;
- builder.append("\n\t");
- builder.append(node.getName());
- builder.append(": '");
- builder.append(node.getValue());
- builder.append('\'');
- return this;
- }
-
- @Override
- public String toString() {
- return builder.toString();
- }
-}
diff --git a/src/main/java/org/blockserver/core/exceptions/node/ExceptionNode.java b/src/main/java/org/blockserver/core/exceptions/node/ExceptionNode.java
deleted file mode 100644
index ae0a924..0000000
--- a/src/main/java/org/blockserver/core/exceptions/node/ExceptionNode.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.exceptions.node;
-
-public class ExceptionNode {
- private String name = "";
- private Object value;
-
- public ExceptionNode(String name, Object value) {
- this.name = name;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public Object getValue() {
- return value;
- }
-}
diff --git a/src/main/java/org/blockserver/core/module/Enableable.java b/src/main/java/org/blockserver/core/module/Enableable.java
deleted file mode 100644
index ace3ec5..0000000
--- a/src/main/java/org/blockserver/core/module/Enableable.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.module;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- */
-public interface Enableable {
- void enable();
-
- boolean isEnabled();
-
- void disable();
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/module/EnableableImplementation.java b/src/main/java/org/blockserver/core/module/EnableableImplementation.java
deleted file mode 100644
index c10a6d8..0000000
--- a/src/main/java/org/blockserver/core/module/EnableableImplementation.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.module;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-/**
- * @author BlockServer Team
- * @see org.blockserver.core.module.Enableable
- */
-public interface EnableableImplementation extends Enableable {
- Map instances = new WeakHashMap<>();
-
- @Override
- default void enable() {
- instances.put(this, true);
- }
-
- @Override
- default boolean isEnabled() {
- return instances.getOrDefault(this, false);
- }
-
- @Override
- default void disable() {
- instances.put(this, false);
- }
-}
diff --git a/src/main/java/org/blockserver/core/module/Module.java b/src/main/java/org/blockserver/core/module/Module.java
deleted file mode 100644
index 6b4f548..0000000
--- a/src/main/java/org/blockserver/core/module/Module.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.module;
-
-/**
- * Created by Exerosis.
- */
-public interface Module extends EnableableImplementation {
-}
diff --git a/src/main/java/org/blockserver/core/module/ModuleLoader.java b/src/main/java/org/blockserver/core/module/ModuleLoader.java
deleted file mode 100644
index d31bea4..0000000
--- a/src/main/java/org/blockserver/core/module/ModuleLoader.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.module;
-
-import org.blockserver.core.Server;
-
-import java.util.Map;
-
-/**
- * @author BlockServer Team
- * @see org.blockserver.core.module.loaders
- */
-public interface ModuleLoader {
- void setModules(Map, ServerModule> modules, Server server);
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/module/ServerModule.java b/src/main/java/org/blockserver/core/module/ServerModule.java
deleted file mode 100644
index 8a8922e..0000000
--- a/src/main/java/org/blockserver/core/module/ServerModule.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.module;
-
-import lombok.Getter;
-import org.blockserver.core.Server;
-
-/**
- * Base class for all modules. New modules should implement this class.
- *
- * @author BlockServer Team
- * @see org.blockserver.core.modules
- * @see org.blockserver.core.module.EnableableImplementation
- */
-public class ServerModule implements Module {
- @Getter private final Server server;
-
- public ServerModule(Server server) {
- this.server = server;
- }
-
- @Override
- public String toString() {
- return "[" + server.toString() + "] " + getClass().getSimpleName();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/module/loaders/CoreModuleLoader.java b/src/main/java/org/blockserver/core/module/loaders/CoreModuleLoader.java
deleted file mode 100644
index 5c91ba7..0000000
--- a/src/main/java/org/blockserver/core/module/loaders/CoreModuleLoader.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.module.loaders;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ModuleLoader;
-import org.blockserver.core.module.ServerModule;
-import org.blockserver.core.modules.config.ConfigModule;
-import org.blockserver.core.modules.file.FileModule;
-import org.blockserver.core.modules.logging.LoggingModule;
-import org.blockserver.core.modules.network.NetworkModule;
-import org.blockserver.core.modules.player.PlayerModule;
-import org.blockserver.core.modules.scheduler.SchedulerModule;
-import org.blockserver.core.modules.thread.ExecutorModule;
-
-import java.util.Map;
-
-/**
- * @author BlockServer Team
- * @see org.blockserver.core.module.ModuleLoader
- */
-public class CoreModuleLoader implements ModuleLoader {
-
- @Override
- public void setModules(Map, ServerModule> modules, Server server) {
- int start = modules.size();
-
- //Logging Module
- LoggingModule loggingModule = new LoggingModule(server);
- loggingModule.info("[CoreModuleLoader]: LoggingModule online, continuing load with logging capabilities!");
-
- //No Depends
- FileModule fileModule = new FileModule(server);
- PlayerModule playerModule = new PlayerModule(server);
- NetworkModule networkModule = new NetworkModule(server);
-
- //Single Module Depends
- ConfigModule configModule = new ConfigModule(server, fileModule);
- ExecutorModule executorModule = new ExecutorModule(server, configModule);
- SchedulerModule schedulerModule = new SchedulerModule(server, executorModule);
-
- //Multiple Module Depends
-
-
- //Module Adds
- //No Depends
- modules.put(fileModule.getClass(), fileModule);
- modules.put(loggingModule.getClass(), loggingModule);
- modules.put(networkModule.getClass(), networkModule);
- modules.put(playerModule.getClass(), playerModule);
-
- //Single Module Depends
- modules.put(configModule.getClass(), configModule);
- modules.put(executorModule.getClass(), executorModule);
- modules.put(schedulerModule.getClass(), schedulerModule);
-
- loggingModule.info("[CoreModuleLoader]: Loaded " + (modules.size() - start) + " core modules.");
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/module/loaders/JarModuleLoader.java b/src/main/java/org/blockserver/core/module/loaders/JarModuleLoader.java
deleted file mode 100644
index 5a24afd..0000000
--- a/src/main/java/org/blockserver/core/module/loaders/JarModuleLoader.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.module.loaders;
-
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ModuleLoader;
-import org.blockserver.core.module.ServerModule;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Map;
-import java.util.Properties;
-import java.util.jar.JarFile;
-
-/**
- * ServerModule Loader that can load modules from JARs
- *
- * @author BlockServer Team
- * @see org.blockserver.core.module.ModuleLoader
- */
-public class JarModuleLoader implements ModuleLoader {
- @SuppressWarnings({"unchecked", "deprecation"})
- @Override
- public void setModules(Map, ServerModule> modules, Server server) {
- File moduleFolder = new File("Modules");
- if (moduleFolder.mkdirs())
- System.err.println("Could not find modules folder, created modules folder!");
- File[] files = moduleFolder.listFiles();
- System.err.println(files.length);
- if (files == null || files.length <= 0)
- return;
-
- for (File file : files) {
- System.err.println(file.getName());
- if (file.getName().endsWith(".jar")) {
- try {
- JarFile jar = new JarFile(file);
- Properties jarProp = getJarProperties(jar);
- URLClassLoader loader = new URLClassLoader(new URL[]{file.toURL()});
- String className = jarProp.getProperty("mainClass", "default");
- try {
- Class clazz = loader.loadClass(className);
- try {
- ServerModule module = (ServerModule) clazz.getConstructor(Server.class).newInstance(server);
- modules.put(module.getClass(), module);
- System.out.println("[ServerModule Loader]: Loaded " + file.getName());
- } catch (ClassCastException e) {
- System.err.println("[ServerModule Loader]: Failed to load main class for " + file.getName() + ": main class does not extend ServerModule.");
- } catch (NoSuchMethodException | InvocationTargetException e) {
- System.err.println("[ServerModule Loader]: Failed to load main class for " + file.getName() + ": " + e.getClass().getSimpleName() + " -> " + e.getMessage());
- }
- } catch (ClassNotFoundException e) {
- if (className.equals("default")) {
- System.err.println("[ServerModule Loader]: Failed to load main class for " + file.getName() + ": main class not specified.");
- }
- System.err.println("[ServerModule Loader]: Failed to load main class for " + file.getName() + ": ClassNotFoundException -> " + e.getMessage());
- } catch (InstantiationException | IllegalAccessException e) {
- System.err.println("[ServerModule Loader]: Failed to load main class for " + file.getName() + ": " + e.getClass().getSimpleName() + " -> " + e.getMessage());
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- private Properties getJarProperties(JarFile jar) throws IOException {
- InputStream stream = jar.getInputStream(jar.getJarEntry("module.properties"));
- Properties p = new Properties();
- p.load(stream);
- return p;
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/config/ConfigModule.java b/src/main/java/org/blockserver/core/modules/config/ConfigModule.java
deleted file mode 100644
index 2ca99e4..0000000
--- a/src/main/java/org/blockserver/core/modules/config/ConfigModule.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.blockserver.core.modules.config;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-import org.blockserver.core.modules.file.FileModule;
-
-/**
- * Created by Exerosis.
- */
-public class ConfigModule extends ServerModule {
- private final FileModule fileModule;
-
- public ConfigModule(Server server, FileModule fileModule) {
- super(server);
- this.fileModule = fileModule;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/entity/Entity.java b/src/main/java/org/blockserver/core/modules/entity/Entity.java
deleted file mode 100644
index cca43c3..0000000
--- a/src/main/java/org/blockserver/core/modules/entity/Entity.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.entity;
-
-import org.blockserver.core.modules.world.positions.Location;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- */
-public class Entity {
- private final Map, EntityModule> modules = new HashMap<>();
- private float x;
- private float y;
- private float z;
-
- //TODO deal with locations and what not!!
- public Entity(float x, float y, float z) {
- this.x = x;
- this.y = y;
- this.z = z;
- modules.values().forEach(EntityModule::enable);
- }
-
- public Entity(Location location) {
- this(location.getX(), location.getY(), location.getZ());
- }
-
-
- public void addModule(EntityModule module) {
- modules.put(module.getClass(), module);
- }
-
- public void removeModule(Class extends EntityModule> moduleClass) {
- modules.remove(moduleClass);
- }
-
- public void removeModule(EntityModule module) {
- removeModule(module.getClass());
- }
-
- public EntityModule getModule(Class extends EntityModule> moduleClass) {
- return modules.get(moduleClass);
- }
-
- public void destroy() {
- modules.values().forEach(EntityModule::disable);
- }
-
-
- public Map, EntityModule> getModules() {
- return Collections.unmodifiableMap(modules);
- }
-
- public Location getLocation() {
- return new Location(x, y, z);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/entity/EntityModule.java b/src/main/java/org/blockserver/core/modules/entity/EntityModule.java
deleted file mode 100644
index ce02e87..0000000
--- a/src/main/java/org/blockserver/core/modules/entity/EntityModule.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package org.blockserver.core.modules.entity;
-
-import lombok.Getter;
-import org.blockserver.core.module.Module;
-
-/**
- * Created by Exerosis.
- */
-public class EntityModule implements Module {
- @Getter private final Entity entity;
-
- public EntityModule(Entity entity) {
- this.entity = entity;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/entity/entities/ExampleEntity.java b/src/main/java/org/blockserver/core/modules/entity/entities/ExampleEntity.java
deleted file mode 100644
index 37f4fd6..0000000
--- a/src/main/java/org/blockserver/core/modules/entity/entities/ExampleEntity.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.blockserver.core.modules.entity.entities;
-
-import org.blockserver.core.modules.entity.Entity;
-import org.blockserver.core.modules.entity.modules.ExampleEntityModule;
-import org.blockserver.core.modules.world.positions.Location;
-
-/**
- * Created by Exerosis.
- */
-public class ExampleEntity extends Entity {
- public ExampleEntity(Location location) {
- super(location);
- }
-
- public ExampleEntity(float x, float y, float z) {
- super(x, y, z);
- addModule(new ExampleEntityModule(this));
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/entity/modules/ExampleEntityModule.java b/src/main/java/org/blockserver/core/modules/entity/modules/ExampleEntityModule.java
deleted file mode 100644
index a2fbe92..0000000
--- a/src/main/java/org/blockserver/core/modules/entity/modules/ExampleEntityModule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.blockserver.core.modules.entity.modules;
-
-import org.blockserver.core.modules.entity.Entity;
-import org.blockserver.core.modules.entity.EntityModule;
-
-/**
- * Created by Exerosis.
- */
-public class ExampleEntityModule extends EntityModule {
- public ExampleEntityModule(Entity entity) {
- super(entity);
- }
-
- @Override
- public void enable() {
- super.enable();
- }
-
- @Override
- public void disable() {
- super.disable();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/file/FileModule.java b/src/main/java/org/blockserver/core/modules/file/FileModule.java
deleted file mode 100644
index 916739f..0000000
--- a/src/main/java/org/blockserver/core/modules/file/FileModule.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.blockserver.core.modules.file;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-
-/**
- * Created by Exerosis.
- */
-public class FileModule extends ServerModule {
- public FileModule(Server server) {
- super(server);
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/logging/LoggingModule.java b/src/main/java/org/blockserver/core/modules/logging/LoggingModule.java
deleted file mode 100644
index af1fcf5..0000000
--- a/src/main/java/org/blockserver/core/modules/logging/LoggingModule.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.logging;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-
-/**
- * Logging ServerModule with different log levels. (debug, info, warn, error)
- * TODO: Implement SLF4j and/or log4j2
- *
- * @author BlockServer Team
- * @see ServerModule
- */
-public class LoggingModule extends ServerModule {
-
- public LoggingModule(Server server) {
- super(server);
- }
-
- public void debug(String message) {
- System.out.println("[DEBUG]: " + message);
- }
-
- public void info(String message) {
- System.out.println("[INFO]: " + message);
- }
-
- public void warn(String message) {
- System.out.println("[WARN]: " + message);
- }
-
- public void error(String message) {
- System.err.println("[ERROR]: " + message);
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/message/Message.java b/src/main/java/org/blockserver/core/modules/message/Message.java
deleted file mode 100644
index 4a86642..0000000
--- a/src/main/java/org/blockserver/core/modules/message/Message.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.message;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.modules.player.Player;
-
-/**
- * Written by Exerosis!
- */
-public class Message {
- @Getter final private boolean async;
- @Getter @Setter private Player player;
-
- public Message(Player player) {
- this.player = player;
- async = false;
- }
-
- public Message(Player player, boolean async) {
- this.player = player;
- this.async = async;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/message/MessageModule.java b/src/main/java/org/blockserver/core/modules/message/MessageModule.java
deleted file mode 100644
index 8a164bb..0000000
--- a/src/main/java/org/blockserver/core/modules/message/MessageModule.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.message;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.event.Priority;
-import org.blockserver.core.event.ServerEventListener;
-import org.blockserver.core.events.messages.MessageReceiveEvent;
-import org.blockserver.core.events.messages.MessageSendEvent;
-import org.blockserver.core.modules.network.NetworkConverter;
-import org.blockserver.core.modules.network.pipeline.NetworkPipelineHandler;
-import org.blockserver.core.modules.network.pipeline.PipelineDispatcher;
-import org.blockserver.core.modules.network.pipeline.PipelineProviderImplementation;
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-import org.blockserver.core.modules.thread.ExecutorModule;
-
-public class MessageModule extends PipelineProviderImplementation implements PipelineDispatcher {
- private final ServerEventListener listener;
- private final ExecutorModule executorModule;
- private final NetworkConverter converter;
-
- public MessageModule(Server server, ExecutorModule executorModule, NetworkPipelineHandler handler, NetworkConverter converter) {
- super(server, handler);
- this.executorModule = executorModule;
- this.converter = converter;
- listener = new ServerEventListener() {
- @Override
- public void onEvent(MessageSendEvent event) {
- if (!event.isCancelled())
- provide(converter.toPacket(event.getMessage()));
- }
- }.priority(Priority.INTERNAL).post();
- }
-
- @Override
- public void enable() {
- listener.register(MessageSendEvent.class, getServer());
- super.enable();
- }
-
- @Override
- public void disable() {
- listener.unregister(getServer());
- super.disable();
- }
-
- @Override
- public void dispatch(RawPacket packet) {
- executorModule.getExecutorService().execute(() -> getServer().getEventManager().fire(new MessageReceiveEvent<>(converter.toMessage(packet))));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/message/messages/PlayerLoginMessage.java b/src/main/java/org/blockserver/core/modules/message/messages/PlayerLoginMessage.java
deleted file mode 100644
index 06ddec8..0000000
--- a/src/main/java/org/blockserver/core/modules/message/messages/PlayerLoginMessage.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.message.messages;
-
-import org.blockserver.core.modules.message.Message;
-import org.blockserver.core.modules.player.Player;
-import org.blockserver.core.utilities.Skin;
-
-import java.util.UUID;
-
-/**
- * Written by Exerosis!
- */
-public class PlayerLoginMessage extends Message {
- public long clientID;
- public String username;
- public UUID uuid;
- public Skin skin;
-
- public PlayerLoginMessage(Player player) {
- super(player);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/message/messages/block/MessageOutBlockChange.java b/src/main/java/org/blockserver/core/modules/message/messages/block/MessageOutBlockChange.java
deleted file mode 100644
index 76c4117..0000000
--- a/src/main/java/org/blockserver/core/modules/message/messages/block/MessageOutBlockChange.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.message.messages.block;
-
-import org.blockserver.core.modules.message.Message;
-import org.blockserver.core.modules.player.Player;
-import org.blockserver.core.modules.world.Block;
-
-/**
- * Written by Exerosis!
- */
-public class MessageOutBlockChange extends Message {
- public MessageOutBlockChange(Player player, Block... blocks) {
- super(player);
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/network/NetworkConverter.java b/src/main/java/org/blockserver/core/modules/network/NetworkConverter.java
deleted file mode 100644
index 56194e0..0000000
--- a/src/main/java/org/blockserver/core/modules/network/NetworkConverter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.network;
-
-
-import org.blockserver.core.modules.message.Message;
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-/**
- * Written by Exerosis!
- */
-public interface NetworkConverter {
- RawPacket toPacket(Message message);
-
- Message toMessage(RawPacket packet);
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/network/NetworkModule.java b/src/main/java/org/blockserver/core/modules/network/NetworkModule.java
deleted file mode 100644
index 1494e70..0000000
--- a/src/main/java/org/blockserver/core/modules/network/NetworkModule.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.blockserver.core.modules.network;
-
-import lombok.Getter;
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-import org.blockserver.core.modules.network.pipeline.NetworkPipelineHandler;
-
-/**
- * Created by Exerosis.
- */
-public class NetworkModule extends ServerModule {
- @Getter private NetworkPipelineHandler inboundHandler = new NetworkPipelineHandler();
- @Getter private NetworkPipelineHandler outboundHandler = new NetworkPipelineHandler();
-
- public NetworkModule(Server server) {
- super(server);
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/network/PacketEventModule.java b/src/main/java/org/blockserver/core/modules/network/PacketEventModule.java
deleted file mode 100644
index d1ea4ce..0000000
--- a/src/main/java/org/blockserver/core/modules/network/PacketEventModule.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.network;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.event.Priority;
-import org.blockserver.core.event.ServerEventListener;
-import org.blockserver.core.events.packets.PacketReceiveEvent;
-import org.blockserver.core.events.packets.PacketSendEvent;
-import org.blockserver.core.modules.network.pipeline.NetworkPipelineHandler;
-import org.blockserver.core.modules.network.pipeline.PipelineDispatcher;
-import org.blockserver.core.modules.network.pipeline.PipelineProviderImplementation;
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-public class PacketEventModule extends PipelineProviderImplementation implements PipelineDispatcher {
- private final ServerEventListener listener;
-
- public PacketEventModule(NetworkPipelineHandler handler, Server server) {
- super(server, handler);
- listener = new ServerEventListener() {
- @Override
- public void onEvent(PacketSendEvent event) {
- if (!event.isCancelled())
- provide(event.getPacket());
- }
- }.priority(Priority.INTERNAL).post();
- }
-
- @Override
- public void enable() {
- listener.register(PacketSendEvent.class, getServer());
- super.enable();
- }
-
- @Override
- public void disable() {
- listener.unregister(getServer());
- super.disable();
- }
-
- @Override
- public void dispatch(RawPacket packet) {
- getServer().getEventManager().fire(new PacketReceiveEvent(packet));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/network/pipeline/NetworkPipelineHandler.java b/src/main/java/org/blockserver/core/modules/network/pipeline/NetworkPipelineHandler.java
deleted file mode 100644
index c6efada..0000000
--- a/src/main/java/org/blockserver/core/modules/network/pipeline/NetworkPipelineHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.network.pipeline;
-
-
-import lombok.Getter;
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-public class NetworkPipelineHandler {
- @Getter private final Set dispatchers = Collections.synchronizedSet(new HashSet<>());
-
- public NetworkPipelineHandler() {
-
- }
-
- public void provide(RawPacket packet) {
- for (PipelineDispatcher dispatcher : dispatchers) {
- dispatcher.dispatch(packet);
- }
- }
-
- public void unregisterDispatcher(PipelineDispatcher dispatcher) {
- dispatchers.remove(dispatcher);
- }
-
- public void registerDispatcher(PipelineDispatcher dispatcher) {
- dispatchers.add(dispatcher);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineDispatcher.java b/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineDispatcher.java
deleted file mode 100644
index d00377c..0000000
--- a/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineDispatcher.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.network.pipeline;
-
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-/**
- * Written by Exerosis!
- */
-public interface PipelineDispatcher {
- void dispatch(RawPacket packet);
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineProvider.java b/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineProvider.java
deleted file mode 100644
index 9c3d4db..0000000
--- a/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineProvider.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.blockserver.core.modules.network.pipeline;
-
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-/**
- * Created by Exerosis.
- */
-public interface PipelineProvider {
- void provide(RawPacket packet);
-}
diff --git a/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineProviderImplementation.java b/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineProviderImplementation.java
deleted file mode 100644
index 0b1242c..0000000
--- a/src/main/java/org/blockserver/core/modules/network/pipeline/PipelineProviderImplementation.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.network.pipeline;
-
-import lombok.Getter;
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-import org.blockserver.core.modules.network.pipeline.packet.RawPacket;
-
-public class PipelineProviderImplementation extends ServerModule implements PipelineProvider {
- @Getter private final NetworkPipelineHandler handler;
-
- public PipelineProviderImplementation(Server server, NetworkPipelineHandler handler) {
- super(server);
- this.handler = handler;
- }
-
- @Override
- public void provide(RawPacket packet) {
- handler.provide(packet);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/network/pipeline/packet/BinaryBuffer.java b/src/main/java/org/blockserver/core/modules/network/pipeline/packet/BinaryBuffer.java
deleted file mode 100644
index 8557636..0000000
--- a/src/main/java/org/blockserver/core/modules/network/pipeline/packet/BinaryBuffer.java
+++ /dev/null
@@ -1,402 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.network.pipeline.packet;
-
-/*
-import net.redstonelamp.item.Item;
-import net.redstonelamp.utils.BinaryUtils;
-import org.spout.nbt.CompoundTag;
-*/
-
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.UUID;
-
-/**
- * An NIO buffer class to wrap around a java.nio.ByteBuffer.
- *
- * This buffer is dynamic, as it changes size when the allocated amount is too small.
- *
- * This class is originally from the RedstoneLamp Project. It has been modified from the original
- * which can be found at: https://github.com/RedstoneLamp/RedstoneLamp/blob/rewrite/src/main/java/net/redstonelamp/nio/BinaryBuffer.java
- *
- * @author RedstoneLamp Team and BlockServer Team
- */
-public class BinaryBuffer{
- private ByteBuffer bb;
-
- protected BinaryBuffer(ByteBuffer bb){
- this.bb = bb;
- }
-
- /**
- * Create a new DynamicByteBuffer wrapped around a byte array with the specified order
- *
- * @param bytes The byte array to be wrapped around
- * @param order The ByteOrder of the buffer, Big Endian or Little Endian.
- * @return A new DynamicByteBuffer class, at position zero wrapped around the byte array in the specified order
- */
- public static BinaryBuffer wrapBytes(byte[] bytes, ByteOrder order){
- ByteBuffer bb = ByteBuffer.wrap(bytes);
- bb.order(order);
- bb.position(0);
- return new BinaryBuffer(bb);
- }
-
- /**
- * Create a new DynamicByteBuffer with the specified initalSize and order
- *
- * The Buffer will grow if an attempt is to put more data than the initalSize
- *
- * @param initalSize The inital size of the buffer
- * @param order The ByteOrder of the buffer, Big Endian or Little Endian
- * @return A new DynamicByteBuffer class, at position zero with the specified order and initalSize
- */
- public static BinaryBuffer newInstance(int initalSize, ByteOrder order){
- ByteBuffer bb = ByteBuffer.allocate(initalSize);
- bb.order(order);
- bb.position(0);
- return new BinaryBuffer(bb);
- }
-
- /**
- * Get len of bytes from the buffer.
- *
- * @param len The length of bytes to get from the buffer
- * @return A byte array of len bytes
- * @throws java.nio.BufferUnderflowException If there is not enough bytes in the buffer to read
- */
- public byte[] get(int len){
- byte[] b = new byte[len];
- bb.get(b);
- return b;
- }
-
- /**
- * Put an amount of bytes into the buffer. The buffer will resize to fit the bytes if the buffer is too small.
- *
- * @param bytes The byte array to be put into the buffer
- */
- public void put(byte[] bytes){
- try{
- bb.put(bytes);
- }catch(BufferOverflowException e){
- setPosition(0);
- byte[] all = get(remaining());
- bb = ByteBuffer.allocate(all.length + bytes.length);
- bb.put(all);
- bb.put(bytes);
- }
- }
-
- /**
- * Get a single signed byte from the buffer
- *
- * @return A single unsigned byte
- */
- public byte getByte(){
- return bb.get();
- }
-
- /**
- * Get a single signed boolean from the buffer (one byte)
- *
- * @return A single boolean
- */
- public boolean getBoolean(){
- return bb.get() > 0;
- }
-
- /**
- * Get a single unsigned byte from the buffer
- *
- * @return A single unsigned byte
- */
- public short getUnsignedByte(){
- return (short) (bb.get() & 0xFF);
- }
-
- /**
- * Get a single signed short (2 bytes) from the buffer
- *
- * @return A single signed short
- */
- public short getShort(){
- return bb.getShort();
- }
-
- /**
- * Get a single unsigned short (2 bytes) from the buffer
- *
- * @return A single unsigned short
- */
- public short getUnsignedShort(){
- return (short) (bb.getShort() & 0xFFFF);
- }
-
- /**
- * Get a single signed integer (4 bytes) from the buffer
- *
- * @return A single signed integer
- */
- public int getInt(){
- return bb.getInt();
- }
-
- /**
- * Get a single singed long (8 bytes) from the buffer
- *
- * @return A single signed long
- */
- public long getLong(){
- return bb.getLong();
- }
-
- public float getFloat(){
- return bb.getFloat();
- }
-
- public double getDouble(){
- return bb.getDouble();
- }
-
- /**
- * Gets a Google Protocol Buffers VarInt from the buffer.
- * Code is from: https://gist.github.com/thinkofdeath/e975ddee04e9c87faf22
- *
- * @return The VarInt, as an integer.
- */
- public int getVarInt(){
- int size = 0;
- for(int i = 0; ; i += 7){
- byte tmp = getByte();
- if((tmp & 0x80) == 0 && (i != 4 * 7 || tmp < 1 << 3)){
- return size | tmp << i;
- }else if(i < 4 * 7){
- size |= (tmp & 0x7f) << i;
- }
- }
- }
-
- /**
- * Get a single short prefixed string from the buffer (2 + str bytes)
- *
- * @return A single short prefixed string
- */
- public String getString(){
- return new String(get(getUnsignedShort()));
- }
-
- /*
- public Item getSlot(){
- short id = getShort();
- if(id <= 0){
- return Item.get(0, (short) 0, 0);
- }
- int count = getByte();
- short data = getShort();
-
- int len = getUnsignedShort();
- if(len > 0){
- byte[] nbt = get(len);
-
- Item i = Item.get(id, data, count);
- if(i != null){
- i.setCompoundTag((CompoundTag) BinaryUtils.readNBTTag(nbt));
- }
- return i;
- }else{
- return Item.get(id, data, count);
- }
- }
- */
-
- /**
- * Get a single varint prefixed string from the buffer (varint bytes + str bytes)
- *
- * @return A single varint prefixed string
- */
- public String getVarString(){
- return new String(get(getVarInt()));
- }
-
- public UUID getUUID(){
- return new UUID(bb.getLong(), bb.getLong());
- }
-
- public void putByte(byte b){
- put(new byte[]{b});
- }
-
- public void putBoolean(boolean b){
- put(new byte[]{(byte) (b ? 1 : 0)});
- }
-
- public void putShort(short s){
- put(ByteBuffer.allocate(2).order(getOrder()).putShort(s).array());
- }
-
- public void putInt(int i){
- put(ByteBuffer.allocate(4).order(getOrder()).putInt(i).array());
- }
-
- public void putLong(long l){
- put(ByteBuffer.allocate(8).order(getOrder()).putLong(l).array());
- }
-
- public void putFloat(float f){
- put(ByteBuffer.allocate(4).order(getOrder()).putFloat(f).array());
- }
-
- public void putDouble(double d){
- put(ByteBuffer.allocate(8).order(getOrder()).putDouble(d).array());
- }
-
- public void putString(String s){
- putShort((short) s.getBytes().length);
- put(s.getBytes());
- }
-
- public void putVarString(String s){
- putVarInt(s.getBytes().length);
- put(s.getBytes());
- }
-
- public void putUUID(UUID uuid){
- putLong(uuid.getMostSignificantBits());
- putLong(uuid.getLeastSignificantBits());
- }
-
- /*
- public void putSlot(Item item){
- if(item.getId() == 0){
- putShort((short) 0);
- return;
- }
- putShort((short) item.getId());
- putByte((byte) item.getCount());
- putShort(item.getMeta());
-
- byte[] nbt = item.getCompoundTag() != null ? BinaryUtils.writeNBT(item.getCompoundTag()) : new byte[0];
- putShort((short) nbt.length);
- put(nbt);
- }
- */
-
- /**
- * Puts a Google Protocol Buffers VarInt into the buffer
- * Code is from: https://gist.github.com/thinkofdeath/e975ddee04e9c87faf22
- *
- * @param i The VarInt as an Integer.
- */
- public void putVarInt(int i){
- while(i > 0x7f){
- putByte((byte) (i & 0x7f | 0x80));
- i >>= 7;
- }
- putByte((byte) i);
- }
-
- /**
- * Get a single line string containing each byte of the buffer in hexadecimal
- *
- * @return A String containing each byte of the buffer in hexadecimal with no newlines.
- */
- public String singleLineHexDump(){
- StringBuilder sb = new StringBuilder();
- byte[] data = bb.array();
- for(byte b : data){
- sb.append(String.format("%02X", b)).append(" ");
- }
- return sb.toString();
- }
-
- /**
- * Get the ByteOrder of the underlying ByteBuffer
- *
- * @return The ByteOrder of the ByteBuffer
- */
- public ByteOrder getOrder(){
- return bb.order();
- }
-
- /**
- * Set the ByteOrder of the underlying ByteBuffer
- *
- * @param order The ByteOrder to be set to.
- */
- public void setOrder(ByteOrder order){
- bb.order(order);
- }
-
- /**
- * Get the position of the underyling ByteBuffer
- *
- * @return The position in the buffer
- */
- public int getPosition() {
- return bb.position();
- }
-
- /**
- * Set the position of the underlying ByteBuffer
- *
- * @param position The position in the buffer to be set to
- */
- public void setPosition(int position) {
- bb.position(position);
- }
-
- /**
- * Get the amount of bytes remaining in the buffer
- *
- * @return The amount of remaining bytes in the buffer
- */
- public int remaining(){
- return bb.remaining();
- }
-
- /**
- * Get the remaining bytes in the buffer.
- *
- * NOTE: This DOES increase the position in the buffer.
- *
- * @return The reamaining bytes in the buffer.
- */
- public byte[] remainingBytes(){
- return get(remaining());
- }
-
- /**
- * Get a byte array of the buffer
- *
- * @return A byte array containing all the bytes in the buffer
- */
- public byte[] toArray(){
- return bb.array();
- }
-
- /**
- * Skip bytes amount of bytes in the buffer (equivalent to setPosition(getPosition() + len))
- *
- * @param bytes The amount of bytes to skip in the buffer
- */
- public void skip(int bytes){
- setPosition(getPosition() + bytes);
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/network/pipeline/packet/RawPacket.java b/src/main/java/org/blockserver/core/modules/network/pipeline/packet/RawPacket.java
deleted file mode 100644
index f1cce67..0000000
--- a/src/main/java/org/blockserver/core/modules/network/pipeline/packet/RawPacket.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.network.pipeline.packet;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.event.CancellableImplementation;
-
-import java.net.InetSocketAddress;
-
-/**
- * Represents a packet recieved or ready to be sent in byte form.
- *
- * @author BlockServer Team
- */
-public class RawPacket implements CancellableImplementation {
- @Getter @Setter private BinaryBuffer buffer;
- @Getter @Setter private InetSocketAddress address;
-
- public RawPacket(BinaryBuffer buffer, InetSocketAddress address) {
- this.buffer = buffer;
- this.address = address;
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/player/Player.java b/src/main/java/org/blockserver/core/modules/player/Player.java
deleted file mode 100644
index b6d6a74..0000000
--- a/src/main/java/org/blockserver/core/modules/player/Player.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.player;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.Server;
-import org.blockserver.core.modules.message.Message;
-import org.blockserver.core.modules.world.positions.Location;
-
-import java.net.InetSocketAddress;
-import java.util.UUID;
-
-/**
- * Represents a Player on the server.
- *
- * @author BlockServer Team
- */
-public class Player {
- @Getter private final Server server;
- @Getter private final InetSocketAddress address;
- @Getter private final String name;
- @Getter private final UUID UUID;
- @Getter @Setter private int x;
- @Getter @Setter private int y;
- @Getter @Setter private int z;
-
- public Player(Server server, InetSocketAddress address, String name, UUID UUID) {
- this.server = server;
- this.address = address;
- this.name = name;
- this.UUID = UUID;
- }
-
- public Location getLocation() {
- return new Location(x, y, z);
- }
-
- public void sendMessage(Message message) {
-
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/player/PlayerModule.java b/src/main/java/org/blockserver/core/modules/player/PlayerModule.java
deleted file mode 100644
index 671656c..0000000
--- a/src/main/java/org/blockserver/core/modules/player/PlayerModule.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.player;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-import org.blockserver.core.modules.logging.LoggingModule;
-import org.blockserver.core.modules.network.pipeline.PipelineProviderImplementation;
-
-import java.net.InetSocketAddress;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.UUID;
-
-/**
- * Module that handles players.
- *
- * @author BlockServer Team
- * @see org.blockserver.core.module.Module
- */
-public class PlayerModule extends ServerModule {
- private final Set players = Collections.synchronizedSet(new HashSet<>());
-
- public PlayerModule(Server server) {
- super(server);
- }
-
- @Override
- public void enable() {
- super.enable();
- }
-
- @Override
- public void disable() {
- players.clear();
- super.disable();
- }
-
- /**
- * Attempts to find a current online {@linkplain Player} with the specified name. If
- * there is no {@linkplain Player} found this method will return null.
- *
- * @param name ({@linkplain String}): The name of the {@linkplain Player} to locate.
- * @return player - ({@linkplain Player}): The {@linkplain Player} with the given name or null.
- */
- public Player getPlayer(String name) {
- for (Player player : players) {
- if (player.getName().equals(name))
- return player;
- }
- return null;
- }
-
- /**
- * Attempts to find a current online {@linkplain Player} with the specified {@linkplain UUID}. If
- * there is no {@linkplain Player} found this method will return null.
- *
- * @param name ({@linkplain UUID}): The {@linkplain UUID} of the {@linkplain Player} to locate.
- * @return player - ({@linkplain Player}): The {@linkplain Player} with the given {@linkplain UUID} or null.
- */
- public Player getPlayer(UUID name) {
- for (Player player : players) {
- if (player.getUUID().equals(name))
- return player;
- }
- return null;
- }
-
- /**
- * Attempts to find a current online {@linkplain Player} with the specified {@linkplain InetSocketAddress}. If
- * there is no {@linkplain Player} found this method will return null.
- *
- * @param address ({@linkplain InetSocketAddress}): The {@linkplain InetSocketAddress} of the {@linkplain Player} to locate.
- * @return player - ({@linkplain Player}): The {@linkplain Player} with the given {@linkplain InetSocketAddress} or null.
- */
- public Player getPlayer(InetSocketAddress address) {
- for (Player player : players) {
- if (player.getAddress().equals(address))
- return player;
- }
- return null;
- }
-
-
- /**
- * Opens a new session, and adds the specified {@linkplain Player} to the list of online {@linkplain Player}s.
- *
- * NOTE: THIS METHOD IS FOR INTERNAL USE ONLY!
- *
- * @param address ({@linkplain InetSocketAddress}): The new {@linkplain Player}'s {@linkplain InetSocketAddress}.
- * @param name ({@linkplain String}): The new {@linkplain Player}'s {@linkplain String}.
- * @param UUID ({@linkplain UUID}): The new {@linkplain Player}'s {@linkplain UUID}.
- * @param provider {{@linkplain PipelineProviderImplementation}}: The {@linkplain Player}'s {@linkplain PipelineProviderImplementation} that is used
- * to communicate with the client.
- */
- public void internalOpenSession(InetSocketAddress address, String name, UUID UUID, PipelineProviderImplementation provider) {
- players.add(new Player(getServer(), address, name, UUID/*, provider*/));
- getServer().getModule(LoggingModule.class).debug("New session from " + address.getHostString() + ":" + address.getPort());
- }
-
- /**
- * Removes a Player from the list of online players.
- *
- * NOTE: THIS METHOD IS FOR INTERNAL USE ONLY!
- *
- * @param player The player to be removed.
- */
- public void internalCloseSession(Player player) {
- players.remove(player);
- getServer().getModule(LoggingModule.class).debug("Session " + player.getAddress().getHostString() + ":" + player.getAddress().getPort() + " closed.");
- }
-
- public Set getPlayers() {
- return Collections.unmodifiableSet(players);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/scheduler/SchedulerModule.java b/src/main/java/org/blockserver/core/modules/scheduler/SchedulerModule.java
deleted file mode 100644
index e308006..0000000
--- a/src/main/java/org/blockserver/core/modules/scheduler/SchedulerModule.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.scheduler;
-
-import lombok.Getter;
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-import org.blockserver.core.modules.thread.ExecutorModule;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see ServerModule
- */
-public class SchedulerModule extends ServerModule {
- @Getter private final Map tasks = new HashMap<>();
- private final ExecutorModule executorModule;
-
- public SchedulerModule(Server server, ExecutorModule executorModule) {
- super(server);
- this.executorModule = executorModule;
- }
-
- //TODO maybe make this better!
- @Override
- public void enable() {
- executorModule.getExecutorService().execute(() -> {
- while (isEnabled()) {
- for (Map.Entry entry : tasks.entrySet()) {
- TaskData taskData = entry.getValue();
- if (taskData.getNextTickTime() > System.currentTimeMillis())
- continue;
- taskData.repeatTimes--;
- //So by doing this every task will be run at the same time... not in series... is that ok?
- executorModule.getExecutorService().execute(() -> entry.getKey().run());
- //
- if (taskData.getRepeatTimes() <= 0)
- tasks.remove(entry.getKey());
- taskData.setLastTickTime(System.currentTimeMillis());
- }
- try {
- Thread.sleep(1L);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- });
- super.enable();
- }
-
- @Override
- public void disable() {
- tasks.clear();
- super.disable();
- }
-
- public void registerTask(Runnable task, double delay) {
- registerTask(task, delay, 1);
- }
-
- public void registerTask(Runnable task, int repeatTimes) {
- registerTask(task, 1, repeatTimes);
- }
-
- public void registerTask(Runnable task, double delay, int repeatTimes) {
- registerTask(task, new TaskData(delay, repeatTimes));
- }
-
- public void registerTask(Runnable task, TaskData taskData) {
- synchronized (tasks) {
- tasks.put(task, taskData);
- }
- }
-
- public TaskData getTaskData(Runnable task) {
- synchronized (tasks) {
- return tasks.get(task);
- }
- }
-
- public void setTaskData(Runnable task, TaskData taskData) {
- synchronized (tasks) {
- tasks.put(task, taskData);
- }
- }
-
- public void setTaskDelay(Runnable task, double delay) {
- getTaskData(task).setDelay(delay);
- }
-
- public void setTaskRepeatTimes(Runnable task, int repeatTimes) {
- getTaskData(task).setRepeatTimes(repeatTimes);
- }
-
- public double getTaskDelay(Runnable task) {
- return getTaskData(task).getDelay();
- }
-
- public int getTaskRepeatTimes(Runnable task) {
- return getTaskData(task).getRepeatTimes();
- }
-
- public void cancelTask(Runnable task) {
- synchronized (tasks) {
- tasks.remove(task);
- }
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/scheduler/TaskData.java b/src/main/java/org/blockserver/core/modules/scheduler/TaskData.java
deleted file mode 100644
index 55e20ff..0000000
--- a/src/main/java/org/blockserver/core/modules/scheduler/TaskData.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.scheduler;
-
-import lombok.Getter;
-import lombok.Setter;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see SchedulerModule
- */
-public class TaskData {
- @Getter @Setter protected long lastTickTime;
- @Getter @Setter protected double delay;
- @Getter @Setter protected int repeatTimes;
-
- public TaskData(double delay, int repeatTimes) {
- this.delay = delay;
- this.repeatTimes = repeatTimes;
- }
-
- public long getNextTickTime() {
- return lastTickTime + (long) delay;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/serverlist/ServerListModule.java b/src/main/java/org/blockserver/core/modules/serverlist/ServerListModule.java
deleted file mode 100644
index 7e5f8cc..0000000
--- a/src/main/java/org/blockserver/core/modules/serverlist/ServerListModule.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.serverlist;
-
-import lombok.Getter;
-import org.blockserver.core.Server;
-import org.blockserver.core.event.ServerEventListener;
-import org.blockserver.core.events.packets.PacketEvent;
-import org.blockserver.core.module.ServerModule;
-import org.blockserver.core.modules.scheduler.SchedulerModule;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see ServerModule
- */
-public class ServerListModule extends ServerModule {
- private final SchedulerModule schedulerModule;
- @Getter private final Runnable task;
- private final ServerEventListener listener;
-
- public ServerListModule(Server server, SchedulerModule schedulerModule) {
- super(server);
- this.schedulerModule = schedulerModule;
- task = () -> {
- //networkModule.sendPackets();
- //send things
- };
- listener = new ServerEventListener() {
- @Override
- public void onEvent(PacketEvent event) {
- //receive pings
- //send pongs
- }
- };
- }
-
- @Override
- public void enable() {
- schedulerModule.registerTask(task, 1.0, Integer.MAX_VALUE);
- listener.register(PacketEvent.class, getServer());
- super.enable();
- }
-
- @Override
- public void disable() {
- schedulerModule.cancelTask(task);
- listener.unregister(getServer());
- super.disable();
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/thread/ExecutorModule.java b/src/main/java/org/blockserver/core/modules/thread/ExecutorModule.java
deleted file mode 100644
index d1b5f69..0000000
--- a/src/main/java/org/blockserver/core/modules/thread/ExecutorModule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.blockserver.core.modules.thread;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-import org.blockserver.core.modules.config.ConfigModule;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * Created by Exerosis.
- */
-public class ExecutorModule extends ServerModule {
- private final ConfigModule configModule;
- @Getter @Setter private ExecutorService executorService = Executors.newFixedThreadPool(4);
-
- public ExecutorModule(Server server, ConfigModule configModule) {
- super(server);
- this.configModule = configModule;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/world/Block.java b/src/main/java/org/blockserver/core/modules/world/Block.java
deleted file mode 100644
index 76e10db..0000000
--- a/src/main/java/org/blockserver/core/modules/world/Block.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world;
-
-import lombok.Getter;
-import org.blockserver.core.modules.world.positions.Vector;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see WorldModule
- */
-public class Block {
- @Getter private ChunkPosition chunk;
- @Getter private Material material;
- @Getter private byte lightLevel;
- @Getter private Vector vector;
-
- /**
- * Sets lightlevel between 0 and 15.
- *
- * @param lightLevel block lightlevel
- */
- public void setLightLevel(byte lightLevel) {
- this.lightLevel = lightLevel;
- }
-
- /**
- * Sets block material.
- *
- * @param material block material
- * @see Material
- */
- public void setMaterial(Material material) {
- this.material = material;
- /*
- for (Player player : world.getPlayers()) {
- player.sendMessage(new MessageOutBlockChange(player, this)); //TODO: Material
- }
- */
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/world/ChunkPosition.java b/src/main/java/org/blockserver/core/modules/world/ChunkPosition.java
deleted file mode 100644
index ac1d9d4..0000000
--- a/src/main/java/org/blockserver/core/modules/world/ChunkPosition.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see WorldModule
- */
-public class ChunkPosition {
- public Block getBlockAt(int x, int y, int z) {
- return null;
- }
-
- public int getChunkID() {
- throw new UnsupportedOperationException();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/world/ChunkProvider.java b/src/main/java/org/blockserver/core/modules/world/ChunkProvider.java
deleted file mode 100644
index cf82d3c..0000000
--- a/src/main/java/org/blockserver/core/modules/world/ChunkProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see WorldModule
- */
-public interface ChunkProvider {
- ChunkPosition loadChunkAt(int x, int y);
-
- void unloadChunkAt(int x, int y);
-
- void unloadChunk(ChunkPosition chunk);
-
- ChunkPosition getOrLoadChunkAt(int x, int y);
-
- boolean isChunkLoaded(int x, int y);
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/world/Material.java b/src/main/java/org/blockserver/core/modules/world/Material.java
deleted file mode 100644
index 260ed2b..0000000
--- a/src/main/java/org/blockserver/core/modules/world/Material.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see WorldServerModule
- */
-public enum Material {
-}
diff --git a/src/main/java/org/blockserver/core/modules/world/World.java b/src/main/java/org/blockserver/core/modules/world/World.java
deleted file mode 100644
index 739ed36..0000000
--- a/src/main/java/org/blockserver/core/modules/world/World.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world;
-
-import org.blockserver.core.utilities.ByteUtil;
-
-public class World {
- private ChunkPosition[][] loadedChunks;
- private WorldAllocation worldAllocation;
-
- public World(short allocationSize) {
- worldAllocation = new WorldAllocation(allocationSize);
- }
-
- public void saveChunk(int x, int y) {
-
- }
-
- public short[][][] getChunk(int x, int y) {
- return worldAllocation.getChunkAt(loadedChunks[x][y].getChunkID());
- }
-
- public short getBlock(int x, int y, int z) {
- short[][][] chunk = getChunk(x / 16, y / 16);
- return chunk[x % 16][y % 16][z];
- }
-
- public byte getBlockMaterial(int x, int y, int z) {
- return ByteUtil.fromShort(getBlock(x, y, z))[0];
- }
-
- public byte getBlockLightLevel(int x, int y, int z) {
- return ByteUtil.fromShort(getBlock(x, y, z))[1];
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/world/WorldAllocation.java b/src/main/java/org/blockserver/core/modules/world/WorldAllocation.java
deleted file mode 100644
index 834334c..0000000
--- a/src/main/java/org/blockserver/core/modules/world/WorldAllocation.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see WorldAllocation
- */
-public class WorldAllocation {
- private short[][][][] memoryAllocation;
-
- public WorldAllocation(short allocationSize) {
- int chunkCount = allocationSize / 131072 - allocationSize % 131072;
- memoryAllocation = new short[chunkCount][16][16][256];
-
- for (int i = 0; i < memoryAllocation.length; i++) {
- memoryAllocation[i] = null;
- }
- }
-
- public void setChunkAt(int id, short[][][] chunkData) {
- memoryAllocation[id] = chunkData;
- }
-
- public short[][][] getChunkAt(int id) {
- return memoryAllocation[id];
- }
-}
diff --git a/src/main/java/org/blockserver/core/modules/world/WorldModule.java b/src/main/java/org/blockserver/core/modules/world/WorldModule.java
deleted file mode 100644
index f448a9a..0000000
--- a/src/main/java/org/blockserver/core/modules/world/WorldModule.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world;
-
-import org.blockserver.core.Server;
-import org.blockserver.core.module.ServerModule;
-
-/**
- * Created by Exerosis.
- */
-public class WorldModule extends ServerModule {
-
- public WorldModule(Server server) {
- super(server);
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/world/positions/Location.java b/src/main/java/org/blockserver/core/modules/world/positions/Location.java
deleted file mode 100644
index 42a8551..0000000
--- a/src/main/java/org/blockserver/core/modules/world/positions/Location.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world.positions;
-
-import lombok.Getter;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see org.blockserver.core.modules.world.positions.Vector
- * @see org.blockserver.core.modules.world.WorldModule
- */
-public class Location extends Vector {
- @Getter long yaw;
- @Getter long pitch;
-
- public Location(Vector vector) {
- super(vector);
- }
-
- public Location(Location location) {
- this(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
- }
-
- public Location(float x, float y, float z) {
- super(x, y, z);
- }
-
- public Location(float x, float y, float z, long yaw, long pitch) {
- this(x, y, z);
- this.yaw = yaw;
- this.pitch = pitch;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/modules/world/positions/Vector.java b/src/main/java/org/blockserver/core/modules/world/positions/Vector.java
deleted file mode 100644
index d668fad..0000000
--- a/src/main/java/org/blockserver/core/modules/world/positions/Vector.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.modules.world.positions;
-
-import lombok.Getter;
-
-/**
- * Written by Exerosis!
- *
- * @author BlockServer Team
- * @see org.blockserver.core.modules.world.WorldModule
- */
-public class Vector {
- @Getter float x;
- @Getter float y;
- @Getter float z;
-
- public Vector(Vector vector) {
- this(vector.getX(), vector.getY(), vector.getZ());
- }
-
- public Vector(float x, float y, float z) {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/run.java b/src/main/java/org/blockserver/core/run.java
deleted file mode 100644
index 6a320e4..0000000
--- a/src/main/java/org/blockserver/core/run.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core;
-
-import org.blockserver.core.event.EventListener;
-import org.blockserver.core.events.modules.ModuleEnableEvent;
-import org.blockserver.core.module.loaders.CoreModuleLoader;
-import org.blockserver.core.module.loaders.JarModuleLoader;
-import org.blockserver.core.modules.logging.LoggingModule;
-
-/**
- * Main class for the core.
- *
- * @author BlockServer team
- */
-public class run {
-
- public static void main(String[] args) {
- Server server = new Server(new CoreModuleLoader(), new JarModuleLoader());
-
- new EventListener() {
- @Override
- public void onEvent(ModuleEnableEvent event) {
- System.out.println(event.getModule().getClass().getName());
- }
- }.register(ModuleEnableEvent.class, server.getEventManager());
-
- Runtime.getRuntime().addShutdownHook(new Thread(server::disable));
- server.enable();
- server.getModule(LoggingModule.class).info("BlockServer is now running.");
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/utilities/ArchiveUtils.java b/src/main/java/org/blockserver/core/utilities/ArchiveUtils.java
deleted file mode 100644
index 26e0d19..0000000
--- a/src/main/java/org/blockserver/core/utilities/ArchiveUtils.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.utilities;
-
-import java.io.*;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-public class ArchiveUtils {
- //TODO Make this whole thing not suck
- private ArchiveUtils() {
- }
-
- public static void downloadFileInto(CharSequence stringURL, File directory) {
- try {
- URL url = new URL(stringURL.toString());
- unzipIntoDirectory(url.openStream(), directory);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public static File downloadFile(CharSequence stringURL, File directory) {
- try {
- if (directory.isFile()) {
- return null;
- }
- directory.mkdirs();
- URL url = new URL(stringURL.toString());
- String urlPath = url.getPath();
- String fileName = urlPath.substring(urlPath.lastIndexOf('/') + 1);
-
- String[] fileComponents = fileName.split("\\.");
-
- String extension = "";
- if (fileComponents.length >= 2)
- extension = fileComponents[1];
-
- if (!extension.equals("zip"))
- Files.copy(url.openStream(), Paths.get(directory.getPath() + extension), StandardCopyOption.REPLACE_EXISTING);
- else
- unzipIntoDirectory(url.openStream(), directory);
- return directory;
- } catch (Exception ignored) {
- }
- return null;
- }
-
- public static void copyFile(File from, File into) {
- if (!from.exists())
- return;
- if (from.getPath().equals(into.getPath()))
- return;
- from.setReadable(true);
- if (into.exists())
- into.delete();
- try {
- ByteUtil.writeBuffer(into, new FileInputStream(from), true);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- public static void unzipIntoDirectory(File file, File directory) {
- try {
- unzipIntoDirectory(new FileInputStream(file), directory);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- public static void unzipIntoDirectory(InputStream inputStream, File directory) {
- if (directory.isFile())
- return;
- directory.mkdirs();
-
- try {
- inputStream = new BufferedInputStream(inputStream);
- inputStream = new ZipInputStream(inputStream);
-
- for (ZipEntry entry = null; (entry = ((ZipInputStream) inputStream).getNextEntry()) != null; ) {
- StringBuilder pathBuilder = new StringBuilder(directory.getPath()).append('/').append(entry.getName());
- File file = new File(pathBuilder.toString());
-
- if (entry.isDirectory()) {
- file.mkdirs();
- continue;
- }
-
- ByteUtil.write(pathBuilder, inputStream, false);
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- ByteUtil.closeQuietly(inputStream);
- }
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/utilities/ByteUtil.java b/src/main/java/org/blockserver/core/utilities/ByteUtil.java
deleted file mode 100644
index 7bed872..0000000
--- a/src/main/java/org/blockserver/core/utilities/ByteUtil.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.utilities;
-
-import java.io.*;
-
-public class ByteUtil {
-
- private ByteUtil() {
- }
-
- public static short toShort(byte... bytes) {
- return (short) ((bytes[0] << 8) + bytes[1]);
- }
-
- public static byte[] fromShort(short number) {
- return new byte[]{(byte) (number >> 8), (byte) (number & 255)};
- }
-
- public static void write(CharSequence path, InputStream stream, boolean close) {
- write(new File(path.toString()), stream, close);
- }
-
- public static void write(File file, InputStream stream, boolean close) {
- file.getParentFile().mkdirs();
- if (file.exists())
- file.delete();
-
- OutputStream fileOutputStream = null;
- try {
- fileOutputStream = new FileOutputStream(file);
- fileOutputStream = new BufferedOutputStream(fileOutputStream);
- // IOUtils.copy(stream, fileOutputStream);
-
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- ByteUtil.closeQuietly(fileOutputStream);
- if (close)
- ByteUtil.closeQuietly(stream);
- }
- }
-
- public static void writeBuffer(File file, InputStream inputStream, boolean close) {
- OutputStream outputStream = null;
- try {
- inputStream = new BufferedInputStream(inputStream);
-
- outputStream = new FileOutputStream(file);
- outputStream = new BufferedOutputStream(outputStream);
-
- //IOUtils.copy(inputStream, outputStream);
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- ByteUtil.closeQuietly(outputStream);
- if (close)
- ByteUtil.closeQuietly(inputStream);
- }
- }
-
- public static void closeQuietly(Closeable closeable) {
- if (closeable != null)
- try {
- if (closeable.getClass().isAssignableFrom(OutputStream.class))
- ((OutputStream) closeable).flush();
- closeable.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Gets bytes from InputStream
- *
- * @param stream The InputStream
- * @return Returns a byte[] representation of given stream
- */
-
- public static byte[] getBytesFromIS(InputStream stream) {
-
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- try {
- int nRead;
- byte[] data = new byte[16384];
-
- while ((nRead = stream.read(data, 0, data.length)) != -1) {
- buffer.write(data, 0, nRead);
- }
-
- buffer.flush();
- } catch (Exception e) {
- System.err.println("Failed to convert IS to byte[]!");
- e.printStackTrace();
- }
-
- return buffer.toByteArray();
-
- }
-
- /**
- * Gets bytes from class
- *
- * @param clazz The class
- * @return Returns a byte[] representation of given class
- */
-
- public static byte[] getBytesFromClass(Class> clazz) {
- return getBytesFromIS(clazz.getClassLoader().getResourceAsStream(clazz.getName().replace('.', '/') + ".class"));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/core/utilities/FileUtil.java b/src/main/java/org/blockserver/core/utilities/FileUtil.java
deleted file mode 100644
index 260c09d..0000000
--- a/src/main/java/org/blockserver/core/utilities/FileUtil.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.utilities;
-
-import java.io.File;
-
-public class FileUtil {
- public static File getDirectoryUp(File file, int amount) {
- while (amount != 0) {
- file = file.getParentFile();
- amount--;
- }
- return file;
- }
-
- public static File searchFolder(File folder, String uniqueContent) {
- return searchFolder(folder, uniqueContent, 0);
- }
-
- private static File searchFolder(File folder, String uniqueContent, int depth) {
- if (folder != null)
- for (File file : folder.listFiles()) {
- if (file.getName().contains(uniqueContent))
- return file.getParentFile();
- if (file.isDirectory()) {
- File result = searchFolder(file, uniqueContent, depth++);
- if (result != null)
- return getDirectoryUp(result, depth - 1);
- }
- }
- return null;
- }
-
-
-}
diff --git a/src/main/java/org/blockserver/core/utilities/NetworkUtil.java b/src/main/java/org/blockserver/core/utilities/NetworkUtil.java
deleted file mode 100644
index 99b5e29..0000000
--- a/src/main/java/org/blockserver/core/utilities/NetworkUtil.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.utilities;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-
-public final class NetworkUtil {
- private NetworkUtil() {
-
- }
-
- public static InetAddress getLocalHost() {
- try {
- return InetAddress.getLocalHost();
- } catch (UnknownHostException e) {
- e.printStackTrace();
- }
- return null;
- }
-}
diff --git a/src/main/java/org/blockserver/core/utilities/Skin.java b/src/main/java/org/blockserver/core/utilities/Skin.java
deleted file mode 100644
index fb443b7..0000000
--- a/src/main/java/org/blockserver/core/utilities/Skin.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * This file is part of BlockServer.
- *
- * BlockServer is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * BlockServer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with BlockServer. If not, see .
- */
-package org.blockserver.core.utilities;
-
-/**
- * Utility class that represents a Skin.
- */
-public class Skin {
- public byte[] bytes;
- public String skinName;
-}
diff --git a/src/main/java/org/blockserver/server/core/Player.java b/src/main/java/org/blockserver/server/core/Player.java
new file mode 100644
index 0000000..1eb9776
--- /dev/null
+++ b/src/main/java/org/blockserver/server/core/Player.java
@@ -0,0 +1,9 @@
+package org.blockserver.server.core;
+
+/**
+ * Represents a Player on the server.
+ *
+ * @author BlockServer Team
+ */
+public class Player {
+}
diff --git a/src/main/java/org/blockserver/server/core/Server.java b/src/main/java/org/blockserver/server/core/Server.java
new file mode 100644
index 0000000..271f509
--- /dev/null
+++ b/src/main/java/org/blockserver/server/core/Server.java
@@ -0,0 +1,138 @@
+package org.blockserver.server.core;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.blockserver.server.core.module.ModuleLoader;
+import org.blockserver.server.core.util.Task;
+import org.slf4j.Logger;
+
+import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The main server implementation.
+ *
+ * @author BlockServer Team
+ */
+public class Server implements Runnable {
+ public static final String SOFTWARE = "BlockServer";
+ public static final String SOFTWARE_VERSION = "1.0-SNAPSHOT";
+
+ @Getter private InetSocketAddress bindAddress;
+
+ @Getter private final Logger logger;
+ @Getter private final List loaders;
+
+ @Setter
+ @Getter private boolean running = false;
+
+ private long currentTick = 0;
+ private long currentTaskId = 0;
+ private final List players = new ArrayList<>();
+ private final List tasks = new ArrayList<>();
+
+ public Server(InetSocketAddress bindAddress, Logger logger, List loaders) {
+ this.logger = logger;
+ this.bindAddress = bindAddress;
+ this.loaders = loaders;
+ }
+
+ private void loadModules() {
+
+ }
+
+ @Override
+ public void run() {
+ if(!running) return;
+ logger.info("This server is running "+Server.SOFTWARE+" "+Server.SOFTWARE_VERSION+" on "+System.getProperty("os.name")+" "+System.getProperty("os.version"));
+
+ loadModules();
+
+ boolean exception = false;
+ while(isRunning()) { // Begin ticking
+ long start = System.currentTimeMillis();
+ try {
+ tick();
+ } catch (Exception e) {
+ logger.error("FATAL! "+e.getClass().getName()+" while ticking! "+e.getMessage());
+ e.printStackTrace();
+ exception = true;
+ }
+ long elapsed = System.currentTimeMillis() - start;
+ if(elapsed > 50) { // 20 TPS
+ logger.warn("Can't keep up! ("+elapsed+">50) Did the system time change or is the server overloaded?");
+ } else {
+ try {
+ Thread.sleep(50 - elapsed);
+ } catch (InterruptedException e) {
+ logger.error("FATAL! failed to sleep while ticking! java.lang.InterruptedException: "+e.getMessage());
+ e.printStackTrace();
+ exception = true;
+ }
+ }
+ }
+
+ logger.info("Stopping server...");
+ logger.info("Halting...");
+ System.exit(exception ? 1 : 0);
+ }
+
+ /**
+ * Add a task to run in a certain amount of ticks
+ * @param ticks Amount of ticks to pass before the task runs.
+ * @param r The Runnable to be ran.
+ * @return The task that was added.
+ */
+ public synchronized Task addTask(long ticks, Runnable r) {
+ return addTask(ticks, r, currentTaskId++, false, 0);
+ }
+
+ private Task addTask(long ticks, Runnable r, long taskId, boolean repeat, long interval) {
+ synchronized (this.tasks) {
+ Task t = new Task();
+ t.taskId = taskId;
+ t.runAt = this.currentTick + ticks;
+ t.r = r;
+ t.repeat = repeat;
+ t.interval = interval;
+ this.tasks.add(t);
+ return t;
+ }
+ }
+
+ /**
+ * Add a task to repeatably run based on an interval of ticks.
+ * @param interval The amount of ticks to pass between runs.
+ * @param r The Runnable to be ran.
+ * @return The task that was added.
+ */
+ public synchronized Task addRepeatingTask(long interval, Runnable r) {
+ return addTask(1, r, currentTaskId++, true, interval);
+ }
+
+ public synchronized void cancelTask(long taskId) {
+ final Task[] t = new Task[1];
+ synchronized (this.tasks) {
+ this.tasks.stream().filter(task -> task.taskId == taskId).forEach(task1 -> t[0] = task1);
+ this.tasks.remove(t[0]);
+ }
+ }
+
+ private void tick() throws Exception {
+ if(this.tasks.isEmpty()) return;
+ List toRemove = new ArrayList<>();
+ synchronized (this.tasks) {
+ this.tasks.stream().forEach(task -> {
+ if (this.currentTick == task.runAt) {
+ task.r.run();
+ if(task.repeat) {
+ task.runAt = this.currentTick + task.interval;
+ } else toRemove.add(task);
+ }
+ });
+ this.tasks.removeAll(toRemove);
+ }
+ currentTick++;
+ }
+}
diff --git a/src/main/java/org/blockserver/server/core/module/Module.java b/src/main/java/org/blockserver/server/core/module/Module.java
new file mode 100644
index 0000000..47c49bf
--- /dev/null
+++ b/src/main/java/org/blockserver/server/core/module/Module.java
@@ -0,0 +1,24 @@
+package org.blockserver.server.core.module;
+
+import lombok.Getter;
+import org.blockserver.server.core.Server;
+
+/**
+ * Represents an extension that adds features
+ * to the Server
+ *
+ * @author BlockServer Team
+ */
+public abstract class Module {
+ @Getter private Server server;
+
+ public final void init(Server server) {
+ this.server = server;
+ }
+
+ public abstract void register();
+
+ public void cleanup() {
+
+ }
+}
diff --git a/src/main/java/org/blockserver/server/core/module/ModuleLoader.java b/src/main/java/org/blockserver/server/core/module/ModuleLoader.java
new file mode 100644
index 0000000..f4c443e
--- /dev/null
+++ b/src/main/java/org/blockserver/server/core/module/ModuleLoader.java
@@ -0,0 +1,23 @@
+package org.blockserver.server.core.module;
+
+import org.blockserver.server.core.Server;
+
+import java.util.List;
+
+/**
+ * Represents a Loader capable of loading
+ * external Modules.
+ *
+ * @author BlockServer Team
+ */
+public interface ModuleLoader {
+ /**
+ * Loads a module(s) using the supplied params.
+ *
+ * The Loader MUST call Module.init
+ * @param server The Server this loader belongs to.
+ * @param params Parameters that may or may not be required by the loader.
+ * @return A List of modules that have been loaded.
+ */
+ List loadModules(Server server, Object... params);
+}
diff --git a/src/main/java/org/blockserver/server/core/run.java b/src/main/java/org/blockserver/server/core/run.java
new file mode 100644
index 0000000..14d4b7d
--- /dev/null
+++ b/src/main/java/org/blockserver/server/core/run.java
@@ -0,0 +1,29 @@
+package org.blockserver.server.core;
+
+import java.net.InetSocketAddress;
+import java.util.Arrays;
+
+import org.blockserver.server.core.services.module.ModuleService;
+import org.blockserver.server.pocket.PocketModule;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.impl.SimpleLogger;
+
+/**
+ * Main run class for BlockServer
+ */
+public class run {
+ public static void main(String[] args) {
+ System.setProperty(SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "DEBUG");
+ Logger logger = LoggerFactory.getLogger("BlockServer");
+
+ Server server = new Server(new InetSocketAddress("0.0.0.0", 19132), logger);
+ server.getServiceManager().getService(ModuleService.class).registerLoader((service, params) -> {
+ PocketModule m = new PocketModule();
+ m.init(server);
+ return Arrays.asList(m);
+ });
+ server.setRunning(true);
+ server.run();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/blockserver/server/core/util/MiscUtils.java b/src/main/java/org/blockserver/server/core/util/MiscUtils.java
new file mode 100644
index 0000000..4f99c3c
--- /dev/null
+++ b/src/main/java/org/blockserver/server/core/util/MiscUtils.java
@@ -0,0 +1,16 @@
+package org.blockserver.server.core.util;
+
+/**
+ * Misc utility class
+ *
+ * @author BlockServer Team
+ */
+public abstract class MiscUtils {
+ public static String bytesToHexString(byte[] bytes) {
+ StringBuilder sb = new StringBuilder();
+ for(byte b : bytes) {
+ sb.append(String.format("%02X", b)).append(" ");
+ }
+ return sb.toString();
+ }
+}
diff --git a/src/main/java/org/blockserver/server/core/util/Task.java b/src/main/java/org/blockserver/server/core/util/Task.java
new file mode 100644
index 0000000..4bf6e0e
--- /dev/null
+++ b/src/main/java/org/blockserver/server/core/util/Task.java
@@ -0,0 +1,12 @@
+package org.blockserver.server.core.util;
+
+/**
+ * Utility class: represents a task that can be ran at a certain time.
+ */
+public class Task {
+ public long taskId;
+ public boolean repeat;
+ public long interval;
+ public Runnable r;
+ public long runAt;
+}