Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMicky-FR committed Nov 17, 2019
0 parents commit 92f5237
Show file tree
Hide file tree
Showing 50 changed files with 1,996 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Eclipse
.classpath
.project
.metadata
.settings/

# IntelliJ
.idea/
.idea_modules/
*.iml
*.iws
/out/

# Mac
.DS_Store

# Gradle
.gradle
build/
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sudo: false

language: java
jdk:
- openjdk8
- openjdk11

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

script:
- ./gradlew build
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Azuriom.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# AzLink

AzLink is a plugin to link a Minecraft server or proxy with [Azuriom](https://azuriom.com).

This plugin currently support the following platforms:
* [Bukkit/Spigot](https://www.spigotmc.org/)
* [BungeeCord](https://github.com/SpigotMC/BungeeCord)
* [Sponge](https://www.spongepowered.org/)
* [Velocity](https://www.velocitypowered.com/)

## Setup

### Installation
The plugin works with the same .jar for all the platforms, except Bukkit/Spigot 1.7.10 wich require the legacy version of the plugin.

You just need to download the plugin, add it to the plugins folder of your server, and restart your server.
21 changes: 21 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
allprojects {
group 'com.azuriom'
version '1.0-SNAPSHOT'
}

subprojects {
apply plugin: 'java'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()

maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}

dependencies {
compileOnly 'com.google.code.gson:gson:2.8.5'
}
}
14 changes: 14 additions & 0 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repositories {
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
}

dependencies {
compileOnly 'org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT'
compile project(':azlink-common')
}

processResources {
from(sourceSets.main.resources.srcDirs) {
expand 'pluginVersion': project.version
}
}
108 changes: 108 additions & 0 deletions bukkit/src/main/java/com/azuriom/azlink/bukkit/AzLinkBukkitPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
package com.azuriom.azlink.bukkit;

import com.azuriom.azlink.bukkit.command.BukkitCommandExecutor;
import com.azuriom.azlink.bukkit.command.BukkitCommandSender;
import com.azuriom.azlink.common.AzLinkPlatform;
import com.azuriom.azlink.common.AzLinkPlugin;
import com.azuriom.azlink.common.PlatformType;
import com.azuriom.azlink.common.command.CommandSender;
import com.azuriom.azlink.common.data.WorldData;
import com.azuriom.azlink.common.logger.JulLoggerAdapter;
import com.azuriom.azlink.common.logger.LoggerAdapter;
import org.bukkit.plugin.java.JavaPlugin;

import java.nio.file.Path;
import java.util.Optional;
import java.util.stream.Stream;

public final class AzLinkBukkitPlugin extends JavaPlugin implements AzLinkPlatform {

private final AzLinkPlugin plugin = new AzLinkPlugin(this);

private LoggerAdapter logger;

@Override
public void onEnable() {
logger = new JulLoggerAdapter(getLogger());

plugin.init();

getCommand("azlink").setExecutor(new BukkitCommandExecutor(plugin));
}

@Override
public void onDisable() {
plugin.shutdown();
}

@Override
public AzLinkPlugin getPlugin() {
return plugin;
}

@Override
public LoggerAdapter getLoggerAdapter() {
return logger;
}

@Override
public PlatformType getPlatformType() {
return PlatformType.BUKKIT;
}

@Override
public String getPlatformName() {
return getServer().getName();
}

@Override
public String getPlatformVersion() {
return getServer().getVersion();
}

@Override
public String getPluginVersion() {
return getDescription().getVersion();
}

@Override
public Path getDataDirectory() {
return getDataFolder().toPath();
}

@Override
public Optional<WorldData> getWorldData() {
int loadedChunks = getServer().getWorlds().stream()
.mapToInt(w -> w.getLoadedChunks().length)
.sum();

int entities = getServer().getWorlds().stream().mapToInt(w -> w.getEntities().size()).sum();

return Optional.of(new WorldData(0, loadedChunks, entities));
}

@Override
public Stream<CommandSender> getOnlinePlayers() {
return getServer().getOnlinePlayers().stream().map(BukkitCommandSender::new);
}

@Override
public int getMaxPlayers() {
return getServer().getMaxPlayers();
}

@Override
public void dispatchConsoleCommand(String command) {
getServer().dispatchCommand(getServer().getConsoleSender(), command);
}

@Override
public void executeSync(Runnable runnable) {
getServer().getScheduler().runTask(this, runnable);
}

@Override
public void executeAsync(Runnable runnable) {
getServer().getScheduler().runTaskAsynchronously(this, runnable);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.azuriom.azlink.bukkit.command;

import com.azuriom.azlink.common.AzLinkPlugin;
import com.azuriom.azlink.common.command.AzLinkCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;

import java.util.List;

public class BukkitCommandExecutor extends AzLinkCommand implements TabExecutor {

public BukkitCommandExecutor(AzLinkPlugin plugin) {
super(plugin);
}

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
execute(new BukkitCommandSender(sender), args);

return true;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return tabComplete(new BukkitCommandSender(sender), args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.azuriom.azlink.bukkit.command;

import com.azuriom.azlink.common.command.CommandSender;
import org.bukkit.entity.Entity;

import java.util.UUID;

public class BukkitCommandSender implements CommandSender {

private final org.bukkit.command.CommandSender sender;

public BukkitCommandSender(org.bukkit.command.CommandSender sender) {
this.sender = sender;
}

@Override
public String getName() {
return sender.getName();
}

@Override
public UUID getUuid() {
if (sender instanceof Entity) {
return ((Entity) sender).getUniqueId();
}

return UUID.nameUUIDFromBytes(getName().getBytes());
}

@Override
public void sendMessage(String message) {
sender.sendMessage(message);
}

@Override
public boolean hasPermission(String permission) {
return sender.hasPermission(permission);
}
}
12 changes: 12 additions & 0 deletions bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: AzLink
version: ${pluginVersion}
author: Azuriom Team
description: The plugin to link your Azuriom website with your server.
website: https://azuriom.com
main: com.azuriom.azlink.bukkit.AzLinkBukkitPlugin
api-version: 1.13
commands:
azlink:
description: Manage the AzLink plugin.
usage: /<command> [status|key|url]
aliases: [azuriomlink]
10 changes: 10 additions & 0 deletions bungee/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
dependencies {
compileOnly 'net.md-5:bungeecord-api:1.14-SNAPSHOT'
compile project(':azlink-common')
}

processResources {
from(sourceSets.main.resources.srcDirs) {
expand 'pluginVersion': project.version
}
}
Loading

0 comments on commit 92f5237

Please sign in to comment.