diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 19b655c2..b4b93dca 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,7 +1,7 @@
# These are supported funding model platforms
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
-patreon: #GeyserMC # Disabled currently
+patreon: GeyserMC
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 17e88f26..7a1fdba5 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -7,51 +7,34 @@ assignees: ''
---
-
-
-
+
**Describe the bug**
-
-A clear and concise description of what the bug is.
+
**To Reproduce**
-
-Steps to reproduce the behavior:
-1. Go to '...'
-2. Click on '....'
-3. Scroll down to '....'
-4. See error
+
+
+
+
+
**Expected behavior**
-
-A clear and concise description of what you expected to happen.
+
**Screenshots / Videos**
+
-If applicable, add screenshots to help explain your problem.
+**Server Version**
+
-**Server Version and Plugins**
-
-If you just run Geyser-Spigot, you can leave this area blank as the next section covers this information.
-
-If you're running a multi-server instance, or using Geyser Standalone:
-
-- Give us the exact output from `/version` on all servers involved. Saying "latest" does not help us at all.
-- Please list all plugins on all servers involved.
-
-If this bug occurs on a server you do not control, please fill this in to the best of your knowledge.
-
-**Geyser Dump**
-
-If Geyser starts correctly, please also include the link to a dump by using `/geyser dump`. If you use the Standalone GUI, the option can be found under `Commands` => `Dump`. This provides us information about your server that we can use to debug your issue.
+**Geyser Version**
+
**Minecraft: Bedrock Edition Version**
-
-The version of your Minecraft: Bedrock Edition client you tested with, along with your device type (e.g. Windows 10, Switch...).
+
**Additional Context**
-
-Add any other context about the problem here.
+
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 46653e62..75a76cd0 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -11,4 +11,4 @@ assignees: ''
Add a description
**Alternatives?**
-List any alternatives you might have tried
+Any alternatives you have tryed
diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml
index 78a3ce29..7f941da6 100644
--- a/.github/workflows/pullrequest.yml
+++ b/.github/workflows/pullrequest.yml
@@ -8,8 +8,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - uses: actions/cache@v2
+ - uses: actions/checkout@v1
+ - uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
@@ -22,33 +22,33 @@ jobs:
- name: submodules-init
uses: snickerbockers/submodules-init@v4
- name: Build with Maven
- run: mvn -B package -T 2C
+ run: mvn -B package
- name: Archive artifacts (Geyser Standalone)
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v1
if: success()
with:
name: Geyser Standalone
path: bootstrap/standalone/target/Geyser.jar
- - name: Archive artifacts (Geyser Spigot)
- uses: actions/upload-artifact@v2
+ - name: Archive artifacts (Geyser Bukkit)
+ uses: actions/upload-artifact@v1
if: success()
with:
- name: Geyser Spigot
- path: bootstrap/spigot/target/Geyser-Spigot.jar
+ name: Geyser Bukkit
+ path: bootstrap/bukkit/target/Geyser-Bukkit.jar
- name: Archive artifacts (Geyser BungeeCord)
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v1
if: success()
with:
name: Geyser BungeeCord
path: bootstrap/bungeecord/target/Geyser-BungeeCord.jar
- name: Archive artifacts (Geyser Sponge)
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v1
if: success()
with:
name: Geyser Sponge
path: bootstrap/sponge/target/Geyser-Sponge.jar
- name: Archive artifacts (Geyser Velocity)
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v1
if: success()
with:
name: Geyser Velocity
diff --git a/.gitignore b/.gitignore
index 85f8a6e9..0af6ecd0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
-# Created by https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode
-# Edit at https://www.gitignore.io/gitignore?templates=git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode
+# Created by https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all
+# Edit at https://www.gitignore.io/?templates=git,java,maven,eclipse,netbeans,jetbrains+all
### Eclipse ###
.metadata
@@ -53,19 +53,22 @@ local.properties
# Annotation Processing
.apt_generated/
-.apt_generated_test/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
-# Uncomment this line if you wish to ignore the project description file.
-# Typically, this file would be tracked if it contains build/dependency configurations:
+### Eclipse Patch ###
+# Eclipse Core
.project
-### Eclipse Patch ###
-# Spring Boot Tooling
+# JDT-specific (Eclipse Java Development Tools)
+.classpath
+
+# Annotation Processing
+.apt_generated
+
.sts4-cache/
### Git ###
@@ -109,7 +112,7 @@ local.properties
hs_err_pid*
### JetBrains+all ###
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
+# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
@@ -139,9 +142,6 @@ hs_err_pid*
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
-# .idea/artifacts
-# .idea/compiler.xml
-# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
@@ -207,7 +207,6 @@ release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
-# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
### NetBeans ###
@@ -220,20 +219,7 @@ dist/
nbdist/
.nb-gradle/
-### VisualStudioCode ###
-# Note: Manually edited to remove settings files
-.vscode/*
-# !.vscode/settings.json
-# !.vscode/tasks.json
-# !.vscode/launch.json
-# !.vscode/extensions.json
-# *.code-workspace
-
-### VisualStudioCode Patch ###
-# Ignore all local history of files
-.history
-
-# End of https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all,visualstudiocode
+# End of https://www.gitignore.io/api/git,java,maven,eclipse,netbeans,jetbrains+all
### Geyser ###
run/
@@ -241,6 +227,3 @@ config.yml
logs/
public-key.pem
locales/
-/cache/
-/packs/
-/dump.json
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
index 0c014712..0090e64a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
[submodule "connector/src/main/resources/mappings"]
path = connector/src/main/resources/mappings
url = https://github.com/GeyserMC/mappings.git
-[submodule "connector/src/main/resources/languages"]
- path = connector/src/main/resources/languages
- url = https://github.com/GeyserMC/languages.git
diff --git a/.idea/copyright/Geyser.xml b/.idea/copyright/Geyser.xml
index c6b553aa..568fa7b8 100644
--- a/.idea/copyright/Geyser.xml
+++ b/.idea/copyright/Geyser.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index c7a5a3d2..acb35e9f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,44 +1 @@
-Thank for for considering a contribution! Generally, Geyser welcomes PRs from everyone. There are some guidelines about what features should go where:
-
-
-*Pull requests that may not get accepted:* Niche features that apply to a specific group, for example integration with a specific plugin. For now, please create a separate plugin if possible.
-
-*Pull requests for Floodgate:* Anything that opens up information within the game for developers to use.
-
-*Pull requests for Geyser:* Anything that fixes compatibility between Java or Bedrock, or improves the quality of play for Bedrock players. The exception is wherever direct server access is required; in this case it may be better for Floodgate.
-
-
-We have some general style guides that should be applied throughout the code:
-
-```java
-
-private static final AIR_ITEM = 0; // Static item names should be capitalized
-
-public Int2IntMap items = new Int2IntOpenHashMap(); // Use the interface as the class type but initialize with the implementation.
-
-public int nameWithMultipleWords = 0;
-
-/**
-* Javadoc comment to explain what a function does.
-*/
-public void applyStuff() {
- if (condition) {
- // Do stuff.
- } else if (anotherCondition) {
- // Do something else.
- }
-
- switch (value) {
- case 0:
- break;
- case 1:
- break:
- }
-}
-```
-
-Make sure to comment your code where possible.
-
-The nature of our software requires a lot of arrays and maps to be stored - where possible, use Fastutil's specialized maps. For example, if you're storing block state translations, use an `Int2IntMap`.
-
-We have a rundown of all the tools you need to develop over on our [wiki](https://github.com/GeyserMC/Geyser/wiki/Developer-Guide). If you have any questions, please feel free to reach out to our [Discord](https://discord.geysermc.org)!
+When contributing, please remember to read wiki about the api. Learn Steivice10's library and the nukkit protocol library if you are editing any core classes. Keep your code clean and readable, and please be mindful of fil conflicts. If you need help, join our discord. Other than that, you're all set!
diff --git a/Jenkinsfile b/Jenkinsfile
index 50149136..ffa4f1bd 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -5,7 +5,7 @@ pipeline {
jdk 'Java 8'
}
options {
- buildDiscarder(logRotator(artifactNumToKeepStr: '20'))
+ buildDiscarder(logRotator(artifactNumToKeepStr: '5'))
}
stages {
stage ('Build') {
@@ -24,77 +24,17 @@ pipeline {
when {
branch "master"
}
-
steps {
- rtMavenDeployer(
- id: "maven-deployer",
- serverId: "opencollab-artifactory",
- releaseRepo: "maven-releases",
- snapshotRepo: "maven-snapshots"
- )
- rtMavenResolver(
- id: "maven-resolver",
- serverId: "opencollab-artifactory",
- releaseRepo: "release",
- snapshotRepo: "snapshot"
- )
- rtMavenRun(
- pom: 'pom.xml',
- goals: 'javadoc:jar source:jar install -DskipTests',
- deployerId: "maven-deployer",
- resolverId: "maven-resolver"
- )
- rtPublishBuildInfo(
- serverId: "opencollab-artifactory"
- )
+ sh 'mvn javadoc:jar source:jar deploy -DskipTests'
}
}
}
post {
always {
- script {
- def changeLogSets = currentBuild.changeSets
- def message = "**Changes:**"
-
- if (changeLogSets.size() == 0) {
- message += "\n*No changes.*"
- } else {
- def repositoryUrl = scm.userRemoteConfigs[0].url.replace(".git", "")
- def count = 0;
- def extra = 0;
- for (int i = 0; i < changeLogSets.size(); i++) {
- def entries = changeLogSets[i].items
- for (int j = 0; j < entries.length; j++) {
- if (count <= 10) {
- def entry = entries[j]
- def commitId = entry.commitId.substring(0, 6)
- message += "\n - [`${commitId}`](${repositoryUrl}/commit/${entry.commitId}) ${entry.msg}"
- count++
- } else {
- extra++;
- }
- }
- }
-
- if (extra != 0) {
- message += "\n - ${extra} more commits"
- }
- }
-
- env.changes = message
- }
deleteDir()
withCredentials([string(credentialsId: 'geyser-discord-webhook', variable: 'DISCORD_WEBHOOK')]) {
- discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})\n${changes}\n\n[**Artifacts on Jenkins**](https://ci.opencollab.dev/job/GeyserMC/job/Geyser)", footer: 'Open Collaboration Jenkins', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK
- }
- }
- success {
- script {
- if (env.BRANCH_NAME == 'master') {
- build propagate: false, wait: false, job: 'GeyserMC/Geyser-Fabric/java-1.16'
- build propagate: false, wait: false, job: 'GeyserMC/GeyserAndroid/master'
- }
+ discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}](${env.BUILD_URL})\n\n[**Artifacts on Jenkins**](https://ci.nukkitx.com/job/Geyser)", footer: 'NukkitX Jenkins', link: env.BUILD_URL, successful: currentBuild.resultIsBetterOrEqualTo('SUCCESS'), title: "${env.JOB_NAME} #${currentBuild.id}", webhookURL: DISCORD_WEBHOOK
}
}
}
diff --git a/LICENSE b/LICENSE
index 0e368d54..acd4af14 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 1d1657ed..874c79f3 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,11 @@
-
+
[](https://java.com/)
[](LICENSE)
-[](https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/master/)
+[](https://ci.nukkitx.com/job/Geyser/job/master/)
[](http://discord.geysermc.org/)
[](http://hits.dwyl.io/Geyser/GeyserMC)
-[](https://translate.geysermc.org/)
Geyser is a bridge between Minecraft: Bedrock Edition and Minecraft: Java Edition, closing the gap from those wanting to play true cross-platform.
@@ -18,7 +17,7 @@ The ultimate goal of this project is to allow Minecraft: Bedrock Edition users t
Special thanks to the DragonProxy project for being a trailblazer in protocol translation and for all the team members who have now joined us here!
-### Currently supporting Minecraft Bedrock v1.16.100 - v1.16.201 and Minecraft Java v1.16.4.
+### Currently supporting Minecraft Bedrock v1.14.6(0) and Minecraft Java v1.15.2.
## Setting Up
Take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set up Geyser.
@@ -30,30 +29,16 @@ Take a look [here](https://github.com/GeyserMC/Geyser/wiki#Setup) for how to set
- Docs: https://github.com/GeyserMC/Geyser/wiki
- Download: http://ci.geysermc.org
- Discord: http://discord.geysermc.org/
-- ~~Donate: https://patreon.com/GeyserMC~~ Currently disabled.
-- Test Server: `test.geysermc.org` port `25565` for Java and `19132` for Bedrock
+- Donate: https://patreon.com/GeyserMC
## What's Left to be Added/Fixed
-- Lecterns
-- Near-perfect movement (to the point where anticheat on large servers is unlikely to ban you)
-- Resource pack conversion/CustomModelData
-- Some Entity Flags
- The Following Inventories
- - Enchantment Table (as a proper GUI)
- - Beacon
- - Cartography Table
- - Stonecutter
- - Structure Block
- - Horse Inventory
- - Loom
- - Smithing Table
-
-## What can't be fixed
-The following things can't be fixed because of Bedrock limitations. They might be fixable in the future, but not as of now.
-
-- Custom heads in inventories
-- Clickable links in chat
-- Glowing effect
+ - [ ] Enchantment Table
+ - [ ] Beacon
+ - [ ] Cartography Table
+ - [ ] Stonecutter
+ - [ ] Villager Trading
+- Some Entity Flags
## Compiling
1. Clone the repo to your computer
diff --git a/bootstrap/spigot/pom.xml b/bootstrap/bukkit/pom.xml
similarity index 57%
rename from bootstrap/spigot/pom.xml
rename to bootstrap/bukkit/pom.xml
index 93eebc3d..1f831d67 100644
--- a/bootstrap/spigot/pom.xml
+++ b/bootstrap/bukkit/pom.xml
@@ -6,37 +6,32 @@
org.geysermcbootstrap-parent
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOT
+ ../
- bootstrap-spigot
-
+ bootstrap-bukkitorg.geysermcconnector
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOTcompileorg.spigotmcspigot-api
- 1.15.2-R0.1-SNAPSHOT
+ 1.14-R0.1-SNAPSHOTprovidedus.mylesviaversion
- 3.2.0
+ 3.0.0-SNAPSHOTprovided
-
- org.geysermc.adapters
- spigot-all
- 1.0-SNAPSHOT
-
- ${outputName}-Spigot
+ ${outputName}-Bukkitsrc/main/resources/
@@ -51,7 +46,7 @@
- org.geysermc.platform.spigot.GeyserSpigotMain
+ org.geysermc.platform.bukkit.GeyserBukkitMain
@@ -70,35 +65,11 @@
io.netty
- org.geysermc.platform.spigot.shaded.netty
+ org.geysermc.platform.bukkit.shaded.nettyit.unimi.dsi.fastutil
- org.geysermc.platform.spigot.shaded.fastutil
-
-
- com.fasterxml.jackson
- org.geysermc.platform.spigot.shaded.jackson
-
-
- org.reflections
- org.geysermc.platform.spigot.shaded.reflections
-
-
- com.google.common
- org.geysermc.platform.spigot.shaded.google.common
-
-
- com.google.guava
- org.geysermc.platform.spigot.shaded.google.guava
-
-
- org.dom4j
- org.geysermc.platform.spigot.shaded.dom4j
-
-
- net.kyori
- org.geysermc.platform.spigot.shaded.kyori
+ org.geysermc.platform.bukkit.shaded.fastutil
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java
new file mode 100644
index 00000000..df98b408
--- /dev/null
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitConfiguration.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ */
+
+package org.geysermc.platform.bukkit;
+
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.plugin.Plugin;
+import org.geysermc.connector.FloodgateKeyLoader;
+import org.geysermc.connector.GeyserConfiguration;
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+public class GeyserBukkitConfiguration implements GeyserConfiguration {
+
+ private FileConfiguration config;
+ private File dataFolder;
+
+ private BukkitBedrockConfiguration bedrockConfig;
+ private BukkitRemoteConfiguration remoteConfig;
+ private BukkitMetricsInfo metricsInfo;
+
+ private Map userAuthInfo = new HashMap<>();
+
+ private Path floodgateKey;
+
+ public GeyserBukkitConfiguration(File dataFolder, FileConfiguration config) {
+ this.dataFolder = dataFolder;
+ this.config = config;
+
+ bedrockConfig = new BukkitBedrockConfiguration();
+ remoteConfig = new BukkitRemoteConfiguration();
+ metricsInfo = new BukkitMetricsInfo();
+
+ if (!config.contains("userAuths"))
+ return;
+
+ for (String key : config.getConfigurationSection("userAuths").getKeys(false)) {
+ userAuthInfo.put(key, new BukkitUserAuthenticationInfo(key));
+ }
+ }
+
+ public void loadFloodgate(GeyserBukkitPlugin plugin) {
+ Plugin floodgate = Bukkit.getPluginManager().getPlugin("floodgate-bukkit");
+ floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem")), floodgate, floodgate != null ? floodgate.getDataFolder().toPath() : null);
+ }
+
+ @Override
+ public IBedrockConfiguration getBedrock() {
+ return bedrockConfig;
+ }
+
+ @Override
+ public IRemoteConfiguration getRemote() {
+ return remoteConfig;
+ }
+
+ @Override
+ public Map getUserAuths() {
+ return userAuthInfo;
+ }
+
+ @Override
+ public boolean isCommandSuggestions() {
+ return config.getBoolean("command-suggestions", true);
+ }
+
+ @Override
+ public boolean isPassthroughMotd() {
+ return config.getBoolean("passthrough-motd", false);
+ }
+
+ @Override
+ public boolean isPassthroughPlayerCounts() {
+ return config.getBoolean("passthrough-player-counts", false);
+ }
+
+ @Override
+ public boolean isLegacyPingPassthrough() {
+ return config.getBoolean("legacy-ping-passthrough", false);
+ }
+
+ @Override
+ public int getPingPassthroughInterval() {
+ return config.getInt("ping-passthrough-interval", 3);
+ }
+
+ @Override
+ public int getMaxPlayers() {
+ return config.getInt("max-players", 10);
+ }
+
+ @Override
+ public boolean isDebugMode() {
+ return config.getBoolean("debug-mode", false);
+ }
+
+ @Override
+ public int getGeneralThreadPool() {
+ return config.getInt("general-thread-pool", 32);
+ }
+
+ @Override
+ public boolean isAllowThirdPartyCapes() {
+ return config.getBoolean("allow-third-party-capes", true);
+ }
+
+ @Override
+ public boolean isAllowThirdPartyEars() {
+ return config.getBoolean("allow-third-party-ears", false);
+ }
+
+ @Override
+ public String getDefaultLocale() {
+ return config.getString("default-locale", "en_us");
+ }
+
+ @Override
+ public Path getFloodgateKeyFile() {
+ return floodgateKey;
+ }
+
+ @Override
+ public boolean isCacheChunks() {
+ return true; // We override this as with Bukkit, we have direct access to the server implementation
+ }
+
+ @Override
+ public boolean isAboveBedrockNetherBuilding() {
+ return config.getBoolean("above-bedrock-nether-building", false);
+ }
+
+ @Override
+ public IMetricsInfo getMetrics() {
+ return metricsInfo;
+ }
+
+ public class BukkitBedrockConfiguration implements IBedrockConfiguration {
+
+ @Override
+ public String getAddress() {
+ return config.getString("bedrock.address", "0.0.0.0");
+ }
+
+ @Override
+ public int getPort() {
+ return config.getInt("bedrock.port", 25565);
+ }
+
+ @Override
+ public String getMotd1() {
+ return config.getString("bedrock.motd1", "GeyserMC");
+ }
+
+ @Override
+ public String getMotd2() {
+ return config.getString("bedrock.motd2", "GeyserMC");
+ }
+ }
+
+ public class BukkitRemoteConfiguration implements IRemoteConfiguration {
+
+ @Override
+ public String getAddress() {
+ return config.getString("remote.address", "127.0.0.1");
+ }
+
+ @Override
+ public int getPort() {
+ return config.getInt("remote.port", 25565);
+ }
+
+ @Override
+ public String getAuthType() {
+ return config.getString("remote.auth-type", "online");
+ }
+ }
+
+ public class BukkitUserAuthenticationInfo implements IUserAuthenticationInfo {
+
+ private String key;
+
+ public BukkitUserAuthenticationInfo(String key) {
+ this.key = key;
+ }
+
+ @Override
+ public String getEmail() {
+ return config.getString("userAuths." + key + ".email");
+ }
+
+ @Override
+ public String getPassword() {
+ return config.getString("userAuths." + key + ".password");
+ }
+ }
+
+ public class BukkitMetricsInfo implements IMetricsInfo {
+
+ @Override
+ public boolean isEnabled() {
+ return config.getBoolean("metrics.enabled", true);
+ }
+
+ @Override
+ public String getUniqueId() {
+ return config.getString("metrics.uuid", "generateduuid");
+ }
+ }
+
+ @Override
+ public int getConfigVersion() {
+ return config.getInt("config-version", 0);
+ }
+}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotLogger.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitLogger.java
similarity index 86%
rename from bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotLogger.java
rename to bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitLogger.java
index f760079f..08822568 100644
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotLogger.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitLogger.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,21 +23,20 @@
* @link https://github.com/GeyserMC/Geyser
*/
-package org.geysermc.platform.spigot;
+package org.geysermc.platform.bukkit;
import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
+
import org.geysermc.connector.GeyserLogger;
import java.util.logging.Level;
import java.util.logging.Logger;
@AllArgsConstructor
-public class GeyserSpigotLogger implements GeyserLogger {
- private final Logger logger;
- @Getter @Setter
- private boolean debug;
+public class GeyserBukkitLogger implements GeyserLogger {
+
+ private Logger logger;
+ private boolean debugMode;
@Override
public void severe(String message) {
@@ -71,8 +70,12 @@ public class GeyserSpigotLogger implements GeyserLogger {
@Override
public void debug(String message) {
- if (debug) {
+ if (debugMode)
info(message);
- }
+ }
+
+ @Override
+ public void setDebug(boolean debug) {
+ debugMode = debug;
}
}
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitMain.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitMain.java
new file mode 100644
index 00000000..b6da66c1
--- /dev/null
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitMain.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.platform.bukkit;
+
+import org.geysermc.common.main.IGeyserMain;
+
+public class GeyserBukkitMain extends IGeyserMain {
+
+ public static void main(String[] args) {
+ new GeyserBukkitMain().displayMessage();
+ }
+
+ public String getPluginType() {
+ return "Spigot or Paper (recommended)";
+ }
+
+ public String getPluginFolder() {
+ return "plugins";
+ }
+}
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPingPassthrough.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPingPassthrough.java
new file mode 100644
index 00000000..812467be
--- /dev/null
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPingPassthrough.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.platform.bukkit;
+
+import lombok.AllArgsConstructor;
+import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
+import org.bukkit.event.server.ServerListPingEvent;
+import org.bukkit.util.CachedServerIcon;
+import org.geysermc.common.ping.GeyserPingInfo;
+import org.geysermc.connector.ping.IGeyserPingPassthrough;
+
+import java.net.InetAddress;
+import java.util.Collections;
+import java.util.Iterator;
+
+@AllArgsConstructor
+public class GeyserBukkitPingPassthrough implements IGeyserPingPassthrough {
+
+ private final GeyserBukkitLogger logger;
+
+ @Override
+ public GeyserPingInfo getPingInformation() {
+ try {
+ ServerListPingEvent event = new GeyserPingEvent(InetAddress.getLocalHost(), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers());
+ Bukkit.getPluginManager().callEvent(event);
+ GeyserPingInfo geyserPingInfo = new GeyserPingInfo(event.getMotd(), event.getNumPlayers(), event.getMaxPlayers());
+ Bukkit.getOnlinePlayers().forEach(player -> {
+ geyserPingInfo.addPlayer(player.getName());
+ });
+ return geyserPingInfo;
+ } catch (Exception e) {
+ logger.debug("Error while getting Bukkit ping passthrough: " + e.toString());
+ return new GeyserPingInfo(null, 0, 0);
+ }
+ }
+
+ // These methods are unimplemented on spigot api by default so we add stubs so plugins don't complain
+ private static class GeyserPingEvent extends ServerListPingEvent {
+
+ public GeyserPingEvent(InetAddress address, String motd, int numPlayers, int maxPlayers) {
+ super(address, motd, numPlayers, maxPlayers);
+ }
+
+ @Override
+ public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
+ }
+
+ @Override
+ public Iterator iterator() throws UnsupportedOperationException {
+ return Collections.EMPTY_LIST.iterator();
+ }
+ }
+
+}
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
new file mode 100644
index 00000000..5f0e967a
--- /dev/null
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/GeyserBukkitPlugin.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ */
+
+package org.geysermc.platform.bukkit;
+
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.geysermc.common.PlatformType;
+import org.geysermc.connector.GeyserConfiguration;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.bootstrap.GeyserBootstrap;
+import org.geysermc.connector.command.CommandManager;
+import org.geysermc.connector.network.translators.world.WorldManager;
+import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
+import org.geysermc.connector.ping.IGeyserPingPassthrough;
+import org.geysermc.platform.bukkit.command.GeyserBukkitCommandExecutor;
+import org.geysermc.platform.bukkit.command.GeyserBukkitCommandManager;
+import org.geysermc.platform.bukkit.world.GeyserBukkitBlockPlaceListener;
+import org.geysermc.platform.bukkit.world.GeyserBukkitWorldManager;
+import us.myles.ViaVersion.api.Via;
+
+import java.util.UUID;
+
+public class GeyserBukkitPlugin extends JavaPlugin implements GeyserBootstrap {
+
+ private GeyserBukkitCommandManager geyserCommandManager;
+ private GeyserBukkitConfiguration geyserConfig;
+ private GeyserBukkitLogger geyserLogger;
+ private IGeyserPingPassthrough geyserBukkitPingPassthrough;
+ private GeyserBukkitBlockPlaceListener blockPlaceListener;
+ private GeyserBukkitWorldManager geyserWorldManager;
+
+ private GeyserConnector connector;
+
+ @Override
+ public void onEnable() {
+ saveDefaultConfig();
+
+ this.geyserConfig = new GeyserBukkitConfiguration(getDataFolder(), getConfig());
+ if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) {
+ getConfig().set("metrics.uuid", UUID.randomUUID().toString());
+ saveConfig();
+ }
+
+ // Don't change the ip if its listening on all interfaces
+ // By default this should be 127.0.0.1 but may need to be changed in some circumstances
+ if (!Bukkit.getIp().equals("0.0.0.0") && !Bukkit.getIp().equals("")) {
+ getConfig().set("remote.address", Bukkit.getIp());
+ }
+
+ getConfig().set("remote.port", Bukkit.getPort());
+ saveConfig();
+
+ this.geyserLogger = new GeyserBukkitLogger(getLogger(), geyserConfig.isDebugMode());
+ GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
+
+ geyserConfig.loadFloodgate(this);
+
+ this.connector = GeyserConnector.start(PlatformType.BUKKIT, this);
+
+ if (geyserConfig.isLegacyPingPassthrough()) {
+ this.geyserBukkitPingPassthrough = GeyserLegacyPingPassthrough.init(connector);
+ } else {
+ this.geyserBukkitPingPassthrough = new GeyserBukkitPingPassthrough(geyserLogger);
+ }
+
+ this.geyserCommandManager = new GeyserBukkitCommandManager(this, connector);
+
+ boolean isViaVersion = false;
+ // Used to determine if Block.getBlockData() is present.
+ boolean isLegacy = !isCompatible(Bukkit.getServer().getVersion(), "1.13.0");
+ if (isLegacy)
+ geyserLogger.debug("Legacy version of Minecraft (1.12.2 or older) detected.");
+
+ if (Bukkit.getPluginManager().getPlugin("ViaVersion") != null) {
+ // TODO: Update when ViaVersion updates
+ // API changes between 2.2.3 and 3.0.0-SNAPSHOT require this check
+ if (!Via.getAPI().getVersion().equals("3.0.0-SNAPSHOT") && isLegacy) {
+ geyserLogger.info("ViaVersion detected but not ViaVersion-ABSTRACTION. Please update your ViaVersion plugin for compatibility with Geyser.");
+ } else {
+ isViaVersion = true;
+ }
+ }
+
+ this.geyserWorldManager = new GeyserBukkitWorldManager(isLegacy, isViaVersion);
+ this.blockPlaceListener = new GeyserBukkitBlockPlaceListener(connector, isLegacy, isViaVersion);
+ Bukkit.getServer().getPluginManager().registerEvents(blockPlaceListener, this);
+
+ this.getCommand("geyser").setExecutor(new GeyserBukkitCommandExecutor(connector));
+ }
+
+ @Override
+ public void onDisable() {
+ connector.shutdown();
+ }
+
+ @Override
+ public GeyserBukkitConfiguration getGeyserConfig() {
+ return geyserConfig;
+ }
+
+ @Override
+ public GeyserBukkitLogger getGeyserLogger() {
+ return geyserLogger;
+ }
+
+ @Override
+ public CommandManager getGeyserCommandManager() {
+ return this.geyserCommandManager;
+ }
+
+ @Override
+ public IGeyserPingPassthrough getGeyserPingPassthrough() {
+ return geyserBukkitPingPassthrough;
+ }
+
+ @Override
+ public WorldManager getWorldManager() {
+ return this.geyserWorldManager;
+ }
+
+ public boolean isCompatible(String version, String whichVersion) {
+ int[] currentVersion = parseVersion(version);
+ int[] otherVersion = parseVersion(whichVersion);
+ int length = Math.max(currentVersion.length, otherVersion.length);
+ for (int index = 0; index < length; index = index + 1) {
+ int self = (index < currentVersion.length) ? currentVersion[index] : 0;
+ int other = (index < otherVersion.length) ? otherVersion[index] : 0;
+
+ if (self != other) {
+ return (self - other) > 0;
+ }
+ }
+ return true;
+ }
+
+ private int[] parseVersion(String versionParam) {
+ versionParam = (versionParam == null) ? "" : versionParam;
+ if (versionParam.contains("(MC: ")) {
+ versionParam = versionParam.split("\\(MC: ")[1];
+ versionParam = versionParam.split("\\)")[0];
+ }
+ String[] stringArray = versionParam.split("[_.-]");
+ int[] temp = new int[stringArray.length];
+ for (int index = 0; index <= (stringArray.length - 1); index = index + 1) {
+ String t = stringArray[index].replaceAll("\\D", "");
+ try {
+ temp[index] = Integer.parseInt(t);
+ } catch(NumberFormatException ex) {
+ temp[index] = 0;
+ }
+ }
+ return temp;
+ }
+}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotMain.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/BukkitCommandSender.java
similarity index 64%
rename from bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotMain.java
rename to bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/BukkitCommandSender.java
index 3e410f60..05e371e5 100644
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotMain.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/BukkitCommandSender.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,21 +23,30 @@
* @link https://github.com/GeyserMC/Geyser
*/
-package org.geysermc.platform.spigot;
+package org.geysermc.platform.bukkit.command;
-import org.geysermc.connector.common.main.IGeyserMain;
+import lombok.AllArgsConstructor;
-public class GeyserSpigotMain extends IGeyserMain {
+import org.bukkit.command.ConsoleCommandSender;
+import org.geysermc.connector.command.CommandSender;
- public static void main(String[] args) {
- new GeyserSpigotMain().displayMessage();
+@AllArgsConstructor
+public class BukkitCommandSender implements CommandSender {
+
+ private org.bukkit.command.CommandSender handle;
+
+ @Override
+ public String getName() {
+ return handle.getName();
}
- public String getPluginType() {
- return "Spigot or Paper (recommended)";
+ @Override
+ public void sendMessage(String message) {
+ handle.sendMessage(message);
}
- public String getPluginFolder() {
- return "plugins";
+ @Override
+ public boolean isConsole() {
+ return handle instanceof ConsoleCommandSender;
}
}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/GeyserSpigotCommandExecutor.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/GeyserBukkitCommandExecutor.java
similarity index 72%
rename from bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/GeyserSpigotCommandExecutor.java
rename to bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/GeyserBukkitCommandExecutor.java
index 1db86856..d2603f7c 100644
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/GeyserSpigotCommandExecutor.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/GeyserBukkitCommandExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,42 +23,39 @@
* @link https://github.com/GeyserMC/Geyser
*/
-package org.geysermc.platform.spigot.command;
+package org.geysermc.platform.bukkit.command;
import lombok.AllArgsConstructor;
+
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.utils.LanguageUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@AllArgsConstructor
-public class GeyserSpigotCommandExecutor implements TabExecutor {
+public class GeyserBukkitCommandExecutor implements TabExecutor {
- private final GeyserConnector connector;
+ private GeyserConnector connector;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length > 0) {
if (getCommand(args[0]) != null) {
if (!sender.hasPermission(getCommand(args[0]).getPermission())) {
- SpigotCommandSender commandSender = new SpigotCommandSender(sender);
- String message = LanguageUtils.getPlayerLocaleString("geyser.bootstrap.command.permission_fail", commandSender.getLocale());;
-
- commandSender.sendMessage(ChatColor.RED + message);
+ sender.sendMessage(ChatColor.RED + "You do not have permission to execute this command!");
return true;
}
- getCommand(args[0]).execute(new SpigotCommandSender(sender), args.length > 1 ? Arrays.copyOfRange(args, 1, args.length) : new String[0]);
+ getCommand(args[0]).execute(new BukkitCommandSender(sender), args);
return true;
}
} else {
- getCommand("help").execute(new SpigotCommandSender(sender), new String[0]);
+ getCommand("help").execute(new BukkitCommandSender(sender), args);
return true;
}
return true;
@@ -67,7 +64,7 @@ public class GeyserSpigotCommandExecutor implements TabExecutor {
@Override
public List onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 1) {
- return connector.getCommandManager().getCommandNames();
+ return Arrays.asList("?", "help", "reload", "shutdown", "stop");
}
return new ArrayList<>();
}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/GeyserSpigotCommandManager.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/GeyserBukkitCommandManager.java
similarity index 86%
rename from bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/GeyserSpigotCommandManager.java
rename to bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/GeyserBukkitCommandManager.java
index c0c239b0..b826ab1f 100644
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/GeyserSpigotCommandManager.java
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/command/GeyserBukkitCommandManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,18 +23,18 @@
* @link https://github.com/GeyserMC/Geyser
*/
-package org.geysermc.platform.spigot.command;
+package org.geysermc.platform.bukkit.command;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandMap;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandManager;
-import org.geysermc.platform.spigot.GeyserSpigotPlugin;
+import org.geysermc.platform.bukkit.GeyserBukkitPlugin;
import java.lang.reflect.Field;
-public class GeyserSpigotCommandManager extends CommandManager {
+public class GeyserBukkitCommandManager extends CommandManager {
private static CommandMap COMMAND_MAP;
@@ -48,9 +48,9 @@ public class GeyserSpigotCommandManager extends CommandManager {
}
}
- private GeyserSpigotPlugin plugin;
+ private GeyserBukkitPlugin plugin;
- public GeyserSpigotCommandManager(GeyserSpigotPlugin plugin, GeyserConnector connector) {
+ public GeyserBukkitCommandManager(GeyserBukkitPlugin plugin, GeyserConnector connector) {
super(connector);
this.plugin = plugin;
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitBlockPlaceListener.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitBlockPlaceListener.java
new file mode 100644
index 00000000..76d1564e
--- /dev/null
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitBlockPlaceListener.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.platform.bukkit.world;
+
+import com.nukkitx.math.vector.Vector3f;
+import com.nukkitx.protocol.bedrock.data.SoundEvent;
+import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
+import lombok.AllArgsConstructor;
+import org.bukkit.Bukkit;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.BlockPlaceEvent;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.network.session.GeyserSession;
+import org.geysermc.connector.network.translators.world.block.BlockTranslator;
+
+@AllArgsConstructor
+public class GeyserBukkitBlockPlaceListener implements Listener {
+
+ private final GeyserConnector connector;
+ private final boolean isLegacy;
+ private final boolean isViaVersion;
+
+ @EventHandler
+ public void place(final BlockPlaceEvent event) {
+ for (GeyserSession session : connector.getPlayers().values()) {
+ if (event.getPlayer() == Bukkit.getPlayer(session.getPlayerEntity().getUsername())) {
+ LevelSoundEventPacket placeBlockSoundPacket = new LevelSoundEventPacket();
+ placeBlockSoundPacket.setSound(SoundEvent.PLACE);
+ placeBlockSoundPacket.setPosition(Vector3f.from(event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ()));
+ placeBlockSoundPacket.setBabySound(false);
+ String javaBlockId;
+ if (isLegacy) {
+ javaBlockId = BlockTranslator.getJavaIdBlockMap().inverse().get(GeyserBukkitWorldManager.getLegacyBlock(session,
+ event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ(), isViaVersion));
+ } else {
+ javaBlockId = event.getBlockPlaced().getBlockData().getAsString();
+ }
+ placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaIdBlockMap().get(javaBlockId)));
+ placeBlockSoundPacket.setIdentifier(":");
+ session.sendUpstreamPacket(placeBlockSoundPacket);
+ session.setLastBlockPlacePosition(null);
+ session.setLastBlockPlacedId(null);
+ break;
+ }
+ }
+ }
+
+}
diff --git a/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitWorldManager.java b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitWorldManager.java
new file mode 100644
index 00000000..fbdf2a47
--- /dev/null
+++ b/bootstrap/bukkit/src/main/java/org/geysermc/platform/bukkit/world/GeyserBukkitWorldManager.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.platform.bukkit.world;
+
+import com.github.steveice10.mc.protocol.data.game.world.block.BlockState;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.bukkit.Bukkit;
+import org.bukkit.block.Block;
+import org.geysermc.connector.network.session.GeyserSession;
+import org.geysermc.connector.network.translators.world.WorldManager;
+import org.geysermc.connector.network.translators.world.block.BlockTranslator;
+import org.geysermc.platform.bukkit.GeyserBukkitPlugin;
+import us.myles.ViaVersion.protocols.protocol1_13_1to1_13.Protocol1_13_1To1_13;
+import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
+
+@AllArgsConstructor
+public class GeyserBukkitWorldManager extends WorldManager {
+
+ private final boolean isLegacy;
+ // You need ViaVersion to connect to an older server with Geyser.
+ // However, we still check for ViaVersion in case there's some other way that gets Geyser on a pre-1.13 Bukkit server
+ private final boolean isViaVersion;
+
+ @Override
+ public BlockState getBlockAt(GeyserSession session, int x, int y, int z) {
+ if (session.getPlayerEntity() == null) {
+ return BlockTranslator.AIR;
+ }
+ if (isLegacy) {
+ return getLegacyBlock(session, x, y, z, isViaVersion);
+ }
+ return BlockTranslator.getJavaIdBlockMap().get(Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getBlockAt(x, y, z).getBlockData().getAsString());
+ }
+
+ @SuppressWarnings("deprecation")
+ public static BlockState getLegacyBlock(GeyserSession session, int x, int y, int z, boolean isViaVersion) {
+ if (isViaVersion) {
+ Block block = Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getBlockAt(x, y, z);
+ // Black magic that gets the old block state ID
+ int oldBlockId = (block.getType().getId() << 4) | (block.getData() & 0xF);
+ // Convert block state from old version -> 1.13 -> 1.13.1 -> 1.14 -> 1.15
+ int thirteenBlockId = us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.MappingData.blockMappings.getNewId(oldBlockId);
+ int thirteenPointOneBlockId = Protocol1_13_1To1_13.getNewBlockStateId(thirteenBlockId);
+ int fourteenBlockId = us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.blockStateMappings.getNewId(thirteenPointOneBlockId);
+ return new BlockState(MappingData.blockStateMappings.getNewId(fourteenBlockId));
+ } else {
+ return BlockTranslator.AIR;
+ }
+ }
+}
diff --git a/bootstrap/spigot/src/main/resources/plugin.yml b/bootstrap/bukkit/src/main/resources/plugin.yml
similarity index 67%
rename from bootstrap/spigot/src/main/resources/plugin.yml
rename to bootstrap/bukkit/src/main/resources/plugin.yml
index fee71ab1..89c90789 100644
--- a/bootstrap/spigot/src/main/resources/plugin.yml
+++ b/bootstrap/bukkit/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
-main: org.geysermc.platform.spigot.GeyserSpigotPlugin
-name: ${outputName}-Spigot
+main: org.geysermc.platform.bukkit.GeyserBukkitPlugin
+name: ${outputName}-Bukkit
author: ${project.organization.name}
website: ${project.organization.url}
version: ${project.version}
diff --git a/bootstrap/bungeecord/pom.xml b/bootstrap/bungeecord/pom.xml
index 54e0d56e..dd66db32 100644
--- a/bootstrap/bungeecord/pom.xml
+++ b/bootstrap/bungeecord/pom.xml
@@ -6,15 +6,15 @@
org.geysermcbootstrap-parent
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOT
+ ../bootstrap-bungeecord
-
org.geysermcconnector
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOTcompile
@@ -61,34 +61,10 @@
net.md_5.bungee.jniorg.geysermc.platform.bungeecord.shaded.jni
-
- com.fasterxml.jackson
- org.geysermc.platform.bungeecord.shaded.jackson
- io.nettyorg.geysermc.platform.bungeecord.shaded.netty
-
- org.reflections
- org.geysermc.platform.bungeecord.shaded.reflections
-
-
- com.google.common
- org.geysermc.platform.bungeecord.shaded.google.common
-
-
- com.google.guava
- org.geysermc.platform.bungeecord.shaded.google.guava
-
-
- org.dom4j
- org.geysermc.platform.bungeecord.shaded.dom4j
-
-
- net.kyori
- org.geysermc.platform.bungeecord.shaded.kyori
-
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java
index af246f6f..d983aec1 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,26 +25,216 @@
package org.geysermc.platform.bungeecord;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import lombok.Getter;
import net.md_5.bungee.api.plugin.Plugin;
+import net.md_5.bungee.config.Configuration;
import org.geysermc.connector.FloodgateKeyLoader;
-import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
+import java.io.File;
import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
-@Getter
-@JsonIgnoreProperties(ignoreUnknown = true)
-public final class GeyserBungeeConfiguration extends GeyserJacksonConfiguration {
- @JsonIgnore
- private Path floodgateKeyPath;
+public class GeyserBungeeConfiguration implements GeyserConfiguration {
+
+ private File dataFolder;
+ private Configuration config;
+
+ private BungeeBedrockConfiguration bedrockConfig;
+ private BungeeRemoteConfiguration remoteConfig;
+ private BungeeMetricsInfo metricsInfo;
+
+ private Map userAuthInfo = new HashMap<>();
+
+ private Path floodgateKey;
+
+ public GeyserBungeeConfiguration(File dataFolder, Configuration config) {
+ this.dataFolder = dataFolder;
+ this.config = config;
+
+ bedrockConfig = new BungeeBedrockConfiguration();
+ remoteConfig = new BungeeRemoteConfiguration();
+ metricsInfo = new BungeeMetricsInfo();
+
+ if (!config.contains("userAuths"))
+ return;
+
+ for (String key : config.getSection("userAuths").getKeys()) {
+ userAuthInfo.put(key, new BungeeUserAuthenticationInfo(key));
+ }
+ }
public void loadFloodgate(GeyserBungeePlugin plugin) {
Plugin floodgate = plugin.getProxy().getPluginManager().getPlugin("floodgate-bungee");
- Path geyserDataFolder = plugin.getDataFolder().toPath();
- Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;
+ floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), config.getString("floodgate-key-file", "public-key.pem")), floodgate, floodgate != null ? floodgate.getDataFolder().toPath() : null);
+ }
- floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, floodgateDataFolder, geyserDataFolder, plugin.getGeyserLogger());
+ @Override
+ public BungeeBedrockConfiguration getBedrock() {
+ return bedrockConfig;
+ }
+
+ @Override
+ public BungeeRemoteConfiguration getRemote() {
+ return remoteConfig;
+ }
+
+ @Override
+ public Map getUserAuths() {
+ return userAuthInfo;
+ }
+
+ @Override
+ public boolean isCommandSuggestions() {
+ return config.getBoolean("command-suggestions", true);
+ }
+
+ @Override
+ public boolean isPassthroughMotd() {
+ return config.getBoolean("passthrough-motd", false);
+ }
+
+ @Override
+ public boolean isPassthroughPlayerCounts() {
+ return config.getBoolean("passthrough-player-counts", false);
+ }
+
+ @Override
+ public boolean isLegacyPingPassthrough() {
+ return config.getBoolean("legacy-ping-passthrough", false);
+ }
+
+ @Override
+ public int getPingPassthroughInterval() {
+ return config.getInt("ping-passthrough-interval", 3);
+ }
+
+ @Override
+ public int getMaxPlayers() {
+ return config.getInt("max-players", 10);
+ }
+
+ @Override
+ public boolean isDebugMode() {
+ return config.getBoolean("debug-mode", false);
+ }
+
+ @Override
+ public int getGeneralThreadPool() {
+ return config.getInt("general-thread-pool", 32);
+ }
+
+ @Override
+ public boolean isAllowThirdPartyCapes() {
+ return config.getBoolean("allow-third-party-capes", true);
+ }
+
+ @Override
+ public boolean isAllowThirdPartyEars() {
+ return config.getBoolean("allow-third-party-ears", false);
+ }
+
+ @Override
+ public String getDefaultLocale() {
+ return config.getString("default-locale", "en_us");
+ }
+
+ @Override
+ public Path getFloodgateKeyFile() {
+ return floodgateKey;
+ }
+
+ @Override
+ public boolean isCacheChunks() {
+ return config.getBoolean("cache-chunks", false);
+ }
+
+ @Override
+ public boolean isAboveBedrockNetherBuilding() {
+ return config.getBoolean("above-bedrock-nether-building", false);
+ }
+
+ @Override
+ public BungeeMetricsInfo getMetrics() {
+ return metricsInfo;
+ }
+
+ public class BungeeBedrockConfiguration implements IBedrockConfiguration {
+
+ @Override
+ public String getAddress() {
+ return config.getString("bedrock.address", "0.0.0.0");
+ }
+
+ @Override
+ public int getPort() {
+ return config.getInt("bedrock.port", 25565);
+ }
+
+ @Override
+ public String getMotd1() {
+ return config.getString("bedrock.motd1", "GeyserMC");
+ }
+
+ @Override
+ public String getMotd2() {
+ return config.getString("bedrock.motd2", "GeyserMC");
+ }
+ }
+
+ public class BungeeRemoteConfiguration implements IRemoteConfiguration {
+
+ @Override
+ public String getAddress() {
+ return config.getString("remote.address", "127.0.0.1");
+ }
+
+ @Override
+ public int getPort() {
+ return config.getInt("remote.port", 25565);
+ }
+
+ @Override
+ public String getAuthType() {
+ return config.getString("remote.auth-type", "online");
+ }
+ }
+
+ public class BungeeUserAuthenticationInfo implements IUserAuthenticationInfo {
+
+ private String key;
+
+ public BungeeUserAuthenticationInfo(String key) {
+ this.key = key;
+ }
+
+ @Override
+ public String getEmail() {
+ return config.getString("userAuths." + key + ".email");
+ }
+
+ @Override
+ public String getPassword() {
+ return config.getString("userAuths." + key + ".password");
+ }
+ }
+
+ public class BungeeMetricsInfo implements IMetricsInfo {
+
+ @Override
+ public boolean isEnabled() {
+ return config.getBoolean("metrics.enabled", true);
+ }
+
+ @Override
+ public String getUniqueId() {
+ return config.getString("metrics.uuid", "generateduuid");
+ }
+ }
+
+ @Override
+ public int getConfigVersion() {
+ return config.getInt("config-version", 0);
}
}
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeDumpInfo.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeDumpInfo.java
deleted file mode 100644
index 12429d75..00000000
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeDumpInfo.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.bungeecord;
-
-import lombok.Getter;
-import net.md_5.bungee.api.ProxyServer;
-import net.md_5.bungee.api.plugin.Plugin;
-import org.geysermc.connector.common.serializer.AsteriskSerializer;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-@Getter
-public class GeyserBungeeDumpInfo extends BootstrapDumpInfo {
-
- private String platformName;
- private String platformVersion;
- private boolean onlineMode;
- private List listeners;
- private List plugins;
-
- GeyserBungeeDumpInfo(ProxyServer proxy) {
- super();
- this.platformName = proxy.getName();
- this.platformVersion = proxy.getVersion();
- this.onlineMode = proxy.getConfig().isOnlineMode();
- this.listeners = new ArrayList<>();
- this.plugins = new ArrayList<>();
-
- for (net.md_5.bungee.api.config.ListenerInfo listener : proxy.getConfig().getListeners()) {
- String hostname;
- if (AsteriskSerializer.showSensitive || (listener.getHost().getHostString().equals("") || listener.getHost().getHostString().equals("0.0.0.0"))) {
- hostname = listener.getHost().getHostString();
- } else {
- hostname = "***";
- }
- this.listeners.add(new ListenerInfo(hostname, listener.getHost().getPort()));
- }
-
- for (Plugin plugin : proxy.getPluginManager().getPlugins()) {
- this.plugins.add(new PluginInfo(true, plugin.getDescription().getName(), plugin.getDescription().getVersion(), plugin.getDescription().getMain(), Arrays.asList(plugin.getDescription().getAuthor())));
- }
- }
-}
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java
index 1903bb86..cd07b333 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeLogger.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,21 +25,19 @@
package org.geysermc.platform.bungeecord;
-import lombok.Getter;
-import lombok.Setter;
import org.geysermc.connector.GeyserLogger;
import java.util.logging.Level;
import java.util.logging.Logger;
public class GeyserBungeeLogger implements GeyserLogger {
- private final Logger logger;
- @Getter @Setter
- private boolean debug;
- public GeyserBungeeLogger(Logger logger, boolean debug) {
+ private Logger logger;
+ private boolean debugMode;
+
+ public GeyserBungeeLogger(Logger logger, boolean debugMode) {
this.logger = logger;
- this.debug = debug;
+ this.debugMode = debugMode;
}
@Override
@@ -74,8 +72,12 @@ public class GeyserBungeeLogger implements GeyserLogger {
@Override
public void debug(String message) {
- if (debug) {
+ if (debugMode)
info(message);
- }
+ }
+
+ @Override
+ public void setDebug(boolean debug) {
+ debugMode = debug;
}
}
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeMain.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeMain.java
index b69c3573..eabbcc69 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeMain.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeeMain.java
@@ -1,31 +1,32 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.platform.bungeecord;
-import org.geysermc.connector.common.main.IGeyserMain;
+import org.geysermc.common.main.IGeyserMain;
public class GeyserBungeeMain extends IGeyserMain {
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePingPassthrough.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePingPassthrough.java
index 6eea2591..c7f8f276 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePingPassthrough.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePingPassthrough.java
@@ -1,26 +1,27 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.platform.bungeecord;
@@ -34,7 +35,7 @@ import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.event.ProxyPingEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.protocol.ProtocolConstants;
-import org.geysermc.connector.common.ping.GeyserPingInfo;
+import org.geysermc.common.ping.GeyserPingInfo;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import java.net.Inet4Address;
@@ -47,25 +48,26 @@ import java.util.concurrent.CompletableFuture;
@AllArgsConstructor
public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, Listener {
+ private static final GeyserPendingConnection PENDING_CONNECTION = new GeyserPendingConnection();
+
private final ProxyServer proxyServer;
@Override
- public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
+ public GeyserPingInfo getPingInformation() {
CompletableFuture future = new CompletableFuture<>();
- proxyServer.getPluginManager().callEvent(new ProxyPingEvent(new GeyserPendingConnection(inetSocketAddress), getPingInfo(), (event, throwable) -> {
+ proxyServer.getPluginManager().callEvent(new ProxyPingEvent(PENDING_CONNECTION, getPingInfo(), (event, throwable) -> {
if (throwable != null) future.completeExceptionally(throwable);
else future.complete(event);
}));
ProxyPingEvent event = future.join();
- ServerPing response = event.getResponse();
GeyserPingInfo geyserPingInfo = new GeyserPingInfo(
- response.getDescriptionComponent().toLegacyText(),
- new GeyserPingInfo.Players(response.getPlayers().getMax(), response.getPlayers().getOnline()),
- new GeyserPingInfo.Version(response.getVersion().getName(), response.getVersion().getProtocol())
+ event.getResponse().getDescription(),
+ event.getResponse().getPlayers().getOnline(),
+ event.getResponse().getPlayers().getMax()
);
if (event.getResponse().getPlayers().getSample() != null) {
Arrays.stream(event.getResponse().getPlayers().getSample()).forEach(proxiedPlayer -> {
- geyserPingInfo.getPlayerList().add(proxiedPlayer.getName());
+ geyserPingInfo.addPlayer(proxiedPlayer.getName());
});
}
return geyserPingInfo;
@@ -87,12 +89,7 @@ public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, List
private static class GeyserPendingConnection implements PendingConnection {
private static final UUID FAKE_UUID = UUID.nameUUIDFromBytes("geyser!internal".getBytes());
-
- private final InetSocketAddress remote;
-
- public GeyserPendingConnection(InetSocketAddress remote) {
- this.remote = remote;
- }
+ private static final InetSocketAddress FAKE_REMOTE = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 69);
@Override
public String getName() {
@@ -146,7 +143,7 @@ public class GeyserBungeePingPassthrough implements IGeyserPingPassthrough, List
@Override
public InetSocketAddress getAddress() {
- return remote;
+ return FAKE_REMOTE;
}
@Override
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java
index 8d37bffb..525b9b6d 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/GeyserBungeePlugin.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -27,23 +27,24 @@ package org.geysermc.platform.bungeecord;
import net.md_5.bungee.api.config.ListenerInfo;
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 org.geysermc.common.PlatformType;
+import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager;
-import org.geysermc.connector.configuration.GeyserConfiguration;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
-import org.geysermc.connector.utils.FileUtils;
-import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandExecutor;
import org.geysermc.platform.bungeecord.command.GeyserBungeeCommandManager;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.net.InetSocketAddress;
-import java.nio.file.Path;
+import java.nio.file.Files;
import java.util.UUID;
import java.util.logging.Level;
@@ -61,48 +62,66 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
if (!getDataFolder().exists())
getDataFolder().mkdir();
- try {
- if (!getDataFolder().exists())
- getDataFolder().mkdir();
- File configFile = FileUtils.fileOrCopiedFromResource(new File(getDataFolder(), "config.yml"), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
- this.geyserConfig = FileUtils.loadConfig(configFile, GeyserBungeeConfiguration.class);
- } catch (IOException ex) {
- getLogger().log(Level.WARNING, LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
- ex.printStackTrace();
+ File file = new File(getDataFolder(), "config.yml");
+ Configuration configuration = null;
+
+ if (!file.exists()) {
+ try (InputStream in = getResourceAsStream("config.yml")) {
+ Files.copy(in, file.toPath());
+ } catch (IOException ex) {
+ getLogger().log(Level.SEVERE, "Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
+ return;
+ }
}
+ try {
+ configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
+ } catch(IOException e) {
+ e.printStackTrace();
+ }
+
+ if (configuration == null) {
+ getLogger().severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!");
+ return;
+ }
+
+ this.geyserConfig = new GeyserBungeeConfiguration(getDataFolder(), configuration);
+
+ boolean configHasChanged = false;
if (getProxy().getConfig().getListeners().size() == 1) {
ListenerInfo listener = getProxy().getConfig().getListeners().toArray(new ListenerInfo[0])[0];
InetSocketAddress javaAddr = listener.getHost();
- // By default this should be localhost but may need to be changed in some circumstances
- if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
- this.geyserConfig.setAutoconfiguredRemote(true);
- // Don't use localhost if not listening on all interfaces
- if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
- this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
- }
- this.geyserConfig.getRemote().setPort(javaAddr.getPort());
+ // Don't change the ip if its listening on all interfaces
+ // By default this should be 127.0.0.1 but may need to be changed in some circumstances
+ if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
+ configuration.set("remote.address", javaAddr.getHostString());
}
- if (geyserConfig.getBedrock().isCloneRemotePort()) {
- geyserConfig.getBedrock().setPort(javaAddr.getPort());
+ configuration.set("remote.port", javaAddr.getPort());
+
+ configHasChanged = true;
+ }
+
+ if (geyserConfig.getMetrics().getUniqueId().equals("generateduuid")) {
+ configuration.set("metrics.uuid", UUID.randomUUID().toString());
+
+ configHasChanged = true;
+ }
+
+ if (configHasChanged) {
+ try {
+ ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration, new File(getDataFolder(), "config.yml"));
+ } catch (IOException ex) {
+ getLogger().log(Level.SEVERE, "Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
+ return;
}
}
this.geyserLogger = new GeyserBungeeLogger(getLogger(), geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
- if (geyserConfig.getRemote().getAuthType().equals("floodgate") && getProxy().getPluginManager().getPlugin("floodgate-bungee") == null) {
- geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
- return;
- } else if (geyserConfig.isAutoconfiguredRemote() && getProxy().getPluginManager().getPlugin("floodgate-bungee") != null) {
- // Floodgate installed means that the user wants Floodgate authentication
- geyserLogger.debug("Auto-setting to Floodgate authentication.");
- geyserConfig.getRemote().setAuthType("floodgate");
- }
-
geyserConfig.loadFloodgate(this);
this.connector = GeyserConnector.start(PlatformType.BUNGEECORD, this);
@@ -142,14 +161,4 @@ public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap {
public IGeyserPingPassthrough getGeyserPingPassthrough() {
return geyserBungeePingPassthrough;
}
-
- @Override
- public Path getConfigFolder() {
- return getDataFolder().toPath();
- }
-
- @Override
- public BootstrapDumpInfo getDumpInfo() {
- return new GeyserBungeeDumpInfo(getProxy());
- }
}
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/BungeeCommandSender.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/BungeeCommandSender.java
index 807cf478..d40dc902 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/BungeeCommandSender.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/BungeeCommandSender.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,20 +25,17 @@
package org.geysermc.platform.bungeecord.command;
+import lombok.AllArgsConstructor;
+
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
-import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.utils.LanguageUtils;
+import org.geysermc.connector.command.CommandSender;
+
+@AllArgsConstructor
public class BungeeCommandSender implements CommandSender {
- private final net.md_5.bungee.api.CommandSender handle;
-
- public BungeeCommandSender(net.md_5.bungee.api.CommandSender handle) {
- this.handle = handle;
- // Ensure even Java players' languages are loaded
- LanguageUtils.loadGeyserLocale(getLocale());
- }
+ private net.md_5.bungee.api.CommandSender handle;
@Override
public String getName() {
@@ -54,14 +51,4 @@ public class BungeeCommandSender implements CommandSender {
public boolean isConsole() {
return !(handle instanceof ProxiedPlayer);
}
-
- @Override
- public String getLocale() {
- if (handle instanceof ProxiedPlayer) {
- ProxiedPlayer player = (ProxiedPlayer) handle;
- String locale = player.getLocale().getLanguage() + "_" + player.getLocale().getCountry();
- return LanguageUtils.formatLocale(locale);
- }
- return LanguageUtils.getDefaultLocale();
- }
}
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/GeyserBungeeCommandExecutor.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/GeyserBungeeCommandExecutor.java
index 2431f0a4..d1c8473b 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/GeyserBungeeCommandExecutor.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/GeyserBungeeCommandExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -27,18 +27,19 @@ package org.geysermc.platform.bungeecord.command;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
+import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.TabExecutor;
+
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.utils.LanguageUtils;
import java.util.ArrayList;
import java.util.Arrays;
public class GeyserBungeeCommandExecutor extends Command implements TabExecutor {
- private final GeyserConnector connector;
+ private GeyserConnector connector;
public GeyserBungeeCommandExecutor(GeyserConnector connector) {
super("geyser");
@@ -51,23 +52,20 @@ public class GeyserBungeeCommandExecutor extends Command implements TabExecutor
if (args.length > 0) {
if (getCommand(args[0]) != null) {
if (!sender.hasPermission(getCommand(args[0]).getPermission())) {
- BungeeCommandSender commandSender = new BungeeCommandSender(sender);
- String message = LanguageUtils.getPlayerLocaleString("geyser.bootstrap.command.permission_fail", commandSender.getLocale());
-
- commandSender.sendMessage(ChatColor.RED + message);
+ sender.sendMessage(TextComponent.fromLegacyText(ChatColor.RED + "You do not have permission to execute this command!"));
return;
}
- getCommand(args[0]).execute(new BungeeCommandSender(sender), args.length > 1 ? Arrays.copyOfRange(args, 1, args.length) : new String[0]);
+ getCommand(args[0]).execute(new BungeeCommandSender(sender), args);
}
} else {
- getCommand("help").execute(new BungeeCommandSender(sender), new String[0]);
+ getCommand("help").execute(new BungeeCommandSender(sender), args);
}
}
@Override
public Iterable onTabComplete(CommandSender sender, String[] args) {
if (args.length == 1) {
- return connector.getCommandManager().getCommandNames();
+ return Arrays.asList("?", "help", "reload", "shutdown", "stop");
}
return new ArrayList<>();
}
diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/GeyserBungeeCommandManager.java b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/GeyserBungeeCommandManager.java
index bc5c6a59..bb79c577 100644
--- a/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/GeyserBungeeCommandManager.java
+++ b/bootstrap/bungeecord/src/main/java/org/geysermc/platform/bungeecord/command/GeyserBungeeCommandManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/bootstrap/pom.xml b/bootstrap/pom.xml
index a5ad53cb..6d12b673 100644
--- a/bootstrap/pom.xml
+++ b/bootstrap/pom.xml
@@ -6,11 +6,12 @@
org.geysermcgeyser-parent
- 1.2.0-SNAPSHOT
+ parent
+ ../bootstrap-parent
+ 1.0-SNAPSHOTpom
-
spigot-public
@@ -34,8 +35,8 @@
+ bukkitbungeecord
- spigotspongestandalonevelocity
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotConfiguration.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotConfiguration.java
deleted file mode 100644
index 2dbdbf83..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotConfiguration.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import lombok.Getter;
-import org.bukkit.Bukkit;
-import org.bukkit.plugin.Plugin;
-import org.geysermc.connector.FloodgateKeyLoader;
-import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
-
-import java.nio.file.Path;
-
-@Getter
-@JsonIgnoreProperties(ignoreUnknown = true)
-public final class GeyserSpigotConfiguration extends GeyserJacksonConfiguration {
- @JsonIgnore
- private Path floodgateKeyPath;
-
- public void loadFloodgate(GeyserSpigotPlugin plugin) {
- Plugin floodgate = Bukkit.getPluginManager().getPlugin("floodgate-bukkit");
- Path geyserDataFolder = plugin.getDataFolder().toPath();
- Path floodgateDataFolder = floodgate != null ? floodgate.getDataFolder().toPath() : null;
-
- floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, floodgateDataFolder, geyserDataFolder, plugin.getGeyserLogger());
- }
-
- @Override
- public boolean isCacheChunks() {
- return true; // We override this as with Bukkit, we have direct access to the server implementation
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotDumpInfo.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotDumpInfo.java
deleted file mode 100644
index 03fa0850..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotDumpInfo.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot;
-
-import lombok.Getter;
-import org.bukkit.Bukkit;
-import org.bukkit.plugin.Plugin;
-import org.geysermc.connector.common.serializer.AsteriskSerializer;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Getter
-public class GeyserSpigotDumpInfo extends BootstrapDumpInfo {
-
- private String platformName;
- private String platformVersion;
- private String platformAPIVersion;
- private boolean onlineMode;
- private String serverIP;
- private int serverPort;
- private List plugins;
-
- GeyserSpigotDumpInfo() {
- super();
- this.platformName = Bukkit.getName();
- this.platformVersion = Bukkit.getVersion();
- this.platformAPIVersion = Bukkit.getBukkitVersion();
- this.onlineMode = Bukkit.getOnlineMode();
- if (AsteriskSerializer.showSensitive || (Bukkit.getIp().equals("") || Bukkit.getIp().equals("0.0.0.0"))) {
- this.serverIP = Bukkit.getIp();
- } else {
- this.serverIP = "***";
- }
- this.serverPort = Bukkit.getPort();
- this.plugins = new ArrayList<>();
-
- for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
- this.plugins.add(new PluginInfo(plugin.isEnabled(), plugin.getName(), plugin.getDescription().getVersion(), plugin.getDescription().getMain(), plugin.getDescription().getAuthors()));
- }
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPingPassthrough.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPingPassthrough.java
deleted file mode 100644
index 20bfecb6..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPingPassthrough.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot;
-
-import com.github.steveice10.mc.protocol.MinecraftConstants;
-import lombok.AllArgsConstructor;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.event.server.ServerListPingEvent;
-import org.bukkit.util.CachedServerIcon;
-import org.geysermc.connector.common.ping.GeyserPingInfo;
-import org.geysermc.connector.ping.IGeyserPingPassthrough;
-
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.util.Collections;
-import java.util.Iterator;
-
-@AllArgsConstructor
-public class GeyserSpigotPingPassthrough implements IGeyserPingPassthrough {
-
- private final GeyserSpigotLogger logger;
-
- @Override
- public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
- try {
- ServerListPingEvent event = new GeyserPingEvent(inetSocketAddress.getAddress(), Bukkit.getMotd(), Bukkit.getOnlinePlayers().size(), Bukkit.getMaxPlayers());
- Bukkit.getPluginManager().callEvent(event);
- GeyserPingInfo geyserPingInfo = new GeyserPingInfo(event.getMotd(),
- new GeyserPingInfo.Players(event.getMaxPlayers(), event.getNumPlayers()),
- new GeyserPingInfo.Version(Bukkit.getVersion(), MinecraftConstants.PROTOCOL_VERSION) // thanks Spigot for not exposing this, just default to latest
- );
- Bukkit.getOnlinePlayers().stream().map(Player::getName).forEach(geyserPingInfo.getPlayerList()::add);
- return geyserPingInfo;
- } catch (Exception e) {
- logger.debug("Error while getting Bukkit ping passthrough: " + e.toString());
- return new GeyserPingInfo(null, null, null);
- }
- }
-
- // These methods are unimplemented on spigot api by default so we add stubs so plugins don't complain
- private static class GeyserPingEvent extends ServerListPingEvent {
-
- public GeyserPingEvent(InetAddress address, String motd, int numPlayers, int maxPlayers) {
- super(address, motd, numPlayers, maxPlayers);
- }
-
- @Override
- public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
- }
-
- @Override
- public Iterator iterator() throws UnsupportedOperationException {
- return Collections.EMPTY_LIST.iterator();
- }
- }
-
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java
deleted file mode 100644
index b85aa313..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/GeyserSpigotPlugin.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot;
-
-import com.github.steveice10.mc.protocol.MinecraftConstants;
-import org.bukkit.Bukkit;
-import org.bukkit.plugin.java.JavaPlugin;
-import org.geysermc.adapters.spigot.SpigotAdapters;
-import org.geysermc.common.PlatformType;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.bootstrap.GeyserBootstrap;
-import org.geysermc.connector.command.CommandManager;
-import org.geysermc.connector.configuration.GeyserConfiguration;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
-import org.geysermc.connector.network.translators.world.WorldManager;
-import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
-import org.geysermc.connector.ping.IGeyserPingPassthrough;
-import org.geysermc.connector.utils.FileUtils;
-import org.geysermc.connector.utils.LanguageUtils;
-import org.geysermc.platform.spigot.command.GeyserSpigotCommandExecutor;
-import org.geysermc.platform.spigot.command.GeyserSpigotCommandManager;
-import org.geysermc.platform.spigot.command.SpigotCommandSender;
-import org.geysermc.platform.spigot.world.GeyserSpigotBlockPlaceListener;
-import org.geysermc.platform.spigot.world.manager.*;
-import us.myles.ViaVersion.api.Pair;
-import us.myles.ViaVersion.api.Via;
-import us.myles.ViaVersion.api.data.MappingData;
-import us.myles.ViaVersion.api.protocol.Protocol;
-import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
-import us.myles.ViaVersion.api.protocol.ProtocolVersion;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.UUID;
-import java.util.logging.Level;
-
-public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap {
- private GeyserSpigotCommandManager geyserCommandManager;
- private GeyserSpigotConfiguration geyserConfig;
- private GeyserSpigotLogger geyserLogger;
- private IGeyserPingPassthrough geyserSpigotPingPassthrough;
- private GeyserSpigotWorldManager geyserWorldManager;
-
- private GeyserConnector connector;
-
- @Override
- public void onEnable() {
- // This is manually done instead of using Bukkit methods to save the config because otherwise comments get removed
- try {
- if (!getDataFolder().exists()) {
- getDataFolder().mkdir();
- File bukkitConfig = new File("plugins/Geyser-Bukkit/config.yml");
- if (bukkitConfig.exists()) { // Copy over old configs
- getLogger().log(Level.INFO, LanguageUtils.getLocaleStringLog("geyser.bootstrap.config.copy_bukkit_config"));
- Files.copy(bukkitConfig.toPath(), new File(getDataFolder().toString() + "/config.yml").toPath());
- getLogger().log(Level.INFO, LanguageUtils.getLocaleStringLog("geyser.bootstrap.config.copied_bukkit_config"));
- }
- }
- File configFile = FileUtils.fileOrCopiedFromResource(new File(getDataFolder(), "config.yml"), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
- this.geyserConfig = FileUtils.loadConfig(configFile, GeyserSpigotConfiguration.class);
- } catch (IOException ex) {
- getLogger().log(Level.WARNING, LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
- ex.printStackTrace();
- }
-
- // By default this should be localhost but may need to be changed in some circumstances
- if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
- geyserConfig.setAutoconfiguredRemote(true);
- // Don't use localhost if not listening on all interfaces
- if (!Bukkit.getIp().equals("0.0.0.0") && !Bukkit.getIp().equals("")) {
- geyserConfig.getRemote().setAddress(Bukkit.getIp());
- }
- geyserConfig.getRemote().setPort(Bukkit.getPort());
- }
-
- if (geyserConfig.getBedrock().isCloneRemotePort()) {
- geyserConfig.getBedrock().setPort(Bukkit.getPort());
- }
-
- this.geyserLogger = new GeyserSpigotLogger(getLogger(), geyserConfig.isDebugMode());
- GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
-
- if (geyserConfig.getRemote().getAuthType().equals("floodgate") && Bukkit.getPluginManager().getPlugin("floodgate-bukkit") == null) {
- geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
- this.getPluginLoader().disablePlugin(this);
- return;
- } else if (geyserConfig.isAutoconfiguredRemote() && Bukkit.getPluginManager().getPlugin("floodgate-bukkit") != null) {
- // Floodgate installed means that the user wants Floodgate authentication
- geyserLogger.debug("Auto-setting to Floodgate authentication.");
- geyserConfig.getRemote().setAuthType("floodgate");
- }
-
- geyserConfig.loadFloodgate(this);
-
- this.connector = GeyserConnector.start(PlatformType.SPIGOT, this);
-
- if (geyserConfig.isLegacyPingPassthrough()) {
- this.geyserSpigotPingPassthrough = GeyserLegacyPingPassthrough.init(connector);
- } else {
- this.geyserSpigotPingPassthrough = new GeyserSpigotPingPassthrough(geyserLogger);
- }
-
- this.geyserCommandManager = new GeyserSpigotCommandManager(this, connector);
-
- boolean isViaVersion = (Bukkit.getPluginManager().getPlugin("ViaVersion") != null);
- if (isViaVersion) {
- if (!isCompatible(Via.getAPI().getVersion().replace("-SNAPSHOT", ""), "3.2.0")) {
- geyserLogger.warning(LanguageUtils.getLocaleStringLog("geyser.bootstrap.viaversion.too_old",
- "https://ci.viaversion.com/job/ViaVersion/"));
- isViaVersion = false;
- }
- }
- // Used to determine if Block.getBlockData() is present.
- boolean isLegacy = !isCompatible(Bukkit.getServer().getVersion(), "1.13.0");
- if (isLegacy)
- geyserLogger.debug("Legacy version of Minecraft (1.12.2 or older) detected; falling back to ViaVersion for block state retrieval.");
-
- boolean use3dBiomes = isCompatible(Bukkit.getServer().getVersion(), "1.16.0");
- if (!use3dBiomes) {
- geyserLogger.debug("Legacy version of Minecraft (1.15.2 or older) detected; not using 3D biomes.");
- }
-
- // Set if we need to use a different method for getting a player's locale
- SpigotCommandSender.setUseLegacyLocaleMethod(!isCompatible(Bukkit.getServer().getVersion(), "1.12.0"));
-
- if (connector.getConfig().isUseAdapters()) {
- try {
- String name = Bukkit.getServer().getClass().getPackage().getName();
- String nmsVersion = name.substring(name.lastIndexOf('.') + 1);
- SpigotAdapters.registerWorldAdapter(nmsVersion);
- if (isViaVersion && isViaVersionNeeded()) {
- if (isLegacy) {
- // Pre-1.13
- this.geyserWorldManager = new GeyserSpigot1_12NativeWorldManager();
- } else {
- // Post-1.13
- this.geyserWorldManager = new GeyserSpigotLegacyNativeWorldManager(this, use3dBiomes);
- }
- } else {
- // No ViaVersion
- this.geyserWorldManager = new GeyserSpigotNativeWorldManager(use3dBiomes);
- }
- geyserLogger.debug("Using NMS adapter: " + this.geyserWorldManager.getClass() + ", " + nmsVersion);
- } catch (Exception e) {
- if (geyserConfig.isDebugMode()) {
- geyserLogger.debug("Error while attempting to find NMS adapter. Most likely, this can be safely ignored. :)");
- e.printStackTrace();
- }
- }
- } else {
- geyserLogger.debug("Not using NMS adapter as it is disabled in the config.");
- }
- if (this.geyserWorldManager == null) {
- // No NMS adapter
- if (isLegacy && isViaVersion) {
- // Use ViaVersion for converting pre-1.13 block states
- this.geyserWorldManager = new GeyserSpigot1_12WorldManager();
- } else if (isLegacy) {
- // Not sure how this happens - without ViaVersion, we don't know any block states, so just assume everything is air
- this.geyserWorldManager = new GeyserSpigotFallbackWorldManager();
- } else {
- // Post-1.13
- this.geyserWorldManager = new GeyserSpigotWorldManager(use3dBiomes);
- }
- geyserLogger.debug("Using default world manager: " + this.geyserWorldManager.getClass());
- }
- GeyserSpigotBlockPlaceListener blockPlaceListener = new GeyserSpigotBlockPlaceListener(connector, this.geyserWorldManager);
-
- Bukkit.getServer().getPluginManager().registerEvents(blockPlaceListener, this);
-
- this.getCommand("geyser").setExecutor(new GeyserSpigotCommandExecutor(connector));
- }
-
- @Override
- public void onDisable() {
- if (connector != null) {
- connector.shutdown();
- }
- }
-
- @Override
- public GeyserSpigotConfiguration getGeyserConfig() {
- return geyserConfig;
- }
-
- @Override
- public GeyserSpigotLogger getGeyserLogger() {
- return geyserLogger;
- }
-
- @Override
- public CommandManager getGeyserCommandManager() {
- return this.geyserCommandManager;
- }
-
- @Override
- public IGeyserPingPassthrough getGeyserPingPassthrough() {
- return geyserSpigotPingPassthrough;
- }
-
- @Override
- public WorldManager getWorldManager() {
- return this.geyserWorldManager;
- }
-
- @Override
- public Path getConfigFolder() {
- return getDataFolder().toPath();
- }
-
- @Override
- public BootstrapDumpInfo getDumpInfo() {
- return new GeyserSpigotDumpInfo();
- }
-
- public boolean isCompatible(String version, String whichVersion) {
- int[] currentVersion = parseVersion(version);
- int[] otherVersion = parseVersion(whichVersion);
- int length = Math.max(currentVersion.length, otherVersion.length);
- for (int index = 0; index < length; index = index + 1) {
- int self = (index < currentVersion.length) ? currentVersion[index] : 0;
- int other = (index < otherVersion.length) ? otherVersion[index] : 0;
-
- if (self != other) {
- return (self - other) > 0;
- }
- }
- return true;
- }
-
- private int[] parseVersion(String versionParam) {
- versionParam = (versionParam == null) ? "" : versionParam;
- if (versionParam.contains("(MC: ")) {
- versionParam = versionParam.split("\\(MC: ")[1];
- versionParam = versionParam.split("\\)")[0];
- }
- String[] stringArray = versionParam.split("[_.-]");
- int[] temp = new int[stringArray.length];
- for (int index = 0; index <= (stringArray.length - 1); index = index + 1) {
- String t = stringArray[index].replaceAll("\\D", "");
- try {
- temp[index] = Integer.parseInt(t);
- } catch (NumberFormatException ex) {
- temp[index] = 0;
- }
- }
- return temp;
- }
-
- /**
- * @return the server version before ViaVersion finishes initializing
- */
- public ProtocolVersion getServerProtocolVersion() {
- String bukkitVersion = Bukkit.getServer().getVersion();
- // Turn "(MC: 1.16.4)" into 1.16.4.
- String version = bukkitVersion.split("\\(MC: ")[1].split("\\)")[0];
- return ProtocolVersion.getClosest(version);
- }
-
- /**
- * This function should not run unless ViaVersion is installed on the server.
- *
- * @return true if there is any block mappings difference between the server and client.
- */
- private boolean isViaVersionNeeded() {
- ProtocolVersion serverVersion = getServerProtocolVersion();
- List> protocolList = ProtocolRegistry.getProtocolPath(MinecraftConstants.PROTOCOL_VERSION,
- serverVersion.getVersion());
- if (protocolList == null) {
- // No translation needed!
- return false;
- }
- for (int i = protocolList.size() - 1; i >= 0; i--) {
- MappingData mappingData = protocolList.get(i).getValue().getMappingData();
- if (mappingData != null) {
- return true;
- }
- }
- // All mapping data is null, which means client and server block states are the same
- return false;
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/SpigotCommandSender.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/SpigotCommandSender.java
deleted file mode 100644
index c1c2b2c7..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/command/SpigotCommandSender.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot.command;
-
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.entity.Player;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.utils.LanguageUtils;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-public class SpigotCommandSender implements CommandSender {
-
- /**
- * Whether to use {@code Player.getLocale()} or {@code Player.spigot().getLocale()}, depending on version.
- * 1.12 or greater should not use the legacy method.
- */
- private static boolean USE_LEGACY_METHOD = false;
- private static Method LOCALE_METHOD;
-
- private final org.bukkit.command.CommandSender handle;
- private final String locale;
-
- public SpigotCommandSender(org.bukkit.command.CommandSender handle) {
- this.handle = handle;
- this.locale = getSpigotLocale();
- // Ensure even Java players' languages are loaded
- LanguageUtils.loadGeyserLocale(locale);
- }
-
- @Override
- public String getName() {
- return handle.getName();
- }
-
- @Override
- public void sendMessage(String message) {
- handle.sendMessage(message);
- }
-
- @Override
- public boolean isConsole() {
- return handle instanceof ConsoleCommandSender;
- }
-
- @Override
- public String getLocale() {
- return locale;
- }
-
- /**
- * Set if we are on pre-1.12, and therefore {@code player.getLocale()} doesn't exist and we have to get
- * {@code player.spigot().getLocale()}.
- *
- * @param useLegacyMethod if we are running pre-1.12 and therefore need to use reflection to get the player locale
- */
- public static void setUseLegacyLocaleMethod(boolean useLegacyMethod) {
- USE_LEGACY_METHOD = useLegacyMethod;
- if (USE_LEGACY_METHOD) {
- try {
- //noinspection JavaReflectionMemberAccess - of course it doesn't exist; that's why we're doing it
- LOCALE_METHOD = Player.Spigot.class.getMethod("getLocale");
- } catch (NoSuchMethodException e) {
- GeyserConnector.getInstance().getLogger().debug("Player.Spigot.getLocale() doesn't exist? Not a big deal but if you're seeing this please report it to the developers!");
- }
- }
- }
-
- /**
- * So we only have to do nasty reflection stuff once per command
- *
- * @return the locale of the Spigot player
- */
- private String getSpigotLocale() {
- if (handle instanceof Player) {
- Player player = (Player) handle;
- if (USE_LEGACY_METHOD) {
- try {
- // sigh
- // This was the only option on older Spigot instances and now it's gone
- return (String) LOCALE_METHOD.invoke(player.spigot());
- } catch (IllegalAccessException | InvocationTargetException ignored) {
- }
- } else {
- return player.getLocale();
- }
- }
- return LanguageUtils.getDefaultLocale();
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/GeyserSpigotBlockPlaceListener.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/GeyserSpigotBlockPlaceListener.java
deleted file mode 100644
index 56fa7581..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/GeyserSpigotBlockPlaceListener.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot.world;
-
-import com.nukkitx.math.vector.Vector3f;
-import com.nukkitx.protocol.bedrock.data.SoundEvent;
-import com.nukkitx.protocol.bedrock.packet.LevelSoundEventPacket;
-import lombok.AllArgsConstructor;
-import org.bukkit.Bukkit;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.block.BlockPlaceEvent;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.translators.world.block.BlockTranslator;
-import org.geysermc.platform.spigot.world.manager.GeyserSpigotWorldManager;
-
-@AllArgsConstructor
-public class GeyserSpigotBlockPlaceListener implements Listener {
-
- private final GeyserConnector connector;
- private final GeyserSpigotWorldManager worldManager;
-
- @EventHandler
- public void place(final BlockPlaceEvent event) {
- for (GeyserSession session : connector.getPlayers()) {
- if (event.getPlayer() == Bukkit.getPlayer(session.getPlayerEntity().getUsername())) {
- LevelSoundEventPacket placeBlockSoundPacket = new LevelSoundEventPacket();
- placeBlockSoundPacket.setSound(SoundEvent.PLACE);
- placeBlockSoundPacket.setPosition(Vector3f.from(event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ()));
- placeBlockSoundPacket.setBabySound(false);
- if (worldManager.isLegacy()) {
- placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(worldManager.getBlockAt(session,
- event.getBlockPlaced().getX(), event.getBlockPlaced().getY(), event.getBlockPlaced().getZ())));
- } else {
- String javaBlockId = event.getBlockPlaced().getBlockData().getAsString();
- placeBlockSoundPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaIdBlockMap().getOrDefault(javaBlockId, BlockTranslator.JAVA_AIR_ID)));
- }
- placeBlockSoundPacket.setIdentifier(":");
- session.sendUpstreamPacket(placeBlockSoundPacket);
- session.setLastBlockPlacePosition(null);
- session.setLastBlockPlacedId(null);
- break;
- }
- }
- }
-
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12NativeWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12NativeWorldManager.java
deleted file mode 100644
index ae199272..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12NativeWorldManager.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot.world.manager;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.geysermc.adapters.spigot.SpigotAdapters;
-import org.geysermc.adapters.spigot.SpigotWorldAdapter;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.translators.world.block.BlockTranslator;
-import us.myles.ViaVersion.api.Via;
-import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
-
-/**
- * Used with ViaVersion and pre-1.13.
- */
-public class GeyserSpigot1_12NativeWorldManager extends GeyserSpigot1_12WorldManager {
- private final SpigotWorldAdapter adapter;
-
- public GeyserSpigot1_12NativeWorldManager() {
- this.adapter = SpigotAdapters.getWorldAdapter();
- // Unlike post-1.13, we can't build up a cache of block states, because block entities need some special conversion
- }
-
- @Override
- public int getBlockAt(GeyserSession session, int x, int y, int z) {
- Player player = Bukkit.getPlayer(session.getPlayerEntity().getUsername());
- if (player == null) {
- return BlockTranslator.JAVA_AIR_ID;
- }
- // Get block entity storage
- BlockStorage storage = Via.getManager().getConnection(player.getUniqueId()).get(BlockStorage.class);
- int blockId = adapter.getBlockAt(player.getWorld(), x, y, z);
- return getLegacyBlock(storage, blockId, x, y, z);
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12WorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12WorldManager.java
deleted file mode 100644
index cb450f7f..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigot1_12WorldManager.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot.world.manager;
-
-import com.github.steveice10.mc.protocol.data.game.chunk.Chunk;
-import org.bukkit.Bukkit;
-import org.bukkit.World;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.translators.world.block.BlockTranslator;
-import us.myles.ViaVersion.api.Pair;
-import us.myles.ViaVersion.api.Via;
-import us.myles.ViaVersion.api.data.MappingData;
-import us.myles.ViaVersion.api.minecraft.Position;
-import us.myles.ViaVersion.api.protocol.Protocol;
-import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
-import us.myles.ViaVersion.api.protocol.ProtocolVersion;
-import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
-import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.storage.BlockStorage;
-
-import java.util.List;
-
-/**
- * Should be used when ViaVersion is present, no NMS adapter is being used, and we are pre-1.13.
- *
- * You need ViaVersion to connect to an older server with the Geyser-Spigot plugin.
- */
-public class GeyserSpigot1_12WorldManager extends GeyserSpigotWorldManager {
- /**
- * Specific mapping data for 1.12 to 1.13. Used to convert the 1.12 block into the 1.13 block state.
- * (Block IDs did not change between server versions until 1.13 and after)
- */
- private final MappingData mappingData1_12to1_13;
-
- /**
- * The list of all protocols from the client's version to 1.13.
- */
- private final List> protocolList;
-
- public GeyserSpigot1_12WorldManager() {
- super(false);
- this.mappingData1_12to1_13 = ProtocolRegistry.getProtocol(Protocol1_13To1_12_2.class).getMappingData();
- this.protocolList = ProtocolRegistry.getProtocolPath(CLIENT_PROTOCOL_VERSION,
- ProtocolVersion.v1_13.getVersion());
- }
-
- @Override
- @SuppressWarnings("deprecation")
- public int getBlockAt(GeyserSession session, int x, int y, int z) {
- Player player = Bukkit.getPlayer(session.getPlayerEntity().getUsername());
- if (player == null) {
- return BlockTranslator.JAVA_AIR_ID;
- }
- // Get block entity storage
- BlockStorage storage = Via.getManager().getConnection(player.getUniqueId()).get(BlockStorage.class);
- Block block = player.getWorld().getBlockAt(x, y, z);
- // Black magic that gets the old block state ID
- int blockId = (block.getType().getId() << 4) | (block.getData() & 0xF);
- return getLegacyBlock(storage, blockId, x, y, z);
- }
-
- /**
- *
- * @param storage ViaVersion's block entity storage (used to fix block entity state differences)
- * @param blockId the pre-1.13 block id
- * @param x X coordinate of block
- * @param y Y coordinate of block
- * @param z Z coordinate of block
- * @return the block state updated to the latest Minecraft version
- */
- @SuppressWarnings("deprecation")
- public int getLegacyBlock(BlockStorage storage, int blockId, int x, int y, int z) {
- // Convert block state from old version (1.12.2) -> 1.13 -> 1.13.1 -> 1.14 -> 1.15 -> 1.16 -> 1.16.2
- blockId = mappingData1_12to1_13.getNewBlockId(blockId);
- // Translate block entity differences - some information was stored in block tags and not block states
- if (storage.isWelcome(blockId)) { // No getOrDefault method
- BlockStorage.ReplacementData data = storage.get(new Position(x, (short) y, z));
- if (data != null && data.getReplacement() != -1) {
- blockId = data.getReplacement();
- }
- }
- for (int i = protocolList.size() - 1; i >= 0; i--) {
- MappingData mappingData = protocolList.get(i).getValue().getMappingData();
- if (mappingData != null) {
- blockId = mappingData.getNewBlockStateId(blockId);
- }
- }
- return blockId;
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public void getBlocksInSection(GeyserSession session, int x, int y, int z, Chunk chunk) {
- Player player = Bukkit.getPlayer(session.getPlayerEntity().getUsername());
- if (player == null) {
- return;
- }
- World world = player.getWorld();
- // Get block entity storage
- BlockStorage storage = Via.getManager().getConnection(player.getUniqueId()).get(BlockStorage.class);
- for (int blockY = 0; blockY < 16; blockY++) { // Cache-friendly iteration order
- for (int blockZ = 0; blockZ < 16; blockZ++) {
- for (int blockX = 0; blockX < 16; blockX++) {
- Block block = world.getBlockAt((x << 4) + blockX, (y << 4) + blockY, (z << 4) + blockZ);
- // Black magic that gets the old block state ID
- int blockId = (block.getType().getId() << 4) | (block.getData() & 0xF);
- chunk.set(blockX, blockY, blockZ, getLegacyBlock(storage, blockId, (x << 4) + blockX, (y << 4) + blockY, (z << 4) + blockZ));
- }
- }
- }
- }
-
- @Override
- public boolean isLegacy() {
- return true;
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotFallbackWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotFallbackWorldManager.java
deleted file mode 100644
index f2ae8a64..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotFallbackWorldManager.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot.world.manager;
-
-import com.github.steveice10.mc.protocol.data.game.chunk.Chunk;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.translators.world.block.BlockTranslator;
-
-/**
- * Should only be used when we know {@link GeyserSpigotWorldManager#getBlockAt(GeyserSession, int, int, int)}
- * cannot be accurate. Typically, this is when ViaVersion is not installed but a client still manages to connect.
- * If this occurs to you somehow, please let us know!!
- */
-public class GeyserSpigotFallbackWorldManager extends GeyserSpigotWorldManager {
- public GeyserSpigotFallbackWorldManager() {
- // Since this is pre-1.13 (and thus pre-1.15), there will never be 3D biomes.
- super(false);
- }
-
- @Override
- public int getBlockAt(GeyserSession session, int x, int y, int z) {
- return BlockTranslator.JAVA_AIR_ID;
- }
-
- @Override
- public void getBlocksInSection(GeyserSession session, int x, int y, int z, Chunk chunk) {
- // Do nothing, since we can't do anything with the chunk
- }
-
- @Override
- public boolean hasMoreBlockDataThanChunkCache() {
- return false;
- }
-
- @Override
- public boolean isLegacy() {
- return true;
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotLegacyNativeWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotLegacyNativeWorldManager.java
deleted file mode 100644
index 8ed1b388..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotLegacyNativeWorldManager.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot.world.manager;
-
-import com.github.steveice10.mc.protocol.MinecraftConstants;
-import it.unimi.dsi.fastutil.ints.Int2IntMap;
-import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
-import it.unimi.dsi.fastutil.ints.IntList;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.platform.spigot.GeyserSpigotPlugin;
-import us.myles.ViaVersion.api.Pair;
-import us.myles.ViaVersion.api.data.MappingData;
-import us.myles.ViaVersion.api.protocol.Protocol;
-import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
-import us.myles.ViaVersion.api.protocol.ProtocolVersion;
-
-import java.util.List;
-
-/**
- * Used when block IDs need to be translated to the latest version
- */
-public class GeyserSpigotLegacyNativeWorldManager extends GeyserSpigotNativeWorldManager {
-
- private final Int2IntMap oldToNewBlockId;
-
- public GeyserSpigotLegacyNativeWorldManager(GeyserSpigotPlugin plugin, boolean use3dBiomes) {
- super(use3dBiomes);
- IntList allBlockStates = adapter.getAllBlockStates();
- oldToNewBlockId = new Int2IntOpenHashMap(allBlockStates.size());
- ProtocolVersion serverVersion = plugin.getServerProtocolVersion();
- List> protocolList = ProtocolRegistry.getProtocolPath(MinecraftConstants.PROTOCOL_VERSION,
- serverVersion.getVersion());
- for (int oldBlockId : allBlockStates) {
- int newBlockId = oldBlockId;
- // protocolList should *not* be null; we checked for that before initializing this class
- for (int i = protocolList.size() - 1; i >= 0; i--) {
- MappingData mappingData = protocolList.get(i).getValue().getMappingData();
- if (mappingData != null) {
- newBlockId = mappingData.getNewBlockStateId(newBlockId);
- }
- }
- oldToNewBlockId.put(oldBlockId, newBlockId);
- }
- }
-
- @Override
- public int getBlockAt(GeyserSession session, int x, int y, int z) {
- int nativeBlockId = super.getBlockAt(session, x, y, z);
- return oldToNewBlockId.getOrDefault(nativeBlockId, nativeBlockId);
- }
-
- @Override
- public boolean isLegacy() {
- return true;
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotNativeWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotNativeWorldManager.java
deleted file mode 100644
index c7e3a3d4..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotNativeWorldManager.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot.world.manager;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.geysermc.adapters.spigot.SpigotAdapters;
-import org.geysermc.adapters.spigot.SpigotWorldAdapter;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.translators.world.block.BlockTranslator;
-
-public class GeyserSpigotNativeWorldManager extends GeyserSpigotWorldManager {
- protected final SpigotWorldAdapter adapter;
-
- public GeyserSpigotNativeWorldManager(boolean use3dBiomes) {
- super(use3dBiomes);
- adapter = SpigotAdapters.getWorldAdapter();
- }
-
- @Override
- public int getBlockAt(GeyserSession session, int x, int y, int z) {
- Player player = Bukkit.getPlayer(session.getPlayerEntity().getUsername());
- if (player == null) {
- return BlockTranslator.JAVA_AIR_ID;
- }
- return adapter.getBlockAt(player.getWorld(), x, y, z);
- }
-}
diff --git a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotWorldManager.java
deleted file mode 100644
index 748d0f1e..00000000
--- a/bootstrap/spigot/src/main/java/org/geysermc/platform/spigot/world/manager/GeyserSpigotWorldManager.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.spigot.world.manager;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.github.steveice10.mc.protocol.MinecraftConstants;
-import com.github.steveice10.mc.protocol.data.game.chunk.Chunk;
-import it.unimi.dsi.fastutil.ints.Int2IntMap;
-import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
-import org.bukkit.Bukkit;
-import org.bukkit.World;
-import org.bukkit.block.Biome;
-import org.bukkit.block.Block;
-import org.bukkit.block.data.BlockData;
-import org.bukkit.entity.Player;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.translators.world.GeyserWorldManager;
-import org.geysermc.connector.network.translators.world.block.BlockTranslator;
-import org.geysermc.connector.utils.FileUtils;
-import org.geysermc.connector.utils.GameRule;
-import org.geysermc.connector.utils.LanguageUtils;
-
-import java.io.InputStream;
-
-/**
- * The base world manager to use when there is no supported NMS revision
- */
-public class GeyserSpigotWorldManager extends GeyserWorldManager {
- /**
- * The current client protocol version for ViaVersion usage.
- */
- protected static final int CLIENT_PROTOCOL_VERSION = MinecraftConstants.PROTOCOL_VERSION;
-
- /**
- * Whether the server is pre-1.16 and therefore does not support 3D biomes on an API level guaranteed.
- */
- private final boolean use3dBiomes;
- /**
- * Stores a list of {@link Biome} ordinal numbers to Minecraft biome numeric IDs.
- *
- * Working with the Biome enum in Spigot poses two problems:
- * 1: The Biome enum values change in both order and names over the years.
- * 2: There is no way to get the Minecraft biome ID from the name itself with Spigot.
- * To solve both of these problems, we store a JSON file of every Biome enum that has existed,
- * along with its 1.16 biome number.
- *
- * The key is the Spigot Biome ordinal; the value is the Minecraft Java biome numerical ID
- */
- private final Int2IntMap biomeToIdMap = new Int2IntOpenHashMap(Biome.values().length);
-
- public GeyserSpigotWorldManager(boolean use3dBiomes) {
- this.use3dBiomes = use3dBiomes;
-
- // Load the values into the biome-to-ID map
- InputStream biomeStream = FileUtils.getResource("biomes.json");
- JsonNode biomes;
- try {
- biomes = GeyserConnector.JSON_MAPPER.readTree(biomeStream);
- } catch (Exception e) {
- throw new AssertionError(LanguageUtils.getLocaleStringLog("geyser.toolbox.fail.runtime_java"), e);
- }
- // Only load in the biomes that are present in this version of Minecraft
- for (Biome enumBiome : Biome.values()) {
- JsonNode biome = biomes.get(enumBiome.toString());
- if (biome != null) {
- biomeToIdMap.put(enumBiome.ordinal(), biome.intValue());
- } else {
- GeyserConnector.getInstance().getLogger().debug("No biome mapping found for " + enumBiome.toString() +
- ", defaulting to 0");
- biomeToIdMap.put(enumBiome.ordinal(), 0);
- }
- }
- }
-
- @Override
- public int getBlockAt(GeyserSession session, int x, int y, int z) {
- Player bukkitPlayer;
- if ((bukkitPlayer = Bukkit.getPlayer(session.getPlayerEntity().getUsername())) == null) {
- return BlockTranslator.JAVA_AIR_ID;
- }
- World world = bukkitPlayer.getWorld();
- return BlockTranslator.getJavaIdBlockMap().getOrDefault(world.getBlockAt(x, y, z).getBlockData().getAsString(), BlockTranslator.JAVA_AIR_ID);
- }
-
- @Override
- public void getBlocksInSection(GeyserSession session, int x, int y, int z, Chunk chunk) {
- Player bukkitPlayer;
- if ((bukkitPlayer = Bukkit.getPlayer(session.getPlayerEntity().getUsername())) == null) {
- return;
- }
- World world = bukkitPlayer.getWorld();
- for (int blockY = 0; blockY < 16; blockY++) { // Cache-friendly iteration order
- for (int blockZ = 0; blockZ < 16; blockZ++) {
- for (int blockX = 0; blockX < 16; blockX++) {
- Block block = world.getBlockAt((x << 4) + blockX, (y << 4) + blockY, (z << 4) + blockZ);
- int id = BlockTranslator.getJavaIdBlockMap().getOrDefault(block.getBlockData().getAsString(), BlockTranslator.JAVA_AIR_ID);
- chunk.set(blockX, blockY, blockZ, id);
- }
- }
- }
- }
-
- @Override
- public boolean hasMoreBlockDataThanChunkCache() {
- return true;
- }
-
- @Override
- @SuppressWarnings("deprecation")
- public int[] getBiomeDataAt(GeyserSession session, int x, int z) {
- if (session.getPlayerEntity() == null) {
- return new int[1024];
- }
- int[] biomeData = new int[1024];
- World world = Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld();
- int chunkX = x << 4;
- int chunkZ = z << 4;
- int chunkXmax = chunkX + 16;
- int chunkZmax = chunkZ + 16;
- // 3D biomes didn't exist until 1.15
- if (use3dBiomes) {
- for (int localX = chunkX; localX < chunkXmax; localX += 4) {
- for (int localY = 0; localY < 255; localY += + 4) {
- for (int localZ = chunkZ; localZ < chunkZmax; localZ += 4) {
- // Index is based on wiki.vg's index requirements
- final int i = ((localY >> 2) & 63) << 4 | ((localZ >> 2) & 3) << 2 | ((localX >> 2) & 3);
- biomeData[i] = biomeToIdMap.getOrDefault(world.getBiome(localX, localY, localZ).ordinal(), 0);
- }
- }
- }
- } else {
- // Looks like the same code, but we're not checking the Y coordinate here
- for (int localX = chunkX; localX < chunkXmax; localX += 4) {
- for (int localY = 0; localY < 255; localY += + 4) {
- for (int localZ = chunkZ; localZ < chunkZmax; localZ += 4) {
- // Index is based on wiki.vg's index requirements
- final int i = ((localY >> 2) & 63) << 4 | ((localZ >> 2) & 3) << 2 | ((localX >> 2) & 3);
- biomeData[i] = biomeToIdMap.getOrDefault(world.getBiome(localX, localZ).ordinal(), 0);
- }
- }
- }
- }
- return biomeData;
- }
-
- public Boolean getGameRuleBool(GeyserSession session, GameRule gameRule) {
- return Boolean.parseBoolean(Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getGameRuleValue(gameRule.getJavaID()));
- }
-
- @Override
- public int getGameRuleInt(GeyserSession session, GameRule gameRule) {
- return Integer.parseInt(Bukkit.getPlayer(session.getPlayerEntity().getUsername()).getWorld().getGameRuleValue(gameRule.getJavaID()));
- }
-
- @Override
- public boolean hasPermission(GeyserSession session, String permission) {
- return Bukkit.getPlayer(session.getPlayerEntity().getUsername()).hasPermission(permission);
- }
-
- /**
- * This must be set to true if we are pre-1.13, and {@link BlockData#getAsString() does not exist}.
- *
- * This should be set to true if we are post-1.13 but before the latest version, and we should convert the old block state id
- * to the current one.
- *
- * @return whether there is a difference between client block state and server block state that requires extra processing
- */
- public boolean isLegacy() {
- return false;
- }
-}
diff --git a/bootstrap/spigot/src/main/resources/biomes.json b/bootstrap/spigot/src/main/resources/biomes.json
deleted file mode 100644
index 56520e91..00000000
--- a/bootstrap/spigot/src/main/resources/biomes.json
+++ /dev/null
@@ -1,155 +0,0 @@
-{
- "MUTATED_ICE_FLATS" : 140,
- "MUTATED_TAIGA" : 133,
- "SAVANNA_PLATEAU_MOUNTAINS" : 164,
- "DEEP_WARM_OCEAN" : 47,
- "REDWOOD_TAIGA_HILLS" : 33,
- "THE_VOID" : 127,
- "COLD_TAIGA_MOUNTAINS" : 158,
- "BAMBOO_JUNGLE_HILLS" : 169,
- "MOUNTAINS" : 3,
- "MESA_PLATEAU" : 39,
- "SNOWY_TAIGA_HILLS" : 31,
- "DEEP_FROZEN_OCEAN" : 50,
- "EXTREME_HILLS" : 3,
- "BIRCH_FOREST_MOUNTAINS" : 155,
- "FOREST" : 4,
- "BIRCH_FOREST" : 27,
- "SNOWY_TUNDRA" : 12,
- "ICE_SPIKES" : 140,
- "FROZEN_OCEAN" : 10,
- "WARPED_FOREST" : 172,
- "WOODED_BADLANDS_PLATEAU" : 38,
- "BADLANDS_PLATEAU" : 39,
- "ICE_PLAINS_SPIKES" : 140,
- "MEGA_TAIGA" : 32,
- "MUTATED_SAVANNA_ROCK" : 164,
- "SAVANNA_PLATEAU" : 36,
- "DARK_FOREST_HILLS" : 157,
- "END_MIDLANDS" : 41,
- "SHATTERED_SAVANNA_PLATEAU" : 164,
- "SAVANNA" : 35,
- "MUSHROOM_ISLAND_SHORE" : 15,
- "SWAMP" : 6,
- "ICE_MOUNTAINS" : 13,
- "BEACH" : 16,
- "MUTATED_MESA_CLEAR_ROCK" : 167,
- "END_HIGHLANDS" : 42,
- "COLD_BEACH" : 26,
- "JUNGLE" : 21,
- "MUTATED_TAIGA_COLD" : 158,
- "TALL_BIRCH_HILLS" : 156,
- "DARK_FOREST" : 29,
- "WOODED_HILLS" : 18,
- "HELL" : 8,
- "MUTATED_REDWOOD_TAIGA" : 160,
- "MESA_PLATEAU_FOREST" : 38,
- "MUSHROOM_ISLAND" : 14,
- "BADLANDS" : 37,
- "END_BARRENS" : 43,
- "MUTATED_EXTREME_HILLS_WITH_TREES" : 162,
- "MUTATED_JUNGLE_EDGE" : 151,
- "MODIFIED_BADLANDS_PLATEAU" : 167,
- "ROOFED_FOREST_MOUNTAINS" : 157,
- "SOUL_SAND_VALLEY" : 170,
- "DESERT" : 2,
- "MUTATED_PLAINS" : 129,
- "MUTATED_BIRCH_FOREST" : 155,
- "WOODED_MOUNTAINS" : 34,
- "TAIGA_HILLS" : 19,
- "BAMBOO_JUNGLE" : 168,
- "SWAMPLAND_MOUNTAINS" : 134,
- "DESERT_MOUNTAINS" : 130,
- "REDWOOD_TAIGA" : 32,
- "MUSHROOM_FIELDS" : 14,
- "GIANT_TREE_TAIGA_HILLS" : 33,
- "PLAINS" : 1,
- "JUNGLE_EDGE" : 23,
- "SAVANNA_MOUNTAINS" : 163,
- "DEEP_COLD_OCEAN" : 49,
- "DESERT_LAKES" : 130,
- "MOUNTAIN_EDGE" : 20,
- "SNOWY_MOUNTAINS" : 13,
- "MESA_PLATEAU_MOUNTAINS" : 167,
- "JUNGLE_MOUNTAINS" : 149,
- "SMALLER_EXTREME_HILLS" : 20,
- "MESA_PLATEAU_FOREST_MOUNTAINS" : 166,
- "NETHER_WASTES" : 8,
- "BIRCH_FOREST_HILLS_MOUNTAINS" : 156,
- "MUTATED_JUNGLE" : 149,
- "WARM_OCEAN" : 44,
- "DEEP_OCEAN" : 24,
- "STONE_BEACH" : 25,
- "MODIFIED_JUNGLE" : 149,
- "MUTATED_SAVANNA" : 163,
- "TAIGA_COLD_HILLS" : 31,
- "OCEAN" : 0,
- "SMALL_END_ISLANDS" : 40,
- "MUSHROOM_FIELD_SHORE" : 15,
- "GRAVELLY_MOUNTAINS" : 131,
- "FROZEN_RIVER" : 11,
- "TAIGA_COLD" : 30,
- "BASALT_DELTAS" : 173,
- "EXTREME_HILLS_WITH_TREES" : 34,
- "MEGA_TAIGA_HILLS" : 33,
- "MUTATED_FOREST" : 132,
- "MUTATED_BIRCH_FOREST_HILLS" : 156,
- "SKY" : 9,
- "LUKEWARM_OCEAN" : 45,
- "EXTREME_HILLS_MOUNTAINS" : 131,
- "COLD_TAIGA_HILLS" : 31,
- "THE_END" : 9,
- "SUNFLOWER_PLAINS" : 129,
- "SAVANNA_ROCK" : 36,
- "ERODED_BADLANDS" : 165,
- "STONE_SHORE" : 25,
- "EXTREME_HILLS_PLUS_MOUNTAINS" : 162,
- "CRIMSON_FOREST" : 171,
- "VOID" : 127,
- "SNOWY_TAIGA" : 30,
- "SNOWY_TAIGA_MOUNTAINS" : 158,
- "FLOWER_FOREST" : 132,
- "COLD_OCEAN" : 46,
- "BEACHES" : 16,
- "MESA" : 37,
- "MUSHROOM_SHORE" : 15,
- "MESA_CLEAR_ROCK" : 39,
- "NETHER" : 8,
- "ICE_PLAINS" : 12,
- "SHATTERED_SAVANNA" : 163,
- "ROOFED_FOREST" : 29,
- "GIANT_SPRUCE_TAIGA_HILLS" : 161,
- "SNOWY_BEACH" : 26,
- "MESA_BRYCE" : 165,
- "JUNGLE_EDGE_MOUNTAINS" : 151,
- "MUTATED_DESERT" : 130,
- "MODIFIED_GRAVELLY_MOUNTAINS" : 158,
- "MEGA_SPRUCE_TAIGA" : 160,
- "TAIGA_MOUNTAINS" : 133,
- "SMALL_MOUNTAINS" : 20,
- "EXTREME_HILLS_PLUS" : 34,
- "GIANT_SPRUCE_TAIGA" : 160,
- "FOREST_HILLS" : 18,
- "DESERT_HILLS" : 17,
- "MUTATED_REDWOOD_TAIGA_HILLS" : 161,
- "MEGA_SPRUCE_TAIGA_HILLS" : 161,
- "RIVER" : 7,
- "GIANT_TREE_TAIGA" : 32,
- "SWAMPLAND" : 6,
- "JUNGLE_HILLS" : 22,
- "TALL_BIRCH_FOREST" : 155,
- "DEEP_LUKEWARM_OCEAN" : 48,
- "MESA_ROCK" : 38,
- "SWAMP_HILLS" : 134,
- "MODIFIED_WOODED_BADLANDS_PLATEAU" : 166,
- "MODIFIED_JUNGLE_EDGE" : 151,
- "BIRCH_FOREST_HILLS" : 28,
- "COLD_TAIGA" : 30,
- "TAIGA" : 5,
- "MUTATED_MESA_ROCK" : 166,
- "MUTATED_SWAMPLAND" : 134,
- "ICE_FLATS" : 12,
- "MUTATED_ROOFED_FOREST" : 157,
- "MUTATED_MESA" : 165,
- "MUTATED_EXTREME_HILLS" : 131
-}
diff --git a/bootstrap/sponge/pom.xml b/bootstrap/sponge/pom.xml
index 97c4ac8a..c9abbe3e 100644
--- a/bootstrap/sponge/pom.xml
+++ b/bootstrap/sponge/pom.xml
@@ -6,15 +6,15 @@
org.geysermcbootstrap-parent
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOT
+ ../bootstrap-sponge
-
org.geysermcconnector
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOTcompile
@@ -69,26 +69,6 @@
it.unimi.dsi.fastutilorg.geysermc.platform.sponge.shaded.fastutil
-
- org.reflections
- org.geysermc.platform.sponge.shaded.reflections
-
-
- com.google.common
- org.geysermc.platform.sponge.shaded.google.common
-
-
- com.google.guava
- org.geysermc.platform.sponge.shaded.google.guava
-
-
- org.dom4j
- org.geysermc.platform.sponge.shaded.dom4j
-
-
- net.kyori
- org.geysermc.platform.sponge.shaded.kyori
-
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java
index 5a0496ca..fc148470 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,13 +25,216 @@
package org.geysermc.platform.sponge;
-import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
+import lombok.AllArgsConstructor;
+import ninja.leaping.configurate.ConfigurationNode;
+
+import org.geysermc.connector.GeyserConfiguration;
+
+import java.io.File;
import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.*;
+
+public class GeyserSpongeConfiguration implements GeyserConfiguration {
+
+ private File dataFolder;
+ private ConfigurationNode node;
+
+ private SpongeBedrockConfiguration bedrockConfig;
+ private SpongeRemoteConfiguration remoteConfig;
+ private SpongeMetricsInfo metricsInfo;
+
+ private Map userAuthInfo = new HashMap<>();
+
+ public GeyserSpongeConfiguration(File dataFolder, ConfigurationNode node) {
+ this.dataFolder = dataFolder;
+ this.node = node;
+
+ this.bedrockConfig = new SpongeBedrockConfiguration(node.getNode("bedrock"));
+ this.remoteConfig = new SpongeRemoteConfiguration(node.getNode("remote"));
+ this.metricsInfo = new SpongeMetricsInfo();
+
+ if (node.getNode("userAuths").getValue() == null)
+ return;
+
+ List userAuths = new ArrayList(((LinkedHashMap)node.getNode("userAuths").getValue()).keySet());
+ for (String key : userAuths) {
+ userAuthInfo.put(key, new SpongeUserAuthenticationInfo(key));
+ }
+ }
-public final class GeyserSpongeConfiguration extends GeyserJacksonConfiguration {
@Override
- public Path getFloodgateKeyPath() {
- return null; //floodgate isn't available for Sponge
+ public SpongeBedrockConfiguration getBedrock() {
+ return bedrockConfig;
+ }
+
+ @Override
+ public SpongeRemoteConfiguration getRemote() {
+ return remoteConfig;
+ }
+
+ @Override
+ public Map getUserAuths() {
+ return userAuthInfo;
+ }
+
+ @Override
+ public boolean isCommandSuggestions() {
+ return node.getNode("command-suggestions").getBoolean(true);
+ }
+
+ @Override
+ public boolean isPassthroughMotd() {
+ return node.getNode("passthrough-motd").getBoolean(false);
+ }
+
+ @Override
+ public boolean isPassthroughPlayerCounts() {
+ return node.getNode("passthrough-player-counts").getBoolean(false);
+ }
+
+ @Override
+ public boolean isLegacyPingPassthrough() {
+ return node.getNode("legacy-ping-passthrough").getBoolean(false);
+ }
+
+ @Override
+ public int getPingPassthroughInterval() {
+ return node.getNode("ping-passthrough-interval").getInt(3);
+ }
+
+ @Override
+ public int getMaxPlayers() {
+ return node.getNode("max-players").getInt(100);
+ }
+
+ @Override
+ public boolean isDebugMode() {
+ return node.getNode("debug-mode").getBoolean(false);
+ }
+
+ @Override
+ public int getGeneralThreadPool() {
+ return node.getNode("genereal-thread-pool").getInt(32);
+ }
+
+ @Override
+ public boolean isAllowThirdPartyCapes() {
+ return node.getNode("allow-third-party-capes").getBoolean(true);
+ }
+
+ @Override
+ public boolean isAllowThirdPartyEars() {
+ return node.getNode("allow-third-party-ears").getBoolean(false);
+ }
+
+ @Override
+ public String getDefaultLocale() {
+ return node.getNode("default-locale").getString("en_us");
+ }
+
+ @Override
+ public Path getFloodgateKeyFile() {
+ return Paths.get(dataFolder.toString(), node.getNode("floodgate-key-file").getString("public-key.pem"));
+ }
+
+ @Override
+ public boolean isCacheChunks() {
+ return node.getNode("cache-chunks").getBoolean(false);
+ }
+
+ @Override
+ public boolean isAboveBedrockNetherBuilding() {
+ return node.getNode("above-bedrock-nether-building").getBoolean(false);
+ }
+
+ @Override
+ public SpongeMetricsInfo getMetrics() {
+ return metricsInfo;
+ }
+
+ @AllArgsConstructor
+ public class SpongeBedrockConfiguration implements IBedrockConfiguration {
+
+ private ConfigurationNode node;
+
+ @Override
+ public String getAddress() {
+ return node.getNode("address").getString("0.0.0.0");
+ }
+
+ @Override
+ public int getPort() {
+ return node.getNode("port").getInt(19132);
+ }
+
+ @Override
+ public String getMotd1() {
+ return node.getNode("motd1").getString("GeyserMC");
+ }
+
+ @Override
+ public String getMotd2() {
+ return node.getNode("motd2").getString("GeyserMC");
+ }
+ }
+
+ @AllArgsConstructor
+ public class SpongeRemoteConfiguration implements IRemoteConfiguration {
+
+ private ConfigurationNode node;
+
+ @Override
+ public String getAddress() {
+ return node.getNode("address").getString("127.0.0.1");
+ }
+
+ @Override
+ public int getPort() {
+ return node.getNode("port").getInt(25565);
+ }
+
+ @Override
+ public String getAuthType() {
+ return node.getNode("auth-type").getString("online");
+ }
+ }
+
+ public class SpongeUserAuthenticationInfo implements IUserAuthenticationInfo {
+
+ private String key;
+
+ public SpongeUserAuthenticationInfo(String key) {
+ this.key = key;
+ }
+
+ @Override
+ public String getEmail() {
+ return node.getNode("userAuths").getNode(key).getNode("email").getString();
+ }
+
+ @Override
+ public String getPassword() {
+ return node.getNode("userAuths").getNode(key).getNode("password").getString();
+ }
+ }
+
+ public class SpongeMetricsInfo implements IMetricsInfo {
+
+ @Override
+ public boolean isEnabled() {
+ return node.getNode("metrics").getNode("enabled").getBoolean(true);
+ }
+
+ @Override
+ public String getUniqueId() {
+ return node.getNode("metrics").getNode("uuid").getString("generateduuid");
+ }
+ }
+
+ @Override
+ public int getConfigVersion() {
+ return node.getNode("config-version").getInt(0);
}
}
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeDumpInfo.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeDumpInfo.java
deleted file mode 100644
index d36ba311..00000000
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeDumpInfo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.sponge;
-
-import lombok.Getter;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
-import org.spongepowered.api.Platform;
-import org.spongepowered.api.Sponge;
-import org.spongepowered.api.plugin.PluginContainer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Getter
-public class GeyserSpongeDumpInfo extends BootstrapDumpInfo {
-
- private String platformName;
- private String platformVersion;
- private boolean onlineMode;
- private String serverIP;
- private int serverPort;
- private List plugins;
-
- GeyserSpongeDumpInfo() {
- super();
- PluginContainer container = Sponge.getPlatform().getContainer(Platform.Component.IMPLEMENTATION);
- this.platformName = container.getName();
- this.platformVersion = container.getVersion().get();
- this.onlineMode = Sponge.getServer().getOnlineMode();
- this.serverIP = Sponge.getServer().getBoundAddress().get().getHostString();
- this.serverPort = Sponge.getServer().getBoundAddress().get().getPort();
- this.plugins = new ArrayList<>();
-
- for (PluginContainer plugin : Sponge.getPluginManager().getPlugins()) {
- String pluginClass = plugin.getInstance().map((pl) -> pl.getClass().getName()).orElse("unknown");
- this.plugins.add(new PluginInfo(true, plugin.getName(), plugin.getVersion().get(), pluginClass, plugin.getAuthors()));
- }
- }
-}
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeLogger.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeLogger.java
index b560c4dd..fb7cb54b 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeLogger.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeLogger.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,16 +26,15 @@
package org.geysermc.platform.sponge;
import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
+
import org.geysermc.connector.GeyserLogger;
import org.slf4j.Logger;
@AllArgsConstructor
public class GeyserSpongeLogger implements GeyserLogger {
- private final Logger logger;
- @Getter @Setter
- private boolean debug;
+
+ private Logger logger;
+ private boolean debugMode;
@Override
public void severe(String message) {
@@ -69,8 +68,12 @@ public class GeyserSpongeLogger implements GeyserLogger {
@Override
public void debug(String message) {
- if (debug) {
+ if (debugMode)
info(message);
- }
+ }
+
+ @Override
+ public void setDebug(boolean debugMode) {
+ this.debugMode = debugMode;
}
}
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeMain.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeMain.java
index f6643a5c..11b9583f 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeMain.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongeMain.java
@@ -1,31 +1,32 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.platform.sponge;
-import org.geysermc.connector.common.main.IGeyserMain;
+import org.geysermc.common.main.IGeyserMain;
public class GeyserSpongeMain extends IGeyserMain {
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePingPassthrough.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePingPassthrough.java
index 8d63fca6..31b6dc7f 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePingPassthrough.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePingPassthrough.java
@@ -1,32 +1,32 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.platform.sponge;
-import com.github.steveice10.mc.protocol.MinecraftConstants;
-import org.geysermc.connector.common.ping.GeyserPingInfo;
+import org.geysermc.common.ping.GeyserPingInfo;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import org.spongepowered.api.MinecraftVersion;
import org.spongepowered.api.Sponge;
@@ -35,65 +35,55 @@ import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.cause.EventContext;
import org.spongepowered.api.event.server.ClientPingServerEvent;
import org.spongepowered.api.network.status.StatusClient;
-import org.spongepowered.api.profile.GameProfile;
import java.lang.reflect.Method;
+import java.net.Inet4Address;
import java.net.InetSocketAddress;
import java.util.Optional;
public class GeyserSpongePingPassthrough implements IGeyserPingPassthrough {
+ private static final GeyserStatusClient STATUS_CLIENT = new GeyserStatusClient();
private static final Cause CAUSE = Cause.of(EventContext.empty(), Sponge.getServer());
private static Method SpongeStatusResponse_create;
@SuppressWarnings({"unchecked", "rawtypes"})
@Override
- public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
+ public GeyserPingInfo getPingInformation() {
// come on Sponge, this is in commons, why not expose it :(
ClientPingServerEvent event;
try {
- if (SpongeStatusResponse_create == null) {
+ if(SpongeStatusResponse_create == null) {
Class SpongeStatusResponse = Class.forName("org.spongepowered.common.network.status.SpongeStatusResponse");
Class MinecraftServer = Class.forName("net.minecraft.server.MinecraftServer");
SpongeStatusResponse_create = SpongeStatusResponse.getDeclaredMethod("create", MinecraftServer);
}
Object response = SpongeStatusResponse_create.invoke(null, Sponge.getServer());
- event = SpongeEventFactory.createClientPingServerEvent(CAUSE, new GeyserStatusClient(inetSocketAddress), (ClientPingServerEvent.Response) response);
+ event = SpongeEventFactory.createClientPingServerEvent(CAUSE, STATUS_CLIENT, (ClientPingServerEvent.Response) response);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
Sponge.getEventManager().post(event);
GeyserPingInfo geyserPingInfo = new GeyserPingInfo(
event.getResponse().getDescription().toPlain(),
- new GeyserPingInfo.Players(
- event.getResponse().getPlayers().orElseThrow(IllegalStateException::new).getMax(),
- event.getResponse().getPlayers().orElseThrow(IllegalStateException::new).getOnline()
- ),
- new GeyserPingInfo.Version(
- event.getResponse().getVersion().getName(),
- MinecraftConstants.PROTOCOL_VERSION) // thanks for also not exposing this sponge
- );
- event.getResponse().getPlayers().get().getProfiles().stream()
- .map(GameProfile::getName)
- .map(op -> op.orElseThrow(IllegalStateException::new))
- .forEach(geyserPingInfo.getPlayerList()::add);
+ event.getResponse().getPlayers().orElseThrow(IllegalStateException::new).getOnline(),
+ event.getResponse().getPlayers().orElseThrow(IllegalStateException::new).getMax());
+ event.getResponse().getPlayers().get().getProfiles().forEach(player -> {
+ geyserPingInfo.addPlayer(player.getName().orElseThrow(IllegalStateException::new));
+ });
return geyserPingInfo;
}
@SuppressWarnings("NullableProblems")
private static class GeyserStatusClient implements StatusClient {
- private final InetSocketAddress remote;
-
- public GeyserStatusClient(InetSocketAddress remote) {
- this.remote = remote;
- }
+ private static final InetSocketAddress FAKE_REMOTE = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 69);
@Override
public InetSocketAddress getAddress() {
- return this.remote;
+ return FAKE_REMOTE;
}
@Override
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java
index 5b8bf54b..d226add7 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/GeyserSpongePlugin.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,16 +26,17 @@
package org.geysermc.platform.sponge;
import com.google.inject.Inject;
+import ninja.leaping.configurate.ConfigurationNode;
+import ninja.leaping.configurate.loader.ConfigurationLoader;
+import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
import org.geysermc.common.PlatformType;
+import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager;
-import org.geysermc.connector.configuration.GeyserConfiguration;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import org.geysermc.connector.utils.FileUtils;
-import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.platform.sponge.command.GeyserSpongeCommandExecutor;
import org.geysermc.platform.sponge.command.GeyserSpongeCommandManager;
import org.slf4j.Logger;
@@ -49,7 +50,6 @@ import org.spongepowered.api.plugin.Plugin;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.nio.file.Path;
import java.util.UUID;
@Plugin(id = "geyser", name = GeyserConnector.NAME + "-Sponge", version = GeyserConnector.VERSION, url = "https://geysermc.org", authors = "GeyserMC")
@@ -78,31 +78,34 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
try {
configFile = FileUtils.fileOrCopiedFromResource(new File(configDir, "config.yml"), "config.yml", (file) -> file.replaceAll("generateduuid", UUID.randomUUID().toString()));
} catch (IOException ex) {
- logger.warn(LanguageUtils.getLocaleStringLog("geyser.config.failed"));
+ logger.warn("Failed to copy config.yml from jar path!");
ex.printStackTrace();
}
+ ConfigurationLoader loader = YAMLConfigurationLoader.builder().setPath(configFile.toPath()).build();
+ ConfigurationNode config;
try {
- this.geyserConfig = FileUtils.loadConfig(configFile, GeyserSpongeConfiguration.class);
+ config = loader.load();
+ this.geyserConfig = new GeyserSpongeConfiguration(configDir, config);
} catch (IOException ex) {
- logger.warn(LanguageUtils.getLocaleStringLog("geyser.config.failed"));
+ logger.warn("Failed to load config.yml!");
ex.printStackTrace();
return;
}
+ ConfigurationNode serverIP = config.getNode("remote").getNode("address");
+ ConfigurationNode serverPort = config.getNode("remote").getNode("port");
+
if (Sponge.getServer().getBoundAddress().isPresent()) {
InetSocketAddress javaAddr = Sponge.getServer().getBoundAddress().get();
// Don't change the ip if its listening on all interfaces
// By default this should be 127.0.0.1 but may need to be changed in some circumstances
- if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
- this.geyserConfig.setAutoconfiguredRemote(true);
- geyserConfig.getRemote().setPort(javaAddr.getPort());
+ if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
+ serverIP.setValue("127.0.0.1");
}
- }
- if (geyserConfig.getBedrock().isCloneRemotePort()){
- geyserConfig.getBedrock().setPort(geyserConfig.getRemote().getPort());
+ serverPort.setValue(javaAddr.getPort());
}
this.geyserLogger = new GeyserSpongeLogger(logger, geyserConfig.isDebugMode());
@@ -144,11 +147,6 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
return geyserSpongePingPassthrough;
}
- @Override
- public Path getConfigFolder() {
- return configDir.toPath();
- }
-
@Listener
public void onServerStart(GameStartedServerEvent event) {
onEnable();
@@ -158,9 +156,4 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
public void onServerStop(GameStoppedEvent event) {
onDisable();
}
-
- @Override
- public BootstrapDumpInfo getDumpInfo() {
- return new GeyserSpongeDumpInfo();
- }
}
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/GeyserSpongeCommandExecutor.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/GeyserSpongeCommandExecutor.java
index 938d1992..91cb59b0 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/GeyserSpongeCommandExecutor.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/GeyserSpongeCommandExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,10 +26,10 @@
package org.geysermc.platform.sponge.command;
import lombok.AllArgsConstructor;
+
+import org.geysermc.common.ChatColor;
import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.common.ChatColor;
import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.utils.LanguageUtils;
import org.spongepowered.api.command.CommandCallable;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
@@ -55,14 +55,13 @@ public class GeyserSpongeCommandExecutor implements CommandCallable {
if (args.length > 0) {
if (getCommand(args[0]) != null) {
if (!source.hasPermission(getCommand(args[0]).getPermission())) {
- // Not ideal to use log here but we dont get a session
- source.sendMessage(Text.of(ChatColor.RED + LanguageUtils.getLocaleStringLog("geyser.bootstrap.command.permission_fail")));
+ source.sendMessage(Text.of(ChatColor.RED + "You do not have permission to execute this command!"));
return CommandResult.success();
}
- getCommand(args[0]).execute(new SpongeCommandSender(source), args.length > 1 ? Arrays.copyOfRange(args, 1, args.length) : new String[0]);
+ getCommand(args[0]).execute(new SpongeCommandSender(source), args);
}
} else {
- getCommand("help").execute(new SpongeCommandSender(source), new String[0]);
+ getCommand("help").execute(new SpongeCommandSender(source), args);
}
return CommandResult.success();
}
@@ -70,7 +69,7 @@ public class GeyserSpongeCommandExecutor implements CommandCallable {
@Override
public List getSuggestions(CommandSource source, String arguments, @Nullable Location targetPosition) throws CommandException {
if (arguments.split(" ").length == 1) {
- return connector.getCommandManager().getCommandNames();
+ return Arrays.asList("?", "help", "reload", "shutdown", "stop");
}
return new ArrayList<>();
}
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/GeyserSpongeCommandManager.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/GeyserSpongeCommandManager.java
index 1f6eaa69..c36511a4 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/GeyserSpongeCommandManager.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/GeyserSpongeCommandManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/SpongeCommandSender.java b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/SpongeCommandSender.java
index 4616e400..a309a26f 100644
--- a/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/SpongeCommandSender.java
+++ b/bootstrap/sponge/src/main/java/org/geysermc/platform/sponge/command/SpongeCommandSender.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/bootstrap/standalone/pom.xml b/bootstrap/standalone/pom.xml
index 831239f6..770ca100 100644
--- a/bootstrap/standalone/pom.xml
+++ b/bootstrap/standalone/pom.xml
@@ -6,21 +6,21 @@
org.geysermcbootstrap-parent
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOT
+ ../bootstrap-standalone
-
org.geysermcconnector
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOTcompilenet.minecrellterminalconsoleappender
- 1.2.0
+ 1.1.1org.apache.logging.log4j
@@ -63,7 +63,7 @@
org.apache.logging.log4jlog4j-core
- 2.13.2
+ 2.13.1org.apache.logging.log4j
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java
index 5aa15635..aa0d2392 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneBootstrap.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,39 +25,19 @@
package org.geysermc.platform.standalone;
-import com.fasterxml.jackson.databind.BeanDescription;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.introspect.AnnotatedField;
-import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
-import lombok.Getter;
-import net.minecrell.terminalconsole.TerminalConsoleAppender;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.core.appender.ConsoleAppender;
import org.geysermc.common.PlatformType;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.bootstrap.GeyserBootstrap;
-import org.geysermc.connector.command.CommandManager;
-import org.geysermc.connector.configuration.GeyserConfiguration;
-import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
+import org.geysermc.connector.GeyserConfiguration;
+import org.geysermc.connector.bootstrap.GeyserBootstrap;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.command.CommandManager;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import org.geysermc.connector.utils.FileUtils;
-import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.platform.standalone.command.GeyserCommandManager;
-import org.geysermc.platform.standalone.gui.GeyserStandaloneGUI;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.Method;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.text.MessageFormat;
-import java.util.*;
-import java.util.stream.Collectors;
+import java.util.UUID;
public class GeyserStandaloneBootstrap implements GeyserBootstrap {
@@ -66,180 +46,33 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
private GeyserStandaloneLogger geyserLogger;
private IGeyserPingPassthrough geyserPingPassthrough;
- private GeyserStandaloneGUI gui;
-
- @Getter
- private boolean useGui = System.console() == null && !isHeadless();
- private String configFilename = "config.yml";
-
private GeyserConnector connector;
- private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
-
- private static final Map argsConfigKeys = new HashMap<>();
-
public static void main(String[] args) {
- GeyserStandaloneBootstrap bootstrap = new GeyserStandaloneBootstrap();
- // Set defaults
- boolean useGuiOpts = bootstrap.useGui;
- String configFilenameOpt = bootstrap.configFilename;
-
- List availableProperties = getPOJOForClass(GeyserJacksonConfiguration.class);
-
- for (int i = 0; i < args.length; i++) {
- // By default, standalone Geyser will check if it should open the GUI based on if the GUI is null
- // Optionally, you can force the use of a GUI or no GUI by specifying args
- // Allows gui and nogui without options, for backwards compatibility
- String arg = args[i];
- switch (arg) {
- case "--gui":
- case "gui":
- useGuiOpts = true;
- break;
- case "--nogui":
- case "nogui":
- useGuiOpts = false;
- break;
- case "--config":
- case "-c":
- if (i >= args.length - 1) {
- System.err.println(MessageFormat.format(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.config_not_specified"), "-c"));
- return;
- }
- configFilenameOpt = args[i+1]; i++;
- System.out.println(MessageFormat.format(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.config_specified"), configFilenameOpt));
- break;
- case "--help":
- case "-h":
- System.out.println(MessageFormat.format(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.usage"), "[java -jar] Geyser.jar [opts]"));
- System.out.println(" " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.options"));
- System.out.println(" -c, --config [file] " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.config"));
- System.out.println(" -h, --help " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.help"));
- System.out.println(" --gui, --nogui " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.gui"));
- return;
- default:
- // We have likely added a config option argument
- if (arg.startsWith("--")) {
- // Split the argument by an =
- String[] argParts = arg.substring(2).split("=");
- if (argParts.length == 2) {
- // Split the config key by . to allow for nested options
- String[] configKeyParts = argParts[0].split("\\.");
-
- // Loop the possible config options to check the passed key is valid
- boolean found = false;
- for (BeanPropertyDefinition property : availableProperties) {
- if (configKeyParts[0].equals(property.getName())) {
- if (configKeyParts.length > 1) {
- // Loop sub-section options to check the passed key is valid
- for (BeanPropertyDefinition subProperty : getPOJOForClass(property.getRawPrimaryType())) {
- if (configKeyParts[1].equals(subProperty.getName())) {
- found = true;
- break;
- }
- }
- } else {
- found = true;
- }
-
- break;
- }
- }
-
- // Add the found key to the stored list for later usage
- if (found) {
- argsConfigKeys.put(argParts[0], argParts[1]);
- break;
- }
- }
- }
-
- System.err.println(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.unrecognised", arg));
- return;
- }
- }
- bootstrap.onEnable(useGuiOpts, configFilenameOpt);
- }
-
- public void onEnable(boolean useGui, String configFilename) {
- this.configFilename = configFilename;
- this.useGui = useGui;
- this.onEnable();
- }
-
- public void onEnable(boolean useGui) {
- this.useGui = useGui;
- this.onEnable();
+ new GeyserStandaloneBootstrap().onEnable();
}
@Override
public void onEnable() {
- Logger logger = (Logger) LogManager.getRootLogger();
- for (Appender appender : logger.getAppenders().values()) {
- // Remove the appender that is not in use
- // Prevents multiple appenders/double logging and removes harmless errors
- if ((useGui && appender instanceof TerminalConsoleAppender) || (!useGui && appender instanceof ConsoleAppender)) {
- logger.removeAppender(appender);
- }
- }
- if (useGui && gui == null) {
- gui = new GeyserStandaloneGUI();
- gui.redirectSystemStreams();
- gui.startUpdateThread();
- }
-
geyserLogger = new GeyserStandaloneLogger();
LoopbackUtil.checkLoopback(geyserLogger);
try {
- File configFile = FileUtils.fileOrCopiedFromResource(new File(configFilename), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
+ File configFile = FileUtils.fileOrCopiedFromResource("config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
geyserConfig = FileUtils.loadConfig(configFile, GeyserStandaloneConfiguration.class);
-
- handleArgsConfigOptions();
-
- if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
- geyserConfig.setAutoconfiguredRemote(true); // Doesn't really need to be set but /shrug
- geyserConfig.getRemote().setAddress("127.0.0.1");
- }
} catch (IOException ex) {
- geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
- if (gui == null) {
- System.exit(1);
- } else {
- // Leave the process running so the GUI is still visible
- return;
- }
+ geyserLogger.severe("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
+ System.exit(0);
}
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
connector = GeyserConnector.start(PlatformType.STANDALONE, this);
geyserCommandManager = new GeyserCommandManager(connector);
- if (gui != null) {
- gui.setupInterface(geyserLogger, geyserCommandManager);
- }
-
geyserPingPassthrough = GeyserLegacyPingPassthrough.init(connector);
- if (!useGui) {
- geyserLogger.start(); // Throws an error otherwise
- }
- }
-
- /**
- * Check using {@link java.awt.GraphicsEnvironment} that we are a headless client
- *
- * @return If the current environment is headless
- */
- private boolean isHeadless() {
- try {
- Class> graphicsEnv = Class.forName("java.awt.GraphicsEnvironment");
- Method isHeadless = graphicsEnv.getDeclaredMethod("isHeadless");
- return (boolean) isHeadless.invoke(null);
- } catch (Exception ignore) { }
-
- return true;
+ geyserLogger.start();
}
@Override
@@ -267,110 +100,4 @@ public class GeyserStandaloneBootstrap implements GeyserBootstrap {
public IGeyserPingPassthrough getGeyserPingPassthrough() {
return geyserPingPassthrough;
}
-
- @Override
- public Path getConfigFolder() {
- // Return the current working directory
- return Paths.get(System.getProperty("user.dir"));
- }
-
- @Override
- public BootstrapDumpInfo getDumpInfo() {
- return new GeyserStandaloneDumpInfo(this);
- }
-
- /**
- * Get the {@link BeanPropertyDefinition}s for the given class
- *
- * @param clazz The class to get the definitions for
- * @return A list of {@link BeanPropertyDefinition} for the given class
- */
- public static List getPOJOForClass(Class> clazz) {
- JavaType javaType = OBJECT_MAPPER.getTypeFactory().constructType(clazz);
-
- // Introspect the given type
- BeanDescription beanDescription = OBJECT_MAPPER.getSerializationConfig().introspect(javaType);
-
- // Find properties
- List properties = beanDescription.findProperties();
-
- // Get the ignored properties
- Set ignoredProperties = OBJECT_MAPPER.getSerializationConfig().getAnnotationIntrospector()
- .findPropertyIgnorals(beanDescription.getClassInfo()).getIgnored();
-
- // Filter properties removing the ignored ones
- return properties.stream()
- .filter(property -> !ignoredProperties.contains(property.getName()))
- .collect(Collectors.toList());
- }
-
- /**
- * Set a POJO property value on an object
- *
- * @param property The {@link BeanPropertyDefinition} to set
- * @param parentObject The object to alter
- * @param value The new value of the property
- */
- private static void setConfigOption(BeanPropertyDefinition property, Object parentObject, Object value) {
- Object parsedValue = value;
-
- // Change the values type if needed
- if (int.class.equals(property.getRawPrimaryType())) {
- parsedValue = Integer.valueOf((String) parsedValue);
- } else if (boolean.class.equals(property.getRawPrimaryType())) {
- parsedValue = Boolean.valueOf((String) parsedValue);
- }
-
- // Force the value to be set
- AnnotatedField field = property.getField();
- field.fixAccess(true);
- field.setValue(parentObject, parsedValue);
- }
-
- /**
- * Update the loaded {@link GeyserStandaloneConfiguration} with any values passed in the command line arguments
- */
- private void handleArgsConfigOptions() {
- // Get the available properties from the class
- List availableProperties = getPOJOForClass(GeyserJacksonConfiguration.class);
-
- for (Map.Entry configKey : argsConfigKeys.entrySet()) {
- String[] configKeyParts = configKey.getKey().split("\\.");
-
- // Loop over the properties looking for any matches against the stored one from the argument
- for (BeanPropertyDefinition property : availableProperties) {
- if (configKeyParts[0].equals(property.getName())) {
- if (configKeyParts.length > 1) {
- // Loop through the sub property if the first part matches
- for (BeanPropertyDefinition subProperty : getPOJOForClass(property.getRawPrimaryType())) {
- if (configKeyParts[1].equals(subProperty.getName())) {
- geyserLogger.info(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.set_config_option", configKey.getKey(), configKey.getValue()));
-
- // Set the sub property value on the config
- try {
- Object subConfig = property.getGetter().callOn(geyserConfig);
- setConfigOption(subProperty, subConfig, configKey.getValue());
- } catch (Exception e) {
- geyserLogger.error("Failed to set config option: " + property.getFullName());
- }
-
- break;
- }
- }
- } else {
- geyserLogger.info(LanguageUtils.getLocaleStringLog("geyser.bootstrap.args.set_config_option", configKey.getKey(), configKey.getValue()));
-
- // Set the property value on the config
- try {
- setConfigOption(property, geyserConfig, configKey.getValue());
- } catch (Exception e) {
- geyserLogger.error("Failed to set config option: " + property.getFullName());
- }
- }
-
- break;
- }
- }
- }
- }
}
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneConfiguration.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneConfiguration.java
index fad05d9d..bd029204 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneConfiguration.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,17 +26,111 @@
package org.geysermc.platform.standalone;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
import lombok.Getter;
-import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Map;
-@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
-public final class GeyserStandaloneConfiguration extends GeyserJacksonConfiguration {
+@Getter
+public class GeyserStandaloneConfiguration implements GeyserConfiguration {
+
+ private BedrockConfiguration bedrock;
+ private RemoteConfiguration remote;
+
+ @JsonProperty("floodgate-key-file")
+ private String floodgateKeyFile;
+
+ private Map userAuths;
+
+ @JsonProperty("command-suggestions")
+ private boolean isCommandSuggestions;
+
+ @JsonProperty("passthrough-motd")
+ private boolean isPassthroughMotd;
+
+ @JsonProperty("passthrough-player-counts")
+ private boolean isPassthroughPlayerCounts;
+
+ @JsonProperty("legacy-ping-passthrough")
+ private boolean isLegacyPingPassthrough;
+
+ @JsonProperty("ping-passthrough-interval")
+ private int pingPassthroughInterval;
+
+ @JsonProperty("max-players")
+ private int maxPlayers;
+
+ @JsonProperty("debug-mode")
+ private boolean debugMode;
+
+ @JsonProperty("general-thread-pool")
+ private int generalThreadPool;
+
+ @JsonProperty("allow-third-party-capes")
+ private boolean allowThirdPartyCapes;
+
+ @JsonProperty("allow-third-party-ears")
+ private boolean allowThirdPartyEars;
+
+ @JsonProperty("default-locale")
+ private String defaultLocale;
+
+ @JsonProperty("cache-chunks")
+ private boolean cacheChunks;
+
+ @JsonProperty("above-bedrock-nether-building")
+ private boolean isAboveBedrockNetherBuilding;
+
+ private MetricsInfo metrics;
+
@Override
- public Path getFloodgateKeyPath() {
- return Paths.get(getFloodgateKeyFile());
+ public Path getFloodgateKeyFile() {
+ return Paths.get(floodgateKeyFile);
}
+
+ @Getter
+ public static class BedrockConfiguration implements IBedrockConfiguration {
+
+ private String address;
+ private int port;
+
+ private String motd1;
+ private String motd2;
+ }
+
+ @Getter
+ public static class RemoteConfiguration implements IRemoteConfiguration {
+
+ private String address;
+ private int port;
+
+ private String motd1;
+ private String motd2;
+
+ @JsonProperty("auth-type")
+ private String authType;
+ }
+
+ @Getter
+ public static class UserAuthenticationInfo implements IUserAuthenticationInfo {
+ private String email;
+ private String password;
+ }
+
+ @Getter
+ public static class MetricsInfo implements IMetricsInfo {
+
+ private boolean enabled;
+
+ @JsonProperty("uuid")
+ private String uniqueId;
+ }
+
+ @JsonProperty("config-version")
+ private int configVersion;
}
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneDumpInfo.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneDumpInfo.java
deleted file mode 100644
index 2577ce03..00000000
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneDumpInfo.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.standalone;
-
-import lombok.Getter;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
-
-@Getter
-public class GeyserStandaloneDumpInfo extends BootstrapDumpInfo {
-
- private boolean isGui;
-
- GeyserStandaloneDumpInfo(GeyserStandaloneBootstrap bootstrap) {
- super();
- this.isGui = bootstrap.isUseGui();
- }
-}
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneLogger.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneLogger.java
index 64e5b5e8..ffb252b2 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneLogger.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/GeyserStandaloneLogger.java
@@ -1,41 +1,43 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.platform.standalone;
import lombok.extern.log4j.Log4j2;
+
import net.minecrell.terminalconsole.SimpleTerminalConsole;
-import org.apache.logging.log4j.Level;
+
import org.apache.logging.log4j.core.config.Configurator;
+import org.geysermc.common.ChatColor;
import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.GeyserLogger;
import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.common.ChatColor;
@Log4j2
-public class GeyserStandaloneLogger extends SimpleTerminalConsole implements GeyserLogger, CommandSender {
+public class GeyserStandaloneLogger extends SimpleTerminalConsole implements org.geysermc.connector.GeyserLogger, CommandSender {
+
private boolean colored = true;
@Override
@@ -80,7 +82,7 @@ public class GeyserStandaloneLogger extends SimpleTerminalConsole implements Gey
@Override
public void info(String message) {
- log.info(printConsole(ChatColor.RESET + ChatColor.BOLD + message, colored));
+ log.info(printConsole(ChatColor.WHITE + message, colored));
}
@Override
@@ -94,11 +96,7 @@ public class GeyserStandaloneLogger extends SimpleTerminalConsole implements Gey
@Override
public void setDebug(boolean debug) {
- Configurator.setLevel(log.getName(), debug ? Level.DEBUG : Level.INFO);
- }
-
- public boolean isDebug() {
- return log.isDebugEnabled();
+ Configurator.setLevel(log.getName(), debug ? org.apache.logging.log4j.Level.DEBUG : log.getLevel());
}
@Override
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/LoopbackUtil.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/LoopbackUtil.java
index 9c10234f..03c49705 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/LoopbackUtil.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/LoopbackUtil.java
@@ -1,38 +1,12 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
package org.geysermc.platform.standalone;
-import org.geysermc.connector.common.ChatColor;
-import org.geysermc.connector.utils.LanguageUtils;
-
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Paths;
+import org.geysermc.common.ChatColor;
+
public class LoopbackUtil {
private static final String checkExemption = "powershell -Command \"CheckNetIsolation LoopbackExempt -s\""; // Java's Exec feature runs as CMD, NetIsolation is only accessible from PowerShell.
private static final String loopbackCommand = "powershell -Command \"CheckNetIsolation LoopbackExempt -a -n='Microsoft.MinecraftUWP_8wekyb3d8bbwe'\"";
@@ -57,12 +31,12 @@ public class LoopbackUtil {
Files.write(Paths.get(System.getenv("temp") + "/loopback_minecraft.bat"), loopbackCommand.getBytes(), new OpenOption[0]);
process = Runtime.getRuntime().exec(startScript);
- geyserLogger.info(ChatColor.AQUA + LanguageUtils.getLocaleStringLog("geyser.bootstrap.loopback.added"));
+ geyserLogger.info(ChatColor.AQUA + "Added loopback exemption to Windows!");
}
} catch (Exception e) {
e.printStackTrace();
- geyserLogger.error(LanguageUtils.getLocaleStringLog("geyser.bootstrap.loopback.failed"));
+ geyserLogger.error("Couldn't auto add loopback exemption to Windows!");
}
}
}
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/command/GeyserCommandManager.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/command/GeyserCommandManager.java
index 85b2798f..41bf61c1 100644
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/command/GeyserCommandManager.java
+++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/command/GeyserCommandManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/ANSIColor.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/ANSIColor.java
deleted file mode 100644
index eb64a969..00000000
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/ANSIColor.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.standalone.gui;
-
-import lombok.Getter;
-
-import java.awt.*;
-import java.util.regex.Pattern;
-
-public enum ANSIColor {
- // Normal colors
- BLACK("(0;)?30(0;)?m", Color.getHSBColor(0.000f, 0.000f, 0.000f)),
- RED("(0;)?31(0;)?m", Color.getHSBColor(0.000f, 1.000f, 0.502f)),
- GREEN("(0;)?32(0;)?m", Color.getHSBColor(0.333f, 1.000f, 0.502f)),
- YELLOW("(0;)?33(0;)?m", Color.getHSBColor(0.167f, 1.000f, 0.502f)),
- BLUE("(0;)?34(0;)?m", Color.getHSBColor(0.667f, 1.000f, 0.502f)),
- MAGENTA("(0;)?35(0;)?m", Color.getHSBColor(0.833f, 1.000f, 0.502f)),
- CYAN("(0;)?36(0;)?m", Color.getHSBColor(0.500f, 1.000f, 0.502f)),
- WHITE("(0;)?37(0;)?m", Color.getHSBColor(0.000f, 0.000f, 0.753f)),
-
- // Bold colors
- B_BLACK("(1;30|30;1)m", Color.getHSBColor(0.000f, 0.000f, 0.502f)),
- B_RED("(1;31|31;1)m", Color.getHSBColor(0.000f, 1.000f, 1.000f)),
- B_GREEN("(1;32|32;1)m", Color.getHSBColor(0.333f, 1.000f, 1.000f)),
- B_YELLOW("(1;33|33;1)m", Color.getHSBColor(0.167f, 1.000f, 1.000f)),
- B_BLUE("(1;34|34;1)m", Color.getHSBColor(0.667f, 1.000f, 1.000f)),
- B_MAGENTA("(1;35|35;1)m", Color.getHSBColor(0.833f, 1.000f, 1.000f)),
- B_CYAN("(1;36|36;1)m", Color.getHSBColor(0.500f, 1.000f, 1.000f)),
- B_WHITE("(1;37|37;1)m", Color.getHSBColor(0.000f, 0.000f, 1.000f)),
-
- RESET("0m", Color.getHSBColor(0.000f, 0.000f, 1.000f));
-
- private static final ANSIColor[] VALUES = values();
- private static final String PREFIX = Pattern.quote("\u001B[");
-
- private final String ANSICode;
-
- @Getter
- private final Color color;
-
- ANSIColor(String ANSICode, Color color) {
- this.ANSICode = ANSICode;
- this.color = color;
- }
-
- public static ANSIColor fromANSI(String code) {
- for (ANSIColor value : VALUES) {
- if (code.matches(PREFIX + value.ANSICode)) {
- return value;
- }
- }
-
- return B_WHITE;
- }
-}
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/ColorPane.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/ColorPane.java
deleted file mode 100644
index 10309395..00000000
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/ColorPane.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.standalone.gui;
-
-import javax.swing.*;
-import javax.swing.text.*;
-import java.awt.*;
-
-/**
- * This class was based on this code: https://stackoverflow.com/a/6899478/5299903
- */
-public class ColorPane extends JTextPane {
- private static Color colorCurrent = ANSIColor.RESET.getColor();
- private String remaining = "";
-
- /**
- * Append the given string in the given color to the text pane
- * @param c The color
- * @param s The text
- */
- private void append(Color c, String s) {
- StyleContext sc = StyleContext.getDefaultStyleContext();
- AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
- int len = getDocument().getLength();
-
- try {
- getDocument().insertString(len, s, aset);
- } catch (BadLocationException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Extract the ANSI color codes from the string and add each part to the text pane
- *
- * @param s The text to parse
- */
- public void appendANSI(String s) { // convert ANSI color codes first
- int aPos = 0; // current char position in addString
- int aIndex = 0; // index of next Escape sequence
- int mIndex = 0; // index of "m" terminating Escape sequence
- String tmpString = "";
- boolean stillSearching = true; // true until no more Escape sequences
- String addString = remaining + s;
- remaining = "";
-
- if (addString.length() > 0) {
- aIndex = addString.indexOf("\u001B"); // find first escape
- if (aIndex == -1) { // no escape/color change in this string, so just send it with current color
- append(colorCurrent, addString);
- return;
- }
- // otherwise There is an escape character in the string, so we must process it
-
- if (aIndex > 0) { // Escape is not first char, so send text up to first escape
- tmpString = addString.substring(0, aIndex);
- append(colorCurrent, tmpString);
- aPos = aIndex; // aPos is now at the beginning of the first escape sequence
- }
-
-
- // while there's text in the input buffer
- stillSearching = true;
- while (stillSearching) {
- mIndex = addString.indexOf("m", aPos); // find the end of the escape sequence
- if (mIndex < 0) { // the buffer ends halfway through the ansi string!
- remaining = addString.substring(aPos, addString.length());
- stillSearching = false;
- continue;
- } else {
- tmpString = addString.substring(aPos, mIndex+1);
- colorCurrent = ANSIColor.fromANSI(tmpString).getColor();
- }
- aPos = mIndex + 1;
- // now we have the color, send text that is in that color (up to next escape)
-
- aIndex = addString.indexOf("\u001B", aPos);
-
- if (aIndex == -1) { // if that was the last sequence of the input, send remaining text
- tmpString = addString.substring(aPos, addString.length());
- append(colorCurrent, tmpString);
- stillSearching = false;
- continue; // jump out of loop early, as the whole string has been sent now
- }
-
- // there is another escape sequence, so send part of the string and prepare for the next
- tmpString = addString.substring(aPos, aIndex);
- aPos = aIndex;
- append(colorCurrent, tmpString);
-
- }
- }
- }
-}
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GeyserStandaloneGUI.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GeyserStandaloneGUI.java
deleted file mode 100644
index fb6a46f9..00000000
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GeyserStandaloneGUI.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.standalone.gui;
-
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.utils.LanguageUtils;
-import org.geysermc.platform.standalone.GeyserStandaloneLogger;
-import org.geysermc.platform.standalone.command.GeyserCommandManager;
-
-import javax.swing.*;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.text.Document;
-import java.awt.*;
-import java.awt.event.*;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-public class GeyserStandaloneGUI {
-
- private static final DefaultTableModel playerTableModel = new DefaultTableModel();
- private static final List ramValues = new ArrayList<>();
-
- private static final ColorPane consolePane = new ColorPane();
- private static final GraphPanel ramGraph = new GraphPanel();
- private static final JTable playerTable = new JTable(playerTableModel);
- private static final int originalFontSize = consolePane.getFont().getSize();
-
- private static final long MEGABYTE = 1024L * 1024L;
-
- private final JMenu commandsMenu;
- private final JMenu optionsMenu;
-
- public GeyserStandaloneGUI() {
- // Create the frame and setup basic settings
- JFrame frame = new JFrame(LanguageUtils.getLocaleStringLog("geyser.gui.title"));
- frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- frame.setSize(800, 400);
- frame.setMinimumSize(frame.getSize());
-
- // Remove Java UI look
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception ignored) { }
-
- // Show a confirm dialog on close
- frame.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosing(WindowEvent we)
- {
- String[] buttons = {LanguageUtils.getLocaleStringLog("geyser.gui.exit.confirm"), LanguageUtils.getLocaleStringLog("geyser.gui.exit.deny")};
- int result = JOptionPane.showOptionDialog(frame, LanguageUtils.getLocaleStringLog("geyser.gui.exit.message"), frame.getTitle(), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null, buttons, buttons[1]);
- if (result == JOptionPane.YES_OPTION) {
- System.exit(0);
- }
- }
- });
-
- Container cp = frame.getContentPane();
-
- // Fetch and set the icon for the frame
- URL image = getClass().getClassLoader().getResource("icon.png");
- if (image != null) {
- ImageIcon icon = new ImageIcon(image);
- frame.setIconImage(icon.getImage());
- }
-
- // Setup the split pane and event listeners
- JSplitPane splitPane = new JSplitPane();
- splitPane.setDividerLocation(600);
- splitPane.addPropertyChangeListener("dividerLocation", e -> splitPaneLimit((JSplitPane)e.getSource()));
- splitPane.addComponentListener(new ComponentAdapter() {
- public void componentResized(ComponentEvent e) {
- splitPaneLimit((JSplitPane)e.getSource());
- }
- });
-
- cp.add(splitPane, BorderLayout.CENTER);
-
- // Set the background and disable input for the text pane
- consolePane.setBackground(Color.BLACK);
- consolePane.setEditable(false);
-
- // Wrap the text pane in a scroll pane and add it to the form
- JScrollPane consoleScrollPane = new JScrollPane(consolePane);
- //cp.add(consoleScrollPane, BorderLayout.CENTER);
- splitPane.setLeftComponent(consoleScrollPane);
-
- // Create a new menu bar for the top of the frame
- JMenuBar menuBar = new JMenuBar();
-
- // Create 'File'
- JMenu fileMenu = new JMenu(LanguageUtils.getLocaleStringLog("geyser.gui.menu.file"));
- fileMenu.setMnemonic(KeyEvent.VK_F);
- menuBar.add(fileMenu);
-
- // 'Open Geyser folder' button
- JMenuItem openButton = new JMenuItem(LanguageUtils.getLocaleStringLog("geyser.gui.menu.file.open_folder"), KeyEvent.VK_O);
- openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
- openButton.addActionListener(e -> {
- try {
- Desktop.getDesktop().open(new File("./"));
- } catch (IOException ignored) { }
- });
- fileMenu.add(openButton);
-
- fileMenu.addSeparator();
-
- // 'Exit' button
- JMenuItem exitButton = new JMenuItem(LanguageUtils.getLocaleStringLog("geyser.gui.menu.file.exit"), KeyEvent.VK_X);
- exitButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));
- exitButton.addActionListener(e -> System.exit(0));
- fileMenu.add(exitButton);
-
- // Create 'Commands'
- commandsMenu = new JMenu(LanguageUtils.getLocaleStringLog("geyser.gui.menu.commands"));
- commandsMenu.setMnemonic(KeyEvent.VK_C);
- menuBar.add(commandsMenu);
-
- // Create 'View'
- JMenu viewMenu = new JMenu(LanguageUtils.getLocaleStringLog("geyser.gui.menu.view"));
- viewMenu.setMnemonic(KeyEvent.VK_V);
- menuBar.add(viewMenu);
-
- // 'Zoom in' button
- JMenuItem zoomInButton = new JMenuItem(LanguageUtils.getLocaleStringLog("geyser.gui.menu.view.zoom_in"));
- zoomInButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_DOWN_MASK));
- zoomInButton.addActionListener(e -> consolePane.setFont(new Font(consolePane.getFont().getName(), consolePane.getFont().getStyle(), consolePane.getFont().getSize() + 1)));
- viewMenu.add(zoomInButton);
-
- // 'Zoom in' button
- JMenuItem zoomOutButton = new JMenuItem(LanguageUtils.getLocaleStringLog("geyser.gui.menu.view.zoom_out"));
- zoomOutButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK));
- zoomOutButton.addActionListener(e -> consolePane.setFont(new Font(consolePane.getFont().getName(), consolePane.getFont().getStyle(), consolePane.getFont().getSize() - 1)));
- viewMenu.add(zoomOutButton);
-
- // 'Reset Zoom' button
- JMenuItem resetZoomButton = new JMenuItem(LanguageUtils.getLocaleStringLog("geyser.gui.menu.view.reset_zoom"));
- resetZoomButton.addActionListener(e -> consolePane.setFont(new Font(consolePane.getFont().getName(), consolePane.getFont().getStyle(), originalFontSize)));
- viewMenu.add(resetZoomButton);
-
- // create 'Options'
- optionsMenu = new JMenu(LanguageUtils.getLocaleStringLog("geyser.gui.menu.options"));
- viewMenu.setMnemonic(KeyEvent.VK_O);
- menuBar.add(optionsMenu);
-
- // Set the frames menu bar
- frame.setJMenuBar(menuBar);
-
- JPanel rightPane = new JPanel();
- rightPane.setLayout(new CardLayout(5, 5));
- //cp.add(rightPane, BorderLayout.EAST);
- splitPane.setRightComponent(rightPane);
-
- JPanel rightContentPane = new JPanel();
- rightContentPane.setLayout(new GridLayout(2, 1, 5, 5));
- rightPane.add(rightContentPane);
-
- // Set the ram graph to 0
- for (int i = 0; i < 10; i++) {
- ramValues.add(0);
- }
- ramGraph.setValues(ramValues);
- ramGraph.setXLabel(LanguageUtils.getLocaleStringLog("geyser.gui.graph.loading"));
- rightContentPane.add(ramGraph);
-
- playerTableModel.addColumn(LanguageUtils.getLocaleStringLog("geyser.gui.table.ip"));
- playerTableModel.addColumn(LanguageUtils.getLocaleStringLog("geyser.gui.table.username"));
-
- JScrollPane playerScrollPane = new JScrollPane(playerTable);
- rightContentPane.add(playerScrollPane);
-
- // This has to be done last
- frame.setVisible(true);
- }
-
- /**
- * Queue up an update to the text pane so we don't block the main thread
- *
- * @param text The text to append
- */
- private void updateTextPane(final String text) {
- SwingUtilities.invokeLater(() -> {
- consolePane.appendANSI(text);
- Document doc = consolePane.getDocument();
- consolePane.setCaretPosition(doc.getLength());
- });
- }
-
- /**
- * Redirect the default io streams to the text pane
- */
- public void redirectSystemStreams() {
- // Setup a new output stream to forward it to the text pane
- OutputStream out = new OutputStream() {
- @Override
- public void write(final int b) {
- updateTextPane(String.valueOf((char) b));
- }
-
- @Override
- public void write(byte[] b, int off, int len) {
- updateTextPane(new String(b, off, len));
- }
-
- @Override
- public void write(byte[] b) {
- write(b, 0, b.length);
- }
- };
-
- // Override the system output streams
- System.setOut(new PrintStream(out, true));
- System.setErr(new PrintStream(out, true));
-
- }
-
- /**
- * Add all the Geyser commands to the commands menu, and setup the debug mode toggle
- *
- * @param geyserStandaloneLogger The current logger
- * @param geyserCommandManager The commands manager
- */
- public void setupInterface(GeyserStandaloneLogger geyserStandaloneLogger, GeyserCommandManager geyserCommandManager) {
- commandsMenu.removeAll();
- optionsMenu.removeAll();
-
- for (Map.Entry command : geyserCommandManager.getCommands().entrySet()) {
- // Remove the offhand command and any alias commands to prevent duplicates in the list
- if (!command.getValue().isExecutableOnConsole() || command.getValue().getAliases().contains(command.getKey())) {
- continue;
- }
-
- // Create the button that runs the command
- boolean hasSubCommands = command.getValue().hasSubCommands();
- // Add an extra menu if there are more commands that can be run
- JMenuItem commandButton = hasSubCommands ? new JMenu(command.getValue().getName()) : new JMenuItem(command.getValue().getName());
- commandButton.getAccessibleContext().setAccessibleDescription(command.getValue().getDescription());
- if (!hasSubCommands) {
- commandButton.addActionListener(e -> command.getValue().execute(geyserStandaloneLogger, new String[]{ }));
- } else {
- // Add a submenu that's the same name as the menu can't be pressed
- JMenuItem otherCommandButton = new JMenuItem(command.getValue().getName());
- otherCommandButton.getAccessibleContext().setAccessibleDescription(command.getValue().getDescription());
- otherCommandButton.addActionListener(e -> command.getValue().execute(geyserStandaloneLogger, new String[]{ }));
- commandButton.add(otherCommandButton);
- // Add a menu option for all possible subcommands
- for (String subCommandName : command.getValue().getSubCommands()) {
- JMenuItem item = new JMenuItem(subCommandName);
- item.addActionListener(e -> command.getValue().execute(geyserStandaloneLogger, new String[]{subCommandName}));
- commandButton.add(item);
- }
- }
- commandsMenu.add(commandButton);
- }
-
- // 'Debug Mode' toggle
- JCheckBoxMenuItem debugMode = new JCheckBoxMenuItem(LanguageUtils.getLocaleStringLog("geyser.gui.menu.options.toggle_debug_mode"));
- debugMode.setSelected(geyserStandaloneLogger.isDebug());
- debugMode.addActionListener(e -> geyserStandaloneLogger.setDebug(!geyserStandaloneLogger.isDebug()));
- optionsMenu.add(debugMode);
- }
-
- /**
- * Start the thread to update the form information every 1s
- */
- public void startUpdateThread() {
- ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
-
- Runnable periodicTask = () -> {
- if (GeyserConnector.getInstance() != null) {
- // Update player table
- playerTableModel.getDataVector().removeAllElements();
-
- for (GeyserSession player : GeyserConnector.getInstance().getPlayers()) {
- Vector row = new Vector<>();
- row.add(player.getSocketAddress().getHostName());
- row.add(player.getPlayerEntity().getUsername());
-
- playerTableModel.addRow(row);
- }
-
- playerTableModel.fireTableDataChanged();
- }
-
- // Update ram graph
- final long freeMemory = Runtime.getRuntime().freeMemory();
- final long totalMemory = Runtime.getRuntime().totalMemory();
- final int freePercent = (int)(freeMemory * 100.0 / totalMemory + 0.5);
- ramValues.add(100 - freePercent);
-
- ramGraph.setXLabel(LanguageUtils.getLocaleStringLog("geyser.gui.graph.usage", String.format("%,d", (totalMemory - freeMemory) / MEGABYTE), freePercent));
-
- // Trim the list
- int k = ramValues.size();
- if ( k > 10 )
- ramValues.subList(0, k - 10).clear();
-
- // Update the graph
- ramGraph.setValues(ramValues);
- };
-
- // SwingUtilities.invokeLater is called so we don't run into threading issues with the GUI
- executor.scheduleAtFixedRate(() -> SwingUtilities.invokeLater(periodicTask), 0, 1, TimeUnit.SECONDS);
- }
-
- /**
- * Make sure the JSplitPane divider is within a set of bounds
- *
- * @param splitPane The JSplitPane to check
- */
- private void splitPaneLimit(JSplitPane splitPane) {
- JRootPane frame = splitPane.getRootPane();
- int location = splitPane.getDividerLocation();
- if (location < frame.getWidth() - frame.getWidth() * 0.4f) {
- splitPane.setDividerLocation(Math.round(frame.getWidth() - frame.getWidth() * 0.4f));
- } else if (location > frame.getWidth() - 200) {
- splitPane.setDividerLocation(frame.getWidth() - 200);
- }
- }
-}
diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GraphPanel.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GraphPanel.java
deleted file mode 100644
index ebcc8f82..00000000
--- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/gui/GraphPanel.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.standalone.gui;
-
-import lombok.Setter;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * This has been modified to fit Geyser more but is based on
- * https://gist.github.com/roooodcastro/6325153#gistcomment-3107524
- */
-public final class GraphPanel extends JPanel {
- private final static int padding = 10;
- private final static int labelPadding = 25;
- private final static int pointWidth = 4;
- private final static int numberYDivisions = 10;
- private final static Color lineColor = new Color(44, 102, 230, 255);
- private final static Color pointColor = new Color(100, 100, 100, 255);
- private final static Color gridColor = new Color(200, 200, 200, 255);
- private static final Stroke graphStroke = new BasicStroke(2f);
- private List values = new ArrayList<>(10);
-
- @Setter
- private String xLabel = "";
-
- public GraphPanel() {
- setPreferredSize(new Dimension(200 - (padding * 2), 150 - (padding * 2)));
- }
-
- public void setValues(Collection newValues) {
- values.clear();
- addValues(newValues);
- }
-
- public void addValues(Collection newValues) {
- values.addAll(newValues);
- updateUI();
- }
-
- @Override
- protected void paintComponent(Graphics graphics) {
- super.paintComponent(graphics);
- if (!(graphics instanceof Graphics2D)) {
- graphics.drawString("Graphics is not Graphics2D, unable to render", 0, 0);
- return;
- }
- final Graphics2D g = (Graphics2D) graphics;
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
-
- final int length = values.size();
- final int width = getWidth();
- final int height = getHeight();
- final int maxScore = getMaxScore();
- final int minScore = getMinScore();
- final int scoreRange = maxScore - minScore;
-
- // draw white background
- g.setColor(Color.WHITE);
- g.fillRect(
- padding + labelPadding,
- padding,
- width - (2 * padding) - labelPadding,
- height - 2 * padding - labelPadding);
- g.setColor(Color.BLACK);
-
- final FontMetrics fontMetrics = g.getFontMetrics();
- final int fontHeight = fontMetrics.getHeight();
-
- // create hatch marks and grid lines for y axis.
- for (int i = 0; i < numberYDivisions + 1; i++) {
- final int x1 = padding + labelPadding;
- final int x2 = pointWidth + padding + labelPadding;
- final int y = height - ((i * (height - padding * 2 - labelPadding)) / numberYDivisions + padding + labelPadding);
- if (length > 0) {
- g.setColor(gridColor);
- g.drawLine(padding + labelPadding + 1 + pointWidth, y, width - padding, y);
-
- g.setColor(Color.BLACK);
- final int tickValue = (int) (minScore + ((scoreRange * i) / numberYDivisions));
- final String yLabel = tickValue + "";
- final int labelWidth = fontMetrics.stringWidth(yLabel);
- g.drawString(yLabel, x1 - labelWidth - 5, y + (fontHeight / 2) - 3);
- }
- g.drawLine(x1, y, x2, y);
- }
-
- // and for x axis
- if (length > 1) {
- for (int i = 0; i < length; i++) {
- final int x = i * (width - padding * 2 - labelPadding) / (length - 1) + padding + labelPadding;
- final int y1 = height - padding - labelPadding;
- final int y2 = y1 - pointWidth;
- if ((i % ((int) ((length / 20.0)) + 1)) == 0) {
- g.setColor(gridColor);
- g.drawLine(x, height - padding - labelPadding - 1 - pointWidth, x, padding);
-
- g.setColor(Color.BLACK);
-
- /*g.setColor(Color.BLACK);
- final String xLabel = i + "";
- final int labelWidth = fontMetrics.stringWidth(xLabel);
- g.drawString(xLabel, x - labelWidth / 2, y1 + fontHeight + 3);*/
- }
- g.drawLine(x, y1, x, y2);
- }
- }
-
- // create x and y axes
- g.drawLine(padding + labelPadding, height - padding - labelPadding, padding + labelPadding, padding);
- g.drawLine(padding + labelPadding, height - padding - labelPadding, width - padding, height - padding - labelPadding);
-
- g.setColor(Color.BLACK);
- final int labelWidth = fontMetrics.stringWidth(xLabel);
- final int labelX = ((padding + labelPadding) + (width - padding)) / 2;
- final int labelY = height - padding - labelPadding;
- g.drawString(xLabel, labelX - labelWidth / 2, labelY + fontHeight + 3);
-
- final Stroke oldStroke = g.getStroke();
- g.setColor(lineColor);
- g.setStroke(graphStroke);
-
- final double xScale = ((double) width - (2 * padding) - labelPadding) / (length - 1);
- final double yScale = ((double) height - 2 * padding - labelPadding) / scoreRange;
-
- final List graphPoints = new ArrayList<>(length);
- for (int i = 0; i < length; i++) {
- final int x1 = (int) (i * xScale + padding + labelPadding);
- final int y1 = (int) ((maxScore - values.get(i)) * yScale + padding);
- graphPoints.add(new Point(x1, y1));
- }
-
- for (int i = 0; i < graphPoints.size() - 1; i++) {
- final int x1 = graphPoints.get(i).x;
- final int y1 = graphPoints.get(i).y;
- final int x2 = graphPoints.get(i + 1).x;
- final int y2 = graphPoints.get(i + 1).y;
- g.drawLine(x1, y1, x2, y2);
- }
-
- boolean drawDots = width > (length * pointWidth);
- if (drawDots) {
- g.setStroke(oldStroke);
- g.setColor(pointColor);
- for (Point graphPoint : graphPoints) {
- final int x = graphPoint.x - pointWidth / 2;
- final int y = graphPoint.y - pointWidth / 2;
- g.fillOval(x, y, pointWidth, pointWidth);
- }
- }
- }
-
- private int getMinScore() {
- return 0;
- }
-
- private int getMaxScore() {
- return 100;
- }
-}
diff --git a/bootstrap/standalone/src/main/resources/icon.png b/bootstrap/standalone/src/main/resources/icon.png
deleted file mode 100644
index 4e6a38a7..00000000
Binary files a/bootstrap/standalone/src/main/resources/icon.png and /dev/null differ
diff --git a/bootstrap/standalone/src/main/resources/log4j2.xml b/bootstrap/standalone/src/main/resources/log4j2.xml
index 238a27da..95741540 100644
--- a/bootstrap/standalone/src/main/resources/log4j2.xml
+++ b/bootstrap/standalone/src/main/resources/log4j2.xml
@@ -1,12 +1,9 @@
-
+
-
-
-
@@ -17,7 +14,6 @@
-
diff --git a/bootstrap/velocity/pom.xml b/bootstrap/velocity/pom.xml
index 5c0824de..fb06767e 100644
--- a/bootstrap/velocity/pom.xml
+++ b/bootstrap/velocity/pom.xml
@@ -6,21 +6,21 @@
org.geysermcbootstrap-parent
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOT
+ ../bootstrap-velocity
-
org.geysermcconnector
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOTcompilecom.velocitypoweredvelocity-api
- 1.1.0
+ 1.0.0-SNAPSHOTprovided
@@ -57,34 +57,10 @@
-
- com.fasterxml.jackson
- org.geysermc.platform.velocity.shaded.jackson
- it.unimi.dsi.fastutilorg.geysermc.platform.velocity.shaded.fastutil
-
- org.reflections
- org.geysermc.platform.velocity.shaded.reflections
-
-
- com.google.common
- org.geysermc.platform.velocity.shaded.google.common
-
-
- com.google.guava
- org.geysermc.platform.velocity.shaded.google.guava
-
-
- org.dom4j
- org.geysermc.platform.velocity.shaded.dom4j
-
-
- net.kyori
- org.geysermc.platform.velocity.shaded.kyori
-
@@ -93,16 +69,7 @@
com.google.code.gson:*
-
- io.netty:netty-transport-native-epoll:*
- io.netty:netty-transport-native-unix-common:*
- io.netty:netty-transport-native-kqueue:*
- io.netty:netty-handler:*
- io.netty:netty-common:*
- io.netty:netty-buffer:*
- io.netty:netty-resolver:*
- io.netty:netty-transport:*
- io.netty:netty-codec:*
+ io.netty:*org.slf4j:*org.ow2.asm:*
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityConfiguration.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityConfiguration.java
index 53b87370..aef0edaa 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityConfiguration.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityConfiguration.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,26 +25,127 @@
package org.geysermc.platform.velocity;
-import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.velocitypowered.api.plugin.PluginContainer;
import com.velocitypowered.api.proxy.ProxyServer;
import lombok.Getter;
+import lombok.Setter;
import org.geysermc.connector.FloodgateKeyLoader;
-import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.Map;
+import java.util.Optional;
-@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
-public final class GeyserVelocityConfiguration extends GeyserJacksonConfiguration {
- @JsonIgnore
- private Path floodgateKeyPath;
+@Getter
+public class GeyserVelocityConfiguration implements GeyserConfiguration {
+
+ private BedrockConfiguration bedrock;
+ private RemoteConfiguration remote;
+
+ @JsonProperty("floodgate-key-file")
+ private String floodgateKeyFile;
+
+ private Map userAuths;
+
+ @JsonProperty("command-suggestions")
+ private boolean commandSuggestions;
+
+ @JsonProperty("passthrough-motd")
+ private boolean isPassthroughMotd;
+
+ @JsonProperty("passthrough-player-counts")
+ private boolean isPassthroughPlayerCounts;
+
+ @JsonProperty("legacy-ping-passthrough")
+ private boolean isLegacyPingPassthrough;
+
+ @JsonProperty("ping-passthrough-interval")
+ private int pingPassthroughInterval;
+
+ @JsonProperty("max-players")
+ private int maxPlayers;
+
+ @JsonProperty("debug-mode")
+ private boolean debugMode;
+
+ @JsonProperty("general-thread-pool")
+ private int generalThreadPool;
+
+ @JsonProperty("allow-third-party-capes")
+ private boolean allowThirdPartyCapes;
+
+ @JsonProperty("allow-third-party-ears")
+ private boolean allowThirdPartyEars;
+
+ @JsonProperty("default-locale")
+ private String defaultLocale;
+
+ @JsonProperty("cache-chunks")
+ private boolean cacheChunks;
+
+ @JsonProperty("above-bedrock-nether-building")
+ private boolean aboveBedrockNetherBuilding;
+
+ private MetricsInfo metrics;
+
+ private Path floodgateKey;
public void loadFloodgate(GeyserVelocityPlugin plugin, ProxyServer proxyServer, File dataFolder) {
- PluginContainer floodgate = proxyServer.getPluginManager().getPlugin("floodgate").orElse(null);
- floodgateKeyPath = FloodgateKeyLoader.getKeyPath(this, floodgate, Paths.get("plugins/floodgate/"), dataFolder.toPath(), plugin.getGeyserLogger());
+ Optional floodgate = proxyServer.getPluginManager().getPlugin("floodgate");
+ floodgate.ifPresent(it -> floodgateKey = FloodgateKeyLoader.getKey(plugin.getGeyserLogger(), this, Paths.get(dataFolder.toString(), floodgateKeyFile.isEmpty() ? floodgateKeyFile : "public-key.pem"), it, Paths.get("plugins/floodgate/")));
}
+
+ @Override
+ public Path getFloodgateKeyFile() {
+ return floodgateKey;
+ }
+
+ @Getter
+ public static class BedrockConfiguration implements IBedrockConfiguration {
+
+ private String address;
+ private int port;
+
+ private String motd1;
+ private String motd2;
+ }
+
+ @Getter
+ public static class RemoteConfiguration implements IRemoteConfiguration {
+
+ @Setter
+ private String address;
+
+ @Setter
+ private int port;
+
+ private String motd1;
+ private String motd2;
+
+ @JsonProperty("auth-type")
+ private String authType;
+ }
+
+ @Getter
+ public static class UserAuthenticationInfo implements IUserAuthenticationInfo {
+ private String email;
+ private String password;
+ }
+
+ @Getter
+ public static class MetricsInfo implements IMetricsInfo {
+
+ private boolean enabled;
+
+ @JsonProperty("uuid")
+ private String uniqueId;
+ }
+
+ @JsonProperty("config-version")
+ private int configVersion;
}
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityDumpInfo.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityDumpInfo.java
deleted file mode 100644
index 261e8fef..00000000
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityDumpInfo.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.platform.velocity;
-
-import com.velocitypowered.api.plugin.PluginContainer;
-import com.velocitypowered.api.proxy.ProxyServer;
-import lombok.Getter;
-import org.geysermc.connector.common.serializer.AsteriskSerializer;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@Getter
-public class GeyserVelocityDumpInfo extends BootstrapDumpInfo {
-
- private String platformName;
- private String platformVersion;
- private String platformVendor;
- private boolean onlineMode;
- private String serverIP;
- private int serverPort;
- private List plugins;
-
- GeyserVelocityDumpInfo(ProxyServer proxy) {
- super();
- this.platformName = proxy.getVersion().getName();
- this.platformVersion = proxy.getVersion().getVersion();
- this.platformVendor = proxy.getVersion().getVendor();
- this.onlineMode = proxy.getConfiguration().isOnlineMode();
- if (AsteriskSerializer.showSensitive || (proxy.getBoundAddress().getHostString().equals("") || proxy.getBoundAddress().getHostString().equals("0.0.0.0"))) {
- this.serverIP = proxy.getBoundAddress().getHostString();
- } else {
- this.serverIP = "***";
- }
- this.serverPort = proxy.getBoundAddress().getPort();
- this.plugins = new ArrayList<>();
-
- for (PluginContainer plugin : proxy.getPluginManager().getPlugins()) {
- String pluginClass = plugin.getInstance().map((pl) -> pl.getClass().getName()).orElse("unknown");
- this.plugins.add(new PluginInfo(true, plugin.getDescription().getName().get(), plugin.getDescription().getVersion().get(), pluginClass, plugin.getDescription().getAuthors()));
- }
- }
-}
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityLogger.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityLogger.java
index 729af50a..a935d786 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityLogger.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityLogger.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,16 +26,15 @@
package org.geysermc.platform.velocity;
import lombok.AllArgsConstructor;
-import lombok.Getter;
-import lombok.Setter;
+
import org.geysermc.connector.GeyserLogger;
import org.slf4j.Logger;
@AllArgsConstructor
public class GeyserVelocityLogger implements GeyserLogger {
- private final Logger logger;
- @Getter @Setter
- private boolean debug;
+
+ private Logger logger;
+ private boolean debugMode;
@Override
public void severe(String message) {
@@ -69,8 +68,12 @@ public class GeyserVelocityLogger implements GeyserLogger {
@Override
public void debug(String message) {
- if (debug) {
+ if (debugMode)
info(message);
- }
+ }
+
+ @Override
+ public void setDebug(boolean debugMode) {
+ this.debugMode = debugMode;
}
}
\ No newline at end of file
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityMain.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityMain.java
index 6b337ebb..73eaddf0 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityMain.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityMain.java
@@ -1,31 +1,32 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.platform.velocity;
-import org.geysermc.connector.common.main.IGeyserMain;
+import org.geysermc.common.main.IGeyserMain;
public class GeyserVelocityMain extends IGeyserMain {
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPingPassthrough.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPingPassthrough.java
index bab0e350..01be949b 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPingPassthrough.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPingPassthrough.java
@@ -1,26 +1,27 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.platform.velocity;
@@ -31,8 +32,9 @@ import com.velocitypowered.api.proxy.InboundConnection;
import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.ServerPing;
import lombok.AllArgsConstructor;
+import net.kyori.text.TextComponent;
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
-import org.geysermc.connector.common.ping.GeyserPingInfo;
+import org.geysermc.common.ping.GeyserPingInfo;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import java.net.Inet4Address;
@@ -43,44 +45,38 @@ import java.util.concurrent.ExecutionException;
@AllArgsConstructor
public class GeyserVelocityPingPassthrough implements IGeyserPingPassthrough {
+ private static final GeyserInboundConnection FAKE_INBOUND_CONNECTION = new GeyserInboundConnection();
+
private final ProxyServer server;
@Override
- public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) {
+ public GeyserPingInfo getPingInformation() {
ProxyPingEvent event;
try {
- event = server.getEventManager().fire(new ProxyPingEvent(new GeyserInboundConnection(inetSocketAddress), ServerPing.builder()
+ event = server.getEventManager().fire(new ProxyPingEvent(FAKE_INBOUND_CONNECTION, ServerPing.builder()
.description(server.getConfiguration().getMotdComponent()).onlinePlayers(server.getPlayerCount())
.maximumPlayers(server.getConfiguration().getShowMaxPlayers()).build())).get();
} catch (ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
}
GeyserPingInfo geyserPingInfo = new GeyserPingInfo(
- LegacyComponentSerializer.legacy().serialize(event.getPing().getDescription(), '§'),
- new GeyserPingInfo.Players(
- event.getPing().getPlayers().orElseThrow(IllegalStateException::new).getMax(),
- event.getPing().getPlayers().orElseThrow(IllegalStateException::new).getOnline()
- ),
- new GeyserPingInfo.Version(
- event.getPing().getVersion().getName(),
- event.getPing().getVersion().getProtocol()
- )
+ LegacyComponentSerializer.INSTANCE.serialize(event.getPing().getDescription(), '§'),
+ event.getPing().getPlayers().orElseThrow(IllegalStateException::new).getOnline(),
+ event.getPing().getPlayers().orElseThrow(IllegalStateException::new).getMax()
);
- event.getPing().getPlayers().get().getSample().stream().map(ServerPing.SamplePlayer::getName).forEach(geyserPingInfo.getPlayerList()::add);
+ event.getPing().getPlayers().get().getSample().forEach(player -> {
+ geyserPingInfo.addPlayer(player.getName());
+ });
return geyserPingInfo;
}
private static class GeyserInboundConnection implements InboundConnection {
- private final InetSocketAddress remote;
-
- public GeyserInboundConnection(InetSocketAddress remote) {
- this.remote = remote;
- }
+ private static final InetSocketAddress FAKE_REMOTE = new InetSocketAddress(Inet4Address.getLoopbackAddress(), 69);
@Override
public InetSocketAddress getRemoteAddress() {
- return this.remote;
+ return FAKE_REMOTE;
}
@Override
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java
index bcb388ca..e7b44da5 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/GeyserVelocityPlugin.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,22 +26,21 @@
package org.geysermc.platform.velocity;
import com.google.inject.Inject;
+
import com.velocitypowered.api.command.CommandManager;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
import com.velocitypowered.api.plugin.Plugin;
+
import com.velocitypowered.api.proxy.ProxyServer;
-import lombok.Getter;
import org.geysermc.common.PlatformType;
+import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
-import org.geysermc.connector.configuration.GeyserConfiguration;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
import org.geysermc.connector.ping.GeyserLegacyPingPassthrough;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
import org.geysermc.connector.utils.FileUtils;
-import org.geysermc.connector.utils.LanguageUtils;
import org.geysermc.platform.velocity.command.GeyserVelocityCommandExecutor;
import org.geysermc.platform.velocity.command.GeyserVelocityCommandManager;
import org.slf4j.Logger;
@@ -49,8 +48,6 @@ import org.slf4j.Logger;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.UUID;
@Plugin(id = "geyser", name = GeyserConnector.NAME + "-Velocity", version = GeyserConnector.VERSION, url = "https://geysermc.org", authors = "GeyserMC")
@@ -72,56 +69,39 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
private GeyserConnector connector;
- @Getter
- private final Path configFolder = Paths.get("plugins/" + GeyserConnector.NAME + "-Velocity/");
-
@Override
public void onEnable() {
+ File configDir = new File("plugins/" + GeyserConnector.NAME + "-Velocity/");
+
try {
- if (!configFolder.toFile().exists())
- //noinspection ResultOfMethodCallIgnored
- configFolder.toFile().mkdirs();
- File configFile = FileUtils.fileOrCopiedFromResource(configFolder.resolve("config.yml").toFile(), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
+ if (!configDir.exists())
+ configDir.mkdir();
+ File configFile = FileUtils.fileOrCopiedFromResource(new File(configDir, "config.yml"), "config.yml", (x) -> x.replaceAll("generateduuid", UUID.randomUUID().toString()));
this.geyserConfig = FileUtils.loadConfig(configFile, GeyserVelocityConfiguration.class);
} catch (IOException ex) {
- logger.warn(LanguageUtils.getLocaleStringLog("geyser.config.failed"), ex);
+ logger.warn("Failed to read/create config.yml! Make sure it's up to date and/or readable+writable!", ex);
ex.printStackTrace();
}
InetSocketAddress javaAddr = proxyServer.getBoundAddress();
- // By default this should be localhost but may need to be changed in some circumstances
- if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) {
- this.geyserConfig.setAutoconfiguredRemote(true);
- // Don't use localhost if not listening on all interfaces
- if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
- this.geyserConfig.getRemote().setAddress(javaAddr.getHostString());
- }
- geyserConfig.getRemote().setPort(javaAddr.getPort());
+ // Don't change the ip if its listening on all interfaces
+ // By default this should be 127.0.0.1 but may need to be changed in some circumstances
+ if (!javaAddr.getHostString().equals("0.0.0.0") && !javaAddr.getHostString().equals("")) {
+ geyserConfig.getRemote().setAddress(javaAddr.getHostString());
}
- if (geyserConfig.getBedrock().isCloneRemotePort()) {
- geyserConfig.getBedrock().setPort(javaAddr.getPort());
- }
+ geyserConfig.getRemote().setPort(javaAddr.getPort());
this.geyserLogger = new GeyserVelocityLogger(logger, geyserConfig.isDebugMode());
GeyserConfiguration.checkGeyserConfiguration(geyserConfig, geyserLogger);
- if (geyserConfig.getRemote().getAuthType().equals("floodgate") && !proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
- geyserLogger.severe(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.disabling"));
- return;
- } else if (geyserConfig.isAutoconfiguredRemote() && proxyServer.getPluginManager().getPlugin("floodgate").isPresent()) {
- // Floodgate installed means that the user wants Floodgate authentication
- geyserLogger.debug("Auto-setting to Floodgate authentication.");
- geyserConfig.getRemote().setAuthType("floodgate");
- }
-
- geyserConfig.loadFloodgate(this, proxyServer, configFolder.toFile());
+ geyserConfig.loadFloodgate(this, proxyServer, configDir);
this.connector = GeyserConnector.start(PlatformType.VELOCITY, this);
this.geyserCommandManager = new GeyserVelocityCommandManager(connector);
- this.commandManager.register("geyser", new GeyserVelocityCommandExecutor(connector));
+ this.commandManager.register(new GeyserVelocityCommandExecutor(connector), "geyser");
if (geyserConfig.isLegacyPingPassthrough()) {
this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(connector);
} else {
@@ -163,9 +143,4 @@ public class GeyserVelocityPlugin implements GeyserBootstrap {
public void onShutdown(ProxyShutdownEvent event) {
onDisable();
}
-
- @Override
- public BootstrapDumpInfo getDumpInfo() {
- return new GeyserVelocityDumpInfo(proxyServer);
- }
}
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/GeyserVelocityCommandExecutor.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/GeyserVelocityCommandExecutor.java
index 4aab73e5..940c5224 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/GeyserVelocityCommandExecutor.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/GeyserVelocityCommandExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,48 +25,37 @@
package org.geysermc.platform.velocity.command;
+import com.velocitypowered.api.command.Command;
import com.velocitypowered.api.command.CommandSource;
-import com.velocitypowered.api.command.SimpleCommand;
-import lombok.AllArgsConstructor;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.common.ChatColor;
-import org.geysermc.connector.utils.LanguageUtils;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import lombok.AllArgsConstructor;
+
+import net.kyori.text.TextComponent;
+
+import org.geysermc.common.ChatColor;
+import org.geysermc.connector.GeyserConnector;
+import org.geysermc.connector.command.GeyserCommand;
@AllArgsConstructor
-public class GeyserVelocityCommandExecutor implements SimpleCommand {
+public class GeyserVelocityCommandExecutor implements Command {
- private final GeyserConnector connector;
+ private GeyserConnector connector;
@Override
- public void execute(Invocation invocation) {
- if (invocation.arguments().length > 0) {
- if (getCommand(invocation.arguments()[0]) != null) {
- if (!invocation.source().hasPermission(getCommand(invocation.arguments()[0]).getPermission())) {
- CommandSender sender = new VelocityCommandSender(invocation.source());
- sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.bootstrap.command.permission_fail", sender.getLocale()));
+ public void execute(CommandSource source, String[] args) {
+ if (args.length > 0) {
+ if (getCommand(args[0]) != null) {
+ if (!source.hasPermission(getCommand(args[0]).getPermission())) {
+ source.sendMessage(TextComponent.of(ChatColor.RED + "You do not have permission to execute this command!"));
return;
}
- getCommand(invocation.arguments()[0]).execute(new VelocityCommandSender(invocation.source()), invocation.arguments().length > 1 ? Arrays.copyOfRange(invocation.arguments(), 1, invocation.arguments().length) : new String[0]);
+ getCommand(args[0]).execute(new VelocityCommandSender(source), args);
}
} else {
- getCommand("help").execute(new VelocityCommandSender(invocation.source()), new String[0]);
+ getCommand("help").execute(new VelocityCommandSender(source), args);
}
}
- @Override
- public List suggest(Invocation invocation) {
- if (invocation.arguments().length == 0) {
- return connector.getCommandManager().getCommandNames();
- }
- return new ArrayList<>();
- }
-
private GeyserCommand getCommand(String label) {
return connector.getCommandManager().getCommands().get(label);
}
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/GeyserVelocityCommandManager.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/GeyserVelocityCommandManager.java
index cbf8e3df..76655d0a 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/GeyserVelocityCommandManager.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/GeyserVelocityCommandManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/VelocityCommandSender.java b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/VelocityCommandSender.java
index 8f7d98b8..1b0d6f3e 100644
--- a/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/VelocityCommandSender.java
+++ b/bootstrap/velocity/src/main/java/org/geysermc/platform/velocity/command/VelocityCommandSender.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -28,21 +28,17 @@ package org.geysermc.platform.velocity.command;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.ConsoleCommandSource;
import com.velocitypowered.api.proxy.Player;
+
+import lombok.AllArgsConstructor;
+
import net.kyori.text.TextComponent;
+
import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.utils.LanguageUtils;
-
-import java.util.Locale;
+@AllArgsConstructor
public class VelocityCommandSender implements CommandSender {
- private final CommandSource handle;
-
- public VelocityCommandSender(CommandSource handle) {
- this.handle = handle;
- // Ensure even Java players' languages are loaded
- LanguageUtils.loadGeyserLocale(getLocale());
- }
+ private CommandSource handle;
@Override
public String getName() {
@@ -63,13 +59,4 @@ public class VelocityCommandSender implements CommandSender {
public boolean isConsole() {
return handle instanceof ConsoleCommandSource;
}
-
- @Override
- public String getLocale() {
- if (handle instanceof Player) {
- Locale locale = ((Player) handle).getPlayerSettings().getLocale();
- return LanguageUtils.formatLocale(locale.getLanguage() + "_" + locale.getCountry());
- }
- return LanguageUtils.getDefaultLocale();
- }
}
diff --git a/common/pom.xml b/common/pom.xml
index 32c4b187..0a47fbca 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -6,10 +6,11 @@
org.geysermcgeyser-parent
- 1.2.0-SNAPSHOT
+ parent
+ ../common
-
+ 1.0-SNAPSHOTcom.google.code.gson
diff --git a/common/src/main/java/org/geysermc/common/AuthType.java b/common/src/main/java/org/geysermc/common/AuthType.java
new file mode 100644
index 00000000..8edbc4d5
--- /dev/null
+++ b/common/src/main/java/org/geysermc/common/AuthType.java
@@ -0,0 +1,33 @@
+package org.geysermc.common;
+
+import lombok.Getter;
+
+@Getter
+public enum AuthType {
+ OFFLINE,
+ ONLINE,
+ FLOODGATE;
+
+ public static final AuthType[] VALUES = values();
+
+ public static AuthType getById(int id) {
+ return id < VALUES.length ? VALUES[id] : OFFLINE;
+ }
+
+ /**
+ * Convert the AuthType string (from config) to the enum, OFFLINE on fail
+ *
+ * @param name AuthType string
+ *
+ * @return The converted AuthType
+ */
+ public static AuthType getByName(String name) {
+ String upperCase = name.toUpperCase();
+ for (AuthType type : VALUES) {
+ if (type.name().equals(upperCase)) {
+ return type;
+ }
+ }
+ return OFFLINE;
+ }
+}
\ No newline at end of file
diff --git a/connector/src/main/java/org/geysermc/connector/common/ChatColor.java b/common/src/main/java/org/geysermc/common/ChatColor.java
similarity index 97%
rename from connector/src/main/java/org/geysermc/connector/common/ChatColor.java
rename to common/src/main/java/org/geysermc/common/ChatColor.java
index 946be39c..8868b063 100644
--- a/connector/src/main/java/org/geysermc/connector/common/ChatColor.java
+++ b/common/src/main/java/org/geysermc/common/ChatColor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -23,7 +23,7 @@
* @link https://github.com/GeyserMC/Geyser
*/
-package org.geysermc.connector.common;
+package org.geysermc.common;
public class ChatColor {
diff --git a/common/src/main/java/org/geysermc/common/PlatformType.java b/common/src/main/java/org/geysermc/common/PlatformType.java
index a1096f34..fa6f57fd 100644
--- a/common/src/main/java/org/geysermc/common/PlatformType.java
+++ b/common/src/main/java/org/geysermc/common/PlatformType.java
@@ -1,28 +1,3 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
package org.geysermc.common;
import lombok.AllArgsConstructor;
@@ -32,13 +7,11 @@ import lombok.Getter;
@AllArgsConstructor
public enum PlatformType {
- ANDROID("Android"),
+ BUKKIT("Bukkit"),
BUNGEECORD("BungeeCord"),
- FABRIC("Fabric"),
- SPIGOT("Spigot"),
SPONGE("Sponge"),
STANDALONE("Standalone"),
VELOCITY("Velocity");
- private final String platformName;
+ private String platformName;
}
diff --git a/common/src/main/java/org/geysermc/common/main/IGeyserMain.java b/common/src/main/java/org/geysermc/common/main/IGeyserMain.java
new file mode 100644
index 00000000..75da4e6b
--- /dev/null
+++ b/common/src/main/java/org/geysermc/common/main/IGeyserMain.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.common.main;
+
+import javax.swing.*;
+import java.io.InputStream;
+import java.util.Scanner;
+
+public class IGeyserMain {
+
+ public void displayMessage() {
+ String message = createMessage();
+
+ if (System.console() == null) {
+ JOptionPane.showMessageDialog(null, message, "GeyserMC Plugin: " + this.getPluginType(), JOptionPane.ERROR_MESSAGE);
+ }
+
+ printMessage(message);
+ }
+
+ private String createMessage() {
+ String message = "";
+
+ InputStream helpStream = IGeyserMain.class.getClassLoader().getResourceAsStream("help.txt");
+ Scanner help = new Scanner(helpStream).useDelimiter("\\Z");
+ String line = "";
+ while (help.hasNext()) {
+ line = help.next();
+
+ line = line.replace("${plugin_type}", this.getPluginType());
+ line = line.replace("${plugin_folder}", this.getPluginFolder());
+
+ message += line + "\n";
+ }
+
+ return message;
+ }
+
+ private void printMessage(String message) {
+ System.out.print(message);
+ }
+
+ public String getPluginType() {
+ return "unknown";
+ }
+
+ public String getPluginFolder() {
+ return "unknown";
+ }
+}
diff --git a/common/src/main/java/org/geysermc/common/ping/GeyserPingInfo.java b/common/src/main/java/org/geysermc/common/ping/GeyserPingInfo.java
new file mode 100644
index 00000000..40ef6da6
--- /dev/null
+++ b/common/src/main/java/org/geysermc/common/ping/GeyserPingInfo.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.common.ping;
+
+import lombok.Data;
+import lombok.Getter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+@Data
+public class GeyserPingInfo {
+
+ public final String motd;
+ public final int currentPlayerCount;
+ public final int maxPlayerCount;
+
+ @Getter
+ private Collection players = new ArrayList<>();
+
+ public void addPlayer(String username) {
+ players.add(username);
+ }
+}
diff --git a/common/src/main/java/org/geysermc/common/window/CustomFormBuilder.java b/common/src/main/java/org/geysermc/common/window/CustomFormBuilder.java
index f4e597f0..004b00a9 100644
--- a/common/src/main/java/org/geysermc/common/window/CustomFormBuilder.java
+++ b/common/src/main/java/org/geysermc/common/window/CustomFormBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/CustomFormWindow.java b/common/src/main/java/org/geysermc/common/window/CustomFormWindow.java
index 7043dda9..efc71ae8 100644
--- a/common/src/main/java/org/geysermc/common/window/CustomFormWindow.java
+++ b/common/src/main/java/org/geysermc/common/window/CustomFormWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -92,7 +92,7 @@ public class CustomFormWindow extends FormWindow {
}
public void setResponse(String data) {
- if (data == null || data.trim().equalsIgnoreCase("null") || data.isEmpty()) {
+ if (data == null || data.equalsIgnoreCase("null") || data.isEmpty()) {
closed = true;
return;
}
@@ -108,7 +108,7 @@ public class CustomFormWindow extends FormWindow {
List componentResponses = new ArrayList<>();
try {
- componentResponses = new ObjectMapper().readValue(data.trim(), new TypeReference>(){});
+ componentResponses = new ObjectMapper().readValue(data, new TypeReference>(){});
} catch (IOException e) { }
for (String response : componentResponses) {
diff --git a/common/src/main/java/org/geysermc/common/window/FormWindow.java b/common/src/main/java/org/geysermc/common/window/FormWindow.java
index efc06fe8..c3cc4258 100644
--- a/common/src/main/java/org/geysermc/common/window/FormWindow.java
+++ b/common/src/main/java/org/geysermc/common/window/FormWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/ModalFormWindow.java b/common/src/main/java/org/geysermc/common/window/ModalFormWindow.java
index 9d802161..bfeafa1b 100644
--- a/common/src/main/java/org/geysermc/common/window/ModalFormWindow.java
+++ b/common/src/main/java/org/geysermc/common/window/ModalFormWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/SimpleFormWindow.java b/common/src/main/java/org/geysermc/common/window/SimpleFormWindow.java
index 48bda0bd..7c1acc26 100644
--- a/common/src/main/java/org/geysermc/common/window/SimpleFormWindow.java
+++ b/common/src/main/java/org/geysermc/common/window/SimpleFormWindow.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -72,14 +72,14 @@ public class SimpleFormWindow extends FormWindow {
}
public void setResponse(String data) {
- if (data == null || data.trim().equalsIgnoreCase("null")) {
+ if (data == null || data.equalsIgnoreCase("null")) {
closed = true;
return;
}
int buttonID;
try {
- buttonID = Integer.parseInt(data.trim());
+ buttonID = Integer.parseInt(data);
} catch (Exception ex) {
return;
}
diff --git a/common/src/main/java/org/geysermc/common/window/button/FormButton.java b/common/src/main/java/org/geysermc/common/window/button/FormButton.java
index d2075d3f..6daa2fea 100644
--- a/common/src/main/java/org/geysermc/common/window/button/FormButton.java
+++ b/common/src/main/java/org/geysermc/common/window/button/FormButton.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/button/FormImage.java b/common/src/main/java/org/geysermc/common/window/button/FormImage.java
index 03427829..b700b046 100644
--- a/common/src/main/java/org/geysermc/common/window/button/FormImage.java
+++ b/common/src/main/java/org/geysermc/common/window/button/FormImage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -32,14 +32,14 @@ public class FormImage {
@Getter
@Setter
- private String type;
+ private FormImageType type;
@Getter
@Setter
private String data;
public FormImage(FormImageType type, String data) {
- this.type = type.getName();
+ this.type = type;
this.data = data;
}
diff --git a/common/src/main/java/org/geysermc/common/window/component/DropdownComponent.java b/common/src/main/java/org/geysermc/common/window/component/DropdownComponent.java
index 8ba17bb4..4dac6b04 100644
--- a/common/src/main/java/org/geysermc/common/window/component/DropdownComponent.java
+++ b/common/src/main/java/org/geysermc/common/window/component/DropdownComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/component/FormComponent.java b/common/src/main/java/org/geysermc/common/window/component/FormComponent.java
index 6b503eb4..5a56ae0c 100644
--- a/common/src/main/java/org/geysermc/common/window/component/FormComponent.java
+++ b/common/src/main/java/org/geysermc/common/window/component/FormComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/component/InputComponent.java b/common/src/main/java/org/geysermc/common/window/component/InputComponent.java
index 9dfc249a..fad6a0fe 100644
--- a/common/src/main/java/org/geysermc/common/window/component/InputComponent.java
+++ b/common/src/main/java/org/geysermc/common/window/component/InputComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/component/LabelComponent.java b/common/src/main/java/org/geysermc/common/window/component/LabelComponent.java
index 4608282f..a76b313f 100644
--- a/common/src/main/java/org/geysermc/common/window/component/LabelComponent.java
+++ b/common/src/main/java/org/geysermc/common/window/component/LabelComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/component/SliderComponent.java b/common/src/main/java/org/geysermc/common/window/component/SliderComponent.java
index 3e681664..a7a78362 100644
--- a/common/src/main/java/org/geysermc/common/window/component/SliderComponent.java
+++ b/common/src/main/java/org/geysermc/common/window/component/SliderComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/component/StepSliderComponent.java b/common/src/main/java/org/geysermc/common/window/component/StepSliderComponent.java
index 8e6748a9..8f128d1a 100644
--- a/common/src/main/java/org/geysermc/common/window/component/StepSliderComponent.java
+++ b/common/src/main/java/org/geysermc/common/window/component/StepSliderComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/component/ToggleComponent.java b/common/src/main/java/org/geysermc/common/window/component/ToggleComponent.java
index e79e7592..50a5c631 100644
--- a/common/src/main/java/org/geysermc/common/window/component/ToggleComponent.java
+++ b/common/src/main/java/org/geysermc/common/window/component/ToggleComponent.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,17 +25,9 @@
package org.geysermc.common.window.component;
-import lombok.Getter;
-import lombok.Setter;
-
public class ToggleComponent extends FormComponent {
- @Getter
- @Setter
private String text;
-
- @Getter
- @Setter
private boolean defaultValue;
public ToggleComponent(String text) {
diff --git a/common/src/main/java/org/geysermc/common/window/response/CustomFormResponse.java b/common/src/main/java/org/geysermc/common/window/response/CustomFormResponse.java
index 252a0978..6cdd7097 100644
--- a/common/src/main/java/org/geysermc/common/window/response/CustomFormResponse.java
+++ b/common/src/main/java/org/geysermc/common/window/response/CustomFormResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/response/FormResponse.java b/common/src/main/java/org/geysermc/common/window/response/FormResponse.java
index 35023f16..2be64683 100644
--- a/common/src/main/java/org/geysermc/common/window/response/FormResponse.java
+++ b/common/src/main/java/org/geysermc/common/window/response/FormResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/response/FormResponseData.java b/common/src/main/java/org/geysermc/common/window/response/FormResponseData.java
index 013c4985..fd40be0f 100644
--- a/common/src/main/java/org/geysermc/common/window/response/FormResponseData.java
+++ b/common/src/main/java/org/geysermc/common/window/response/FormResponseData.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/response/ModalFormResponse.java b/common/src/main/java/org/geysermc/common/window/response/ModalFormResponse.java
index 3338df4d..e1a14039 100644
--- a/common/src/main/java/org/geysermc/common/window/response/ModalFormResponse.java
+++ b/common/src/main/java/org/geysermc/common/window/response/ModalFormResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/common/window/response/SimpleFormResponse.java b/common/src/main/java/org/geysermc/common/window/response/SimpleFormResponse.java
index c24f72d0..e80d58e7 100644
--- a/common/src/main/java/org/geysermc/common/window/response/SimpleFormResponse.java
+++ b/common/src/main/java/org/geysermc/common/window/response/SimpleFormResponse.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/floodgate/util/BedrockData.java b/common/src/main/java/org/geysermc/floodgate/util/BedrockData.java
index 22c33f47..dc895a79 100644
--- a/common/src/main/java/org/geysermc/floodgate/util/BedrockData.java
+++ b/common/src/main/java/org/geysermc/floodgate/util/BedrockData.java
@@ -1,28 +1,3 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
package org.geysermc.floodgate.util;
import lombok.AllArgsConstructor;
diff --git a/common/src/main/java/org/geysermc/floodgate/util/DeviceOS.java b/common/src/main/java/org/geysermc/floodgate/util/DeviceOS.java
index 1e0b22cf..93d3c121 100644
--- a/common/src/main/java/org/geysermc/floodgate/util/DeviceOS.java
+++ b/common/src/main/java/org/geysermc/floodgate/util/DeviceOS.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
diff --git a/common/src/main/java/org/geysermc/floodgate/util/EncryptionUtil.java b/common/src/main/java/org/geysermc/floodgate/util/EncryptionUtil.java
index f4dd5d2e..881d01ba 100644
--- a/common/src/main/java/org/geysermc/floodgate/util/EncryptionUtil.java
+++ b/common/src/main/java/org/geysermc/floodgate/util/EncryptionUtil.java
@@ -1,28 +1,3 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
package org.geysermc.floodgate.util;
import javax.crypto.*;
diff --git a/common/src/main/resources/help.txt b/common/src/main/resources/help.txt
new file mode 100644
index 00000000..3512ed83
--- /dev/null
+++ b/common/src/main/resources/help.txt
@@ -0,0 +1,18 @@
+
+--------------------------------------------------------------------------------
+
+ Oops! You attempted to run a plugin version of Geyser directly!
+
+ This jar file is a plugin for ${plugin_type}. You can run this file as a
+ plugin by dropping the jar file into the "${plugin_folder}" directory.
+
+ There is also a standalone version available that doesn't need to
+ be installed as a plugin, you can find it on our build server:
+
+ http://ci.geysermc.org/
+
+ If you need more help, you should check out our discord:
+
+ http://discord.geysermc.org/
+
+--------------------------------------------------------------------------------
\ No newline at end of file
diff --git a/connector/pom.xml b/connector/pom.xml
index a7001be0..91cf6f3d 100644
--- a/connector/pom.xml
+++ b/connector/pom.xml
@@ -6,15 +6,16 @@
org.geysermcgeyser-parent
- 1.2.0-SNAPSHOT
+ parent
+ ../connector
-
+ 1.0-SNAPSHOTorg.geysermccommon
- 1.2.0-SNAPSHOT
+ 1.0-SNAPSHOTcompile
@@ -30,28 +31,17 @@
compile
- com.github.CloudburstMC.Protocol
- bedrock-v422
- d41b84e86c
+ com.nukkitx.protocol
+ bedrock-v390
+ 2.5.6-SNAPSHOTcompilenet.sf.trove4jtrove
-
-
- com.nukkitx.network
- raknet
-
-
- com.nukkitx.network
- raknet
- 1.6.20
- compile
- com.nukkitx.fastutilfastutil-int-int-maps
@@ -76,12 +66,6 @@
8.3.1compile
-
- com.nukkitx.fastutil
- fastutil-int-byte-maps
- 8.3.1
- compile
- com.nukkitx.fastutilfastutil-int-double-maps
@@ -106,12 +90,6 @@
8.3.1compile
-
- com.nukkitx.fastutil
- fastutil-object-object-maps
- 8.3.1
- compile
- com.google.guavaguava
@@ -121,30 +99,10 @@
com.github.steveice10mcprotocollib
- 26201a4
+ 4c315aa206compile
- net.kyori
- adventure-text-serializer-gson
-
-
- com.github.steveice10
- packetlib
-
-
- com.github.steveice10
- mcauthlib
-
-
-
-
- com.github.steveice10
- PacketLib
- 54f761c
- compile
-
- io.nettynetty-all
@@ -156,57 +114,29 @@
4.1.43.Finalcompile
-
- io.netty
- netty-codec-haproxy
- 4.1.56.Final
- compile
- org.reflectionsreflections
- 0.9.11
-
-
- org.dom4j
- dom4j
- 2.1.3
+ 0.9.12net.kyori
- adventure-api
- 4.3.0
+ text-api
+ 3.0.3compilenet.kyori
- adventure-text-serializer-gson
- 4.3.0
+ text-serializer-gson
+ 3.0.3compilenet.kyori
- adventure-text-serializer-legacy
- 4.3.0
+ text-serializer-legacy
+ 3.0.3compile
-
- net.kyori
- adventure-text-serializer-gson-legacy-impl
- 4.3.0
- compile
-
-
- junit
- junit
- 4.13.1
- test
-
-
- com.github.GeyserMC
- MCAuthLib
- 0e48a094f2
-
@@ -234,11 +164,6 @@
falsegit.user.*
- git.*.user.*
- git.closest.*
- git.commit.id.describe
- git.commit.id.describe-short
- git.commit.message.shortflat
@@ -263,12 +188,8 @@
- String VERSION = ".*"
- String VERSION = "${project.version} (" + GIT_VERSION + ")"
-
-
- String GIT_VERSION = ".*"
- String GIT_VERSION = "git-${git.branch}-${git.commit.id.abbrev}"
+ VERSION = ".*"
+ VERSION = "${project.version} (git-${git.branch}-${git.commit.id.abbrev})"
@@ -286,75 +207,14 @@
- String VERSION = ".*"
- String VERSION = "DEV"
-
-
- String GIT_VERSION = ".*"
- String GIT_VERSION = "DEV"
+ VERSION = ".*"
+ VERSION = "DEV"
-
- org.codehaus.gmavenplus
- gmavenplus-plugin
- 1.9.1
-
-
- process-classes
-
- execute
-
-
-
-
-
-
-
-
-
-
- org.reflections
- reflections
- 0.9.11
-
-
- org.dom4j
- dom4j
- 2.1.3
-
-
- org.codehaus.groovy
- groovy-all
- 3.0.5
- runtime
- pom
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.22.0
-
-
- -Dfile.encoding=${project.build.sourceEncoding}
-
-
diff --git a/connector/src/main/java/org/geysermc/connector/FloodgateKeyLoader.java b/connector/src/main/java/org/geysermc/connector/FloodgateKeyLoader.java
index 77492fb7..0b631b2d 100644
--- a/connector/src/main/java/org/geysermc/connector/FloodgateKeyLoader.java
+++ b/connector/src/main/java/org/geysermc/connector/FloodgateKeyLoader.java
@@ -1,51 +1,47 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.connector;
-import org.geysermc.connector.configuration.GeyserJacksonConfiguration;
-import org.geysermc.connector.utils.LanguageUtils;
-
import java.nio.file.Files;
import java.nio.file.Path;
public class FloodgateKeyLoader {
- public static Path getKeyPath(GeyserJacksonConfiguration config, Object floodgate, Path floodgateDataFolder, Path geyserDataFolder, GeyserLogger logger) {
- Path floodgateKey = geyserDataFolder.resolve(config.getFloodgateKeyFile());
-
+ public static Path getKey(GeyserLogger logger, GeyserConfiguration config, Path floodgateKey, Object floodgate, Path floodgateFolder) {
if (!Files.exists(floodgateKey) && config.getRemote().getAuthType().equals("floodgate")) {
if (floodgate != null) {
- Path autoKey = floodgateDataFolder.resolve("public-key.pem");
+ Path autoKey = floodgateFolder.resolve("public-key.pem");
if (Files.exists(autoKey)) {
- logger.info(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.auto_loaded"));
+ logger.info("Auto-loaded floodgate key");
floodgateKey = autoKey;
} else {
- logger.error(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.missing_key"));
+ logger.error("Auth-type set to floodgate and the public key is missing!");
}
} else {
- logger.error(LanguageUtils.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed"));
+ logger.error("Auth-type set to floodgate but floodgate is not installed!");
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConfiguration.java b/connector/src/main/java/org/geysermc/connector/GeyserConfiguration.java
new file mode 100644
index 00000000..8a39323b
--- /dev/null
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConfiguration.java
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
+ *
+ */
+
+package org.geysermc.connector;
+
+import java.nio.file.Path;
+import java.util.Map;
+
+public interface GeyserConfiguration {
+
+ // Modify this when you update the config
+ int CURRENT_CONFIG_VERSION = 3;
+
+ IBedrockConfiguration getBedrock();
+
+ IRemoteConfiguration getRemote();
+
+ Map getUserAuths();
+
+ boolean isCommandSuggestions();
+
+ boolean isPassthroughMotd();
+
+ boolean isPassthroughPlayerCounts();
+
+ boolean isLegacyPingPassthrough();
+
+ int getPingPassthroughInterval();
+
+ int getMaxPlayers();
+
+ boolean isDebugMode();
+
+ int getGeneralThreadPool();
+
+ boolean isAllowThirdPartyCapes();
+
+ boolean isAllowThirdPartyEars();
+
+ String getDefaultLocale();
+
+ Path getFloodgateKeyFile();
+
+ boolean isAboveBedrockNetherBuilding();
+
+ boolean isCacheChunks();
+
+ IMetricsInfo getMetrics();
+
+ interface IBedrockConfiguration {
+
+ String getAddress();
+
+ int getPort();
+
+ String getMotd1();
+
+ String getMotd2();
+ }
+
+ interface IRemoteConfiguration {
+
+ String getAddress();
+
+ int getPort();
+
+ String getAuthType();
+ }
+
+ interface IUserAuthenticationInfo {
+ String getEmail();
+
+ String getPassword();
+ }
+
+ interface IMetricsInfo {
+
+ boolean isEnabled();
+
+ String getUniqueId();
+ }
+
+ int getConfigVersion();
+
+ static void checkGeyserConfiguration(GeyserConfiguration geyserConfig, GeyserLogger geyserLogger) {
+ if (geyserConfig.getConfigVersion() < CURRENT_CONFIG_VERSION) {
+ geyserLogger.warning("Your Geyser config is out of date! Please regenerate your config when possible.");
+ } else if (geyserConfig.getConfigVersion() > CURRENT_CONFIG_VERSION) {
+ geyserLogger.warning("Your Geyser config is too new! Errors may occur.");
+ }
+ }
+}
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
index d61500e0..02e0c500 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,18 +25,16 @@
package org.geysermc.connector;
-import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.nukkitx.network.raknet.RakNetConstants;
+import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
import com.nukkitx.protocol.bedrock.BedrockServer;
+import com.nukkitx.protocol.bedrock.v390.Bedrock_v390;
import lombok.Getter;
-import lombok.Setter;
+import org.geysermc.common.AuthType;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.bootstrap.GeyserBootstrap;
import org.geysermc.connector.command.CommandManager;
-import org.geysermc.connector.common.AuthType;
-import org.geysermc.connector.configuration.GeyserConfiguration;
import org.geysermc.connector.metrics.Metrics;
import org.geysermc.connector.network.ConnectorServerEventHandler;
import org.geysermc.connector.network.remote.RemoteServer;
@@ -44,30 +42,22 @@ import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.BiomeTranslator;
import org.geysermc.connector.network.translators.EntityIdentifierRegistry;
import org.geysermc.connector.network.translators.PacketTranslatorRegistry;
-import org.geysermc.connector.network.translators.collision.CollisionTranslator;
-import org.geysermc.connector.network.translators.effect.EffectRegistry;
import org.geysermc.connector.network.translators.item.ItemRegistry;
import org.geysermc.connector.network.translators.item.ItemTranslator;
-import org.geysermc.connector.network.translators.item.PotionMixRegistry;
-import org.geysermc.connector.network.translators.item.RecipeRegistry;
import org.geysermc.connector.network.translators.sound.SoundHandlerRegistry;
-import org.geysermc.connector.network.translators.sound.SoundRegistry;
import org.geysermc.connector.network.translators.world.WorldManager;
import org.geysermc.connector.network.translators.world.block.BlockTranslator;
+import org.geysermc.connector.network.translators.effect.EffectRegistry;
import org.geysermc.connector.network.translators.world.block.entity.BlockEntityTranslator;
-import org.geysermc.connector.network.translators.world.block.entity.SkullBlockEntityTranslator;
import org.geysermc.connector.utils.DimensionUtils;
-import org.geysermc.connector.utils.LanguageUtils;
+import org.geysermc.connector.utils.DockerCheck;
import org.geysermc.connector.utils.LocaleUtils;
-import org.geysermc.connector.utils.ResourcePack;
+import org.geysermc.connector.network.translators.sound.SoundRegistry;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.InitialDirContext;
-import java.net.InetAddress;
import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
import java.text.DecimalFormat;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -76,29 +66,18 @@ import java.util.concurrent.TimeUnit;
@Getter
public class GeyserConnector {
- public static final ObjectMapper JSON_MAPPER = new ObjectMapper()
- .enable(JsonParser.Feature.IGNORE_UNDEFINED)
- .enable(JsonParser.Feature.ALLOW_COMMENTS)
- .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
- .enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
+ public static final ObjectMapper JSON_MAPPER = new ObjectMapper().disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
+
+ public static final BedrockPacketCodec BEDROCK_PACKET_CODEC = Bedrock_v390.V390_CODEC;
public static final String NAME = "Geyser";
- public static final String GIT_VERSION = "DEV"; // A fallback for running in IDEs
public static final String VERSION = "DEV"; // A fallback for running in IDEs
- /**
- * Oauth client ID for Microsoft authentication
- */
- public static final String OAUTH_CLIENT_ID = "204cefd1-4818-4de1-b98d-513fae875d88";
-
- private static final String IP_REGEX = "\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b";
-
- private final List players = new ArrayList<>();
+ private final Map players = new HashMap<>();
private static GeyserConnector instance;
private RemoteServer remoteServer;
- @Setter
private AuthType authType;
private boolean shuttingDown = false;
@@ -106,8 +85,8 @@ public class GeyserConnector {
private final ScheduledExecutorService generalThreadPool;
private BedrockServer bedrockServer;
- private final PlatformType platformType;
- private final GeyserBootstrap bootstrap;
+ private PlatformType platformType;
+ private GeyserBootstrap bootstrap;
private Metrics metrics;
@@ -125,7 +104,7 @@ public class GeyserConnector {
logger.info("******************************************");
logger.info("");
- logger.info(LanguageUtils.getLocaleStringLog("geyser.core.load", NAME, VERSION));
+ logger.info("Loading " + NAME + " version " + VERSION);
logger.info("");
logger.info("******************************************");
@@ -143,144 +122,52 @@ public class GeyserConnector {
EntityIdentifierRegistry.init();
ItemRegistry.init();
ItemTranslator.init();
- CollisionTranslator.init();
LocaleUtils.init();
- PotionMixRegistry.init();
- RecipeRegistry.init();
SoundRegistry.init();
SoundHandlerRegistry.init();
- ResourcePack.loadPacks();
-
- if (platformType != PlatformType.STANDALONE && config.getRemote().getAddress().equals("auto")) {
- // Set the remote address to localhost since that is where we are always connecting
- try {
- config.getRemote().setAddress(InetAddress.getLocalHost().getHostAddress());
- } catch (UnknownHostException ex) {
- logger.debug("Unknown host when trying to find localhost.");
- if (config.isDebugMode()) {
- ex.printStackTrace();
- }
- }
- }
- String remoteAddress = config.getRemote().getAddress();
- int remotePort = config.getRemote().getPort();
- // Filters whether it is not an IP address or localhost, because otherwise it is not possible to find out an SRV entry.
- if ((config.isLegacyPingPassthrough() || platformType == PlatformType.STANDALONE) && !remoteAddress.matches(IP_REGEX) && !remoteAddress.equalsIgnoreCase("localhost")) {
- try {
- // Searches for a server address and a port from a SRV record of the specified host name
- InitialDirContext ctx = new InitialDirContext();
- Attribute attr = ctx.getAttributes("dns:///_minecraft._tcp." + remoteAddress, new String[]{"SRV"}).get("SRV");
- // size > 0 = SRV entry found
- if (attr != null && attr.size() > 0) {
- String[] record = ((String) attr.get(0)).split(" ");
- // Overwrites the existing address and port with that from the SRV record.
- config.getRemote().setAddress(remoteAddress = record[3]);
- config.getRemote().setPort(remotePort = Integer.parseInt(record[2]));
- logger.debug("Found SRV record \"" + remoteAddress + ":" + remotePort + "\"");
- }
- } catch (Exception | NoClassDefFoundError ex) { // Check for a NoClassDefFoundError to prevent Android crashes
- logger.debug("Exception while trying to find an SRV record for the remote host.");
- if (config.isDebugMode())
- ex.printStackTrace(); // Otherwise we can get a stack trace for any domain that doesn't have an SRV record
- }
+ if (platformType != PlatformType.STANDALONE) {
+ DockerCheck.check(bootstrap);
}
- remoteServer = new RemoteServer(config.getRemote().getAddress(), remotePort);
+ remoteServer = new RemoteServer(config.getRemote().getAddress(), config.getRemote().getPort());
authType = AuthType.getByName(config.getRemote().getAuthType());
- DimensionUtils.changeBedrockNetherId(config.isAboveBedrockNetherBuilding()); // Apply End dimension ID workaround to Nether
- SkullBlockEntityTranslator.ALLOW_CUSTOM_SKULLS = config.isAllowCustomSkulls();
-
- // https://github.com/GeyserMC/Geyser/issues/957
- RakNetConstants.MAXIMUM_MTU_SIZE = (short) config.getMtu();
- logger.debug("Setting MTU to " + config.getMtu());
+ if (config.isAboveBedrockNetherBuilding())
+ DimensionUtils.changeBedrockNetherId(); // Apply End dimension ID workaround to Nether
bedrockServer = new BedrockServer(new InetSocketAddress(config.getBedrock().getAddress(), config.getBedrock().getPort()));
bedrockServer.setHandler(new ConnectorServerEventHandler(this));
bedrockServer.bind().whenComplete((avoid, throwable) -> {
if (throwable == null) {
- logger.info(LanguageUtils.getLocaleStringLog("geyser.core.start", config.getBedrock().getAddress(), String.valueOf(config.getBedrock().getPort())));
+ logger.info("Started Geyser on " + config.getBedrock().getAddress() + ":" + config.getBedrock().getPort());
} else {
- logger.severe(LanguageUtils.getLocaleStringLog("geyser.core.fail", config.getBedrock().getAddress(), String.valueOf(config.getBedrock().getPort())));
+ logger.severe("Failed to start Geyser on " + config.getBedrock().getAddress() + ":" + config.getBedrock().getPort());
throwable.printStackTrace();
}
}).join();
if (config.getMetrics().isEnabled()) {
metrics = new Metrics(this, "GeyserMC", config.getMetrics().getUniqueId(), false, java.util.logging.Logger.getLogger(""));
+ metrics.addCustomChart(new Metrics.SingleLineChart("servers", () -> 1));
metrics.addCustomChart(new Metrics.SingleLineChart("players", players::size));
- // Prevent unwanted words best we can
- metrics.addCustomChart(new Metrics.SimplePie("authMode", () -> AuthType.getByName(config.getRemote().getAuthType()).toString().toLowerCase()));
+ metrics.addCustomChart(new Metrics.SimplePie("authMode", authType.name()::toLowerCase));
metrics.addCustomChart(new Metrics.SimplePie("platform", platformType::getPlatformName));
- metrics.addCustomChart(new Metrics.SimplePie("defaultLocale", LanguageUtils::getDefaultLocale));
- metrics.addCustomChart(new Metrics.SimplePie("version", () -> GeyserConnector.VERSION));
- metrics.addCustomChart(new Metrics.AdvancedPie("playerPlatform", () -> {
- Map valueMap = new HashMap<>();
- for (GeyserSession session : players) {
- if (session == null) continue;
- if (session.getClientData() == null) continue;
- String os = session.getClientData().getDeviceOS().toString();
- if (!valueMap.containsKey(os)) {
- valueMap.put(os, 1);
- } else {
- valueMap.put(os, valueMap.get(os) + 1);
- }
- }
- return valueMap;
- }));
- metrics.addCustomChart(new Metrics.AdvancedPie("playerVersion", () -> {
- Map valueMap = new HashMap<>();
- for (GeyserSession session : players) {
- if (session == null) continue;
- if (session.getClientData() == null) continue;
- String version = session.getClientData().getGameVersion();
- if (!valueMap.containsKey(version)) {
- valueMap.put(version, 1);
- } else {
- valueMap.put(version, valueMap.get(version) + 1);
- }
- }
- return valueMap;
- }));
- }
-
- boolean isGui = false;
- // This will check if we are in standalone and get the 'useGui' variable from there
- if (platformType == PlatformType.STANDALONE) {
- try {
- Class> cls = Class.forName("org.geysermc.platform.standalone.GeyserStandaloneBootstrap");
- isGui = (boolean) cls.getMethod("isUseGui").invoke(cls.cast(bootstrap));
- } catch (Exception e) {
- logger.debug("Failed detecting if standalone is using a GUI; if this is a GeyserConnect instance this can be safely ignored.");
- }
}
double completeTime = (System.currentTimeMillis() - startupTime) / 1000D;
- String message = LanguageUtils.getLocaleStringLog("geyser.core.finish.done", new DecimalFormat("#.###").format(completeTime)) + " ";
- if (isGui) {
- message += LanguageUtils.getLocaleStringLog("geyser.core.finish.gui");
- } else {
- message += LanguageUtils.getLocaleStringLog("geyser.core.finish.console");
- }
- logger.info(message);
-
- if (platformType == PlatformType.STANDALONE) {
- logger.warning(LanguageUtils.getLocaleStringLog("geyser.core.movement_warn"));
- }
+ logger.info(String.format("Done (%ss)! Run /geyser help for help!", new DecimalFormat("#.###").format(completeTime)));
}
public void shutdown() {
- bootstrap.getGeyserLogger().info(LanguageUtils.getLocaleStringLog("geyser.core.shutdown"));
+ bootstrap.getGeyserLogger().info("Shutting down Geyser.");
shuttingDown = true;
if (players.size() >= 1) {
- bootstrap.getGeyserLogger().info(LanguageUtils.getLocaleStringLog("geyser.core.shutdown.kick.log", players.size()));
+ bootstrap.getGeyserLogger().info("Kicking " + players.size() + " player(s)");
- // Make a copy to prevent ConcurrentModificationException
- final List tmpPlayers = new ArrayList<>(players);
- for (GeyserSession playerSession : tmpPlayers) {
- playerSession.disconnect(LanguageUtils.getPlayerLocaleString("geyser.core.shutdown.kick.message", playerSession.getLocale()));
+ for (GeyserSession playerSession : players.values()) {
+ playerSession.disconnect("Geyser Proxy shutting down.");
}
CompletableFuture future = CompletableFuture.runAsync(new Runnable() {
@@ -304,7 +191,7 @@ public class GeyserConnector {
// Block and wait for the future to complete
try {
future.get();
- bootstrap.getGeyserLogger().info(LanguageUtils.getLocaleStringLog("geyser.core.shutdown.kick.done"));
+ bootstrap.getGeyserLogger().info("Kicked all players");
} catch (Exception e) {
// Quietly fail
}
@@ -317,47 +204,15 @@ public class GeyserConnector {
authType = null;
this.getCommandManager().getCommands().clear();
- bootstrap.getGeyserLogger().info(LanguageUtils.getLocaleStringLog("geyser.core.shutdown.done"));
+ bootstrap.getGeyserLogger().info("Geyser shutdown successfully.");
}
public void addPlayer(GeyserSession player) {
- players.add(player);
+ players.put(player.getSocketAddress(), player);
}
public void removePlayer(GeyserSession player) {
- players.remove(player);
- }
-
- /**
- * Gets a player by their current UUID
- *
- * @param uuid the uuid
- * @return the player or null if there is no player online with this UUID
- */
- public GeyserSession getPlayerByUuid(UUID uuid) {
- for (GeyserSession session : players) {
- if (session.getPlayerEntity().getUuid().equals(uuid)) {
- return session;
- }
- }
-
- return null;
- }
-
- /**
- * Gets a player by their Xbox user identifier
- *
- * @param xuid the Xbox user identifier
- * @return the player or null if there is no player online with this xuid
- */
- public GeyserSession getPlayerByXuid(String xuid) {
- for (GeyserSession session : players) {
- if (session.getAuthData() != null && session.getAuthData().getXboxUUID().equals(xuid)) {
- return session;
- }
- }
-
- return null;
+ players.remove(player.getSocketAddress());
}
public static GeyserConnector start(PlatformType platformType, GeyserBootstrap bootstrap) {
@@ -385,19 +240,6 @@ public class GeyserConnector {
return bootstrap.getWorldManager();
}
- /**
- * Whether to use XML reflections in the jar or manually find the reflections.
- * Will return true if the version number is not 'DEV' and the platform is not Fabric.
- * On Fabric - it complains about being unable to create a default XMLReader.
- * On other platforms this should only be true in compiled jars.
- *
- * @return whether to use XML reflections
- */
- public boolean useXmlReflections() {
- //noinspection ConstantConditions
- return !this.getPlatformType().equals(PlatformType.FABRIC) && !"DEV".equals(GeyserConnector.VERSION);
- }
-
public static GeyserConnector getInstance() {
return instance;
}
diff --git a/connector/src/main/java/org/geysermc/connector/GeyserLogger.java b/connector/src/main/java/org/geysermc/connector/GeyserLogger.java
index 6d36958d..4acab222 100644
--- a/connector/src/main/java/org/geysermc/connector/GeyserLogger.java
+++ b/connector/src/main/java/org/geysermc/connector/GeyserLogger.java
@@ -1,26 +1,27 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.connector;
@@ -36,9 +37,6 @@ public interface GeyserLogger {
/**
* Logs a severe message and an exception to console
- *
- * @param message the message to log
- * @param error the error to throw
*/
void severe(String message, Throwable error);
@@ -51,9 +49,6 @@ public interface GeyserLogger {
/**
* Logs an error message and an exception to console
- *
- * @param message the message to log
- * @param error the error to throw
*/
void error(String message, Throwable error);
@@ -84,9 +79,4 @@ public interface GeyserLogger {
* @param debug if the logger should print debug messages
*/
void setDebug(boolean debug);
-
- /**
- * If debug is enabled for this logger
- */
- boolean isDebug();
}
diff --git a/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java b/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java
index 7308fb67..24ce81cf 100644
--- a/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java
+++ b/connector/src/main/java/org/geysermc/connector/bootstrap/GeyserBootstrap.java
@@ -1,43 +1,41 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ * @author GeyserMC
+ * @link https://github.com/GeyserMC/Geyser
*
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.connector.bootstrap;
-import org.geysermc.connector.dump.BootstrapDumpInfo;
import org.geysermc.connector.ping.IGeyserPingPassthrough;
-import org.geysermc.connector.configuration.GeyserConfiguration;
+import org.geysermc.connector.GeyserConfiguration;
import org.geysermc.connector.GeyserLogger;
import org.geysermc.connector.command.CommandManager;
-import org.geysermc.connector.network.translators.world.GeyserWorldManager;
+import org.geysermc.connector.network.translators.world.CachedChunkManager;
import org.geysermc.connector.network.translators.world.WorldManager;
-import java.nio.file.Path;
-
public interface GeyserBootstrap {
- GeyserWorldManager DEFAULT_CHUNK_MANAGER = new GeyserWorldManager();
+ CachedChunkManager DEFAULT_CHUNK_MANAGER = new CachedChunkManager();
/**
* Called when the GeyserBootstrap is enabled
@@ -85,18 +83,4 @@ public interface GeyserBootstrap {
default WorldManager getWorldManager() {
return DEFAULT_CHUNK_MANAGER;
}
-
- /**
- * Return the data folder where files get stored
- *
- * @return Path location of data folder
- */
- Path getConfigFolder();
-
- /**
- * Information used for the bootstrap section of the debug dump
- *
- * @return The info about the bootstrap
- */
- BootstrapDumpInfo getDumpInfo();
}
diff --git a/connector/src/main/java/org/geysermc/connector/command/CommandManager.java b/connector/src/main/java/org/geysermc/connector/command/CommandManager.java
index d31983eb..88b9e795 100644
--- a/connector/src/main/java/org/geysermc/connector/command/CommandManager.java
+++ b/connector/src/main/java/org/geysermc/connector/command/CommandManager.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -29,35 +29,31 @@ import lombok.Getter;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.defaults.*;
-import org.geysermc.connector.utils.LanguageUtils;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
public abstract class CommandManager {
@Getter
private final Map commands = Collections.synchronizedMap(new HashMap<>());
- private final GeyserConnector connector;
+ private GeyserConnector connector;
public CommandManager(GeyserConnector connector) {
this.connector = connector;
- registerCommand(new HelpCommand(connector, "help", "geyser.commands.help.desc", "geyser.command.help"));
- registerCommand(new ListCommand(connector, "list", "geyser.commands.list.desc", "geyser.command.list"));
- registerCommand(new ReloadCommand(connector, "reload", "geyser.commands.reload.desc", "geyser.command.reload"));
- registerCommand(new StopCommand(connector, "stop", "geyser.commands.stop.desc", "geyser.command.stop"));
- registerCommand(new OffhandCommand(connector, "offhand", "geyser.commands.offhand.desc", "geyser.command.offhand"));
- registerCommand(new DumpCommand(connector, "dump", "geyser.commands.dump.desc", "geyser.command.dump"));
- registerCommand(new VersionCommand(connector, "version", "geyser.commands.version.desc", "geyser.command.version"));
- registerCommand(new SettingsCommand(connector, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
- registerCommand(new StatisticsCommand(connector, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
- registerCommand(new AdvancementsCommand(connector, "advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
+ registerCommand(new HelpCommand(connector, "help", "Shows help for all registered commands.", "geyser.command.help"));
+ registerCommand(new ListCommand(connector, "list", "List all players connected through Geyser.", "geyser.command.list"));
+ registerCommand(new ReloadCommand(connector, "reload", "Reloads the Geyser configurations. Kicks all players when used!", "geyser.command.reload"));
+ registerCommand(new StopCommand(connector, "stop", "Shuts down Geyser.", "geyser.command.stop"));
+ registerCommand(new OffhandCommand(connector, "offhand", "Puts an items in your offhand.", "geyser.command.offhand"));
}
public void registerCommand(GeyserCommand command) {
commands.put(command.getName(), command);
- connector.getLogger().debug(LanguageUtils.getLocaleStringLog("geyser.commands.registered", command.getName()));
+ connector.getLogger().debug("Registered command " + command.getName());
if (command.getAliases().isEmpty())
return;
@@ -79,26 +75,19 @@ public abstract class CommandManager {
args = new String[0];
} else {
label = command.substring(0, command.indexOf(" ")).toLowerCase();
- String argLine = command.substring(command.indexOf(" ") + 1);
+ String argLine = command.substring(command.indexOf(" " + 1));
args = argLine.contains(" ") ? argLine.split(" ") : new String[] { argLine };
}
GeyserCommand cmd = commands.get(label);
if (cmd == null) {
- connector.getLogger().error(LanguageUtils.getLocaleStringLog("geyser.commands.invalid"));
+ connector.getLogger().error("Invalid Command! Try /geyser help for a list of commands.");
return;
}
cmd.execute(sender, args);
}
- /**
- * @return a list of all subcommands under {@code /geyser}.
- */
- public List getCommandNames() {
- return Arrays.asList(connector.getCommandManager().getCommands().keySet().toArray(new String[0]));
- }
-
/**
* Returns the description of the given command
*
diff --git a/connector/src/main/java/org/geysermc/connector/command/CommandSender.java b/connector/src/main/java/org/geysermc/connector/command/CommandSender.java
index 78d12aad..9e4f020b 100644
--- a/connector/src/main/java/org/geysermc/connector/command/CommandSender.java
+++ b/connector/src/main/java/org/geysermc/connector/command/CommandSender.java
@@ -1,36 +1,5 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
package org.geysermc.connector.command;
-import org.geysermc.connector.utils.LanguageUtils;
-
-/**
- * Implemented on top of any class that can send a command.
- * For example, it wraps around Spigot's CommandSender class.
- */
public interface CommandSender {
String getName();
@@ -43,17 +12,5 @@ public interface CommandSender {
void sendMessage(String message);
- /**
- * @return true if the specified sender is from the console.
- */
boolean isConsole();
-
- /**
- * Returns the locale of the command sender. Defaults to the default locale at {@link LanguageUtils#getDefaultLocale()}.
- *
- * @return the locale of the command sender.
- */
- default String getLocale() {
- return LanguageUtils.getDefaultLocale();
- }
}
diff --git a/connector/src/main/java/org/geysermc/connector/command/GeyserCommand.java b/connector/src/main/java/org/geysermc/connector/command/GeyserCommand.java
index c606e2e7..62bc6c73 100644
--- a/connector/src/main/java/org/geysermc/connector/command/GeyserCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/GeyserCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -30,7 +30,6 @@ import lombok.RequiredArgsConstructor;
import lombok.Setter;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
@Getter
@@ -38,9 +37,6 @@ import java.util.List;
public abstract class GeyserCommand {
protected final String name;
- /**
- * The description of the command - will attempt to be translated.
- */
protected final String description;
protected final String permission;
@@ -48,31 +44,4 @@ public abstract class GeyserCommand {
private List aliases = new ArrayList<>();
public abstract void execute(CommandSender sender, String[] args);
-
- /**
- * If false, hides the command from being shown on the Geyser Standalone GUI.
- *
- * @return true if the command can be run on the server console
- */
- public boolean isExecutableOnConsole() {
- return true;
- }
-
- /**
- * Used in the GUI to know what subcommands can be run
- *
- * @return a list of all possible subcommands, or empty if none.
- */
- public List getSubCommands() {
- return Collections.emptyList();
- }
-
- /**
- * Shortcut to {@link #getSubCommands()}{@code .isEmpty()}.
- *
- * @return true if there are subcommand present for this command.
- */
- public boolean hasSubCommands() {
- return !getSubCommands().isEmpty();
- }
}
\ No newline at end of file
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/AdvancementsCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/AdvancementsCommand.java
deleted file mode 100644
index 3067f3d5..00000000
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/AdvancementsCommand.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.command.defaults;
-
-import org.geysermc.common.window.SimpleFormWindow;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.network.session.cache.AdvancementsCache;
-
-public class AdvancementsCommand extends GeyserCommand {
-
- private final GeyserConnector connector;
-
- public AdvancementsCommand(GeyserConnector connector, String name, String description, String permission) {
- super(name, description, permission);
-
- this.connector = connector;
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- if (sender.isConsole()) {
- return;
- }
-
- // Make sure the sender is a Bedrock edition client
- GeyserSession session = null;
- if (sender instanceof GeyserSession) {
- session = (GeyserSession) sender;
- } else {
- // Needed for Spigot - sender is not an instance of GeyserSession
- for (GeyserSession otherSession : connector.getPlayers()) {
- if (sender.getName().equals(otherSession.getPlayerEntity().getUsername())) {
- session = otherSession;
- break;
- }
- }
- }
- if (session == null) return;
-
- SimpleFormWindow window = session.getAdvancementsCache().buildMenuForm();
- session.sendForm(window, AdvancementsCache.ADVANCEMENTS_MENU_FORM_ID);
- }
-
- @Override
- public boolean isExecutableOnConsole() {
- return false;
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/DumpCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/DumpCommand.java
deleted file mode 100644
index 5bc3efea..00000000
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/DumpCommand.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.command.defaults;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.common.ChatColor;
-import org.geysermc.connector.common.serializer.AsteriskSerializer;
-import org.geysermc.connector.dump.DumpInfo;
-import org.geysermc.connector.utils.LanguageUtils;
-import org.geysermc.connector.utils.WebUtils;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-public class DumpCommand extends GeyserCommand {
-
- private final GeyserConnector connector;
- private static final ObjectMapper MAPPER = new ObjectMapper();
- private static final String DUMP_URL = "https://dump.geysermc.org/";
-
- public DumpCommand(GeyserConnector connector, String name, String description, String permission) {
- super(name, description, permission);
-
- this.connector = connector;
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- boolean showSensitive = false;
- boolean offlineDump = false;
- if (args.length >= 1) {
- for (String arg : args) {
- switch (arg) {
- case "full":
- showSensitive = true;
- break;
- case "offline":
- offlineDump = true;
- break;
-
- }
- }
- }
-
- AsteriskSerializer.showSensitive = showSensitive;
-
- sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.dump.collecting", sender.getLocale()));
- String dumpData = "";
- try {
- if (offlineDump) {
- dumpData = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(new DumpInfo());
- } else {
- dumpData = MAPPER.writeValueAsString(new DumpInfo());
- }
- } catch (IOException e) {
- sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.commands.dump.collect_error", sender.getLocale()));
- connector.getLogger().error(LanguageUtils.getLocaleStringLog("geyser.commands.dump.collect_error_short"), e);
- return;
- }
-
- String uploadedDumpUrl = "";
-
- if (offlineDump) {
- sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.dump.writing", sender.getLocale()));
-
- try {
- FileOutputStream outputStream = new FileOutputStream(GeyserConnector.getInstance().getBootstrap().getConfigFolder().resolve("dump.json").toFile());
- outputStream.write(dumpData.getBytes());
- outputStream.close();
- } catch (IOException e) {
- sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.commands.dump.write_error", sender.getLocale()));
- connector.getLogger().error(LanguageUtils.getLocaleStringLog("geyser.commands.dump.write_error_short"), e);
- return;
- }
-
- uploadedDumpUrl = "dump.json";
- } else {
- sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.dump.uploading", sender.getLocale()));
-
- String response;
- JsonNode responseNode;
- try {
- response = WebUtils.post(DUMP_URL + "documents", dumpData);
- responseNode = MAPPER.readTree(response);
- } catch (IOException e) {
- sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.commands.dump.upload_error", sender.getLocale()));
- connector.getLogger().error(LanguageUtils.getLocaleStringLog("geyser.commands.dump.upload_error_short"), e);
- return;
- }
-
- if (!responseNode.has("key")) {
- sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.commands.dump.upload_error_short", sender.getLocale()) + ": " + (responseNode.has("message") ? responseNode.get("message").asText() : response));
- return;
- }
-
- uploadedDumpUrl = DUMP_URL + responseNode.get("key").asText();
- }
-
- sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.dump.message", sender.getLocale()) + " " + ChatColor.DARK_AQUA + uploadedDumpUrl);
- if (!sender.isConsole()) {
- connector.getLogger().info(LanguageUtils.getLocaleStringLog("geyser.commands.dump.created", sender.getName(), uploadedDumpUrl));
- }
- }
-
- @Override
- public List getSubCommands() {
- return Arrays.asList("offline", "full");
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/HelpCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/HelpCommand.java
index 7ab3aec3..6acb7822 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/HelpCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/HelpCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,11 +25,10 @@
package org.geysermc.connector.command.defaults;
+import org.geysermc.common.ChatColor;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.common.ChatColor;
-import org.geysermc.connector.utils.LanguageUtils;
import java.util.Collections;
import java.util.List;
@@ -49,14 +48,9 @@ public class HelpCommand extends GeyserCommand {
@Override
public void execute(CommandSender sender, String[] args) {
- int page = 1;
- int maxPage = 1;
- String header = LanguageUtils.getPlayerLocaleString("geyser.commands.help.header", sender.getLocale(), page, maxPage);
-
- sender.sendMessage(header);
+ sender.sendMessage("---- Showing Help For: Geyser (Page 1/1) ----");
Map cmds = connector.getCommandManager().getCommands();
List commands = connector.getCommandManager().getCommands().keySet().stream().sorted().collect(Collectors.toList());
- commands.forEach(cmd -> sender.sendMessage(ChatColor.YELLOW + "/geyser " + cmd + ChatColor.WHITE + ": " +
- LanguageUtils.getPlayerLocaleString(cmds.get(cmd).getDescription(), sender.getLocale())));
+ commands.forEach(cmd -> sender.sendMessage(ChatColor.YELLOW + "/geyser " + cmd + ChatColor.WHITE + ": " + cmds.get(cmd).getDescription()));
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/ListCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/ListCommand.java
index f52ab7f3..21fa4253 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/ListCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/ListCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,17 +25,17 @@
package org.geysermc.connector.command.defaults;
+import org.geysermc.common.ChatColor;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.command.GeyserCommand;
import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.utils.LanguageUtils;
import java.util.stream.Collectors;
public class ListCommand extends GeyserCommand {
- private final GeyserConnector connector;
+ private GeyserConnector connector;
public ListCommand(GeyserConnector connector, String name, String description, String permission) {
super(name, description, permission);
@@ -45,11 +45,6 @@ public class ListCommand extends GeyserCommand {
@Override
public void execute(CommandSender sender, String[] args) {
- String message = "";
- message = LanguageUtils.getPlayerLocaleString("geyser.commands.list.message", sender.getLocale(),
- connector.getPlayers().size(),
- connector.getPlayers().stream().map(GeyserSession::getName).collect(Collectors.joining(" ")));
-
- sender.sendMessage(message);
+ sender.sendMessage(ChatColor.YELLOW + "Online Players (" + connector.getPlayers().size() + "): " + ChatColor.WHITE + connector.getPlayers().values().stream().map(GeyserSession::getName).collect(Collectors.joining(" ")));
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java
index d6916700..a49506b0 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -36,7 +36,7 @@ import org.geysermc.connector.network.session.GeyserSession;
public class OffhandCommand extends GeyserCommand {
- private final GeyserConnector connector;
+ private GeyserConnector connector;
public OffhandCommand(GeyserConnector connector, String name, String description, String permission) {
super(name, description, permission);
@@ -58,8 +58,8 @@ public class OffhandCommand extends GeyserCommand {
session.sendDownstreamPacket(releaseItemPacket);
return;
}
- // Needed for Spigot - sender is not an instance of GeyserSession
- for (GeyserSession session : connector.getPlayers()) {
+ // Needed for Bukkit - sender is not an instance of GeyserSession
+ for (GeyserSession session : connector.getPlayers().values()) {
if (sender.getName().equals(session.getPlayerEntity().getUsername())) {
ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(0,0,0),
BlockFace.DOWN);
@@ -68,9 +68,4 @@ public class OffhandCommand extends GeyserCommand {
}
}
}
-
- @Override
- public boolean isExecutableOnConsole() {
- return false;
- }
}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java
index 798dd7a7..c38a0c23 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/ReloadCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -25,12 +25,12 @@
package org.geysermc.connector.command.defaults;
+import org.geysermc.common.ChatColor;
import org.geysermc.common.PlatformType;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.CommandSender;
import org.geysermc.connector.command.GeyserCommand;
import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.utils.LanguageUtils;
public class ReloadCommand extends GeyserCommand {
@@ -46,13 +46,9 @@ public class ReloadCommand extends GeyserCommand {
if (!sender.isConsole() && connector.getPlatformType() == PlatformType.STANDALONE) {
return;
}
-
- String message = LanguageUtils.getPlayerLocaleString("geyser.commands.reload.message", sender.getLocale());
-
- sender.sendMessage(message);
-
- for (GeyserSession session : connector.getPlayers()) {
- session.disconnect(LanguageUtils.getPlayerLocaleString("geyser.commands.reload.kick", session.getLocale()));
+ sender.sendMessage(ChatColor.YELLOW + "Reloading Geyser configurations... all connected bedrock clients will be kicked.");
+ for (GeyserSession session : connector.getPlayers().values()) {
+ session.disconnect("Geyser has been reloaded... sorry for the inconvenience!");
}
connector.reload();
}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/SettingsCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/SettingsCommand.java
deleted file mode 100644
index 5e28e985..00000000
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/SettingsCommand.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.command.defaults;
-
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.network.session.GeyserSession;
-import org.geysermc.connector.utils.SettingsUtils;
-
-public class SettingsCommand extends GeyserCommand {
-
- private final GeyserConnector connector;
-
- public SettingsCommand(GeyserConnector connector, String name, String description, String permission) {
- super(name, description, permission);
-
- this.connector = connector;
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- // Make sure the sender is a Bedrock edition client
- GeyserSession session = null;
- if (sender instanceof GeyserSession) {
- session = (GeyserSession) sender;
- } else {
- // Needed for Spigot - sender is not an instance of GeyserSession
- for (GeyserSession otherSession : connector.getPlayers()) {
- if (sender.getName().equals(otherSession.getPlayerEntity().getUsername())) {
- session = otherSession;
- break;
- }
- }
- }
- if (session == null) return;
- SettingsUtils.buildForm(session);
- session.sendForm(session.getSettingsForm(), SettingsUtils.SETTINGS_FORM_ID);
- }
-
- @Override
- public boolean isExecutableOnConsole() {
- return false;
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/StatisticsCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/StatisticsCommand.java
deleted file mode 100644
index 920ec50c..00000000
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/StatisticsCommand.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.command.defaults;
-
-import com.github.steveice10.mc.protocol.data.game.ClientRequest;
-import com.github.steveice10.mc.protocol.packet.ingame.client.ClientRequestPacket;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.network.session.GeyserSession;
-
-public class StatisticsCommand extends GeyserCommand {
-
- private final GeyserConnector connector;
-
- public StatisticsCommand(GeyserConnector connector, String name, String description, String permission) {
- super(name, description, permission);
-
- this.connector = connector;
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- if (sender.isConsole()) {
- return;
- }
-
- // Make sure the sender is a Bedrock edition client
- GeyserSession session = null;
- if (sender instanceof GeyserSession) {
- session = (GeyserSession) sender;
- } else {
- // Needed for Spigot - sender is not an instance of GeyserSession
- for (GeyserSession otherSession : connector.getPlayers()) {
- if (sender.getName().equals(otherSession.getPlayerEntity().getUsername())) {
- session = otherSession;
- break;
- }
- }
- }
- if (session == null) return;
- session.setWaitingForStatistics(true);
- ClientRequestPacket clientRequestPacket = new ClientRequestPacket(ClientRequest.STATS);
- session.sendDownstreamPacket(clientRequestPacket);
- }
-
- @Override
- public boolean isExecutableOnConsole() {
- return false;
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/StopCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/StopCommand.java
index b192c9e9..2222cdef 100644
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/StopCommand.java
+++ b/connector/src/main/java/org/geysermc/connector/command/defaults/StopCommand.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
+ * Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -49,6 +49,10 @@ public class StopCommand extends GeyserCommand {
return;
}
- connector.getBootstrap().onDisable();
+ connector.shutdown();
+
+ if (connector.getPlatformType() == PlatformType.STANDALONE) {
+ System.exit(0);
+ }
}
}
diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java
deleted file mode 100644
index 1f807cf6..00000000
--- a/connector/src/main/java/org/geysermc/connector/command/defaults/VersionCommand.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.command.defaults;
-
-import com.github.steveice10.mc.protocol.MinecraftConstants;
-import com.nukkitx.protocol.bedrock.BedrockPacketCodec;
-import org.geysermc.connector.GeyserConnector;
-import org.geysermc.connector.command.CommandSender;
-import org.geysermc.connector.command.GeyserCommand;
-import org.geysermc.connector.common.ChatColor;
-import org.geysermc.connector.network.BedrockProtocol;
-import org.geysermc.connector.utils.FileUtils;
-import org.geysermc.connector.utils.LanguageUtils;
-import org.geysermc.connector.utils.WebUtils;
-
-import java.io.IOException;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.Properties;
-
-public class VersionCommand extends GeyserCommand {
-
- public GeyserConnector connector;
-
- public VersionCommand(GeyserConnector connector, String name, String description, String permission) {
- super(name, description, permission);
- this.connector = connector;
- }
-
- @Override
- public void execute(CommandSender sender, String[] args) {
- String bedrockVersions;
- List supportedCodecs = BedrockProtocol.SUPPORTED_BEDROCK_CODECS;
- if (supportedCodecs.size() > 1) {
- bedrockVersions = supportedCodecs.get(0).getMinecraftVersion() + " - " + supportedCodecs.get(supportedCodecs.size() - 1).getMinecraftVersion();
- } else {
- bedrockVersions = BedrockProtocol.DEFAULT_BEDROCK_CODEC.getMinecraftVersion();
- }
-
- sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.version.version", sender.getLocale(), GeyserConnector.NAME, GeyserConnector.VERSION, MinecraftConstants.GAME_VERSION, bedrockVersions));
-
- // Disable update checking in dev mode
- //noinspection ConstantConditions - changes in production
- if (!GeyserConnector.VERSION.equals("DEV")) {
- sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.version.checking", sender.getLocale()));
- try {
- Properties gitProp = new Properties();
- gitProp.load(FileUtils.getResource("git.properties"));
-
- String buildXML = WebUtils.getBody("https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/" + URLEncoder.encode(gitProp.getProperty("git.branch"), StandardCharsets.UTF_8.toString()) + "/lastSuccessfulBuild/api/xml?xpath=//buildNumber");
- if (buildXML.startsWith("")) {
- int latestBuildNum = Integer.parseInt(buildXML.replaceAll("<(\\\\)?(/)?buildNumber>", "").trim());
- int buildNum = Integer.parseInt(gitProp.getProperty("git.build.number"));
- if (latestBuildNum == buildNum) {
- sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.version.no_updates", sender.getLocale()));
- } else {
- sender.sendMessage(LanguageUtils.getPlayerLocaleString("geyser.commands.version.outdated", sender.getLocale(), (latestBuildNum - buildNum), "https://ci.geysermc.org/"));
- }
- } else {
- throw new AssertionError("buildNumber missing");
- }
- } catch (IOException | AssertionError | NumberFormatException e) {
- GeyserConnector.getInstance().getLogger().error(LanguageUtils.getLocaleStringLog("geyser.commands.version.failed"), e);
- sender.sendMessage(ChatColor.RED + LanguageUtils.getPlayerLocaleString("geyser.commands.version.failed", sender.getLocale()));
- }
- }
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/common/AuthType.java b/connector/src/main/java/org/geysermc/connector/common/AuthType.java
deleted file mode 100644
index 253bd6a5..00000000
--- a/connector/src/main/java/org/geysermc/connector/common/AuthType.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.common;
-
-import lombok.Getter;
-
-@Getter
-public enum AuthType {
- OFFLINE,
- ONLINE,
- FLOODGATE;
-
- public static final AuthType[] VALUES = values();
-
- public static AuthType getById(int id) {
- return id < VALUES.length ? VALUES[id] : OFFLINE;
- }
-
- /**
- * Convert the AuthType string (from config) to the enum, OFFLINE on fail
- *
- * @param name AuthType string
- *
- * @return The converted AuthType
- */
- public static AuthType getByName(String name) {
- String upperCase = name.toUpperCase();
- for (AuthType type : VALUES) {
- if (type.name().equals(upperCase)) {
- return type;
- }
- }
- return OFFLINE;
- }
-}
\ No newline at end of file
diff --git a/connector/src/main/java/org/geysermc/connector/common/main/IGeyserMain.java b/connector/src/main/java/org/geysermc/connector/common/main/IGeyserMain.java
deleted file mode 100644
index 3f674d7f..00000000
--- a/connector/src/main/java/org/geysermc/connector/common/main/IGeyserMain.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.common.main;
-
-import javax.swing.*;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-import java.util.Locale;
-import java.util.Scanner;
-
-public class IGeyserMain {
-
- /**
- * Displays the run help message in the console and a message box if running with a gui
- */
- public void displayMessage() {
- String message = createMessage();
-
- if (System.console() == null && !isHeadless()) {
- JOptionPane.showMessageDialog(null, message, "GeyserMC Plugin: " + this.getPluginType(), JOptionPane.ERROR_MESSAGE);
- }
-
- printMessage(message);
- }
-
- /**
- * Load and format the run help text
- *
- * @return The formatted message
- */
- private String createMessage() {
- String message = "";
-
- InputStream helpStream = IGeyserMain.class.getClassLoader().getResourceAsStream("languages/run-help/" + Locale.getDefault().toString() + ".txt");
-
- if (helpStream == null) {
- helpStream = IGeyserMain.class.getClassLoader().getResourceAsStream("languages/run-help/en_US.txt");
- }
-
- Scanner help = new Scanner(helpStream).useDelimiter("\\Z");
- String line = "";
- while (help.hasNext()) {
- line = help.next();
-
- line = line.replace("${plugin_type}", this.getPluginType());
- line = line.replace("${plugin_folder}", this.getPluginFolder());
-
- message += line + "\n";
- }
-
- return message;
- }
-
- /**
- * Check if we are in a headless environment
- *
- * @return Are we in a headless environment?
- */
- private boolean isHeadless() {
- try {
- Class> graphicsEnvironment = Class.forName("java.awt.GraphicsEnvironment");
- Method isHeadless = graphicsEnvironment.getDeclaredMethod("isHeadless");
- return (Boolean)isHeadless.invoke(null);
- } catch (Exception ex) { }
-
- return true;
- }
-
- /**
- * Simply print a message to console
- *
- * @param message The message to print
- */
- private void printMessage(String message) {
- System.out.print(message);
- }
-
- /**
- * Get the platform the plugin is for
- *
- * @return The string representation of the plugin platforms name
- */
- public String getPluginType() {
- return "unknown";
- }
-
- /**
- * Get the folder name the plugin should go into
- *
- * @return The string representation of the folder
- */
- public String getPluginFolder() {
- return "unknown";
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/common/ping/GeyserPingInfo.java b/connector/src/main/java/org/geysermc/connector/common/ping/GeyserPingInfo.java
deleted file mode 100644
index 4f86ddfb..00000000
--- a/connector/src/main/java/org/geysermc/connector/common/ping/GeyserPingInfo.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.common.ping;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonSetter;
-import com.fasterxml.jackson.databind.JsonNode;
-import lombok.Data;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-@Data
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class GeyserPingInfo {
-
- private String description;
-
- private Players players;
- private Version version;
-
- @JsonIgnore
- private Collection playerList = new ArrayList<>();
-
- public GeyserPingInfo() {
- }
-
- public GeyserPingInfo(String description, Players players, Version version) {
- this.description = description;
- this.players = players;
- this.version = version;
- }
-
- @JsonSetter("description")
- void setDescription(JsonNode description) {
- this.description = description.toString();
- }
-
- @Data
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class Players {
-
- private int max;
- private int online;
-
- public Players() {
- }
-
- public Players(int max, int online) {
- this.max = max;
- this.online = online;
- }
- }
-
- @Data
- public static class Version {
-
- private String name;
- private int protocol;
-
- public Version() {
- }
-
- public Version(String name, int protocol) {
- this.name = name;
- this.protocol = protocol;
- }
- }
-}
diff --git a/connector/src/main/java/org/geysermc/connector/common/serializer/AsteriskSerializer.java b/connector/src/main/java/org/geysermc/connector/common/serializer/AsteriskSerializer.java
deleted file mode 100644
index 0b723817..00000000
--- a/connector/src/main/java/org/geysermc/connector/common/serializer/AsteriskSerializer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @author GeyserMC
- * @link https://github.com/GeyserMC/Geyser
- */
-
-package org.geysermc.connector.common.serializer;
-
-import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.BeanProperty;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.ser.ContextualSerializer;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-
-import java.io.IOException;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.util.Optional;
-
-public class AsteriskSerializer extends StdSerializer