Skip to content

Commit

Permalink
Merge pull request #20 from CaaMoe/Dev
Browse files Browse the repository at this point in the history
提交更新 RC.5
  • Loading branch information
CaaMoe authored Oct 11, 2021
2 parents 7e98069 + 9b0a975 commit b6a83e8
Show file tree
Hide file tree
Showing 58 changed files with 2,023 additions and 214 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
name: Java CI

on:
push: { }
push:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2

- name: 'Setup JDK 8'
uses: AdoptOpenJDK/install-jdk@v1
with:
version: '8'
architecture: x64

- name: 'Setup JDK 11'
uses: AdoptOpenJDK/install-jdk@v1
with:
version: '11'
architecture: x64
targets: 'JDK_11'

- name: Cache Gradle packages
uses: actions/cache@v2
with:
Expand All @@ -21,23 +33,21 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
uses: gradle/gradle-command-action@v1
with:
arguments: shadowJar
gradle-version: 7.2

- name: Cleanup Gradle Cache
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
- name: Package Artifact
run: |
mkdir builds
mv bukkit/build/libs/*.jar builds
mv bungee/build/libs/*.jar builds
- name: Upload to Artifact
uses: actions/upload-artifact@v2
- name: Upload to artifact respectively
uses: MuirProject/upload-artifact@v2-beta
with:
name: Package
path: builds
retention-days: 1
name: '["Bukkit", "Bungee", "Velocity"]'
path: '["bukkit/loader/build/libs/MultiLogin-*.jar", "bungee/loader/build/libs/MultiLogin-*.jar", "velocity/loader/build/libs/MultiLogin-*.jar"]'
retention-days: 1
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,5 +200,16 @@ MultiLogin 的二次验证就是专门来解决这个问题的,它能限制玩
| /whitelist remove <name|uuid> | command.multilogin.whitelist.remove| 移除 target 的白名单|
| /whitelist list | command.multilogin.whitelist.list| 获得白名单列表|

## PlaceholderAPI 变量(Bukkit Only)

| 变量 | 简介 |
| ---- | --- |
| %multilogin_currentname% | 玩家当前的游戏 ID|
| %multilogin_onlineuuid% | 玩家在线的 UUID|
| %multilogin_redirecteduuid% | 玩家在游戏内的 UUID|
| %multilogin_whitelist% | 玩家是否具有白名单|
| %multilogin_yggdrasilname% | 玩家所在的 Yggdrasil 账户验证服务器的名字|
| %multilogin_yggdrasilpath% | 玩家所在的 Yggdrasil 账户验证服务器的路径|

如果你在使用这个插件时有任何的疑问或建议,欢迎加入我们的 QQ
群互相讨论: [![GitHub license](https://img.shields.io/badge/QQ%20group-832210691-yellow?style=flat-square)](https://jq.qq.com/?_wv=1027&k=WrOTGIC7)
18 changes: 6 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,18 @@ allprojects {

subprojects {
repositories {
maven { url "https://maven.aliyun.com/repository/public" }
mavenCentral()
}

dependencies {
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.20'
annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.20'

implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.14.1'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.14.1'
implementation group: 'com.zaxxer', name: 'HikariCP', version: '4.0.3'
implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.25'
implementation group: 'com.h2database', name: 'h2', version: '1.4.200'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.8'
implementation group: 'org.yaml', name: 'snakeyaml', version: '1.29'

}

String env;
String ver;

processResources {
String env;
String ver;
env = System.getProperty("env", "AUTO")
if (env.toLowerCase() == "final") {
ver = (project.plugin_version as String)
Expand All @@ -41,6 +33,8 @@ subprojects {
}

jar {
String env;
String ver;
env = System.getProperty("env", "AUTO")
if (env.toLowerCase() == "final") {
ver = (project.plugin_version as String)
Expand Down
24 changes: 12 additions & 12 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ plugins {
repositories {
maven { url "https://hub.spigotmc.org/nexus/content/groups/public/" }
maven { url "https://repo.codemc.io/repository/nms/" }
maven { url "https://repo.extendedclip.com/content/repositories/placeholderapi/" }
}

dependencies {
compileOnly group: 'com.destroystokyo.paper', name: 'paper', version: '1.16.5-R0.1-SNAPSHOT'
implementation project(":core")
compileOnly project(":bukkit:loader")
compileOnly project(":core:loader")
compileOnly group: 'com.destroystokyo.paper', name: 'paper', version: '1.16.5-R0.1-SNAPSHOT'

// support
compileOnly 'me.clip:placeholderapi:2.10.10'
}

shadowJar {
String env = System.getProperty("env", "AUTO")
archiveBaseName.set('MultiLogin-Bukkit')
if (env.toLowerCase() == "final") {
archiveVersion.set(project.plugin_version as String)
} else {
String ver = "Build_" + ((System.currentTimeMillis() / 1000) as int)
archiveVersion.set(ver)
}
archiveClassifier.set("")

archiveFileName = "MultiLogin-Bukkit.JarFile"

relocate 'com.zaxxer.hikari', 'moe.caa.multilogin.lib.com.zaxxer.hikari'
relocate 'com.mysql', 'moe.caa.multilogin.lib.com.mysql'
relocate 'com.zaxxer.hikari', 'moe.caa.multilogin.lib.com.zaxxer.hikari'
relocate 'com.google.gson', 'moe.caa.multilogin.lib.com.google.gson'
relocate 'com.google.protobuf', 'moe.caa.multilogin.lib.com.google.protobuf'
relocate 'google.protobuf', 'moe.caa.multilogin.lib.google.protobuf'
relocate 'org.yaml.snakeyaml', 'moe.caa.multilogin.lib.org.yaml.snakeyaml'
}

artifacts {
archives shadowJar
}
33 changes: 33 additions & 0 deletions bukkit/loader/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
id 'com.github.johnrengelman.shadow'
}

repositories {
maven { url "https://hub.spigotmc.org/nexus/content/groups/public/" }
maven { url "https://repo.codemc.io/repository/nms/" }
}

dependencies {
implementation project(":core:loader")
compileOnly group: 'com.destroystokyo.paper', name: 'paper', version: '1.16.5-R0.1-SNAPSHOT'
}

shadowJar {
String env = System.getProperty("env", "AUTO")
archiveBaseName.set('MultiLogin-Bukkit')
if (env.toLowerCase() == "final") {
archiveVersion.set(project.plugin_version as String)
} else {
String ver = "Build_" + ((System.currentTimeMillis() / 1000) as int)
archiveVersion.set(ver)
}
archiveClassifier.set("")

from {
project(':bukkit').tasks.shadowJar.archiveFile
}
}

artifacts {
archives shadowJar
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package moe.caa.multilogin.bukkit.loader.main;

import moe.caa.multilogin.core.loader.impl.BasePluginBootstrap;
import moe.caa.multilogin.core.loader.impl.IPluginLoader;
import moe.caa.multilogin.core.loader.main.MultiLoginCoreLoader;
import org.bukkit.Server;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.logging.Level;

/**
* Bukkit 插件引导程序
*/
public class MultiLoginBukkitLoader extends JavaPlugin implements IPluginLoader {
private MultiLoginCoreLoader coreLoader;
private BasePluginBootstrap pluginBootstrap;

@Override
public void onLoad() {
try {
coreLoader = new MultiLoginCoreLoader(this);
if (!coreLoader.start()) {
shutdown();
return;
}

pluginBootstrap = coreLoader.loadBootstrap(
"moe.caa.multilogin.bukkit.main.MultiLoginBukkitPluginBootstrap",
new Class[]{JavaPlugin.class, Server.class}, new Object[]{this, getServer()});
pluginBootstrap.onLoad();
} catch (Throwable throwable) {
loggerLog(Level.SEVERE, "A FATAL ERROR OCCURRED DURING INITIALIZATION.", throwable);
onDisable();
}
}

@Override
public void onEnable() {
if (pluginBootstrap != null) pluginBootstrap.onEnable();
}

@Override
public void onDisable() {
if (pluginBootstrap != null) pluginBootstrap.onDisable();
pluginBootstrap = null;
coreLoader.close();
getServer().shutdown();
}

@Override
public String getSectionJarFileName() {
return "MultiLogin-Bukkit.JarFile";
}

@Override
public void shutdown() {
getServer().shutdown();
}

@Override
public void loggerLog(Level level, String message, Throwable throwable) {
getLogger().log(level, message, throwable);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: MultiLogin
version: @version@
main: moe.caa.multilogin.bukkit.main.MultiLoginBukkit
main: moe.caa.multilogin.bukkit.loader.main.MultiLoginBukkitLoader
author: @author@
api-version: 1.13
softdepend: [ PlaceholderAPI ]
commands:
multilogin:
aliases:
- login
- ml
whitelist:

permissions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,44 @@
import com.mojang.authlib.GameProfile;
import lombok.Getter;
import moe.caa.multilogin.bukkit.impl.BukkitUserLogin;
import moe.caa.multilogin.bukkit.main.MultiLoginBukkit;
import moe.caa.multilogin.bukkit.main.MultiLoginBukkitPluginBootstrap;
import moe.caa.multilogin.core.auth.response.HasJoinedResponse;
import moe.caa.multilogin.core.auth.response.Property;
import moe.caa.multilogin.core.logger.LoggerLevel;
import moe.caa.multilogin.core.logger.MultiLogger;
import moe.caa.multilogin.core.user.User;
import moe.caa.multilogin.core.util.CachedHashSet;

import java.net.InetAddress;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class BukkitAuthCore {
@Getter
private static final CachedHashSet<BukkitUserLogin> loginCachedHashSet = new CachedHashSet<>(10000);

// 这里放置的是正式登入成功后尚未编入系统的用户实例
@Getter
private static final CachedHashSet<User> bufferUsers = new CachedHashSet<>(10000);

@Getter
private static final Set<User> users = new HashSet<>();

@Getter
private static final UUID DIRTY_UUID = UUID.fromString("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF");

public GameProfile doAuth(GameProfile user, String serverId, InetAddress address) {
try {
CountDownLatch latch = new CountDownLatch(1);
BukkitUserLogin login = new BukkitUserLogin(user.getName(), serverId, address == null ? null : address.getHostAddress(), latch);
MultiLoginBukkit.getInstance().getCore().getAuthCore().doAuth(login);
latch.await(MultiLoginBukkit.getInstance().getCore().getConfig().getServicesTimeOut(), TimeUnit.MILLISECONDS);
MultiLoginBukkitPluginBootstrap.getInstance().getCore().getAuthCore().doAuth(login);
latch.await();
loginCachedHashSet.add(login);
if (login.getUser() != null)
bufferUsers.add(login.getUser());
return generate(login.getResponse(), user.getName());
} catch (Exception e) {
MultiLogger.getLogger().log(LoggerLevel.ERROR, "An exception occurred while processing login data.", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package moe.caa.multilogin.bukkit.impl;

import moe.caa.multilogin.bukkit.main.MultiLoginBukkit;
import moe.caa.multilogin.core.impl.BaseScheduler;
import org.bukkit.plugin.java.JavaPlugin;

/**
* Bukkit 端的线程调度器对象
*/
public class BukkitScheduler extends BaseScheduler {
private final org.bukkit.scheduler.BukkitScheduler scheduler;
private final MultiLoginBukkit plugin;
private final JavaPlugin plugin;

public BukkitScheduler(org.bukkit.scheduler.BukkitScheduler scheduler, MultiLoginBukkit plugin) {
public BukkitScheduler(org.bukkit.scheduler.BukkitScheduler scheduler, JavaPlugin plugin) {
this.scheduler = scheduler;
this.plugin = plugin;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package moe.caa.multilogin.bukkit.impl;

import moe.caa.multilogin.bukkit.main.MultiLoginBukkit;
import moe.caa.multilogin.core.impl.BaseScheduler;
import moe.caa.multilogin.core.impl.IPlayerManager;
import moe.caa.multilogin.core.impl.IServer;
import org.bukkit.Server;
import org.bukkit.plugin.java.JavaPlugin;

/**
* Bukkit 端的服务器对象
Expand All @@ -14,7 +14,7 @@ public class BukkitServer implements IServer {
private final IPlayerManager playerManager;
private final BaseScheduler scheduler;

public BukkitServer(Server server, MultiLoginBukkit plugin) {
public BukkitServer(Server server, JavaPlugin plugin) {
this.server = server;
this.playerManager = new BukkitPlayerManager(server);
this.scheduler = new BukkitScheduler(server.getScheduler(), plugin);
Expand Down
Loading

0 comments on commit b6a83e8

Please sign in to comment.