mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-06-26 06:24:57 +02:00
Merge branch 'master' into fix/heightmaps
This commit is contained in:
commit
069e1747fa
20
.github/workflows/build.yml
vendored
20
.github/workflows/build.yml
vendored
|
@ -9,6 +9,7 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- "*"
|
- "*"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
@ -18,18 +19,15 @@ jobs:
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0 # needed for versioning
|
fetch-depth: 0 # needed for versioning
|
||||||
- name: Set up JDK 1.17
|
- name: Set up Java
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: 17
|
distribution: 'temurin'
|
||||||
- uses: actions/cache@v3
|
java-version: |
|
||||||
with:
|
11
|
||||||
path: |
|
16
|
||||||
~/.gradle/caches
|
17
|
||||||
~/.gradle/wrapper
|
cache: 'gradle'
|
||||||
key: "${{ runner.os }}-bluemap-${{ hashFiles('**/*.gradle*') }}"
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-bluemap-
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew clean spotlessCheck test build
|
run: ./gradlew clean spotlessCheck test build
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
|
|
19
.github/workflows/publish.yml
vendored
19
.github/workflows/publish.yml
vendored
|
@ -11,18 +11,15 @@ jobs:
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0 # needed for versioning
|
fetch-depth: 0 # needed for versioning
|
||||||
- name: Set up JDK 1.17
|
- name: Set up Java
|
||||||
uses: actions/setup-java@v1
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: 17
|
distribution: 'temurin'
|
||||||
- uses: actions/cache@v2
|
java-version: |
|
||||||
with:
|
11
|
||||||
path: |
|
16
|
||||||
~/.gradle/caches
|
17
|
||||||
~/.gradle/wrapper
|
cache: 'gradle'
|
||||||
key: "${{ runner.os }}-bluemap-${{ hashFiles('**/*.gradle*') }}"
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-bluemap-
|
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
env:
|
env:
|
||||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2cdc5c8a8770a8b26fcdd4ad6d742b13cc4770f5
|
Subproject commit 5c3624832f17334f7b82dd40d7dbb6ba041163c4
|
|
@ -363,6 +363,7 @@ private ConfigTemplate createOverworldMapTemplate(String name, Path worldFolder,
|
||||||
.setVariable("sorting", "" + index)
|
.setVariable("sorting", "" + index)
|
||||||
.setVariable("world", formatPath(worldFolder))
|
.setVariable("world", formatPath(worldFolder))
|
||||||
.setVariable("sky-color", "#7dabff")
|
.setVariable("sky-color", "#7dabff")
|
||||||
|
.setVariable("void-color", "#000000")
|
||||||
.setVariable("ambient-light", "0.1")
|
.setVariable("ambient-light", "0.1")
|
||||||
.setVariable("world-sky-light", "15")
|
.setVariable("world-sky-light", "15")
|
||||||
.setVariable("remove-caves-below-y", "55")
|
.setVariable("remove-caves-below-y", "55")
|
||||||
|
@ -376,6 +377,7 @@ private ConfigTemplate createNetherMapTemplate(String name, Path worldFolder, in
|
||||||
.setVariable("sorting", "" + (100 + index))
|
.setVariable("sorting", "" + (100 + index))
|
||||||
.setVariable("world", formatPath(worldFolder))
|
.setVariable("world", formatPath(worldFolder))
|
||||||
.setVariable("sky-color", "#290000")
|
.setVariable("sky-color", "#290000")
|
||||||
|
.setVariable("void-color", "#000000")
|
||||||
.setVariable("ambient-light", "0.6")
|
.setVariable("ambient-light", "0.6")
|
||||||
.setVariable("world-sky-light", "0")
|
.setVariable("world-sky-light", "0")
|
||||||
.setVariable("remove-caves-below-y", "-10000")
|
.setVariable("remove-caves-below-y", "-10000")
|
||||||
|
@ -389,6 +391,7 @@ private ConfigTemplate createEndMapTemplate(String name, Path worldFolder, int i
|
||||||
.setVariable("sorting", "" + (200 + index))
|
.setVariable("sorting", "" + (200 + index))
|
||||||
.setVariable("world", formatPath(worldFolder))
|
.setVariable("world", formatPath(worldFolder))
|
||||||
.setVariable("sky-color", "#080010")
|
.setVariable("sky-color", "#080010")
|
||||||
|
.setVariable("void-color", "#000000")
|
||||||
.setVariable("ambient-light", "0.6")
|
.setVariable("ambient-light", "0.6")
|
||||||
.setVariable("world-sky-light", "0")
|
.setVariable("world-sky-light", "0")
|
||||||
.setVariable("remove-caves-below-y", "-10000")
|
.setVariable("remove-caves-below-y", "-10000")
|
||||||
|
|
|
@ -49,6 +49,7 @@ public class MapConfig implements MapSettings {
|
||||||
private Vector2i startPos = null;
|
private Vector2i startPos = null;
|
||||||
|
|
||||||
private String skyColor = "#7dabff";
|
private String skyColor = "#7dabff";
|
||||||
|
private String voidColor = "#000000";
|
||||||
|
|
||||||
private float ambientLight = 0;
|
private float ambientLight = 0;
|
||||||
|
|
||||||
|
@ -112,6 +113,11 @@ public String getSkyColor() {
|
||||||
return skyColor;
|
return skyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVoidColor() {
|
||||||
|
return voidColor;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getAmbientLight() {
|
public float getAmbientLight() {
|
||||||
return ambientLight;
|
return ambientLight;
|
||||||
|
|
|
@ -24,11 +24,16 @@ sorting: ${sorting}
|
||||||
# This defaults to the world-spawn if you don't set it.
|
# This defaults to the world-spawn if you don't set it.
|
||||||
#start-pos: {x:500, z:-820}
|
#start-pos: {x:500, z:-820}
|
||||||
|
|
||||||
# The color of thy sky as a hex-color
|
# The color of the sky as a hex-color
|
||||||
# You can change this at any time.
|
# You can change this at any time.
|
||||||
# Default is "#7dabff"
|
# Default is "#7dabff"
|
||||||
sky-color: "${sky-color}"
|
sky-color: "${sky-color}"
|
||||||
|
|
||||||
|
# The color of the void as a hex-color
|
||||||
|
# You can change this at any time.
|
||||||
|
# Default is "#000000"
|
||||||
|
void-color: "${void-color}"
|
||||||
|
|
||||||
# Defines the ambient light-strength that every block is receiving, regardless of the sunlight/blocklight.
|
# Defines the ambient light-strength that every block is receiving, regardless of the sunlight/blocklight.
|
||||||
# 0 is no ambient light, 1 is fully lighted.
|
# 0 is no ambient light, 1 is fully lighted.
|
||||||
# You can change this at any time.
|
# You can change this at any time.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<Group :title="$t('controls.title')">
|
<Group :title="$t('controls.title')">
|
||||||
<SimpleButton :active="appState.controls.state === 'perspective'" @action="$bluemap.setPerspectiveView(500, appState.controls.state === 'free' ? 100 : 0)">{{$t('controls.perspective.button')}}</SimpleButton>
|
<SimpleButton :active="appState.controls.state === 'perspective'" @action="$bluemap.setPerspectiveView(500, appState.controls.state === 'free' ? 100 : 0)">{{$t('controls.perspective.button')}}</SimpleButton>
|
||||||
<SimpleButton :active="appState.controls.state === 'flat'" @action="$bluemap.setFlatView(500, appState.controls.state === 'free' ? 100 : 0)">{{$t('controls.flatView.button')}}</SimpleButton>
|
<SimpleButton :active="appState.controls.state === 'flat'" @action="$bluemap.setFlatView(500, appState.controls.state === 'free' ? 100 : 0)">{{$t('controls.flatView.button')}}</SimpleButton>
|
||||||
<SimpleButton :active="appState.controls.state === 'free'" @action="$bluemap.setFreeFlight(500)">{{$t('controls.freeFlight.button')}}</SimpleButton>
|
<SimpleButton v-if="appState.controls.enableFreeFlight" :active="appState.controls.state === 'free'" @action="$bluemap.setFreeFlight(500)">{{$t('controls.freeFlight.button')}}</SimpleButton>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Group :title="$t('lighting.title')">
|
<Group :title="$t('lighting.title')">
|
||||||
|
|
|
@ -60,6 +60,7 @@ export class MapViewer {
|
||||||
sunlightStrength: { value: 1 },
|
sunlightStrength: { value: 1 },
|
||||||
ambientLight: { value: 0 },
|
ambientLight: { value: 0 },
|
||||||
skyColor: { value: new Color(0.5, 0.5, 1) },
|
skyColor: { value: new Color(0.5, 0.5, 1) },
|
||||||
|
voidColor: { value: new Color(0, 0, 0) },
|
||||||
hiresTileMap: {
|
hiresTileMap: {
|
||||||
value: {
|
value: {
|
||||||
map: null,
|
map: null,
|
||||||
|
@ -393,6 +394,7 @@ export class MapViewer {
|
||||||
|
|
||||||
this.data.uniforms.distance.value = this.controlsManager.distance;
|
this.data.uniforms.distance.value = this.controlsManager.distance;
|
||||||
this.data.uniforms.skyColor.value = map.data.skyColor;
|
this.data.uniforms.skyColor.value = map.data.skyColor;
|
||||||
|
this.data.uniforms.voidColor.value = map.data.voidColor;
|
||||||
this.data.uniforms.ambientLight.value = map.data.ambientLight;
|
this.data.uniforms.ambientLight.value = map.data.ambientLight;
|
||||||
this.data.uniforms.hiresTileMap.value.map = map.hiresTileManager.tileMap.texture;
|
this.data.uniforms.hiresTileMap.value.map = map.hiresTileManager.tileMap.texture;
|
||||||
this.data.uniforms.hiresTileMap.value.scale.set(map.data.hires.tileSize.x, map.data.hires.tileSize.z);
|
this.data.uniforms.hiresTileMap.value.scale.set(map.data.hires.tileSize.x, map.data.hires.tileSize.z);
|
||||||
|
|
|
@ -63,6 +63,7 @@ export class Map {
|
||||||
name: id,
|
name: id,
|
||||||
startPos: {x: 0, z: 0},
|
startPos: {x: 0, z: 0},
|
||||||
skyColor: new Color(),
|
skyColor: new Color(),
|
||||||
|
voidColor: new Color(),
|
||||||
ambientLight: 0,
|
ambientLight: 0,
|
||||||
hires: {
|
hires: {
|
||||||
tileSize: {x: 32, z: 32},
|
tileSize: {x: 32, z: 32},
|
||||||
|
@ -150,6 +151,14 @@ export class Map {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (worldSettings.voidColor && worldSettings.voidColor.length >= 3) {
|
||||||
|
this.data.voidColor.setRGB(
|
||||||
|
worldSettings.voidColor[0],
|
||||||
|
worldSettings.voidColor[1],
|
||||||
|
worldSettings.voidColor[2]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.data.ambientLight = worldSettings.ambientLight ? worldSettings.ambientLight : this.data.ambientLight;
|
this.data.ambientLight = worldSettings.ambientLight ? worldSettings.ambientLight : this.data.ambientLight;
|
||||||
|
|
||||||
if (worldSettings.hires === undefined) worldSettings.hires = {};
|
if (worldSettings.hires === undefined) worldSettings.hires = {};
|
||||||
|
|
|
@ -50,6 +50,7 @@ uniform vec2 tileSize;
|
||||||
uniform vec2 textureSize;
|
uniform vec2 textureSize;
|
||||||
uniform float lod;
|
uniform float lod;
|
||||||
uniform float lodScale;
|
uniform float lodScale;
|
||||||
|
uniform vec3 voidColor;
|
||||||
|
|
||||||
varying vec3 vPosition;
|
varying vec3 vPosition;
|
||||||
varying vec3 vWorldPosition;
|
varying vec3 vWorldPosition;
|
||||||
|
@ -76,14 +77,16 @@ vec2 posToMetaUV(vec2 pos) {
|
||||||
return vec2(pos.x / textureSize.x, pos.y / textureSize.y + 0.5);
|
return vec2(pos.x / textureSize.x, pos.y / textureSize.y + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec3 adjustColor(vec3 color) {
|
||||||
|
return vec3(color * max(sunlightStrength * sunlightStrength, ambientLight));
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
//discard if hires tile is loaded at that position
|
//discard if hires tile is loaded at that position
|
||||||
if (distance < 1000.0 && texture(hiresTileMap.map, ((vWorldPosition.xz - hiresTileMap.translate) / hiresTileMap.scale - hiresTileMap.pos) / hiresTileMap.size + 0.5).r > 0.75) discard;
|
if (distance < 1000.0 && texture(hiresTileMap.map, ((vWorldPosition.xz - hiresTileMap.translate) / hiresTileMap.scale - hiresTileMap.pos) / hiresTileMap.size + 0.5).r > 0.75) discard;
|
||||||
|
|
||||||
vec4 color = texture(textureImage, posToColorUV(vPosition.xz));
|
vec4 color = texture(textureImage, posToColorUV(vPosition.xz));
|
||||||
color.a = 1.0; // don't use alpha channel
|
|
||||||
|
|
||||||
vec4 meta = texture(textureImage, posToMetaUV(vPosition.xz));
|
vec4 meta = texture(textureImage, posToMetaUV(vPosition.xz));
|
||||||
|
|
||||||
float height = metaToHeight(meta);
|
float height = metaToHeight(meta);
|
||||||
|
@ -119,7 +122,12 @@ void main() {
|
||||||
float blockLight = metaToLight(meta);
|
float blockLight = metaToLight(meta);
|
||||||
float light = mix(blockLight, 15.0, sunlightStrength);
|
float light = mix(blockLight, 15.0, sunlightStrength);
|
||||||
color.rgb *= mix(ambientLight, 1.0, light / 15.0);
|
color.rgb *= mix(ambientLight, 1.0, light / 15.0);
|
||||||
|
|
||||||
|
vec3 adjustedVoidColor = adjustColor(voidColor);
|
||||||
|
//where there's transparency, there is void that needs to be coloured
|
||||||
|
color.rgb = mix(adjustedVoidColor, color.rgb, color.a);
|
||||||
|
color.a = 1.0; //but don't actually display the transparency
|
||||||
|
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
|
|
||||||
${ShaderChunk.logdepthbuf_fragment}
|
${ShaderChunk.logdepthbuf_fragment}
|
||||||
|
|
|
@ -26,17 +26,23 @@ export const SKY_FRAGMENT_SHADER = `
|
||||||
uniform float sunlightStrength;
|
uniform float sunlightStrength;
|
||||||
uniform float ambientLight;
|
uniform float ambientLight;
|
||||||
uniform vec3 skyColor;
|
uniform vec3 skyColor;
|
||||||
|
uniform vec3 voidColor;
|
||||||
|
|
||||||
varying vec3 vPosition;
|
varying vec3 vPosition;
|
||||||
|
|
||||||
|
vec3 adjustColor(vec3 color) {
|
||||||
|
return vec3(color * max(sunlightStrength * sunlightStrength, ambientLight));
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
float horizonWidth = 0.005;
|
float horizonWidth = 0.005;
|
||||||
float horizonHeight = 0.0;
|
float horizonHeight = 0.0;
|
||||||
|
|
||||||
vec4 color = vec4(skyColor * max(sunlightStrength * sunlightStrength, ambientLight), 1.0);
|
vec3 adjustedSkyColor = adjustColor(skyColor);
|
||||||
|
vec3 adjustedVoidColor = adjustColor(voidColor);
|
||||||
float voidMultiplier = (clamp(vPosition.y - horizonHeight, -horizonWidth, horizonWidth) + horizonWidth) / (horizonWidth * 2.0);
|
float voidMultiplier = (clamp(vPosition.y - horizonHeight, -horizonWidth, horizonWidth) + horizonWidth) / (horizonWidth * 2.0);
|
||||||
color.rgb *= voidMultiplier;
|
vec3 color = mix(adjustedVoidColor, adjustedSkyColor, voidMultiplier);
|
||||||
|
|
||||||
gl_FragColor = color;
|
gl_FragColor = vec4(color, 1.0);
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -37,6 +37,8 @@ public interface MapSettings extends RenderSettings {
|
||||||
|
|
||||||
String getSkyColor();
|
String getSkyColor();
|
||||||
|
|
||||||
|
String getVoidColor();
|
||||||
|
|
||||||
long getMinInhabitedTime();
|
long getMinInhabitedTime();
|
||||||
|
|
||||||
int getMinInhabitedTimeRadius();
|
int getMinInhabitedTimeRadius();
|
||||||
|
|
|
@ -74,6 +74,10 @@ public JsonElement serialize(BmMap map, Type typeOfSrc, JsonSerializationContext
|
||||||
Color skyColor = new Color().parse(map.getMapSettings().getSkyColor());
|
Color skyColor = new Color().parse(map.getMapSettings().getSkyColor());
|
||||||
root.add("skyColor", context.serialize(skyColor));
|
root.add("skyColor", context.serialize(skyColor));
|
||||||
|
|
||||||
|
// voidColor
|
||||||
|
Color voidColor = new Color().parse(map.getMapSettings().getVoidColor());
|
||||||
|
root.add("voidColor", context.serialize(voidColor));
|
||||||
|
|
||||||
// ambientLight
|
// ambientLight
|
||||||
root.addProperty("ambientLight", map.getMapSettings().getAmbientLight());
|
root.addProperty("ambientLight", map.getMapSettings().getAmbientLight());
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public void render(World world, Vector3i modelMin, Vector3i modelMax, HiresTileM
|
||||||
maxHeight = 0;
|
maxHeight = 0;
|
||||||
topBlockLight = 0f;
|
topBlockLight = 0f;
|
||||||
|
|
||||||
columnColor.set(0, 0, 0, 1, true);
|
columnColor.set(0, 0, 0, 0, true);
|
||||||
|
|
||||||
if (renderSettings.isInsideRenderBoundaries(x, z)) {
|
if (renderSettings.isInsideRenderBoundaries(x, z)) {
|
||||||
minY = Math.max(min.getY(), world.getMinY(x, z));
|
minY = Math.max(min.getY(), world.getMinY(x, z));
|
||||||
|
|
|
@ -61,7 +61,7 @@ dependencies {
|
||||||
minecraft ("com.mojang:minecraft:1.15.2")
|
minecraft ("com.mojang:minecraft:1.15.2")
|
||||||
mappings ("net.fabricmc:yarn:1.15.2+build.17:v2")
|
mappings ("net.fabricmc:yarn:1.15.2+build.17:v2")
|
||||||
modImplementation ("net.fabricmc:fabric-loader:0.9.2+build.206")
|
modImplementation ("net.fabricmc:fabric-loader:0.9.2+build.206")
|
||||||
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.19.0+build.325-1.15")
|
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.28.5+1.15")
|
||||||
modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")
|
modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")
|
||||||
|
|
||||||
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
package de.bluecolored.bluemap.fabric;
|
package de.bluecolored.bluemap.fabric;
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
@ -43,8 +42,13 @@ public FabricEventForwarder(FabricMod mod) {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
this.eventListeners = new ArrayList<>(1);
|
this.eventListeners = new ArrayList<>(1);
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.player);
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.player);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addEventListener(ServerEventListener listener) {
|
public synchronized void addEventListener(ServerEventListener listener) {
|
||||||
|
|
|
@ -35,8 +35,7 @@
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
import de.bluecolored.bluemap.core.BlueMap;
|
||||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
|
@ -113,8 +112,13 @@ public void onInitialize() {
|
||||||
Logger.global.logInfo("BlueMap unloaded!");
|
Logger.global.logInfo("BlueMap unloaded!");
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.player);
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.player);
|
||||||
|
});
|
||||||
|
|
||||||
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
||||||
if (server == this.serverInstance) this.updateSomePlayers();
|
if (server == this.serverInstance) this.updateSomePlayers();
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerJoinCallback {
|
|
||||||
Event<PlayerJoinCallback> EVENT = EventFactory.createArrayBacked(PlayerJoinCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerJoinCallback event : listeners) {
|
|
||||||
event.onPlayerJoin(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerLeaveCallback {
|
|
||||||
Event<PlayerLeaveCallback> EVENT = EventFactory.createArrayBacked(PlayerLeaveCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerLeaveCallback event : listeners) {
|
|
||||||
event.onPlayerLeave(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.mixin;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.PlayerManager;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
@Mixin(PlayerManager.class)
|
|
||||||
public abstract class MixinPlayerManager {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract MinecraftServer getServer();
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "onPlayerConnect")
|
|
||||||
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerJoinCallback.EVENT.invoker().onPlayerJoin(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "remove")
|
|
||||||
public void remove(ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerLeaveCallback.EVENT.invoker().onPlayerLeave(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "de.bluecolored.bluemap.fabric.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [],
|
|
||||||
"client": [],
|
|
||||||
"server": [
|
|
||||||
"MixinPlayerManager"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,9 +22,6 @@
|
||||||
"de.bluecolored.bluemap.fabric.FabricMod"
|
"de.bluecolored.bluemap.fabric.FabricMod"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
|
||||||
"bluemap.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.9.0",
|
"fabricloader": ">=0.9.0",
|
||||||
|
|
|
@ -61,7 +61,7 @@ dependencies {
|
||||||
minecraft ("com.mojang:minecraft:1.16.3")
|
minecraft ("com.mojang:minecraft:1.16.3")
|
||||||
mappings ("net.fabricmc:yarn:1.16.3+build.1:v2")
|
mappings ("net.fabricmc:yarn:1.16.3+build.1:v2")
|
||||||
modImplementation ("net.fabricmc:fabric-loader:0.9.3+build.207")
|
modImplementation ("net.fabricmc:fabric-loader:0.9.3+build.207")
|
||||||
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.20.2+build.402-1.16")
|
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.28.4+1.16")
|
||||||
modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")
|
modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")
|
||||||
|
|
||||||
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
package de.bluecolored.bluemap.fabric;
|
package de.bluecolored.bluemap.fabric;
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
@ -43,8 +42,13 @@ public FabricEventForwarder(FabricMod mod) {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
this.eventListeners = new ArrayList<>(1);
|
this.eventListeners = new ArrayList<>(1);
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.player);
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.player);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addEventListener(ServerEventListener listener) {
|
public synchronized void addEventListener(ServerEventListener listener) {
|
||||||
|
|
|
@ -35,8 +35,7 @@
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
import de.bluecolored.bluemap.core.BlueMap;
|
||||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
|
@ -115,8 +114,13 @@ public void onInitialize() {
|
||||||
Logger.global.logInfo("BlueMap unloaded!");
|
Logger.global.logInfo("BlueMap unloaded!");
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.player);
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.player);
|
||||||
|
});
|
||||||
|
|
||||||
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
||||||
if (server == this.serverInstance) this.updateSomePlayers();
|
if (server == this.serverInstance) this.updateSomePlayers();
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerJoinCallback {
|
|
||||||
Event<PlayerJoinCallback> EVENT = EventFactory.createArrayBacked(PlayerJoinCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerJoinCallback event : listeners) {
|
|
||||||
event.onPlayerJoin(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerLeaveCallback {
|
|
||||||
Event<PlayerLeaveCallback> EVENT = EventFactory.createArrayBacked(PlayerLeaveCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerLeaveCallback event : listeners) {
|
|
||||||
event.onPlayerLeave(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.mixin;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.PlayerManager;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
@Mixin(PlayerManager.class)
|
|
||||||
public abstract class MixinPlayerManager {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract MinecraftServer getServer();
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "onPlayerConnect")
|
|
||||||
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerJoinCallback.EVENT.invoker().onPlayerJoin(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "remove")
|
|
||||||
public void remove(ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerLeaveCallback.EVENT.invoker().onPlayerLeave(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "de.bluecolored.bluemap.fabric.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [],
|
|
||||||
"client": [],
|
|
||||||
"server": [
|
|
||||||
"MixinPlayerManager"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,9 +22,6 @@
|
||||||
"de.bluecolored.bluemap.fabric.FabricMod"
|
"de.bluecolored.bluemap.fabric.FabricMod"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
|
||||||
"bluemap.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.9.0",
|
"fabricloader": ">=0.9.0",
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
package de.bluecolored.bluemap.fabric;
|
package de.bluecolored.bluemap.fabric;
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
@ -43,8 +42,13 @@ public FabricEventForwarder(FabricMod mod) {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
this.eventListeners = new ArrayList<>(1);
|
this.eventListeners = new ArrayList<>(1);
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.getPlayer());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addEventListener(ServerEventListener listener) {
|
public synchronized void addEventListener(ServerEventListener listener) {
|
||||||
|
|
|
@ -35,12 +35,11 @@
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
import de.bluecolored.bluemap.core.BlueMap;
|
||||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -115,8 +114,13 @@ public void onInitialize() {
|
||||||
Logger.global.logInfo("BlueMap unloaded!");
|
Logger.global.logInfo("BlueMap unloaded!");
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
||||||
if (server == this.serverInstance) this.updateSomePlayers();
|
if (server == this.serverInstance) this.updateSomePlayers();
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerJoinCallback {
|
|
||||||
Event<PlayerJoinCallback> EVENT = EventFactory.createArrayBacked(PlayerJoinCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerJoinCallback event : listeners) {
|
|
||||||
event.onPlayerJoin(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerLeaveCallback {
|
|
||||||
Event<PlayerLeaveCallback> EVENT = EventFactory.createArrayBacked(PlayerLeaveCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerLeaveCallback event : listeners) {
|
|
||||||
event.onPlayerLeave(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.mixin;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.PlayerManager;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
@Mixin(PlayerManager.class)
|
|
||||||
public abstract class MixinPlayerManager {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract MinecraftServer getServer();
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "onPlayerConnect")
|
|
||||||
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerJoinCallback.EVENT.invoker().onPlayerJoin(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "remove")
|
|
||||||
public void remove(ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerLeaveCallback.EVENT.invoker().onPlayerLeave(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "de.bluecolored.bluemap.fabric.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [],
|
|
||||||
"client": [],
|
|
||||||
"server": [
|
|
||||||
"MixinPlayerManager"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,9 +22,6 @@
|
||||||
"de.bluecolored.bluemap.fabric.FabricMod"
|
"de.bluecolored.bluemap.fabric.FabricMod"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
|
||||||
"bluemap.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.11.3",
|
"fabricloader": ">=0.11.3",
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
package de.bluecolored.bluemap.fabric;
|
package de.bluecolored.bluemap.fabric;
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
@ -43,8 +42,13 @@ public FabricEventForwarder(FabricMod mod) {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
this.eventListeners = new ArrayList<>(1);
|
this.eventListeners = new ArrayList<>(1);
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.getPlayer());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addEventListener(ServerEventListener listener) {
|
public synchronized void addEventListener(ServerEventListener listener) {
|
||||||
|
|
|
@ -35,12 +35,11 @@
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
import de.bluecolored.bluemap.core.BlueMap;
|
||||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
@ -115,8 +114,13 @@ public void onInitialize() {
|
||||||
Logger.global.logInfo("BlueMap unloaded!");
|
Logger.global.logInfo("BlueMap unloaded!");
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
||||||
if (server == this.serverInstance) this.updateSomePlayers();
|
if (server == this.serverInstance) this.updateSomePlayers();
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerJoinCallback {
|
|
||||||
Event<PlayerJoinCallback> EVENT = EventFactory.createArrayBacked(PlayerJoinCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerJoinCallback event : listeners) {
|
|
||||||
event.onPlayerJoin(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerLeaveCallback {
|
|
||||||
Event<PlayerLeaveCallback> EVENT = EventFactory.createArrayBacked(PlayerLeaveCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerLeaveCallback event : listeners) {
|
|
||||||
event.onPlayerLeave(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.mixin;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.PlayerManager;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
@Mixin(PlayerManager.class)
|
|
||||||
public abstract class MixinPlayerManager {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract MinecraftServer getServer();
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "onPlayerConnect")
|
|
||||||
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerJoinCallback.EVENT.invoker().onPlayerJoin(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "remove")
|
|
||||||
public void remove(ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerLeaveCallback.EVENT.invoker().onPlayerLeave(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "de.bluecolored.bluemap.fabric.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [],
|
|
||||||
"client": [],
|
|
||||||
"server": [
|
|
||||||
"MixinPlayerManager"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,9 +22,6 @@
|
||||||
"de.bluecolored.bluemap.fabric.FabricMod"
|
"de.bluecolored.bluemap.fabric.FabricMod"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
|
||||||
"bluemap.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.11.3",
|
"fabricloader": ">=0.11.3",
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
package de.bluecolored.bluemap.fabric;
|
package de.bluecolored.bluemap.fabric;
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
@ -43,8 +42,13 @@ public FabricEventForwarder(FabricMod mod) {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
this.eventListeners = new ArrayList<>(1);
|
this.eventListeners = new ArrayList<>(1);
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.getPlayer());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addEventListener(ServerEventListener listener) {
|
public synchronized void addEventListener(ServerEventListener listener) {
|
||||||
|
|
|
@ -35,12 +35,11 @@
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
import de.bluecolored.bluemap.core.BlueMap;
|
||||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
import net.minecraft.registry.RegistryKey;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
@ -116,8 +115,13 @@ public void onInitialize() {
|
||||||
Logger.global.logInfo("BlueMap unloaded!");
|
Logger.global.logInfo("BlueMap unloaded!");
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
||||||
if (server == this.serverInstance) this.updateSomePlayers();
|
if (server == this.serverInstance) this.updateSomePlayers();
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerJoinCallback {
|
|
||||||
Event<PlayerJoinCallback> EVENT = EventFactory.createArrayBacked(PlayerJoinCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerJoinCallback event : listeners) {
|
|
||||||
event.onPlayerJoin(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerLeaveCallback {
|
|
||||||
Event<PlayerLeaveCallback> EVENT = EventFactory.createArrayBacked(PlayerLeaveCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerLeaveCallback event : listeners) {
|
|
||||||
event.onPlayerLeave(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.mixin;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.PlayerManager;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
@Mixin(PlayerManager.class)
|
|
||||||
public abstract class MixinPlayerManager {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract MinecraftServer getServer();
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "onPlayerConnect")
|
|
||||||
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerJoinCallback.EVENT.invoker().onPlayerJoin(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "remove")
|
|
||||||
public void remove(ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerLeaveCallback.EVENT.invoker().onPlayerLeave(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "de.bluecolored.bluemap.fabric.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [],
|
|
||||||
"client": [],
|
|
||||||
"server": [
|
|
||||||
"MixinPlayerManager"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,9 +22,6 @@
|
||||||
"de.bluecolored.bluemap.fabric.FabricMod"
|
"de.bluecolored.bluemap.fabric.FabricMod"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
|
||||||
"bluemap.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.17",
|
"fabricloader": ">=0.14.17",
|
||||||
|
|
|
@ -1,182 +0,0 @@
|
||||||
import com.matthewprenger.cursegradle.CurseArtifact
|
|
||||||
import com.matthewprenger.cursegradle.CurseProject
|
|
||||||
import com.matthewprenger.cursegradle.CurseRelation
|
|
||||||
import com.matthewprenger.cursegradle.Options
|
|
||||||
import net.fabricmc.loom.task.RemapJarTask
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
java
|
|
||||||
`java-library`
|
|
||||||
id("com.diffplug.spotless") version "6.1.2"
|
|
||||||
id ("com.github.node-gradle.node") version "3.0.1"
|
|
||||||
id ("com.github.johnrengelman.shadow") version "7.1.2"
|
|
||||||
id ("fabric-loom") version "1.3-SNAPSHOT"
|
|
||||||
id ("com.modrinth.minotaur") version "2.+"
|
|
||||||
id ("com.matthewprenger.cursegradle") version "1.4.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
group = "de.bluecolored.bluemap.fabric"
|
|
||||||
version = System.getProperty("bluemap.version") ?: "?" // set by BlueMapCore
|
|
||||||
|
|
||||||
val javaTarget = 17
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.toVersion(javaTarget)
|
|
||||||
targetCompatibility = JavaVersion.toVersion(javaTarget)
|
|
||||||
|
|
||||||
withSourcesJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
setUrl("https://libraries.minecraft.net")
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
setUrl("https://jitpack.io")
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
setUrl("https://maven.fabricmc.net/")
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
setUrl("https://oss.sonatype.org/content/repositories/snapshots")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val shadowInclude: Configuration by configurations.creating
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
implementation.get().extendsFrom(shadowInclude)
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
shadowInclude ("de.bluecolored.bluemap.common:BlueMapCommon") {
|
|
||||||
//exclude dependencies provided by fabric
|
|
||||||
exclude (group = "com.google.guava", module = "guava")
|
|
||||||
exclude (group = "com.google.code.gson", module = "gson")
|
|
||||||
exclude (group = "org.apache.commons", module = "commons-lang3")
|
|
||||||
exclude (group = "commons-io", module = "commons-io")
|
|
||||||
exclude (group = "com.mojang", module = "brigadier")
|
|
||||||
}
|
|
||||||
|
|
||||||
minecraft ("com.mojang:minecraft:1.20.2")
|
|
||||||
mappings ("net.fabricmc:yarn:1.20.2+build.1")
|
|
||||||
modImplementation ("net.fabricmc:fabric-loader:0.14.22")
|
|
||||||
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.89.1+1.20.2")
|
|
||||||
modImplementation("me.lucko:fabric-permissions-api:0.2-SNAPSHOT")
|
|
||||||
|
|
||||||
testImplementation ("org.junit.jupiter:junit-jupiter:5.9.0")
|
|
||||||
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.9.0")
|
|
||||||
}
|
|
||||||
|
|
||||||
spotless {
|
|
||||||
java {
|
|
||||||
target ("src/*/java/**/*.java")
|
|
||||||
|
|
||||||
licenseHeaderFile("../../HEADER")
|
|
||||||
indentWithSpaces()
|
|
||||||
trimTrailingWhitespace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile::class).configureEach {
|
|
||||||
options.apply {
|
|
||||||
encoding = "utf-8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(AbstractArchiveTask::class).configureEach {
|
|
||||||
isReproducibleFileOrder = true
|
|
||||||
isPreserveFileTimestamps = false
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.processResources {
|
|
||||||
inputs.property ("version", project.version)
|
|
||||||
|
|
||||||
filesMatching("fabric.mod.json") {
|
|
||||||
expand ("version" to project.version)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar {
|
|
||||||
configurations = listOf(shadowInclude)
|
|
||||||
|
|
||||||
//relocate ("com.flowpowered.math", "de.bluecolored.shadow.flowpowered.math") //DON"T relocate this, because the API depends on it
|
|
||||||
relocate ("com.typesafe.config", "de.bluecolored.shadow.typesafe.config")
|
|
||||||
relocate ("net.querz.nbt", "de.bluecolored.shadow.querz.nbt")
|
|
||||||
relocate ("org.spongepowered.configurate", "de.bluecolored.shadow.configurate")
|
|
||||||
relocate ("com.github.benmanes.caffeine", "de.bluecolored.shadow.benmanes.caffeine")
|
|
||||||
relocate ("org.aopalliance", "de.bluecolored.shadow.aopalliance")
|
|
||||||
relocate ("javax.inject", "de.bluecolored.shadow.javax.inject")
|
|
||||||
relocate ("org.checkerframework", "de.bluecolored.shadow.checkerframework")
|
|
||||||
relocate ("org.codehaus", "de.bluecolored.shadow.codehaus")
|
|
||||||
relocate ("io.leangen.geantyref", "de.bluecolored.shadow.geantyref")
|
|
||||||
relocate ("io.airlift", "de.bluecolored.shadow.airlift")
|
|
||||||
|
|
||||||
relocate ("com.google.errorprone", "de.bluecolored.shadow.google.errorprone")
|
|
||||||
relocate ("com.google.inject", "de.bluecolored.shadow.google.inject")
|
|
||||||
|
|
||||||
relocate ("org.apache.commons.dbcp2", "de.bluecolored.shadow.apache.commons.dbcp2")
|
|
||||||
relocate ("org.apache.commons.logging", "de.bluecolored.shadow.apache.commons.logging")
|
|
||||||
relocate ("org.apache.commons.pool2", "de.bluecolored.shadow.apache.commons.pool2")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("remappedShadowJar", type = RemapJarTask::class) {
|
|
||||||
destinationDirectory.set(file("../../build/release"))
|
|
||||||
archiveFileName.set("BlueMap-${project.version}-${project.name}.jar")
|
|
||||||
dependsOn (tasks.shadowJar)
|
|
||||||
inputFile.set(tasks.shadowJar.get().archiveFile)
|
|
||||||
addNestedDependencies.set(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("release") {
|
|
||||||
dependsOn("remappedShadowJar")
|
|
||||||
}
|
|
||||||
|
|
||||||
modrinth {
|
|
||||||
token.set(System.getenv("MODRINTH_TOKEN"))
|
|
||||||
projectId.set("swbUV1cr")
|
|
||||||
versionNumber.set("${project.version}-${project.name}")
|
|
||||||
changelog.set("Releasenotes and Changelog:\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}")
|
|
||||||
uploadFile.set(tasks.findByName("remappedShadowJar"))
|
|
||||||
gameVersions.addAll("1.20.2")
|
|
||||||
dependencies {
|
|
||||||
required.project("P7dR8mSH") // Fabric API
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
curseforge {
|
|
||||||
apiKey = System.getenv("CURSEFORGE_TOKEN") ?: ""
|
|
||||||
project(closureOf<CurseProject> {
|
|
||||||
id = "406463"
|
|
||||||
changelogType = "markdown"
|
|
||||||
changelog = "**Releasenotes and Changelog:**\n\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}"
|
|
||||||
releaseType = "release"
|
|
||||||
|
|
||||||
addGameVersion("Fabric")
|
|
||||||
|
|
||||||
addGameVersion("Java 18")
|
|
||||||
addGameVersion("Java 17")
|
|
||||||
|
|
||||||
addGameVersion("1.20.2")
|
|
||||||
|
|
||||||
mainArtifact(tasks.findByName("remappedShadowJar"), closureOf<CurseArtifact> {
|
|
||||||
relations(closureOf<CurseRelation> {
|
|
||||||
requiredDependency("fabric-api")
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
options(closureOf<Options> {
|
|
||||||
javaVersionAutoDetect = false
|
|
||||||
javaIntegration = false
|
|
||||||
forgeGradleIntegration = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("publish") {
|
|
||||||
dependsOn("modrinth")
|
|
||||||
dependsOn("curseforge")
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,5 +0,0 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
234
implementations/fabric-1.20.2/gradlew
vendored
234
implementations/fabric-1.20.2/gradlew
vendored
|
@ -1,234 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright © 2015-2021 the original authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
|
||||||
#
|
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
app_path=$0
|
|
||||||
|
|
||||||
# Need this for daisy-chained symlinks.
|
|
||||||
while
|
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
||||||
[ -h "$app_path" ]
|
|
||||||
do
|
|
||||||
ls=$( ls -ld "$app_path" )
|
|
||||||
link=${ls#*' -> '}
|
|
||||||
case $link in #(
|
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD=maximum
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "$( uname )" in #(
|
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
|
||||||
Darwin* ) darwin=true ;; #(
|
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
|
||||||
NONSTOP* ) nonstop=true ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
||||||
else
|
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD=java
|
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
||||||
case $MAX_FD in #(
|
|
||||||
max*)
|
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
|
||||||
warn "Could not query maximum file descriptor limit"
|
|
||||||
esac
|
|
||||||
case $MAX_FD in #(
|
|
||||||
'' | soft) :;; #(
|
|
||||||
*)
|
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
|
||||||
# * args from the command line
|
|
||||||
# * the main class name
|
|
||||||
# * -classpath
|
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if "$cygwin" || "$msys" ; then
|
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
for arg do
|
|
||||||
if
|
|
||||||
case $arg in #(
|
|
||||||
-*) false ;; # don't mess with options #(
|
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
|
||||||
# double quotes to make sure that they get re-expanded; and
|
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
|
@ -1,13 +0,0 @@
|
||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "Fabric"
|
|
||||||
url = uri("https://maven.fabricmc.net/")
|
|
||||||
}
|
|
||||||
gradlePluginPortal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = "fabric-1.20.2"
|
|
||||||
|
|
||||||
includeBuild("../../BlueMapCommon")
|
|
|
@ -1,87 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric;
|
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector3d;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.CommandSource;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.text.Text;
|
|
||||||
import de.bluecolored.bluemap.core.world.World;
|
|
||||||
import me.lucko.fabric.api.permissions.v0.Permissions;
|
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class FabricCommandSource implements CommandSource {
|
|
||||||
|
|
||||||
private final FabricMod mod;
|
|
||||||
private final Plugin plugin;
|
|
||||||
private final ServerCommandSource delegate;
|
|
||||||
|
|
||||||
public FabricCommandSource(FabricMod mod, Plugin plugin, ServerCommandSource delegate) {
|
|
||||||
this.mod = mod;
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.delegate = delegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(Text text) {
|
|
||||||
delegate.sendFeedback(() -> net.minecraft.text.Text.Serializer.fromJson(text.toJSONString()), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(String permission) {
|
|
||||||
try {
|
|
||||||
Class.forName("me.lucko.fabric.api.permissions.v0.Permissions");
|
|
||||||
return Permissions.check(delegate, permission, 1);
|
|
||||||
} catch (ClassNotFoundException ex) {
|
|
||||||
return delegate.hasPermissionLevel(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Vector3d> getPosition() {
|
|
||||||
Vec3d pos = delegate.getPosition();
|
|
||||||
if (pos != null) {
|
|
||||||
return Optional.of(new Vector3d(pos.x, pos.y, pos.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<World> getWorld() {
|
|
||||||
try {
|
|
||||||
var serverWorld = mod.getWorld(delegate.getWorld());
|
|
||||||
String worldId = plugin.getBlueMap().getWorldId(serverWorld.getSaveFolder());
|
|
||||||
return Optional.ofNullable(plugin.getWorlds().get(worldId));
|
|
||||||
} catch (IOException ignore) {}
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class FabricEventForwarder {
|
|
||||||
|
|
||||||
private FabricMod mod;
|
|
||||||
private Collection<ServerEventListener> eventListeners;
|
|
||||||
|
|
||||||
public FabricEventForwarder(FabricMod mod) {
|
|
||||||
this.mod = mod;
|
|
||||||
this.eventListeners = new ArrayList<>(1);
|
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void addEventListener(ServerEventListener listener) {
|
|
||||||
this.eventListeners.add(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void removeAllListeners() {
|
|
||||||
this.eventListeners.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player) {
|
|
||||||
if (this.mod.getServer() != server) return;
|
|
||||||
|
|
||||||
UUID uuid = player.getUuid();
|
|
||||||
for (ServerEventListener listener : eventListeners) listener.onPlayerJoin(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player) {
|
|
||||||
if (this.mod.getServer() != server) return;
|
|
||||||
|
|
||||||
UUID uuid = player.getUuid();
|
|
||||||
for (ServerEventListener listener : eventListeners) listener.onPlayerLeave(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,249 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric;
|
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.commands.Commands;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.Player;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerInterface;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
|
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
|
||||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
|
||||||
import net.minecraft.SharedConstants;
|
|
||||||
import net.minecraft.registry.RegistryKey;
|
|
||||||
import net.minecraft.registry.RegistryKeys;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.util.Identifier;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
public class FabricMod implements ModInitializer, ServerInterface {
|
|
||||||
|
|
||||||
private final Plugin pluginInstance;
|
|
||||||
private MinecraftServer serverInstance = null;
|
|
||||||
|
|
||||||
private final FabricEventForwarder eventForwarder;
|
|
||||||
|
|
||||||
private final LoadingCache<net.minecraft.server.world.ServerWorld, ServerWorld> worlds;
|
|
||||||
|
|
||||||
private int playerUpdateIndex = 0;
|
|
||||||
private final Map<UUID, Player> onlinePlayerMap;
|
|
||||||
private final List<FabricPlayer> onlinePlayerList;
|
|
||||||
|
|
||||||
public FabricMod() {
|
|
||||||
Logger.global.clear();
|
|
||||||
Logger.global.put(new Log4jLogger(LogManager.getLogger(Plugin.PLUGIN_NAME)));
|
|
||||||
|
|
||||||
this.onlinePlayerMap = new ConcurrentHashMap<>();
|
|
||||||
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
|
|
||||||
|
|
||||||
pluginInstance = new Plugin("fabric-1.20.2", this);
|
|
||||||
|
|
||||||
this.eventForwarder = new FabricEventForwarder(this);
|
|
||||||
this.worlds = Caffeine.newBuilder()
|
|
||||||
.executor(BlueMap.THREAD_POOL)
|
|
||||||
.weakKeys()
|
|
||||||
.maximumSize(1000)
|
|
||||||
.build(FabricWorld::new);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onInitialize() {
|
|
||||||
|
|
||||||
//register commands
|
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) ->
|
|
||||||
new Commands<>(pluginInstance, dispatcher, fabricSource ->
|
|
||||||
new FabricCommandSource(this, pluginInstance, fabricSource)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
ServerLifecycleEvents.SERVER_STARTED.register((MinecraftServer server) -> {
|
|
||||||
this.serverInstance = server;
|
|
||||||
|
|
||||||
new Thread(()->{
|
|
||||||
Logger.global.logInfo("Loading BlueMap...");
|
|
||||||
|
|
||||||
try {
|
|
||||||
pluginInstance.load();
|
|
||||||
if (pluginInstance.isLoaded()) Logger.global.logInfo("BlueMap loaded!");
|
|
||||||
} catch (IOException e) {
|
|
||||||
Logger.global.logError("Failed to load bluemap!", e);
|
|
||||||
pluginInstance.unload();
|
|
||||||
}
|
|
||||||
}, "BlueMap-Plugin-Loading").start();
|
|
||||||
});
|
|
||||||
|
|
||||||
ServerLifecycleEvents.SERVER_STOPPING.register((MinecraftServer server) -> {
|
|
||||||
pluginInstance.unload();
|
|
||||||
Logger.global.logInfo("BlueMap unloaded!");
|
|
||||||
});
|
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
|
||||||
|
|
||||||
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
|
||||||
if (server == this.serverInstance) this.updateSomePlayers();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MinecraftVersion getMinecraftVersion() {
|
|
||||||
try {
|
|
||||||
return MinecraftVersion.of(SharedConstants.getGameVersion().getId());
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
return MinecraftVersion.LATEST_SUPPORTED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerListener(ServerEventListener listener) {
|
|
||||||
eventForwarder.addEventListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unregisterAllListeners() {
|
|
||||||
eventForwarder.removeAllListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ServerWorld> getLoadedWorlds() {
|
|
||||||
Collection<ServerWorld> loadedWorlds = new ArrayList<>(3);
|
|
||||||
for (net.minecraft.server.world.ServerWorld serverWorld : serverInstance.getWorlds()) {
|
|
||||||
loadedWorlds.add(worlds.get(serverWorld));
|
|
||||||
}
|
|
||||||
return loadedWorlds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public Optional<ServerWorld> getWorld(Object world) {
|
|
||||||
if (world instanceof Path)
|
|
||||||
return getWorld((Path) world);
|
|
||||||
|
|
||||||
if (world instanceof String) {
|
|
||||||
Identifier identifier = Identifier.tryParse((String) world);
|
|
||||||
if (identifier != null) world = serverInstance.getWorld(RegistryKey.of(RegistryKeys.WORLD, identifier));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world instanceof RegistryKey) {
|
|
||||||
try {
|
|
||||||
world = serverInstance.getWorld((RegistryKey<World>) world);
|
|
||||||
} catch (ClassCastException ignored) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world instanceof net.minecraft.server.world.ServerWorld)
|
|
||||||
return Optional.of(getWorld((net.minecraft.server.world.ServerWorld) world));
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerWorld getWorld(net.minecraft.server.world.ServerWorld serverWorld) {
|
|
||||||
return worlds.get(serverWorld);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Path getConfigFolder() {
|
|
||||||
return Path.of("config", "bluemap");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Path> getModsFolder() {
|
|
||||||
return Optional.of(Path.of("mods"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPlayerJoin(MinecraftServer server, ServerPlayerEntity playerInstance) {
|
|
||||||
if (this.serverInstance != server) return;
|
|
||||||
|
|
||||||
FabricPlayer player = new FabricPlayer(playerInstance.getUuid(), this);
|
|
||||||
onlinePlayerMap.put(player.getUuid(), player);
|
|
||||||
onlinePlayerList.add(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player) {
|
|
||||||
if (this.serverInstance != server) return;
|
|
||||||
|
|
||||||
UUID playerUUID = player.getUuid();
|
|
||||||
onlinePlayerMap.remove(playerUUID);
|
|
||||||
synchronized (onlinePlayerList) {
|
|
||||||
onlinePlayerList.removeIf(p -> p.getUuid().equals(playerUUID));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MinecraftServer getServer() {
|
|
||||||
return this.serverInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Plugin getPluginInstance() {
|
|
||||||
return pluginInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Player> getOnlinePlayers() {
|
|
||||||
return onlinePlayerMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Player> getPlayer(UUID uuid) {
|
|
||||||
return Optional.ofNullable(onlinePlayerMap.get(uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only update some of the online players each tick to minimize performance impact on the server-thread.
|
|
||||||
* Only call this method on the server-thread.
|
|
||||||
*/
|
|
||||||
private void updateSomePlayers() {
|
|
||||||
int onlinePlayerCount = onlinePlayerList.size();
|
|
||||||
if (onlinePlayerCount == 0) return;
|
|
||||||
|
|
||||||
int playersToBeUpdated = onlinePlayerCount / 20; //with 20 tps, each player is updated once a second
|
|
||||||
if (playersToBeUpdated == 0) playersToBeUpdated = 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < playersToBeUpdated; i++) {
|
|
||||||
playerUpdateIndex++;
|
|
||||||
if (playerUpdateIndex >= 20 && playerUpdateIndex >= onlinePlayerCount) playerUpdateIndex = 0;
|
|
||||||
|
|
||||||
if (playerUpdateIndex < onlinePlayerCount) {
|
|
||||||
onlinePlayerList.get(playerUpdateIndex).update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,171 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric;
|
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector3d;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.text.Text;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.Gamemode;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.Player;
|
|
||||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
|
||||||
import net.minecraft.entity.effect.StatusEffects;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
import net.minecraft.util.math.Vec3d;
|
|
||||||
import net.minecraft.world.GameMode;
|
|
||||||
import net.minecraft.world.LightType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class FabricPlayer implements Player {
|
|
||||||
|
|
||||||
private static final Map<GameMode, Gamemode> GAMEMODE_MAP = new EnumMap<>(GameMode.class);
|
|
||||||
static {
|
|
||||||
GAMEMODE_MAP.put(GameMode.ADVENTURE, Gamemode.ADVENTURE);
|
|
||||||
GAMEMODE_MAP.put(GameMode.SURVIVAL, Gamemode.SURVIVAL);
|
|
||||||
GAMEMODE_MAP.put(GameMode.CREATIVE, Gamemode.CREATIVE);
|
|
||||||
GAMEMODE_MAP.put(GameMode.SPECTATOR, Gamemode.SPECTATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final UUID uuid;
|
|
||||||
private Text name;
|
|
||||||
private String world;
|
|
||||||
private Vector3d position;
|
|
||||||
private Vector3d rotation;
|
|
||||||
private int skyLight;
|
|
||||||
private int blockLight;
|
|
||||||
private boolean online;
|
|
||||||
private boolean sneaking;
|
|
||||||
private boolean invisible;
|
|
||||||
private Gamemode gamemode;
|
|
||||||
|
|
||||||
private final FabricMod mod;
|
|
||||||
|
|
||||||
public FabricPlayer(UUID playerUuid, FabricMod mod) {
|
|
||||||
this.uuid = playerUuid;
|
|
||||||
this.mod = mod;
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getUuid() {
|
|
||||||
return this.uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Text getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getWorld() {
|
|
||||||
return this.world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector3d getPosition() {
|
|
||||||
return this.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector3d getRotation() {
|
|
||||||
return rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSkyLight() {
|
|
||||||
return skyLight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBlockLight() {
|
|
||||||
return blockLight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnline() {
|
|
||||||
return this.online;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSneaking() {
|
|
||||||
return this.sneaking;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInvisible() {
|
|
||||||
return this.invisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Gamemode getGamemode() {
|
|
||||||
return this.gamemode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only call on server thread!
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
MinecraftServer server = mod.getServer();
|
|
||||||
if (server == null) {
|
|
||||||
this.online = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid);
|
|
||||||
if (player == null) {
|
|
||||||
this.online = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameMode());
|
|
||||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
|
||||||
|
|
||||||
StatusEffectInstance invis = player.getStatusEffect(StatusEffects.INVISIBILITY);
|
|
||||||
this.invisible = invis != null && invis.getDuration() > 0;
|
|
||||||
|
|
||||||
this.name = Text.of(player.getName().getString());
|
|
||||||
this.online = true;
|
|
||||||
|
|
||||||
Vec3d pos = player.getPos();
|
|
||||||
this.position = new Vector3d(pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
this.rotation = new Vector3d(player.getPitch(), player.getHeadYaw(), 0);
|
|
||||||
this.sneaking = player.isSneaking();
|
|
||||||
|
|
||||||
this.skyLight = player.getWorld().getLightingProvider().get(LightType.SKY).getLightLevel(player.getBlockPos());
|
|
||||||
this.blockLight = player.getWorld().getLightingProvider().get(LightType.BLOCK).getLightLevel(player.getBlockPos());
|
|
||||||
|
|
||||||
try {
|
|
||||||
var world = mod.getWorld(player.getWorld()).orElse(null);
|
|
||||||
this.world = world != null ? mod.getPluginInstance().getBlueMap().getWorldId(world.getSaveFolder()) : "unknown";
|
|
||||||
} catch (IOException | NullPointerException e) { // NullPointerException -> the plugin isn't fully loaded
|
|
||||||
this.world = "unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,99 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.Dimension;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.util.WorldSavePath;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraft.world.dimension.DimensionType;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.CompletionException;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
public class FabricWorld implements ServerWorld {
|
|
||||||
|
|
||||||
private final WeakReference<net.minecraft.server.world.ServerWorld> delegate;
|
|
||||||
private final Path saveFolder;
|
|
||||||
|
|
||||||
public FabricWorld(net.minecraft.server.world.ServerWorld delegate) {
|
|
||||||
this.delegate = new WeakReference<>(delegate);
|
|
||||||
|
|
||||||
MinecraftServer server = delegate.getServer();
|
|
||||||
Path worldFolder = delegate.getServer().getRunDirectory().toPath().resolve(server.getSavePath(WorldSavePath.ROOT));
|
|
||||||
this.saveFolder = DimensionType.getSaveDirectory(delegate.getRegistryKey(), worldFolder)
|
|
||||||
.toAbsolutePath().normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dimension getDimension() {
|
|
||||||
net.minecraft.server.world.ServerWorld world = delegate.get();
|
|
||||||
if (world != null) {
|
|
||||||
if (world.getRegistryKey().equals(World.NETHER)) return Dimension.NETHER;
|
|
||||||
if (world.getRegistryKey().equals(World.END)) return Dimension.END;
|
|
||||||
if (world.getRegistryKey().equals(World.OVERWORLD)) return Dimension.OVERWORLD;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ServerWorld.super.getDimension();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean persistWorldChanges() throws IOException {
|
|
||||||
net.minecraft.server.world.ServerWorld world = delegate.get();
|
|
||||||
if (world == null) return false;
|
|
||||||
|
|
||||||
var taskResult = CompletableFuture.supplyAsync(() -> {
|
|
||||||
try {
|
|
||||||
world.save(null, true, false);
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new CompletionException(e);
|
|
||||||
}
|
|
||||||
}, world.getServer());
|
|
||||||
|
|
||||||
try {
|
|
||||||
return taskResult.get();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
Throwable t = e.getCause();
|
|
||||||
if (t instanceof IOException) throw (IOException) t;
|
|
||||||
if (t instanceof IllegalArgumentException) throw (IllegalArgumentException) t;
|
|
||||||
throw new IOException(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Path getSaveFolder() {
|
|
||||||
return this.saveFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.core.logger.AbstractLogger;
|
|
||||||
|
|
||||||
public class Log4jLogger extends AbstractLogger {
|
|
||||||
|
|
||||||
private final Logger out;
|
|
||||||
|
|
||||||
public Log4jLogger(Logger out) {
|
|
||||||
this.out = out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logError(String message, Throwable throwable) {
|
|
||||||
out.error(message, throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logWarning(String message) {
|
|
||||||
out.warn(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logInfo(String message) {
|
|
||||||
out.info(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logDebug(String message) {
|
|
||||||
if (out.isDebugEnabled()) out.debug(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void noFloodDebug(String message) {
|
|
||||||
if (out.isDebugEnabled()) super.noFloodDebug(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void noFloodDebug(String key, String message) {
|
|
||||||
if (out.isDebugEnabled()) super.noFloodDebug(key, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerJoinCallback {
|
|
||||||
Event<PlayerJoinCallback> EVENT = EventFactory.createArrayBacked(PlayerJoinCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerJoinCallback event : listeners) {
|
|
||||||
event.onPlayerJoin(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerLeaveCallback {
|
|
||||||
Event<PlayerLeaveCallback> EVENT = EventFactory.createArrayBacked(PlayerLeaveCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerLeaveCallback event : listeners) {
|
|
||||||
event.onPlayerLeave(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.server.network.ConnectedClientData;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.PlayerManager;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
@Mixin(PlayerManager.class)
|
|
||||||
public abstract class MixinPlayerManager {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract MinecraftServer getServer();
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "onPlayerConnect")
|
|
||||||
public void onPlayerConnect(ClientConnection clientConnection, ServerPlayerEntity player, ConnectedClientData connectedClientData, CallbackInfo ci) {
|
|
||||||
PlayerJoinCallback.EVENT.invoker().onPlayerJoin(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "remove")
|
|
||||||
public void remove(ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerLeaveCallback.EVENT.invoker().onPlayerLeave(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 10 KiB |
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "de.bluecolored.bluemap.fabric.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [],
|
|
||||||
"client": [],
|
|
||||||
"server": [
|
|
||||||
"MixinPlayerManager"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
{
|
|
||||||
"schemaVersion": 1,
|
|
||||||
"id": "bluemap",
|
|
||||||
"version": "${version}",
|
|
||||||
|
|
||||||
"name": "BlueMap",
|
|
||||||
"description": "A 3d-map of your Minecraft worlds view-able in your browser using three.js (WebGL)",
|
|
||||||
"authors": [
|
|
||||||
"Blue (TBlueF, Lukas Rieger)"
|
|
||||||
],
|
|
||||||
"contact": {
|
|
||||||
"homepage": "https://github.com/BlueMap-Minecraft",
|
|
||||||
"sources": "https://github.com/BlueMap-Minecraft/BlueMap"
|
|
||||||
},
|
|
||||||
|
|
||||||
"license": "MIT",
|
|
||||||
"icon": "assets/bluemap/icon.png",
|
|
||||||
|
|
||||||
"environment": "*",
|
|
||||||
"entrypoints": {
|
|
||||||
"main": [
|
|
||||||
"de.bluecolored.bluemap.fabric.FabricMod"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"mixins": [
|
|
||||||
"bluemap.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
|
||||||
"fabricloader": ">=0.14.22",
|
|
||||||
"fabric": "*",
|
|
||||||
"fabric-api-base": "*",
|
|
||||||
"minecraft": "*"
|
|
||||||
},
|
|
||||||
"suggests": {}
|
|
||||||
}
|
|
|
@ -142,7 +142,7 @@ modrinth {
|
||||||
versionNumber.set("${project.version}-${project.name}")
|
versionNumber.set("${project.version}-${project.name}")
|
||||||
changelog.set("Releasenotes and Changelog:\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}")
|
changelog.set("Releasenotes and Changelog:\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}")
|
||||||
uploadFile.set(tasks.findByName("remappedShadowJar"))
|
uploadFile.set(tasks.findByName("remappedShadowJar"))
|
||||||
gameVersions.addAll("1.20", "1.20.1")
|
gameVersions.addAll("1.20", "1.20.1", "1.20.2")
|
||||||
dependencies {
|
dependencies {
|
||||||
required.project("P7dR8mSH") // Fabric API
|
required.project("P7dR8mSH") // Fabric API
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,7 @@ curseforge {
|
||||||
|
|
||||||
addGameVersion("1.20")
|
addGameVersion("1.20")
|
||||||
addGameVersion("1.20.1")
|
addGameVersion("1.20.1")
|
||||||
|
addGameVersion("1.20.2")
|
||||||
|
|
||||||
mainArtifact(tasks.findByName("remappedShadowJar"), closureOf<CurseArtifact> {
|
mainArtifact(tasks.findByName("remappedShadowJar"), closureOf<CurseArtifact> {
|
||||||
relations(closureOf<CurseRelation> {
|
relations(closureOf<CurseRelation> {
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
package de.bluecolored.bluemap.fabric;
|
package de.bluecolored.bluemap.fabric;
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
|
|
||||||
|
@ -43,8 +42,13 @@ public FabricEventForwarder(FabricMod mod) {
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
this.eventListeners = new ArrayList<>(1);
|
this.eventListeners = new ArrayList<>(1);
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.getPlayer());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addEventListener(ServerEventListener listener) {
|
public synchronized void addEventListener(ServerEventListener listener) {
|
||||||
|
|
|
@ -35,12 +35,11 @@
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
import de.bluecolored.bluemap.core.BlueMap;
|
||||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
import de.bluecolored.bluemap.core.logger.Logger;
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||||
|
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
|
||||||
import net.minecraft.SharedConstants;
|
import net.minecraft.SharedConstants;
|
||||||
import net.minecraft.registry.RegistryKey;
|
import net.minecraft.registry.RegistryKey;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
|
@ -116,8 +115,13 @@ public void onInitialize() {
|
||||||
Logger.global.logInfo("BlueMap unloaded!");
|
Logger.global.logInfo("BlueMap unloaded!");
|
||||||
});
|
});
|
||||||
|
|
||||||
PlayerJoinCallback.EVENT.register(this::onPlayerJoin);
|
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
|
||||||
PlayerLeaveCallback.EVENT.register(this::onPlayerLeave);
|
this.onPlayerJoin(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
|
this.onPlayerLeave(server, handler.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
ServerTickEvents.END_SERVER_TICK.register((MinecraftServer server) -> {
|
||||||
if (server == this.serverInstance) this.updateSomePlayers();
|
if (server == this.serverInstance) this.updateSomePlayers();
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerJoinCallback {
|
|
||||||
Event<PlayerJoinCallback> EVENT = EventFactory.createArrayBacked(PlayerJoinCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerJoinCallback event : listeners) {
|
|
||||||
event.onPlayerJoin(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerJoin(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.events;
|
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
public interface PlayerLeaveCallback {
|
|
||||||
Event<PlayerLeaveCallback> EVENT = EventFactory.createArrayBacked(PlayerLeaveCallback.class,
|
|
||||||
(listeners) -> (server, player) -> {
|
|
||||||
for (PlayerLeaveCallback event : listeners) {
|
|
||||||
event.onPlayerLeave(server, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
void onPlayerLeave(MinecraftServer server, ServerPlayerEntity player);
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.fabric.mixin;
|
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerJoinCallback;
|
|
||||||
import de.bluecolored.bluemap.fabric.events.PlayerLeaveCallback;
|
|
||||||
import net.minecraft.network.ClientConnection;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.PlayerManager;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
|
||||||
|
|
||||||
@Mixin(PlayerManager.class)
|
|
||||||
public abstract class MixinPlayerManager {
|
|
||||||
|
|
||||||
@Shadow
|
|
||||||
public abstract MinecraftServer getServer();
|
|
||||||
|
|
||||||
@Inject(at = @At("RETURN"), method = "onPlayerConnect")
|
|
||||||
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerJoinCallback.EVENT.invoker().onPlayerJoin(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(at = @At("HEAD"), method = "remove")
|
|
||||||
public void remove(ServerPlayerEntity player, CallbackInfo ci) {
|
|
||||||
PlayerLeaveCallback.EVENT.invoker().onPlayerLeave(this.getServer(), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"required": true,
|
|
||||||
"minVersion": "0.8",
|
|
||||||
"package": "de.bluecolored.bluemap.fabric.mixin",
|
|
||||||
"compatibilityLevel": "JAVA_8",
|
|
||||||
"mixins": [],
|
|
||||||
"client": [],
|
|
||||||
"server": [
|
|
||||||
"MixinPlayerManager"
|
|
||||||
],
|
|
||||||
"injectors": {
|
|
||||||
"defaultRequire": 1
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,9 +22,6 @@
|
||||||
"de.bluecolored.bluemap.fabric.FabricMod"
|
"de.bluecolored.bluemap.fabric.FabricMod"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"mixins": [
|
|
||||||
"bluemap.mixins.json"
|
|
||||||
],
|
|
||||||
|
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.21",
|
"fabricloader": ">=0.14.21",
|
||||||
|
|
|
@ -29,6 +29,10 @@ def javaTarget = 16
|
||||||
java {
|
java {
|
||||||
sourceCompatibility = JavaVersion.toVersion(javaTarget)
|
sourceCompatibility = JavaVersion.toVersion(javaTarget)
|
||||||
targetCompatibility = JavaVersion.toVersion(javaTarget)
|
targetCompatibility = JavaVersion.toVersion(javaTarget)
|
||||||
|
|
||||||
|
toolchain {
|
||||||
|
languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
|
|
|
@ -150,4 +150,5 @@ hangarPublish {
|
||||||
|
|
||||||
tasks.register("publish") {
|
tasks.register("publish") {
|
||||||
dependsOn("modrinth")
|
dependsOn("modrinth")
|
||||||
|
dependsOn("publishPluginPublicationToHangar")
|
||||||
}
|
}
|
||||||
|
|
89
implementations/sponge-8.0.0/gradlew.bat
vendored
89
implementations/sponge-8.0.0/gradlew.bat
vendored
|
@ -1,89 +0,0 @@
|
||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
|
||||||
@rem ##########################################################################
|
|
||||||
@rem
|
|
||||||
@rem Gradle startup script for Windows
|
|
||||||
@rem
|
|
||||||
@rem ##########################################################################
|
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
||||||
exit /b 1
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
|
@ -1,341 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.sponge;
|
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector2i;
|
|
||||||
import com.flowpowered.math.vector.Vector3d;
|
|
||||||
import com.flowpowered.math.vector.Vector3i;
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
|
||||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.Player;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerInterface;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
|
|
||||||
import de.bluecolored.bluemap.core.BlueMap;
|
|
||||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
|
||||||
import de.bluecolored.bluemap.core.logger.Logger;
|
|
||||||
import de.bluecolored.bluemap.sponge.SpongeCommands.SpongeCommandProxy;
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
|
||||||
import org.spongepowered.api.Platform;
|
|
||||||
import org.spongepowered.api.ResourceKey;
|
|
||||||
import org.spongepowered.api.Server;
|
|
||||||
import org.spongepowered.api.Sponge;
|
|
||||||
import org.spongepowered.api.command.Command;
|
|
||||||
import org.spongepowered.api.config.ConfigDir;
|
|
||||||
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
|
||||||
import org.spongepowered.api.event.Listener;
|
|
||||||
import org.spongepowered.api.event.lifecycle.RefreshGameEvent;
|
|
||||||
import org.spongepowered.api.event.lifecycle.RegisterCommandEvent;
|
|
||||||
import org.spongepowered.api.event.lifecycle.StartedEngineEvent;
|
|
||||||
import org.spongepowered.api.event.lifecycle.StoppingEngineEvent;
|
|
||||||
import org.spongepowered.api.event.network.ServerSideConnectionEvent;
|
|
||||||
import org.spongepowered.api.scheduler.ScheduledTask;
|
|
||||||
import org.spongepowered.api.scheduler.Task;
|
|
||||||
import org.spongepowered.api.util.Ticks;
|
|
||||||
import org.spongepowered.api.util.Tristate;
|
|
||||||
import org.spongepowered.plugin.PluginContainer;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
|
|
||||||
@org.spongepowered.plugin.builtin.jvm.Plugin(Plugin.PLUGIN_ID)
|
|
||||||
public class SpongePlugin implements ServerInterface {
|
|
||||||
private static SpongePlugin instance;
|
|
||||||
|
|
||||||
private final PluginContainer pluginContainer;
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Inject
|
|
||||||
@ConfigDir(sharedRoot = false)
|
|
||||||
private Path configurationDir;
|
|
||||||
|
|
||||||
private final Plugin pluginInstance;
|
|
||||||
private final SpongeCommands commands;
|
|
||||||
|
|
||||||
private ExecutorService asyncExecutor;
|
|
||||||
private ExecutorService syncExecutor;
|
|
||||||
|
|
||||||
private int playerUpdateIndex = 0;
|
|
||||||
private final Map<UUID, Player> onlinePlayerMap;
|
|
||||||
private final List<SpongePlayer> onlinePlayerList;
|
|
||||||
|
|
||||||
private final MinecraftVersion minecraftVersion;
|
|
||||||
private final LoadingCache<org.spongepowered.api.world.server.ServerWorld, ServerWorld> worlds;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public SpongePlugin(org.apache.logging.log4j.Logger logger, PluginContainer pluginContainer/*, Metrics.Factory metricsFactory*/) {
|
|
||||||
Logger.global.clear();
|
|
||||||
Logger.global.put(new Log4J2Logger(logger));
|
|
||||||
|
|
||||||
this.pluginContainer = pluginContainer;
|
|
||||||
|
|
||||||
this.onlinePlayerMap = new ConcurrentHashMap<>();
|
|
||||||
this.onlinePlayerList = Collections.synchronizedList(new ArrayList<>());
|
|
||||||
|
|
||||||
final ArtifactVersion versionFromSponge = Sponge.platform().container(Platform.Component.GAME).metadata().version();
|
|
||||||
this.minecraftVersion = new MinecraftVersion(
|
|
||||||
versionFromSponge.getMajorVersion(),
|
|
||||||
versionFromSponge.getMinorVersion(),
|
|
||||||
versionFromSponge.getIncrementalVersion()
|
|
||||||
);
|
|
||||||
|
|
||||||
this.pluginInstance = new Plugin("sponge-8.0.0", this);
|
|
||||||
this.commands = new SpongeCommands(pluginInstance);
|
|
||||||
|
|
||||||
this.worlds = Caffeine.newBuilder()
|
|
||||||
.executor(BlueMap.THREAD_POOL)
|
|
||||||
.weakKeys()
|
|
||||||
.maximumSize(1000)
|
|
||||||
.build(SpongeWorld::new);
|
|
||||||
|
|
||||||
//bstats
|
|
||||||
//metricsFactory.make(5911);
|
|
||||||
|
|
||||||
SpongePlugin.instance = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onRegisterCommands(final RegisterCommandEvent<Command.Raw> event) {
|
|
||||||
//register commands
|
|
||||||
for(SpongeCommandProxy command : commands.getRootCommands()) {
|
|
||||||
event.register(this.pluginContainer, command, command.getLabel());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onServerStart(StartedEngineEvent<Server> evt) {
|
|
||||||
asyncExecutor = evt.game().asyncScheduler().executor(pluginContainer);
|
|
||||||
syncExecutor = evt.engine().scheduler().executor(pluginContainer);
|
|
||||||
|
|
||||||
//start updating players
|
|
||||||
Task task = Task.builder()
|
|
||||||
.interval(Ticks.of(1))
|
|
||||||
.execute(this::updateSomePlayers)
|
|
||||||
.plugin(pluginContainer)
|
|
||||||
.build();
|
|
||||||
evt.engine().scheduler().submit(task);
|
|
||||||
|
|
||||||
asyncExecutor.execute(() -> {
|
|
||||||
try {
|
|
||||||
Logger.global.logInfo("Loading...");
|
|
||||||
pluginInstance.load();
|
|
||||||
if (pluginInstance.isLoaded()) Logger.global.logInfo("Loaded!");
|
|
||||||
} catch (IOException | RuntimeException e) {
|
|
||||||
Logger.global.logError("Failed to load!", e);
|
|
||||||
pluginInstance.unload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onServerStop(StoppingEngineEvent<Server> evt) {
|
|
||||||
Logger.global.logInfo("Stopping...");
|
|
||||||
evt.engine().scheduler().tasks(pluginContainer).forEach(ScheduledTask::cancel);
|
|
||||||
pluginInstance.unload();
|
|
||||||
Logger.global.logInfo("Saved and stopped!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onServerReload(RefreshGameEvent evt) {
|
|
||||||
asyncExecutor.execute(() -> {
|
|
||||||
try {
|
|
||||||
Logger.global.logInfo("Reloading...");
|
|
||||||
pluginInstance.reload();
|
|
||||||
Logger.global.logInfo("Reloaded!");
|
|
||||||
} catch (IOException | RuntimeException e) {
|
|
||||||
Logger.global.logError("Failed to load!", e);
|
|
||||||
pluginInstance.unload();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// update player list
|
|
||||||
onlinePlayerMap.clear();
|
|
||||||
synchronized (onlinePlayerList) {
|
|
||||||
onlinePlayerList.clear();
|
|
||||||
for (ServerPlayer spongePlayer : Sponge.server().onlinePlayers()) {
|
|
||||||
SpongePlayer player = new SpongePlayer(spongePlayer.uniqueId());
|
|
||||||
onlinePlayerMap.put(spongePlayer.uniqueId(), player);
|
|
||||||
onlinePlayerList.add(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onPlayerJoin(ServerSideConnectionEvent.Join evt) {
|
|
||||||
SpongePlayer player = new SpongePlayer(evt.player().uniqueId());
|
|
||||||
onlinePlayerMap.put(evt.player().uniqueId(), player);
|
|
||||||
onlinePlayerList.add(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener
|
|
||||||
public void onPlayerLeave(ServerSideConnectionEvent.Disconnect evt) {
|
|
||||||
UUID playerUUID = evt.player().uniqueId();
|
|
||||||
onlinePlayerMap.remove(playerUUID);
|
|
||||||
synchronized (onlinePlayerList) {
|
|
||||||
onlinePlayerList.removeIf(p -> p.getUuid().equals(playerUUID));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MinecraftVersion getMinecraftVersion() {
|
|
||||||
return minecraftVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerListener(ServerEventListener listener) {
|
|
||||||
Sponge.eventManager().registerListeners(this.pluginContainer, new EventForwarder(listener));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void unregisterAllListeners() {
|
|
||||||
Sponge.eventManager().unregisterListeners(this.pluginContainer);
|
|
||||||
Sponge.eventManager().registerListeners(this.pluginContainer, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<ServerWorld> getLoadedWorlds() {
|
|
||||||
Collection<ServerWorld> loadedWorlds = new ArrayList<>(3);
|
|
||||||
for (var world : Sponge.server().worldManager().worlds()) {
|
|
||||||
loadedWorlds.add(worlds.get(world));
|
|
||||||
}
|
|
||||||
return loadedWorlds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<ServerWorld> getWorld(Object world) {
|
|
||||||
if (world instanceof Path)
|
|
||||||
return getWorld((Path) world);
|
|
||||||
|
|
||||||
if (world instanceof String) {
|
|
||||||
ResourceKey resourceKey = ResourceKey.resolve((String) world);
|
|
||||||
var serverWorld = Sponge.server().worldManager().world(resourceKey).orElse(null);
|
|
||||||
if (serverWorld != null) world = serverWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world instanceof ResourceKey) {
|
|
||||||
var serverWorld = Sponge.server().worldManager().world((ResourceKey) world).orElse(null);
|
|
||||||
if (serverWorld != null) world = serverWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world instanceof org.spongepowered.api.world.server.ServerWorld)
|
|
||||||
return Optional.of(getWorld((org.spongepowered.api.world.server.ServerWorld) world));
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerWorld getWorld(org.spongepowered.api.world.server.ServerWorld world) {
|
|
||||||
return worlds.get(world);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Path getConfigFolder() {
|
|
||||||
return configurationDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Path> getModsFolder() {
|
|
||||||
return Optional.of(Path.of("mods"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Collection<Player> getOnlinePlayers() {
|
|
||||||
return onlinePlayerMap.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Player> getPlayer(UUID uuid) {
|
|
||||||
return Optional.ofNullable(onlinePlayerMap.get(uuid));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public de.bluecolored.bluemap.core.util.Tristate isMetricsEnabled() {
|
|
||||||
if (pluginContainer != null) {
|
|
||||||
Tristate metricsEnabled = Sponge.metricsConfigManager().collectionState(pluginContainer);
|
|
||||||
if (metricsEnabled != Tristate.UNDEFINED) {
|
|
||||||
if (metricsEnabled == Tristate.TRUE) return de.bluecolored.bluemap.core.util.Tristate.TRUE;
|
|
||||||
return de.bluecolored.bluemap.core.util.Tristate.FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return switch (Sponge.metricsConfigManager().globalCollectionState()) {
|
|
||||||
case TRUE -> de.bluecolored.bluemap.core.util.Tristate.TRUE;
|
|
||||||
case FALSE -> de.bluecolored.bluemap.core.util.Tristate.FALSE;
|
|
||||||
default -> de.bluecolored.bluemap.core.util.Tristate.UNDEFINED;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only update some of the online players each tick to minimize performance impact on the server-thread.
|
|
||||||
* Only call this method on the server-thread.
|
|
||||||
*/
|
|
||||||
private void updateSomePlayers() {
|
|
||||||
synchronized (onlinePlayerList) {
|
|
||||||
int onlinePlayerCount = onlinePlayerList.size();
|
|
||||||
if (onlinePlayerCount == 0) return;
|
|
||||||
|
|
||||||
int playersToBeUpdated = onlinePlayerCount / 20; //with 20 tps, each player is updated once a second
|
|
||||||
if (playersToBeUpdated == 0) playersToBeUpdated = 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < playersToBeUpdated; i++) {
|
|
||||||
playerUpdateIndex++;
|
|
||||||
if (playerUpdateIndex >= 20 && playerUpdateIndex >= onlinePlayerCount) playerUpdateIndex = 0;
|
|
||||||
|
|
||||||
if (playerUpdateIndex < onlinePlayerCount) {
|
|
||||||
onlinePlayerList.get(playerUpdateIndex).update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3d fromSpongePoweredVector(org.spongepowered.math.vector.Vector3d vec) {
|
|
||||||
return new Vector3d(vec.x(), vec.y(), vec.z());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector3i fromSpongePoweredVector(org.spongepowered.math.vector.Vector3i vec) {
|
|
||||||
return new Vector3i(vec.x(), vec.y(), vec.z());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Vector2i fromSpongePoweredVector(org.spongepowered.math.vector.Vector2i vec) {
|
|
||||||
return new Vector2i(vec.x(), vec.y());
|
|
||||||
}
|
|
||||||
|
|
||||||
public ExecutorService getSyncExecutor() {
|
|
||||||
return syncExecutor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Plugin getPlugin() {
|
|
||||||
return pluginInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SpongePlugin getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,110 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.sponge;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.Dimension;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
||||||
import org.spongepowered.api.world.WorldTypes;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.CompletionException;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
public class SpongeWorld implements ServerWorld {
|
|
||||||
|
|
||||||
private final WeakReference<org.spongepowered.api.world.server.ServerWorld> delegate;
|
|
||||||
private final Path saveFolder;
|
|
||||||
|
|
||||||
public SpongeWorld(org.spongepowered.api.world.server.ServerWorld delegate) {
|
|
||||||
this.delegate = new WeakReference<>(delegate);
|
|
||||||
this.saveFolder = delegate.directory()
|
|
||||||
.resolve(getDimension().getDimensionSubPath())
|
|
||||||
.toAbsolutePath().normalize();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dimension getDimension() {
|
|
||||||
var world = delegate.get();
|
|
||||||
if (world != null) {
|
|
||||||
if (world.worldType().equals(WorldTypes.THE_NETHER.get())) return Dimension.NETHER;
|
|
||||||
if (world.worldType().equals(WorldTypes.THE_END.get())) return Dimension.END;
|
|
||||||
}
|
|
||||||
return Dimension.OVERWORLD;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<String> getId() {
|
|
||||||
var world = delegate.get();
|
|
||||||
if (world != null) {
|
|
||||||
return Optional.of(world.uniqueId().toString());
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<String> getName() {
|
|
||||||
var world = delegate.get();
|
|
||||||
if (world != null) {
|
|
||||||
return world.properties().displayName()
|
|
||||||
.map(PlainTextComponentSerializer.plainText()::serialize);
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean persistWorldChanges() throws IOException {
|
|
||||||
var delegateWorld = delegate.get();
|
|
||||||
if (delegateWorld == null) return false;
|
|
||||||
|
|
||||||
try {
|
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
|
||||||
try {
|
|
||||||
return delegateWorld.save();
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new CompletionException(e);
|
|
||||||
}
|
|
||||||
}, SpongePlugin.getInstance().getSyncExecutor()).get();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
throw new IOException(e);
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
Throwable t = e.getCause();
|
|
||||||
if (t instanceof IOException) throw (IOException) t;
|
|
||||||
if (t instanceof IllegalArgumentException) throw (IllegalArgumentException) t;
|
|
||||||
throw new IOException(t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Path getSaveFolder() {
|
|
||||||
return this.saveFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,145 +0,0 @@
|
||||||
import org.spongepowered.gradle.plugin.config.PluginLoaders
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
java
|
|
||||||
`java-library`
|
|
||||||
id("com.diffplug.spotless") version "6.1.2"
|
|
||||||
id ("com.github.node-gradle.node") version "3.0.1"
|
|
||||||
id ("com.github.johnrengelman.shadow") version "7.1.2"
|
|
||||||
id ("org.spongepowered.gradle.plugin") version "2.0.0"
|
|
||||||
id ("com.modrinth.minotaur") version "2.+"
|
|
||||||
}
|
|
||||||
|
|
||||||
group = "de.bluecolored.bluemap.bukkit"
|
|
||||||
version = System.getProperty("bluemap.version") ?: "?" // set by BlueMapCore
|
|
||||||
|
|
||||||
val javaTarget = 17
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.toVersion(javaTarget)
|
|
||||||
targetCompatibility = JavaVersion.toVersion(javaTarget)
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven {
|
|
||||||
setUrl("https://libraries.minecraft.net")
|
|
||||||
}
|
|
||||||
maven {
|
|
||||||
setUrl("https://jitpack.io")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api ("de.bluecolored.bluemap.common:BlueMapCommon"){
|
|
||||||
//exclude dependencies provided by sponge
|
|
||||||
exclude( group = "com.google.guava", module = "guava" )
|
|
||||||
exclude( group = "com.google.code.gson", module = "gson" )
|
|
||||||
exclude( group = "org.apache.commons", module = "commons-lang3" )
|
|
||||||
exclude( group = "javax.inject" )
|
|
||||||
exclude( group = "com.google.inject" )
|
|
||||||
}
|
|
||||||
|
|
||||||
implementation ("org.bstats:bstats-sponge:2.2.1")
|
|
||||||
|
|
||||||
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
|
||||||
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
|
||||||
}
|
|
||||||
|
|
||||||
sponge {
|
|
||||||
apiVersion("9.0.0-SNAPSHOT")
|
|
||||||
license("MIT")
|
|
||||||
loader {
|
|
||||||
name(PluginLoaders.JAVA_PLAIN)
|
|
||||||
version("1.0")
|
|
||||||
}
|
|
||||||
plugin("bluemap") {
|
|
||||||
displayName("bluemap")
|
|
||||||
entrypoint("de.bluecolored.bluemap.sponge.SpongePlugin")
|
|
||||||
description("A 3d-map of your Minecraft worlds view-able in your browser using three.js (WebGL)")
|
|
||||||
contributor("Blue (TBlueF, Lukas Rieger)") {
|
|
||||||
description("Lead Developer")
|
|
||||||
}
|
|
||||||
dependency("spongeapi") {
|
|
||||||
version("9.0.0-SNAPSHOT")
|
|
||||||
optional(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spotless {
|
|
||||||
java {
|
|
||||||
target ("src/*/java/**/*.java")
|
|
||||||
|
|
||||||
licenseHeaderFile("../../HEADER")
|
|
||||||
indentWithSpaces()
|
|
||||||
trimTrailingWhitespace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile::class).configureEach {
|
|
||||||
options.apply {
|
|
||||||
encoding = "utf-8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(AbstractArchiveTask::class).configureEach {
|
|
||||||
isReproducibleFileOrder = true
|
|
||||||
isPreserveFileTimestamps = false
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.processResources {
|
|
||||||
from("src/main/resources") {
|
|
||||||
include("META-INF/plugins.json")
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
|
|
||||||
expand (
|
|
||||||
"version" to project.version
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.shadowJar {
|
|
||||||
destinationDirectory.set(file("../../build/release"))
|
|
||||||
archiveFileName.set("BlueMap-${project.version}-${project.name}.jar")
|
|
||||||
|
|
||||||
//relocate ("com.flowpowered.math", "de.bluecolored.shadow.flowpowered.math") //DON"T relocate this, because the API depends on it
|
|
||||||
relocate ("net.querz.nbt", "de.bluecolored.shadow.querz.nbt")
|
|
||||||
relocate ("com.mojang.brigadier", "de.bluecolored.shadow.mojang.brigadier")
|
|
||||||
relocate ("com.github.benmanes.caffeine", "de.bluecolored.shadow.benmanes.caffeine")
|
|
||||||
relocate ("com.google.errorprone", "de.bluecolored.shadow.google.errorprone")
|
|
||||||
relocate ("org.spongepowered.configurate", "de.bluecolored.shadow.configurate")
|
|
||||||
relocate ("org.aopalliance", "de.bluecolored.shadow.aopalliance")
|
|
||||||
relocate ("org.bstats", "de.bluecolored.shadow.bstats")
|
|
||||||
relocate ("com.typesafe.config", "de.bluecolored.shadow.typesafe.config")
|
|
||||||
relocate ("org.checkerframework", "de.bluecolored.shadow.checkerframework")
|
|
||||||
relocate ("org.codehaus", "de.bluecolored.shadow.codehaus")
|
|
||||||
relocate ("io.leangen.geantyref", "de.bluecolored.shadow.geantyref")
|
|
||||||
relocate ("io.airlift", "de.bluecolored.shadow.airlift")
|
|
||||||
|
|
||||||
relocate ("org.apache.commons.dbcp2", "de.bluecolored.shadow.apache.commons.dbcp2")
|
|
||||||
relocate ("org.apache.commons.io", "de.bluecolored.shadow.apache.commons.io")
|
|
||||||
relocate ("org.apache.commons.logging", "de.bluecolored.shadow.apache.commons.logging")
|
|
||||||
relocate ("org.apache.commons.pool2", "de.bluecolored.shadow.apache.commons.pool2")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("release") {
|
|
||||||
dependsOn(tasks.shadowJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
modrinth {
|
|
||||||
token.set(System.getenv("MODRINTH_TOKEN"))
|
|
||||||
projectId.set("swbUV1cr")
|
|
||||||
versionNumber.set("${project.version}-${project.name}")
|
|
||||||
changelog.set("Releasenotes and Changelog:\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}")
|
|
||||||
uploadFile.set(tasks.findByName("shadowJar"))
|
|
||||||
loaders.addAll("sponge")
|
|
||||||
gameVersions.addAll("1.18.2")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("publish") {
|
|
||||||
dependsOn("modrinth")
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,5 +0,0 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
185
implementations/sponge-9.0.0/gradlew
vendored
185
implementations/sponge-9.0.0/gradlew
vendored
|
@ -1,185 +0,0 @@
|
||||||
#!/usr/bin/env sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright 2015 the original author or authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
##
|
|
||||||
## Gradle start up script for UN*X
|
|
||||||
##
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
PRG="$0"
|
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
|
||||||
ls=`ls -ld "$PRG"`
|
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
|
||||||
PRG="$link"
|
|
||||||
else
|
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=`basename "$0"`
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD="maximum"
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
}
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "`uname`" in
|
|
||||||
CYGWIN* )
|
|
||||||
cygwin=true
|
|
||||||
;;
|
|
||||||
Darwin* )
|
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MSYS* | MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
|
||||||
else
|
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD="java"
|
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
|
||||||
if [ $? -eq 0 ] ; then
|
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
ulimit -n $MAX_FD
|
|
||||||
if [ $? -ne 0 ] ; then
|
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Escape application args
|
|
||||||
save () {
|
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
|
||||||
echo " "
|
|
||||||
}
|
|
||||||
APP_ARGS=`save "$@"`
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
89
implementations/sponge-9.0.0/gradlew.bat
vendored
89
implementations/sponge-9.0.0/gradlew.bat
vendored
|
@ -1,89 +0,0 @@
|
||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
|
||||||
@rem ##########################################################################
|
|
||||||
@rem
|
|
||||||
@rem Gradle startup script for Windows
|
|
||||||
@rem
|
|
||||||
@rem ##########################################################################
|
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
|
||||||
|
|
||||||
echo.
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
|
||||||
echo.
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
echo location of your Java installation.
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
|
||||||
exit /b 1
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
|
@ -1,3 +0,0 @@
|
||||||
rootProject.name = "sponge-9.0.0"
|
|
||||||
|
|
||||||
includeBuild("../../BlueMapCommon")
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.sponge;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.common.plugin.text.Text;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.ServerEventListener;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
||||||
import org.spongepowered.api.event.Listener;
|
|
||||||
import org.spongepowered.api.event.Order;
|
|
||||||
import org.spongepowered.api.event.message.PlayerChatEvent;
|
|
||||||
import org.spongepowered.api.event.network.ServerSideConnectionEvent;
|
|
||||||
|
|
||||||
public class EventForwarder {
|
|
||||||
|
|
||||||
private ServerEventListener listener;
|
|
||||||
|
|
||||||
public EventForwarder(ServerEventListener listener) {
|
|
||||||
this.listener = listener;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener(order = Order.POST)
|
|
||||||
public void onPlayerJoin(ServerSideConnectionEvent.Join evt) {
|
|
||||||
listener.onPlayerJoin(evt.player().uniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener(order = Order.POST)
|
|
||||||
public void onPlayerLeave(ServerSideConnectionEvent.Disconnect evt) {
|
|
||||||
listener.onPlayerJoin(evt.player().uniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listener(order = Order.POST)
|
|
||||||
public void onPlayerChat(PlayerChatEvent evt) {
|
|
||||||
listener.onChatMessage(Text.of(PlainTextComponentSerializer.plainText().serialize(evt.message())));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,68 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.sponge;
|
|
||||||
|
|
||||||
import de.bluecolored.bluemap.core.logger.AbstractLogger;
|
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
public class Log4J2Logger extends AbstractLogger {
|
|
||||||
|
|
||||||
private final Logger out;
|
|
||||||
|
|
||||||
public Log4J2Logger(Logger out) {
|
|
||||||
this.out = out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logError(String message, Throwable throwable) {
|
|
||||||
out.error(message, throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logWarning(String message) {
|
|
||||||
out.warn(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logInfo(String message) {
|
|
||||||
out.info(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logDebug(String message) {
|
|
||||||
if (out.isDebugEnabled()) out.debug(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void noFloodDebug(String message) {
|
|
||||||
if (out.isDebugEnabled()) super.noFloodDebug(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void noFloodDebug(String key, String message) {
|
|
||||||
if (out.isDebugEnabled()) super.noFloodDebug(key, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.sponge;
|
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector3d;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.CommandSource;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.text.Text;
|
|
||||||
import de.bluecolored.bluemap.core.world.World;
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
|
||||||
import org.spongepowered.api.service.permission.Subject;
|
|
||||||
import org.spongepowered.api.world.Locatable;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class SpongeCommandSource implements CommandSource {
|
|
||||||
|
|
||||||
private final Plugin plugin;
|
|
||||||
private final Audience audience;
|
|
||||||
private final Subject subject;
|
|
||||||
|
|
||||||
public SpongeCommandSource(Plugin plugin, Audience audience, Subject subject) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.subject = subject;
|
|
||||||
this.audience = audience;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendMessage(Text text) {
|
|
||||||
audience.sendMessage(GsonComponentSerializer.gson().deserialize(text.toJSONString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasPermission(String permission) {
|
|
||||||
return subject.hasPermission(permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Vector3d> getPosition() {
|
|
||||||
if (audience instanceof Locatable) {
|
|
||||||
return Optional.of(SpongePlugin.fromSpongePoweredVector(((Locatable) audience).location().position()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<World> getWorld() {
|
|
||||||
if (audience instanceof Locatable locatable) {
|
|
||||||
try {
|
|
||||||
var serverWorld = SpongePlugin.getInstance().getWorld(locatable.serverLocation().world());
|
|
||||||
String worldId = plugin.getBlueMap().getWorldId(serverWorld.getSaveFolder());
|
|
||||||
return Optional.ofNullable(plugin.getWorlds().get(worldId));
|
|
||||||
} catch (IOException ignore) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,166 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.sponge;
|
|
||||||
|
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
|
||||||
import com.mojang.brigadier.Message;
|
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
||||||
import com.mojang.brigadier.suggestion.Suggestion;
|
|
||||||
import com.mojang.brigadier.suggestion.Suggestions;
|
|
||||||
import com.mojang.brigadier.tree.CommandNode;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.Plugin;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.commands.Commands;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.JoinConfiguration;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import org.spongepowered.api.command.Command;
|
|
||||||
import org.spongepowered.api.command.CommandCause;
|
|
||||||
import org.spongepowered.api.command.CommandCompletion;
|
|
||||||
import org.spongepowered.api.command.CommandResult;
|
|
||||||
import org.spongepowered.api.command.parameter.ArgumentReader;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
public class SpongeCommands {
|
|
||||||
|
|
||||||
private final CommandDispatcher<CommandCause> dispatcher;
|
|
||||||
|
|
||||||
public SpongeCommands(final Plugin plugin) {
|
|
||||||
this.dispatcher = new CommandDispatcher<>();
|
|
||||||
|
|
||||||
// register commands
|
|
||||||
new Commands<>(plugin, dispatcher, cause -> new SpongeCommandSource(plugin, cause.audience(), cause.subject()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Collection<SpongeCommandProxy> getRootCommands(){
|
|
||||||
Collection<SpongeCommandProxy> rootCommands = new ArrayList<>();
|
|
||||||
|
|
||||||
for (CommandNode<CommandCause> node : this.dispatcher.getRoot().getChildren()) {
|
|
||||||
rootCommands.add(new SpongeCommandProxy(node.getName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return rootCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SpongeCommandProxy implements Command.Raw {
|
|
||||||
|
|
||||||
private final String label;
|
|
||||||
|
|
||||||
protected SpongeCommandProxy(String label) {
|
|
||||||
this.label = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CommandResult process(CommandCause cause, ArgumentReader.Mutable arguments) {
|
|
||||||
String command = label;
|
|
||||||
if (!arguments.input().isEmpty()) {
|
|
||||||
command += " " + arguments.input();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return CommandResult.builder().result(dispatcher.execute(command, cause)).build();
|
|
||||||
} catch (CommandSyntaxException ex) {
|
|
||||||
Component errText = Component.text(ex.getRawMessage().getString(), NamedTextColor.RED);
|
|
||||||
|
|
||||||
String context = ex.getContext();
|
|
||||||
if (context != null)
|
|
||||||
errText = errText.append(Component.newline()).append(Component.text(context, NamedTextColor.GRAY));
|
|
||||||
|
|
||||||
return CommandResult.error(errText);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<CommandCompletion> complete(CommandCause cause, ArgumentReader.Mutable arguments) {
|
|
||||||
String command = label;
|
|
||||||
if (!arguments.input().isEmpty()) {
|
|
||||||
command += " " + arguments.input();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<CommandCompletion> completions = new ArrayList<>();
|
|
||||||
|
|
||||||
try {
|
|
||||||
Suggestions suggestions = dispatcher.getCompletionSuggestions(dispatcher.parse(command, cause)).get(100, TimeUnit.MILLISECONDS);
|
|
||||||
for (Suggestion suggestion : suggestions.getList()) {
|
|
||||||
String text = suggestion.getText();
|
|
||||||
|
|
||||||
if (text.indexOf(' ') == -1) {
|
|
||||||
Message tooltip = suggestion.getTooltip();
|
|
||||||
if (tooltip == null) {
|
|
||||||
completions.add(CommandCompletion.of(text));
|
|
||||||
} else {
|
|
||||||
completions.add(CommandCompletion.of(text, Component.text(tooltip.getString())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (InterruptedException ignore) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
} catch (ExecutionException | TimeoutException ignore) {}
|
|
||||||
|
|
||||||
completions.sort(Comparator.comparing(CommandCompletion::completion));
|
|
||||||
|
|
||||||
return completions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExecute(CommandCause cause) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Component> shortDescription(CommandCause cause) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Optional<Component> extendedDescription(CommandCause cause) {
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component usage(CommandCause cause) {
|
|
||||||
CommandNode<CommandCause> node = dispatcher.getRoot().getChild(label);
|
|
||||||
if (node == null) return Component.text("/" + label);
|
|
||||||
|
|
||||||
List<Component> lines = new ArrayList<>();
|
|
||||||
for (String usageString : dispatcher.getSmartUsage(node, cause).values()) {
|
|
||||||
lines.add(Component.text("/" + label + " ", NamedTextColor.WHITE).append(Component.text(usageString, NamedTextColor.GRAY)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Component.join(JoinConfiguration.builder()
|
|
||||||
.separator(Component.newline())
|
|
||||||
.build(),
|
|
||||||
lines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,173 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
|
||||||
*
|
|
||||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
|
||||||
* Copyright (c) contributors
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
package de.bluecolored.bluemap.sponge;
|
|
||||||
|
|
||||||
import com.flowpowered.math.vector.Vector3d;
|
|
||||||
import de.bluecolored.bluemap.common.plugin.text.Text;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.Gamemode;
|
|
||||||
import de.bluecolored.bluemap.common.serverinterface.Player;
|
|
||||||
import org.spongepowered.api.Sponge;
|
|
||||||
import org.spongepowered.api.data.Keys;
|
|
||||||
import org.spongepowered.api.effect.VanishState;
|
|
||||||
import org.spongepowered.api.effect.potion.PotionEffect;
|
|
||||||
import org.spongepowered.api.effect.potion.PotionEffectTypes;
|
|
||||||
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
|
|
||||||
import org.spongepowered.api.entity.living.player.gamemode.GameModes;
|
|
||||||
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class SpongePlayer implements Player {
|
|
||||||
|
|
||||||
private static final Map<GameMode, Gamemode> GAMEMODE_MAP = new HashMap<>(5);
|
|
||||||
static {
|
|
||||||
GAMEMODE_MAP.put(GameModes.ADVENTURE.get(), Gamemode.ADVENTURE);
|
|
||||||
GAMEMODE_MAP.put(GameModes.SURVIVAL.get(), Gamemode.SURVIVAL);
|
|
||||||
GAMEMODE_MAP.put(GameModes.CREATIVE.get(), Gamemode.CREATIVE);
|
|
||||||
GAMEMODE_MAP.put(GameModes.SPECTATOR.get(), Gamemode.SPECTATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final UUID uuid;
|
|
||||||
private Text name;
|
|
||||||
private String world;
|
|
||||||
private Vector3d position;
|
|
||||||
private Vector3d rotation;
|
|
||||||
private int skyLight;
|
|
||||||
private int blockLight;
|
|
||||||
private boolean online;
|
|
||||||
private boolean sneaking;
|
|
||||||
private boolean invisible;
|
|
||||||
private boolean vanished;
|
|
||||||
private Gamemode gamemode;
|
|
||||||
|
|
||||||
public SpongePlayer(UUID playerUUID) {
|
|
||||||
this.uuid = playerUUID;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getUuid() {
|
|
||||||
return this.uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Text getName() {
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getWorld() {
|
|
||||||
return this.world;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector3d getPosition() {
|
|
||||||
return this.position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Vector3d getRotation() {
|
|
||||||
return rotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getSkyLight() {
|
|
||||||
return skyLight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBlockLight() {
|
|
||||||
return blockLight;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isOnline() {
|
|
||||||
return this.online;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSneaking() {
|
|
||||||
return this.sneaking;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInvisible() {
|
|
||||||
return this.invisible;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVanished() {
|
|
||||||
return vanished;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Gamemode getGamemode() {
|
|
||||||
return this.gamemode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API access, only call on server thread!
|
|
||||||
*/
|
|
||||||
public void update() {
|
|
||||||
ServerPlayer player = Sponge.server().player(uuid).orElse(null);
|
|
||||||
if (player == null) {
|
|
||||||
this.online = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.gamemode = GAMEMODE_MAP.get(player.get(Keys.GAME_MODE).orElse(GameModes.SURVIVAL.get()));
|
|
||||||
if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;
|
|
||||||
|
|
||||||
boolean invis = false;
|
|
||||||
Optional<List<PotionEffect>> effects = player.get(Keys.POTION_EFFECTS);
|
|
||||||
if (effects.isPresent()) {
|
|
||||||
for (PotionEffect effect : effects.get()) {
|
|
||||||
if (effect.type().equals(PotionEffectTypes.INVISIBILITY.get()) && effect.duration().ticks() > 0) invis = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.invisible = invis;
|
|
||||||
|
|
||||||
this.vanished = player.get(Keys.VANISH_STATE).orElse(VanishState.unvanished()).invisible();
|
|
||||||
|
|
||||||
this.name = Text.of(player.name());
|
|
||||||
this.online = player.isOnline();
|
|
||||||
this.position = SpongePlugin.fromSpongePoweredVector(player.position());
|
|
||||||
this.rotation = SpongePlugin.fromSpongePoweredVector(player.rotation());
|
|
||||||
this.sneaking = player.get(Keys.IS_SNEAKING).orElse(false);
|
|
||||||
|
|
||||||
// not implemented in sponge
|
|
||||||
this.skyLight = 15; //player.world().light(LightTypes.SKY, player.blockPosition());
|
|
||||||
this.blockLight = 0; //player.world().light(LightTypes.BLOCK, player.blockPosition());
|
|
||||||
|
|
||||||
try {
|
|
||||||
var world = SpongePlugin.getInstance().getWorld(player.world());
|
|
||||||
this.world = SpongePlugin.getInstance().getPlugin().getBlueMap().getWorldId(world.getSaveFolder());
|
|
||||||
} catch (IOException | NullPointerException e) { // NullPointerException -> the plugin isn't fully loaded
|
|
||||||
this.world = "unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -8,6 +8,7 @@ plugins {
|
||||||
id ("com.github.johnrengelman.shadow") version "7.1.2"
|
id ("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
id ("org.spongepowered.gradle.plugin") version "2.0.0"
|
id ("org.spongepowered.gradle.plugin") version "2.0.0"
|
||||||
id ("com.modrinth.minotaur") version "2.+"
|
id ("com.modrinth.minotaur") version "2.+"
|
||||||
|
id("org.spongepowered.gradle.ore") version "2.2.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "de.bluecolored.bluemap.bukkit"
|
group = "de.bluecolored.bluemap.bukkit"
|
||||||
|
@ -46,7 +47,7 @@ dependencies {
|
||||||
}
|
}
|
||||||
|
|
||||||
sponge {
|
sponge {
|
||||||
apiVersion("8.0.0-SNAPSHOT")
|
apiVersion("8.2.0")
|
||||||
license("MIT")
|
license("MIT")
|
||||||
loader {
|
loader {
|
||||||
name(PluginLoaders.JAVA_PLAIN)
|
name(PluginLoaders.JAVA_PLAIN)
|
||||||
|
@ -60,7 +61,7 @@ sponge {
|
||||||
description("Lead Developer")
|
description("Lead Developer")
|
||||||
}
|
}
|
||||||
dependency("spongeapi") {
|
dependency("spongeapi") {
|
||||||
version("8.0.0-SNAPSHOT")
|
version("8.2.0")
|
||||||
optional(false)
|
optional(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,4 +143,14 @@ modrinth {
|
||||||
|
|
||||||
tasks.register("publish") {
|
tasks.register("publish") {
|
||||||
dependsOn("modrinth")
|
dependsOn("modrinth")
|
||||||
|
dependsOn("publishToOre")
|
||||||
|
}
|
||||||
|
|
||||||
|
oreDeployment {
|
||||||
|
apiKey(System.getenv("ORE_TOKEN"))
|
||||||
|
defaultPublication {
|
||||||
|
projectId.set("BlueMap")
|
||||||
|
versionBody.set("Releasenotes and Changelog:\nhttps://github.com/BlueMap-Minecraft/BlueMap/releases/tag/v${project.version}")
|
||||||
|
publishArtifacts.setFrom(tasks.findByName("shadowJar"))
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,3 @@
|
||||||
rootProject.name = "sponge-8.0.0"
|
rootProject.name = "sponge"
|
||||||
|
|
||||||
includeBuild("../../BlueMapCommon")
|
includeBuild("../../BlueMapCommon")
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user