-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit be202eb
Showing
34 changed files
with
1,095 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- 'v*.*.*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
- id: sha | ||
run: | | ||
SHA=${{ github.sha }} | ||
echo "::set-output name=sha8::${SHA:0:8}" | ||
- uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: | | ||
build | ||
-Pversion=0.0.0+${{ steps.sha.outputs.sha8 }} | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: Artifacts (${{ steps.sha.outputs.sha8 }}) | ||
path: | | ||
bungee/build/libs/MapModCompanion-Bungee.jar | ||
spigot/build/libs/MapModCompanion-Spigot.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
- name: Detect version from the tag name | ||
id: version | ||
run: | | ||
TAG=${{ github.ref }} | ||
VERSION=${TAG#refs/tags/v} | ||
echo "::set-output name=version::$VERSION" | ||
IS_PRE_RELEASE=$([[ $VERSION =~ .+(alpha|beta|pre|rc).* ]] && echo "true" || echo "false") | ||
echo "::set-output name=pre-release::$IS_PRE_RELEASE" | ||
- uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: | | ||
build | ||
-Pversion=${{ steps.version.outputs.version }} | ||
- uses: softprops/action-gh-release@v1 | ||
with: | ||
name: ${{ steps.version.outputs.version }} | ||
prerelease: ${{ steps.version.outputs.pre-release }} | ||
generate_release_notes: true | ||
draft: true | ||
files: | | ||
bungee/build/libs/MapModCompanion-Bungee.jar | ||
spigot/build/libs/MapModCompanion-Spigot.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
debug*/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Artur Khusainov | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Companion for map mods | ||
Unofficial BungeeCord and Spigot (Paper) companion plugin for | ||
[Xaero's Minimap](https://www.curseforge.com/minecraft/mc-mods/xaeros-minimap) | ||
(and their [World Map](https://www.curseforge.com/minecraft/mc-mods/xaeros-world-map)), | ||
[JourneyMap](https://www.curseforge.com/minecraft/mc-mods/journeymap) and | ||
VoxelMap. | ||
|
||
This plugin fixes Multi-world detection in multiplayer by simulating mod presence on | ||
the server side. | ||
|
||
This plugin was inspired by @kosma's [worldnamepacket](https://github.com/kosma/worldnamepacket), | ||
which supported Velocity, Fabric and Spigot at the time of writing. | ||
|
||
## Support table | ||
| Mod | Version | Status | | ||
|------------------------------------------------------------------------------------|-----------------------------|-------------| | ||
| [Xaero's Minimap](https://www.curseforge.com/minecraft/mc-mods/xaeros-minimap) | v22.13.2 (1.19.2) | ✅ Supported | | ||
| [Xaero's World Map](https://www.curseforge.com/minecraft/mc-mods/xaeros-world-map) | v22.13.2 (1.19.2) | ✅ Supported | | ||
| [JourneyMap](https://www.curseforge.com/minecraft/mc-mods/journeymap) | 5.9.0beta2 (1.18.2, 1.19.2) | ✅ Supported | | ||
| VoxelMap (Refresh-MC) | 1.11.10 (1.19.2) | ✅ Supported | | ||
|
||
## Installation | ||
1. Download the latest release from [Releases](https://github.com/turikhay/xaeros-minimap-companion/releases) page | ||
2. Put each of them into the corresponding plugins folder | ||
3. That's it. No configuration required. You can restart your servers now. | ||
|
||
⚠️ **NOTE** Spigot plugin can be used without BungeeCord counterpart, but it's highly recommended to install | ||
plugins on both sides. On the contrary, BungeeCord plugin is useless if you don't install Spigot plugin on | ||
downstream servers. | ||
|
||
## Alternatives | ||
- [worldnamepacket](https://github.com/kosma/worldnamepacket) (Velocity, Fabric, Spigot) | ||
- [JourneyMap Server](https://www.curseforge.com/minecraft/mc-mods/journeymap-server) (Spigot) | ||
- [Minimap server](https://github.com/Ewpratten/MinimapServer) (Spigot) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
plugins { | ||
id 'java' | ||
id 'kr.entree.spigradle' version '2.4.2' apply false | ||
id 'kr.entree.spigradle.bungee' version '2.4.2' apply false | ||
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false | ||
} | ||
|
||
group 'com.turikhay.mc' | ||
|
||
subprojects { | ||
apply plugin: 'java' | ||
|
||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
|
||
group rootProject.group | ||
version rootProject.version | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.7.1' | ||
|
||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' | ||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' | ||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
plugins { | ||
id 'kr.entree.spigradle.bungee' | ||
id 'com.github.johnrengelman.shadow' | ||
} | ||
|
||
bungee { | ||
name 'MapModCompanion' | ||
author 'turikhay' | ||
} | ||
|
||
assemble { | ||
dependsOn shadowJar | ||
} | ||
|
||
shadowJar { | ||
archiveName("MapModCompanion-Bungee.jar") | ||
} | ||
|
||
dependencies { | ||
implementation project(":common") | ||
compileOnly bungeecord() | ||
} |
20 changes: 20 additions & 0 deletions
20
bungee/src/main/java/com/turikhay/mc/mapmodcompanion/bungee/CompanionBungee.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.turikhay.mc.mapmodcompanion.bungee; | ||
|
||
import net.md_5.bungee.api.plugin.Listener; | ||
import net.md_5.bungee.api.plugin.Plugin; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class CompanionBungee extends Plugin implements Listener { | ||
|
||
List<PacketHandler<?, ?>> handlers = Arrays.asList( | ||
new XaerosPacketHandler(this), | ||
new WorldIdPacketHandler(this) | ||
); | ||
|
||
@Override | ||
public void onEnable() { | ||
handlers.forEach(PacketHandler::init); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
bungee/src/main/java/com/turikhay/mc/mapmodcompanion/bungee/PacketHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.turikhay.mc.mapmodcompanion.bungee; | ||
|
||
import com.turikhay.mc.mapmodcompanion.IdMessagePacket; | ||
import net.md_5.bungee.api.connection.ProxiedPlayer; | ||
import net.md_5.bungee.api.connection.Server; | ||
import net.md_5.bungee.api.event.PluginMessageEvent; | ||
import net.md_5.bungee.api.plugin.Listener; | ||
import net.md_5.bungee.event.EventHandler; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.Arrays; | ||
|
||
public abstract class PacketHandler<Id2 extends IdMessagePacket<?>, Id extends IdMessagePacket<Id2>> implements Listener { | ||
private final String channelName; | ||
private final CompanionBungee plugin; | ||
|
||
public PacketHandler(String channelName, CompanionBungee plugin) { | ||
this.channelName = channelName; | ||
this.plugin = plugin; | ||
} | ||
|
||
public void init() { | ||
plugin.getProxy().registerChannel(channelName); | ||
plugin.getProxy().getPluginManager().registerListener(plugin, this); | ||
} | ||
|
||
/* | ||
Intercept world IDs received from the downstream servers | ||
in order to (hopefully) resolve ID conflicts that may occur | ||
*/ | ||
@EventHandler | ||
public void onPluginMessageSentToPlayer(PluginMessageEvent event) { | ||
if (!event.getTag().equals(channelName)) { | ||
return; | ||
} | ||
if (!(event.getSender() instanceof Server)) { | ||
return; | ||
} | ||
Server server = (Server) event.getSender(); | ||
if (!(event.getReceiver() instanceof ProxiedPlayer)) { | ||
return; | ||
} | ||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver(); | ||
byte[] data = event.getData(); | ||
Id oldId = tryRead(data); | ||
if (oldId == null) { | ||
plugin.getLogger().warning("Possibly corrupted packet from " + channelName + ": " + Arrays.toString(data)); | ||
return; | ||
} | ||
event.setCancelled(true); | ||
Id2 newId = oldId.combineWith(getId(server)); | ||
player.sendData(channelName, IdMessagePacket.bytesPacket(newId)); | ||
} | ||
|
||
@Nullable | ||
public abstract Id tryRead(byte[] data); | ||
public abstract Id2 getId(Server server); | ||
} |
25 changes: 25 additions & 0 deletions
25
bungee/src/main/java/com/turikhay/mc/mapmodcompanion/bungee/WorldIdPacketHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.turikhay.mc.mapmodcompanion.bungee; | ||
|
||
import com.turikhay.mc.mapmodcompanion.worldid.WorldId; | ||
import net.md_5.bungee.api.connection.Server; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import static com.turikhay.mc.mapmodcompanion.worldid.WorldIdCompanion.WORLD_ID_CHANNEL_NAME; | ||
|
||
public class WorldIdPacketHandler extends PacketHandler<WorldId, WorldId> { | ||
|
||
public WorldIdPacketHandler(CompanionBungee plugin) { | ||
super(WORLD_ID_CHANNEL_NAME, plugin); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public WorldId tryRead(byte[] data) { | ||
return WorldId.tryRead(data); | ||
} | ||
|
||
@Override | ||
public WorldId getId(Server server) { | ||
return WorldId.createTruncatingLength(server.getInfo().getName()); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
bungee/src/main/java/com/turikhay/mc/mapmodcompanion/bungee/XaerosPacketHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.turikhay.mc.mapmodcompanion.bungee; | ||
|
||
import com.turikhay.mc.mapmodcompanion.xaeros.LevelMapProperties; | ||
import net.md_5.bungee.api.connection.Server; | ||
import net.md_5.bungee.api.plugin.Listener; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import static com.turikhay.mc.mapmodcompanion.xaeros.XaerosCompanion.XAEROS_CHANNEL_NAME; | ||
|
||
public class XaerosPacketHandler extends PacketHandler<LevelMapProperties, LevelMapProperties> implements Listener { | ||
|
||
public XaerosPacketHandler(CompanionBungee plugin) { | ||
super(XAEROS_CHANNEL_NAME, plugin); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public LevelMapProperties tryRead(byte[] data) { | ||
return LevelMapProperties.tryRead(data); | ||
} | ||
|
||
@Override | ||
public LevelMapProperties getId(Server server) { | ||
return new LevelMapProperties(server.getInfo().getName().hashCode()); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
bungee/src/main/java/com/turikhay/mc/mapmodcompanion/bungee/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@ParametersAreNonnullByDefault | ||
package com.turikhay.mc.mapmodcompanion.bungee; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
Empty file.
20 changes: 20 additions & 0 deletions
20
common/src/main/java/com/turikhay/mc/mapmodcompanion/IdMessagePacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.turikhay.mc.mapmodcompanion; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.DataOutputStream; | ||
import java.io.IOException; | ||
|
||
public interface IdMessagePacket<CombinableWith extends IdMessagePacket<?>> { | ||
CombinableWith combineWith(CombinableWith packet); | ||
void constructPacket(DataOutputStream out) throws IOException; | ||
|
||
static byte[] bytesPacket(IdMessagePacket<?> id) { | ||
ByteArrayOutputStream buffer = new ByteArrayOutputStream(); | ||
try (DataOutputStream out = new DataOutputStream(buffer)) { | ||
id.constructPacket(out); | ||
} catch (IOException e) { | ||
throw new Error(e); | ||
} | ||
return buffer.toByteArray(); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
common/src/main/java/com/turikhay/mc/mapmodcompanion/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@ParametersAreNonnullByDefault | ||
package com.turikhay.mc.mapmodcompanion; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
Oops, something went wrong.