geforkt von SteamWar/BungeeCore
Commits vergleichen
4 Commits
master
...
TeamComman
Autor | SHA1 | Datum | |
---|---|---|---|
![]() |
c7937847bc | ||
![]() |
18a16e91b0 | ||
![]() |
9628ff8ac7 | ||
![]() |
e1a713d52f |
@ -1 +1 @@
|
|||||||
Subproject commit 20c22c47f940c4510de17594b28eb0a96cb9da0c
|
Subproject commit 1dea71993d897354d3f52a705f6e0e1e0c8ec580
|
224
build.gradle
224
build.gradle
@ -17,6 +17,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.tools.ant.taskdefs.condition.Os
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
|
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
|
||||||
//
|
//
|
||||||
@ -29,19 +33,36 @@ plugins {
|
|||||||
id 'java'
|
id 'java'
|
||||||
id 'application'
|
id 'application'
|
||||||
|
|
||||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
||||||
id 'de.steamwar.gradle' version 'RELEASE'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'de.steamwar'
|
group 'de.steamwar'
|
||||||
version ''
|
version ''
|
||||||
|
|
||||||
|
Properties steamwarProperties = new Properties()
|
||||||
|
if (file("steamwar.properties").exists()) {
|
||||||
|
steamwarProperties.load(file("steamwar.properties").newDataInputStream())
|
||||||
|
}
|
||||||
|
|
||||||
|
ext {
|
||||||
|
buildName = 'BungeeCore'
|
||||||
|
artifactName = 'bungeecore'
|
||||||
|
|
||||||
|
uberJarName = "${buildName}-all.jar"
|
||||||
|
jarName = "${artifactName}.jar"
|
||||||
|
libs = "${buildDir}/libs"
|
||||||
|
|
||||||
|
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
|
||||||
|
operatingSystem = "windows"
|
||||||
|
} else {
|
||||||
|
operatingSystem = "unix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
compileJava.options.encoding = 'UTF-8'
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
java {
|
sourceCompatibility = 1.8
|
||||||
sourceCompatibility = JavaVersion.VERSION_17
|
targetCompatibility = 1.8
|
||||||
targetCompatibility = JavaVersion.VERSION_17
|
|
||||||
}
|
|
||||||
|
|
||||||
mainClassName = ''
|
mainClassName = ''
|
||||||
|
|
||||||
@ -60,32 +81,12 @@ sourceSets {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
name = 'papermc'
|
url 'https://m2.dv8tion.net/releases'
|
||||||
url = 'https://repo.papermc.io/repository/maven-public/'
|
|
||||||
}
|
}
|
||||||
maven {
|
|
||||||
url = 'https://m2.dv8tion.net/releases'
|
|
||||||
content {
|
|
||||||
includeGroup 'net.dv8tion'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
url = 'https://repo.lunarclient.dev'
|
|
||||||
content {
|
|
||||||
includeGroup 'com.lunarclient'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maven { url 'https://jitpack.io' }
|
|
||||||
mavenLocal()
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
maven {
|
||||||
exclude 'META-INF/*'
|
url = uri('https://steamwar.de/maven')
|
||||||
//https://imperceptiblethoughts.com/shadow/configuration/minimizing/
|
|
||||||
minimize {
|
|
||||||
exclude project(':')
|
|
||||||
}
|
}
|
||||||
duplicatesStrategy DuplicatesStrategy.INCLUDE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -94,24 +95,159 @@ dependencies {
|
|||||||
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
annotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
|
||||||
|
|
||||||
compileOnly 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
|
compileOnly 'de.steamwar:waterfall:RELEASE'
|
||||||
annotationProcessor 'com.velocitypowered:velocity-api:3.3.0-SNAPSHOT'
|
compileOnly 'de.steamwar:persistentbungeecore:RELEASE'
|
||||||
compileOnly 'com.velocitypowered:velocity-proxy:3.3.0-SNAPSHOT'
|
|
||||||
|
|
||||||
compileOnly 'de.steamwar:persistentvelocitycore:DEV'
|
|
||||||
implementation("net.dv8tion:JDA:4.4.0_352") {
|
implementation("net.dv8tion:JDA:4.4.0_352") {
|
||||||
exclude module: 'opus-java'
|
exclude module: 'opus-java'
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation project(":CommonCore")
|
implementation project(":CommonCore")
|
||||||
|
}
|
||||||
implementation 'com.lunarclient:apollo-api:1.1.0'
|
|
||||||
implementation 'com.lunarclient:apollo-common:1.1.0'
|
task buildProject {
|
||||||
|
description 'Build this project'
|
||||||
implementation 'org.reflections:reflections:0.10.2'
|
group "Steamwar"
|
||||||
|
|
||||||
compileOnly 'io.netty:netty-buffer:4.1.106.Final'
|
dependsOn build
|
||||||
compileOnly 'io.netty:netty-transport:4.1.106.Final'
|
}
|
||||||
|
|
||||||
implementation 'com.github.Carleslc.Simple-YAML:Simple-Yaml:1.8.4'
|
task finalizeProject {
|
||||||
|
description 'Finalize this project'
|
||||||
|
group "Steamwar"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
if ("${buildDir}" == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
delete fileTree("${libs}").matching {
|
||||||
|
exclude("${uberJarName}")
|
||||||
|
}
|
||||||
|
file(libs + "/" + uberJarName).renameTo(file(libs + "/" + jarName))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
build.finalizedBy(finalizeProject)
|
||||||
|
|
||||||
|
if (steamwarProperties.containsKey("hostname")) {
|
||||||
|
String hostname = steamwarProperties.get("hostname")
|
||||||
|
String uploadPath = steamwarProperties.getOrDefault("uploadPath", "~")
|
||||||
|
|
||||||
|
String server = steamwarProperties.getOrDefault("server", "DevBungee")
|
||||||
|
String serverStartFlags = steamwarProperties.getOrDefault("serverStartFlags", "")
|
||||||
|
|
||||||
|
task uploadProject {
|
||||||
|
description 'Upload this project'
|
||||||
|
group "Steamwar"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
await(shell("scp ${libs}/${jarName} ${hostname}:${uploadPath}/${server}/plugins"))
|
||||||
|
if (steamwarProperties.getOrDefault("directStart", "false") == "false" && !answer("Start ${server} server?")) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
serverStart(server, serverStartFlags, hostname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
uploadProject.dependsOn(buildProject)
|
||||||
|
|
||||||
|
task startDevServer {
|
||||||
|
description 'Start the DevBungee'
|
||||||
|
group "Steamwar"
|
||||||
|
|
||||||
|
doLast {
|
||||||
|
serverStart(server, serverStartFlags, hostname)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def await(Process proc) {
|
||||||
|
def out = new StringBuilder()
|
||||||
|
def err = new StringBuilder()
|
||||||
|
proc.waitForProcessOutput(out, err)
|
||||||
|
return [out, err, proc.exitValue()]
|
||||||
|
}
|
||||||
|
|
||||||
|
private def shell(String command) {
|
||||||
|
if (operatingSystem == "unix") {
|
||||||
|
return ['bash', '-c', command].execute()
|
||||||
|
} else {
|
||||||
|
return ["cmd", "/c", command].execute()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def serverStart(String serverName, String serverFlags, String hostname) {
|
||||||
|
def proc = shell("ssh -t ${hostname} \"./mc ${serverFlags} ${serverName}\"")
|
||||||
|
|
||||||
|
Set<String> strings = new HashSet<>()
|
||||||
|
File file = new File("${projectDir}/ignoredlog");
|
||||||
|
if (file.exists()) {
|
||||||
|
new BufferedReader(new InputStreamReader(new FileInputStream(file))).readLines().forEach({ s ->
|
||||||
|
strings.add(s)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Thread outputThread = new Thread({
|
||||||
|
Reader reader = proc.getInputStream().newReader();
|
||||||
|
Writer writer = System.out.newWriter();
|
||||||
|
try {
|
||||||
|
while (proc.alive) {
|
||||||
|
String s = reader.readLine()
|
||||||
|
if (s == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (strings.stream().anyMatch({check -> s.contains(check)})) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
writer.write(s + "\n")
|
||||||
|
writer.flush()
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
})
|
||||||
|
outputThread.setName("${serverName} - OutputThread")
|
||||||
|
outputThread.start()
|
||||||
|
|
||||||
|
Writer writer
|
||||||
|
Thread inputThread = new Thread({
|
||||||
|
Reader reader = System.in.newReader()
|
||||||
|
writer = proc.getOutputStream().newWriter()
|
||||||
|
try {
|
||||||
|
while (proc.alive) {
|
||||||
|
String s = reader.readLine()
|
||||||
|
writer.write(s + "\n")
|
||||||
|
writer.flush()
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignored
|
||||||
|
}
|
||||||
|
})
|
||||||
|
inputThread.setName("${serverName} - InputThread")
|
||||||
|
inputThread.start()
|
||||||
|
|
||||||
|
gradle.buildFinished { buildResult ->
|
||||||
|
if (!proc.alive) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writer = proc.getOutputStream().newWriter()
|
||||||
|
writer.write("stop\n")
|
||||||
|
writer.flush()
|
||||||
|
awaitClose(proc, outputThread, inputThread)
|
||||||
|
}
|
||||||
|
awaitClose(proc, outputThread, inputThread)
|
||||||
|
};
|
||||||
|
|
||||||
|
private static def awaitClose(Process proc, Thread outputThread, Thread inputThread) {
|
||||||
|
while (proc.alive) {
|
||||||
|
Thread.sleep(10)
|
||||||
|
}
|
||||||
|
proc.closeStreams()
|
||||||
|
outputThread.interrupt()
|
||||||
|
inputThread.interrupt()
|
||||||
|
}
|
||||||
|
|
||||||
|
private def answer(String question) {
|
||||||
|
while (System.in.available() > 0) System.in.read()
|
||||||
|
println(question)
|
||||||
|
boolean valid = "Yy".contains(((char) System.in.read()).toString())
|
||||||
|
while (System.in.available() > 0) System.in.read()
|
||||||
|
return valid
|
||||||
}
|
}
|
@ -1,86 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
import datetime
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
import tarfile
|
|
||||||
from os import path
|
|
||||||
|
|
||||||
# Non stdlib
|
|
||||||
from nbt import nbt
|
|
||||||
from ruamel.yaml import YAML
|
|
||||||
yaml = YAML()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
configfile = f'/configs/GameModes/{sys.argv[1]}'
|
|
||||||
version = int(sys.argv[2])
|
|
||||||
worldname = sys.argv[3]
|
|
||||||
|
|
||||||
with open(configfile, 'r') as file:
|
|
||||||
gamemode = yaml.load(file)
|
|
||||||
|
|
||||||
builderworld = path.expanduser(f'~/builder{version}/{worldname}')
|
|
||||||
arenaworld = f'/servers/{gamemode["Server"]["Folder"]}/arenas/{worldname}'
|
|
||||||
|
|
||||||
if path.exists(arenaworld):
|
|
||||||
backupworld = path.expanduser(f'~/backup/arenas/{datetime.datetime.now()}-{worldname}-{version}.tar.xz')
|
|
||||||
with tarfile.open(backupworld, 'w:xz') as tar:
|
|
||||||
tar.add(arenaworld, arcname=worldname)
|
|
||||||
|
|
||||||
shutil.rmtree(arenaworld)
|
|
||||||
else:
|
|
||||||
gamemode['Server']['Maps'].append(worldname)
|
|
||||||
|
|
||||||
with open(configfile, 'w') as file:
|
|
||||||
yaml.dump(gamemode, file)
|
|
||||||
|
|
||||||
|
|
||||||
level = nbt.NBTFile(f'{builderworld}/level.dat')
|
|
||||||
level['Data']['Difficulty'] = nbt.TAG_Byte(2)
|
|
||||||
gameRules = level['Data']['GameRules']
|
|
||||||
gameRules['announceAdvancements'] = nbt.TAG_String('false')
|
|
||||||
gameRules['disableRaids'] = nbt.TAG_String('true')
|
|
||||||
gameRules['doDaylightCycle'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doEntityDrops'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doFireTick'] = nbt.TAG_String('true')
|
|
||||||
gameRules['doImmediateRespawn'] = nbt.TAG_String('true')
|
|
||||||
gameRules['doInsomnia'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doLimitedCrafting'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doMobLoot'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doMobSpawning'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doPatrolSpawning'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doTileDrops'] = nbt.TAG_String('true')
|
|
||||||
gameRules['doTraderSpawning'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doWardenSpawning'] = nbt.TAG_String('false')
|
|
||||||
gameRules['doWeatherCycle'] = nbt.TAG_String('false')
|
|
||||||
gameRules['drowningDamage'] = nbt.TAG_String('true')
|
|
||||||
gameRules['fallDamage'] = nbt.TAG_String('true')
|
|
||||||
gameRules['fireDamage'] = nbt.TAG_String('true')
|
|
||||||
gameRules['freezeDamage'] = nbt.TAG_String('true')
|
|
||||||
gameRules['keepInventory'] = nbt.TAG_String('true')
|
|
||||||
gameRules['lavaSourceConversion'] = nbt.TAG_String('false')
|
|
||||||
gameRules['maxEntityCramming'] = nbt.TAG_String('24')
|
|
||||||
gameRules['mobGriefing'] = nbt.TAG_String('false')
|
|
||||||
gameRules['naturalRegeneration'] = nbt.TAG_String('false')
|
|
||||||
gameRules['randomTickSpeed'] = nbt.TAG_String('3')
|
|
||||||
gameRules['reducedDebugInfo'] = nbt.TAG_String('true')
|
|
||||||
gameRules['snowAccumulationHeight'] = nbt.TAG_String('1')
|
|
||||||
gameRules['spawnRadius'] = nbt.TAG_String('0')
|
|
||||||
gameRules['spectatorsGenerateChunks'] = nbt.TAG_String('true')
|
|
||||||
gameRules['waterSourceConversion'] = nbt.TAG_String('true')
|
|
||||||
level.write_file()
|
|
||||||
|
|
||||||
if path.exists(arenaworld):
|
|
||||||
shutil.rmtree(arenaworld)
|
|
||||||
|
|
||||||
os.makedirs(f'{arenaworld}/backup')
|
|
||||||
shutil.copy2(f'{builderworld}/level.dat', f'{arenaworld}/backup/level.dat')
|
|
||||||
shutil.copytree(f'{builderworld}/region', f'{arenaworld}/backup/region')
|
|
||||||
|
|
||||||
shutil.copy2(f'{builderworld}/level.dat', f'{arenaworld}/level.dat')
|
|
||||||
shutil.copytree(f'{builderworld}/region', f'{arenaworld}/region')
|
|
||||||
shutil.copy2(f'{builderworld}/config.yml', f'{arenaworld}/config.yml')
|
|
||||||
|
|
||||||
if path.exists(f'{builderworld}/paper-world.yml'):
|
|
||||||
shutil.copy2(f'{builderworld}/paper-world.yml', f'{arenaworld}/backup/paper-world.yml')
|
|
||||||
shutil.copy2(f'{builderworld}/paper-world.yml', f'{arenaworld}/paper-world.yml')
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
#Sat Apr 10 23:34:12 CEST 2021
|
#Sat Apr 10 23:34:12 CEST 2021
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-all.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -17,15 +17,6 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pluginManagement {
|
rootProject.name = 'BungeeCore'
|
||||||
repositories {
|
|
||||||
gradlePluginPortal()
|
|
||||||
maven {
|
|
||||||
url = uri("https://steamwar.de/maven/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = 'VelocityCore'
|
|
||||||
|
|
||||||
include 'CommonCore'
|
include 'CommonCore'
|
@ -19,9 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.bungeecore.sql.SchematicType;
|
||||||
import org.simpleyaml.configuration.Configuration;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import org.simpleyaml.configuration.file.YamlFile;
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
|
import net.md_5.bungee.config.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -30,29 +32,19 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class ArenaMode {
|
public class ArenaMode {
|
||||||
|
|
||||||
private static final Random random = new Random();
|
|
||||||
|
|
||||||
private static final Map<String, ArenaMode> byChat = new HashMap<>();
|
private static final Map<String, ArenaMode> byChat = new HashMap<>();
|
||||||
private static final Map<String, ArenaMode> byInternal = new HashMap<>();
|
private static final Map<String, ArenaMode> byInternal = new HashMap<>();
|
||||||
private static final Map<SchematicType, ArenaMode> bySchemType = new HashMap<>();
|
private static final Map<SchematicType, ArenaMode> bySchemType = new HashMap<>();
|
||||||
private static final List<ArenaMode> allModes = new LinkedList<>();
|
private static final List<ArenaMode> allModes = new LinkedList<>();
|
||||||
|
private static final Random random = new Random();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
init();
|
File folder = new File(ProxyServer.getInstance().getPluginsFolder(), "FightSystem");
|
||||||
}
|
|
||||||
|
|
||||||
public static void init() {
|
|
||||||
byChat.clear();
|
|
||||||
byInternal.clear();
|
|
||||||
bySchemType.clear();
|
|
||||||
allModes.clear();
|
|
||||||
|
|
||||||
File folder = new File(VelocityCore.get().getDataDirectory().getParent().toFile(), "FightSystem");
|
|
||||||
|
|
||||||
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
|
for(File configFile : Arrays.stream(folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))).sorted().collect(Collectors.toList())) {
|
||||||
Configuration config;
|
Configuration config;
|
||||||
try {
|
try {
|
||||||
config = YamlFile.loadConfiguration(configFile);
|
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SecurityException("Could not load SchematicTypes", e);
|
throw new SecurityException("Could not load SchematicTypes", e);
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@ -30,15 +29,14 @@ class Broadcaster {
|
|||||||
private int lastBroadCast = 0;
|
private int lastBroadCast = 0;
|
||||||
|
|
||||||
Broadcaster(){
|
Broadcaster(){
|
||||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
if(!VelocityCore.get().getProxyServer().getAllPlayers().isEmpty() && broadCastMsgs.length > 0) {
|
if(!ProxyServer.getInstance().getPlayers().isEmpty())
|
||||||
VelocityCore.get().getProxyServer().sendMessage(LegacyComponentSerializer.legacySection().deserialize(VelocityCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]));
|
BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]);
|
||||||
}
|
|
||||||
lastBroadCast++;
|
lastBroadCast++;
|
||||||
if(lastBroadCast == broadCastMsgs.length){
|
if(lastBroadCast == broadCastMsgs.length){
|
||||||
lastBroadCast = 0;
|
lastBroadCast = 0;
|
||||||
}
|
}
|
||||||
}).repeat(10, TimeUnit.MINUTES);
|
}, 10, 10, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setBroadCastMsgs(String[] broadCastMsgs) {
|
static void setBroadCastMsgs(String[] broadCastMsgs) {
|
||||||
|
@ -19,51 +19,45 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|
||||||
import com.velocitypowered.api.event.proxy.ProxyReloadEvent;
|
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.commands.*;
|
import de.steamwar.bungeecore.commands.*;
|
||||||
import de.steamwar.bungeecore.listeners.*;
|
import de.steamwar.bungeecore.listeners.*;
|
||||||
import de.steamwar.bungeecore.mods.ServerListPing;
|
import de.steamwar.bungeecore.listeners.mods.*;
|
||||||
import de.steamwar.bungeecore.mods.*;
|
import de.steamwar.bungeecore.listeners.ping.PingListener;
|
||||||
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
import de.steamwar.bungeecore.network.BungeeNetworkHandler;
|
||||||
|
import de.steamwar.bungeecore.network.NetworkReceiver;
|
||||||
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.bungeecore.tablist.TablistManager;
|
import de.steamwar.bungeecore.tablist.TablistManager;
|
||||||
import de.steamwar.bungeecore.util.SteamWarModule;
|
|
||||||
import de.steamwar.bungeecore.util.annotations.Create;
|
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.SWTypeMapperCreator;
|
import de.steamwar.command.SWTypeMapperCreator;
|
||||||
import de.steamwar.command.TabCompletionCache;
|
import de.steamwar.command.TabCompletionCache;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.sql.Punishment;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import de.steamwar.sql.Team;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import de.steamwar.sql.UserElo;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import de.steamwar.sql.internal.Statement;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import lombok.Getter;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import org.reflections.Reflections;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
import net.md_5.bungee.config.ConfigurationProvider;
|
||||||
|
import net.md_5.bungee.config.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.*;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
@Plugin(
|
public class BungeeCore extends Plugin {
|
||||||
id = "velocitycore",
|
|
||||||
name = "VelocityCore",
|
|
||||||
authors = {"SteamWar"}
|
|
||||||
)
|
|
||||||
public class VelocityCore {
|
|
||||||
|
|
||||||
public static boolean MAIN_SERVER;
|
public static boolean MAIN_SERVER;
|
||||||
|
|
||||||
@ -71,75 +65,62 @@ public class VelocityCore {
|
|||||||
public static String LOBBY_SERVER;
|
public static String LOBBY_SERVER;
|
||||||
public static boolean EVENT_MODE;
|
public static boolean EVENT_MODE;
|
||||||
|
|
||||||
private static VelocityCore instance;
|
private static BungeeCore instance;
|
||||||
|
|
||||||
|
public static final Map<String, String> serverPermissions = new HashMap<>();
|
||||||
|
public static final Map<String, String> commands = new HashMap<>();
|
||||||
|
|
||||||
|
public static Node local;
|
||||||
private ErrorLogger errorLogger;
|
private ErrorLogger errorLogger;
|
||||||
private TablistManager tablistManager;
|
private TablistManager tablistManager;
|
||||||
|
|
||||||
@Getter
|
@Override
|
||||||
private final ProxyServer proxyServer;
|
public void onEnable(){
|
||||||
|
getProxy().registerChannel("sw:bridge");
|
||||||
|
getProxy().registerChannel("fabricmodsender:mods");
|
||||||
|
getProxy().registerChannel("nochatreports:sync");
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Logger logger;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Path dataDirectory;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private Injector injector;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public VelocityCore(ProxyServer proxyServer, Logger logger, @DataDirectory Path dataDirectory, Injector injector) {
|
|
||||||
this.proxyServer = proxyServer;
|
|
||||||
this.logger = logger;
|
|
||||||
this.dataDirectory = dataDirectory;
|
|
||||||
this.injector = injector;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
|
||||||
setInstance(this);
|
setInstance(this);
|
||||||
MAIN_SERVER = proxyServer.getBoundAddress().getPort() == 25565;
|
MAIN_SERVER = ProxyServer.getInstance().getConfig().getListeners().stream().anyMatch(info -> ((InetSocketAddress) info.getSocketAddress()).getPort() == 25565);
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
injector = injector.createChildInjector(new SteamWarModule(this));
|
|
||||||
|
|
||||||
errorLogger = new ErrorLogger();
|
errorLogger = new ErrorLogger();
|
||||||
|
|
||||||
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, Player, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
|
SWCommandUtils.init((SWTypeMapperCreator<TypeMapper<Object>, CommandSender, Object>) (mapper, tabCompleter) -> new TypeMapper<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object map(Player commandSender, String[] previousArguments, String s) {
|
public Object map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
return mapper.apply(s);
|
return mapper.apply(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(Player sender, String[] previousArguments, String s) {
|
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
||||||
return tabCompleter.apply(sender, s);
|
return tabCompleter.apply(sender, s);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
proxyServer.getScheduler().buildTask(this, TabCompletionCache::invalidateOldEntries).repeat(1, TimeUnit.SECONDS);
|
BungeeCord.getInstance().getScheduler().schedule(this, TabCompletionCache::invalidateOldEntries, 1, 1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
Reflections reflections = new Reflections("de.steamwar.bungeecore");
|
|
||||||
reflections.getTypesAnnotatedWith(Create.class)
|
|
||||||
.forEach(clazz -> {
|
|
||||||
Create create = clazz.getAnnotation(Create.class);
|
|
||||||
if (create.eventProxy() || MAIN_SERVER) {
|
|
||||||
Object obj = injector.getInstance(clazz);
|
|
||||||
if (Arrays.stream(clazz.getDeclaredMethods()).anyMatch(method -> method.isAnnotationPresent(Subscribe.class))) {
|
|
||||||
proxyServer.getEventManager().register(this, obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new ConnectionListener();
|
new ConnectionListener();
|
||||||
|
new Forge();
|
||||||
|
new Forge12();
|
||||||
|
new LabyMod();
|
||||||
|
new Badlion();
|
||||||
new ChatListener();
|
new ChatListener();
|
||||||
new BanListener();
|
new BanListener();
|
||||||
new CheckListener();
|
new CheckListener();
|
||||||
new IPSanitizer();
|
new ModLoaderBlocker();
|
||||||
|
new WorldDownloader();
|
||||||
|
new BrandListener();
|
||||||
|
new Fabric();
|
||||||
|
new SubserverProtocolFixer();
|
||||||
|
new PingListener();
|
||||||
|
|
||||||
if(MAIN_SERVER) {
|
local = new Node.LocalNode();
|
||||||
//new Node.RemoteNode("lx");
|
//new Node.RemoteNode("lx");
|
||||||
}
|
|
||||||
|
commands.put("/tp", null);
|
||||||
|
commands.put("/bc", null);
|
||||||
|
commands.put("/bauchat", null);
|
||||||
|
commands.put("/local", null);
|
||||||
|
|
||||||
new TeamchatCommand();
|
new TeamchatCommand();
|
||||||
new MsgCommand();
|
new MsgCommand();
|
||||||
@ -149,7 +130,7 @@ public class VelocityCore {
|
|||||||
new KickCommand();
|
new KickCommand();
|
||||||
new JoinmeCommand();
|
new JoinmeCommand();
|
||||||
new TpCommand();
|
new TpCommand();
|
||||||
HelpCommand helpCommand = new HelpCommand();
|
new HelpCommand();
|
||||||
new TeamCommand();
|
new TeamCommand();
|
||||||
new ServerTeamchatCommand();
|
new ServerTeamchatCommand();
|
||||||
new DevCommand();
|
new DevCommand();
|
||||||
@ -174,8 +155,6 @@ public class VelocityCore {
|
|||||||
new SetLocaleCommand();
|
new SetLocaleCommand();
|
||||||
new BuilderCloudCommand();
|
new BuilderCloudCommand();
|
||||||
|
|
||||||
new ModCommand();
|
|
||||||
|
|
||||||
// Punishment Commands:
|
// Punishment Commands:
|
||||||
new PunishmentCommand("ban", Punishment.PunishmentType.Ban);
|
new PunishmentCommand("ban", Punishment.PunishmentType.Ban);
|
||||||
new PunishmentCommand("mute", Punishment.PunishmentType.Mute);
|
new PunishmentCommand("mute", Punishment.PunishmentType.Mute);
|
||||||
@ -188,7 +167,7 @@ public class VelocityCore {
|
|||||||
new PunishmentCommand("note", Punishment.PunishmentType.Note);
|
new PunishmentCommand("note", Punishment.PunishmentType.Note);
|
||||||
|
|
||||||
if(!EVENT_MODE){
|
if(!EVENT_MODE){
|
||||||
new BauCommand(helpCommand);
|
new BauCommand();
|
||||||
new WebpasswordCommand();
|
new WebpasswordCommand();
|
||||||
new FightCommand();
|
new FightCommand();
|
||||||
new ChallengeCommand();
|
new ChallengeCommand();
|
||||||
@ -204,15 +183,16 @@ public class VelocityCore {
|
|||||||
|
|
||||||
new EventStarter();
|
new EventStarter();
|
||||||
new SessionManager();
|
new SessionManager();
|
||||||
|
new NetworkReceiver();
|
||||||
BungeeNetworkHandler.register();
|
BungeeNetworkHandler.register();
|
||||||
tablistManager = new TablistManager();
|
tablistManager = new TablistManager();
|
||||||
new SettingsChangedListener();
|
new SettingsChangedListener();
|
||||||
|
|
||||||
proxyServer.getScheduler().buildTask(this, () -> {
|
getProxy().getScheduler().schedule(this, () -> {
|
||||||
SteamwarUser.clear();
|
SteamwarUser.clearCache();
|
||||||
UserElo.clear();
|
UserElo.clearCache();
|
||||||
Team.clear();
|
Team.clearCache();
|
||||||
}).repeat(1, TimeUnit.HOURS);
|
}, 1, 1, TimeUnit.HOURS);
|
||||||
|
|
||||||
if (SteamwarDiscordBotConfig.loaded) {
|
if (SteamwarDiscordBotConfig.loaded) {
|
||||||
try {
|
try {
|
||||||
@ -223,8 +203,8 @@ public class VelocityCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Override
|
||||||
public void onDisable(ProxyReloadEvent event) {
|
public void onDisable(){
|
||||||
if (SteamwarDiscordBotConfig.loaded) {
|
if (SteamwarDiscordBotConfig.loaded) {
|
||||||
try {
|
try {
|
||||||
SteamwarDiscordBot.instance().getJda().shutdown();
|
SteamwarDiscordBot.instance().getJda().shutdown();
|
||||||
@ -239,10 +219,64 @@ public class VelocityCore {
|
|||||||
Statement.closeAll();
|
Statement.closeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VelocityCore get() {
|
public static BungeeCore get() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TextComponent stringToText(String msg){
|
||||||
|
return new TextComponent(TextComponent.fromLegacyText(msg));
|
||||||
|
}
|
||||||
|
public static void send(ProxiedPlayer player, String msg){
|
||||||
|
send(player, msg, null, null);
|
||||||
|
}
|
||||||
|
public static void send(CommandSender sender, String msg){
|
||||||
|
sender.sendMessage(stringToText(msg));
|
||||||
|
}
|
||||||
|
public static void send(ProxiedPlayer player, ChatMessageType type, String msg){
|
||||||
|
send(player, type, msg, null, null);
|
||||||
|
}
|
||||||
|
public static void send(ProxiedPlayer player, String msg, String onHover, ClickEvent onClick){
|
||||||
|
send(player, ChatMessageType.SYSTEM, msg, onHover, onClick);
|
||||||
|
}
|
||||||
|
public static void send(ProxiedPlayer player, ChatMessageType type, String msg, String onHover, ClickEvent onClick){
|
||||||
|
if(type == ChatMessageType.CHAT && player.getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
|
||||||
|
return;
|
||||||
|
TextComponent message = stringToText(msg);
|
||||||
|
if(onHover != null)
|
||||||
|
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
||||||
|
if(onClick != null)
|
||||||
|
message.setClickEvent(onClick);
|
||||||
|
player.sendMessage(type, message);
|
||||||
|
}
|
||||||
|
public static void broadcast(String msg){
|
||||||
|
ProxyServer.getInstance().broadcast(stringToText(msg));
|
||||||
|
}
|
||||||
|
public static void broadcast(String msg, String onHover, ClickEvent onClick){
|
||||||
|
TextComponent message = stringToText(msg);
|
||||||
|
if(onHover != null)
|
||||||
|
message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
|
||||||
|
if(onClick != null)
|
||||||
|
message.setClickEvent(onClick);
|
||||||
|
ProxyServer.getInstance().broadcast(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void log(final ServerInfo server, final String msg){
|
||||||
|
log(server.getName() + ": " + msg);
|
||||||
|
}
|
||||||
|
public static void log(final ProxiedPlayer player, final String msg){
|
||||||
|
log(player.getName() + ": " + msg);
|
||||||
|
}
|
||||||
|
public static void log(final String msg){
|
||||||
|
log(Level.INFO, msg);
|
||||||
|
}
|
||||||
|
public static void log(final Level logLevel, final String msg){
|
||||||
|
get().getLogger().log(logLevel, msg);
|
||||||
|
}
|
||||||
|
public static void log(final String msg, final Throwable e){
|
||||||
|
get().getLogger().log(Level.SEVERE, msg, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void loadConfig(){
|
private static void loadConfig(){
|
||||||
Configuration config;
|
Configuration config;
|
||||||
try{
|
try{
|
||||||
@ -269,25 +303,28 @@ public class VelocityCore {
|
|||||||
EVENT_MODE = config.getBoolean("eventmode");
|
EVENT_MODE = config.getBoolean("eventmode");
|
||||||
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
|
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
|
||||||
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
|
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
|
||||||
|
Persistent.setChatPrefix(CHAT_PREFIX);
|
||||||
|
Persistent.setLobbyServer(LOBBY_SERVER);
|
||||||
|
|
||||||
final Configuration servers = config.getSection("servers");
|
final Configuration servers = config.getSection("servers");
|
||||||
for(final String serverName : servers.getKeys()){
|
for(final String serverName : servers.getKeys()){
|
||||||
final Configuration server = servers.getSection(serverName);
|
final Configuration server = servers.getSection(serverName);
|
||||||
List<String> cmds = server.getStringList("commands");
|
List<String> cmds = server.getStringList("commands");
|
||||||
|
serverPermissions.put(serverName, "bungeecore.server." + server.getString("permission"));
|
||||||
String cmd = cmds.remove(0);
|
String cmd = cmds.remove(0);
|
||||||
|
|
||||||
if(server.contains("spectatePort"))
|
|
||||||
EventStarter.addSpectateServer(server.getInt("spectatePort"), cmd);
|
|
||||||
|
|
||||||
new ServerSwitchCommand(
|
new ServerSwitchCommand(
|
||||||
cmd,
|
cmd,
|
||||||
serverName,
|
serverName,
|
||||||
|
serverPermissions.get(serverName),
|
||||||
cmds.toArray(new String[0])
|
cmds.toArray(new String[0])
|
||||||
);
|
);
|
||||||
|
if(server.getBoolean("modchecked", false)) {
|
||||||
|
ModLoaderBlocker.addServer(serverName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File discordFile = new File(System.getProperty("user.home"), "discord.yml");
|
File discordFile = new File(System.getProperty("user.home"), "discord.yml");
|
||||||
if(discordFile.exists() && !EVENT_MODE) {
|
if(discordFile.exists()) {
|
||||||
try {
|
try {
|
||||||
SteamwarDiscordBotConfig.loadConfig(ConfigurationProvider.getProvider(YamlConfiguration.class).load(discordFile));
|
SteamwarDiscordBotConfig.loadConfig(ConfigurationProvider.getProvider(YamlConfiguration.class).load(discordFile));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -296,7 +333,7 @@ public class VelocityCore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setInstance(VelocityCore core){
|
private static void setInstance(BungeeCore core){
|
||||||
instance = core;
|
instance = core;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.sql.SWException;
|
import de.steamwar.bungeecore.sql.SWException;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
@ -61,7 +61,7 @@ public class ErrorLogger extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWException.log(message, stacktrace);
|
SWException.log("Bungee", message, stacktrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,8 +86,6 @@ public class ErrorLogger extends Handler {
|
|||||||
contains.add("Error occurred processing connection for");
|
contains.add("Error occurred processing connection for");
|
||||||
contains.add("Server is online mode!");
|
contains.add("Server is online mode!");
|
||||||
contains.add(" took ");
|
contains.add(" took ");
|
||||||
contains.add("Could not translate packet ");
|
|
||||||
contains.add("455420");
|
|
||||||
ignoreContains = Collections.unmodifiableList(contains);
|
ignoreContains = Collections.unmodifiableList(contains);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,37 +19,42 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.bungeecore.sql.Event;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.bungeecore.sql.EventFight;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static de.steamwar.bungeecore.Storage.eventServer;
|
import static de.steamwar.bungeecore.Storage.eventServer;
|
||||||
|
|
||||||
public class EventStarter {
|
public class EventStarter implements Runnable {
|
||||||
|
|
||||||
private static final Map<Integer, String> spectatePorts = new HashMap<>();
|
private static ScheduledTask task = null;
|
||||||
|
|
||||||
public static void addSpectateServer(int port, String command) {
|
EventStarter(){
|
||||||
spectatePorts.put(port, command);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EventStarter() {
|
|
||||||
EventFight.loadAllComingFights();
|
EventFight.loadAllComingFights();
|
||||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), this::run).repeat(10, TimeUnit.SECONDS);
|
|
||||||
|
if(task != null)
|
||||||
|
task.cancel();
|
||||||
|
|
||||||
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), this, 1, 10, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<Integer, Subserver> getEventServer() {
|
public static Map<Integer, Subserver> getEventServer() {
|
||||||
return eventServer;
|
return eventServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run() {
|
@Override
|
||||||
eventServer.entrySet().removeIf(entry -> Subserver.getSubserver(entry.getValue().getServer()) == null);
|
public void run() {
|
||||||
|
eventServer.entrySet().removeIf(entry -> !Subserver.getServerList().contains(entry.getValue()));
|
||||||
Queue<EventFight> fights = EventFight.getFights();
|
Queue<EventFight> fights = EventFight.getFights();
|
||||||
|
|
||||||
EventFight next;
|
EventFight next;
|
||||||
@ -58,19 +63,22 @@ public class EventStarter {
|
|||||||
Team red = Team.get(next.getTeamRed());
|
Team red = Team.get(next.getTeamRed());
|
||||||
|
|
||||||
//Don't start EventServer if not the event bungee
|
//Don't start EventServer if not the event bungee
|
||||||
if(VelocityCore.EVENT_MODE || next.getSpectatePort() == 0) {
|
if(BungeeCore.EVENT_MODE || !Event.get(next.getEventID()).spectateSystem()) {
|
||||||
ServerStarter starter = new ServerStarter().event(next);
|
ServerStarter starter = new ServerStarter().event(next);
|
||||||
|
|
||||||
starter.callback(subserver -> {
|
ProxiedPlayer leiter = ProxyServer.getInstance().getPlayer(SteamwarUser.get(next.getKampfleiter()).getUuid());
|
||||||
eventServer.put(blue.getTeamId(), subserver);
|
if(leiter != null)
|
||||||
eventServer.put(red.getTeamId(), subserver);
|
starter.send(leiter);
|
||||||
}).start();
|
|
||||||
|
|
||||||
|
Subserver subserver = starter.start();
|
||||||
|
|
||||||
|
eventServer.put(blue.getTeamId(), subserver);
|
||||||
|
eventServer.put(red.getTeamId(), subserver);
|
||||||
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
||||||
ClickEvent.runCommand("/event " + blue.getTeamKuerzel()), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/event " + blue.getTeamKuerzel()), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||||
} else {
|
} else {
|
||||||
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
Message.broadcast("EVENT_FIGHT_BROADCAST", "EVENT_FIGHT_BROADCAST_HOVER",
|
||||||
ClickEvent.runCommand("/" + spectatePorts.get(next.getSpectatePort())), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/spectate"), blue.getTeamColor(), blue.getTeamName(), red.getTeamColor(), red.getTeamName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,12 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.messages.SteamwarResourceBundle;
|
import de.steamwar.messages.SteamwarResourceBundle;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -36,17 +35,17 @@ import java.util.ResourceBundle;
|
|||||||
public class Message {
|
public class Message {
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static Component parseToComponent(String message, boolean prefixed, CommandSource sender, Object... params){
|
public static TextComponent parseToComponent(String message, boolean prefixed, CommandSender sender, Object... params){
|
||||||
return LegacyComponentSerializer.legacySection().deserialize(parse(message, prefixed, locale(sender), params));
|
return new TextComponent(TextComponent.fromLegacyText(parse(message, prefixed, locale(sender), params)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String parsePrefixed(String message, CommandSource sender, Object... params){
|
public static String parsePrefixed(String message, CommandSender sender, Object... params){
|
||||||
return parse(message, true, locale(sender), params);
|
return parse(message, true, locale(sender), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static String parse(String message, CommandSource sender, Object... params){
|
public static String parse(String message, CommandSender sender, Object... params){
|
||||||
return parse(message, false, locale(sender), params);
|
return parse(message, false, locale(sender), params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,8 +55,8 @@ public class Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private static Locale locale(CommandSource sender) {
|
private static Locale locale(CommandSender sender) {
|
||||||
return sender.get(Identity.LOCALE).orElse(Locale.GERMAN);
|
return ChatSender.of(sender).getLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -83,32 +82,32 @@ public class Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void send(String message, CommandSource sender, Object... params){
|
public static void send(String message, CommandSender sender, Object... params){
|
||||||
send(message, true, sender, null, null, params);
|
send(message, true, sender, ChatMessageType.SYSTEM, null, null, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void sendPrefixless(String message, CommandSource sender, Object... params){
|
public static void sendPrefixless(String message, CommandSender sender, Object... params){
|
||||||
send(message, false, sender, null, null, params);
|
send(message, false, sender, ChatMessageType.SYSTEM, null, null, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void send(String message, CommandSource sender, String onHover, ClickEvent onClick, Object... params){
|
public static void send(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
||||||
send(message, true, sender, onHover, onClick, params);
|
send(message, true, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void sendPrefixless(String message, CommandSource sender, String onHover, ClickEvent onClick, Object... params){
|
public static void sendPrefixless(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
|
||||||
send(message, false, sender, onHover, onClick, params);
|
send(message, false, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
private static void send(String message, boolean prefixed, CommandSource s, String onHover, ClickEvent onClick, Object... params){
|
private static void send(String message, boolean prefixed, CommandSender s, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
|
||||||
ChatSender sender = ChatSender.of(s);
|
ChatSender sender = ChatSender.of(s);
|
||||||
if(!sender.chatShown())
|
if(type == ChatMessageType.CHAT && !sender.chatShown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sender.send(prefixed, onHover != null ? new Message("PLAIN_STRING", onHover) : null, onClick, new Message(message, params));
|
sender.send(prefixed, type, onHover != null ? new Message("PLAIN_STRING", onHover) : null, onClick, new Message(message, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcast(String message, Object... params) {
|
public static void broadcast(String message, Object... params) {
|
||||||
@ -124,7 +123,7 @@ public class Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void team(String message, String onHover, ClickEvent onClick, Object... params) {
|
public static void team(String message, String onHover, ClickEvent onClick, Object... params) {
|
||||||
ChatSender.serverteamReceivers().forEach(player -> player.prefixless(message, onHover != null ? new Message(onHover, params) : null, onClick, params));
|
ChatSender.serverteamReceivers().filter(player -> player.user().getUserGroup().isTeamGroup()).forEach(player -> player.prefixless(message, onHover != null ? new Message(onHover, params) : null, onClick, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String format;
|
private final String format;
|
||||||
|
@ -23,7 +23,6 @@ import net.md_5.bungee.BungeeCord;
|
|||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -31,13 +30,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public abstract class Node {
|
public abstract class Node {
|
||||||
|
|
||||||
//-Xquickstart Langzeitperformance testen!
|
private static final List<String> OPENJ9_ARGS = Arrays.asList("-Xgc:excessiveGCratio=80", "-Xsyslog:none", "-Xtrace:none", "-Xdisableexplicitgc", "-XX:+AlwaysPreTouch", "-XX:+CompactStrings", "-XX:-HeapDumpOnOutOfMemory", "-XX:+ExitOnOutOfMemoryError", "-Dlog4j.configurationFile=log4j2.xml");
|
||||||
private static final List<String> OPENJ9_ARGS = Arrays.asList(
|
|
||||||
"-XX:+EnableCRIUSupport", "-XX:-CRIURestoreNonPortableMode",
|
|
||||||
"-Xgc:excessiveGCratio=80", "-Xdisableexplicitgc", "-Xnoclassgc", "-Xmos128M", "-Xmns48M", "-XX:+ExitOnOutOfMemoryError", // initial heap half values of memory observed by 1.19 spectate server
|
|
||||||
"-Xsyslog:none", "-Xtrace:none", "-Xverify:none", "-Xdump:system:none", "-Xdump:jit:none", "-Xdump:snap:none",
|
|
||||||
"-Dlog4j.configurationFile=log4j2.xml"
|
|
||||||
);
|
|
||||||
private static final Set<String> JAVA_8 = new HashSet<>();
|
private static final Set<String> JAVA_8 = new HashSet<>();
|
||||||
static {
|
static {
|
||||||
JAVA_8.add("paper-1.8.8.jar");
|
JAVA_8.add("paper-1.8.8.jar");
|
||||||
@ -48,6 +41,7 @@ public abstract class Node {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final long MIN_FREE_MEM = 4 * 1024 * 1024L; // 4 GiB
|
private static final long MIN_FREE_MEM = 4 * 1024 * 1024L; // 4 GiB
|
||||||
|
private static final double MAX_LOAD = 0.8;
|
||||||
|
|
||||||
private static final List<Node> nodes = new ArrayList<>();
|
private static final List<Node> nodes = new ArrayList<>();
|
||||||
|
|
||||||
@ -71,10 +65,13 @@ public abstract class Node {
|
|||||||
protected final String hostname;
|
protected final String hostname;
|
||||||
protected volatile boolean belowLoadLimit = true;
|
protected volatile boolean belowLoadLimit = true;
|
||||||
|
|
||||||
|
private long previousCpuLoaded = 0;
|
||||||
|
private long previousCpuTotal = 0;
|
||||||
|
|
||||||
protected Node(String hostname) {
|
protected Node(String hostname) {
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
nodes.add(this);
|
nodes.add(this);
|
||||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> calcLoadLimit()).repeat(2, TimeUnit.SECONDS);
|
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), this::calcLoadLimit, 1, 2, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void execute(String... command) {
|
public void execute(String... command) {
|
||||||
@ -83,7 +80,7 @@ public abstract class Node {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SecurityException("Could not execute command", e);
|
throw new SecurityException("Could not execute command", e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Interrupted during execution", e);
|
ProxyServer.getInstance().getLogger().log(Level.SEVERE, "Interrupted during execution", e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,18 +96,17 @@ public abstract class Node {
|
|||||||
if (JAVA_8.contains(serverJar))
|
if (JAVA_8.contains(serverJar))
|
||||||
cmd.add("/usr/lib/jvm/java-8-openj9-amd64/bin/java");
|
cmd.add("/usr/lib/jvm/java-8-openj9-amd64/bin/java");
|
||||||
else
|
else
|
||||||
cmd.add("/usr/lib/jvm/java-21-openj9-amd64/bin/java");
|
cmd.add("java");
|
||||||
|
|
||||||
for(String param : dParams){
|
for(String param : dParams){
|
||||||
cmd.add("-D" + param);
|
cmd.add("-D" + param);
|
||||||
}
|
}
|
||||||
cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName());
|
|
||||||
cmd.add("-Xmx" + xmx);
|
cmd.add("-Xmx" + xmx);
|
||||||
|
cmd.add("-Xshareclasses:nonfatal,name=" + directory.getName());
|
||||||
cmd.addAll(OPENJ9_ARGS);
|
cmd.addAll(OPENJ9_ARGS);
|
||||||
if (!JAVA_8.contains(serverJar)) {
|
if (!JAVA_8.contains(serverJar)) {
|
||||||
cmd.add("--add-opens");
|
cmd.add("--add-opens");
|
||||||
cmd.add("java.base/jdk.internal.misc=ALL-UNNAMED");
|
cmd.add("java.base/jdk.internal.misc=ALL-UNNAMED");
|
||||||
cmd.add("-XX:-CRIUSecProvider");
|
|
||||||
}
|
}
|
||||||
cmd.add("-jar");
|
cmd.add("-jar");
|
||||||
cmd.add("/binarys/" + serverJar);
|
cmd.add("/binarys/" + serverJar);
|
||||||
@ -124,18 +120,28 @@ public abstract class Node {
|
|||||||
cmd.add("nogui");
|
cmd.add("nogui");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void calcLoadLimit(BufferedReader meminfo) throws IOException {
|
protected void calcLoadLimit(BufferedReader stat, BufferedReader meminfo) throws IOException {
|
||||||
|
String[] cpuline = stat.readLine().split(" "); // 0-1: prefix, 2: user, 3: nice, 4: system, 5: idle, 6: iowait, 7: irq, 8: softirq, 9: steal, 10: guest, 11: guest_nice
|
||||||
|
long cpuLoaded = Long.parseLong(cpuline[2]) + Long.parseLong(cpuline[4]) + Long.parseLong(cpuline[6]) + Long.parseLong(cpuline[7]) + Long.parseLong(cpuline[8]) + Long.parseLong(cpuline[9]) + Long.parseLong(cpuline[10]) + Long.parseLong(cpuline[11]);
|
||||||
|
long cpuTotal = cpuLoaded + Long.parseLong(cpuline[3]) + Long.parseLong(cpuline[5]);
|
||||||
|
|
||||||
|
cpuLoaded -= previousCpuLoaded;
|
||||||
|
cpuTotal -= previousCpuTotal;
|
||||||
|
previousCpuLoaded += cpuLoaded;
|
||||||
|
previousCpuTotal += cpuTotal;
|
||||||
|
|
||||||
String line = meminfo.readLine();
|
String line = meminfo.readLine();
|
||||||
while(!line.startsWith("MemAvailable")) {
|
while(!line.startsWith("MemAvailable")) {
|
||||||
line = meminfo.readLine();
|
line = meminfo.readLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
long availableMem = Long.parseLong(line.replaceAll(" +", " ").split(" ")[1]);
|
long availableMem = Long.parseLong(line.replaceAll(" +", " ").split(" ")[1]);
|
||||||
belowLoadLimit = availableMem >= MIN_FREE_MEM;
|
belowLoadLimit = cpuLoaded / (double)cpuTotal <= MAX_LOAD && availableMem >= MIN_FREE_MEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class LocalNode extends Node {
|
public static class LocalNode extends Node {
|
||||||
private static final File MEMINFO = new File("/proc/meminfo");
|
private static final File MEMINFO = new File("/proc/meminfo");
|
||||||
|
private static final File STAT = new File("/proc/stat");
|
||||||
|
|
||||||
public LocalNode() {
|
public LocalNode() {
|
||||||
super("sw");
|
super("sw");
|
||||||
@ -152,10 +158,12 @@ public abstract class Node {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void calcLoadLimit() {
|
protected void calcLoadLimit() {
|
||||||
try (BufferedReader meminfo = new BufferedReader(new InputStreamReader(Files.newInputStream(MEMINFO.toPath())))) {
|
try (BufferedReader loadavg = new BufferedReader(new InputStreamReader(new FileInputStream(STAT)))) {
|
||||||
calcLoadLimit(meminfo);
|
try (BufferedReader meminfo = new BufferedReader(new InputStreamReader(new FileInputStream(MEMINFO)))) {
|
||||||
|
calcLoadLimit(loadavg, meminfo);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not read local load", e);
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not read local load", e);
|
||||||
belowLoadLimit = false;
|
belowLoadLimit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,7 +178,7 @@ public abstract class Node {
|
|||||||
|
|
||||||
public RemoteNode(String hostname) {
|
public RemoteNode(String hostname) {
|
||||||
super(hostname);
|
super(hostname);
|
||||||
VelocityCore.get().getLogger().log(Level.INFO, "Added node " + hostname);
|
BungeeCore.get().getLogger().log(Level.INFO, "Added node " + hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -199,15 +207,15 @@ public abstract class Node {
|
|||||||
@Override
|
@Override
|
||||||
protected void calcLoadLimit() {
|
protected void calcLoadLimit() {
|
||||||
try {
|
try {
|
||||||
Process process = prepareExecution("cat /proc/meminfo").start();
|
Process process = prepareExecution("cat /proc/stat /proc/meminfo").start();
|
||||||
if(!process.waitFor(1, TimeUnit.SECONDS))
|
if(process.waitFor(1, TimeUnit.SECONDS))
|
||||||
throw new IOException(hostname + " timeout");
|
throw new IOException(hostname + " timeout");
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
||||||
calcLoadLimit(reader);
|
calcLoadLimit(reader, reader);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if(belowLoadLimit)
|
if(belowLoadLimit)
|
||||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could read remote load", e);
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could read remote load", e);
|
||||||
belowLoadLimit = false;
|
belowLoadLimit = false;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import de.steamwar.bungeecore.sql.EventFight;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
|
import de.steamwar.bungeecore.sql.Tutorial;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.sql.*;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
@ -13,22 +14,23 @@ import java.nio.file.Files;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BooleanSupplier;
|
import java.util.function.BooleanSupplier;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ServerStarter {
|
public class ServerStarter {
|
||||||
|
|
||||||
private static final Portrange BAU_PORTS = VelocityCore.MAIN_SERVER ? new Portrange(10100, 20000) : new Portrange(2100, 2200);
|
private static final Portrange BAU_PORTS = BungeeCore.MAIN_SERVER ? new Portrange(10100, 20000) : new Portrange(2100, 2200);
|
||||||
private static final Portrange ARENA_PORTS = VelocityCore.MAIN_SERVER ? new Portrange(3000, 3100) : (VelocityCore.EVENT_MODE ? new Portrange(4000, 5000) : BAU_PORTS);
|
private static final Portrange ARENA_PORTS = BungeeCore.MAIN_SERVER ? new Portrange(3000, 3100) : (BungeeCore.EVENT_MODE ? new Portrange(4000, 5000) : BAU_PORTS);
|
||||||
|
|
||||||
private static final String SERVER_PATH = "/servers/";
|
private static final String SERVER_PATH = "/servers/";
|
||||||
private static final String USER_HOME = System.getProperty("user.home") + "/";
|
private static final String USER_HOME = System.getProperty("user.home") + "/";
|
||||||
private static final String EVENT_PATH = USER_HOME + "event/";
|
private static final String EVENT_PATH = USER_HOME + "event/";
|
||||||
public static final String TEMP_WORLD_PATH = USER_HOME + "arenaserver/";
|
public static final String TEMP_WORLD_PATH = USER_HOME + "arenaserver/";
|
||||||
public static final String TUTORIAL_PATH = USER_HOME + "tutorials/";
|
public static final String TUTORIAL_PATH = USER_HOME + "tutorials/";
|
||||||
|
public static final String WORLDS12_PATH = USER_HOME + "userworlds/";
|
||||||
|
public static final String WORLDS15_PATH = USER_HOME + "userworlds15/";
|
||||||
|
public static final String WORLDS19_PATH = USER_HOME + "userworlds19/";
|
||||||
|
|
||||||
public static final String WORLDS_BASE_PATH = USER_HOME + "userworlds";
|
|
||||||
public static final String BUILDER_BASE_PATH = USER_HOME + "builder";
|
public static final String BUILDER_BASE_PATH = USER_HOME + "builder";
|
||||||
|
|
||||||
private File directory = null;
|
private File directory = null;
|
||||||
@ -46,11 +48,9 @@ public class ServerStarter {
|
|||||||
private boolean allowMerge = false;
|
private boolean allowMerge = false;
|
||||||
private String fightMap = null;
|
private String fightMap = null;
|
||||||
private String gameMode = null;
|
private String gameMode = null;
|
||||||
private boolean checkpoint = false;
|
private ServerConstructor constructor = (serverName, port, builder, shutdownCallback) -> new Arenaserver(serverName, gameMode, fightMap, allowMerge, port, builder, shutdownCallback);
|
||||||
private ServerConstructor constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Arenaserver(serverName, gameMode, fightMap, allowMerge, port, builder, shutdownCallback);
|
|
||||||
private Consumer<Subserver> callback = subserver -> {};
|
|
||||||
|
|
||||||
private final Set<Player> playersToSend = new HashSet<>();
|
private final Set<ProxiedPlayer> playersToSend = new HashSet<>();
|
||||||
private final Map<String, String> arguments = new HashMap<>();
|
private final Map<String, String> arguments = new HashMap<>();
|
||||||
|
|
||||||
public ServerStarter arena(ArenaMode mode, String map) {
|
public ServerStarter arena(ArenaMode mode, String map) {
|
||||||
@ -67,13 +67,13 @@ public class ServerStarter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter event(EventFight eventFight) {
|
public ServerStarter event(EventFight eventFight) {
|
||||||
arena(ArenaMode.getByInternal(eventFight.getSpielmodus()), eventFight.getMap());
|
arena(eventFight.getSpielmodus(), eventFight.getMap());
|
||||||
node = Node.LocalNode.getNode();
|
node = BungeeCore.local;
|
||||||
worldDir = EVENT_PATH;
|
worldDir = EVENT_PATH;
|
||||||
worldCleanup = () -> {};
|
worldCleanup = () -> {};
|
||||||
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
arguments.put("fightID", String.valueOf(eventFight.getFightID()));
|
||||||
fightMap = eventFight.getMap();
|
fightMap = eventFight.getMap();
|
||||||
gameMode = eventFight.getSpielmodus();
|
gameMode = eventFight.getSpielmodus().getInternalName();
|
||||||
|
|
||||||
String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel();
|
String serverName = Team.get(eventFight.getTeamBlue()).getTeamKuerzel() + " vs " + Team.get(eventFight.getTeamRed()).getTeamKuerzel();
|
||||||
serverNameProvider = port -> serverName;
|
serverNameProvider = port -> serverName;
|
||||||
@ -81,7 +81,7 @@ public class ServerStarter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter test(ArenaMode mode, String map, Player owner) {
|
public ServerStarter test(ArenaMode mode, String map, ProxiedPlayer owner) {
|
||||||
arena(mode, map);
|
arena(mode, map);
|
||||||
buildWithTemp(owner);
|
buildWithTemp(owner);
|
||||||
portrange = BAU_PORTS;
|
portrange = BAU_PORTS;
|
||||||
@ -89,12 +89,12 @@ public class ServerStarter {
|
|||||||
return send(owner);
|
return send(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter blueLeader(Player player) {
|
public ServerStarter blueLeader(ProxiedPlayer player) {
|
||||||
arguments.put("blueLeader", player.getUniqueId().toString());
|
arguments.put("blueLeader", player.getUniqueId().toString());
|
||||||
return send(player);
|
return send(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter redLeader(Player player) {
|
public ServerStarter redLeader(ProxiedPlayer player) {
|
||||||
arguments.put("redLeader", player.getUniqueId().toString());
|
arguments.put("redLeader", player.getUniqueId().toString());
|
||||||
return send(player);
|
return send(player);
|
||||||
}
|
}
|
||||||
@ -114,50 +114,38 @@ public class ServerStarter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter build(Version version, UUID owner) {
|
public ServerStarter build19(UUID owner) {
|
||||||
directory = version.getServerDirectory("Bau");
|
directory = new File(SERVER_PATH, "Bau19");
|
||||||
serverJar = version.getServerJar();
|
serverJar = "paper-1.19.2.jar";
|
||||||
worldDir = version.getWorldFolder(WORLDS_BASE_PATH);
|
worldDir = WORLDS19_PATH;
|
||||||
worldName = version != Version.SPIGOT_12 ? String.valueOf(SteamwarUser.get(owner).getId()) : owner.toString();
|
worldName = String.valueOf(SteamwarUser.get(owner).getId());
|
||||||
checkpoint = true;
|
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
||||||
|
|
||||||
build(owner);
|
|
||||||
|
|
||||||
worldSetup = () -> {
|
|
||||||
File world = new File(worldDir, worldName);
|
|
||||||
if (!world.exists())
|
|
||||||
copyWorld(node, new File(directory, "Bauwelt").getPath(), world.getPath());
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send players to existing server
|
|
||||||
startCondition = () -> {
|
|
||||||
Bauserver subserver = Bauserver.get(owner);
|
|
||||||
if(subserver != null) {
|
|
||||||
for(Player p : playersToSend)
|
|
||||||
SubserverSystem.sendPlayer(subserver, p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
boolean atLeastOneSupervisor = playersToSend.stream().anyMatch(player -> {
|
|
||||||
if (player.getUniqueId().equals(owner)) return true;
|
|
||||||
BauweltMember bauweltMember = BauweltMember.getBauMember(owner, player.getUniqueId());
|
|
||||||
return bauweltMember.isSupervisor();
|
|
||||||
});
|
|
||||||
if (!atLeastOneSupervisor) {
|
|
||||||
for (Player p : playersToSend) {
|
|
||||||
ChatSender.of(p).system("BAU_START_NOT_ALLOWED");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return atLeastOneSupervisor;
|
|
||||||
};
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter tutorial(Player owner, Tutorial tutorial) {
|
public ServerStarter build15(UUID owner) {
|
||||||
|
directory = new File(SERVER_PATH, "Bau15");
|
||||||
|
worldDir = WORLDS15_PATH;
|
||||||
|
worldName = String.valueOf(SteamwarUser.get(owner).getId());
|
||||||
|
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerStarter build12(UUID owner) {
|
||||||
|
directory = new File(SERVER_PATH, "Bau12");
|
||||||
|
serverJar = "spigot-1.12.2.jar";
|
||||||
|
xmx = "256M";
|
||||||
|
worldDir = WORLDS12_PATH;
|
||||||
|
worldName = owner.toString();
|
||||||
|
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerStarter tutorial(ProxiedPlayer owner, Tutorial tutorial) {
|
||||||
directory = new File(SERVER_PATH, "Tutorial");
|
directory = new File(SERVER_PATH, "Tutorial");
|
||||||
buildWithTemp(owner);
|
buildWithTemp(owner);
|
||||||
tempWorld(TUTORIAL_PATH + tutorial.getTutorialId());
|
tempWorld(TUTORIAL_PATH + tutorial.id());
|
||||||
arguments.put("tutorial", String.valueOf(tutorial.getTutorialId()));
|
arguments.put("tutorial", String.valueOf(tutorial.id()));
|
||||||
return send(owner);
|
return send(owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +155,29 @@ public class ServerStarter {
|
|||||||
worldCleanup = () -> SubserverSystem.deleteFolder(node, worldDir + worldName);
|
worldCleanup = () -> SubserverSystem.deleteFolder(node, worldDir + worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildWithTemp(Player owner) {
|
private void buildWithWorld(UUID owner, String prototype) {
|
||||||
|
build(owner);
|
||||||
|
|
||||||
|
worldSetup = () -> {
|
||||||
|
File world = new File(worldDir, worldName);
|
||||||
|
if (!world.exists())
|
||||||
|
copyWorld(node, prototype, world.getPath());
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send players to existing server
|
||||||
|
startCondition = () -> {
|
||||||
|
for(Subserver subserver : Subserver.getServerList()) {
|
||||||
|
if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)) {
|
||||||
|
for(ProxiedPlayer p : playersToSend)
|
||||||
|
SubserverSystem.sendPlayer(subserver, p);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildWithTemp(ProxiedPlayer owner) {
|
||||||
build(owner.getUniqueId());
|
build(owner.getUniqueId());
|
||||||
|
|
||||||
// Stop existing build server
|
// Stop existing build server
|
||||||
@ -175,16 +185,19 @@ public class ServerStarter {
|
|||||||
if(startingBau(owner))
|
if(startingBau(owner))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Bauserver subserver = Bauserver.get(owner.getUniqueId());
|
for (Subserver subserver : Subserver.getServerList()) {
|
||||||
if(subserver != null && subserver.isStarted())
|
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(owner.getUniqueId()) && subserver.hasStarted()) {
|
||||||
subserver.stop();
|
subserver.stop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return !startingBau(owner);
|
return !startingBau(owner);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void build(UUID owner) {
|
private void build(UUID owner) {
|
||||||
constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Bauserver(serverName, owner, port, builder, shutdownCallback, failureCallback);
|
constructor = (serverName, port, builder, shutdownCallback) -> new Bauserver(serverName, owner, port, builder, shutdownCallback);
|
||||||
serverNameProvider = port -> bauServerName(SteamwarUser.get(owner));
|
serverNameProvider = port -> bauServerName(SteamwarUser.get(owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,16 +207,16 @@ public class ServerStarter {
|
|||||||
worldDir = version.getWorldFolder(BUILDER_BASE_PATH);
|
worldDir = version.getWorldFolder(BUILDER_BASE_PATH);
|
||||||
worldName = map;
|
worldName = map;
|
||||||
serverNameProvider = port -> "⛏" + map;
|
serverNameProvider = port -> "⛏" + map;
|
||||||
checkpoint = true;
|
constructor = (serverName, port, builder, shutdownCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback);
|
||||||
constructor = (serverName, port, builder, shutdownCallback, failureCallback) -> new Builderserver(serverName, worldName, port, builder, shutdownCallback, failureCallback);
|
|
||||||
|
|
||||||
// Send players to existing server
|
// Send players to existing server
|
||||||
startCondition = () -> {
|
startCondition = () -> {
|
||||||
Builderserver subserver = Builderserver.get(worldName);
|
for(Subserver subserver : Subserver.getServerList()) {
|
||||||
if (subserver != null) {
|
if(subserver.getType() == Servertype.BUILDER && ((Builderserver)subserver).getMap().equals(worldName)) {
|
||||||
for(Player p : playersToSend)
|
for(ProxiedPlayer p : playersToSend)
|
||||||
SubserverSystem.sendPlayer(subserver, p);
|
SubserverSystem.sendPlayer(subserver, p);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@ -222,19 +235,14 @@ public class ServerStarter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter send(Player player) {
|
public ServerStarter send(ProxiedPlayer player) {
|
||||||
playersToSend.add(player);
|
playersToSend.add(player);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter callback(Consumer<Subserver> callback) {
|
public Subserver start() {
|
||||||
this.callback = callback;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean start() {
|
|
||||||
if(!startCondition.getAsBoolean())
|
if(!startCondition.getAsBoolean())
|
||||||
return false;
|
return null;
|
||||||
|
|
||||||
int port = portrange.freePort();
|
int port = portrange.freePort();
|
||||||
String serverName = serverNameProvider.apply(port);
|
String serverName = serverNameProvider.apply(port);
|
||||||
@ -242,10 +250,10 @@ public class ServerStarter {
|
|||||||
if(node == null) {
|
if(node == null) {
|
||||||
node = Node.getNode();
|
node = Node.getNode();
|
||||||
if(node == null) {
|
if(node == null) {
|
||||||
for (Player p : playersToSend)
|
for (ProxiedPlayer p : playersToSend)
|
||||||
ChatSender.of(p).system("SERVER_START_OVERLOAD");
|
ChatSender.of(p).system("SERVER_START_OVERLOAD");
|
||||||
|
|
||||||
return false;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(worldName == null)
|
if(worldName == null)
|
||||||
@ -254,45 +262,22 @@ public class ServerStarter {
|
|||||||
worldSetup.run();
|
worldSetup.run();
|
||||||
arguments.put("logPath", worldName);
|
arguments.put("logPath", worldName);
|
||||||
|
|
||||||
File checkpointDir = new File("/tmp/" + System.getProperty("user.name") + ".checkpoints/" + directory.getName() + "/" + worldName);
|
Subserver subserver = constructor.construct(serverName, port, node.startServer(
|
||||||
if(checkpoint)
|
|
||||||
arguments.put("checkpoint", checkpointDir.getPath());
|
|
||||||
|
|
||||||
if(checkpoint && checkpointDir.exists()) {
|
|
||||||
try {
|
|
||||||
new DataOutputStream(Files.newOutputStream(new File(checkpointDir, "port").toPath())).writeInt(port);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
postStart(constructor.construct(serverName, port, node.prepareExecution(
|
|
||||||
"criu", "restore", "-D", checkpointDir.getPath(), "--auto-dedup", "--shell-job", "-v"
|
|
||||||
), worldCleanup, e -> regularStart(serverName, port)));
|
|
||||||
} else {
|
|
||||||
regularStart(serverName, port);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void regularStart(String serverName, int port) {
|
|
||||||
postStart(constructor.construct(serverName, port, node.startServer(
|
|
||||||
serverJar, directory, worldDir, worldName, port, xmx, arguments.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new)
|
serverJar, directory, worldDir, worldName, port, xmx, arguments.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).toArray(String[]::new)
|
||||||
), worldCleanup, null));
|
), worldCleanup);
|
||||||
}
|
|
||||||
|
|
||||||
private void postStart(Subserver subserver) {
|
for(ProxiedPlayer p : playersToSend)
|
||||||
for(Player p : playersToSend)
|
|
||||||
SubserverSystem.sendPlayer(subserver, p);
|
SubserverSystem.sendPlayer(subserver, p);
|
||||||
|
|
||||||
callback.accept(subserver);
|
return subserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean startingBau(Player p) {
|
private static boolean startingBau(ProxiedPlayer p) {
|
||||||
Bauserver subserver = Bauserver.get(p.getUniqueId());
|
for (Subserver subserver : Subserver.getServerList()) {
|
||||||
if(subserver != null && !subserver.isStarted()) {
|
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(p.getUniqueId()) && !subserver.hasStarted()) {
|
||||||
ChatSender.of(p).system("BAU_START_ALREADY");
|
Message.send("BAU_START_ALREADY", p);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -310,7 +295,7 @@ public class ServerStarter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private interface ServerConstructor {
|
private interface ServerConstructor {
|
||||||
Subserver construct(String serverName, int port, ProcessBuilder builder, Runnable shutdownCallback, Consumer<Exception> failureCallback);
|
Subserver construct(String serverName, int port, ProcessBuilder builder, Runnable shutdownCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Portrange {
|
private static class Portrange {
|
||||||
@ -349,12 +334,10 @@ public class ServerStarter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
|
||||||
public enum Version {
|
public enum Version {
|
||||||
SPIGOT_12("spigot-1.12.2.jar", 12),
|
SPIGOT_12("spigot-1.12.2.jar", 12),
|
||||||
SPIGOT_15("spigot-1.15.2.jar", 15),
|
SPIGOT_15("spigot-1.15.2.jar", 15),
|
||||||
PAPER_19("paper-1.19.3.jar", 19),
|
PAPER_19("paper-1.19.2.jar", 19);
|
||||||
PAPER_20("paper-1.20.1.jar", 20);
|
|
||||||
|
|
||||||
private final String serverJar;
|
private final String serverJar;
|
||||||
private final int versionSuffix;
|
private final int versionSuffix;
|
||||||
@ -364,6 +347,10 @@ public class ServerStarter {
|
|||||||
this.versionSuffix = versionSuffix;
|
this.versionSuffix = versionSuffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getServerJar() {
|
||||||
|
return serverJar;
|
||||||
|
}
|
||||||
|
|
||||||
public String getWorldFolder(String base) {
|
public String getWorldFolder(String base) {
|
||||||
return base + versionSuffix + "/";
|
return base + versionSuffix + "/";
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,14 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
|
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.network.packets.server.StartingServerPacket;
|
import de.steamwar.network.packets.server.StartingServerPacket;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -36,26 +37,23 @@ public class SubserverSystem {
|
|||||||
node.execute("rm", "-r", worldName);
|
node.execute("rm", "-r", worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendDeniedMessage(Player p, UUID owner){
|
public static void sendDeniedMessage(ProxiedPlayer p, UUID owner){
|
||||||
Player o = VelocityCore.get().getProxyServer().getPlayer(owner).orElse(null);
|
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
|
||||||
|
if(o == null)
|
||||||
if(o == null){
|
|
||||||
return;
|
return;
|
||||||
}
|
if(IgnoreSystem.isIgnored(o, p)){
|
||||||
|
|
||||||
if(IgnoreSystem.isIgnored(owner, p.getUniqueId())){
|
|
||||||
Message.send("SERVER_IGNORED", p);
|
Message.send("SERVER_IGNORED", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message.send("SERVER_ADD_MEMBER", o, p.getUsername());
|
Message.send("SERVER_ADD_MEMBER", o, p.getName());
|
||||||
Message.sendPrefixless("SERVER_ADD_MESSAGE", o, Message.parse("SERVER_ADD_MESSAGE_HOVER", o, p.getUsername()),
|
Message.sendPrefixless("SERVER_ADD_MESSAGE", o, Message.parse("SERVER_ADD_MESSAGE_HOVER", o, p.getName()),
|
||||||
ClickEvent.runCommand("/bau addmember " + p.getUsername()));
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendPlayer(Subserver subserver, Player player) {
|
public static void sendPlayer(Subserver subserver, ProxiedPlayer player) {
|
||||||
subserver.sendPlayer(player);
|
subserver.sendPlayer(player);
|
||||||
if(!subserver.isStarted() && FightInfoHandler.onLobby(player))
|
if(!subserver.hasStarted() && FightInfoHandler.onLobby(player))
|
||||||
NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot;
|
package de.steamwar.bungeecore.bot;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
import net.dv8tion.jda.api.entities.Emoji;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
@ -46,8 +46,8 @@ public class AuthManager {
|
|||||||
String code = Base64.getEncoder().encodeToString(randBytes);
|
String code = Base64.getEncoder().encodeToString(randBytes);
|
||||||
|
|
||||||
TOKENS.put(code, member.getIdLong());
|
TOKENS.put(code, member.getIdLong());
|
||||||
VelocityCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
|
BungeeCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
|
||||||
VelocityCore.get().getProxy().getScheduler().schedule(VelocityCore.get(), () -> TOKENS.remove(code), 10, TimeUnit.MINUTES);
|
BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> TOKENS.remove(code), 10, TimeUnit.MINUTES);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot;
|
package de.steamwar.bungeecore.bot;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.bot.commands.*;
|
import de.steamwar.bungeecore.bot.commands.*;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.bot.events.EventManager;
|
import de.steamwar.bungeecore.bot.events.EventManager;
|
||||||
@ -28,8 +28,8 @@ import de.steamwar.bungeecore.bot.listeners.*;
|
|||||||
import de.steamwar.bungeecore.bot.util.DiscordRolesMessage;
|
import de.steamwar.bungeecore.bot.util.DiscordRolesMessage;
|
||||||
import de.steamwar.bungeecore.bot.util.DiscordRulesMessage;
|
import de.steamwar.bungeecore.bot.util.DiscordRulesMessage;
|
||||||
import de.steamwar.bungeecore.bot.util.DiscordTicketMessage;
|
import de.steamwar.bungeecore.bot.util.DiscordTicketMessage;
|
||||||
|
import de.steamwar.bungeecore.sql.Event;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.sql.Event;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
@ -81,7 +81,7 @@ public class SteamwarDiscordBot {
|
|||||||
} catch (LoginException e) {
|
} catch (LoginException e) {
|
||||||
throw new SecurityException("Could not Login: " + SteamwarDiscordBotConfig.TOKEN, e);
|
throw new SecurityException("Could not Login: " + SteamwarDiscordBotConfig.TOKEN, e);
|
||||||
}
|
}
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
try {
|
try {
|
||||||
jda.awaitReady();
|
jda.awaitReady();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -90,11 +90,11 @@ public class SteamwarDiscordBot {
|
|||||||
try {
|
try {
|
||||||
activity();
|
activity();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not set initial activity to discord", e);
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not set initial activity to discord", e);
|
||||||
}
|
}
|
||||||
EventManager.update();
|
EventManager.update();
|
||||||
SchematicsManager.update();
|
SchematicsManager.update();
|
||||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
try {
|
try {
|
||||||
activity();
|
activity();
|
||||||
EventManager.update();
|
EventManager.update();
|
||||||
@ -148,7 +148,7 @@ public class SteamwarDiscordBot {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
int count = VelocityCore.get().getProxy().getOnlineCount();
|
int count = BungeeCore.get().getProxy().getOnlineCount();
|
||||||
if (count == 1) {
|
if (count == 1) {
|
||||||
jda.getPresence().setActivity(Activity.playing("mit 1 Spieler"));
|
jda.getPresence().setActivity(Activity.playing("mit 1 Spieler"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,7 +21,8 @@ package de.steamwar.bungeecore.bot.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
|
|
||||||
@ -44,7 +45,7 @@ public class BanCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
@ -59,7 +60,7 @@ public class BanCommand extends BasicDiscordCommand {
|
|||||||
String msg = event.getOption("reason").getAsString();
|
String msg = event.getOption("reason").getAsString();
|
||||||
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
boolean isPerma = event.getOption("time").getAsString().equals("perma");
|
||||||
|
|
||||||
PunishmentCommand.ban(target, time, msg, sender, isPerma);
|
target.punish(Punishment.PunishmentType.Ban, time, msg, sender.getId(), isPerma);
|
||||||
Message.team("BAN_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
|
Message.team("BAN_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
|
||||||
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
|
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.bungeecore.sql.UserGroup;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
@ -45,7 +45,7 @@ public abstract class BasicDiscordCommand extends CommandData {
|
|||||||
protected boolean testPermission(SlashCommandEvent event) {
|
protected boolean testPermission(SlashCommandEvent event) {
|
||||||
Member member = event.getMember();
|
Member member = event.getMember();
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
||||||
if (steamwarUser == null || (!steamwarUser.hasPerm(UserPerm.TEAM))) {
|
if (steamwarUser == null || (!steamwarUser.getUserGroup().isTeamGroup() && steamwarUser.getUserGroup() != UserGroup.Builder)) {
|
||||||
event.reply("Du hast für " + event.getName() + " keine Rechte oder es existiert keine Verknüpfung für dich.").setEphemeral(true).queue();
|
event.reply("Du hast für " + event.getName() + " keine Rechte oder es existiert keine Verknüpfung für dich.").setEphemeral(true).queue();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.bot.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class MuteCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
event.reply("Angegebener User invalide").setEphemeral(true).complete();
|
event.reply("Angegebener User invalide").setEphemeral(true).complete();
|
||||||
return;
|
return;
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.bungeecore.sql.Event;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import de.steamwar.sql.TeamTeilnahme;
|
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Emoji;
|
import net.dv8tion.jda.api.entities.Emoji;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
@ -91,6 +91,6 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isOnline(SteamwarUser user) {
|
private boolean isOnline(SteamwarUser user) {
|
||||||
return ProxyServer.getInstance().getPlayer(user.getUUID()) != null;
|
return ProxyServer.getInstance().getPlayer(user.getUuid()) != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.sql.BannedUserIPs;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.Punishment;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
|
|
||||||
@ -44,7 +42,7 @@ public class UnbanCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||||
SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
@ -56,7 +54,6 @@ public class UnbanCommand extends BasicDiscordCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
target.punish(Punishment.PunishmentType.Ban, Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
|
target.punish(Punishment.PunishmentType.Ban, Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
|
||||||
BannedUserIPs.unbanIPs(target.getId());
|
|
||||||
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
|
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
@ -72,7 +72,7 @@ public class WhoisCommand extends BasicDiscordCommand {
|
|||||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
embedBuilder.setTitle("Whois: " + user.getUserName());
|
embedBuilder.setTitle("Whois: " + user.getUserName());
|
||||||
StringBuilder st = new StringBuilder();
|
StringBuilder st = new StringBuilder();
|
||||||
st.append("UUID: ").append(user.getUUID()).append("\n");
|
st.append("UUID: ").append(user.getUuid()).append("\n");
|
||||||
st.append("ID: ").append(user.getId()).append("\n");
|
st.append("ID: ").append(user.getId()).append("\n");
|
||||||
if (user.getDiscordId() != null) {
|
if (user.getDiscordId() != null) {
|
||||||
st.append("DiscordID: ").append(user.getDiscordId()).append("\n");
|
st.append("DiscordID: ").append(user.getDiscordId()).append("\n");
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.config;
|
package de.steamwar.bungeecore.bot.config;
|
||||||
|
|
||||||
import de.steamwar.sql.UserPerm;
|
import de.steamwar.bungeecore.sql.UserGroup;
|
||||||
import net.md_5.bungee.config.Configuration;
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -52,7 +52,7 @@ public class SteamwarDiscordBotConfig {
|
|||||||
public static String TICKET_CREATED;
|
public static String TICKET_CREATED;
|
||||||
public static String TICKET_LOG;
|
public static String TICKET_LOG;
|
||||||
public static Map<String, DiscordTicketType> TICKET_TYPES;
|
public static Map<String, DiscordTicketType> TICKET_TYPES;
|
||||||
public static Map<UserPerm, String> RANKS;
|
public static Map<UserGroup, String> RANKS;
|
||||||
|
|
||||||
public static void loadConfig(Configuration config) {
|
public static void loadConfig(Configuration config) {
|
||||||
TOKEN = config.getString("token");
|
TOKEN = config.getString("token");
|
||||||
@ -109,7 +109,7 @@ public class SteamwarDiscordBotConfig {
|
|||||||
RANKS = new HashMap<>();
|
RANKS = new HashMap<>();
|
||||||
Configuration ranksSections = config.getSection("ranks");
|
Configuration ranksSections = config.getSection("ranks");
|
||||||
for (String type : ranksSections.getKeys()) {
|
for (String type : ranksSections.getKeys()) {
|
||||||
RANKS.put(UserPerm.valueOf(type.toUpperCase()), ranksSections.getString(type));
|
RANKS.put(UserGroup.getUsergroup(type), ranksSections.getString(type));
|
||||||
}
|
}
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,10 @@ package de.steamwar.bungeecore.bot.events;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.bungeecore.sql.Event;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.bungeecore.sql.EventFight;
|
||||||
import de.steamwar.sql.TeamTeilnahme;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
|
@ -22,7 +22,7 @@ package de.steamwar.bungeecore.bot.events;
|
|||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.bot.AuthManager;
|
import de.steamwar.bungeecore.bot.AuthManager;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.entities.ChannelType;
|
import net.dv8tion.jda.api.entities.ChannelType;
|
||||||
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
|
||||||
import net.dv8tion.jda.api.interactions.InteractionType;
|
import net.dv8tion.jda.api.interactions.InteractionType;
|
||||||
|
@ -22,8 +22,8 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -21,10 +21,10 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.bot.events.EventManager;
|
import de.steamwar.bungeecore.bot.events.EventManager;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.Event;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.TeamTeilnahme;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||||
import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
|
import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
|
||||||
import net.dv8tion.jda.api.interactions.components.Component;
|
import net.dv8tion.jda.api.interactions.components.Component;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -19,12 +19,11 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.listeners;
|
package de.steamwar.bungeecore.bot.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserPerm;
|
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
@ -137,15 +136,15 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
|||||||
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
|
||||||
if(event.getChannel().getParent() != null && event.getChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
|
if(event.getChannel().getParent() != null && event.getChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
|
||||||
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
|
if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
|
||||||
VelocityCore.get().getProxy().getPlayers().forEach(player -> {
|
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
||||||
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player);
|
||||||
boolean sendMessage;
|
boolean sendMessage;
|
||||||
if(user.getDiscordId() == null) {
|
if(user.getDiscordId() == null) {
|
||||||
sendMessage = user.hasPerm(UserPerm.CHECK);
|
sendMessage = user.getUserGroup().isCheckSchematics();
|
||||||
} else {
|
} else {
|
||||||
if(event.getAuthor().getId().equals(user.getDiscordId())) return;
|
if(event.getAuthor().getId().equals(user.getDiscordId())) return;
|
||||||
sendMessage = user.getDiscordId().equals(event.getChannel().getTopic()) || user.hasPerm(UserPerm.CHECK);
|
sendMessage = user.getDiscordId().equals(event.getChannel().getTopic()) || user.getUserGroup().isCheckSchematics();
|
||||||
}
|
}
|
||||||
if(sendMessage) {
|
if(sendMessage) {
|
||||||
Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw());
|
Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw());
|
||||||
|
@ -18,15 +18,15 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.listeners;
|
package de.steamwar.bungeecore.bot.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.sql.NodeData;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
import net.dv8tion.jda.api.entities.Message;
|
||||||
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class PrivateMessageListener extends BasicDiscordListener {
|
public class PrivateMessageListener extends BasicDiscordListener {
|
||||||
|
|
||||||
@ -60,19 +60,19 @@ public class PrivateMessageListener extends BasicDiscordListener {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SchematicNode node = SchematicNode.getSchematicNode(user.getId(), name, (Integer) null);
|
SchematicNode node = SchematicNode.getSchematicNode(user.getId(), name, 0);
|
||||||
if(node == null) {
|
if(node == null) {
|
||||||
node = SchematicNode.createSchematic(user.getId(), name, null);
|
node = SchematicNode.createSchematic(user.getId(), name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InputStream in = attachment.retrieveInputStream().get();
|
InputStream in = attachment.retrieveInputStream().get();
|
||||||
NodeData.get(node).saveFromStream(in, newFormat);
|
node.saveFromStream(in, newFormat);
|
||||||
in.close();
|
in.close();
|
||||||
event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
|
event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
event.getMessage().reply("`" + name + "` konnte nicht hochgeladen werden, bitte versuche es später nochmal oder wende dich an einen Developer").queue();
|
event.getMessage().reply("`" + name + "` konnte nicht hochgeladen werden, bitte versuche es später nochmal oder wende dich an einen Developer").queue();
|
||||||
VelocityCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"", e);
|
BungeeCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"" + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.util;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
@ -42,7 +42,7 @@ public class DiscordRanks {
|
|||||||
guild.retrieveMemberById(steamwarUser.getDiscordId()).queue(member -> {
|
guild.retrieveMemberById(steamwarUser.getDiscordId()).queue(member -> {
|
||||||
List<Role> roleList = member.getRoles();
|
List<Role> roleList = member.getRoles();
|
||||||
Set<String> strings = new HashSet<>(SteamwarDiscordBotConfig.RANKS.values());
|
Set<String> strings = new HashSet<>(SteamwarDiscordBotConfig.RANKS.values());
|
||||||
String needed = SteamwarDiscordBotConfig.RANKS.get(steamwarUser.prefix());
|
String needed = SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup());
|
||||||
for (Role role : roleList) {
|
for (Role role : roleList) {
|
||||||
if (!strings.contains(role.getId())) {
|
if (!strings.contains(role.getId())) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.bot.util;
|
package de.steamwar.bungeecore.bot.util;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
|
@ -21,7 +21,6 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -30,7 +29,7 @@ import net.md_5.bungee.api.CommandSender;
|
|||||||
public class AlertCommand extends SWCommand {
|
public class AlertCommand extends SWCommand {
|
||||||
|
|
||||||
public AlertCommand() {
|
public AlertCommand() {
|
||||||
super("alert", ConnectionListener.ALERT_PERMISSION, "broadcast", "bbc");
|
super("alert", "bungeecore.alert", "broadcast", "bbc");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "USAGE_ALERT")
|
@Register(description = "USAGE_ALERT")
|
||||||
|
69
src/de/steamwar/bungeecore/commands/BasicCommand.java
Normale Datei
69
src/de/steamwar/bungeecore/commands/BasicCommand.java
Normale Datei
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
|
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
abstract class BasicCommand extends Command implements TabExecutor {
|
||||||
|
|
||||||
|
public BasicCommand(String name, String permission, String... aliases) {
|
||||||
|
super(name, permission, aliases);
|
||||||
|
BungeeCore.commands.put("/" + name, permission);
|
||||||
|
ProxyServer.getInstance().getPluginManager().registerCommand(BungeeCore.get(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterable<String> allPlayers(String begin) {
|
||||||
|
List<String> suggestions = new ArrayList<>();
|
||||||
|
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
||||||
|
String playerName = player.getName();
|
||||||
|
if(playerName.startsWith(begin))
|
||||||
|
suggestions.add(playerName);
|
||||||
|
}
|
||||||
|
return suggestions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SteamwarUser existingUser(CommandSender sender, String arg){
|
||||||
|
SteamwarUser target = SteamwarUser.get(arg);
|
||||||
|
if(target == null)
|
||||||
|
Message.send("UNKNOWN_PLAYER", sender);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
||||||
|
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg);
|
||||||
|
if(target == null)
|
||||||
|
Message.send("UNKNOWN_PLAYER", sender);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
}
|
@ -23,84 +23,89 @@ import de.steamwar.bungeecore.*;
|
|||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.util.BauLock;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.bungeecore.util.BauLockState;
|
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.command.PreviousArguments;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||||
import de.steamwar.sql.BauweltMember;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class BauCommand extends SWCommand {
|
public class BauCommand extends SWCommand {
|
||||||
|
|
||||||
private final HelpCommand command;
|
public BauCommand(){
|
||||||
|
|
||||||
public BauCommand(HelpCommand command){
|
|
||||||
super("bau", null, "b", "build", "gs");
|
super("bau", null, "b", "build", "gs");
|
||||||
this.command = command;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(noTabComplete = true)
|
@Register(help = true)
|
||||||
public void genericHelp(ProxiedPlayer p, String... args) {
|
public void genericHelp(ProxiedPlayer p, String... args) {
|
||||||
this.command.sendBauHelp(p);
|
HelpCommand.sendBauHelp(ChatSender.of(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void toBau(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
public void toBau(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||||
new ServerStarter().build(version, p.getUniqueId()).send(p).start();
|
versionSelector(version,
|
||||||
|
() -> new ServerStarter().build12(p.getUniqueId()).send(p).start(),
|
||||||
|
() -> new ServerStarter().build15(p.getUniqueId()).send(p).start(),
|
||||||
|
() -> new ServerStarter().build19(p.getUniqueId()).send(p).start()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void versionSelector(int version, Runnable r12, Runnable r15, Runnable r19) {
|
||||||
|
switch (version) {
|
||||||
|
case 12:
|
||||||
|
r12.run();
|
||||||
|
break;
|
||||||
|
case 15:
|
||||||
|
r15.run();
|
||||||
|
break;
|
||||||
|
case 19:
|
||||||
|
r19.run();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper(value = "version", local = true)
|
@Mapper(value = "version", local = true)
|
||||||
public TypeMapper<ServerStarter.Version> versionMapper() {
|
public TypeMapper<Integer> versionMapper() {
|
||||||
Map<String, ServerStarter.Version> versionMap = new HashMap<>();
|
Map<String, Integer> versionMap = new HashMap<>();
|
||||||
versionMap.put("20", ServerStarter.Version.PAPER_20);
|
versionMap.put("19", 19);
|
||||||
versionMap.put("1.20", ServerStarter.Version.PAPER_20);
|
versionMap.put("1.19", 19);
|
||||||
versionMap.put("as", ServerStarter.Version.PAPER_20);
|
versionMap.put("mwg", 19);
|
||||||
versionMap.put("airship", ServerStarter.Version.PAPER_20);
|
versionMap.put("miniwargear", 19);
|
||||||
versionMap.put("wg", ServerStarter.Version.PAPER_20);
|
versionMap.put("wg", 19);
|
||||||
versionMap.put("wargear", ServerStarter.Version.PAPER_20);
|
versionMap.put("wargear", 19);
|
||||||
versionMap.put("ws", ServerStarter.Version.PAPER_20);
|
versionMap.put("ws", 15);
|
||||||
versionMap.put("warship", ServerStarter.Version.PAPER_20);
|
|
||||||
|
|
||||||
versionMap.put("19", ServerStarter.Version.PAPER_19);
|
versionMap.put("15", 15);
|
||||||
versionMap.put("1.19", ServerStarter.Version.PAPER_19);
|
versionMap.put("1.15", 15);
|
||||||
versionMap.put("mwg", ServerStarter.Version.PAPER_19);
|
versionMap.put("warship", 15);
|
||||||
versionMap.put("miniwargear", ServerStarter.Version.PAPER_19);
|
versionMap.put("as", 15);
|
||||||
|
versionMap.put("airship", 15);
|
||||||
|
|
||||||
versionMap.put("15", ServerStarter.Version.SPIGOT_15);
|
versionMap.put("12", 12);
|
||||||
versionMap.put("1.15", ServerStarter.Version.SPIGOT_15);
|
versionMap.put("1.12", 12);
|
||||||
|
|
||||||
versionMap.put("12", ServerStarter.Version.SPIGOT_12);
|
return new TypeMapper<Integer>() {
|
||||||
versionMap.put("1.12", ServerStarter.Version.SPIGOT_12);
|
|
||||||
|
|
||||||
return new TypeMapper<ServerStarter.Version>() {
|
|
||||||
@Override
|
@Override
|
||||||
public ServerStarter.Version map(CommandSender commandSender, String[] previousArguments, String s) {
|
public Integer map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
if (commandSender == null) return null;
|
if (commandSender == null) return null;
|
||||||
ProxiedPlayer player = (ProxiedPlayer) commandSender;
|
ProxiedPlayer player = (ProxiedPlayer) commandSender;
|
||||||
if (s.isEmpty()) {
|
if (s.isEmpty()) {
|
||||||
int version = player.getPendingConnection().getVersion();
|
int version = player.getPendingConnection().getVersion();
|
||||||
if (version > 762) { // Version > 1.19.4
|
if (version > 578) { // Version > 1.15.2
|
||||||
return ServerStarter.Version.PAPER_20;
|
return 19;
|
||||||
} else if (version > 578) { // Version > 1.15.2
|
|
||||||
return ServerStarter.Version.PAPER_19;
|
|
||||||
} else if (version > 340) { // Version > 1.12.2
|
} else if (version > 340) { // Version > 1.12.2
|
||||||
return ServerStarter.Version.SPIGOT_15;
|
return 15;
|
||||||
} else {
|
} else {
|
||||||
return ServerStarter.Version.SPIGOT_12;
|
return 12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return versionMap.get(s.toLowerCase());
|
return versionMap.get(s.toLowerCase());
|
||||||
@ -115,10 +120,10 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE")
|
@Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE")
|
||||||
public void addmember(ProxiedPlayer p, @Validator("addMemberTarget") SteamwarUser target) {
|
public void addmember(ProxiedPlayer p, @Validator("addMemberTarget") SteamwarUser target) {
|
||||||
BauweltMember.addMember(p.getUniqueId(), target.getUUID());
|
new BauweltMember(p.getUniqueId(), target.getUuid(), false, false);
|
||||||
Message.send("BAU_ADDMEMBER_ADDED", p);
|
Message.send("BAU_ADDMEMBER_ADDED", p);
|
||||||
|
|
||||||
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUUID());
|
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(target.getUuid());
|
||||||
if(z != null)
|
if(z != null)
|
||||||
Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName());
|
Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName());
|
||||||
}
|
}
|
||||||
@ -130,11 +135,11 @@ public class BauCommand extends SWCommand {
|
|||||||
messageSender.send("UNKNOWN_PLAYER");
|
messageSender.send("UNKNOWN_PLAYER");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUUID())) {
|
if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUuid())) {
|
||||||
messageSender.send("BAU_ADDMEMBER_SELFADD");
|
messageSender.send("BAU_ADDMEMBER_SELFADD");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUUID()) != null) {
|
if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUuid()) != null) {
|
||||||
messageSender.send("BAU_ADDMEMBER_ISADDED");
|
messageSender.send("BAU_ADDMEMBER_ISADDED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -144,8 +149,12 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(value = "tp", description = "BAU_TP_USAGE")
|
@Register(value = "tp", description = "BAU_TP_USAGE")
|
||||||
@Register("teleport")
|
@Register("teleport")
|
||||||
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||||
new ServerStarter().build(version, worldOwner.getUUID()).send(p).start();
|
versionSelector(version,
|
||||||
|
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
|
||||||
|
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
|
||||||
|
() -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validator(value = "teleportTarget", local = true)
|
@Validator(value = "teleportTarget", local = true)
|
||||||
@ -156,12 +165,16 @@ public class BauCommand extends SWCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ProxiedPlayer p = (ProxiedPlayer) sender;
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
if (!p.getUniqueId().equals(value.getUUID()) && BauweltMember.getBauMember(value.getUUID(), p.getUniqueId()) == null) {
|
if (!p.getUniqueId().equals(value.getUuid()) && BauweltMember.getBauMember(value.getUuid(), p.getUniqueId()) == null) {
|
||||||
SubserverSystem.sendDeniedMessage(p, value.getUUID());
|
SubserverSystem.sendDeniedMessage(p, value.getUuid());
|
||||||
messageSender.send("BAU_TP_NOALLOWED");
|
messageSender.send("BAU_TP_NOALLOWED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !BauLock.checkNotifyLocked(value, p);
|
if(BauLock.isLocked(value, SteamwarUser.get(p))) {
|
||||||
|
messageSender.send("BAU_LOCKED_NOALLOWED");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,52 +183,34 @@ public class BauCommand extends SWCommand {
|
|||||||
Chat19.chat(p, "/bauinfo");
|
Chat19.chat(p, "/bauinfo");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("setspectator")
|
@Register("togglewe")
|
||||||
public void setSpectator(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
public void togglewe(ProxiedPlayer p, @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
Message.send("BAU_MEMBER_SET_USAGE", p, "setspectator");
|
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "togglewe");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BauweltMember target = member(p, user);
|
BauweltMember target = member(p, user);
|
||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
target.setBuild(false);
|
target.setWorldEdit(!target.isWorldEdit());
|
||||||
target.setSupervisor(false);
|
|
||||||
clearMembercache(p);
|
clearMembercache(p);
|
||||||
sendPermissionUpdate(p, target, "BAU_MEMBER_SET_SPECTATOR");
|
isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("setbuild")
|
@Register("toggleworld")
|
||||||
public void setBuild(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
public void toggleworld(ProxiedPlayer p, @AllowNull @OptionalValue("") SteamwarUser user) {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
Message.send("BAU_MEMBER_SET_USAGE", p, "setbuild");
|
Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleworld");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BauweltMember target = member(p, user);
|
BauweltMember target = member(p, user);
|
||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
target.setBuild(true);
|
target.setWorld(!target.isWorld());
|
||||||
target.setSupervisor(false);
|
|
||||||
clearMembercache(p);
|
clearMembercache(p);
|
||||||
sendPermissionUpdate(p, target, "BAU_MEMBER_SET_BUILDER");
|
isAllowedTo(target.isWorld(), p, target, "BAU_MEMBER_TOGGLE_WORLD");
|
||||||
}
|
|
||||||
|
|
||||||
@Register("setsupervisor")
|
|
||||||
public void setSupervisor(ProxiedPlayer p, @Mapper("addedUsers") @AllowNull @OptionalValue("") SteamwarUser user) {
|
|
||||||
if (user == null) {
|
|
||||||
Message.send("BAU_MEMBER_SET_USAGE", p, "setsupervisor");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
BauweltMember target = member(p, user);
|
|
||||||
if (target == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
target.setBuild(true);
|
|
||||||
target.setSupervisor(true);
|
|
||||||
clearMembercache(p);
|
|
||||||
sendPermissionUpdate(p, target, "BAU_MEMBER_SET_SUPERVISOR");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void clearMembercache(ProxiedPlayer p){
|
private static void clearMembercache(ProxiedPlayer p){
|
||||||
@ -229,51 +224,37 @@ public class BauCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "delmember", description = "BAU_DELMEMBER_USAGE")
|
@Register(value = "delmember", description = "BAU_DELMEMBER_USAGE")
|
||||||
public void delmember(ProxiedPlayer p, @Mapper("addedUsers") SteamwarUser user) {
|
public void delmember(ProxiedPlayer p, SteamwarUser user) {
|
||||||
BauweltMember target = member(p, user);
|
BauweltMember target = member(p, user);
|
||||||
if (target == null)
|
if (target == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(SteamwarUser.get(target.getMemberID()).getUUID().equals(p.getUniqueId())) {
|
if(SteamwarUser.get(target.getMemberID()).getUuid().equals(p.getUniqueId())) {
|
||||||
Message.send("BAU_DELMEMBER_SELFDEL", p);
|
Message.send("BAU_DELMEMBER_SELFDEL", p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.remove();
|
target.remove();
|
||||||
ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
|
ProxiedPlayer toRemove = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid());
|
||||||
if(toRemove != null){
|
if(toRemove != null){
|
||||||
Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName());
|
Message.send("BAU_DELMEMBER_DELETED_TARGET", toRemove, p.getName());
|
||||||
Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo());
|
Subserver currentServer = Subserver.getSubserver(toRemove.getServer().getInfo());
|
||||||
if (currentServer != null && currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) {
|
if (currentServer != null && currentServer.getType() == Servertype.BAUSERVER && ((Bauserver) currentServer).getOwner().equals(p.getUniqueId())) {
|
||||||
toRemove.connect(ProxyServer.getInstance().getServerInfo(VelocityCore.LOBBY_SERVER));
|
toRemove.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message.send("BAU_DELMEMBER_DELETED", p);
|
Message.send("BAU_DELMEMBER_DELETED", p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper(value = "addedUsers", local = true)
|
|
||||||
public TypeMapper<SteamwarUser> addedUsers() {
|
|
||||||
return new TypeMapper<SteamwarUser>() {
|
|
||||||
@Override
|
|
||||||
public SteamwarUser map(CommandSender commandSender, String[] previousArguments, String s) {
|
|
||||||
return SteamwarUser.get(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
|
||||||
if (!(sender instanceof ProxiedPlayer)) return Collections.emptyList();
|
|
||||||
return BauweltMember.getMembers(((ProxiedPlayer) sender).getUniqueId()).stream()
|
|
||||||
.map(bauweltMember -> SteamwarUser.get(bauweltMember.getMemberID()))
|
|
||||||
.map(steamwarUser -> steamwarUser.getUserName())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register("resetall")
|
@Register("resetall")
|
||||||
@Register("delete")
|
@Register("delete")
|
||||||
public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||||
deleteConfirmation(p, () -> deleteWorld(p, version.getWorldFolder(ServerStarter.WORLDS_BASE_PATH) + (version != ServerStarter.Version.SPIGOT_12 ? SteamwarUser.get(p.getUniqueId()).getId() : p.getUniqueId().toString())));
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
|
versionSelector(version,
|
||||||
|
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS12_PATH + p.getUniqueId().toString())),
|
||||||
|
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS15_PATH + user.getId())),
|
||||||
|
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId()))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) {
|
private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) {
|
||||||
@ -289,12 +270,14 @@ public class BauCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteWorld(ProxiedPlayer player, String world) {
|
private static void deleteWorld(ProxiedPlayer player, String world) {
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
Bauserver subserver = Bauserver.get(player.getUniqueId());
|
for (Subserver subserver : Subserver.getServerList()) {
|
||||||
if(subserver != null)
|
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(player.getUniqueId())) {
|
||||||
subserver.stop();
|
subserver.stop();
|
||||||
|
break;
|
||||||
SubserverSystem.deleteFolder(VelocityCore.local, world);
|
}
|
||||||
|
}
|
||||||
|
SubserverSystem.deleteFolder(BungeeCore.local, world);
|
||||||
Message.send("BAU_DELETE_DELETED", player);
|
Message.send("BAU_DELETE_DELETED", player);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -303,7 +286,7 @@ public class BauCommand extends SWCommand {
|
|||||||
@Register("testarena")
|
@Register("testarena")
|
||||||
public void testarena(ProxiedPlayer p, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void testarena(ProxiedPlayer p, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
FightCommand.createArena(p, "/bau testarena ", false, arenaMode, map, false, (player, mode, m) -> {
|
FightCommand.createArena(p, "/bau testarena ", false, arenaMode, map, false, (player, mode, m) -> {
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> new ServerStarter().test(mode, m, p).start());
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> new ServerStarter().test(mode, map, p).start());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,7 +306,7 @@ public class BauCommand extends SWCommand {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUUID());
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), member.getUuid());
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
Message.send("BAU_MEMBER_NOMEMBER", p);
|
Message.send("BAU_MEMBER_NOMEMBER", p);
|
||||||
return null;
|
return null;
|
||||||
@ -331,10 +314,17 @@ public class BauCommand extends SWCommand {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendPermissionUpdate(ProxiedPlayer p, BauweltMember target, String what){
|
private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUUID());
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid());
|
||||||
if(player != null)
|
|
||||||
Message.send("BAU_MEMBER_SET_TARGET", player, p.getName(), Message.parse(what, player));
|
if(permission){
|
||||||
Message.send("BAU_MEMBER_SET", p, Message.parse(what, p));
|
if(player != null)
|
||||||
|
Message.send("BAU_MEMBER_TOGGLE_TARGET", player, p.getName(), Message.parse(what, player));
|
||||||
|
Message.send("BAU_MEMBER_TOGGLE", p, Message.parse(what, p));
|
||||||
|
}else{
|
||||||
|
if(player != null)
|
||||||
|
Message.send("BAU_MEMBER_TOGGLE_TARGET_OFF", player, p.getName(), Message.parse(what, player));
|
||||||
|
Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.sql.SWException;
|
import de.steamwar.bungeecore.sql.SWException;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -34,7 +34,7 @@ public class BugCommand extends SWCommand {
|
|||||||
public void bugMessage(ProxiedPlayer player, String... message) {
|
public void bugMessage(ProxiedPlayer player, String... message) {
|
||||||
String server = player.getServer().getInfo().getName();
|
String server = player.getServer().getInfo().getName();
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
SWException.log(String.join(" ", message), server + " " + player.getName() + " " + user.getId());
|
SWException.log(server, String.join(" ", message), player.getName() + " " + user.getId());
|
||||||
ChatSender.of(player).system("BUG_MESSAGE");
|
ChatSender.of(player).system("BUG_MESSAGE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.ArenaMode;
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
|
||||||
import de.steamwar.bungeecore.ServerStarter;
|
import de.steamwar.bungeecore.ServerStarter;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.ChatSender;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -22,7 +15,7 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
private final Map<String, ServerStarter.Version> versionMap = new HashMap<>();
|
private final Map<String, ServerStarter.Version> versionMap = new HashMap<>();
|
||||||
|
|
||||||
public BuilderCloudCommand() {
|
public BuilderCloudCommand() {
|
||||||
super("buildercloud", ConnectionListener.BUILDERCLOUD_PERMISSION, "builder");
|
super("buildercloud", "bungeecore.server.team");
|
||||||
|
|
||||||
versionMap.put("15", ServerStarter.Version.SPIGOT_15);
|
versionMap.put("15", ServerStarter.Version.SPIGOT_15);
|
||||||
versionMap.put("1.15", ServerStarter.Version.SPIGOT_15);
|
versionMap.put("1.15", ServerStarter.Version.SPIGOT_15);
|
||||||
@ -30,62 +23,11 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
versionMap.put("19", ServerStarter.Version.PAPER_19);
|
versionMap.put("19", ServerStarter.Version.PAPER_19);
|
||||||
versionMap.put("1.19", ServerStarter.Version.PAPER_19);
|
versionMap.put("1.19", ServerStarter.Version.PAPER_19);
|
||||||
versionMap.put("1.19.2", ServerStarter.Version.PAPER_19);
|
versionMap.put("1.19.2", ServerStarter.Version.PAPER_19);
|
||||||
versionMap.put("20", ServerStarter.Version.PAPER_20);
|
|
||||||
versionMap.put("1.20", ServerStarter.Version.PAPER_20);
|
|
||||||
versionMap.put("1.20.1", ServerStarter.Version.PAPER_20);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "create", description = "BUILDERCLOUD_CREATE_USAGE")
|
|
||||||
public void create(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map, @OptionalValue("") @Mapper("generator") @AllowNull File generator) {
|
|
||||||
mapFile(version, map).mkdir();
|
|
||||||
new ServerStarter().builder(version, map, generator).send(player).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "BUILDERCLOUD_USAGE")
|
@Register(description = "BUILDERCLOUD_USAGE")
|
||||||
public void start(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map) {
|
public void genericCommand(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map, @OptionalValue("") @Mapper("generator") @AllowNull File generator) {
|
||||||
if(!mapFile(version, map).exists()) {
|
new ServerStarter().builder(version, map, generator).send(player).start();
|
||||||
ChatSender.of(player).system("BUILDERCLOUD_UNKNOWN_MAP");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new ServerStarter().builder(version, map, null).send(player).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "rename", description = "BUILDERCLOUD_RENAME_USAGE")
|
|
||||||
public void rename(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String oldName, String newName) {
|
|
||||||
File oldMap = mapFile(version, oldName);
|
|
||||||
if(!oldMap.exists()) {
|
|
||||||
ChatSender.of(player).system("BUILDERCLOUD_UNKNOWN_MAP");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
File newMap = mapFile(version, newName);
|
|
||||||
if(newMap.exists()) {
|
|
||||||
ChatSender.of(player).system("BUILDERCLOUD_EXISTING_MAP");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Files.move(oldMap.toPath(), newMap.toPath());
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new SecurityException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatSender.of(player).system("BUILDERCLOUD_RENAMED");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = "deploy", description = "BUILDERCLOUD_DEPLOY_USAGE")
|
|
||||||
public void deploy(ProxiedPlayer player, @Mapper("nonHistoricArenaMode") ArenaMode arenaMode, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map) {
|
|
||||||
if(!mapFile(version, map).exists()) {
|
|
||||||
ChatSender.of(player).system("BUILDERCLOUD_UNKNOWN_MAP");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
|
||||||
VelocityCore.local.execute("/binarys/deployarena.py", arenaMode.getConfig(), Integer.toString(version.getVersionSuffix()), map);
|
|
||||||
ArenaMode.init();
|
|
||||||
ChatSender.of(player).system("BUILDERCLOUD_DEPLOY_FINISHED");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = ServerStarter.Version.class, local = true)
|
@ClassMapper(value = ServerStarter.Version.class, local = true)
|
||||||
@ -110,7 +52,16 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
return new TypeMapper<String>() {
|
return new TypeMapper<String>() {
|
||||||
@Override
|
@Override
|
||||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
return s;
|
File folder = getWorldFolder(previousArguments, 1);
|
||||||
|
|
||||||
|
if(folder == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
File map = new File(folder, s);
|
||||||
|
if(!map.exists() && !map.mkdir())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return map.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -121,7 +72,7 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
if(folder == null || (files = folder.list()) == null)
|
if(folder == null || (files = folder.list()) == null)
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
||||||
return Arrays.stream(files).filter(file -> new File(folder, file).isDirectory()).filter(file -> s.startsWith(".") || !file.startsWith(".")).collect(Collectors.toList());
|
return Arrays.stream(files).filter(file -> new File(folder, file).isDirectory()).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -161,10 +112,6 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private File mapFile(ServerStarter.Version version, String map) {
|
|
||||||
return new File(version.getWorldFolder(ServerStarter.BUILDER_BASE_PATH), map);
|
|
||||||
}
|
|
||||||
|
|
||||||
private File getWorldFolder(String[] previousArguments, int offset) {
|
private File getWorldFolder(String[] previousArguments, int offset) {
|
||||||
ServerStarter.Version v = versionMap.get(previousArguments[previousArguments.length - offset]);
|
ServerStarter.Version v = versionMap.get(previousArguments[previousArguments.length - offset]);
|
||||||
if(v == null)
|
if(v == null)
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -43,9 +43,11 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
challenges.remove(target);
|
challenges.remove(target);
|
||||||
challenges.remove(p);
|
challenges.remove(p);
|
||||||
|
|
||||||
new ServerStarter().arena(mode, map).blueLeader(player).redLeader(target).callback(
|
Subserver arena = new ServerStarter().arena(mode, map).blueLeader(player).redLeader(target).start();
|
||||||
arena -> Message.broadcast("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName(), target.getName())
|
if(arena != null) {
|
||||||
).start();
|
Message.broadcast("CHALLENGE_BROADCAST", "CHALLENGE_BROADCAST_HOVER",
|
||||||
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName(), target.getName());
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
if(!challenges.containsKey(p)){
|
if(!challenges.containsKey(p)){
|
||||||
challenges.put(p, new LinkedList<>());
|
challenges.put(p, new LinkedList<>());
|
||||||
@ -72,7 +74,7 @@ public class ChallengeCommand extends SWCommand {
|
|||||||
messageSender.send("CHALLENGE_SELF");
|
messageSender.send("CHALLENGE_SELF");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (IgnoreSystem.isIgnored(value.getUniqueId(), ((ProxiedPlayer) sender).getUniqueId())) {
|
if (IgnoreSystem.isIgnored(value, (ProxiedPlayer) sender)) {
|
||||||
messageSender.send("CHALLENGE_IGNORED");
|
messageSender.send("CHALLENGE_IGNORED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -19,23 +19,30 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.bot.util.DiscordSchemAlert;
|
import de.steamwar.bungeecore.bot.util.DiscordSchemAlert;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.bungeecore.sql.CheckedSchematic;
|
||||||
|
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||||
|
import de.steamwar.bungeecore.sql.SchematicType;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.simpleyaml.configuration.Configuration;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.config.Configuration;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CheckCommand extends SWCommand {
|
public class CheckCommand extends SWCommand {
|
||||||
private static final Map<SchematicType, SchematicType> fightTypes = new HashMap<>();
|
|
||||||
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
|
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
|
||||||
private static Map<SchematicType, List<String>> ranks = new HashMap<>();
|
private static Map<SchematicType, List<String>> ranks = new HashMap<>();
|
||||||
|
|
||||||
@ -48,31 +55,27 @@ public class CheckCommand extends SWCommand {
|
|||||||
ranks.put(checkType, config.getStringList("Ranks"));
|
ranks.put(checkType, config.getStringList("Ranks"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addFightType(SchematicType checkType, SchematicType fightType) {
|
public static boolean isChecking(ProxiedPlayer player){
|
||||||
fightTypes.put(checkType, fightType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isChecking(Player player){
|
|
||||||
return currentCheckers.containsKey(player.getUniqueId());
|
return currentCheckers.containsKey(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SchematicNode getCheckingSchem(Player player) {
|
public static SchematicNode getCheckingSchem(ProxiedPlayer player) {
|
||||||
return currentCheckers.get(player.getUniqueId()).schematic;
|
return currentCheckers.get(player.getUniqueId()).schematic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CheckCommand() {
|
public CheckCommand() {
|
||||||
super("check", ConnectionListener.CHECK_PERMISSION);
|
super("check", ConnectionListener.CHECK_PERMISSION);
|
||||||
|
|
||||||
VelocityCore.get().getProxyServer().getScheduler().buildTask(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
List<SchematicNode> schematics = getSchemsToCheck();
|
List<SchematicNode> schematics = getSchemsToCheck();
|
||||||
if(schematics.size() != currentCheckers.size())
|
if(schematics.size() != currentCheckers.size())
|
||||||
Message.team("CHECK_REMINDER", "CHECK_REMINDER_HOVER", ClickEvent.runCommand("/check list"), schematics.size() - currentCheckers.size());
|
Message.team("CHECK_REMINDER", "CHECK_REMINDER_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size());
|
||||||
}).repeat(10, TimeUnit.MINUTES).schedule();
|
}, 10, 10, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
public static void sendReminder(Player player) {
|
public static void sendReminder(ProxiedPlayer player) {
|
||||||
List<SchematicNode> schematics = getSchemsToCheck();
|
List<SchematicNode> schematics = getSchemsToCheck();
|
||||||
if(schematics.size() != currentCheckers.size())
|
if(schematics.size() != currentCheckers.size())
|
||||||
Message.send("CHECK_REMINDER", player, Message.parse("CHECK_REMINDER_HOVER", player), ClickEvent.runCommand("/check list"), schematics.size() - currentCheckers.size());
|
Message.send("CHECK_REMINDER", player, Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "list", description = "CHECK_HELP_LIST")
|
@Register(value = "list", description = "CHECK_HELP_LIST")
|
||||||
@ -111,21 +114,15 @@ public class CheckCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser checkingUser = SteamwarUser.get(player.getUniqueId());
|
|
||||||
SchematicNode schem = SchematicNode.getSchematicNode(Integer.parseInt(schemID));
|
SchematicNode schem = SchematicNode.getSchematicNode(Integer.parseInt(schemID));
|
||||||
if(!schem.getSchemtype().check()){
|
if(!schem.getSchemtype().check()){
|
||||||
ProxyServer.getInstance().getLogger().log(Level.SEVERE, player.getName() + " tried to check an uncheckable schematic!");
|
ProxyServer.getInstance().getLogger().log(Level.SEVERE, player.getName() + " tried to check an uncheckable schematic!");
|
||||||
return;
|
return;
|
||||||
}else if(schem.getOwner() == checkingUser.getId()) {
|
}else if(schem.getOwner() == SteamwarUser.get(player.getUniqueId()).getId()) {
|
||||||
Message.send("CHECK_SCHEMATIC_OWN", player);
|
Message.send("CHECK_SCHEMATIC_OWN", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerTeam = checkingUser.hasPerm(UserPerm.MODERATION) ? 0 : checkingUser.getTeam();
|
|
||||||
if (playerTeam != 0 && SteamwarUser.get(schem.getOwner()).getTeam() == playerTeam) {
|
|
||||||
Message.send("CHECK_SCHEMATIC_OWN_TEAM", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
new CheckSession(player, schem);
|
new CheckSession(player, schem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,9 +214,9 @@ public class CheckCommand extends SWCommand {
|
|||||||
this.startTime = Timestamp.from(Instant.now());
|
this.startTime = Timestamp.from(Instant.now());
|
||||||
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
this.checkList = checkQuestions.get(schematic.getSchemtype()).listIterator();
|
||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
ArenaMode mode = ArenaMode.getBySchemType(fightTypes.get(schematic.getSchemtype()));
|
ArenaMode mode = ArenaMode.getBySchemType(schematic.getSchemtype().fightType());
|
||||||
if(!new ServerStarter().test(mode, mode.getRandomMap(), checker).check(schematic.getId()).start()) {
|
if(new ServerStarter().test(mode, mode.getRandomMap(), checker).check(schematic.getId()).start() == null) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -268,56 +265,56 @@ public class CheckCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void accept(int rank){
|
private void accept(int rank){
|
||||||
if(createLog("freigegeben")) {
|
if(ranks.containsKey(schematic.getSchemtype())){
|
||||||
if(ranks.containsKey(schematic.getSchemtype())){
|
if(rank <= 0 || ranks.get(schematic.getSchemtype()).size() < rank){
|
||||||
if(rank <= 0 || ranks.get(schematic.getSchemtype()).size() < rank){
|
Message.send("CHECK_INVALID_RANK", checker);
|
||||||
Message.send("CHECK_INVALID_RANK", checker);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
schematic.setRank(rank);
|
|
||||||
}
|
}
|
||||||
|
schematic.setRank(rank);
|
||||||
schematic.setType(fightTypes.get(schematic.getSchemtype()).toDB());
|
|
||||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
|
||||||
if(player != null) {
|
|
||||||
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
|
|
||||||
} else {
|
|
||||||
DiscordSchemAlert.sendAccept(schematic, user);
|
|
||||||
}
|
|
||||||
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
schematic.setType(schematic.getSchemtype().fightType().toDB());
|
||||||
|
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "freigegeben");
|
||||||
|
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||||
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
||||||
|
if(player != null) {
|
||||||
|
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
|
||||||
|
} else {
|
||||||
|
DiscordSchemAlert.sendAccept(schematic, user);
|
||||||
|
}
|
||||||
|
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void decline(String reason){
|
private void decline(String reason){
|
||||||
if(createLog(reason)) {
|
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason);
|
||||||
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
|
||||||
if(player != null) {
|
if(player != null) {
|
||||||
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
|
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
|
||||||
} else {
|
} else {
|
||||||
DiscordSchemAlert.sendDecline(schematic, user, reason);
|
DiscordSchemAlert.sendDecline(schematic, user, reason);
|
||||||
}
|
|
||||||
Message.team("CHECK_DECLINED_TEAM", schematic.getName(), user.getUserName(), reason);
|
|
||||||
schematic.setType(SchematicType.Normal.toDB());
|
|
||||||
}
|
}
|
||||||
|
Message.team("CHECK_DECLINED_TEAM", schematic.getName(), user.getUserName(), reason);
|
||||||
|
schematic.setType(SchematicType.Normal.toDB());
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abort(){
|
private void abort(){
|
||||||
createLog("Prüfvorgang abgebrochen");
|
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "Prüfvorgang abgebrochen");
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stop(){
|
private void stop(){
|
||||||
currentCheckers.remove(checker.getUniqueId());
|
currentCheckers.remove(checker.getUniqueId());
|
||||||
currentSchems.remove(schematic.getId());
|
currentSchems.remove(schematic.getId());
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
Bauserver subserver = Bauserver.get(checker.getUniqueId());
|
for (Subserver subserver : Subserver.getServerList()) {
|
||||||
if(subserver != null)
|
if (subserver.getType() == Servertype.BAUSERVER && ((Bauserver) subserver).getOwner().equals(checker.getUniqueId())) {
|
||||||
subserver.stop();
|
subserver.stop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,13 +322,5 @@ public class CheckCommand extends SWCommand {
|
|||||||
currentCheckers.remove(checker.getUniqueId());
|
currentCheckers.remove(checker.getUniqueId());
|
||||||
currentSchems.remove(schematic.getId());
|
currentSchems.remove(schematic.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean createLog(String reason) {
|
|
||||||
if(SchematicNode.getSchematicNode(schematic.getId()) == null) // Schematic was deleted
|
|
||||||
return false;
|
|
||||||
|
|
||||||
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.sql.Punishment;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.*;
|
import de.steamwar.command.*;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -79,9 +79,9 @@ public class DevCommand extends SWCommand {
|
|||||||
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
@ClassValidator(value = ProxiedPlayer.class, local = true)
|
||||||
public TypeValidator<ProxiedPlayer> punishmentGuardChecker() {
|
public TypeValidator<ProxiedPlayer> punishmentGuardChecker() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
SteamwarUser user = SteamwarUser.get(value.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(value);
|
||||||
if (user.isPunished(Punishment.PunishmentType.NoDevServer)) {
|
if (user.isPunished(Punishment.PunishmentType.NoDevServer)) {
|
||||||
Message message = PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.NoDevServer);
|
Message message = user.punishmentMessage(Punishment.PunishmentType.NoDevServer);
|
||||||
messageSender.send(message.getFormat(), message.getParams());
|
messageSender.send(message.getFormat(), message.getParams());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -20,35 +20,55 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.sql.*;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.command.SWCommandUtils;
|
|
||||||
import de.steamwar.command.TypeMapper;
|
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class EventCommand extends SWCommand {
|
public class EventCommand extends BasicCommand {
|
||||||
|
|
||||||
public EventCommand() {
|
public EventCommand() {
|
||||||
super("event");
|
super("event", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validator("noEvent")
|
@Override
|
||||||
public TypeValidator<ProxiedPlayer> noEventValidator() {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
return (sender, value, messageSender) -> Event.get() == null;
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
|
Event currentEvent = Event.get();
|
||||||
|
|
||||||
|
if(currentEvent == null) {
|
||||||
|
noCurrentEvent(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.length != 1){
|
||||||
|
eventOverview(player, currentEvent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Team team = Team.get(args[0]);
|
||||||
|
if(team == null){
|
||||||
|
Message.send("EVENT_NO_TEAM", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
||||||
|
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
|
||||||
|
Message.send("EVENT_NO_FIGHT_TEAM", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubserverSystem.sendPlayer(eventArena, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
private void noCurrentEvent(ProxiedPlayer player){
|
||||||
public void noCurrentEvent(@Validator("noEvent") ProxiedPlayer player){
|
|
||||||
Message.send("EVENT_NO_CURRENT", player);
|
Message.send("EVENT_NO_CURRENT", player);
|
||||||
List<Event> coming = Event.getComing();
|
List<Event> coming = Event.getComing();
|
||||||
Instant now = Instant.now();
|
Instant now = Instant.now();
|
||||||
@ -61,9 +81,10 @@ public class EventCommand extends SWCommand {
|
|||||||
if(now.isBefore(e.getDeadline().toInstant())) {
|
if(now.isBefore(e.getDeadline().toInstant())) {
|
||||||
Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline());
|
Message.send("EVENT_COMING_DEADLINE", player, e.getDeadline());
|
||||||
}
|
}
|
||||||
SchematicType schemType = e.getSchematicType();
|
String schemType = e.getSchemType();
|
||||||
if (schemType != null) {
|
if (schemType != null) {
|
||||||
if (schemType.getDeadline() != null && now.isBefore(schemType.getDeadline().toInstant())) {
|
SchematicType schematicType = SchematicType.fromDB(schemType);
|
||||||
|
if (schematicType != null && schematicType.deadline() != null && now.isBefore(schematicType.deadline().toInstant())) {
|
||||||
Message.send("EVENT_COMING_SCHEM_DEADLINE", player, e.getDeadline());
|
Message.send("EVENT_COMING_SCHEM_DEADLINE", player, e.getDeadline());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,9 +99,7 @@ public class EventCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
private void eventOverview(ProxiedPlayer player, Event currentEvent){
|
||||||
public void eventOverview(@Validator(value = "noEvent", invert = true) ProxiedPlayer player) {
|
|
||||||
Event currentEvent = Event.get();
|
|
||||||
Message.send("EVENT_USAGE", player);
|
Message.send("EVENT_USAGE", player);
|
||||||
|
|
||||||
List<EventFight> fights = EventFight.getEvent(currentEvent.getEventID());
|
List<EventFight> fights = EventFight.getEvent(currentEvent.getEventID());
|
||||||
@ -107,32 +126,7 @@ public class EventCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VelocityCore.send(player, fline.toString());
|
BungeeCore.send(player, fline.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
|
||||||
public void eventWithTeam(@Validator(value = "noEvent", invert = true) ProxiedPlayer player, @ErrorMessage("EVENT_NO_TEAM") Team team) {
|
|
||||||
Subserver eventArena = EventStarter.getEventServer().get(team.getTeamId());
|
|
||||||
if(eventArena == null || !Subserver.getServerList().contains(eventArena)){
|
|
||||||
Message.send("EVENT_NO_FIGHT_TEAM", player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ChatSender sender = ChatSender.of(player);
|
|
||||||
if (!PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) {
|
|
||||||
SubserverSystem.sendPlayer(eventArena, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassMapper(Team.class)
|
|
||||||
@Cached(cacheDuration = 10, global = true)
|
|
||||||
public TypeMapper<Team> teamMapper() {
|
|
||||||
return SWCommandUtils.createMapper(Team::get, s -> EventStarter.getEventServer()
|
|
||||||
.keySet()
|
|
||||||
.stream()
|
|
||||||
.map(Team::get)
|
|
||||||
.map(t -> Arrays.asList(t.getTeamKuerzel(), t.getTeamColor()))
|
|
||||||
.flatMap(Collection::stream)
|
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,11 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.sql.Event;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.bungeecore.sql.EventFight;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.sql.Event;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ import java.util.stream.Stream;
|
|||||||
public class EventRescheduleCommand extends SWCommand {
|
public class EventRescheduleCommand extends SWCommand {
|
||||||
|
|
||||||
public EventRescheduleCommand() {
|
public EventRescheduleCommand() {
|
||||||
super("eventreschedule", ConnectionListener.EVENTRELOAD_PERMISSION);
|
super("eventreschedule", "bungeecore.softreload");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
@ -70,7 +69,7 @@ public class EventRescheduleCommand extends SWCommand {
|
|||||||
Message.send("EVENTRESCHEDULE_NO_FIGHT", player);
|
Message.send("EVENTRESCHEDULE_NO_FIGHT", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = Team.class, local = true)
|
@Register
|
||||||
public TypeMapper<Team> teamTypeMapper() {
|
public TypeMapper<Team> teamTypeMapper() {
|
||||||
return new TypeMapper<Team>() {
|
return new TypeMapper<Team>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,14 +19,13 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.sql.EventFight;
|
||||||
import de.steamwar.sql.EventFight;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
|
||||||
public class EventreloadCommand extends SWCommand {
|
public class EventreloadCommand extends SWCommand {
|
||||||
public EventreloadCommand() {
|
public EventreloadCommand() {
|
||||||
super("eventreload", ConnectionListener.EVENTRELOAD_PERMISSION);
|
super("eventreload", "bungeecore.softreload");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
|
@ -22,10 +22,13 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
import de.steamwar.bungeecore.inventory.SWInventory;
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
|
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
@ -87,6 +90,34 @@ public class FightCommand extends SWCommand {
|
|||||||
sender.sendMessage(ChatMessageType.SYSTEM, start);
|
sender.sendMessage(ChatMessageType.SYSTEM, start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void getMaps(ChatSender sender, String precommand, ArenaMode mode){
|
||||||
|
TextComponent start = new TextComponent();
|
||||||
|
TextComponent current = start;
|
||||||
|
if(mode.getMaps().size() > 1){
|
||||||
|
String command = precommand + mode.getChatName() + " Random";
|
||||||
|
start.setBold(true);
|
||||||
|
start.setColor(ChatColor.GRAY);
|
||||||
|
start.setText(sender.parseToPlain("FIGHT_ARENA_RANDOM") + " ");
|
||||||
|
start.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§e" + command)));
|
||||||
|
start.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
|
||||||
|
current = new TextComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String map : mode.getMaps()){
|
||||||
|
String command = precommand + mode.getChatName() + " " + map;
|
||||||
|
current.setBold(true);
|
||||||
|
current.setColor(ChatColor.GRAY);
|
||||||
|
current.setText(map + " ");
|
||||||
|
current.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§e" + command)));
|
||||||
|
current.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
|
||||||
|
if(current != start)
|
||||||
|
start.addExtra(current);
|
||||||
|
current = new TextComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatMessageType.SYSTEM, start);
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean alreadyInArena(ProxiedPlayer player){
|
private static boolean alreadyInArena(ProxiedPlayer player){
|
||||||
Subserver subserver = Subserver.getSubserver(player);
|
Subserver subserver = Subserver.getSubserver(player);
|
||||||
if(subserver != null && subserver.getType() == Servertype.ARENA){
|
if(subserver != null && subserver.getType() == Servertype.ARENA){
|
||||||
@ -108,8 +139,16 @@ public class FightCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (map == null)
|
if (map == null) {
|
||||||
|
if (arenaMode.getMaps().size() == 1) {
|
||||||
|
map = arenaMode.getRandomMap();
|
||||||
|
} else {
|
||||||
|
getMaps(sender, precommand, arenaMode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (map.equalsIgnoreCase("random")) {
|
||||||
map = arenaMode.getRandomMap();
|
map = arenaMode.getRandomMap();
|
||||||
|
}
|
||||||
|
|
||||||
if (!allowMerging) {
|
if (!allowMerging) {
|
||||||
callback.run(player, arenaMode, map);
|
callback.run(player, arenaMode, map);
|
||||||
@ -124,7 +163,7 @@ public class FightCommand extends SWCommand {
|
|||||||
for (Subserver subserver : Subserver.getServerList()) {
|
for (Subserver subserver : Subserver.getServerList()) {
|
||||||
if(subserver instanceof Arenaserver) {
|
if(subserver instanceof Arenaserver) {
|
||||||
Arenaserver arenaserver = (Arenaserver) subserver;
|
Arenaserver arenaserver = (Arenaserver) subserver;
|
||||||
if(mode.getInternalName().equals(arenaserver.getMode()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) {
|
if(mode.getInternalName().equals(arenaserver.getMode()) && map.equals(arenaserver.getMap()) && arenaserver.isAllowMerge() && arenaserver.getServer().getPlayers().size() == 1) {
|
||||||
mergable = arenaserver;
|
mergable = arenaserver;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -159,11 +198,13 @@ public class FightCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void fight(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void fight(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
createArena(player, "/fight ", true, arenaMode, map, false,
|
createArena(player, "/fight ", true, arenaMode, map, false, (p, mode, m) -> {
|
||||||
(p, mode, m) -> new ServerStarter().arena(mode, m).blueLeader(p).callback(
|
Subserver arena = new ServerStarter().arena(mode, m).blueLeader(p).start();
|
||||||
arena -> Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName())
|
if(arena != null) {
|
||||||
).start()
|
Message.broadcast("FIGHT_BROADCAST", "FIGHT_BROADCAST_HOVER"
|
||||||
);
|
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.sql.internal.Statement;
|
import de.steamwar.bungeecore.sql.Statement;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -25,13 +26,13 @@ public class GDPRQuery extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) {
|
public void generate(ProxiedPlayer player, ProxiedPlayer forPlayer) {
|
||||||
SteamwarUser user = SteamwarUser.get(forPlayer.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(forPlayer);
|
||||||
if(user == null) {
|
if(user == null) {
|
||||||
Message.send("UNKNOWN_PLAYER", player);
|
Message.send("UNKNOWN_PLAYER", player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BungeeCord.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
try {
|
try {
|
||||||
createZip(player, user);
|
createZip(player, user);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@ -49,7 +50,7 @@ public class GDPRQuery extends SWCommand {
|
|||||||
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt");
|
copy(getClass().getClassLoader().getResourceAsStream("GDPRQueryREADME.md"), out, "README.txt");
|
||||||
|
|
||||||
printUpdate(player, "GDPR_STATUS_WORLD");
|
printUpdate(player, "GDPR_STATUS_WORLD");
|
||||||
copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUUID().toString(), "BuildWorld12");
|
copyBauwelt(user, out, "/home/minecraft/userworlds/" + user.getUuid().toString(), "BuildWorld12");
|
||||||
copyBauwelt(user, out, "/home/minecraft/userworlds15/" + user.getId(), "BuildWorld15");
|
copyBauwelt(user, out, "/home/minecraft/userworlds15/" + user.getId(), "BuildWorld15");
|
||||||
|
|
||||||
printUpdate(player, "GDPR_STATUS_INVENTORIES");
|
printUpdate(player, "GDPR_STATUS_INVENTORIES");
|
||||||
@ -214,14 +215,14 @@ public class GDPRQuery extends SWCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File playerdata = new File(world, "playerdata/" + user.getUUID().toString() + ".dat");
|
File playerdata = new File(world, "playerdata/" + user.getUuid().toString() + ".dat");
|
||||||
if(playerdata.exists())
|
if(playerdata.exists())
|
||||||
copy(playerdata, out, outDir + "/playerdata/" + user.getUUID().toString() + ".dat");
|
copy(playerdata, out, outDir + "/playerdata/" + user.getUuid().toString() + ".dat");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyPlayerdata(SteamwarUser user, ZipOutputStream out, String inDir, String outDir) throws IOException {
|
private void copyPlayerdata(SteamwarUser user, ZipOutputStream out, String inDir, String outDir) throws IOException {
|
||||||
File worlds = new File(inDir);
|
File worlds = new File(inDir);
|
||||||
String path = "playerdata/" + user.getUUID().toString() + ".dat";
|
String path = "playerdata/" + user.getUuid().toString() + ".dat";
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(File world : worlds.listFiles()) {
|
for(File world : worlds.listFiles()) {
|
||||||
@ -229,7 +230,7 @@ public class GDPRQuery extends SWCommand {
|
|||||||
if(!playerdata.exists())
|
if(!playerdata.exists())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUUID().toString() + ".dat");
|
copy(playerdata, out, outDir + "/" + (i++) + "/" + user.getUuid().toString() + ".dat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,61 +20,72 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class HelpCommand extends SWCommand {
|
public class HelpCommand extends BasicCommand {
|
||||||
|
|
||||||
public HelpCommand() {
|
public HelpCommand() {
|
||||||
super("help", "", "?");
|
super("help", "", "?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Override
|
||||||
public void genericCommand(ProxiedPlayer player) {
|
public void execute(CommandSender s, String[] args) {
|
||||||
ChatSender sender = ChatSender.of(player);
|
ChatSender sender = ChatSender.of(s);
|
||||||
|
if (args.length < 1) {
|
||||||
|
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||||
|
"HELP_LOBBY", "/l",
|
||||||
|
"HELP_BAU", "/build",
|
||||||
|
"HELP_BAUSERVER", "/help build",
|
||||||
|
"HELP_FIGHT", "/fight",
|
||||||
|
"HELP_CHALLENGE", "/challenge",
|
||||||
|
"HELP_HISTORIC", "/historic",
|
||||||
|
"HELP_TEAM", "/team",
|
||||||
|
"HELP_JOIN", "/join",
|
||||||
|
"HELP_LOCAL", "/local");
|
||||||
|
}else if (args[0].equalsIgnoreCase("buildserver")) {
|
||||||
|
sendBauHelp(sender);
|
||||||
|
}else if (args[0].equalsIgnoreCase("build")) {
|
||||||
|
bauHelpGroup(sender, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void bauHelpGroup(ChatSender sender, String[] args) {
|
||||||
|
if (args.length < 2) {
|
||||||
|
sendBauHelpGroup(sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args[1].toLowerCase()) {
|
||||||
|
case "admin":
|
||||||
|
case "owner":
|
||||||
|
case "bauwelt":
|
||||||
|
sender.system("HELP_BAU_GROUP_ADMIN_TITLE");
|
||||||
|
sendBauHelp(sender);
|
||||||
|
return;
|
||||||
|
case "world":
|
||||||
|
printPage(sender, "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
||||||
|
return;
|
||||||
|
case "player":
|
||||||
|
printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
||||||
|
return;
|
||||||
|
case "worldedit":
|
||||||
|
case "we":
|
||||||
|
case "world-edit":
|
||||||
|
case "edit":
|
||||||
|
printPage(sender, "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
|
||||||
|
return;
|
||||||
|
case "other":
|
||||||
|
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
sendBauHelpGroup(sender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sendBauHelpGroup(ChatSender sender) {
|
||||||
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
printPage(sender, ClickEvent.Action.RUN_COMMAND,
|
||||||
"HELP_LOBBY", "/l",
|
|
||||||
"HELP_BAU", "/build",
|
|
||||||
"HELP_BAUSERVER", "/help build",
|
|
||||||
"HELP_FIGHT", "/fight",
|
|
||||||
"HELP_CHALLENGE", "/challenge",
|
|
||||||
"HELP_HISTORIC", "/historic",
|
|
||||||
"HELP_TEAM", "/team",
|
|
||||||
"HELP_JOIN", "/join",
|
|
||||||
"HELP_LOCAL", "/local");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register({"build","world"})
|
|
||||||
public void buildWorld(ProxiedPlayer player) {
|
|
||||||
printPage(ChatSender.of(player), "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register({"build","player"})
|
|
||||||
public void buildPlayer(ProxiedPlayer player) {
|
|
||||||
printPage(ChatSender.of(player), "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register({"build","worldedit"})
|
|
||||||
@Register({"build","we"})
|
|
||||||
@Register({"build","world-edit"})
|
|
||||||
@Register({"build","edit"})
|
|
||||||
public void buildWorldedit(ProxiedPlayer player) {
|
|
||||||
printPage(ChatSender.of(player), "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register({"build","other"})
|
|
||||||
public void buildOther(ProxiedPlayer player) {
|
|
||||||
ChatSender sender = ChatSender.of(player);
|
|
||||||
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
|
|
||||||
sender.prefixless("HELP_SCHEMSUBMIT", new Message("HELP_SCHEMSUBMIT_HOVER"), new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.youtube.com/watch?v=9QrQ3UBWveE"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register("build")
|
|
||||||
public void sendBauHelpGroup(ProxiedPlayer player) {
|
|
||||||
printPage(ChatSender.of(player), ClickEvent.Action.RUN_COMMAND,
|
|
||||||
"HELP_BAU_GROUP_ADMIN", "/help build admin",
|
"HELP_BAU_GROUP_ADMIN", "/help build admin",
|
||||||
"HELP_BAU_GROUP_WORLD", "/help build world",
|
"HELP_BAU_GROUP_WORLD", "/help build world",
|
||||||
"HELP_BAU_GROUP_PLAYER", "/help build player",
|
"HELP_BAU_GROUP_PLAYER", "/help build player",
|
||||||
@ -82,18 +93,13 @@ public class HelpCommand extends SWCommand {
|
|||||||
"HELP_BAU_GROUP_OTHER", "/help build other");
|
"HELP_BAU_GROUP_OTHER", "/help build other");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("buildserver")
|
static void sendBauHelp(ChatSender sender) {
|
||||||
@Register({"build","admin"})
|
printPage(sender, ClickEvent.Action.SUGGEST_COMMAND,
|
||||||
@Register({"build","owner"})
|
|
||||||
@Register({"build","bauwelt"})
|
|
||||||
public void sendBauHelp(ProxiedPlayer player) {
|
|
||||||
printPage(ChatSender.of(player), ClickEvent.Action.SUGGEST_COMMAND,
|
|
||||||
"HELP_BAU_TP", "/build tp ",
|
"HELP_BAU_TP", "/build tp ",
|
||||||
"HELP_BAU_ADDMEMBER", "/build addmember ",
|
"HELP_BAU_ADDMEMBER", "/build addmember ",
|
||||||
"HELP_BAU_DELMEMBER", "/build delmember ",
|
"HELP_BAU_DELMEMBER", "/build delmember ",
|
||||||
"HELP_BAU_SET_SPECTATOR", "/build setSpectator ",
|
"HELP_BAU_TOGGLEWE", "/build togglewe ",
|
||||||
"HELP_BAU_SET_BUILDER", "/build setBuilder ",
|
"HELP_BAU_TOGGLEWORLD", "/build toggleworld ",
|
||||||
"HELP_BAU_SET_SUPERVISOR", "/build setSupervisor ",
|
|
||||||
"HELP_BAU_DELETE", "/build delete ",
|
"HELP_BAU_DELETE", "/build delete ",
|
||||||
"HELP_BAU_TESTARENA", "/build testarena ",
|
"HELP_BAU_TESTARENA", "/build testarena ",
|
||||||
"HELP_BAU_LOCK", "/build lock ",
|
"HELP_BAU_LOCK", "/build lock ",
|
||||||
|
@ -22,6 +22,7 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.ArenaMode;
|
import de.steamwar.bungeecore.ArenaMode;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.ServerStarter;
|
import de.steamwar.bungeecore.ServerStarter;
|
||||||
|
import de.steamwar.bungeecore.Subserver;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -32,11 +33,13 @@ public class HistoricCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void historic(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("historicArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
public void historic(@Validator("arenaPlayer") ProxiedPlayer player, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) {
|
||||||
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> {
|
FightCommand.createArena(player, "/historic ", true, arenaMode, map, true, (p, mode, m) -> {
|
||||||
new ServerStarter().arena(mode, m).blueLeader(p).callback(
|
Subserver arena = new ServerStarter().arena(mode, m).blueLeader(p).start();
|
||||||
arena -> Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName())
|
if(arena != null) {
|
||||||
).start();
|
Message.broadcast("HISTORIC_BROADCAST", "HISTORIC_BROADCAST_HOVER",
|
||||||
|
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/arena " + arena.getServer().getName()), mode.getDisplayName(), p.getName());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,17 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import net.md_5.bungee.BungeeCord;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class IgnoreCommand extends SWCommand {
|
public class IgnoreCommand extends SWCommand {
|
||||||
|
|
||||||
public IgnoreCommand() {
|
public IgnoreCommand() {
|
||||||
@ -32,9 +38,14 @@ public class IgnoreCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "USAGE_IGNORE")
|
@Register(description = "USAGE_IGNORE")
|
||||||
public void genericCommand(ProxiedPlayer p, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
public void genericCommand(ProxiedPlayer p, @Mapper("player") String toIgnore) {
|
||||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||||
|
|
||||||
|
SteamwarUser target = SteamwarUser.get(toIgnore);
|
||||||
|
if(target == null){
|
||||||
|
Message.send("UNKNOWN_PLAYER", p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(target.equals(user)){
|
if(target.equals(user)){
|
||||||
Message.send("IGNORE_YOURSELF", p);
|
Message.send("IGNORE_YOURSELF", p);
|
||||||
return;
|
return;
|
||||||
@ -47,4 +58,9 @@ public class IgnoreCommand extends SWCommand {
|
|||||||
IgnoreSystem.ignore(user, target);
|
IgnoreSystem.ignore(user, target);
|
||||||
Message.send("IGNORE_MESSAGE", p, target.getUserName());
|
Message.send("IGNORE_MESSAGE", p, target.getUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mapper(value = "player", local = true)
|
||||||
|
public TypeMapper<String> playerTypeMapper() {
|
||||||
|
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,50 +19,79 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.Subserver;
|
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||||
import de.steamwar.command.SWCommand;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import de.steamwar.command.TypeValidator;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.UserPerm;
|
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
public class JoinmeCommand extends SWCommand {
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class JoinmeCommand extends BasicCommand {
|
||||||
|
|
||||||
public JoinmeCommand() {
|
public JoinmeCommand() {
|
||||||
super("joinme");
|
super("joinme", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "JOINME_USAGE")
|
@Override
|
||||||
public void genericCommand(ProxiedPlayer player) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if (!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.TEAM)) {
|
if(sender instanceof ProxiedPlayer) {
|
||||||
Message.send("JOINME_USAGE", player);
|
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||||
return;
|
|
||||||
}
|
|
||||||
Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER",
|
|
||||||
new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
if (args.length == 0 && player.hasPermission("bungeecore.joinme")) {
|
||||||
public void genericCommand(ProxiedPlayer player, @Validator ProxiedPlayer target) {
|
Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER"
|
||||||
if (target.equals(player)){
|
, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName());
|
||||||
Message.send("JOINME_PLAYER_SELF", player);
|
} else if (args.length == 1) {
|
||||||
return;
|
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
|
||||||
}
|
if(target == null || !target.isConnected()){
|
||||||
|
Message.send("JOINME_PLAYER_OFFLINE", player);
|
||||||
|
return;
|
||||||
|
}else if(target.equals(player)){
|
||||||
|
Message.send("JOINME_PLAYER_SELF", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ServerInfo server = target.getServer().getInfo();
|
||||||
|
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
|
||||||
|
Subserver subserver = Subserver.getSubserver(target);
|
||||||
|
|
||||||
Subserver subserver = Subserver.getSubserver(target);
|
if(subserver != null) {
|
||||||
TpCommand.teleport(player, subserver != null ? subserver.getServer() : target.getServer().getInfo());
|
Servertype type = subserver.getType();
|
||||||
}
|
if (type == Servertype.ARENA) {
|
||||||
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
@ClassValidator(ProxiedPlayer.class)
|
} else if (type == Servertype.BAUSERVER) {
|
||||||
public TypeValidator<ProxiedPlayer> playerMapper() {
|
Bauserver bauserver = (Bauserver) subserver;
|
||||||
return (sender, value, messageSender) -> {
|
if (bauserver.getOwner().equals(player.getUniqueId()) ||
|
||||||
if (value == null || !value.isConnected()) {
|
BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
||||||
messageSender.send("JOINME_PLAYER_OFFLINE", sender);
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
return false;
|
} else {
|
||||||
|
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
||||||
|
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||||
|
}
|
||||||
|
} else if(type == Servertype.BUILDER && !player.hasPermission("bungeecore.server.team")) {
|
||||||
|
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||||
|
} else {
|
||||||
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
|
}
|
||||||
|
}else if(serverPerm != null && !player.hasPermission(serverPerm)){
|
||||||
|
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||||
|
}else if(serverPerm == null && !player.getGroups().contains("team")) {
|
||||||
|
Message.send("JOIN_PLAYER_BLOCK", player);
|
||||||
|
}else{
|
||||||
|
player.connect(server);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Message.send("JOINME_USAGE", player);
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||||
|
if(args.length == 1){
|
||||||
|
return allPlayers(args[0]);
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,26 +19,42 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import de.steamwar.command.SWCommandUtils;
|
||||||
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class KickCommand extends SWCommand {
|
public class KickCommand extends SWCommand {
|
||||||
|
|
||||||
public KickCommand() {
|
public KickCommand() {
|
||||||
super("kick", ConnectionListener.KICK_PERMISSION);
|
super("kick", "bungeecore.kick");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "KICK_USAGE")
|
@Register(description = "KICK_USAGE")
|
||||||
public void genericCommand(CommandSender sender, @ErrorMessage("KICK_OFFLINE") ProxiedPlayer target, String... message) {
|
public void genericCommand(CommandSender sender, @Mapper("player") String player, String... message) {
|
||||||
|
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(player);
|
||||||
|
if(target == null){
|
||||||
|
Message.send("KICK_OFFLINE", sender);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (message.length == 0) {
|
if (message.length == 0) {
|
||||||
target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target));
|
target.disconnect(Message.parseToComponent("KICK_NORMAL", true, target));
|
||||||
} else {
|
} else {
|
||||||
target.disconnect(VelocityCore.stringToText(VelocityCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
|
target.disconnect(BungeeCore.stringToText(BungeeCore.CHAT_PREFIX + "§c" + String.join(" ", message)));
|
||||||
}
|
}
|
||||||
Message.send("KICK_CONFIRM", sender, target.getName());
|
Message.send("KICK_CONFIRM", sender, target.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mapper(value = "player", local = true)
|
||||||
|
public TypeMapper<String> playerTypeMapper() {
|
||||||
|
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,148 +0,0 @@
|
|||||||
/*
|
|
||||||
This file is a part of the SteamWar software.
|
|
||||||
|
|
||||||
Copyright (C) 2023 SteamWar.de-Serverteam
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU Affero General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program 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 Affero General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Affero General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.inventory.SWInventory;
|
|
||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
|
||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
|
||||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.sql.Mod;
|
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class ModCommand extends SWCommand {
|
|
||||||
|
|
||||||
public ModCommand() {
|
|
||||||
super("mod", ConnectionListener.MOD_PERMISSION, "mods");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final Map<ProxiedPlayer, Mod.ModType> playerFilterType = new HashMap<>();
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void genericCommand(ProxiedPlayer p) {
|
|
||||||
playerFilterType.putIfAbsent(p,Mod.ModType.UNKLASSIFIED);
|
|
||||||
openGui(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openGui(ProxiedPlayer p) {
|
|
||||||
SWStreamInv<Mod> swStreamInv = new SWStreamInv<>(p,Message.parse("MOD_COMMAND_GUI_TITLE",p), (click, element) -> {
|
|
||||||
openClassificationGui(p,element);
|
|
||||||
},page -> {
|
|
||||||
Mod.ModType filtertype = playerFilterType.get(p);
|
|
||||||
return Mod.getAllModsFiltered(page,45, filtertype).stream().map(mod -> new SWListInv.SWListEntry<>(getModItem(mod),mod)).collect(Collectors.toList());
|
|
||||||
});
|
|
||||||
|
|
||||||
swStreamInv.addItem(52,new SWItem("NAME_TAG","Filter"), click -> {
|
|
||||||
swStreamInv.close();
|
|
||||||
openFilterGui(p);
|
|
||||||
});
|
|
||||||
|
|
||||||
swStreamInv.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateAndCloseGui(Mod.ModType modType, Mod mod, SWInventory toClose, ProxiedPlayer p) {
|
|
||||||
mod.setModType(modType);
|
|
||||||
toClose.close();
|
|
||||||
openGui(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openFilterGui(ProxiedPlayer p) {
|
|
||||||
SWInventory inv = new SWInventory(p, 9, "Filter");
|
|
||||||
|
|
||||||
inv.addItem(1, new SWItem(Message.parse("MOD_UNCLASSIFIED",p),8), click -> playerFilterType.replace(p, Mod.ModType.UNKLASSIFIED));
|
|
||||||
inv.addItem(2, new SWItem(Message.parse("MOD_ALLOWED",p),2), click -> playerFilterType.replace(p, Mod.ModType.GREEN));
|
|
||||||
inv.addItem(3, new SWItem(Message.parse("MOD_FORBIDDEN",p), 11), click -> playerFilterType.replace(p, Mod.ModType.YELLOW));
|
|
||||||
inv.addItem(4, new SWItem(Message.parse("MOD_AUTOBAN",p),1), click -> playerFilterType.replace(p, Mod.ModType.RED));
|
|
||||||
inv.addItem(5, new SWItem(Message.parse("MOD_YT",p),13), click -> playerFilterType.replace(p, Mod.ModType.YOUTUBER_ONLY));
|
|
||||||
|
|
||||||
inv.addItem(8, new SWItem("ARROW", Message.parse("MOD_ITEM_BACK",p)), click -> {
|
|
||||||
inv.close();
|
|
||||||
openGui(p);
|
|
||||||
});
|
|
||||||
|
|
||||||
inv.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openClassificationGui(ProxiedPlayer p,Mod element) {
|
|
||||||
SWInventory swInventory = new SWInventory(p,9,Message.parse("MOD_COMMAND_CLASSICIATION_GUI",p));
|
|
||||||
|
|
||||||
swInventory.addItem(2, new SWItem(Message.parse("MOD_UNCLASSIFIED",p),8), (click1 -> updateAndCloseGui(Mod.ModType.UNKLASSIFIED,element,swInventory,p)));
|
|
||||||
swInventory.addItem(3, new SWItem(Message.parse("MOD_ALLOWED",p), 2), (click1 -> updateAndCloseGui(Mod.ModType.GREEN,element,swInventory,p)));
|
|
||||||
swInventory.addItem(4, new SWItem(Message.parse("MOD_FORBIDDEN",p), 11), (click1 -> updateAndCloseGui(Mod.ModType.YELLOW,element,swInventory,p)));
|
|
||||||
swInventory.addItem(5, new SWItem(Message.parse("MOD_AUTOBAN",p),1), (click1 -> updateAndCloseGui(Mod.ModType.RED,element,swInventory,p)));
|
|
||||||
swInventory.addItem(6, new SWItem(Message.parse("MOD_YT",p), 13), (click1 -> updateAndCloseGui(Mod.ModType.YOUTUBER_ONLY,element,swInventory,p)));
|
|
||||||
|
|
||||||
swInventory.addItem(8,new SWItem("ARROW",Message.parse("MOD_ITEM_BACK",p)), click1 -> {
|
|
||||||
swInventory.close();
|
|
||||||
openGui(p);
|
|
||||||
});
|
|
||||||
|
|
||||||
swInventory.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
private SWItem getModItem(Mod modEntry) {
|
|
||||||
SWItem item = new SWItem("NAME_TAG", modEntry.getModName());
|
|
||||||
|
|
||||||
item.addLore(modEntry.getPlatform().name());
|
|
||||||
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = {"set"},description = "MOD_COMMAND_SET_USAGE")
|
|
||||||
public void set(ProxiedPlayer p,String modName,Mod.Platform platform,Mod.ModType newModType) {
|
|
||||||
Mod mod = Mod.get(modName, platform);
|
|
||||||
if(mod == null) {
|
|
||||||
Message.send("MOD_COMMAND_NOT_FOUND_IN_DATABASE",p,modName, platform.name());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mod.setModType(newModType);
|
|
||||||
Message.send("MOD_CHANGED_TYPE",p,modName,platform.name(),newModType.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = {"get"},description = "MOD_COMMAND_GET_USAGE")
|
|
||||||
public void get(ProxiedPlayer p,String modName,Mod.Platform platform) {
|
|
||||||
Mod mod = Mod.get(modName, platform);
|
|
||||||
if(mod == null) {
|
|
||||||
Message.send("MOD_COMMAND_NOT_FOUND_IN_DATABASE", p, modName, platform.name());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Message.send("MOD_COMMAND_INFO", p, modName, platform.name(), mod.getModType().name());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register(value = {"next"})
|
|
||||||
public void next(ProxiedPlayer p) {
|
|
||||||
Mod mod = Mod.findFirstMod();
|
|
||||||
if(mod == null) {
|
|
||||||
Message.send("MOD_NO_MORE_UNCLASSIFIED_MODS",p);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Message.send("MOD_FOUND_NEXT_MOD",p,"MOD_OPEN_GUI",new ClickEvent(ClickEvent.Action.RUN_COMMAND,""),mod.getModName(),mod.getPlatform().name());
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -36,7 +36,7 @@ public class MsgCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "MSG_USAGE")
|
@Register(description = "MSG_USAGE")
|
||||||
public void genericCommand(ProxiedPlayer sender, @ErrorMessage(value = "MSG_OFFLINE") ProxiedPlayer target, @ErrorMessage(value = "MSG_USAGE", allowEAs = false) String... message) {
|
public void genericCommand(ProxiedPlayer sender, ProxiedPlayer target, @ErrorMessage(value = "MSG_USAGE", allowEAs = false) String... message) {
|
||||||
msg(sender, target, message);
|
msg(sender, target, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class MsgCommand extends SWCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IgnoreSystem.isIgnored(target.getUniqueId(), player.getUniqueId())) {
|
if (IgnoreSystem.isIgnored(target, player)) {
|
||||||
sender.system("MSG_IGNORED");
|
sender.system("MSG_IGNORED");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,15 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import org.apache.commons.lang3.LocaleUtils;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class PlaytimeCommand extends SWCommand {
|
public class PlaytimeCommand extends SWCommand {
|
||||||
|
|
||||||
@ -34,10 +38,9 @@ public class PlaytimeCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(ProxiedPlayer player) {
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
NumberFormat format = NumberFormat.getNumberInstance((player).getLocale());
|
||||||
NumberFormat format = NumberFormat.getNumberInstance(user.getLocale());
|
|
||||||
format.setMaximumFractionDigits(2);
|
format.setMaximumFractionDigits(2);
|
||||||
String formattedText = format.format((user.getOnlinetime() / (double) 3600));
|
String formattedText = format.format((SteamwarUser.get(player).getOnlinetime() / (double) 3600));
|
||||||
|
|
||||||
Message.send("HOURS_PLAYED", player, formattedText);
|
Message.send("HOURS_PLAYED", player, formattedText);
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||||
import de.steamwar.sql.PollAnswer;
|
import de.steamwar.bungeecore.sql.PollAnswer;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
@ -20,9 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
|
||||||
import de.steamwar.bungeecore.listeners.PollSystem;
|
import de.steamwar.bungeecore.listeners.PollSystem;
|
||||||
import de.steamwar.sql.PollAnswer;
|
import de.steamwar.bungeecore.sql.PollAnswer;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -32,15 +31,15 @@ import java.util.Map;
|
|||||||
public class PollresultCommand extends SWCommand {
|
public class PollresultCommand extends SWCommand {
|
||||||
|
|
||||||
public PollresultCommand() {
|
public PollresultCommand() {
|
||||||
super("pollresult", ConnectionListener.POLLRESULT_PERMISSION);
|
super("pollresult", "bungeecore.pollresults");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void genericCommand(@Validator ProxiedPlayer player) {
|
public void genericCommand(@Validator ProxiedPlayer player) {
|
||||||
Map<Integer, Integer> voted = PollAnswer.getCurrentResults();
|
Map<String, Integer> voted = PollAnswer.getCurrentResults();
|
||||||
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollAnswer.getCurrentPoll());
|
Message.send("POLLRESULT_HEADER", player, voted.values().stream().reduce(Integer::sum).orElse(0), PollSystem.getQuestion());
|
||||||
for (Map.Entry<Integer, Integer> e: voted.entrySet()) {
|
for (Map.Entry<String, Integer> e: voted.entrySet()) {
|
||||||
Message.send("POLLRESULT_LIST", player, PollSystem.getAnswer(e.getKey()), e.getValue());
|
Message.send("POLLRESULT_LIST", player, e.getKey(), e.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,112 +19,26 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.bungeecore.listeners.IPSanitizer;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.PreviousArguments;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
|
||||||
import de.steamwar.sql.BannedUserIPs;
|
|
||||||
import de.steamwar.sql.Punishment;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.UserPerm;
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.util.Date;
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class PunishmentCommand {
|
public class PunishmentCommand {
|
||||||
|
|
||||||
private static final String API_URL = "https://api.mojang.com/users/profiles/minecraft/";
|
|
||||||
private static final JsonParser jsonParser = new JsonParser();
|
|
||||||
|
|
||||||
public static SteamwarUser getOrCreateOfflinePlayer(String name) {
|
|
||||||
SteamwarUser user = SteamwarUser.get(name);
|
|
||||||
if (user != null) {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
UUID uuid = getUUIDofOfflinePlayer(name);
|
|
||||||
if (uuid == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SteamwarUser.getOrCreate(uuid, name, u -> {}, (o, n) -> {});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static UUID getUUIDofOfflinePlayer(String playerName) {
|
|
||||||
try {
|
|
||||||
final URL url = new URL(API_URL + playerName);
|
|
||||||
String uuid = jsonParser.parse(new Scanner(url.openConnection().getInputStream()).nextLine()).getAsJsonObject().get("id").getAsString();
|
|
||||||
return UUID.fromString(uuid.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
|
|
||||||
} catch (NoSuchElementException e) {
|
|
||||||
// ignore, player does not exist
|
|
||||||
} catch (IOException e) {
|
|
||||||
VelocityCore.get().getLogger().log(Level.SEVERE, "Could not get offline player UUID " + playerName, e);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPunishedWithMessage(ChatSender player, Punishment.PunishmentType punishment) {
|
|
||||||
SteamwarUser user = player.user();
|
|
||||||
if (!user.isPunished(punishment)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
player.system(punishmentMessage(user, punishment));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void ban(SteamwarUser user, Timestamp time, String banReason, SteamwarUser punisher, boolean perma) {
|
|
||||||
user.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma);
|
|
||||||
|
|
||||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUUID());
|
|
||||||
if (player != null) {
|
|
||||||
String ip = IPSanitizer.getTrueAddress(player.getPendingConnection()).getHostAddress();
|
|
||||||
ChatSender.disconnect(player).system(punishmentMessage(user, Punishment.PunishmentType.Ban));
|
|
||||||
for (BannedUserIPs banned : BannedUserIPs.get(ip)) {
|
|
||||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
|
||||||
if (bannedUser.isPunished(Punishment.PunishmentType.Ban) && bannedUser.getPunishment(Punishment.PunishmentType.Ban).getEndTime().before(time)) {
|
|
||||||
bannedUser.punish(Punishment.PunishmentType.Ban, time, banReason, punisher.getId(), perma);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BannedUserIPs.banIP(user.getId(), ip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Message punishmentMessage(SteamwarUser user, Punishment.PunishmentType punishment) {
|
|
||||||
Punishment currentPunishment = user.getPunishment(punishment);
|
|
||||||
if (currentPunishment.isPerma()) {
|
|
||||||
return new Message(punishment.getPlayerMessagePerma(), currentPunishment.getReason());
|
|
||||||
} else {
|
|
||||||
return new Message(punishment.getPlayerMessageUntil(), currentPunishment.getEndTime(), currentPunishment.getReason());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
|
public PunishmentCommand(String command, Punishment.PunishmentType punishmentType) {
|
||||||
new SWCommand(command, ConnectionListener.BAN_PERMISSION) {
|
new SWCommand(command, "bungeecore.ban") {
|
||||||
|
@Register(description = "PUNISHMENT_USAGE")
|
||||||
@Register
|
public void genericCommand(ProxiedPlayer player, String toPunish, String date, String... message) {
|
||||||
public void genericCommand(ProxiedPlayer player, @Mapper("toPunish") String toPunish, String date, @ErrorMessage(allowEAs = false, value = "PUNISHMENT_USAGE_REASON") String... message) {
|
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
|
||||||
SteamwarUser punisher = SteamwarUser.get(player.getUniqueId());
|
|
||||||
if (punishmentType.isNeedsAdmin() && !punisher.hasPerm(UserPerm.MODERATION)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,47 +52,25 @@ public class PunishmentCommand {
|
|||||||
|
|
||||||
boolean isPerma = date.equalsIgnoreCase("perma");
|
boolean isPerma = date.equalsIgnoreCase("perma");
|
||||||
String msg = String.join(" ", message);
|
String msg = String.join(" ", message);
|
||||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
target.punish(punishmentType, banTime, msg, SteamwarUser.get(player.getName()).getId(), isPerma);
|
||||||
ban(target, banTime, msg, punisher, isPerma);
|
|
||||||
else
|
|
||||||
target.punish(punishmentType, banTime, msg, punisher.getId(), isPerma);
|
|
||||||
Message.team(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), player.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
Message.team(punishmentType.getTeamMessage(), new Message("PREFIX"), target.getUserName(), player.getName(), new Message((isPerma ? "PUNISHMENT_PERMA" : "PUNISHMENT_UNTIL"), banTime), msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
|
||||||
public void genericError(ProxiedPlayer player, String... args) {
|
|
||||||
ChatSender.of(player).send(true, ChatMessageType.CHAT, null, null, new Message("PUNISHMENT_USAGE", command));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mapper(value = "toPunish", local = true)
|
|
||||||
public TypeMapper<String> allUsers() {
|
|
||||||
return new TypeMapper<String>() {
|
|
||||||
@Override
|
|
||||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
|
||||||
List<String> players = BungeeCord.getInstance().getPlayers().stream()
|
|
||||||
.map(CommandSender::getName)
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
players.add(s);
|
|
||||||
return players;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
if (punishmentType.getUnpunishmentMessage() == null) {
|
||||||
if (punishmentType.getUnpunishmentMessage() == null) return;
|
return;
|
||||||
|
}
|
||||||
String antiCommand = "un" + command;
|
String antiCommand = "un" + command;
|
||||||
new SWCommand(antiCommand, ConnectionListener.BAN_PERMISSION) {
|
new SWCommand(antiCommand, "bungeecore.ban") {
|
||||||
@Register
|
@Register(description = "PUNISHMENT_USAGE")
|
||||||
public void genericCommand(ProxiedPlayer player, @ErrorMessage("UNKNOWN_PLAYER") SteamwarUser target) {
|
public void genericCommand(ProxiedPlayer player, String toUnpunish) {
|
||||||
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) {
|
if (punishmentType.isNeedsAdmin() && !SteamwarUser.get(player).getUserGroup().isAdminGroup()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SteamwarUser target = existingUser(player, toUnpunish);
|
||||||
|
if (target == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!target.isPunished(punishmentType)) {
|
if (!target.isPunished(punishmentType)) {
|
||||||
Message.send(punishmentType.getUsageNotPunished(), player);
|
Message.send(punishmentType.getUsageNotPunished(), player);
|
||||||
return;
|
return;
|
||||||
@ -186,61 +78,28 @@ public class PunishmentCommand {
|
|||||||
|
|
||||||
Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
|
Message.send(punishmentType.getUnpunishmentMessage(), player, target.getUserName());
|
||||||
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(player.getName()).getId(), false);
|
target.punish(punishmentType, Timestamp.from(new Date().toInstant()), antiCommand, SteamwarUser.get(player.getName()).getId(), false);
|
||||||
if(punishmentType == Punishment.PunishmentType.Ban)
|
|
||||||
BannedUserIPs.unbanIPs(target.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Register
|
|
||||||
public void genericError(ProxiedPlayer player, String... args) {
|
|
||||||
ChatSender.of(player).send(true, ChatMessageType.CHAT, null, null, new Message("UNPUNISHMENT_USAGE", antiCommand));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
protected SteamwarUser existingUser(CommandSender sender, String arg){
|
||||||
SteamwarUser target = getOrCreateOfflinePlayer(arg);
|
SteamwarUser target = SteamwarUser.get(arg);
|
||||||
if(target == null)
|
if(target == null)
|
||||||
Message.send("UNKNOWN_PLAYER", sender);
|
Message.send("UNKNOWN_PLAYER", sender);
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Pattern RELATIVE_PATTERN = Pattern.compile("([1-9]\\d*[hdwmy])+");
|
protected SteamwarUser unsafeUser(CommandSender sender, String arg){
|
||||||
|
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(arg);
|
||||||
|
if(target == null)
|
||||||
|
Message.send("UNKNOWN_PLAYER", sender);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
public static Timestamp parseTime(CommandSender sender, String arg) {
|
public static Timestamp parseTime(CommandSender sender, String arg) {
|
||||||
if (arg.equalsIgnoreCase("perma")) {
|
if (arg.equalsIgnoreCase("perma")) {
|
||||||
return Punishment.PERMA_TIME;
|
return Punishment.PERMA_TIME;
|
||||||
} else {
|
} else {
|
||||||
if (RELATIVE_PATTERN.matcher(arg).matches()) {
|
|
||||||
Instant instant = Instant.now();
|
|
||||||
StringBuilder st = new StringBuilder();
|
|
||||||
for (int i = 0; i < arg.length(); i++) {
|
|
||||||
char c = arg.charAt(i);
|
|
||||||
if (c >= '0' && c <= '9') {
|
|
||||||
st.append(c);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
int amount = Integer.parseInt(st.toString());
|
|
||||||
st = new StringBuilder();
|
|
||||||
switch (c) {
|
|
||||||
case 'h':
|
|
||||||
instant = instant.plus(amount, ChronoUnit.HOURS);
|
|
||||||
break;
|
|
||||||
case 'd':
|
|
||||||
instant = instant.plus(amount, ChronoUnit.DAYS);
|
|
||||||
break;
|
|
||||||
case 'w':
|
|
||||||
instant = instant.plus(Duration.ofSeconds(amount * ChronoUnit.WEEKS.getDuration().getSeconds()));
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
instant = instant.plus(Duration.ofSeconds(amount * ChronoUnit.MONTHS.getDuration().getSeconds()));
|
|
||||||
break;
|
|
||||||
case 'y':
|
|
||||||
instant = instant.plus(Duration.ofSeconds(amount * ChronoUnit.YEARS.getDuration().getSeconds()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Timestamp.from(instant);
|
|
||||||
}
|
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy_HH:mm");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy_HH:mm");
|
||||||
try {
|
try {
|
||||||
Date parsedDate = dateFormat.parse(arg);
|
Date parsedDate = dateFormat.parse(arg);
|
||||||
|
@ -21,12 +21,13 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.ArenaMode;
|
import de.steamwar.bungeecore.ArenaMode;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import de.steamwar.bungeecore.sql.UserElo;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.UserElo;
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -40,30 +41,39 @@ public class RankCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void ownRank(ProxiedPlayer player) {
|
public void ownRank(ProxiedPlayer player) {
|
||||||
rank(player, SteamwarUser.get(player.getUniqueId()));
|
rank(player, player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void rank(ProxiedPlayer player, @ErrorMessage("RANK_PLAYER_NOT_FOUND") SteamwarUser user) {
|
public void rank(ProxiedPlayer player, @Mapper("player") String s) {
|
||||||
if (!player.getName().equals(user.getUserName())) {
|
SteamwarUser user = SteamwarUser.get(s);
|
||||||
Message.sendPrefixless("RANK_PLAYER_FOUND", player, user.getUserName());
|
if (user == null) {
|
||||||
|
Message.send("RANK_PLAYER_NOT_FOUND", player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!player.getName().equals(s)) {
|
||||||
|
Message.send("RANK_PLAYER_FOUND", player, user.getUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ArenaMode mode : ArenaMode.getAllModes()) {
|
for(ArenaMode mode : ArenaMode.getAllModes()) {
|
||||||
if (!mode.isRanked())
|
if (!mode.isRanked())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
Message.send("RANK_HEADER", player, mode.getChatName());
|
||||||
|
|
||||||
Optional<Integer> elo = UserElo.getElo(user.getId(), mode.getSchemType());
|
Optional<Integer> elo = UserElo.getElo(user.getId(), mode.getSchemType());
|
||||||
String eloString;
|
|
||||||
if (elo.isPresent()) {
|
if (elo.isPresent()) {
|
||||||
int placement = UserElo.getPlacement(elo.get(), mode.getSchemType());
|
int placement = UserElo.getPlacement(elo.get(), mode.getSchemType());
|
||||||
eloString = Message.parse("RANK_PLACED", player, placement, elo.get());
|
Message.send("RANK_PLACED", player, placement, elo.get());
|
||||||
} else {
|
} else {
|
||||||
eloString = Message.parse("RANK_UNPLACED", player);
|
Message.send("RANK_UNPLACED", player);
|
||||||
}
|
}
|
||||||
|
Message.send("RANK_EMBLEM", player, UserElo.getEmblemProgression(player, mode.getChatName(), user.getId()));
|
||||||
Message.sendPrefixless("RANK_HEADER", player, mode.getChatName(), eloString);
|
|
||||||
Message.sendPrefixless("RANK_EMBLEM", player, UserElo.getEmblemProgression(mode.getChatName(), user.getId()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mapper(value = "player", local = true)
|
||||||
|
public TypeMapper<String> playerTypeMapper() {
|
||||||
|
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,5 @@ public class RegelnCommand extends SWCommand {
|
|||||||
Message.sendPrefixless("REGELN_MWG", player, Message.parse("REGELN_MWG_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_MWG_URL", player)));
|
Message.sendPrefixless("REGELN_MWG", player, Message.parse("REGELN_MWG_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_MWG_URL", player)));
|
||||||
Message.sendPrefixless("REGELN_WG", player, Message.parse("REGELN_WG_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_WG_URL", player)));
|
Message.sendPrefixless("REGELN_WG", player, Message.parse("REGELN_WG_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_WG_URL", player)));
|
||||||
Message.sendPrefixless("REGELN_WS", player, Message.parse("REGELN_WS_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_WS_URL", player)));
|
Message.sendPrefixless("REGELN_WS", player, Message.parse("REGELN_WS_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_WS_URL", player)));
|
||||||
Message.sendPrefixless("REGELN_QG", player, Message.parse("REGELN_QG_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_QG_URL", player)));
|
|
||||||
Message.sendPrefixless("REGELN_CONDUCT", player, Message.parse("REGELN_CONDUCT_HOVER", player), new ClickEvent(ClickEvent.Action.OPEN_URL, Message.parse("REGELN_CONDUCT_URL", player)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,13 @@ import de.steamwar.bungeecore.*;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.bungeecore.sql.Fight;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
|
import de.steamwar.bungeecore.sql.SchematicType;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -41,12 +45,12 @@ public class ReplayCommand extends SWCommand {
|
|||||||
@Register
|
@Register
|
||||||
public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) {
|
public void genericCommand(ProxiedPlayer player, @OptionalValue("") String optionalMap) {
|
||||||
ChatSender sender = ChatSender.of(player);
|
ChatSender sender = ChatSender.of(player);
|
||||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> {
|
new SWStreamInv<>(player, Message.parse("REPLAY_TITLE", player), (click, fight) -> {
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
ArenaMode mode = ArenaMode.getBySchemType(fight.getSchemType());
|
ArenaMode mode = fight.getGameMode();
|
||||||
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player);
|
ServerStarter starter = new ServerStarter().replay(fight.getFightID()).blueLeader(player);
|
||||||
|
|
||||||
String map = mode.getRandomMap();
|
String map = mode.getRandomMap();
|
||||||
@ -55,7 +59,7 @@ public class ReplayCommand extends SWCommand {
|
|||||||
if (tMap != null) map = tMap;
|
if (tMap != null) map = tMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.hasPerm(UserPerm.MODERATION) && click.isShiftClick() && fight.replayExists()) {
|
if (user.getUserGroup().isAdminGroup() && click.isShiftClick() && fight.replayExists()) {
|
||||||
starter.test(mode, map, player).start();
|
starter.test(mode, map, player).start();
|
||||||
} else if(!fight.replayAllowed()) {
|
} else if(!fight.replayAllowed()) {
|
||||||
sender.system("REPLAY_UNAVAILABLE");
|
sender.system("REPLAY_UNAVAILABLE");
|
||||||
|
@ -20,16 +20,17 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
public class ServerSwitchCommand extends SWCommand {
|
public class ServerSwitchCommand extends SWCommand {
|
||||||
|
|
||||||
private final String serverName;
|
private String serverName;
|
||||||
|
|
||||||
public ServerSwitchCommand(String cmd, String name, String... aliases) {
|
public ServerSwitchCommand(String cmd, String name, String permission, String... aliases) {
|
||||||
super(cmd, null, aliases);
|
super(cmd, permission, aliases);
|
||||||
serverName = name;
|
serverName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.listeners.ConnectionListener;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -28,7 +27,7 @@ import net.md_5.bungee.api.CommandSender;
|
|||||||
public class ServerTeamchatCommand extends SWCommand {
|
public class ServerTeamchatCommand extends SWCommand {
|
||||||
|
|
||||||
public ServerTeamchatCommand() {
|
public ServerTeamchatCommand() {
|
||||||
super("stc", ConnectionListener.TEAMCHAT_PERMISSION,"serverteamchat");
|
super("stc", "bungeecore.teamchat","serverteamchat");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "STC_USAGE")
|
@Register(description = "STC_USAGE")
|
||||||
|
@ -19,10 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -37,7 +35,6 @@ public class SetLocaleCommand extends SWCommand {
|
|||||||
public void genericCommand(ProxiedPlayer player) {
|
public void genericCommand(ProxiedPlayer player) {
|
||||||
ChatSender sender = ChatSender.of(player);
|
ChatSender sender = ChatSender.of(player);
|
||||||
sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true);
|
sender.user().setLocale(Objects.requireNonNull(player.getLocale()), true);
|
||||||
NetworkSender.send(player, new LocaleInvalidationPacket(sender.user().getId()));
|
|
||||||
sender.system("LOCK_LOCALE_CHANGED");
|
sender.system("LOCK_LOCALE_CHANGED");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -20,28 +20,30 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
||||||
|
|
||||||
public class TeamchatCommand extends SWCommand {
|
public class TeamchatCommand extends BasicCommand {
|
||||||
|
|
||||||
public TeamchatCommand() {
|
public TeamchatCommand() {
|
||||||
super("tc", "","teamchat");
|
super("tc", "","teamchat");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "TC_USAGE")
|
@Override
|
||||||
public void genericCommand(ProxiedPlayer player, @ErrorMessage(value = "TC_USAGE", allowEAs = false) String... args) {
|
public void execute(CommandSender s, String[] args) {
|
||||||
ChatSender sender = ChatSender.of(player);
|
ChatSender sender = ChatSender.of(s);
|
||||||
SteamwarUser user = sender.user();
|
if(args.length == 0){
|
||||||
|
sender.system("TC_USAGE");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SteamwarUser user = sender.user();
|
||||||
if(user.getTeam() == 0){
|
if(user.getTeam() == 0){
|
||||||
sender.system("TC_NO_TEAM");
|
sender.system("TC_NO_TEAM");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(p -> p.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args));
|
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(player -> player.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.bungeecore.util.BauLock;
|
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.command.SWCommand;
|
|
||||||
import de.steamwar.command.TypeMapper;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -32,113 +29,90 @@ import net.md_5.bungee.api.ProxyServer;
|
|||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TpCommand extends SWCommand {
|
public class TpCommand extends BasicCommand {
|
||||||
|
|
||||||
public TpCommand(){
|
public TpCommand(){
|
||||||
super("join", null, "tp", "teleport");
|
super("join", null, "tp", "teleport");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Override
|
||||||
public void genericCommand(ProxiedPlayer p) {
|
public void execute(CommandSender s, String[] args) {
|
||||||
ChatSender.of(p).system(Event.get() == null ? "TP_USAGE" : "TP_USAGE_EVENT");
|
if(!(s instanceof ProxiedPlayer))
|
||||||
}
|
return;
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) s;
|
||||||
|
|
||||||
@Register
|
ChatSender sender = ChatSender.of(player);
|
||||||
public void teleportCommand(ProxiedPlayer p, @Mapper("to") String to, String... rest) {
|
if(args.length == 0){
|
||||||
ServerInfo server = getTarget(to);
|
if(Event.get() == null)
|
||||||
|
sender.system("TP_USAGE");
|
||||||
//Give control of teleport command to server
|
else
|
||||||
if (server == p.getServer().getInfo() || server == null) {
|
sender.system("TP_USAGE_EVENT");
|
||||||
if (rest.length == 0) {
|
|
||||||
Chat19.chat(p, "/tp " + to);
|
|
||||||
} else {
|
|
||||||
Chat19.chat(p, "/tp " + to + " " + String.join(" ", rest));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
teleport(p, server);
|
ServerInfo server = getTarget(args[0]);
|
||||||
|
boolean onTeamServer = Storage.teamServers.containsValue(player.getServer().getInfo());
|
||||||
|
|
||||||
|
//Give control of teleport command to server
|
||||||
|
if (server == player.getServer().getInfo() || onTeamServer || server == null) {
|
||||||
|
Chat19.chat(player, "/tp " + String.join(" ", args));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
teleport(player, server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper("to")
|
@Override
|
||||||
@Cached(cacheDuration = 10)
|
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
|
||||||
public TypeMapper<String> tabCompleter() {
|
if(args.length > 0)
|
||||||
return new TypeMapper<String>() {
|
return allPlayers(args[args.length - 1]);
|
||||||
@Override
|
return new ArrayList<>();
|
||||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> tabCompletes(CommandSender sender, String[] previousArguments, String s) {
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
for (ProxiedPlayer player : BungeeCord.getInstance().getPlayers()) {
|
|
||||||
list.add(player.getName());
|
|
||||||
}
|
|
||||||
if (Event.get() != null) {
|
|
||||||
EventStarter.getEventServer().keySet().forEach(teamId -> {
|
|
||||||
Team team = Team.get(teamId);
|
|
||||||
list.add(team.getTeamName());
|
|
||||||
list.add(team.getTeamKuerzel());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (Storage.teamServers.containsValue(((ProxiedPlayer) sender).getServer().getInfo())) {
|
|
||||||
Storage.directTabItems.getOrDefault((ProxiedPlayer) sender, Collections.emptyMap()).forEach((uuid, item) -> {
|
|
||||||
list.add(item.getUsername());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void teleport(ProxiedPlayer player, ServerInfo server) {
|
public static void teleport(ProxiedPlayer player, ServerInfo server){
|
||||||
ChatSender sender = ChatSender.of(player);
|
ChatSender sender = ChatSender.of(player);
|
||||||
if(CheckCommand.isChecking(player)){
|
if(CheckCommand.isChecking(player)){
|
||||||
sender.system("CHECK_CHECKING");
|
sender.system("CHECK_CHECKING");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
|
||||||
Subserver subserver = Subserver.getSubserver(server);
|
Subserver subserver = Subserver.getSubserver(server);
|
||||||
if(subserver == null) {
|
|
||||||
|
if (subserver != null && subserver.getType() == Servertype.ARENA) {
|
||||||
|
if (!sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
||||||
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
|
|
||||||
|
} else if(subserver instanceof Bauserver) {
|
||||||
|
Bauserver bauserver = (Bauserver) subserver;
|
||||||
|
ProxiedPlayer checker = BungeeCord.getInstance().getPlayer(bauserver.getOwner());
|
||||||
|
if (checker != null && CheckCommand.isChecking(checker)) {
|
||||||
|
SteamwarUser steamwarUser = SteamwarUser.get(player);
|
||||||
|
if (steamwarUser.getUserGroup().isCheckSchematics() || CheckCommand.getCheckingSchem(checker).getOwner() == steamwarUser.getId()) {
|
||||||
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
|
} else {
|
||||||
|
sender.system("JOIN_PLAYER_BLOCK");
|
||||||
|
}
|
||||||
|
}else if (BauLock.isLocked(SteamwarUser.get(bauserver.getOwner()), sender.user())) {
|
||||||
|
Message.send("BAU_LOCKED_NOALLOWED", player);
|
||||||
|
}else if (bauserver.getOwner().equals(player.getUniqueId()) || BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
||||||
|
SubserverSystem.sendPlayer(subserver, player);
|
||||||
|
} else {
|
||||||
|
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
||||||
|
sender.system("JOIN_PLAYER_BLOCK");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if(subserver instanceof Builderserver && !player.hasPermission("bungeecore.server.team")) {
|
||||||
|
sender.system("JOIN_PLAYER_BLOCK");
|
||||||
|
} else if (serverPerm != null && !player.hasPermission(serverPerm)) {
|
||||||
|
sender.system("JOIN_PLAYER_BLOCK");
|
||||||
|
} else if (serverPerm == null && !player.getGroups().contains("team")) {
|
||||||
|
sender.system("JOIN_PLAYER_BLOCK");
|
||||||
|
} else {
|
||||||
player.connect(server);
|
player.connect(server);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (subserver.getType()) {
|
|
||||||
case ARENA:
|
|
||||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer))
|
|
||||||
return;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BAUSERVER:
|
|
||||||
Bauserver bauserver = (Bauserver) subserver;
|
|
||||||
ProxiedPlayer checker = BungeeCord.getInstance().getPlayer(bauserver.getOwner());
|
|
||||||
if (checker != null && CheckCommand.isChecking(checker)) {
|
|
||||||
if (!sender.user().hasPerm(UserPerm.CHECK) && CheckCommand.getCheckingSchem(checker).getOwner() != sender.user().getId()) {
|
|
||||||
sender.system("JOIN_PLAYER_BLOCK");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (BauLock.checkNotifyLocked(SteamwarUser.get(bauserver.getOwner()), player)) {
|
|
||||||
return;
|
|
||||||
} else if (!bauserver.getOwner().equals(player.getUniqueId()) && BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) == null) {
|
|
||||||
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
|
||||||
sender.system("JOIN_PLAYER_BLOCK");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BUILDER:
|
|
||||||
if(!sender.user().hasPerm(UserPerm.BUILD)) {
|
|
||||||
sender.system("JOIN_PLAYER_BLOCK");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SubserverSystem.sendPlayer(subserver, player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ServerInfo getTarget(String arg) {
|
private static ServerInfo getTarget(String arg) {
|
||||||
|
@ -24,12 +24,10 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.inventory.SWListInv;
|
import de.steamwar.bungeecore.inventory.SWListInv;
|
||||||
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
import de.steamwar.bungeecore.inventory.SWStreamInv;
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import de.steamwar.bungeecore.sql.Tutorial;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.sql.Tutorial;
|
|
||||||
import de.steamwar.sql.UserPerm;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
@ -38,6 +36,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class TutorialCommand extends SWCommand {
|
public class TutorialCommand extends SWCommand {
|
||||||
@ -53,14 +52,14 @@ public class TutorialCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register("rate")
|
@Register("rate")
|
||||||
public void rate(ProxiedPlayer player) {
|
public void rate(ProxiedPlayer player) {
|
||||||
Chat19.chat(player, "/tutorial rate");
|
player.chat("/tutorial rate");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register("rate")
|
@Register("rate")
|
||||||
public void rate(ProxiedPlayer player, int id) {
|
public void rate(ProxiedPlayer player, int id) {
|
||||||
Tutorial tutorial = Tutorial.get(id);
|
Tutorial tutorial = Tutorial.get(id);
|
||||||
if(tutorial == null) {
|
if(tutorial == null) {
|
||||||
Chat19.chat(player, "/tutorial rate"); // Catch players manually entering numbers
|
BungeeCore.get().getLogger().log(Level.SEVERE, "rate executed with nonexistent id: " + id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +83,9 @@ public class TutorialCommand extends SWCommand {
|
|||||||
|
|
||||||
@Validator("unreleased")
|
@Validator("unreleased")
|
||||||
public TypeValidator<ProxiedPlayer> unreleasedChecker() {
|
public TypeValidator<ProxiedPlayer> unreleasedChecker() {
|
||||||
return (sender, value, messageSender) -> (SteamwarUser.get((value).getUniqueId()).hasPerm(UserPerm.TEAM));
|
return (sender, value, messageSender) -> {
|
||||||
|
return (SteamwarUser.get((value).getUniqueId()).getUserGroup().isTeamGroup());
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openInventory(ProxiedPlayer player, boolean released, boolean own) {
|
private void openInventory(ProxiedPlayer player, boolean released, boolean own) {
|
||||||
@ -94,37 +95,36 @@ public class TutorialCommand extends SWCommand {
|
|||||||
player,
|
player,
|
||||||
Message.parse("TUTORIAL_TITLE", player),
|
Message.parse("TUTORIAL_TITLE", player),
|
||||||
(click, tutorial) -> {
|
(click, tutorial) -> {
|
||||||
if(!released && click.isShiftClick() && user.hasPerm(UserPerm.TEAM) && user.getId() != tutorial.getCreator()) {
|
if(!released && click.isShiftClick() && user.getUserGroup().isTeamGroup() && user != tutorial.creator()) {
|
||||||
tutorial.release();
|
tutorial.release();
|
||||||
openInventory(player, released, own);
|
openInventory(player, released, own);
|
||||||
return;
|
return;
|
||||||
} else if(own && click.isShiftClick() && click.isRightClick()) {
|
} else if(own && click.isShiftClick() && click.isRightClick()) {
|
||||||
tutorial.delete();
|
tutorial.delete();
|
||||||
SubserverSystem.deleteFolder(VelocityCore.local, world(tutorial).getPath());
|
|
||||||
openInventory(player, released, own);
|
openInventory(player, released, own);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new ServerStarter().tutorial(player, tutorial).start();
|
new ServerStarter().tutorial(player, tutorial).start();
|
||||||
},
|
},
|
||||||
page -> (own ? Tutorial.getOwn(user.getId(), page, 45) : Tutorial.getPage(page, 45, released)).stream().map(tutorial -> new SWListInv.SWListEntry<>(getTutorialItem(player, tutorial, own), tutorial)).collect(Collectors.toList())
|
page -> (own ? Tutorial.getOwn(user, page, 45) : Tutorial.getPage(page, 45, released)).stream().map(tutorial -> new SWListInv.SWListEntry<>(getTutorialItem(player, tutorial, own), tutorial)).collect(Collectors.toList())
|
||||||
).open();
|
).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SWItem getTutorialItem(ProxiedPlayer player, Tutorial tutorial, boolean personalHighlights) {
|
private SWItem getTutorialItem(ProxiedPlayer player, Tutorial tutorial, boolean personalHighlights) {
|
||||||
SWItem item = new SWItem(tutorial.getItem(), Message.parse("TUTORIAL_NAME", player, tutorial.getName()));
|
SWItem item = new SWItem(tutorial.item(), Message.parse("TUTORIAL_NAME", player, tutorial.name()));
|
||||||
item.setHideAttributes(true);
|
item.setHideAttributes(true);
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add(Message.parse("TUTORIAL_BY", player, SteamwarUser.get(tutorial.getCreator()).getUserName()));
|
lore.add(Message.parse("TUTORIAL_BY", player, tutorial.creator().getUserName()));
|
||||||
lore.add(Message.parse("TUTORIAL_STARS", player, String.format("%.1f", tutorial.getStars())));
|
lore.add(Message.parse("TUTORIAL_STARS", player, String.format("%.1f", tutorial.stars())));
|
||||||
|
|
||||||
if (personalHighlights)
|
if (personalHighlights)
|
||||||
lore.add(Message.parse("TUTORIAL_DELETE", player));
|
lore.add(Message.parse("TUTORIAL_DELETE", player));
|
||||||
|
|
||||||
item.setLore(lore);
|
item.setLore(lore);
|
||||||
|
|
||||||
if (personalHighlights && tutorial.isReleased())
|
if (personalHighlights && tutorial.released())
|
||||||
item.setEnchanted(true);
|
item.setEnchanted(true);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
@ -135,7 +135,7 @@ public class TutorialCommand extends SWCommand {
|
|||||||
int[] rates = new int[]{1, 2, 3, 4, 5};
|
int[] rates = new int[]{1, 2, 3, 4, 5};
|
||||||
|
|
||||||
new SWListInv<>(player, Message.parse("TUTORIAL_RATE_TITLE", player), Arrays.stream(rates).mapToObj(rate -> new SWListInv.SWListEntry<>(new SWItem("NETHER_STAR", Message.parse("TUTORIAL_RATE", player, rate)), rate)).collect(Collectors.toList()), (click, rate) -> {
|
new SWListInv<>(player, Message.parse("TUTORIAL_RATE_TITLE", player), Arrays.stream(rates).mapToObj(rate -> new SWListInv.SWListEntry<>(new SWItem("NETHER_STAR", Message.parse("TUTORIAL_RATE", player, rate)), rate)).collect(Collectors.toList()), (click, rate) -> {
|
||||||
tutorial.rate(user.getId(), rate);
|
tutorial.rate(user, rate);
|
||||||
SWInventory.close(player);
|
SWInventory.close(player);
|
||||||
}).open();
|
}).open();
|
||||||
}
|
}
|
||||||
@ -151,18 +151,14 @@ public class TutorialCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subserver.execute("save-all");
|
subserver.execute("save-all");
|
||||||
ProxyServer.getInstance().getScheduler().schedule(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
Tutorial tutorial = Tutorial.create(user.getId(), name, item);
|
Tutorial tutorial = Tutorial.create(user, name, item);
|
||||||
File tutorialWorld = world(tutorial);
|
File tutorialWorld = tutorial.world();
|
||||||
|
|
||||||
if (tutorialWorld.exists())
|
if (tutorialWorld.exists())
|
||||||
SubserverSystem.deleteFolder(VelocityCore.local, tutorialWorld.getPath());
|
SubserverSystem.deleteFolder(BungeeCore.local, tutorialWorld.getPath());
|
||||||
ServerStarter.copyWorld(VelocityCore.local, tempWorld.getPath(), tutorialWorld.getPath());
|
ServerStarter.copyWorld(BungeeCore.local, tempWorld.getPath(), tutorialWorld.getPath());
|
||||||
Message.send("TUTORIAL_CREATED", player);
|
Message.send("TUTORIAL_CREATED", player);
|
||||||
}, 1, TimeUnit.SECONDS);
|
}, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private File world(Tutorial tutorial) {
|
|
||||||
return new File(ServerStarter.TUTORIAL_PATH, String.valueOf(tutorial.getTutorialId()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,19 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.ArenaMode;
|
import de.steamwar.bungeecore.ArenaMode;
|
||||||
|
import de.steamwar.bungeecore.listeners.mods.ModLoaderBlocker;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.sql.Punishment;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
public class TypeMappers {
|
public class TypeMappers {
|
||||||
@ -44,10 +47,14 @@ public class TypeMappers {
|
|||||||
private static TypeValidator<ProxiedPlayer> arenaPlayer() {
|
private static TypeValidator<ProxiedPlayer> arenaPlayer() {
|
||||||
return (sender, value, messageSender) -> {
|
return (sender, value, messageSender) -> {
|
||||||
ChatSender player = ChatSender.of(value);
|
ChatSender player = ChatSender.of(value);
|
||||||
if (PunishmentCommand.isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
if (player.user().isPunishedWithMessage(player, Punishment.PunishmentType.NoFightServer)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ModLoaderBlocker.isFabric(value)) {
|
||||||
|
messageSender.send("MODLOADER_DENIED");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -71,6 +78,7 @@ public class TypeMappers {
|
|||||||
@Override
|
@Override
|
||||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
if (previousArguments.length == 0) return null;
|
if (previousArguments.length == 0) return null;
|
||||||
|
if (s.equalsIgnoreCase("random")) return "random";
|
||||||
return ArenaMode.getByChat(previousArguments[previousArguments.length - 1]).convertToRealMapName(s);
|
return ArenaMode.getByChat(previousArguments[previousArguments.length - 1]).convertToRealMapName(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +87,9 @@ public class TypeMappers {
|
|||||||
if (previousArguments.length == 0) return null;
|
if (previousArguments.length == 0) return null;
|
||||||
ArenaMode arenaMode = ArenaMode.getByChat(previousArguments[previousArguments.length - 1]);
|
ArenaMode arenaMode = ArenaMode.getByChat(previousArguments[previousArguments.length - 1]);
|
||||||
if (arenaMode == null) return null;
|
if (arenaMode == null) return null;
|
||||||
return arenaMode.getMaps();
|
List<String> stringList = new ArrayList<>(arenaMode.getMaps());
|
||||||
|
stringList.add("random");
|
||||||
|
return stringList;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.sql.IgnoreSystem;
|
import de.steamwar.bungeecore.sql.IgnoreSystem;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.bot.AuthManager;
|
import de.steamwar.bungeecore.bot.AuthManager;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -52,7 +52,7 @@ public class VerifyCommand extends SWCommand {
|
|||||||
if(bytes[0] == 'D' && bytes[1] == 'C') {
|
if(bytes[0] == 'D' && bytes[1] == 'C') {
|
||||||
Member member = AuthManager.connectAuth(SteamwarUser.get(sender.getName()), code);
|
Member member = AuthManager.connectAuth(SteamwarUser.get(sender.getName()), code);
|
||||||
if(member != null) {
|
if(member != null) {
|
||||||
VelocityCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong());
|
BungeeCore.log(sender.getName() + " Verified with Discorduser: " + member.getIdLong());
|
||||||
Message.send("VERIFY_SUCCESS", sender, member.getUser().getAsTag());
|
Message.send("VERIFY_SUCCESS", sender, member.getUser().getAsTag());
|
||||||
} else {
|
} else {
|
||||||
Message.send("VERIFY_INVALID", sender);
|
Message.send("VERIFY_INVALID", sender);
|
||||||
|
@ -21,60 +21,54 @@ package de.steamwar.bungeecore.commands;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.Storage;
|
import de.steamwar.bungeecore.Storage;
|
||||||
import de.steamwar.bungeecore.mods.ModUtils;
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import de.steamwar.bungeecore.sql.Team;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.messages.ChatSender;
|
|
||||||
import de.steamwar.sql.*;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
|
|
||||||
public class WhoisCommand extends SWCommand {
|
public class WhoisCommand extends SWCommand {
|
||||||
public WhoisCommand() {
|
public WhoisCommand() {
|
||||||
super("whois");
|
super("whois", "bungeecore.teamchat");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "WHOIS_USAGE")
|
@Register(description = "WHOIS_USAGE")
|
||||||
public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, WhoisParameterTypes... parameters) {
|
public void genericCommand(ProxiedPlayer player, @Mapper("player") String target, @OptionalValue("") @StaticValue(value = {"", "-all", "-a"}, allowISE = true) boolean all) {
|
||||||
ChatSender sender = ChatSender.of(player);
|
|
||||||
SteamwarUser user = SteamwarUser.get(target);
|
SteamwarUser user = SteamwarUser.get(target);
|
||||||
if (sender.user().hasPerm(UserPerm.ADMINISTRATION)) {
|
if (user == null) {
|
||||||
if (user == null) {
|
try {
|
||||||
try {
|
int id = Integer.parseInt(target);
|
||||||
int id = Integer.parseInt(target);
|
user = SteamwarUser.get(id);
|
||||||
user = SteamwarUser.get(id);
|
} catch (NumberFormatException ignored) {
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
// Ignored
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
try {
|
try {
|
||||||
long id = Long.parseLong(target);
|
long id = Long.parseLong(target);
|
||||||
user = SteamwarUser.get(id);
|
user = SteamwarUser.get(id);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
// Ignored
|
// Ignored
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
sender.system("UNKNOWN_PLAYER");
|
Message.send("UNKNOWN_PLAYER", player);
|
||||||
} else {
|
} else {
|
||||||
EnumSet<WhoisParameterTypes> set = parameters.length == 0 ? EnumSet.noneOf(WhoisParameterTypes.class) : EnumSet.copyOf(Arrays.asList(parameters));
|
sendUserinfo(player, user, all);
|
||||||
sendUserinfo(sender, user, set);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,61 +77,36 @@ public class WhoisCommand extends SWCommand {
|
|||||||
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
return SWCommandUtils.createMapper(s -> s, s -> BungeeCord.getInstance().getPlayers().stream().map(ProxiedPlayer::getName).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void sendUserinfo(ChatSender sender, SteamwarUser user, EnumSet<WhoisParameterTypes> parameterTypes) {
|
private static void sendUserinfo(ProxiedPlayer player, SteamwarUser user, boolean all) {
|
||||||
Team team = Team.get(user.getTeam());
|
Message.send("WHOIS_USERNAME", player, user.getUserName());
|
||||||
|
Message.send("WHOIS_UUID", player, Message.parse("WHOIS_UUID_HOVER", player), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUuid().toString()), user.getUuid().toString());
|
||||||
sender.system("WHOIS_USERNAME", user.getUserName());
|
Message.send("WHOIS_ID", player, user.getId());
|
||||||
sender.system("WHOIS_PREFIX", user.prefix().getColorCode() + user.prefix().getChatPrefix());
|
Message.send("WHOIS_GROUP", player, user.getUserGroup().getColorCode(), user.getUserGroup().name());
|
||||||
sender.system("WHOIS_TEAM", new Message("WHOIS_TEAM_HOVER", team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());
|
if (user.getDiscordId() != null) {
|
||||||
|
Message.send("WHOIS_DISCORD_ID", player, user.getDiscordId());
|
||||||
if (!sender.user().hasPerm(UserPerm.TEAM))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (sender.user().hasPerm(UserPerm.MODERATION)) {
|
|
||||||
sender.system("WHOIS_ID", user.getId());
|
|
||||||
sender.system("WHOIS_UUID", new Message("WHOIS_UUID_HOVER"), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, user.getUUID().toString()), user.getUUID().toString());
|
|
||||||
if (user.getDiscordId() != null)
|
|
||||||
sender.system("WHOIS_DISCORD_ID", user.getDiscordId());
|
|
||||||
|
|
||||||
sender.system("WHOIS_PERMS", user.perms().stream().map(Enum::name).collect(Collectors.joining(", ")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUUID());
|
|
||||||
Timestamp firstJoin = user.getFirstjoin();
|
Timestamp firstJoin = user.getFirstjoin();
|
||||||
double onlineTime = user.getOnlinetime();
|
if (firstJoin == null) {
|
||||||
if(firstJoin == null && target != null) {
|
Message.send("WHOIS_JOINED_FIRST", player, "0000-00-00 00:00:00");
|
||||||
firstJoin = Storage.sessions.get(target);
|
} else {
|
||||||
|
Message.send("WHOIS_JOINED_FIRST", player, firstJoin.toString());
|
||||||
|
}
|
||||||
|
Message.send("WHOIS_HOURS_PLAYED", player, new DecimalFormat("###.##").format(user.getOnlinetime() / 3600d));
|
||||||
|
|
||||||
|
if(BungeeCord.getInstance().getPlayer(user.getUuid()) != null) {
|
||||||
|
ProxiedPlayer target = BungeeCord.getInstance().getPlayer(user.getUuid());
|
||||||
|
Message.send("WHOIS_CURRENT_PLAYED", player, new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d));
|
||||||
|
Message.send("WHOIS_CURRENT_SERVER", player, target.getServer().getInfo().getName());
|
||||||
|
Message.send("WHOIS_CURRENT_PROTOCOL", player, target.getPendingConnection().getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(firstJoin != null)
|
Team team = Team.get(user.getTeam());
|
||||||
sender.system("WHOIS_JOINED_FIRST", firstJoin.toString());
|
Message.send("WHOIS_TEAM", player, Message.parse("WHOIS_TEAM_HOVER", player, team.getTeamName()), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + team.getTeamKuerzel()), team.getTeamColor(), team.getTeamKuerzel(), team.getTeamName());
|
||||||
sender.system("WHOIS_HOURS_PLAYED", new DecimalFormat("###.##").format(onlineTime / 3600d));
|
|
||||||
|
|
||||||
if(target != null) {
|
Message.send("WHOIS_PUNISHMENTS", player);
|
||||||
sender.system("WHOIS_CURRENT_PLAYED", new DecimalFormat("####.##").format((Instant.now().getEpochSecond() - Storage.sessions.get(target).toInstant().getEpochSecond()) / 60d));
|
|
||||||
sender.system("WHOIS_CURRENT_SERVER", target.getServer().getInfo().getName());
|
|
||||||
sender.system("WHOIS_CURRENT_PROTOCOL", target.getPendingConnection().getVersion());
|
|
||||||
|
|
||||||
List<Mod> mods = ModUtils.getPlayerModMap().get(user.getUUID());
|
|
||||||
if(mods == null)
|
|
||||||
mods = Collections.emptyList();
|
|
||||||
|
|
||||||
sender.system("WHOIS_PLATFORM", mods.isEmpty() ? "Vanilla" : mods.get(0).getPlatform().toString());
|
|
||||||
|
|
||||||
if (parameterTypes.contains(WhoisParameterTypes.MOD)) {
|
|
||||||
if (!mods.isEmpty()) {
|
|
||||||
sender.system("WHOIS_ACTIVE_MODS", mods.size(), mods.stream().map(mod -> "§" + mod.getModType().getColorCode() + mod.getModName()).collect(Collectors.joining("§8, ")));
|
|
||||||
} else {
|
|
||||||
sender.system("WHOIS_NO_ACTIVE_MODS");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.system("WHOIS_PUNISHMENTS");
|
|
||||||
List<Punishment> punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId());
|
List<Punishment> punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId());
|
||||||
Set<Punishment.PunishmentType> found = new HashSet<>();
|
Set<Punishment.PunishmentType> found = new HashSet<>();
|
||||||
boolean isPunished = false;
|
boolean isPunished = false;
|
||||||
boolean all = parameterTypes.contains(WhoisParameterTypes.ALL);
|
|
||||||
for (Punishment punishment : punishmentList) {
|
for (Punishment punishment : punishmentList) {
|
||||||
if (!all && !punishment.getType().isMulti() && !found.add(punishment.getType())) {
|
if (!all && !punishment.getType().isMulti() && !found.add(punishment.getType())) {
|
||||||
continue;
|
continue;
|
||||||
@ -145,53 +114,11 @@ public class WhoisCommand extends SWCommand {
|
|||||||
if (!all && !punishment.isCurrent()) {
|
if (!all && !punishment.isCurrent()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
sender.prefixless("WHOIS_PUNISHMENT", SteamwarUser.get(punishment.getPunisher()).getUserName(), punishment.getType().name(), punishment.getBantime(punishment.getStartTime(), false), punishment.getBantime(punishment.getEndTime(), punishment.isPerma()), punishment.getReason());
|
Message.sendPrefixless("WHOIS_PUNISHMENT", player, SteamwarUser.get(punishment.getPunisher()).getUserName(), punishment.getType().name(), punishment.getBantime(punishment.getStartTime(), false), punishment.getBantime(punishment.getEndTime(), punishment.isPerma()), punishment.getReason());
|
||||||
isPunished = true;
|
isPunished = true;
|
||||||
}
|
}
|
||||||
if (!isPunished) {
|
if (!isPunished) {
|
||||||
sender.system(all ? "WHOIS_NO_ALL_PUNISHMENT" : "WHOIS_NO_PUNISHMENT");
|
Message.send(all ? "WHOIS_NO_ALL_PUNISHMENT" : "WHOIS_NO_PUNISHMENT", player);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ClassMapper(value = WhoisParameterTypes.class, local = true)
|
|
||||||
public TypeMapper<WhoisParameterTypes> argumentTypeMapper() {
|
|
||||||
WhoisParameterTypes[] values = WhoisParameterTypes.values();
|
|
||||||
|
|
||||||
return new TypeMapper<WhoisParameterTypes>() {
|
|
||||||
@Override
|
|
||||||
public WhoisParameterTypes map(CommandSender commandSender, String[] previousArguments, String s) {
|
|
||||||
SteamwarUser user = SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId());
|
|
||||||
return Stream.of(values)
|
|
||||||
.filter(p -> user.hasPerm(p.perm))
|
|
||||||
.filter(p -> p.getTabCompletes().contains(s))
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
|
|
||||||
SteamwarUser user = SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId());
|
|
||||||
return Stream.of(values)
|
|
||||||
.filter(p -> user.hasPerm(p.perm))
|
|
||||||
.flatMap(p -> p.getTabCompletes().stream())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum WhoisParameterTypes {
|
|
||||||
ALL(Arrays.asList("-a", "-all"), UserPerm.TEAM),
|
|
||||||
MOD(Arrays.asList("-m", "-mod", "-mods"), UserPerm.MODERATION);
|
|
||||||
|
|
||||||
private final UserPerm perm;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private List<String> tabCompletes;
|
|
||||||
|
|
||||||
|
|
||||||
WhoisParameterTypes(List<String> tabCompletes, UserPerm perm) {
|
|
||||||
this.perm = perm;
|
|
||||||
this.tabCompletes = tabCompletes;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.bungeecore.inventory;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.network.handlers.InventoryCallbackHandler;
|
import de.steamwar.bungeecore.network.handlers.InventoryCallbackHandler;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
import de.steamwar.network.packets.server.CloseInventoryPacket;
|
||||||
import de.steamwar.network.packets.server.InventoryPacket;
|
import de.steamwar.network.packets.server.InventoryPacket;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
@ -46,7 +46,7 @@ public class SWInventory {
|
|||||||
|
|
||||||
public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) {
|
public SWInventory(ProxiedPlayer proxiedPlayer, int size, String title) {
|
||||||
itemMap = new HashMap<>();
|
itemMap = new HashMap<>();
|
||||||
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer.getUniqueId()).getId(), this);
|
InventoryCallbackHandler.inventoryHashMap.put(SteamwarUser.get(proxiedPlayer).getId(), this);
|
||||||
this.player = proxiedPlayer;
|
this.player = proxiedPlayer;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
@ -114,7 +114,7 @@ public class SWInventory {
|
|||||||
|
|
||||||
public void handleClose() {
|
public void handleClose() {
|
||||||
if(processingClick.compareAndSet(false, true)) {
|
if(processingClick.compareAndSet(false, true)) {
|
||||||
InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player.getUniqueId()).getId(), this);
|
InventoryCallbackHandler.inventoryHashMap.remove(SteamwarUser.get(player).getId(), this);
|
||||||
if(close != null)
|
if(close != null)
|
||||||
close.clicked(null);
|
close.clicked(null);
|
||||||
processingClick.set(false);
|
processingClick.set(false);
|
||||||
@ -122,7 +122,7 @@ public class SWInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void open() {
|
public void open() {
|
||||||
InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player.getUniqueId()).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).toString()));
|
InventoryPacket inv = new InventoryPacket(title, SteamwarUser.get(player).getId(), size, map(itemMap, (integer, swItem) -> swItem.writeToString(integer).toString()));
|
||||||
NetworkSender.send(player, inv);
|
NetworkSender.send(player, inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ public class SWInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void close(ProxiedPlayer player) {
|
public static void close(ProxiedPlayer player) {
|
||||||
NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player.getUniqueId()).getId()));
|
NetworkSender.send(player, new CloseInventoryPacket(SteamwarUser.get(player).getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClose(InvCallback close) {
|
public void setClose(InvCallback close) {
|
||||||
|
@ -19,44 +19,44 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
import de.steamwar.bungeecore.listeners.mods.Forge;
|
||||||
import de.steamwar.bungeecore.commands.WebpasswordCommand;
|
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.sql.BannedUserIPs;
|
|
||||||
import de.steamwar.sql.Punishment;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.PendingConnection;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.LoginEvent;
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class BanListener extends BasicListener {
|
public class BanListener extends BasicListener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogin(LoginEvent event) {
|
public void onLogin(LoginEvent event) {
|
||||||
event.registerIntent(VelocityCore.get());
|
event.registerIntent(BungeeCore.get());
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
PendingConnection connection = event.getConnection();
|
SteamwarUser user = SteamwarUser.getOrCreate(event.getConnection());
|
||||||
SteamwarUser user = SteamwarUser.getOrCreate(connection.getUniqueId(), connection.getName(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername);
|
|
||||||
String ip = IPSanitizer.getTrueAddress(connection).getHostAddress();
|
|
||||||
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
if (user.isPunished(Punishment.PunishmentType.Ban)) {
|
||||||
|
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
BannedUserIPs.banIP(user.getId(), ip);
|
ChatSender.of(event).system(user.punishmentMessage(Punishment.PunishmentType.Ban));
|
||||||
ChatSender.of(event).system(PunishmentCommand.punishmentMessage(user, Punishment.PunishmentType.Ban));
|
event.completeIntent(BungeeCore.get());
|
||||||
event.completeIntent(VelocityCore.get());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<BannedUserIPs> ips = BannedUserIPs.get(ip);
|
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||||
if(!ips.isEmpty()){
|
if(!ips.isEmpty()){
|
||||||
|
|
||||||
Timestamp highestBan = ips.get(0).getTimestamp();
|
Timestamp highestBan = ips.get(0).getTimestamp();
|
||||||
boolean perma = false;
|
boolean perma = false;
|
||||||
for(BannedUserIPs banned : ips) {
|
for(BannedUserIPs banned : ips) {
|
||||||
@ -73,22 +73,30 @@ public class BanListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " "
|
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " "
|
||||||
+ (perma?"perma":highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm")))
|
+ (perma?"perma":highestBan.toLocalDateTime().format(DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm")))
|
||||||
+ " Ban Evasion - Bannumgehung");
|
+ " Bannumgehung");
|
||||||
|
|
||||||
ChatSender.serverteamReceivers().forEach(sender -> sender.system(
|
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
"BAN_AVOIDING_ALERT",
|
if ((target.hasPermission("bungeecore.teamchat"))
|
||||||
new Message("BAN_AVOIDING_BAN_HOVER"),
|
&& (target.getChatMode() == ProxiedPlayer.ChatMode.COMMANDS_ONLY
|
||||||
clickEvent,
|
|| target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN)){
|
||||||
user.getUserName(),
|
StringBuilder potentialBan = new StringBuilder();
|
||||||
ips.stream().map(banned -> {
|
potentialBan.append(Message.parsePrefixed("BAN_AVOIDING_ALERT", target, user.getUserName()));
|
||||||
|
|
||||||
|
for(BannedUserIPs banned : ips) {
|
||||||
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
SteamwarUser bannedUser = SteamwarUser.get(banned.getUserID());
|
||||||
return sender.parseToLegacy("BAN_AVOIDING_LIST", bannedUser.getUserName(),
|
potentialBan.append(Message.parse("BAN_AVOIDING_LIST", target, bannedUser.getUserName(),
|
||||||
banned.getTimestamp().toLocalDateTime().format(DateTimeFormatter.ofPattern(sender.parseToPlain("TIMEFORMAT"))));
|
banned.getTimestamp().toLocalDateTime().format(DateTimeFormatter.ofPattern(Message.parse("TIMEFORMAT", target)))));
|
||||||
}).collect(Collectors.joining(" "))
|
}
|
||||||
));
|
|
||||||
|
TextComponent msg = new TextComponent(potentialBan.toString());
|
||||||
|
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Message.parse("BAN_AVOIDING_BAN_HOVER", target)).create()));
|
||||||
|
msg.setClickEvent(clickEvent);
|
||||||
|
target.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.completeIntent(VelocityCore.get());
|
Forge.onServerConnected(event);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
src/de/steamwar/bungeecore/listeners/BasicListener.java
Normale Datei
31
src/de/steamwar/bungeecore/listeners/BasicListener.java
Normale Datei
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
|
|
||||||
|
public abstract class BasicListener implements Listener {
|
||||||
|
|
||||||
|
public BasicListener(){
|
||||||
|
ProxyServer.getInstance().getPluginManager().registerListener(BungeeCore.get(), this);
|
||||||
|
}
|
||||||
|
}
|
71
src/de/steamwar/bungeecore/listeners/BrandListener.java
Normale Datei
71
src/de/steamwar/bungeecore/listeners/BrandListener.java
Normale Datei
@ -0,0 +1,71 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.ByteBufAllocator;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import net.md_5.bungee.protocol.DefinedPacket;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.NetworkInterface;
|
||||||
|
import java.net.SocketException;
|
||||||
|
|
||||||
|
public class BrandListener extends BasicListener {
|
||||||
|
|
||||||
|
private static boolean isLocalHost(InetAddress addr) {
|
||||||
|
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return NetworkInterface.getByInetAddress(addr) != null;
|
||||||
|
} catch (SocketException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onServerSwitch(PluginMessageEvent event) {
|
||||||
|
if(!event.getTag().equals("minecraft:brand") && !event.getTag().equals("MC|Brand")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLocalHost(event.getReceiver().getAddress().getAddress())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(event.getReceiver() instanceof ProxiedPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||||
|
String brandString = ChatSender.of(player).parseToLegacy("STEAMWAR_BRAND", ProxyServer.getInstance().getName(), player.getServer().getInfo().getName(), new String(event.getData(), 1, event.getData().length - 1));
|
||||||
|
|
||||||
|
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
||||||
|
DefinedPacket.writeString(brandString, brand);
|
||||||
|
player.sendData(event.getTag(), DefinedPacket.toArray(brand));
|
||||||
|
brand.release();
|
||||||
|
}
|
||||||
|
}
|
@ -21,12 +21,12 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.commands.PunishmentCommand;
|
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
|
import de.steamwar.bungeecore.sql.*;
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.messages.ChatSender;
|
import de.steamwar.messages.ChatSender;
|
||||||
import de.steamwar.network.packets.server.PingPacket;
|
import de.steamwar.network.packets.server.PingPacket;
|
||||||
import de.steamwar.sql.*;
|
import net.md_5.bungee.api.*;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.ChatEvent;
|
import net.md_5.bungee.api.event.ChatEvent;
|
||||||
import net.md_5.bungee.api.event.TabCompleteEvent;
|
import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||||
@ -37,13 +37,17 @@ import net.md_5.bungee.event.EventHandler;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class ChatListener extends BasicListener {
|
public class ChatListener extends BasicListener {
|
||||||
|
|
||||||
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemType).collect(Collectors.toList());
|
private static final Set<Integer> coloredTeams = new HashSet<>();
|
||||||
|
static {
|
||||||
|
coloredTeams.add(12);
|
||||||
|
coloredTeams.add(54);
|
||||||
|
coloredTeams.add(285);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChatEvent(ChatEvent e) {
|
public void onChatEvent(ChatEvent e) {
|
||||||
@ -55,9 +59,7 @@ public class ChatListener extends BasicListener {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
if (message.contains("jndi:ldap")) {
|
if (message.contains("jndi:ldap")) {
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser.get(player).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
|
||||||
PunishmentCommand.ban(user, Punishment.PERMA_TIME, "Versuchte Exploit-Ausnutzung", SteamwarUser.get(-1), true);
|
|
||||||
VelocityCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen jndi:ldap gebannt.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +95,7 @@ public class ChatListener extends BasicListener {
|
|||||||
|
|
||||||
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) {
|
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) {
|
||||||
SteamwarUser user = sender.user();
|
SteamwarUser user = sender.user();
|
||||||
final String coloredMessage = user.hasPerm(UserPerm.COLOR_CHAT) ? ChatColor.translateAlternateColorCodes('&', message) : message;
|
final String coloredMessage = (user.getUserGroup() != UserGroup.Member || coloredTeams.contains(user.getTeam())) ? ChatColor.translateAlternateColorCodes('&', message) : message;
|
||||||
if(chatFilter(sender, coloredMessage))
|
if(chatFilter(sender, coloredMessage))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -145,36 +147,34 @@ public class ChatListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser user = sender.user();
|
SteamwarUser user = sender.user();
|
||||||
if(!user.hasPerm(UserPerm.TEAM) && (message.contains("http:") || message.contains("https:") || message.contains("www."))){
|
UserGroup group = user.getUserGroup();
|
||||||
|
if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){
|
||||||
sender.system("CHAT_NO_LINKS");
|
sender.system("CHAT_NO_LINKS");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PunishmentCommand.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (message.contains("LIXFEL"))
|
if (message.contains("LIXFEL"))
|
||||||
specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15);
|
specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15);
|
||||||
if (message.contains("YOYONOW"))
|
if (message.contains("YOYONOW"))
|
||||||
specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12);
|
specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12);
|
||||||
if (message.contains("CHAOSCAOT"))
|
|
||||||
specialAlert(sender, "Chaoscaot", "CHAT_CHAOSCAOT_", 3, 6, 11, 12, 15, 17);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void chatToReciever(ChatSender receiver, ChatSender msgReceiver, SteamwarUser sender, String format, String message) {
|
private static void chatToReciever(ChatSender receiver, ChatSender msgReceiver, SteamwarUser sender, String format, String message) {
|
||||||
UserPerm.Prefix prefix = sender.prefix();
|
UserGroup group = sender.getUserGroup();
|
||||||
String chatColorCode = sender.hasPerm(UserPerm.TEAM) ? "§f" : "§7";
|
|
||||||
receiver.chat(new Message(format,
|
receiver.chat(new Message(format,
|
||||||
sender,
|
sender,
|
||||||
msgReceiver == null ? receiver : msgReceiver,
|
msgReceiver == null ? receiver : msgReceiver,
|
||||||
highlightMentions(message, chatColorCode, receiver),
|
highlightMentions(message, group.getChatColorCode(), receiver),
|
||||||
sender.getTeam() == 0 ? "" : "§" + Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
|
sender.getTeam() == 0 ? "" : "§" + Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
|
||||||
UserElo.getEmblem(sender, rankedModes),
|
UserElo.getEmblem(sender),
|
||||||
prefix.getColorCode(),
|
group.getColorCode(),
|
||||||
prefix.getChatPrefix().length() == 0 ? "§f" : prefix.getChatPrefix() + " ",
|
group.getChatPrefix().length() == 0 ? "§f" : group.getChatPrefix() + " ",
|
||||||
chatColorCode));
|
group.getChatColorCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean filteredCommand(CommandSender sender, String message) {
|
private static boolean filteredCommand(CommandSender sender, String message) {
|
||||||
@ -191,7 +191,7 @@ public class ChatListener extends BasicListener {
|
|||||||
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
|
TaskScheduler scheduler = ProxyServer.getInstance().getScheduler();
|
||||||
for(int i = 0; i < delay.length; i++) {
|
for(int i = 0; i < delay.length; i++) {
|
||||||
int finalI = i;
|
int finalI = i;
|
||||||
scheduler.schedule(VelocityCore.get(), () -> sender.prefixless("CHAT_MSG", name, sender.user(), new Message(baseMessage + (finalI+1))), delay[i], TimeUnit.SECONDS);
|
scheduler.schedule(BungeeCore.get(), () -> sender.prefixless("CHAT_MSG", name, sender.user(), new Message(baseMessage + (finalI+1))), delay[i], TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,13 +202,49 @@ public class ChatListener extends BasicListener {
|
|||||||
String mark = "@" + player.user().getUserName();
|
String mark = "@" + player.user().getUserName();
|
||||||
return Arrays.stream(message.split(" ")).map(cur -> {
|
return Arrays.stream(message.split(" ")).map(cur -> {
|
||||||
if(cur.equalsIgnoreCase(mark)) {
|
if(cur.equalsIgnoreCase(mark)) {
|
||||||
NetworkSender.send(ProxyServer.getInstance().getPlayer(player.user().getUUID()), new PingPacket(player.user().getId()));
|
NetworkSender.send(player.user().getPlayer(), new PingPacket(player.user().getId()));
|
||||||
return "§e" + cur + returnColor;
|
return "§e" + cur + returnColor;
|
||||||
}
|
}
|
||||||
return cur;
|
return cur;
|
||||||
}).collect(Collectors.joining(" "));
|
}).collect(Collectors.joining(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onTabCompleteEvent(TabCompleteEvent e){
|
||||||
|
List<String> suggestions = e.getSuggestions();
|
||||||
|
String [] cursor = e.getCursor().split(" ");
|
||||||
|
String last;
|
||||||
|
if(cursor.length != 0)
|
||||||
|
last = cursor[cursor.length - 1];
|
||||||
|
else
|
||||||
|
last = "";
|
||||||
|
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
||||||
|
String name = player.getName();
|
||||||
|
if (last.isEmpty() || name.startsWith(last)) {
|
||||||
|
suggestions.add(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(last.startsWith("@")) {
|
||||||
|
String plrName = last.replace("@", "");
|
||||||
|
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
||||||
|
String name = player.getName();
|
||||||
|
if ((plrName.isEmpty() || name.startsWith(plrName)) && !plrName.equalsIgnoreCase(name)) {
|
||||||
|
suggestions.add("@" + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(e.getSender() instanceof ProxiedPlayer && cursor.length == 1 && cursor[0].startsWith("/")){
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||||
|
for(String cmd : BungeeCore.commands.keySet()){
|
||||||
|
if(cmd.startsWith(cursor[0]) && player.hasPermission(BungeeCore.commands.get(cmd))){
|
||||||
|
suggestions.add(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTabCompleteResponseEvent(TabCompleteResponseEvent e){
|
public void onTabCompleteResponseEvent(TabCompleteResponseEvent e){
|
||||||
List<String> suggestions = e.getSuggestions();
|
List<String> suggestions = e.getSuggestions();
|
||||||
|
@ -21,9 +21,9 @@ package de.steamwar.bungeecore.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.*;
|
import de.steamwar.bungeecore.*;
|
||||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.bungeecore.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.bungeecore.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.bungeecore.Servertype;
|
import de.steamwar.bungeecore.Servertype;
|
||||||
import de.steamwar.bungeecore.Subserver;
|
import de.steamwar.bungeecore.Subserver;
|
||||||
@ -27,11 +27,9 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
|||||||
import de.steamwar.bungeecore.bot.util.DiscordRanks;
|
import de.steamwar.bungeecore.bot.util.DiscordRanks;
|
||||||
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
||||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||||
import de.steamwar.bungeecore.commands.ModCommand;
|
|
||||||
import de.steamwar.bungeecore.commands.MsgCommand;
|
import de.steamwar.bungeecore.commands.MsgCommand;
|
||||||
import de.steamwar.bungeecore.mods.ModUtils;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.UserGroup;
|
||||||
import de.steamwar.sql.UserPerm;
|
|
||||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -39,26 +37,18 @@ import net.md_5.bungee.api.config.ServerInfo;
|
|||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
|
import net.md_5.bungee.api.event.ServerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.ServerKickEvent;
|
import net.md_5.bungee.api.event.ServerKickEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ConnectionListener extends BasicListener {
|
public class ConnectionListener extends BasicListener {
|
||||||
|
|
||||||
public static final String ALERT_PERMISSION = "bungeecore.alert";
|
private static final String ADMIN_GROUP = "admin";
|
||||||
public static final String BAN_PERMISSION = "bungeecore.ban";
|
public static final String TEAM_GROUP = "team";
|
||||||
public static final String BUILDERCLOUD_PERMISSION = "bungeecore.buildercloud";
|
|
||||||
public static final String CHECK_PERMISSION = "bungeecore.check";
|
public static final String CHECK_PERMISSION = "bungeecore.check";
|
||||||
public static final String EVENTRELOAD_PERMISSION = "bungeecore.eventreload";
|
private static final String YOUTUBER_MODS = "bungeecore.youtubermods";
|
||||||
public static final String KICK_PERMISSION = "bungeecore.kick";
|
|
||||||
public static final String POLLRESULT_PERMISSION = "bungeecore.pollresult";
|
|
||||||
public static final String SOFTRELOAD_PERMISSION = "bungeecore.softreload";
|
|
||||||
public static final String TEAMCHAT_PERMISSION = "bungeecore.teamchat";
|
|
||||||
public static final String MOD_PERMISSION = "bungeecore.mod";
|
|
||||||
|
|
||||||
private static final Set<UUID> newPlayers = new HashSet<>();
|
private static final Set<UUID> newPlayers = new HashSet<>();
|
||||||
|
|
||||||
@ -71,36 +61,25 @@ public class ConnectionListener extends BasicListener {
|
|||||||
ProxiedPlayer player = event.getPlayer();
|
ProxiedPlayer player = event.getPlayer();
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
|
||||||
if(user.hasPerm(UserPerm.ADMINISTRATION)) {
|
player.removeGroups("Admin", "team");
|
||||||
player.setPermission("bungeecord.command.end", true);
|
|
||||||
player.setPermission("bungeecord.command.reload", true);
|
|
||||||
player.setPermission("bungeecord.command.ip", true);
|
|
||||||
player.setPermission(SOFTRELOAD_PERMISSION, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(user.hasPerm(UserPerm.MODERATION)) {
|
if(user.getUserGroup().isAdminGroup())
|
||||||
player.setPermission(ALERT_PERMISSION, true);
|
player.addGroups(ADMIN_GROUP);
|
||||||
player.setPermission(KICK_PERMISSION, true);
|
|
||||||
player.setPermission(POLLRESULT_PERMISSION, true);
|
|
||||||
player.setPermission(EVENTRELOAD_PERMISSION, true);
|
|
||||||
player.setPermission(MOD_PERMISSION, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(user.hasPerm(UserPerm.TEAM)) {
|
if(user.getUserGroup().isTeamGroup()) {
|
||||||
player.setPermission("bungeecord.command.list", true);
|
player.addGroups(TEAM_GROUP);
|
||||||
player.setPermission("bungeecord.command.send", true);
|
|
||||||
player.setPermission("bungeecord.command.server", true);
|
|
||||||
player.setPermission(TEAMCHAT_PERMISSION, true);
|
|
||||||
player.setPermission(BAN_PERMISSION, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(user.hasPerm(UserPerm.CHECK)) {
|
|
||||||
CheckCommand.sendReminder(player);
|
CheckCommand.sendReminder(player);
|
||||||
player.setPermission(CHECK_PERMISSION, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(user.hasPerm(UserPerm.BUILD)) {
|
if(user.getUserGroup().isCheckSchematics())
|
||||||
player.setPermission(BUILDERCLOUD_PERMISSION, true);
|
player.setPermission(CHECK_PERMISSION, true);
|
||||||
|
|
||||||
|
if(user.getUserGroup() != UserGroup.Member) {
|
||||||
|
player.setPermission(YOUTUBER_MODS, true);
|
||||||
|
player.setDisplayName(user.getUserGroup().getColorCode() + user.getUserGroup().getChatPrefix() + " " + player.getName() + "§r");
|
||||||
|
player.setPermission("bungeecore.group." + user.getUserGroup().name().toLowerCase(), true);
|
||||||
|
}else {
|
||||||
|
player.setDisplayName("§f" + player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Subserver subserver : Subserver.getServerList()){
|
for(Subserver subserver : Subserver.getServerList()){
|
||||||
@ -142,7 +121,7 @@ public class ConnectionListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInfo kickTo = ProxyServer.getInstance().getServerInfo(VelocityCore.LOBBY_SERVER);
|
ServerInfo kickTo = ProxyServer.getInstance().getServerInfo(BungeeCore.LOBBY_SERVER);
|
||||||
|
|
||||||
if (kickedFrom != null && kickedFrom.equals(kickTo)) {
|
if (kickedFrom != null && kickedFrom.equals(kickTo)) {
|
||||||
return;
|
return;
|
||||||
@ -156,7 +135,18 @@ public class ConnectionListener extends BasicListener {
|
|||||||
public void onDisconnect(PlayerDisconnectEvent e){
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
ChallengeCommand.remove(e.getPlayer());
|
ChallengeCommand.remove(e.getPlayer());
|
||||||
MsgCommand.remove(e.getPlayer());
|
MsgCommand.remove(e.getPlayer());
|
||||||
ModUtils.getPlayerModMap().remove(e.getPlayer().getUniqueId());
|
}
|
||||||
ModCommand.playerFilterType.remove(e.getPlayer());
|
|
||||||
|
@EventHandler
|
||||||
|
public void onServerDisconnect(ServerDisconnectEvent e){
|
||||||
|
ServerInfo server = e.getTarget();
|
||||||
|
Subserver subserver = Subserver.getSubserver(server);
|
||||||
|
if(subserver == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ProxiedPlayer player = e.getPlayer();
|
||||||
|
Collection<ProxiedPlayer> players = server.getPlayers();
|
||||||
|
if(players.isEmpty() || (players.size() == 1 && players.contains(player)))
|
||||||
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), subserver::waitForTermination);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.sql.*;
|
import de.steamwar.bungeecore.sql.Event;
|
||||||
|
import de.steamwar.bungeecore.sql.EventFight;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import de.steamwar.bungeecore.sql.TeamTeilnahme;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
@ -21,8 +24,10 @@ public class EventModeListener extends BasicListener {
|
|||||||
if(TeamTeilnahme.nimmtTeil(user.getTeam(), event.getEventID()))
|
if(TeamTeilnahme.nimmtTeil(user.getTeam(), event.getEventID()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(Referee.get(event.getEventID()).contains(user.getId()))
|
for(EventFight eventFight : EventFight.getEvent(event.getEventID())){
|
||||||
return;
|
if(eventFight.getKampfleiter() == user.getId())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.parse("EVENTMODE_KICK", e.getPlayer())));
|
e.getPlayer().disconnect(TextComponent.fromLegacyText(Message.parse("EVENTMODE_KICK", e.getPlayer())));
|
||||||
}
|
}
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.listeners;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.connection.PreLoginEvent;
|
|
||||||
import com.velocitypowered.api.proxy.InboundConnection;
|
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
|
||||||
import com.velocitypowered.proxy.connection.client.InitialInboundConnection;
|
|
||||||
import com.velocitypowered.proxy.connection.client.LoginInboundConnection;
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.InetSocketAddress;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class IPSanitizer {
|
|
||||||
|
|
||||||
private static final Field delegateField;
|
|
||||||
private static final Field remoteAddressField;
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
delegateField = LoginInboundConnection.class.getDeclaredField("delegate");
|
|
||||||
remoteAddressField = MinecraftConnection.class.getDeclaredField("remoteAddress");
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
throw new SecurityException("Could not initialize Reflection", e);
|
|
||||||
}
|
|
||||||
delegateField.setAccessible(true);
|
|
||||||
remoteAddressField.setAccessible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MinecraftConnection getChannelWrapper(InboundConnection connection) {
|
|
||||||
try {
|
|
||||||
return ((InitialInboundConnection) delegateField.get(connection)).getConnection();
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
throw new SecurityException("Could not get channel wrapper", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static InetAddress getTrueAddress(InboundConnection connection) {
|
|
||||||
return ((InetSocketAddress) getChannelWrapper(connection).getRemoteAddress()).getAddress();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private final InetSocketAddress sanitized = new InetSocketAddress("127.127.127.127", 25565);
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void loginEvent(PreLoginEvent e) {
|
|
||||||
VelocityCore.get().getLogger().log(Level.INFO, e.getConnection().getRemoteAddress().getAddress().toString() + " has logged in with user name " + e.getUsername());
|
|
||||||
try {
|
|
||||||
remoteAddressField.set(getChannelWrapper(e.getConnection()), sanitized);
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
throw new SecurityException("Could not set remote address", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,331 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.listeners;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.lunarclient.apollo.ApolloManager;
|
|
||||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.commands.TeamCommand;
|
|
||||||
import de.steamwar.bungeecore.mods.*;
|
|
||||||
import de.steamwar.bungeecore.network.ServerMetaInfo;
|
|
||||||
import de.steamwar.bungeecore.util.annotations.Create;
|
|
||||||
import de.steamwar.messages.ChatSender;
|
|
||||||
import de.steamwar.network.packets.NetworkPacket;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
@Create
|
|
||||||
public class PluginMessage {
|
|
||||||
|
|
||||||
private final Lunar lunar;
|
|
||||||
private final LabyMod labyMod;
|
|
||||||
private final WorldDownloader wdl;
|
|
||||||
private final FabricModSender fms;
|
|
||||||
private final FML flm;
|
|
||||||
|
|
||||||
public static void send(Player player, String legacyChannel, String channel, byte[] data) {
|
|
||||||
// 1.12 format change
|
|
||||||
send(player, player.getProtocolVersion().getProtocol() > 340 ? channel : legacyChannel, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void send(Player player, String channel, byte[] data) {
|
|
||||||
player.sendPluginMessage(MinecraftChannelIdentifier.from(channel), data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] genBufPacket(Consumer<ByteBuf> generator) {
|
|
||||||
ByteBuf buf = Unpooled.buffer();
|
|
||||||
generator.accept(buf);
|
|
||||||
|
|
||||||
byte[] packet = new byte[buf.readableBytes()];
|
|
||||||
buf.readBytes(packet);
|
|
||||||
return packet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] genStreamPacket(StreamConsumer generator) {
|
|
||||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
|
||||||
DataOutputStream out = new DataOutputStream(stream);
|
|
||||||
|
|
||||||
try {
|
|
||||||
generator.accept(out);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new SecurityException("Could not create PluginMessage packet", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return stream.toByteArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface StreamConsumer {
|
|
||||||
void accept(DataOutputStream out) throws IOException;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Parser UNKNOWN = event -> {
|
|
||||||
VelocityCore.get().getLogger().log(Level.WARNING, () -> "Undefined PluginMessage on channel " + event.getIdentifier().getId() + " from " + (event.getSource() instanceof Player pl ? pl.getUsername() : event.getSource().toString()) + " received.\n" + new String(event.getData()) + "\n" + Arrays.toString(event.getData()));
|
|
||||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
|
||||||
};
|
|
||||||
private static final Parser PASS_THROUGH = event -> event.setResult(PluginMessageEvent.ForwardResult.forward());
|
|
||||||
private static final Parser DROP = event -> event.setResult(PluginMessageEvent.ForwardResult.handled());
|
|
||||||
|
|
||||||
private final Set<String> knownBrands = new HashSet<>();
|
|
||||||
private final Map<String, Consumer<Player>> channelRegisterHandlers = new HashMap<>();
|
|
||||||
private final Map<String, Parser> handlers = new HashMap<>();
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public PluginMessage(Lunar lunar, LabyMod labyMod, WorldDownloader wdl, FabricModSender fms, FML flm) {
|
|
||||||
this.lunar = lunar;
|
|
||||||
this.labyMod = labyMod;
|
|
||||||
this.wdl = wdl;
|
|
||||||
this.fms = fms;
|
|
||||||
this.flm = flm;
|
|
||||||
|
|
||||||
knownBrands.addAll(Arrays.asList("vanilla", "fabric", "quilt", "forge", "optifine", "Geyser", "labymod", "Feather Fabric"));
|
|
||||||
|
|
||||||
for(String channel : Arrays.asList(
|
|
||||||
"fabric:container/open", "fabric:registry/sync/direct", "fabric:registry/sync",
|
|
||||||
"fabric-screen-handler-api-v1:open_screen",
|
|
||||||
|
|
||||||
FML.CHANNEL, "fml:loginwrapper", "fml:handshake", "fml:play", "forge:tier_sorting", "forge:split",
|
|
||||||
"forge:login", "forge:handshake",
|
|
||||||
|
|
||||||
"labymod3:main", "labymod:neo",
|
|
||||||
|
|
||||||
"floodgate:skin", "floodgate:form", "floodgate:transfer", "floodgate:packet",
|
|
||||||
|
|
||||||
"Replay|Restrict", "replaymod:restrict",
|
|
||||||
"WDL|CONTROL", "wdl:control",
|
|
||||||
"tpshud:handshake", "tpshud:tps", //https://github.com/mooziii/tpshud-fabric/tree/main
|
|
||||||
"methane_server:statepacket", //https://modrinth.com/mod/methane
|
|
||||||
"servux:structures", //https://modrinth.com/mod/servux
|
|
||||||
"architectury:spawn_entity_packet", //https://modrinth.com/mod/architectury-api
|
|
||||||
"jei:channel", //https://modrinth.com/mod/jei
|
|
||||||
"shulkerboxtooltip:s2c_handshake", "shulkerboxtooltip:ec_update", //https://modrinth.com/mod/shulkerboxtooltip
|
|
||||||
"owo:local_packet", "owo:sync_screen_handler_properties", //https://modrinth.com/mod/owo-lib
|
|
||||||
"essential:", //https://essential.gg/
|
|
||||||
"libgui:screen_message_s2c", //https://github.com/CottonMC/LibGui
|
|
||||||
"minecraft:intave", //https://intave.ac seems to be a client side integration of intave with labymod 4
|
|
||||||
"midnightcontrols:feature", "midnightcontrols:controls_mode", //https://modrinth.com/mod/midnightcontrols
|
|
||||||
"controlify:vibrate_from_origin", "controlify:vibration", "controlify:vibrate_from_entity",
|
|
||||||
"carpet:structures", //https://modrinth.com/mod/carpet
|
|
||||||
"appleskin:exhaustion_sync", "appleskin:saturation_sync", //https://modrinth.com/mod/appleskin
|
|
||||||
"puzzleslib:1/1", //https://modrinth.com/mod/puzzles-lib
|
|
||||||
"pickupnotifier:1/1", //https://modrinth.com/mod/pick-up-notifier
|
|
||||||
"plasmo:voice/v2/installed", "plasmo:voice/v2", //https://modrinth.com/plugin/plasmo-voice
|
|
||||||
"whereisit:s2c_founditem", //https://modrinth.com/mod/where-is-it (needs server side component to work)
|
|
||||||
"inventorysorter:sync_blacklist_packet", //https://github.com/cpw/inventorysorter (needs server side component to work)
|
|
||||||
|
|
||||||
//https://github.com/bernie-g/geckolib
|
|
||||||
"geckolib:block_entity_anim_trigger_sync", "geckolib:entity_anim_trigger_sync",
|
|
||||||
"geckolib:block_entity_anim_data_sync", "geckolib:anim_data_sync",
|
|
||||||
"geckolib:entity_anim_data_sync", "geckolib:anim_trigger_sync",
|
|
||||||
|
|
||||||
//https://github.com/Noxcrew/noxesium
|
|
||||||
"noxesium-v1:reset", "noxesium-v1:change_server_rules", "noxesium-v1:server_info",
|
|
||||||
"noxesium-v1:mcc_server", "noxesium-v1:mcc_game_state", "noxesium-v1:reset_server_rules",
|
|
||||||
"noxesium-v1:stop_sound", "noxesium-v1:start_sound", "noxesium-v1:modify_sound"
|
|
||||||
)) {
|
|
||||||
channelRegisterHandlers.put(channel, player -> {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
channelRegisterHandlers.put(ApolloManager.PLUGIN_MESSAGE_CHANNEL, lunar::sendRestrictions);
|
|
||||||
channelRegisterHandlers.put(Feather.CHANNEL.getId(), new Feather()::sendRestrictions);
|
|
||||||
channelRegisterHandlers.put("xaerominimap:main", player -> player.sendMessage(Component.text("§n§o§m§i§n§i§m§a§p"))); //https://www.curseforge.com/minecraft/mc-mods/xaeros-minimap
|
|
||||||
channelRegisterHandlers.put("litemoretica:init_easy_place", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "litematica")))); //https://github.com/Earthcomputer/litemoretica/tree/master
|
|
||||||
channelRegisterHandlers.put("voxelmap:settings", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "voxelmap")))); //https://modrinth.com/mod/voxelmap-updated undocumented
|
|
||||||
channelRegisterHandlers.put("worldinfo:world_id", player -> player.disconnect(ChatSender.of(player).parseToComponent(false, new Message("MOD_YELLOW_SING", "minimap")))); // JourneyMap and VoxelMap
|
|
||||||
channelRegisterHandlers.put(Controlify.CHANNEL.getId(), new Controlify()::onRegister);
|
|
||||||
|
|
||||||
registerBiDirPassthrough("worldedit:cui");
|
|
||||||
|
|
||||||
registerPassthroughToClient(
|
|
||||||
"axiom:enable", "axiom:initialize_hotbars",
|
|
||||||
"axiom:response_chunk_data", "axiom:register_world_properties", "axiom:set_world_property",
|
|
||||||
"axiom:ack_world_properties", "axiom:restrictions", "axiom:marker_data", "axiom:marker_nbt_response",
|
|
||||||
"axiom:custom_blocks", "axiom:editor_warning", "axiom:blueprint_manifest", "axiom:response_blueprint"
|
|
||||||
);
|
|
||||||
registerBiDirPassthrough("axiom:handle_big_payload", "axiom:set_editor_views");
|
|
||||||
registerPassthroughToServer(
|
|
||||||
"axiom:hello", "axiom:set_gamemode", "axiom:set_fly_speed", "axiom:set_world_time",
|
|
||||||
"axiom:set_world_property", "axiom:set_block", "axiom:set_hotbar_slot", "axiom:switch_active_hotbar",
|
|
||||||
"axiom:teleport", "axiom:request_chunk_data", "axiom:spawn_entity",
|
|
||||||
"axiom:manipulate_entity", "axiom:delete_entity", "axiom:marker_nbt_request", "axiom:set_buffer"
|
|
||||||
);
|
|
||||||
|
|
||||||
for(String channel : Arrays.asList(
|
|
||||||
"UNREGISTER", "minecraft:unregister", // used by carpet and servux
|
|
||||||
"WDL|REQUEST", "wdl:request",
|
|
||||||
"minecraft:intave", //undocumented, byte stringlength, clientconfig, byte length, json {"legacySneakHeight":false,"legacyOldRange":false,"legacyOldSlowdown":false}
|
|
||||||
"waila:entity", "waila:block",
|
|
||||||
"lambdacontrols:hello",
|
|
||||||
"midnightcontrols:controls_mode",
|
|
||||||
"inventorysorter:sync_settings_packet",
|
|
||||||
"voicechat:request_secret", "voicechat:update_state", //https://modrinth.com/plugin/simple-voice-chat
|
|
||||||
"shulkerboxtooltip:c2s_handshake"
|
|
||||||
))
|
|
||||||
register(channel, false, directional(UNKNOWN, DROP));
|
|
||||||
|
|
||||||
register("REGISTER", false, directional(this::serverRegistersChannel, this::clientRegistersChannel));
|
|
||||||
register("minecraft:register", false, directional(this::serverRegistersChannel, this::clientRegistersChannel));
|
|
||||||
|
|
||||||
register("BungeeCord", false, onlySWSource(PASS_THROUGH));
|
|
||||||
register("bungeecord:main", false, onlySWSource(PASS_THROUGH));
|
|
||||||
register("MC|Brand", false, directional(this::steamWarBrand, this::userBrand));
|
|
||||||
register("minecraft:brand", false, directional(this::steamWarBrand, this::userBrand));
|
|
||||||
|
|
||||||
//Needs to be registered cause paper refuses to send PluginMessages on unregistered channels...
|
|
||||||
register("sw:bridge", true, directional(onlySWSource(async(event -> NetworkPacket.handle(new ServerMetaInfo(((ServerConnection) event.getSource()).getServerInfo()), event.getData()))), UNKNOWN));
|
|
||||||
register("sw:hotkeys", false, directional(UNKNOWN, PASS_THROUGH));
|
|
||||||
register("fabricmodsender:mods", true, directional(UNKNOWN, async(fms::handlePluginMessage)));
|
|
||||||
|
|
||||||
register("WDL|INIT", true, directional(UNKNOWN, wdl::handlePluginMessage));
|
|
||||||
register("wdl:init", true, directional(UNKNOWN, wdl::handlePluginMessage));
|
|
||||||
|
|
||||||
register(ApolloManager.PLUGIN_MESSAGE_CHANNEL, true, async(lunar::handlePluginMessage));
|
|
||||||
register("LMC", true, directional(UNKNOWN, async(labyMod::handlePluginMessage)));
|
|
||||||
register("labymod3:main", true, directional(UNKNOWN, async(labyMod::handlePluginMessage)));
|
|
||||||
register("labymod:neo", false, directional(UNKNOWN, DROP)); //undocumented, JSON format "0" byte, packetlängen byte, {"version":"4.1.25"}
|
|
||||||
register(FML.CHANNEL, true, directional(UNKNOWN, async(flm::handlePluginMessage)));
|
|
||||||
|
|
||||||
//vanilla does not register any channels (sends only one minecraft:brand vanilla, nothing else (potential spoofed client detection))
|
|
||||||
//Forge interestingly registers all channels the server registers
|
|
||||||
//meteor https://github.com/MeteorDevelopment/meteor-client/blob/master/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/ServerSpoof.java https://github.com/MeteorDevelopment/meteor-client/blob/master/src/main/java/meteordevelopment/meteorclient/systems/modules/misc/DiscordPresence.java
|
|
||||||
//litematica/malilib https://github.com/maruohon/litematica/issues/75 https://github.com/maruohon/malilib/blob/liteloader_1.12.2/src/main/java/malilib/network/message/ConfigLockPacketHandler.java#L65
|
|
||||||
// Hackclientlike modsuppressor for labymod: https://github.com/Neocraftr/LabyMod-NeoEssentials (Potentially recognizable from NO Addons/NO Mods?) https://github.com/Neocraftr/LabyMod-NeoEssentials/blob/master/src/main/java/de/neocraftr/neoessentials/utils/BytecodeMethods.java
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPluginMessage(PluginMessageEvent event) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
handlers.getOrDefault(event.getTag(), UNKNOWN).handle(event);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SecurityException("PluginMessage handling exception: " + event + "\n" + Arrays.toString(event.getData()), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerPassthroughToClient(String... channels) {
|
|
||||||
for(String channel : channels) {
|
|
||||||
channelRegisterHandlers.put(channel, player -> {});
|
|
||||||
register(channel, false, directional(PASS_THROUGH, UNKNOWN));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerPassthroughToServer(String... channels) {
|
|
||||||
for(String channel : channels)
|
|
||||||
register(channel, false, directional(UNKNOWN, PASS_THROUGH));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerBiDirPassthrough(String... channels) {
|
|
||||||
for(String channel : channels) {
|
|
||||||
channelRegisterHandlers.put(channel, player -> {});
|
|
||||||
register(channel, false, PASS_THROUGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void register(String channel, boolean clientSideRegister, Parser handler) {
|
|
||||||
handlers.put(channel, handler);
|
|
||||||
if(clientSideRegister)
|
|
||||||
ProxyServer.getInstance().registerChannel(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clientRegistersChannel(PluginMessageEvent event) {
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
|
||||||
|
|
||||||
for(String channel : new String(event.getData()).split("\0")) {
|
|
||||||
channelRegisterHandlers.getOrDefault(channel, p -> VelocityCore.get().getLogger().log(Level.WARNING, () -> p.getName() + " registered unknown channel " + channel)).accept(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
PASS_THROUGH.handle(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void serverRegistersChannel(PluginMessageEvent event) {
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer)event.getReceiver();
|
|
||||||
|
|
||||||
List<String> channels = new ArrayList<>(Arrays.asList(new String(event.getData()).split("\0")));
|
|
||||||
channels.removeIf(channel -> channel.equals("sw:bridge"));
|
|
||||||
player.sendData((player).getPendingConnection().getVersion() > 340 ? "minecraft:register" : "REGISTER", String.join("\0", channels).getBytes());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void userBrand(PluginMessageEvent event) {
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
|
||||||
ByteBuf buf = Unpooled.wrappedBuffer(event.getData());
|
|
||||||
String brand = DefinedPacket.readString(buf);
|
|
||||||
boolean lunarclient = brand.startsWith("lunarclient:");
|
|
||||||
|
|
||||||
VelocityCore.get().getLogger().log(knownBrands.contains(brand) || lunarclient ? Level.INFO : Level.WARNING, () -> player.getName() + " joins with brand: " + brand);
|
|
||||||
if(lunarclient)
|
|
||||||
lunar.sendRestrictions(player);
|
|
||||||
|
|
||||||
PASS_THROUGH.handle(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void steamWarBrand(PluginMessageEvent event) {
|
|
||||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
|
||||||
String brandString = ChatSender.of(player).parseToLegacy("STEAMWAR_BRAND", ProxyServer.getInstance().getName(), player.getServer().getInfo().getName(), new String(event.getData(), 1, event.getData().length - 1));
|
|
||||||
|
|
||||||
ByteBuf brand = ByteBufAllocator.DEFAULT.heapBuffer();
|
|
||||||
DefinedPacket.writeString(brandString, brand);
|
|
||||||
player.sendData(event.getTag(), DefinedPacket.toArray(brand));
|
|
||||||
brand.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Parser directional(Parser fromServer, Parser fromPlayer) {
|
|
||||||
return event -> {
|
|
||||||
if(event.getSender() instanceof ProxiedPlayer)
|
|
||||||
fromPlayer.handle(event);
|
|
||||||
else
|
|
||||||
fromServer.handle(event);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private Parser onlySWSource(Parser parser) {
|
|
||||||
return event -> {
|
|
||||||
Connection sender = event.getSender();
|
|
||||||
if(TeamCommand.isLocalhost(sender instanceof ProxiedPlayer ? IPSanitizer.getTrueAddress(((ProxiedPlayer) sender).getPendingConnection()) : sender.getAddress().getAddress()))
|
|
||||||
parser.handle(event);
|
|
||||||
else
|
|
||||||
UNKNOWN.handle(event);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private Parser async(Parser parser) {
|
|
||||||
return event -> ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> parser.handle(event));
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface Parser {
|
|
||||||
void handle(PluginMessageEvent event);
|
|
||||||
}
|
|
||||||
}
|
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
import de.steamwar.sql.PollAnswer;
|
import de.steamwar.bungeecore.sql.PollAnswer;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
@ -40,8 +40,6 @@ public class PollSystem extends BasicListener {
|
|||||||
|
|
||||||
if(noCurrentPoll())
|
if(noCurrentPoll())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PollAnswer.setCurrentPoll(question);
|
|
||||||
new PollSystem();
|
new PollSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +70,10 @@ public class PollSystem extends BasicListener {
|
|||||||
return question == null || question.equals("");
|
return question == null || question.equals("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getQuestion() {
|
||||||
|
return question;
|
||||||
|
}
|
||||||
|
|
||||||
public static int answers(){
|
public static int answers(){
|
||||||
return answers.size();
|
return answers.size();
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.sql.Session;
|
import de.steamwar.bungeecore.sql.Session;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
@ -43,7 +43,7 @@ public class SessionManager extends BasicListener {
|
|||||||
public void onDisconnect(PlayerDisconnectEvent e){
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
Timestamp timestamp = sessions.remove(e.getPlayer());
|
Timestamp timestamp = sessions.remove(e.getPlayer());
|
||||||
if(timestamp != null) {
|
if(timestamp != null) {
|
||||||
ProxyServer.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer().getUniqueId()).getId(), timestamp));
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> Session.insertSession(SteamwarUser.get(e.getPlayer()).getId(), timestamp));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.listeners;
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import de.steamwar.network.packets.server.LocaleInvalidationPacket;
|
|
||||||
import net.md_5.bungee.BungeeCord;
|
import net.md_5.bungee.BungeeCord;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
import net.md_5.bungee.api.event.SettingsChangedEvent;
|
||||||
@ -32,11 +30,9 @@ public class SettingsChangedListener extends BasicListener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onSettingsChanged(SettingsChangedEvent event) {
|
public void onSettingsChanged(SettingsChangedEvent event) {
|
||||||
BungeeCord.getInstance().getScheduler().runAsync(VelocityCore.get(), () -> {
|
BungeeCord.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
ProxiedPlayer player = event.getPlayer();
|
ProxiedPlayer player = event.getPlayer();
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser.get(player).setLocale(player.getLocale(), false);
|
||||||
user.setLocale(player.getLocale(), false);
|
|
||||||
NetworkSender.send(player, new LocaleInvalidationPacket(user.getId()));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
70
src/de/steamwar/bungeecore/listeners/SubserverProtocolFixer.java
Normale Datei
70
src/de/steamwar/bungeecore/listeners/SubserverProtocolFixer.java
Normale Datei
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program 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 Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners;
|
||||||
|
|
||||||
|
import net.md_5.bungee.BungeeCord;
|
||||||
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
|
import net.md_5.bungee.connection.LoginResult;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import net.md_5.bungee.protocol.Property;
|
||||||
|
import net.md_5.bungee.util.AddressUtil;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class SubserverProtocolFixer extends BasicListener {
|
||||||
|
|
||||||
|
private final InetSocketAddress inetSocketAddress = new InetSocketAddress("127.127.127.127", 25565);
|
||||||
|
|
||||||
|
private Field field;
|
||||||
|
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
field = InitialHandler.class.getDeclaredField("extraDataInHandshake");
|
||||||
|
field.setAccessible(true);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
BungeeCord.getInstance().getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void loginEvent(LoginEvent e) {
|
||||||
|
InitialHandler initialHandler = ((InitialHandler) e.getConnection());
|
||||||
|
|
||||||
|
String undashedUUID = initialHandler.getUniqueId().toString().replace("-", "");
|
||||||
|
String extraData = "\00" + AddressUtil.sanitizeAddress(inetSocketAddress) + "\00" + undashedUUID;
|
||||||
|
|
||||||
|
LoginResult result = initialHandler.getLoginProfile();
|
||||||
|
if (result != null) {
|
||||||
|
Property[] properties = result.getProperties();
|
||||||
|
if (properties.length > 0) {
|
||||||
|
extraData += "\00" + BungeeCord.getInstance().gson.toJson(properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
field.set(initialHandler, extraData);
|
||||||
|
} catch (IllegalAccessException ex) {
|
||||||
|
BungeeCord.getInstance().getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
src/de/steamwar/bungeecore/listeners/mods/Badlion.java
Normale Datei
32
src/de/steamwar/bungeecore/listeners/mods/Badlion.java
Normale Datei
@ -0,0 +1,32 @@
|
|||||||
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||||
|
|
||||||
|
public class Badlion extends BasicListener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPostLogin(PostLoginEvent event) {
|
||||||
|
/*
|
||||||
|
{
|
||||||
|
"modsDisallowed": {
|
||||||
|
"Clear Glass":{"disabled":true},
|
||||||
|
"ClearWater":{"disabled":true},
|
||||||
|
"FOV Changer":{"disabled":true},
|
||||||
|
"Hitboxes":{"disabled":true},
|
||||||
|
"MiniMap":{"disabled":true},
|
||||||
|
"MLG Cobweb":{"disabled":true},
|
||||||
|
"Replay":{"disabled":true},
|
||||||
|
"Schematica":{"disabled":true},
|
||||||
|
"ToggleSneak":{"disabled":true},
|
||||||
|
"ToggleSprint":{"disabled":true},
|
||||||
|
"TNT Time":{"disabled":true}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"TNT Time\":{\"disabled\":true}}").getBytes(), false));
|
||||||
|
}
|
||||||
|
}
|
194
src/de/steamwar/bungeecore/listeners/mods/Fabric.java
Normale Datei
194
src/de/steamwar/bungeecore/listeners/mods/Fabric.java
Normale Datei
@ -0,0 +1,194 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.JsonSyntaxException;
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.Storage;
|
||||||
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
|
import de.steamwar.bungeecore.sql.Mod;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import net.md_5.bungee.BungeeCord;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
|
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.charset.UnsupportedCharsetException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Fabric extends BasicListener {
|
||||||
|
|
||||||
|
private final Set<String> neededMods = new HashSet<>();
|
||||||
|
|
||||||
|
{
|
||||||
|
neededMods.add("java");
|
||||||
|
neededMods.add("minecraft");
|
||||||
|
neededMods.add("fabricloader");
|
||||||
|
neededMods.add("steamwarmodsender");
|
||||||
|
|
||||||
|
BungeeCord.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
|
synchronized (Storage.fabricExpectPluginMessage) {
|
||||||
|
for (Map.Entry<ProxiedPlayer, Long> entry : Storage.fabricExpectPluginMessage.entrySet()) {
|
||||||
|
if (!Storage.fabricCheckedPlayers.containsKey(entry.getKey())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
|
||||||
|
banPlayer(SteamwarUser.get(entry.getKey()), entry.getKey(), "Expected message not received");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||||
|
if(!e.getTag().equals("fabricmodsender:mods"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!(e.getSender() instanceof ProxiedPlayer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||||
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
|
|
||||||
|
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||||
|
synchronized (Storage.fabricExpectPluginMessage) {
|
||||||
|
if (Storage.fabricExpectPluginMessage.containsKey(player)) {
|
||||||
|
banPlayer(user, player, "Was not fabric checked but send message nonetheless");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Storage.fabricExpectPluginMessage.remove(player);
|
||||||
|
|
||||||
|
List<Mod> mods = new LinkedList<>();
|
||||||
|
|
||||||
|
byte[] data = e.getData();
|
||||||
|
Utils.VarInt varInt = Utils.readVarInt(data,0);
|
||||||
|
|
||||||
|
if(data.length != varInt.length + varInt.value) {
|
||||||
|
banPlayer(user,player, "Invalid message length");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
data = Arrays.copyOfRange(data,varInt.length, data.length);
|
||||||
|
|
||||||
|
String dataString;
|
||||||
|
|
||||||
|
try{
|
||||||
|
dataString = new String(data, StandardCharsets.UTF_8);
|
||||||
|
}catch (UnsupportedCharsetException exception) {
|
||||||
|
banPlayer(user, player, "Unsupported charset");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonArray array;
|
||||||
|
|
||||||
|
try {
|
||||||
|
array = new JsonParser().parse(dataString).getAsJsonArray();
|
||||||
|
}catch (JsonSyntaxException exception) {
|
||||||
|
banPlayer(user, player, "Invalid json");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(JsonElement mod : array) {
|
||||||
|
mods.add(Mod.get(mod.getAsString(), Mod.Platform.FABRIC));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
boolean isSorted = isSortedAlphabetically(mods);
|
||||||
|
|
||||||
|
if(!isSorted) {
|
||||||
|
banPlayer(user, player, "Mods are not sorted alphabetically: " + mods.stream().map(Mod::getModName).collect(Collectors.joining(", ")));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(!neededModsContained(mods)) {
|
||||||
|
banPlayer(user, player, "Needed mods are not contained");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Utils.handleMods(player,mods)) {
|
||||||
|
if (Storage.fabricCheckedPlayers.containsKey(player)) {
|
||||||
|
long current = Storage.fabricCheckedPlayers.get(player);
|
||||||
|
if (current != dataString.hashCode()) {
|
||||||
|
banPlayer(user, player, "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Message.send("MODIFICATION_CHECK_SUCCESS", player);
|
||||||
|
Storage.fabricCheckedPlayers.put(player, dataString.hashCode());
|
||||||
|
}
|
||||||
|
Storage.fabricPlayers.remove(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onServerSwitchEvent(ServerSwitchEvent e) {
|
||||||
|
if (e.getFrom() == null) return;
|
||||||
|
synchronized (Storage.fabricExpectPluginMessage) {
|
||||||
|
Storage.fabricExpectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSortedAlphabetically(List<Mod> mods) {
|
||||||
|
boolean isSorted = true;
|
||||||
|
for(int i = 0; i < mods.size() - 1; i++) {
|
||||||
|
if(mods.get(i).getModName().compareToIgnoreCase(mods.get(i + 1).getModName()) > 0) {
|
||||||
|
isSorted = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isSorted;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean neededModsContained(List<Mod> mods) {
|
||||||
|
return mods.stream()
|
||||||
|
.map(Mod::getModName)
|
||||||
|
.filter(neededMods::contains)
|
||||||
|
.count() == neededMods.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void banPlayer(SteamwarUser user, ProxiedPlayer player, String reason) {
|
||||||
|
user.punishPerma(Punishment.PunishmentType.Ban,
|
||||||
|
Message.parse("MODIFICATION_BAN_MESSAGE", player, user.getUserName(), user.getId()),
|
||||||
|
0);
|
||||||
|
BungeeCore.log(Level.SEVERE,Message.parse("MODIFICATION_BAN_LOG", player, user.getUserName(), reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void remove(ProxiedPlayer player) {
|
||||||
|
Storage.fabricCheckedPlayers.remove(player);
|
||||||
|
synchronized (Storage.fabricExpectPluginMessage) {
|
||||||
|
Storage.fabricExpectPluginMessage.remove(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
149
src/de/steamwar/bungeecore/listeners/mods/Forge.java
Normale Datei
149
src/de/steamwar/bungeecore/listeners/mods/Forge.java
Normale Datei
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
|
import de.steamwar.bungeecore.sql.Mod;
|
||||||
|
import io.netty.channel.ChannelPipeline;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.md_5.bungee.api.connection.PendingConnection;
|
||||||
|
import net.md_5.bungee.api.event.LoginEvent;
|
||||||
|
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||||
|
import net.md_5.bungee.connection.InitialHandler;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
import net.md_5.bungee.netty.ChannelWrapper;
|
||||||
|
import net.md_5.bungee.netty.HandlerBoss;
|
||||||
|
import net.md_5.bungee.netty.PacketHandler;
|
||||||
|
import net.md_5.bungee.protocol.packet.LoginPayloadRequest;
|
||||||
|
import net.md_5.bungee.protocol.packet.LoginPayloadResponse;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class Forge extends BasicListener {
|
||||||
|
|
||||||
|
private static final String WRAPPER = "fml:loginwrapper";
|
||||||
|
|
||||||
|
private static final Field initialHandlerCh;
|
||||||
|
static{
|
||||||
|
try {
|
||||||
|
initialHandlerCh = InitialHandler.class.getDeclaredField("ch");
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
throw new SecurityException("Could not initialize Reflection", e);
|
||||||
|
}
|
||||||
|
initialHandlerCh.setAccessible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onServerConnected(LoginEvent event) {
|
||||||
|
if(event.getConnection().getVersion() < 341) { //1.13+
|
||||||
|
event.completeIntent(BungeeCore.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//fml:handshake without mods, channels and registries
|
||||||
|
//for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29
|
||||||
|
event.getConnection().unsafe().sendPacket(new LoginPayloadRequest(1, WRAPPER, new byte[]{13,102,109,108,58,104,97,110,100,115,104,97,107,101,4,1,0,0,0}));
|
||||||
|
|
||||||
|
InitialHandler handler = (InitialHandler) event.getConnection();
|
||||||
|
|
||||||
|
ChannelWrapper wrapper;
|
||||||
|
try{
|
||||||
|
wrapper = (ChannelWrapper) initialHandlerCh.get(handler);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not get Channel", e);
|
||||||
|
event.completeIntent(BungeeCore.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChannelPipeline pipeline = wrapper.getHandle().pipeline();
|
||||||
|
if(pipeline != null) {
|
||||||
|
HandlerBoss handlerBoss = pipeline.get(HandlerBoss.class);
|
||||||
|
if(handlerBoss != null)
|
||||||
|
handlerBoss.setHandler(new CustomPacketHandler(event));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CustomPacketHandler extends PacketHandler {
|
||||||
|
private final LoginEvent event;
|
||||||
|
|
||||||
|
public CustomPacketHandler(LoginEvent event) {
|
||||||
|
this.event = event;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "SteamWar Forge Handler";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(LoginPayloadResponse response){
|
||||||
|
byte[] data = response.getData();
|
||||||
|
if(data == null) {
|
||||||
|
event.completeIntent(BungeeCore.get());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29
|
||||||
|
Utils.VarInt channelLength = Utils.readVarInt(data, 0);
|
||||||
|
int pos = channelLength.length;
|
||||||
|
if(!new String(data, pos, channelLength.value).equals("fml:handshake")) {
|
||||||
|
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x00)"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pos += channelLength.value;
|
||||||
|
|
||||||
|
Utils.VarInt length = Utils.readVarInt(data, pos);
|
||||||
|
pos += length.length;
|
||||||
|
if(channelLength.length + channelLength.value + length.length + length.value != data.length) {
|
||||||
|
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x01)"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.VarInt packetId = Utils.readVarInt(data, pos);
|
||||||
|
pos += packetId.length;
|
||||||
|
if(packetId.value != 2) {
|
||||||
|
event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x02)"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.VarInt modCount = Utils.readVarInt(data, pos);
|
||||||
|
pos += modCount.length;
|
||||||
|
|
||||||
|
List<Mod> mods = new ArrayList<>();
|
||||||
|
for(int i = 0; i < modCount.value; i++) {
|
||||||
|
Utils.VarInt nameLength = Utils.readVarInt(data, pos);
|
||||||
|
pos += nameLength.length;
|
||||||
|
|
||||||
|
mods.add(Mod.get(new String(data, pos, nameLength.value), Mod.Platform.FORGE));
|
||||||
|
pos += nameLength.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
PendingConnection connection = event.getConnection();
|
||||||
|
if(!Utils.handleMods(connection.getUniqueId(), Locale.getDefault(), event::setCancelReason, mods)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
event.completeIntent(BungeeCore.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
113
src/de/steamwar/bungeecore/listeners/mods/Forge12.java
Normale Datei
113
src/de/steamwar/bungeecore/listeners/mods/Forge12.java
Normale Datei
@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
|
import de.steamwar.bungeecore.sql.Mod;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.connection.Connection;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
|
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class Forge12 extends BasicListener {
|
||||||
|
private static final String FMLHS = "FML|HS";
|
||||||
|
private static final byte[] REGISTER;
|
||||||
|
private static final byte[] HELLO = new byte[]{0, 2, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
private static final Set<UUID> unlocked = new HashSet<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
ByteBuf buf = UnpooledByteBufAllocator.DEFAULT.directBuffer(7);
|
||||||
|
buf.writeByte(6);
|
||||||
|
buf.writeCharSequence(FMLHS, StandardCharsets.UTF_8);
|
||||||
|
REGISTER = new byte[buf.readableBytes()];
|
||||||
|
buf.readBytes(REGISTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPostLogin(PostLoginEvent event) {
|
||||||
|
ProxiedPlayer player = event.getPlayer();
|
||||||
|
|
||||||
|
synchronized (unlocked) {
|
||||||
|
if(unlocked.contains(player.getUniqueId())){
|
||||||
|
unlocked.remove(player.getUniqueId());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(player.getPendingConnection().getVersion() <= 340) {
|
||||||
|
player.sendData("REGISTER", REGISTER); //1.12-
|
||||||
|
player.sendData(FMLHS, HELLO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||||
|
if(!e.getTag().equals(FMLHS))
|
||||||
|
return;
|
||||||
|
|
||||||
|
e.setCancelled(true);
|
||||||
|
byte[] data = e.getData();
|
||||||
|
|
||||||
|
Connection sender = e.getSender();
|
||||||
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
|
|
||||||
|
if (data[0] == 2) {
|
||||||
|
Utils.VarInt numMods = Utils.readVarInt(data, 1);
|
||||||
|
List<Mod> mods = new LinkedList<>();
|
||||||
|
|
||||||
|
int bytePos = 1 + numMods.length;
|
||||||
|
for (int i = 0; i < numMods.value; i++) {
|
||||||
|
byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
|
||||||
|
bytePos += 1 + data[bytePos];
|
||||||
|
//Version information is unused
|
||||||
|
bytePos += 1 + data[bytePos];
|
||||||
|
|
||||||
|
mods.add(Mod.get(new String(name), Mod.Platform.FORGE));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Utils.handleMods(p, mods)) {
|
||||||
|
synchronized (unlocked) {
|
||||||
|
unlocked.add(p.getUniqueId());
|
||||||
|
}
|
||||||
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(),
|
||||||
|
() -> p.disconnect(BungeeCore.stringToText("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten")),
|
||||||
|
2, TimeUnit.SECONDS);
|
||||||
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
|
synchronized (unlocked) {
|
||||||
|
unlocked.remove(p.getUniqueId());
|
||||||
|
}
|
||||||
|
}, 30, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
184
src/de/steamwar/bungeecore/listeners/mods/LabyMod.java
Normale Datei
184
src/de/steamwar/bungeecore/listeners/mods/LabyMod.java
Normale Datei
@ -0,0 +1,184 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
|
import de.steamwar.bungeecore.sql.Mod;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.connection.Connection;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class LabyMod extends BasicListener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginMessageEvent(PluginMessageEvent event){
|
||||||
|
if(!event.getTag().equals("LMC"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Connection sender = event.getSender();
|
||||||
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
updateGameInfo((ProxiedPlayer) sender);
|
||||||
|
byte[] data = event.getData();
|
||||||
|
|
||||||
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> runAsync(data, (ProxiedPlayer) sender));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runAsync(byte[] data, ProxiedPlayer player) {
|
||||||
|
VarString purpose = readString(data, 0);
|
||||||
|
if(!"INFO".equals(purpose.value))
|
||||||
|
return;
|
||||||
|
|
||||||
|
VarString value = readString(data, purpose.length);
|
||||||
|
List<Mod> mods = new LinkedList<>();
|
||||||
|
|
||||||
|
try{
|
||||||
|
InfoPacket info = new InfoPacket(value.value);
|
||||||
|
for(InfoPacket.Addon addon : info.addons) {
|
||||||
|
mods.add(Mod.get(addon.name, Mod.Platform.LABYMOD));
|
||||||
|
}
|
||||||
|
}catch(IOException e){
|
||||||
|
BungeeCore.log("Could not read JSON", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.handleMods(player, mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
private VarString readString(byte[] array, int startPos){
|
||||||
|
Utils.VarInt varInt = Utils.readVarInt(array, startPos);
|
||||||
|
startPos += varInt.length;
|
||||||
|
return new VarString(varInt.value+varInt.length, new String(Arrays.copyOfRange(array, startPos, startPos + varInt.value), StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGameInfo(ProxiedPlayer proxiedPlayer) {
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
obj.addProperty("hasGame", true);
|
||||||
|
obj.addProperty("game_mode", "steamwar.de");
|
||||||
|
obj.addProperty("game_startTime", 0);
|
||||||
|
obj.addProperty("game_endTime", 0);
|
||||||
|
String output = "{ \"hasGame\" : \"true\", \"game_mode\" : \"steamwar.de\", \"game_startTime\" : \"0\", \"game_endTime\" : \"0\" }";
|
||||||
|
|
||||||
|
proxiedPlayer.sendData("LMC", output.getBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class VarString{
|
||||||
|
private final int length;
|
||||||
|
private final String value;
|
||||||
|
|
||||||
|
private VarString(int length, String value) {
|
||||||
|
this.length = length;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class InfoPacket{
|
||||||
|
String version = null;
|
||||||
|
Feature ccp = null;
|
||||||
|
Feature shadow = null;
|
||||||
|
List<Addon> addons = new LinkedList<>();
|
||||||
|
|
||||||
|
InfoPacket(String input) throws IOException {
|
||||||
|
JsonReader reader = new JsonReader(new StringReader(input));
|
||||||
|
reader.beginObject();
|
||||||
|
while(reader.hasNext()){
|
||||||
|
String name = reader.nextName();
|
||||||
|
switch(name){
|
||||||
|
case "version":
|
||||||
|
version = reader.nextString();
|
||||||
|
break;
|
||||||
|
case "ccp":
|
||||||
|
ccp = new Feature(reader);
|
||||||
|
break;
|
||||||
|
case "shadow":
|
||||||
|
shadow = new Feature(reader);
|
||||||
|
break;
|
||||||
|
case "addons":
|
||||||
|
reader.beginArray();
|
||||||
|
while(reader.hasNext()){
|
||||||
|
addons.add(new Addon(reader));
|
||||||
|
}
|
||||||
|
reader.endArray();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
reader.skipValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reader.endObject();
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Addon{
|
||||||
|
UUID uuid = null;
|
||||||
|
String name = null;
|
||||||
|
|
||||||
|
Addon(JsonReader reader) throws IOException {
|
||||||
|
reader.beginObject();
|
||||||
|
while(reader.hasNext()){
|
||||||
|
String n = reader.nextName();
|
||||||
|
if(n.equals("uuid"))
|
||||||
|
try{
|
||||||
|
uuid = UUID.fromString(reader.nextString());
|
||||||
|
}catch(IllegalArgumentException ignored){
|
||||||
|
//ignored
|
||||||
|
}
|
||||||
|
else if(n.equals("name"))
|
||||||
|
name = reader.nextString();
|
||||||
|
else
|
||||||
|
reader.skipValue();
|
||||||
|
}
|
||||||
|
reader.endObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Feature{
|
||||||
|
boolean enabled;
|
||||||
|
int version;
|
||||||
|
|
||||||
|
Feature(JsonReader reader) throws IOException {
|
||||||
|
reader.beginObject();
|
||||||
|
while(reader.hasNext()){
|
||||||
|
String name = reader.nextName();
|
||||||
|
if(name.equals("version"))
|
||||||
|
version = reader.nextInt();
|
||||||
|
else if(name.equals("enabled"))
|
||||||
|
enabled = reader.nextBoolean();
|
||||||
|
else
|
||||||
|
reader.skipValue();
|
||||||
|
}
|
||||||
|
reader.endObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
86
src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
Normale Datei
86
src/de/steamwar/bungeecore/listeners/mods/ModLoaderBlocker.java
Normale Datei
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.*;
|
||||||
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
|
import net.md_5.bungee.api.connection.Connection;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||||
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
|
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ModLoaderBlocker extends BasicListener {
|
||||||
|
|
||||||
|
private static final Set<String> BLOCKED_SERVER = new HashSet<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginMessageEvent(PluginMessageEvent e){
|
||||||
|
Connection sender = e.getSender();
|
||||||
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(!e.getTag().equals("minecraft:brand"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(new String(e.getData()).contains("fabric")){
|
||||||
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
|
if (!Storage.fabricCheckedPlayers.containsKey(p) && !Storage.fabricPlayers.contains(p)) {
|
||||||
|
Storage.fabricPlayers.add(p);
|
||||||
|
Message.send("MODLOADER_INSTALLED_FABRIC", p, "Fabric");
|
||||||
|
}
|
||||||
|
}else if(new String(e.getData()).contains("LiteLoader")) {
|
||||||
|
ProxiedPlayer p = (ProxiedPlayer) sender;
|
||||||
|
if (!Storage.fabricPlayers.contains(p)) {
|
||||||
|
Storage.fabricPlayers.add(p);
|
||||||
|
Message.send("MODLOADER_INSTALLED", p, "LiteLoader");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
|
Fabric.remove(e.getPlayer());
|
||||||
|
Storage.fabricPlayers.remove(e.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onServerSwitch(ServerSwitchEvent event) {
|
||||||
|
if(((Subserver.getSubserver(event.getPlayer()) != null
|
||||||
|
&& Subserver.getSubserver(event.getPlayer()).getType() == Servertype.ARENA)
|
||||||
|
|| BLOCKED_SERVER.contains(event.getPlayer().getServer().getInfo().getName()))
|
||||||
|
&& isFabric(event.getPlayer())) {
|
||||||
|
event.getPlayer().connect(BungeeCore.get().getProxy().getServerInfo(BungeeCore.LOBBY_SERVER));
|
||||||
|
Message.send("MODLOADER_DENIED", event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFabric(ProxiedPlayer player) {
|
||||||
|
return Storage.fabricPlayers.contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addServer(String server) {
|
||||||
|
BLOCKED_SERVER.add(server);
|
||||||
|
}
|
||||||
|
}
|
114
src/de/steamwar/bungeecore/listeners/mods/Utils.java
Normale Datei
114
src/de/steamwar/bungeecore/listeners/mods/Utils.java
Normale Datei
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.sql.Mod;
|
||||||
|
import de.steamwar.bungeecore.sql.Mod.ModType;
|
||||||
|
import de.steamwar.bungeecore.sql.Punishment;
|
||||||
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
|
import de.steamwar.messages.ChatSender;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
class Utils {
|
||||||
|
private Utils(){}
|
||||||
|
|
||||||
|
static VarInt readVarInt(byte[] array, int startPos) {
|
||||||
|
int numRead = 0;
|
||||||
|
int result = 0;
|
||||||
|
byte read;
|
||||||
|
do {
|
||||||
|
read = array[startPos + numRead];
|
||||||
|
int value = (read & 0b01111111);
|
||||||
|
result |= (value << (7 * numRead));
|
||||||
|
|
||||||
|
numRead++;
|
||||||
|
if (numRead > 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while ((read & 0b10000000) != 0);
|
||||||
|
|
||||||
|
return new VarInt(numRead, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean handleMods(ProxiedPlayer player, List<Mod> mods) {
|
||||||
|
return handleMods(player.getUniqueId(), ChatSender.of(player).getLocale(), player::disconnect, mods);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean handleMods(UUID uuid, Locale locale, Consumer<BaseComponent[]> disconnect, List<Mod> mods){
|
||||||
|
SteamwarUser user = SteamwarUser.get(uuid);
|
||||||
|
boolean privileged = user.getUserGroup().privilegedMods();
|
||||||
|
|
||||||
|
ModType max = ModType.YELLOW;
|
||||||
|
Iterator<Mod> it = mods.iterator();
|
||||||
|
while(it.hasNext()){
|
||||||
|
Mod mod = it.next();
|
||||||
|
if(mod.getModType() == ModType.UNKLASSIFIED || mod.getModType() == ModType.GREEN || (mod.getModType() == ModType.YOUTUBER_ONLY && privileged))
|
||||||
|
it.remove();
|
||||||
|
else if(mod.getModType() == ModType.RED)
|
||||||
|
max = ModType.RED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mods.isEmpty())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
ModType finalMax = max;
|
||||||
|
String modList = mods.stream().filter(mod -> finalMax == ModType.YELLOW || mod.getModType() == ModType.RED).map(Mod::getModName).collect(Collectors.joining("\n"));
|
||||||
|
String message;
|
||||||
|
|
||||||
|
if(mods.size() == 1) {
|
||||||
|
message = Message.parse(max == ModType.RED ? "MOD_RED_SING" : "MOD_YELLOW_SING", locale, modList);
|
||||||
|
} else {
|
||||||
|
message = Message.parse(max == ModType.RED ? "MOD_RED_PLUR" : "MOD_YELLOW_PLUR", locale, modList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(max == ModType.RED) {
|
||||||
|
user.punish(Punishment.PunishmentType.Ban, Timestamp.from(Instant.now().plus(7, ChronoUnit.DAYS)), message, 0, false);
|
||||||
|
BungeeCore.log(Level.SEVERE, user.getUserName() + " " + user.getId() + " wurde automatisch wegen der Mods " + modList + " gebannt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect.accept(TextComponent.fromLegacyText(message));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class VarInt{
|
||||||
|
final int length;
|
||||||
|
final int value;
|
||||||
|
|
||||||
|
VarInt(int length, int value){
|
||||||
|
this.length = length;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
33
src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java
Normale Datei
33
src/de/steamwar/bungeecore/listeners/mods/WorldDownloader.java
Normale Datei
@ -0,0 +1,33 @@
|
|||||||
|
package de.steamwar.bungeecore.listeners.mods;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
|
import de.steamwar.bungeecore.sql.Mod;
|
||||||
|
import net.md_5.bungee.api.connection.Connection;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class WorldDownloader extends BasicListener {
|
||||||
|
|
||||||
|
private static final Set<String> wdlTags = Collections.unmodifiableSet(
|
||||||
|
Sets.newHashSet("WDL|INIT", "wdl:init", "WDL|REQUEST", "wdl:request")
|
||||||
|
);
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPluginMessageEvent(PluginMessageEvent event){
|
||||||
|
if(!wdlTags.contains(event.getTag()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Connection sender = event.getSender();
|
||||||
|
if(!(sender instanceof ProxiedPlayer))
|
||||||
|
return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
Utils.handleMods((ProxiedPlayer) sender, Lists.newArrayList(Mod.get("wdl", Mod.Platform.FORGE)));
|
||||||
|
}
|
||||||
|
}
|
32
src/de/steamwar/bungeecore/listeners/ping/PingListener.java
Normale Datei
32
src/de/steamwar/bungeecore/listeners/ping/PingListener.java
Normale Datei
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners.ping;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
|
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||||
|
import net.md_5.bungee.event.EventHandler;
|
||||||
|
|
||||||
|
public class PingListener extends BasicListener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPing(ProxyPingEvent event) {
|
||||||
|
event.setResponse(new SteamWarServerPing(event.getResponse(), event.getConnection().getVersion()));
|
||||||
|
}
|
||||||
|
}
|
90
src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java
Normale Datei
90
src/de/steamwar/bungeecore/listeners/ping/SteamWarServerPing.java
Normale Datei
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
This file is a part of the SteamWar software.
|
||||||
|
|
||||||
|
Copyright (C) 2022 SteamWar.de-Serverteam
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.bungeecore.listeners.ping;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ServerPing;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class SteamWarServerPing extends ServerPing {
|
||||||
|
|
||||||
|
private final boolean preventsChatReports = true;
|
||||||
|
private final ForgeData forgeData;
|
||||||
|
|
||||||
|
public SteamWarServerPing(ServerPing existing, int version) {
|
||||||
|
super(existing.getVersion(), existing.getPlayers(), existing.getDescriptionComponent(), existing.getFaviconObject());
|
||||||
|
forgeData = new ForgeData(version);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ForgeData {
|
||||||
|
private final List<ForgeChannel> channels = new ArrayList<>();
|
||||||
|
private final List<ForgeMod> mods = new ArrayList<>();
|
||||||
|
private final int fmlNetworkVersion = 2;
|
||||||
|
|
||||||
|
public ForgeData(int versionNumber) {
|
||||||
|
channels.add(new ForgeChannel("minecraft:unregister"));
|
||||||
|
channels.add(new ForgeChannel("minecraft:register"));
|
||||||
|
channels.add(new ForgeChannel("fml:handshake"));
|
||||||
|
mods.add(new ForgeMod("minecraft", ProtocolVersion.getVersion(versionNumber)));
|
||||||
|
mods.add(new ForgeMod("forge", "ANY"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public final static class ProtocolVersion {
|
||||||
|
|
||||||
|
private static final HashMap<Integer, String> versions;
|
||||||
|
|
||||||
|
static {
|
||||||
|
versions = new HashMap();
|
||||||
|
versions.put(757, "1.18");
|
||||||
|
versions.put(756, "1.17.1");
|
||||||
|
versions.put(754, "1.16.5");
|
||||||
|
versions.put(578, "1.15.2");
|
||||||
|
versions.put(498, "1.14.1");
|
||||||
|
versions.put(393, "1.13");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getVersion(int version) {
|
||||||
|
return versions.get(version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ForgeChannel {
|
||||||
|
private final String res;
|
||||||
|
private final String version = "FML2";
|
||||||
|
private final boolean required = true;
|
||||||
|
|
||||||
|
private ForgeChannel(String res) {
|
||||||
|
this.res = res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ForgeMod {
|
||||||
|
private final String modId;
|
||||||
|
private final String modmarker;
|
||||||
|
|
||||||
|
private ForgeMod(String modId, String modmarker) {
|
||||||
|
this.modId = modId;
|
||||||
|
this.modmarker = modmarker;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.mods;
|
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
|
||||||
import de.steamwar.bungeecore.util.annotations.Create;
|
|
||||||
|
|
||||||
@Create
|
|
||||||
public class Badlion {
|
|
||||||
// https://github.com/BadlionClient/BadlionClientModAPI
|
|
||||||
|
|
||||||
private final byte[] packet;
|
|
||||||
|
|
||||||
public Badlion() { //TODO check if working or (json) modsDisallowed wrapper necessary
|
|
||||||
JsonObject disabled = new JsonObject();
|
|
||||||
disabled.addProperty("disabled", true);
|
|
||||||
|
|
||||||
JsonObject json = new JsonObject();
|
|
||||||
json.add("Clear Glass", disabled);
|
|
||||||
json.add("ClearWater", disabled);
|
|
||||||
json.add("FOV Changer", disabled);
|
|
||||||
json.add("Hitboxes", disabled);
|
|
||||||
json.add("LevelHead", disabled);
|
|
||||||
json.add("MiniMap", disabled);
|
|
||||||
json.add("MLG Cobweb", disabled);
|
|
||||||
json.add("Replay", disabled); //TODO check if ReplayMod restrictions work
|
|
||||||
json.add("Schematica", disabled);
|
|
||||||
json.add("ToggleSneak", disabled);
|
|
||||||
json.add("ToggleSprint", disabled);
|
|
||||||
json.add("TNT Time", disabled);
|
|
||||||
|
|
||||||
packet = json.toString().getBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onPostLogin(PostLoginEvent event) {
|
|
||||||
event.getPlayer().sendPluginMessage(MinecraftChannelIdentifier.from("badlion:mods"), packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.mods;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|
||||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
|
||||||
|
|
||||||
public class Controlify {
|
|
||||||
//https://modrinth.com/mod/controlify
|
|
||||||
//https://github.com/isXander/Controlify/blob/1.20.x/dev/src/main/java/dev/isxander/controlify/server/ServerPolicyPacket.java
|
|
||||||
//https://github.com/isXander/Controlify/blob/1.20.x/dev/src/main/java/dev/isxander/controlify/server/ServerPolicies.java
|
|
||||||
|
|
||||||
public static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.from("controlify:server_policy");
|
|
||||||
|
|
||||||
private final byte[][] packets;
|
|
||||||
public Controlify() {
|
|
||||||
packets = new byte[][] {
|
|
||||||
restrict("reachAround"),
|
|
||||||
restrict("disableFlyDrifting")
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] restrict(String name) {
|
|
||||||
return PluginMessage.genBufPacket(buf -> {
|
|
||||||
ProtocolUtils.writeString(buf, name);
|
|
||||||
buf.writeBoolean(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onRegister(Player player) {
|
|
||||||
for(byte[] packet : packets)
|
|
||||||
player.sendPluginMessage(CHANNEL, packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,136 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.mods;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.connection.ConnectionHandshakeEvent;
|
|
||||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
|
||||||
import com.velocitypowered.api.event.connection.PostLoginEvent;
|
|
||||||
import com.velocitypowered.api.proxy.LoginPhaseConnection;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
|
||||||
import com.velocitypowered.proxy.connection.ConnectionType;
|
|
||||||
import com.velocitypowered.proxy.connection.ConnectionTypes;
|
|
||||||
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
|
||||||
import com.velocitypowered.proxy.connection.client.InitialInboundConnection;
|
|
||||||
import com.velocitypowered.proxy.connection.client.LoginInboundConnection;
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|
||||||
import com.velocitypowered.proxy.protocol.packet.HandshakePacket;
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
|
||||||
import de.steamwar.bungeecore.util.annotations.Create;
|
|
||||||
import de.steamwar.sql.Mod;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import lombok.SneakyThrows;
|
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Create
|
|
||||||
public class FML {
|
|
||||||
// https://wiki.vg/Minecraft_Forge_Handshake#FML_protocol_.281.7_-_1.12.29
|
|
||||||
|
|
||||||
private static final Field delegateField;
|
|
||||||
private static final Field handshakeField;
|
|
||||||
|
|
||||||
static {
|
|
||||||
try {
|
|
||||||
delegateField = LoginInboundConnection.class.getDeclaredField("delegate");
|
|
||||||
handshakeField = InitialInboundConnection.class.getDeclaredField("handshake");
|
|
||||||
} catch (NoSuchFieldException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final ModUtils utils;
|
|
||||||
private final ProxyServer proxyServer;
|
|
||||||
private final VelocityCore core;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public FML(ModUtils utils, ProxyServer proxyServer, VelocityCore core) {
|
|
||||||
this.utils = utils;
|
|
||||||
this.proxyServer = proxyServer;
|
|
||||||
this.core = core;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
|
||||||
public static boolean isFML(LoginPhaseConnection connection, String type) {
|
|
||||||
return handshakeField.get(delegateField.get(connection)) instanceof HandshakePacket packet && packet.getServerAddress().endsWith("\0" + type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.from("FML|HS");
|
|
||||||
private final byte[] helloPacket = new byte[]{
|
|
||||||
/* Packet type: ServerHello */ 0,
|
|
||||||
/* FML protocol version */ 2,
|
|
||||||
/* Override dimension (int) */ 0, 0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final Set<UUID> unlocked = new HashSet<>();
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onPostLogin(PostLoginEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
|
|
||||||
synchronized (unlocked) {
|
|
||||||
if(unlocked.contains(player.getUniqueId())){
|
|
||||||
unlocked.remove(player.getUniqueId());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(((ConnectedPlayer) event.getPlayer()).getConnection().getType() == ConnectionTypes.LEGACY_FORGE) {
|
|
||||||
player.sendPluginMessage(CHANNEL, helloPacket);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handlePluginMessage(PluginMessageEvent event) {
|
|
||||||
Player p = (Player) event.getSource();
|
|
||||||
ByteBuf buf = Unpooled.wrappedBuffer(event.getData());
|
|
||||||
|
|
||||||
if (buf.readByte() == /* ModList */ 2) {
|
|
||||||
int numMods = ProtocolUtils.readVarInt(buf);
|
|
||||||
|
|
||||||
List<Mod> mods = new ArrayList<>();
|
|
||||||
for(int i = 0; i < numMods; i++) {
|
|
||||||
String name = ProtocolUtils.readString(buf);
|
|
||||||
ProtocolUtils.readString(buf); // version
|
|
||||||
|
|
||||||
mods.add(Mod.getOrCreate(name, Mod.Platform.FORGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (utils.handleMods(p, mods)) {
|
|
||||||
synchronized (unlocked) {
|
|
||||||
unlocked.add(p.getUniqueId());
|
|
||||||
}
|
|
||||||
p.disconnect(LegacyComponentSerializer.legacySection().deserialize("§7Deine installierten Mods wurden überprüft\n§aDu kannst nun §eSteam§8War §abetreten"));
|
|
||||||
proxyServer.getScheduler().buildTask(core, () -> {
|
|
||||||
synchronized (unlocked) {
|
|
||||||
unlocked.remove(p.getUniqueId());
|
|
||||||
}
|
|
||||||
}).delay(30, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,183 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.mods;
|
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.connection.PreLoginEvent;
|
|
||||||
import com.velocitypowered.api.proxy.LoginPhaseConnection;
|
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
|
||||||
import com.velocitypowered.proxy.connection.client.LoginInboundConnection;
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
|
||||||
import de.steamwar.bungeecore.listeners.IPSanitizer;
|
|
||||||
import de.steamwar.bungeecore.listeners.PluginMessage;
|
|
||||||
import de.steamwar.bungeecore.util.annotations.Create;
|
|
||||||
import de.steamwar.sql.Mod;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
@Create
|
|
||||||
public class FML2 {
|
|
||||||
|
|
||||||
protected final ModUtils modUtils;
|
|
||||||
// FML2: https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29
|
|
||||||
// FML3: https://github.com/adde0109/Ambassador/tree/non-api/src/main/java/org/adde0109/ambassador/forge
|
|
||||||
|
|
||||||
// FORGE: https://github.com/MinecraftForge/MinecraftForge/blob/1.20.x/src/main/java/net/minecraftforge/network/NetworkInitialization.java
|
|
||||||
// FORGE: https://github.com/MinecraftForge/MinecraftForge/blob/1.20.x/src/main/java/net/minecraftforge/network/ForgePacketHandler.java
|
|
||||||
// FORGE: https://github.com/MinecraftForge/MinecraftForge/blob/1.20.x/src/main/java/net/minecraftforge/network/packets/ModVersions.java
|
|
||||||
|
|
||||||
private final byte[] fml2ModListPacket;
|
|
||||||
private final byte[] fml3ModListPacket;
|
|
||||||
private final byte[] forgeModListPacket;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public FML2(ModUtils modUtils) {
|
|
||||||
this.modUtils = modUtils;
|
|
||||||
fml2ModListPacket = generateModListPacket(false);
|
|
||||||
fml3ModListPacket = generateModListPacket(true);
|
|
||||||
forgeModListPacket = PluginMessage.genBufPacket(buf -> {
|
|
||||||
buf.writeByte(0); // Login wrapper packet
|
|
||||||
ProtocolUtils.writeString(buf, "forge:handshake");
|
|
||||||
|
|
||||||
ByteBuf packet = Unpooled.buffer();
|
|
||||||
packet.writeByte(1); // Mod list packet
|
|
||||||
ProtocolUtils.writeVarInt(packet, 0); // Mod amount
|
|
||||||
|
|
||||||
ProtocolUtils.writeVarInt(buf, packet.readableBytes());
|
|
||||||
buf.writeBytes(packet);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onLogin(PreLoginEvent event) {
|
|
||||||
LoginInboundConnection connection = (LoginInboundConnection) event.getConnection();
|
|
||||||
|
|
||||||
boolean fml2 = FML.isFML(connection, "FML2\0");
|
|
||||||
boolean fml3 = FML.isFML(connection, "FML3\0");
|
|
||||||
boolean forge = FML.isFML(connection, "FORGE");
|
|
||||||
if(!fml2 && !fml3 && !forge)
|
|
||||||
return;
|
|
||||||
|
|
||||||
FML2LoginHandler handler = new FML2LoginHandler(connection, event.getUniqueId(), forge);
|
|
||||||
|
|
||||||
if(forge) {
|
|
||||||
((LoginInboundConnection) event.getConnection()).sendLoginPluginMessage(MinecraftChannelIdentifier.from("forge:login"), forgeModListPacket, handler);
|
|
||||||
} else {
|
|
||||||
((LoginInboundConnection) event.getConnection()).sendLoginPluginMessage(MinecraftChannelIdentifier.from("fml:loginwrapper"), fml3 ? fml3ModListPacket : fml2ModListPacket, handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] generateModListPacket(boolean fml3) {
|
|
||||||
return PluginMessage.genBufPacket(buf -> {
|
|
||||||
ProtocolUtils.writeString(buf, "fml:handshake");
|
|
||||||
|
|
||||||
ByteBuf packet = Unpooled.buffer();
|
|
||||||
packet.writeByte(1); // Mod list packet
|
|
||||||
ProtocolUtils.writeVarInt(packet, 0); // Mod amount
|
|
||||||
|
|
||||||
if(fml3) {
|
|
||||||
ProtocolUtils.writeVarInt(packet,1); // Channel amount
|
|
||||||
ProtocolUtils.writeString(packet, "forge:tier_sorting");
|
|
||||||
ProtocolUtils.writeString(packet, "1.0");
|
|
||||||
} else {
|
|
||||||
ProtocolUtils.writeVarInt(packet, 0); // Channel amount
|
|
||||||
}
|
|
||||||
|
|
||||||
ProtocolUtils.writeVarInt(packet, 0); // Registries amount
|
|
||||||
if(fml3)
|
|
||||||
ProtocolUtils.writeVarInt(packet, 0); // DataPacks amount
|
|
||||||
|
|
||||||
ProtocolUtils.writeVarInt(buf, packet.readableBytes());
|
|
||||||
buf.writeBytes(packet);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private class FML2LoginHandler implements LoginPhaseConnection.MessageConsumer {
|
|
||||||
private final LoginInboundConnection connection;
|
|
||||||
private final UUID uuid;
|
|
||||||
private final boolean forge;
|
|
||||||
|
|
||||||
private FML2LoginHandler(LoginInboundConnection connection, UUID uuid, boolean forge) {
|
|
||||||
this.connection = connection;
|
|
||||||
this.uuid = uuid;
|
|
||||||
this.forge = forge;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "SteamWar Forge Handler";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void abort(byte[] response, String error) {
|
|
||||||
|
|
||||||
VelocityCore.get().getLogger().log(Level.SEVERE, () -> error + "\n" + Base64.getEncoder().encodeToString(response));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onMessageResponse(byte @Nullable [] data) {
|
|
||||||
if(data == null) {
|
|
||||||
abort(null, "Not FML2/3 client");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteBuf buf = Unpooled.wrappedBuffer(data);
|
|
||||||
if(forge && buf.readByte() != 0) {
|
|
||||||
abort(data, "Not FORGE login wrapper");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ProtocolUtils.readString(buf).equals(forge ? "forge:handshake" : "fml:handshake")) {
|
|
||||||
abort(data, "Not FML2/3/FORGE handshake response");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ProtocolUtils.readVarInt(buf) != buf.readableBytes()) {
|
|
||||||
abort(data, "FML2/3/FORGE packet size mismatch");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(ProtocolUtils.readVarInt(buf) != (forge ? /* Mod Versions */ 1 : /* Mod List Reply */ 2)) {
|
|
||||||
abort(data, "Not FML2/3/FORGE mod list reply");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Mod> mods = new ArrayList<>();
|
|
||||||
|
|
||||||
int modCount = ProtocolUtils.readVarInt(buf);
|
|
||||||
for(int i = 0; i < modCount; i++) {
|
|
||||||
mods.add(Mod.getOrCreate(ProtocolUtils.readString(buf), Mod.Platform.FORGE));
|
|
||||||
|
|
||||||
if(forge) {
|
|
||||||
ProtocolUtils.readString(buf); // Human readable name
|
|
||||||
ProtocolUtils.readString(buf); // Version
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
modUtils.handleMods(uuid, Locale.getDefault(), connection::disconnect, mods);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,156 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.mods;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
|
||||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
|
||||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
|
||||||
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|
||||||
import de.steamwar.bungeecore.VelocityCore;
|
|
||||||
import de.steamwar.bungeecore.Storage;
|
|
||||||
import de.steamwar.bungeecore.util.annotations.Create;
|
|
||||||
import de.steamwar.sql.Mod;
|
|
||||||
import de.steamwar.sql.SWException;
|
|
||||||
import de.steamwar.sql.SteamwarUser;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.Unpooled;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Create
|
|
||||||
public class FabricModSender {
|
|
||||||
|
|
||||||
private final ModUtils utils;
|
|
||||||
private final ProxyServer proxyServer;
|
|
||||||
private final VelocityCore core;
|
|
||||||
|
|
||||||
private final Set<String> neededFabricMods = new HashSet<>();
|
|
||||||
private final Set<String> neededQuiltMods = new HashSet<>();
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public FabricModSender(ModUtils utils, ProxyServer proxyServer, VelocityCore core) {
|
|
||||||
this.utils = utils;
|
|
||||||
this.proxyServer = proxyServer;
|
|
||||||
this.core = core;
|
|
||||||
neededFabricMods.add("java");
|
|
||||||
neededFabricMods.add("minecraft");
|
|
||||||
neededFabricMods.add("steamwarmodsender");
|
|
||||||
neededQuiltMods.addAll(neededFabricMods);
|
|
||||||
|
|
||||||
neededFabricMods.add("fabricloader");
|
|
||||||
neededQuiltMods.add("quilt_loader");
|
|
||||||
|
|
||||||
proxyServer.getScheduler().buildTask(VelocityCore.get(), () -> {
|
|
||||||
synchronized (Storage.fabricExpectPluginMessage) {
|
|
||||||
for (Map.Entry<Player, Long> entry : Storage.fabricExpectPluginMessage.entrySet()) {
|
|
||||||
if (!Storage.fabricCheckedPlayers.containsKey(entry.getKey())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (System.currentTimeMillis() - entry.getValue() > TimeUnit.SECONDS.toMillis(20)) {
|
|
||||||
Storage.fabricExpectPluginMessage.remove(entry.getKey());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).repeat(1, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void handlePluginMessage(PluginMessageEvent e){
|
|
||||||
Player player = (Player) e.getSource();
|
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
||||||
|
|
||||||
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
|
|
||||||
synchronized (Storage.fabricExpectPluginMessage) {
|
|
||||||
if (Storage.fabricExpectPluginMessage.containsKey(player)) {
|
|
||||||
logMessage(user, "Was not fabric checked but send message nonetheless", Arrays.toString(e.getData()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Storage.fabricExpectPluginMessage.remove(player);
|
|
||||||
|
|
||||||
List<Mod> mods = new ArrayList<>();
|
|
||||||
|
|
||||||
ByteBuf buf = Unpooled.wrappedBuffer(e.getData());
|
|
||||||
String data = ProtocolUtils.readString(buf, 1024*1024);
|
|
||||||
if(buf.readableBytes() > 0) {
|
|
||||||
logMessage(user, "Invalid message length", Arrays.toString(e.getData()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonArray array = JsonParser.parseString(data).getAsJsonArray();
|
|
||||||
|
|
||||||
for(JsonElement mod : array) {
|
|
||||||
mods.add(Mod.getOrCreate(mod.getAsString(), Mod.Platform.FABRIC));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!neededModsContained(neededFabricMods, mods) && !neededModsContained(neededQuiltMods, mods)) {
|
|
||||||
logMessage(user, "Needed mods are not contained", data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!utils.handleMods(player,mods))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!Storage.fabricCheckedPlayers.containsKey(player)) {
|
|
||||||
Storage.fabricCheckedPlayers.put(player, data.hashCode());
|
|
||||||
} else if (Storage.fabricCheckedPlayers.get(player) != data.hashCode()) {
|
|
||||||
logMessage(user, "Mods changed during runtime", data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onServerSwitchEvent(ServerConnectedEvent e) {
|
|
||||||
if (e.getPreviousServer().isEmpty()) return;
|
|
||||||
synchronized (Storage.fabricExpectPluginMessage) {
|
|
||||||
Storage.fabricExpectPluginMessage.put(e.getPlayer(), System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onDisconnect(DisconnectEvent e) {
|
|
||||||
Player player = e.getPlayer();
|
|
||||||
|
|
||||||
Storage.fabricCheckedPlayers.remove(player);
|
|
||||||
synchronized (Storage.fabricExpectPluginMessage) {
|
|
||||||
Storage.fabricExpectPluginMessage.remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean neededModsContained(Set<String> neededMods, List<Mod> mods) {
|
|
||||||
return mods.stream()
|
|
||||||
.map(Mod::getModName)
|
|
||||||
.filter(neededMods::contains)
|
|
||||||
.count() == neededFabricMods.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void logMessage(SteamwarUser user, String reason, String data) {
|
|
||||||
SWException.log("FabricModSender " + user.getUserName() + ": " + reason, data);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.bungeecore.mods;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
|
||||||
|
|
||||||
public class Feather {
|
|
||||||
//https://github.com/Koupah/Feather-Client-API/blob/main/src/club/koupah/feather/packets/FeatherMod.java
|
|
||||||
//https://archive.org/details/feather-server-api
|
|
||||||
public static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.from("feather:client");
|
|
||||||
|
|
||||||
private final byte[] packet;
|
|
||||||
public Feather() {
|
|
||||||
JsonArray array = new JsonArray();
|
|
||||||
array.add("clearWater");
|
|
||||||
array.add("coordinates");
|
|
||||||
array.add("coordinates");
|
|
||||||
array.add("hitbox");
|
|
||||||
array.add("hypixel");
|
|
||||||
array.add("reachDisplay");
|
|
||||||
array.add("snaplook");
|
|
||||||
array.add("toggleSprint");
|
|
||||||
|
|
||||||
JsonObject mods = new JsonObject();
|
|
||||||
mods.add("mods", array);
|
|
||||||
|
|
||||||
JsonObject obj = new JsonObject();
|
|
||||||
obj.addProperty("packetType", "DISABLE_MODS");
|
|
||||||
obj.add("payload", mods);
|
|
||||||
|
|
||||||
packet = obj.toString().getBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendRestrictions(Player player) {
|
|
||||||
player.sendPluginMessage(CHANNEL, packet);
|
|
||||||
}
|
|
||||||
}
|
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
In neuem Issue referenzieren
Einen Benutzer sperren