|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"java.configuration.updateBuildConfiguration": "automatic"
|
||||
"java.configuration.updateBuildConfiguration": "automatic",
|
||||
"java.compile.nullAnalysis.mode": "automatic"
|
||||
}
|
|
@ -194,7 +194,9 @@ var DynmapTileLayer = L.TileLayer.extend({
|
|||
if (!url) {
|
||||
this._cachedTileUrls[tileName] = url = this.options.dynmap.getTileUrl(tileName);
|
||||
}
|
||||
|
||||
if (typeof timestamp === 'undefined') {
|
||||
timestamp = this.options.dynmap.inittime
|
||||
}
|
||||
if(typeof timestamp !== 'undefined') {
|
||||
url += (url.indexOf('?') === -1 ? '?timestamp=' + timestamp : '×tamp=' + timestamp);
|
||||
}
|
||||
|
|
|
@ -4455,3 +4455,61 @@ block:id=%melon_stem,patch0=0:melon_stem,blockcolor=foliagebiome,transparency=TR
|
|||
[1.19.4-]block:id=%pink_petals,state=facing:east/flower_amount:3,patch0=0:pink_petals,patch1=2000:pink_petals_stem,transparency=TRANSPARENT,stdrot=true
|
||||
[1.19.4-]block:id=%pink_petals,state=facing:east/flower_amount:4,patch0=0:pink_petals,patch1=2000:pink_petals_stem,transparency=TRANSPARENT,stdrot=true
|
||||
|
||||
# 1.20
|
||||
[1.20-]texture:id=pitcher_crop_side,filename=assets/minecraft/textures/block/pitcher_crop_side.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=pitcher_crop_bottom,filename=assets/minecraft/textures/block/pitcher_crop_bottom.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=pitcher_crop_top,filename=assets/minecraft/textures/block/pitcher_crop_top.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=pitcher_crop_bottom_stage_1,filename=assets/minecraft/textures/block/pitcher_crop_bottom_stage_1.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=pitcher_crop_bottom_stage_2,filename=assets/minecraft/textures/block/pitcher_crop_bottom_stage_2.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=pitcher_crop_top_stage_3,filename=assets/minecraft/textures/block/pitcher_crop_top_stage_3.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=pitcher_crop_bottom_stage_3,filename=assets/minecraft/textures/block/pitcher_crop_bottom_stage_3.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=pitcher_crop_top_stage_4,filename=assets/minecraft/textures/block/pitcher_crop_top_stage_4.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=pitcher_crop_bottom_stage_4,filename=assets/minecraft/textures/block/pitcher_crop_bottom_stage_4.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_not_cracked_south,filename=assets/minecraft/textures/block/sniffer_egg_not_cracked_south.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_not_cracked_bottom,filename=assets/minecraft/textures/block/sniffer_egg_not_cracked_bottom.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_not_cracked_east,filename=assets/minecraft/textures/block/sniffer_egg_not_cracked_east.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_not_cracked_west,filename=assets/minecraft/textures/block/sniffer_egg_not_cracked_west.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_not_cracked_north,filename=assets/minecraft/textures/block/sniffer_egg_not_cracked_north.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_not_cracked_top,filename=assets/minecraft/textures/block/sniffer_egg_not_cracked_top.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_slightly_cracked_south,filename=assets/minecraft/textures/block/sniffer_egg_slightly_cracked_south.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_slightly_cracked_bottom,filename=assets/minecraft/textures/block/sniffer_egg_slightly_cracked_bottom.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_slightly_cracked_east,filename=assets/minecraft/textures/block/sniffer_egg_slightly_cracked_east.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_slightly_cracked_west,filename=assets/minecraft/textures/block/sniffer_egg_slightly_cracked_west.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_slightly_cracked_north,filename=assets/minecraft/textures/block/sniffer_egg_slightly_cracked_north.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_slightly_cracked_top,filename=assets/minecraft/textures/block/sniffer_egg_slightly_cracked_top.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_very_cracked_south,filename=assets/minecraft/textures/block/sniffer_egg_very_cracked_south.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_very_cracked_bottom,filename=assets/minecraft/textures/block/sniffer_egg_very_cracked_bottom.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_very_cracked_east,filename=assets/minecraft/textures/block/sniffer_egg_very_cracked_east.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_very_cracked_west,filename=assets/minecraft/textures/block/sniffer_egg_very_cracked_west.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_very_cracked_north,filename=assets/minecraft/textures/block/sniffer_egg_very_cracked_north.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=sniffer_egg_very_cracked_top,filename=assets/minecraft/textures/block/sniffer_egg_very_cracked_top.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=calibrated_sculk_sensor_input_side,filename=assets/minecraft/textures/block/calibrated_sculk_sensor_input_side.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=calibrated_sculk_sensor_top,filename=assets/minecraft/textures/block/calibrated_sculk_sensor_top.png,xcount=1,ycount=1
|
||||
[1.20-]texture:id=calibrated_sculk_sensor_amethyst,filename=assets/minecraft/textures/block/calibrated_sculk_sensor_amethyst.png,xcount=1,ycount=1
|
||||
[1.20-]block:id=%pitcher_crop,state=age:0/half:upper,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:0/half:lower,patch0=0:pitcher_crop_side,patch1=0:pitcher_crop_bottom,patch2=0:pitcher_crop_top,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:1/half:upper,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:1/half:lower,patch0=0:pitcher_crop_bottom_stage_1,patch1=0:pitcher_crop_side,patch2=0:pitcher_crop_bottom,patch3=0:pitcher_crop_top,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:2/half:upper,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:2/half:lower,patch0=0:pitcher_crop_bottom_stage_2,patch1=0:pitcher_crop_side,patch2=0:pitcher_crop_bottom,patch3=0:pitcher_crop_top,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:3/half:upper,patch0=0:pitcher_crop_top_stage_3,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:3/half:lower,patch0=0:pitcher_crop_bottom_stage_3,patch1=0:pitcher_crop_side,patch2=0:pitcher_crop_bottom,patch3=0:pitcher_crop_top,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:4/half:upper,patch0=0:pitcher_crop_top_stage_4,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_crop,state=age:4/half:lower,patch0=0:pitcher_crop_bottom_stage_4,patch1=0:pitcher_crop_side,patch2=0:pitcher_crop_bottom,patch3=0:pitcher_crop_top,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_plant,state=half:upper,patch0=0:pitcher_crop_top_stage_4,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%pitcher_plant,state=half:lower,patch0=0:pitcher_crop_bottom_stage_4,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%sniffer_egg,state=hatch:0,patch0=0:sniffer_egg_not_cracked_south,patch1=0:sniffer_egg_not_cracked_bottom,patch2=0:sniffer_egg_not_cracked_east,patch3=0:sniffer_egg_not_cracked_west,patch4=0:sniffer_egg_not_cracked_north,patch5=0:sniffer_egg_not_cracked_top,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%sniffer_egg,state=hatch:1,patch0=0:sniffer_egg_slightly_cracked_south,patch1=0:sniffer_egg_slightly_cracked_bottom,patch2=0:sniffer_egg_slightly_cracked_east,patch3=0:sniffer_egg_slightly_cracked_west,patch4=0:sniffer_egg_slightly_cracked_north,patch5=0:sniffer_egg_slightly_cracked_top,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%sniffer_egg,state=hatch:2,patch0=0:sniffer_egg_very_cracked_south,patch1=0:sniffer_egg_very_cracked_bottom,patch2=0:sniffer_egg_very_cracked_east,patch3=0:sniffer_egg_very_cracked_west,patch4=0:sniffer_egg_very_cracked_north,patch5=0:sniffer_egg_very_cracked_top,transparency=TRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:north/sculk_sensor_phase:inactive,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_inactive,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:north/sculk_sensor_phase:active,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_active,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:north/sculk_sensor_phase:cooldown,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_active,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:south/sculk_sensor_phase:inactive,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_inactive,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:south/sculk_sensor_phase:active,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_active,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:south/sculk_sensor_phase:cooldown,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_active,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:west/sculk_sensor_phase:inactive,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_inactive,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:west/sculk_sensor_phase:active,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_active,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:west/sculk_sensor_phase:cooldown,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_active,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:east/sculk_sensor_phase:inactive,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_inactive,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:east/sculk_sensor_phase:active,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_active,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
[1.20-]block:id=%calibrated_sculk_sensor,state=facing:east/sculk_sensor_phase:cooldown,patch0=0:calibrated_sculk_sensor_input_side,patch1=0:sculk_sensor_bottom,patch2=0:sculk_sensor_side,patch3=0:calibrated_sculk_sensor_top,patch4=0:sculk_sensor_tendril_active,patch5=0:calibrated_sculk_sensor_amethyst,transparency=SEMITRANSPARENT,stdrot=true
|
||||
|
|
After Width: | Height: | Size: 194 B |
After Width: | Height: | Size: 284 B |
After Width: | Height: | Size: 256 B |
Before Width: | Height: | Size: 93 B After Width: | Height: | Size: 80 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 160 B |
After Width: | Height: | Size: 206 B |
After Width: | Height: | Size: 190 B |
After Width: | Height: | Size: 201 B |
After Width: | Height: | Size: 168 B |
After Width: | Height: | Size: 185 B |
After Width: | Height: | Size: 203 B |
After Width: | Height: | Size: 235 B |
Before Width: | Height: | Size: 298 B After Width: | Height: | Size: 293 B |
After Width: | Height: | Size: 207 B |
After Width: | Height: | Size: 263 B |
After Width: | Height: | Size: 305 B |
After Width: | Height: | Size: 295 B |
After Width: | Height: | Size: 229 B |
After Width: | Height: | Size: 269 B |
After Width: | Height: | Size: 222 B |
After Width: | Height: | Size: 301 B |
After Width: | Height: | Size: 350 B |
After Width: | Height: | Size: 331 B |
After Width: | Height: | Size: 275 B |
After Width: | Height: | Size: 312 B |
After Width: | Height: | Size: 232 B |
After Width: | Height: | Size: 323 B |
After Width: | Height: | Size: 365 B |
After Width: | Height: | Size: 353 B |
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 332 B |
After Width: | Height: | Size: 293 B |
After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 302 B |
After Width: | Height: | Size: 295 B |
Before Width: | Height: | Size: 422 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 196 B After Width: | Height: | Size: 134 B |
Before Width: | Height: | Size: 312 B After Width: | Height: | Size: 201 B |
|
@ -28,6 +28,7 @@ eclipse {
|
|||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'https://libraries.minecraft.net/' }
|
||||
maven { url "https://oss.sonatype.org/content/repositories/releases" }
|
||||
maven { url "https://repo.mikeprimm.com" }
|
||||
maven { url "https://repo.maven.apache.org/maven2" }
|
||||
|
@ -38,7 +39,7 @@ allprojects {
|
|||
apply plugin: 'java'
|
||||
|
||||
group = 'us.dynmap'
|
||||
version = '3.5'
|
||||
version = '3.6-beta-1'
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,6 @@ dependencies {
|
|||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.bukkit', name: 'bukkit', version:'1.13.2-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.bukkit', name: 'craftbukkit', version:'1.13.2-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.bukkit', name: 'bukkit', version:'1.13.2-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.bukkit', name: 'craftbukkit', version:'1.13.2-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ dependencies {
|
|||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.bukkit', name: 'bukkit', version:'1.14.1-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.bukkit', name: 'craftbukkit', version:'1.14.1-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.bukkit', name: 'bukkit', version:'1.14.1-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.bukkit', name: 'craftbukkit', version:'1.14.1-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ dependencies {
|
|||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.bukkit', name: 'bukkit', version:'1.15-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.bukkit', name: 'craftbukkit', version:'1.15-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.bukkit', name: 'bukkit', version:'1.15-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.bukkit', name: 'craftbukkit', version:'1.15-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ dependencies {
|
|||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.16.2-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.16.2-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.16.2-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.16.2-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ dependencies {
|
|||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.16.3-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.16.3-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.16.3-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.16.3-R0.1-SNAPSHOT'
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ dependencies {
|
|||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.16.4-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.16.4-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.16.4-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.16.4-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@ dependencies {
|
|||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.16.1-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.16.1-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.16.1-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.16.1-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@ eclipse {
|
|||
|
||||
description = 'bukkit-helper-1.17'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(16) // Need this here so eclipse task generates correctly.
|
||||
|
||||
dependencies {
|
||||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.17-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.17-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.17-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.17-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@ eclipse {
|
|||
|
||||
description = 'bukkit-helper-1.18.2'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
dependencies {
|
||||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.18.2-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.18.2-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.18.2-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.18.2-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@ eclipse {
|
|||
|
||||
description = 'bukkit-helper-1.18'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
dependencies {
|
||||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.18-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.18-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.18-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.18-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@ eclipse {
|
|||
|
||||
description = 'bukkit-helper-1.19.3'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
dependencies {
|
||||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.19.3-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.19.3-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.19.3-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.19.3-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -6,10 +6,12 @@ eclipse {
|
|||
|
||||
description = 'bukkit-helper-1.19.4'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
dependencies {
|
||||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.19.4-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.19.4-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.19.4-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.19.4-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import net.minecraft.world.level.block.Block;
|
|||
import net.minecraft.world.level.block.BlockFluids;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
@ -336,12 +337,12 @@ public class BukkitVersionHelperSpigot119_4 extends BukkitVersionHelper {
|
|||
|
||||
@Override
|
||||
public long getInhabitedTicks(Chunk c) {
|
||||
return ((CraftChunk)c).getHandle().u();
|
||||
return ((CraftChunk)c).getHandle(ChunkStatus.o).u();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<?, ?> getTileEntitiesForChunk(Chunk c) {
|
||||
return ((CraftChunk)c).getHandle().i;
|
||||
return ((CraftChunk)c).getHandle(ChunkStatus.o).i;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,10 +6,12 @@ eclipse {
|
|||
|
||||
description = 'bukkit-helper-1.19'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
dependencies {
|
||||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.19-R0.1-SNAPSHOT'
|
||||
implementation group: 'org.spigotmc', name: 'spigot', version:'1.19-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.19-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.19-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
/build/
|
||||
/bin/
|
|
@ -0,0 +1,17 @@
|
|||
eclipse {
|
||||
project {
|
||||
name = "Dynmap(Spigot-1.20)"
|
||||
}
|
||||
}
|
||||
|
||||
description = 'bukkit-helper-1.20'
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
dependencies {
|
||||
implementation project(':bukkit-helper')
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot-api', version:'1.20-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'org.spigotmc', name: 'spigot', version:'1.20-R0.1-SNAPSHOT'
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package org.dynmap.bukkit.helper.v120;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.world.level.chunk.IChunkAccess;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||
import org.dynmap.MapManager;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* The provider used to work with paper libs
|
||||
* Because paper libs need java 17 we can't interact with them directly
|
||||
*/
|
||||
@SuppressWarnings({"JavaReflectionMemberAccess"}) //java don't know about paper
|
||||
public class AsyncChunkProvider120 {
|
||||
private final Method getChunk;
|
||||
private final Method getAsyncSaveData;
|
||||
private final Method save;
|
||||
private final Enum<?> data;
|
||||
private final Enum<?> priority;
|
||||
private int currTick = MinecraftServer.currentTick;
|
||||
private int currChunks = 0;
|
||||
|
||||
AsyncChunkProvider120() {
|
||||
try {
|
||||
Method getChunk1 = null;
|
||||
Method getAsyncSaveData1 = null;
|
||||
Method save1 = null;
|
||||
Enum<?> priority1 = null;
|
||||
Enum<?> data1 = null;
|
||||
try {
|
||||
Class<?> threadClass = Class.forName("io.papermc.paper.chunk.system.io.RegionFileIOThread");
|
||||
|
||||
Class<?> dataclass = Arrays.stream(threadClass.getDeclaredClasses())
|
||||
.filter(c -> c.getSimpleName().equals("RegionFileType"))
|
||||
.findAny()
|
||||
.orElseThrow(NullPointerException::new);
|
||||
data1 = Enum.valueOf(cast(dataclass), "CHUNK_DATA");
|
||||
|
||||
Class<?> priorityClass = Arrays.stream(Class.forName("ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor").getClasses())
|
||||
.filter(c -> c.getSimpleName().equals("Priority"))
|
||||
.findAny()
|
||||
.orElseThrow(NullPointerException::new);
|
||||
//Almost lowest priority, but not quite so low as to be considered idle
|
||||
//COMPLETING->BLOCKING->HIGHEST->HIGHER->HIGH->NORMAL->LOW->LOWER->LOWEST->IDLE
|
||||
priority1 = Enum.valueOf(cast(priorityClass), "LOWEST");
|
||||
|
||||
getAsyncSaveData1 = ChunkRegionLoader.class.getMethod("getAsyncSaveData", WorldServer.class, IChunkAccess.class);
|
||||
save1 = ChunkRegionLoader.class.getMethod("saveChunk", WorldServer.class, IChunkAccess.class, getAsyncSaveData1.getReturnType());
|
||||
getChunk1 = threadClass.getMethod("loadDataAsync", WorldServer.class, int.class, int.class, data1.getClass(), BiConsumer.class, boolean.class, priority1.getClass());
|
||||
} catch (ClassNotFoundException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
getAsyncSaveData = Objects.requireNonNull(getAsyncSaveData1);
|
||||
save = Objects.requireNonNull(save1);
|
||||
getChunk = Objects.requireNonNull(getChunk1);
|
||||
data = Objects.requireNonNull(data1);
|
||||
priority = Objects.requireNonNull(priority1);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> T cast(Object o) {
|
||||
return (T) o;
|
||||
}
|
||||
public CompletableFuture<NBTTagCompound> getChunk(WorldServer world, int x, int y) throws InvocationTargetException, IllegalAccessException {
|
||||
CompletableFuture<NBTTagCompound> future = new CompletableFuture<>();
|
||||
getChunk.invoke(null, world, x, y, data, (BiConsumer<NBTTagCompound, Throwable>) (nbt, exception) -> future.complete(nbt), true, priority);
|
||||
return future;
|
||||
}
|
||||
|
||||
public synchronized Supplier<NBTTagCompound> getLoadedChunk(CraftWorld world, int x, int z) {
|
||||
if (!world.isChunkLoaded(x, z)) return () -> null;
|
||||
Chunk c = world.getHandle().getChunkIfLoaded(x, z); //already safe async on vanilla
|
||||
if ((c == null) || !c.q) return () -> null; // c.loaded
|
||||
if (currTick != MinecraftServer.currentTick) {
|
||||
currTick = MinecraftServer.currentTick;
|
||||
currChunks = 0;
|
||||
}
|
||||
//prepare data synchronously
|
||||
CompletableFuture<?> future = CompletableFuture.supplyAsync(() -> {
|
||||
//Null will mean that we save with spigot methods, which may be risky on async
|
||||
//Since we're not in main thread, it now refuses new tasks because of shutdown, the risk is lower
|
||||
if (!Bukkit.isPrimaryThread()) return null;
|
||||
try {
|
||||
return getAsyncSaveData.invoke(null, world.getHandle(), c);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}, ((CraftServer) Bukkit.getServer()).getServer());
|
||||
//we shouldn't stress main thread
|
||||
if (++currChunks > MapManager.mapman.getMaxChunkLoadsPerTick()) {
|
||||
try {
|
||||
Thread.sleep(25); //hold the lock so other threads also won't stress main thread
|
||||
} catch (InterruptedException ignored) {}
|
||||
}
|
||||
//save data asynchronously
|
||||
return () -> {
|
||||
Object o = null;
|
||||
try {
|
||||
o = future.get();
|
||||
return (NBTTagCompound) save.invoke(null, world.getHandle(), c, o);
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
//We tried to use simple spigot methods at shutdown and failed, hopes for reading from disk
|
||||
if (o == null) return null;
|
||||
throw new RuntimeException(e);
|
||||
} catch (ReflectiveOperationException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,464 @@
|
|||
package org.dynmap.bukkit.helper.v120;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.bukkit.helper.BukkitMaterial;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelper;
|
||||
import org.dynmap.bukkit.helper.BukkitWorld;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelperGeneric.TexturesPayload;
|
||||
import org.dynmap.renderer.DynmapBlockState;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.Polygon;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
|
||||
import net.minecraft.core.RegistryBlockID;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.core.IRegistry;
|
||||
import net.minecraft.nbt.NBTTagByteArray;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagShort;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tags.TagsBlock;
|
||||
import net.minecraft.world.level.BlockAccessAir;
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.BlockFluids;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.chunk.ChunkStatus;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Helper for isolation of bukkit version specific issues
|
||||
*/
|
||||
public class BukkitVersionHelperSpigot120 extends BukkitVersionHelper {
|
||||
private final boolean unsafeAsync;
|
||||
|
||||
public BukkitVersionHelperSpigot120() {
|
||||
boolean unsafeAsync1;
|
||||
try {
|
||||
Class.forName("io.papermc.paper.chunk.system.io.RegionFileIOThread");
|
||||
unsafeAsync1 = false;
|
||||
} catch (ClassNotFoundException e) {
|
||||
unsafeAsync1 = true;
|
||||
}
|
||||
this.unsafeAsync = unsafeAsync1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnsafeAsync() {
|
||||
return unsafeAsync;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block short name list
|
||||
*/
|
||||
@Override
|
||||
public String[] getBlockNames() {
|
||||
RegistryBlockID<IBlockData> bsids = Block.o;
|
||||
Block baseb = null;
|
||||
Iterator<IBlockData> iter = bsids.iterator();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
while (iter.hasNext()) {
|
||||
IBlockData bs = iter.next();
|
||||
Block b = bs.b();
|
||||
// If this is new block vs last, it's the base block state
|
||||
if (b != baseb) {
|
||||
baseb = b;
|
||||
continue;
|
||||
}
|
||||
MinecraftKey id = BuiltInRegistries.f.b(b);
|
||||
String bn = id.toString();
|
||||
if (bn != null) {
|
||||
names.add(bn);
|
||||
Log.info("block=" + bn);
|
||||
}
|
||||
}
|
||||
return names.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private static IRegistry<BiomeBase> reg = null;
|
||||
|
||||
private static IRegistry<BiomeBase> getBiomeReg() {
|
||||
if (reg == null) {
|
||||
reg = MinecraftServer.getServer().aV().d(Registries.ap);
|
||||
}
|
||||
return reg;
|
||||
}
|
||||
|
||||
private Object[] biomelist;
|
||||
/**
|
||||
* Get list of defined biomebase objects
|
||||
*/
|
||||
@Override
|
||||
public Object[] getBiomeBaseList() {
|
||||
if (biomelist == null) {
|
||||
biomelist = new BiomeBase[256];
|
||||
Iterator<BiomeBase> iter = getBiomeReg().iterator();
|
||||
while (iter.hasNext()) {
|
||||
BiomeBase b = iter.next();
|
||||
int bidx = getBiomeReg().a(b);
|
||||
if (bidx >= biomelist.length) {
|
||||
biomelist = Arrays.copyOf(biomelist, bidx + biomelist.length);
|
||||
}
|
||||
biomelist[bidx] = b;
|
||||
}
|
||||
}
|
||||
return biomelist;
|
||||
}
|
||||
|
||||
/** Get ID from biomebase */
|
||||
@Override
|
||||
public int getBiomeBaseID(Object bb) {
|
||||
return getBiomeReg().a((BiomeBase)bb);
|
||||
}
|
||||
|
||||
public static IdentityHashMap<IBlockData, DynmapBlockState> dataToState;
|
||||
|
||||
/**
|
||||
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
|
||||
*/
|
||||
@Override
|
||||
public void initializeBlockStates() {
|
||||
dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
|
||||
HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
|
||||
RegistryBlockID<IBlockData> bsids = Block.o;
|
||||
Block baseb = null;
|
||||
Iterator<IBlockData> iter = bsids.iterator();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
// Loop through block data states
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
IBlockData bd = iter.next();
|
||||
Block b = bd.b();
|
||||
MinecraftKey id = BuiltInRegistries.f.b(b);
|
||||
String bname = id.toString();
|
||||
DynmapBlockState lastbs = lastBlockState.get(bname); // See if we have seen this one
|
||||
int idx = 0;
|
||||
if (lastbs != null) { // Yes
|
||||
idx = lastbs.getStateCount(); // Get number of states so far, since this is next
|
||||
}
|
||||
// Build state name
|
||||
String sb = "";
|
||||
String fname = bd.toString();
|
||||
int off1 = fname.indexOf('[');
|
||||
if (off1 >= 0) {
|
||||
int off2 = fname.indexOf(']');
|
||||
sb = fname.substring(off1+1, off2);
|
||||
}
|
||||
int lightAtten = b.g(bd, BlockAccessAir.a, BlockPosition.b); // getLightBlock
|
||||
//Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setAttenuatesLight(lightAtten);
|
||||
if (bd.w() != null) { bld.setMaterial(bd.w().toString()); }
|
||||
if (bd.e()) { bld.setSolid(); }
|
||||
if (bd.i()) { bld.setAir(); }
|
||||
if (bd.a(TagsBlock.t)) { bld.setLog(); }
|
||||
if (bd.a(TagsBlock.O)) { bld.setLeaves(); }
|
||||
if ((!bd.u().c()) && ((bd.b() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
|
||||
bld.setWaterlogged();
|
||||
//Log.info("statename=" + bname + "[" + sb + "] = waterlogged");
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
|
||||
dataToState.put(bd, dbs);
|
||||
lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
|
||||
Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create chunk cache for given chunks of given world
|
||||
* @param dw - world
|
||||
* @param chunks - chunk list
|
||||
* @return cache
|
||||
*/
|
||||
@Override
|
||||
public MapChunkCache getChunkCache(BukkitWorld dw, List<DynmapChunk> chunks) {
|
||||
MapChunkCache120 c = new MapChunkCache120(gencache);
|
||||
c.setChunks(dw, chunks);
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get biome base water multiplier
|
||||
*/
|
||||
@Override
|
||||
public int getBiomeBaseWaterMult(Object bb) {
|
||||
BiomeBase biome = (BiomeBase) bb;
|
||||
return biome.i(); // waterColor
|
||||
}
|
||||
|
||||
/** Get temperature from biomebase */
|
||||
@Override
|
||||
public float getBiomeBaseTemperature(Object bb) {
|
||||
return ((BiomeBase)bb).g();
|
||||
}
|
||||
|
||||
/** Get humidity from biomebase */
|
||||
@Override
|
||||
public float getBiomeBaseHumidity(Object bb) {
|
||||
String vals = ((BiomeBase)bb).i.toString(); // Sleazy
|
||||
float humidity = 0.5F;
|
||||
int idx = vals.indexOf("downfall=");
|
||||
if (idx >= 0) {
|
||||
humidity = Float.parseFloat(vals.substring(idx+9, vals.indexOf(']', idx)));
|
||||
}
|
||||
return humidity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder(World world) {
|
||||
Polygon p = null;
|
||||
WorldBorder wb = world.getWorldBorder();
|
||||
if (wb != null) {
|
||||
Location c = wb.getCenter();
|
||||
double size = wb.getSize();
|
||||
if ((size > 1) && (size < 1E7)) {
|
||||
size = size / 2;
|
||||
p = new Polygon();
|
||||
p.addVertex(c.getX()-size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()-size);
|
||||
p.addVertex(c.getX()+size, c.getZ()+size);
|
||||
p.addVertex(c.getX()-size, c.getZ()+size);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
// Send title/subtitle to user
|
||||
public void sendTitleText(Player p, String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTIcks) {
|
||||
if (p != null) {
|
||||
p.sendTitle(title, subtitle, fadeInTicks, stayTicks, fadeOutTIcks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get material map by block ID
|
||||
*/
|
||||
@Override
|
||||
public BukkitMaterial[] getMaterialList() {
|
||||
return new BukkitMaterial[4096]; // Not used
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unloadChunkNoSave(World w, org.bukkit.Chunk c, int cx, int cz) {
|
||||
Log.severe("unloadChunkNoSave not implemented");
|
||||
}
|
||||
|
||||
private String[] biomenames;
|
||||
@Override
|
||||
public String[] getBiomeNames() {
|
||||
if (biomenames == null) {
|
||||
biomenames = new String[256];
|
||||
Iterator<BiomeBase> iter = getBiomeReg().iterator();
|
||||
while (iter.hasNext()) {
|
||||
BiomeBase b = iter.next();
|
||||
int bidx = getBiomeReg().a(b);
|
||||
if (bidx >= biomenames.length) {
|
||||
biomenames = Arrays.copyOf(biomenames, bidx + biomenames.length);
|
||||
}
|
||||
biomenames[bidx] = b.toString();
|
||||
}
|
||||
}
|
||||
return biomenames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStateStringByCombinedId(int blkid, int meta) {
|
||||
Log.severe("getStateStringByCombinedId not implemented");
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
/** Get ID string from biomebase */
|
||||
public String getBiomeBaseIDString(Object bb) {
|
||||
return getBiomeReg().b((BiomeBase)bb).a();
|
||||
}
|
||||
@Override
|
||||
public String getBiomeBaseResourceLocsation(Object bb) {
|
||||
return getBiomeReg().b((BiomeBase)bb).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getUnloadQueue(World world) {
|
||||
Log.warning("getUnloadQueue not implemented yet");
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInUnloadQueue(Object unloadqueue, int x, int z) {
|
||||
Log.warning("isInUnloadQueue not implemented yet");
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getBiomeBaseFromSnapshot(ChunkSnapshot css) {
|
||||
Log.warning("getBiomeBaseFromSnapshot not implemented yet");
|
||||
// TODO Auto-generated method stub
|
||||
return new Object[256];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getInhabitedTicks(Chunk c) {
|
||||
return ((CraftChunk)c).getHandle(ChunkStatus.n).u();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<?, ?> getTileEntitiesForChunk(Chunk c) {
|
||||
return ((CraftChunk)c).getHandle(ChunkStatus.n).k;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityX(Object te) {
|
||||
TileEntity tileent = (TileEntity) te;
|
||||
return tileent.p().u();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityY(Object te) {
|
||||
TileEntity tileent = (TileEntity) te;
|
||||
return tileent.p().v();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTileEntityZ(Object te) {
|
||||
TileEntity tileent = (TileEntity) te;
|
||||
return tileent.p().w();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object readTileEntityNBT(Object te) {
|
||||
TileEntity tileent = (TileEntity) te;
|
||||
NBTTagCompound nbt = tileent.n();
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getFieldValue(Object nbt, String field) {
|
||||
NBTTagCompound rec = (NBTTagCompound) nbt;
|
||||
NBTBase val = rec.c(field);
|
||||
if(val == null) return null;
|
||||
if(val instanceof NBTTagByte) {
|
||||
return ((NBTTagByte)val).h();
|
||||
}
|
||||
else if(val instanceof NBTTagShort) {
|
||||
return ((NBTTagShort)val).g();
|
||||
}
|
||||
else if(val instanceof NBTTagInt) {
|
||||
return ((NBTTagInt)val).f();
|
||||
}
|
||||
else if(val instanceof NBTTagLong) {
|
||||
return ((NBTTagLong)val).e();
|
||||
}
|
||||
else if(val instanceof NBTTagFloat) {
|
||||
return ((NBTTagFloat)val).j();
|
||||
}
|
||||
else if(val instanceof NBTTagDouble) {
|
||||
return ((NBTTagDouble)val).i();
|
||||
}
|
||||
else if(val instanceof NBTTagByteArray) {
|
||||
return ((NBTTagByteArray)val).d();
|
||||
}
|
||||
else if(val instanceof NBTTagString) {
|
||||
return ((NBTTagString)val).m_();
|
||||
}
|
||||
else if(val instanceof NBTTagIntArray) {
|
||||
return ((NBTTagIntArray)val).f();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player[] getOnlinePlayers() {
|
||||
Collection<? extends Player> p = Bukkit.getServer().getOnlinePlayers();
|
||||
return p.toArray(new Player[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth(Player p) {
|
||||
return p.getHealth();
|
||||
}
|
||||
|
||||
private static final Gson gson = new GsonBuilder().create();
|
||||
|
||||
/**
|
||||
* Get skin URL for player
|
||||
* @param player
|
||||
*/
|
||||
@Override
|
||||
public String getSkinURL(Player player) {
|
||||
String url = null;
|
||||
CraftPlayer cp = (CraftPlayer)player;
|
||||
GameProfile profile = cp.getProfile();
|
||||
if (profile != null) {
|
||||
PropertyMap pm = profile.getProperties();
|
||||
if (pm != null) {
|
||||
Collection<Property> txt = pm.get("textures");
|
||||
Property textureProperty = Iterables.getFirst(pm.get("textures"), null);
|
||||
if (textureProperty != null) {
|
||||
String val = textureProperty.getValue();
|
||||
if (val != null) {
|
||||
TexturesPayload result = null;
|
||||
try {
|
||||
String json = new String(Base64.getDecoder().decode(val), StandardCharsets.UTF_8);
|
||||
result = gson.fromJson(json, TexturesPayload.class);
|
||||
} catch (JsonParseException e) {
|
||||
} catch (IllegalArgumentException x) {
|
||||
Log.warning("Malformed response from skin URL check: " + val);
|
||||
}
|
||||
if ((result != null) && (result.textures != null) && (result.textures.containsKey("SKIN"))) {
|
||||
url = result.textures.get("SKIN").url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
// Get minY for world
|
||||
@Override
|
||||
public int getWorldMinY(World w) {
|
||||
CraftWorld cw = (CraftWorld) w;
|
||||
return cw.getMinHeight();
|
||||
}
|
||||
@Override
|
||||
public boolean useGenericCache() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package org.dynmap.bukkit.helper.v120;
|
||||
|
||||
import net.minecraft.world.level.biome.BiomeBase;
|
||||
import net.minecraft.world.level.biome.BiomeFog;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_20_R1.CraftWorld;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.bukkit.helper.BukkitVersionHelper;
|
||||
import org.dynmap.bukkit.helper.BukkitWorld;
|
||||
import org.dynmap.bukkit.helper.v120.AsyncChunkProvider120;
|
||||
import org.dynmap.bukkit.helper.v120.NBT;
|
||||
import org.dynmap.common.BiomeMap;
|
||||
import org.dynmap.common.chunk.GenericChunk;
|
||||
import org.dynmap.common.chunk.GenericChunkCache;
|
||||
import org.dynmap.common.chunk.GenericMapChunkCache;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
|
||||
import net.minecraft.world.level.chunk.Chunk;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
|
||||
*/
|
||||
public class MapChunkCache120 extends GenericMapChunkCache {
|
||||
private static final AsyncChunkProvider120 provider = BukkitVersionHelper.helper.isUnsafeAsync() ? null : new AsyncChunkProvider120();
|
||||
private World w;
|
||||
/**
|
||||
* Construct empty cache
|
||||
*/
|
||||
public MapChunkCache120(GenericChunkCache cc) {
|
||||
super(cc);
|
||||
}
|
||||
|
||||
// Load generic chunk from existing and already loaded chunk
|
||||
@Override
|
||||
protected Supplier<GenericChunk> getLoadedChunkAsync(DynmapChunk chunk) {
|
||||
Supplier<NBTTagCompound> supplier = provider.getLoadedChunk((CraftWorld) w, chunk.x, chunk.z);
|
||||
return () -> {
|
||||
NBTTagCompound nbt = supplier.get();
|
||||
return nbt != null ? parseChunkFromNBT(new NBT.NBTCompound(nbt)) : null;
|
||||
};
|
||||
}
|
||||
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
|
||||
CraftWorld cw = (CraftWorld) w;
|
||||
if (!cw.isChunkLoaded(chunk.x, chunk.z)) return null;
|
||||
Chunk c = cw.getHandle().getChunkIfLoaded(chunk.x, chunk.z);
|
||||
if (c == null || !c.q) return null; // c.loaded
|
||||
NBTTagCompound nbt = ChunkRegionLoader.a(cw.getHandle(), c);
|
||||
return nbt != null ? parseChunkFromNBT(new NBT.NBTCompound(nbt)) : null;
|
||||
}
|
||||
|
||||
// Load generic chunk from unloaded chunk
|
||||
@Override
|
||||
protected Supplier<GenericChunk> loadChunkAsync(DynmapChunk chunk){
|
||||
try {
|
||||
CompletableFuture<NBTTagCompound> nbt = provider.getChunk(((CraftWorld) w).getHandle(), chunk.x, chunk.z);
|
||||
return () -> {
|
||||
NBTTagCompound compound;
|
||||
try {
|
||||
compound = nbt.get();
|
||||
} catch (InterruptedException e) {
|
||||
return null;
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return compound == null ? null : parseChunkFromNBT(new NBT.NBTCompound(compound));
|
||||
};
|
||||
} catch (InvocationTargetException | IllegalAccessException ignored) {
|
||||
return () -> null;
|
||||
}
|
||||
}
|
||||
|
||||
protected GenericChunk loadChunk(DynmapChunk chunk) {
|
||||
CraftWorld cw = (CraftWorld) w;
|
||||
NBTTagCompound nbt = null;
|
||||
ChunkCoordIntPair cc = new ChunkCoordIntPair(chunk.x, chunk.z);
|
||||
GenericChunk gc = null;
|
||||
try { // BUGBUG - convert this all to asyn properly, since now native async
|
||||
nbt = cw.getHandle().k().a.e(cc).join().get(); // playerChunkMap
|
||||
} catch (CancellationException cx) {
|
||||
} catch (NoSuchElementException snex) {
|
||||
}
|
||||
if (nbt != null) {
|
||||
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
|
||||
}
|
||||
return gc;
|
||||
}
|
||||
|
||||
public void setChunks(BukkitWorld dw, List<DynmapChunk> chunks) {
|
||||
this.w = dw.getWorld();
|
||||
super.setChunks(dw, chunks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
return bm.<BiomeBase>getBiomeObject().map(BiomeBase::h).flatMap(BiomeFog::e).orElse(colormap[bm.biomeLookup()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
BiomeFog fog = bm.<BiomeBase>getBiomeObject().map(BiomeBase::h).orElse(null);
|
||||
if (fog == null) return colormap[bm.biomeLookup()];
|
||||
return fog.g().a(x, z, fog.f().orElse(colormap[bm.biomeLookup()]));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package org.dynmap.bukkit.helper.v120;
|
||||
|
||||
import org.dynmap.common.chunk.GenericBitStorage;
|
||||
import org.dynmap.common.chunk.GenericNBTCompound;
|
||||
import org.dynmap.common.chunk.GenericNBTList;
|
||||
|
||||
import java.util.Set;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.SimpleBitStorage;
|
||||
|
||||
public class NBT {
|
||||
|
||||
public static class NBTCompound implements GenericNBTCompound {
|
||||
private final NBTTagCompound obj;
|
||||
public NBTCompound(NBTTagCompound t) {
|
||||
this.obj = t;
|
||||
}
|
||||
@Override
|
||||
public Set<String> getAllKeys() {
|
||||
return obj.e();
|
||||
}
|
||||
@Override
|
||||
public boolean contains(String s) {
|
||||
return obj.e(s);
|
||||
}
|
||||
@Override
|
||||
public boolean contains(String s, int i) {
|
||||
return obj.b(s, i);
|
||||
}
|
||||
@Override
|
||||
public byte getByte(String s) {
|
||||
return obj.f(s);
|
||||
}
|
||||
@Override
|
||||
public short getShort(String s) {
|
||||
return obj.g(s);
|
||||
}
|
||||
@Override
|
||||
public int getInt(String s) {
|
||||
return obj.h(s);
|
||||
}
|
||||
@Override
|
||||
public long getLong(String s) {
|
||||
return obj.i(s);
|
||||
}
|
||||
@Override
|
||||
public float getFloat(String s) {
|
||||
return obj.j(s);
|
||||
}
|
||||
@Override
|
||||
public double getDouble(String s) {
|
||||
return obj.k(s);
|
||||
}
|
||||
@Override
|
||||
public String getString(String s) {
|
||||
return obj.l(s);
|
||||
}
|
||||
@Override
|
||||
public byte[] getByteArray(String s) {
|
||||
return obj.m(s);
|
||||
}
|
||||
@Override
|
||||
public int[] getIntArray(String s) {
|
||||
return obj.n(s);
|
||||
}
|
||||
@Override
|
||||
public long[] getLongArray(String s) {
|
||||
return obj.o(s);
|
||||
}
|
||||
@Override
|
||||
public GenericNBTCompound getCompound(String s) {
|
||||
return new NBTCompound(obj.p(s));
|
||||
}
|
||||
@Override
|
||||
public GenericNBTList getList(String s, int i) {
|
||||
return new NBTList(obj.c(s, i));
|
||||
}
|
||||
@Override
|
||||
public boolean getBoolean(String s) {
|
||||
return obj.q(s);
|
||||
}
|
||||
@Override
|
||||
public String getAsString(String s) {
|
||||
return obj.c(s).m_();
|
||||
}
|
||||
@Override
|
||||
public GenericBitStorage makeBitStorage(int bits, int count, long[] data) {
|
||||
return new OurBitStorage(bits, count, data);
|
||||
}
|
||||
public String toString() {
|
||||
return obj.toString();
|
||||
}
|
||||
}
|
||||
public static class NBTList implements GenericNBTList {
|
||||
private final NBTTagList obj;
|
||||
public NBTList(NBTTagList t) {
|
||||
obj = t;
|
||||
}
|
||||
@Override
|
||||
public int size() {
|
||||
return obj.size();
|
||||
}
|
||||
@Override
|
||||
public String getString(int idx) {
|
||||
return obj.j(idx);
|
||||
}
|
||||
@Override
|
||||
public GenericNBTCompound getCompound(int idx) {
|
||||
return new NBTCompound(obj.a(idx));
|
||||
}
|
||||
public String toString() {
|
||||
return obj.toString();
|
||||
}
|
||||
}
|
||||
public static class OurBitStorage implements GenericBitStorage {
|
||||
private final SimpleBitStorage bs;
|
||||
public OurBitStorage(int bits, int count, long[] data) {
|
||||
bs = new SimpleBitStorage(bits, count, data);
|
||||
}
|
||||
@Override
|
||||
public int get(int idx) {
|
||||
return bs.a(idx);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,38 +2,35 @@
|
|||
<projectDescription>
|
||||
<name>Dynmap(Spigot-Common)</name>
|
||||
<comment>bukkit-helper</comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<projects/>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
||||
</natures>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<linkedResources/>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<name/>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
|
|
|
@ -2,7 +2,7 @@ arguments=
|
|||
auto.sync=false
|
||||
build.scans.enabled=false
|
||||
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
|
||||
connection.project.dir=../bukkit-helper-119-4
|
||||
connection.project.dir=..
|
||||
eclipse.preferences.version=1
|
||||
gradle.user.home=
|
||||
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
#
|
||||
#Wed Mar 15 22:00:51 CDT 2023
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
#Tue Jun 13 11:04:15 CDT 2023
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable=javax.annotation.Nullable
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull=javax.annotation.Nonnull
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
|
|
|
@ -11,6 +11,6 @@ description = 'bukkit-helper'
|
|||
dependencies {
|
||||
implementation project(':dynmap-api')
|
||||
implementation project(path: ':DynmapCore', configuration: 'shadow')
|
||||
implementation group: 'org.bukkit', name: 'bukkit', version:'1.10.2-R0.1-SNAPSHOT'
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version:'2.8.9'
|
||||
compileOnly group: 'org.bukkit', name: 'bukkit', version:'1.10.2-R0.1-SNAPSHOT'
|
||||
compileOnly group: 'com.google.code.gson', name: 'gson', version:'2.8.9'
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.1.10'
|
||||
}
|
||||
|
@ -12,6 +13,8 @@ eclipse {
|
|||
}
|
||||
}
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
configurations {
|
||||
shadow
|
||||
implementation.extendsFrom(shadow)
|
||||
|
|
|
@ -12,6 +12,8 @@ eclipse {
|
|||
}
|
||||
}
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
configurations {
|
||||
shadow
|
||||
implementation.extendsFrom(shadow)
|
||||
|
|
|
@ -12,6 +12,8 @@ eclipse {
|
|||
}
|
||||
}
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
configurations {
|
||||
shadow
|
||||
implementation.extendsFrom(shadow)
|
||||
|
|
|
@ -12,6 +12,8 @@ eclipse {
|
|||
}
|
||||
}
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
configurations {
|
||||
shadow
|
||||
implementation.extendsFrom(shadow)
|
||||
|
|
|
@ -12,6 +12,8 @@ eclipse {
|
|||
}
|
||||
}
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
configurations {
|
||||
shadow
|
||||
implementation.extendsFrom(shadow)
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# gradle
|
||||
|
||||
.gradle/
|
||||
build/
|
||||
out/
|
||||
classes/
|
||||
|
||||
# eclipse
|
||||
|
||||
*.launch
|
||||
|
||||
# idea
|
||||
|
||||
.idea/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# vscode
|
||||
|
||||
.settings/
|
||||
.vscode/
|
||||
bin/
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# fabric
|
||||
|
||||
run/
|
||||
|
||||
# other
|
||||
*.log
|
|
@ -0,0 +1,73 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '1.1.10'
|
||||
}
|
||||
|
||||
archivesBaseName = "Dynmap"
|
||||
version = parent.version
|
||||
group = parent.group
|
||||
|
||||
eclipse {
|
||||
project {
|
||||
name = "Dynmap(Fabric-1.20)"
|
||||
}
|
||||
}
|
||||
|
||||
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = JavaLanguageVersion.of(17) // Need this here so eclipse task generates correctly.
|
||||
|
||||
configurations {
|
||||
shadow
|
||||
implementation.extendsFrom(shadow)
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
compileOnly group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
|
||||
|
||||
shadow project(path: ':DynmapCore', configuration: 'shadow')
|
||||
|
||||
modCompileOnly "me.lucko:fabric-permissions-api:0.1-SNAPSHOT"
|
||||
compileOnly 'net.luckperms:api:5.4'
|
||||
}
|
||||
|
||||
loom {
|
||||
accessWidenerPath = file("src/main/resources/dynmap.accesswidener")
|
||||
}
|
||||
|
||||
processResources {
|
||||
filesMatching('fabric.mod.json') {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
from "LICENSE"
|
||||
from {
|
||||
configurations.shadow.collect { it.toString().contains("guava") ? null : it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
}
|
||||
|
||||
remapJar {
|
||||
archiveFileName = "${archivesBaseName}-${project.version}-fabric-${project.minecraft_version}.jar"
|
||||
destinationDirectory = file '../target'
|
||||
}
|
||||
|
||||
remapJar.doLast {
|
||||
task ->
|
||||
ant.checksum file: task.archivePath
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
minecraft_version=1.20
|
||||
yarn_mappings=1.20+build.1
|
||||
loader_version=0.14.21
|
||||
fabric_version=0.83.0+1.20
|
|
@ -0,0 +1,50 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class DynmapMod implements ModInitializer {
|
||||
private static final String MODID = "dynmap";
|
||||
private static final ModContainer MOD_CONTAINER = FabricLoader.getInstance().getModContainer(MODID)
|
||||
.orElseThrow(() -> new RuntimeException("Failed to get mod container: " + MODID));
|
||||
// The instance of your mod that Fabric uses.
|
||||
public static DynmapMod instance;
|
||||
|
||||
public static DynmapPlugin plugin;
|
||||
public static File jarfile;
|
||||
public static String ver;
|
||||
public static boolean useforcedchunks;
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
instance = this;
|
||||
|
||||
Path path = MOD_CONTAINER.getRootPath();
|
||||
try {
|
||||
jarfile = new File(DynmapCore.class.getProtectionDomain().getCodeSource().getLocation().toURI());
|
||||
} catch (URISyntaxException e) {
|
||||
Log.severe("Unable to get DynmapCore jar path", e);
|
||||
}
|
||||
|
||||
if (path.getFileSystem().provider().getScheme().equals("jar")) {
|
||||
path = Paths.get(path.getFileSystem().toString());
|
||||
jarfile = path.toFile();
|
||||
}
|
||||
|
||||
ver = MOD_CONTAINER.getMetadata().getVersion().getFriendlyString();
|
||||
|
||||
Log.setLogger(new FabricLogger());
|
||||
org.dynmap.modsupport.ModSupportImpl.init();
|
||||
|
||||
// Initialize the plugin, we will enable it fully when the server starts.
|
||||
plugin = new DynmapPlugin();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,796 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
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.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.FluidBlock;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.registry.tag.BlockTags;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.collection.IdList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.EmptyBlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkSection;
|
||||
import org.dynmap.*;
|
||||
import org.dynmap.common.BiomeMap;
|
||||
import org.dynmap.common.DynmapCommandSender;
|
||||
import org.dynmap.common.DynmapListenerManager;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.common.chunk.GenericChunkCache;
|
||||
import org.dynmap.fabric_1_20.command.DmapCommand;
|
||||
import org.dynmap.fabric_1_20.command.DmarkerCommand;
|
||||
import org.dynmap.fabric_1_20.command.DynmapCommand;
|
||||
import org.dynmap.fabric_1_20.command.DynmapExpCommand;
|
||||
import org.dynmap.fabric_1_20.event.BlockEvents;
|
||||
import org.dynmap.fabric_1_20.event.CustomServerChunkEvents;
|
||||
import org.dynmap.fabric_1_20.event.CustomServerLifecycleEvents;
|
||||
import org.dynmap.fabric_1_20.event.PlayerEvents;
|
||||
import org.dynmap.fabric_1_20.mixin.BiomeEffectsAccessor;
|
||||
import org.dynmap.fabric_1_20.permissions.*;
|
||||
import org.dynmap.permissions.PermissionsHandler;
|
||||
import org.dynmap.renderer.DynmapBlockState;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class DynmapPlugin {
|
||||
// FIXME: Fix package-private fields after splitting is done
|
||||
DynmapCore core;
|
||||
private PermissionProvider permissions;
|
||||
private boolean core_enabled;
|
||||
public GenericChunkCache sscache;
|
||||
public PlayerList playerList;
|
||||
MapManager mapManager;
|
||||
/**
|
||||
* Server is set when running and unset at shutdown.
|
||||
*/
|
||||
private net.minecraft.server.MinecraftServer server;
|
||||
public static DynmapPlugin plugin;
|
||||
ChatHandler chathandler;
|
||||
private HashMap<String, Integer> sortWeights = new HashMap<String, Integer>();
|
||||
private HashMap<String, FabricWorld> worlds = new HashMap<String, FabricWorld>();
|
||||
private WorldAccess last_world;
|
||||
private FabricWorld last_fworld;
|
||||
private Map<String, FabricPlayer> players = new HashMap<String, FabricPlayer>();
|
||||
private FabricServer fserver;
|
||||
private boolean tickregistered = false;
|
||||
// TPS calculator
|
||||
double tps;
|
||||
long lasttick;
|
||||
long avgticklen;
|
||||
// Per tick limit, in nsec
|
||||
long perTickLimit = (50000000); // 50 ms
|
||||
private boolean useSaveFolder = true;
|
||||
|
||||
private static final String[] TRIGGER_DEFAULTS = {"blockupdate", "chunkpopulate", "chunkgenerate"};
|
||||
|
||||
static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]");
|
||||
|
||||
DynmapPlugin() {
|
||||
plugin = this;
|
||||
// Fabric events persist between server instances
|
||||
ServerLifecycleEvents.SERVER_STARTING.register(this::serverStart);
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> registerCommands(dispatcher));
|
||||
CustomServerLifecycleEvents.SERVER_STARTED_PRE_WORLD_LOAD.register(this::serverStarted);
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register(this::serverStop);
|
||||
}
|
||||
|
||||
int getSortWeight(String name) {
|
||||
return sortWeights.getOrDefault(name, 0);
|
||||
}
|
||||
|
||||
void setSortWeight(String name, int wt) {
|
||||
sortWeights.put(name, wt);
|
||||
}
|
||||
|
||||
void dropSortWeight(String name) {
|
||||
sortWeights.remove(name);
|
||||
}
|
||||
|
||||
public static class BlockUpdateRec {
|
||||
WorldAccess w;
|
||||
String wid;
|
||||
int x, y, z;
|
||||
}
|
||||
|
||||
ConcurrentLinkedQueue<BlockUpdateRec> blockupdatequeue = new ConcurrentLinkedQueue<BlockUpdateRec>();
|
||||
|
||||
public static DynmapBlockState[] stateByID;
|
||||
|
||||
/**
|
||||
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
|
||||
*/
|
||||
public void initializeBlockStates() {
|
||||
stateByID = new DynmapBlockState[512 * 32]; // Simple map - scale as needed
|
||||
Arrays.fill(stateByID, DynmapBlockState.AIR); // Default to air
|
||||
|
||||
IdList<BlockState> bsids = Block.STATE_IDS;
|
||||
|
||||
DynmapBlockState basebs = null;
|
||||
Block baseb = null;
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getRawId(bs);
|
||||
if (idx >= stateByID.length) {
|
||||
int plen = stateByID.length;
|
||||
stateByID = Arrays.copyOf(stateByID, idx*11/10); // grow array by 10%
|
||||
Arrays.fill(stateByID, plen, stateByID.length, DynmapBlockState.AIR);
|
||||
}
|
||||
Block b = bs.getBlock();
|
||||
// If this is new block vs last, it's the base block state
|
||||
if (b != baseb) {
|
||||
basebs = null;
|
||||
baseidx = idx;
|
||||
baseb = b;
|
||||
}
|
||||
|
||||
Identifier ui = Registries.BLOCK.getId(b);
|
||||
if (ui == null) {
|
||||
continue;
|
||||
}
|
||||
String bn = ui.getNamespace() + ":" + ui.getPath();
|
||||
// Only do defined names, and not "air"
|
||||
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
||||
String statename = "";
|
||||
for (net.minecraft.state.property.Property<?> p : bs.getProperties()) {
|
||||
if (statename.length() > 0) {
|
||||
statename += ",";
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTransparent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (bs.getSoundGroup() != null) { bld.setMaterial(bs.getSoundGroup().toString()); }
|
||||
if (bs.isSolid()) { bld.setSolid(); }
|
||||
if (bs.isAir()) { bld.setAir(); }
|
||||
if (bs.isIn(BlockTags.LOGS)) { bld.setLog(); }
|
||||
if (bs.isIn(BlockTags.LEAVES)) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
}
|
||||
}
|
||||
// for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
// DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
|
||||
// Log.info(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
|
||||
// }
|
||||
}
|
||||
|
||||
public static final Item getItemByID(int id) {
|
||||
return Item.byRawId(id);
|
||||
}
|
||||
|
||||
FabricPlayer getOrAddPlayer(ServerPlayerEntity player) {
|
||||
String name = player.getName().getString();
|
||||
FabricPlayer fp = players.get(name);
|
||||
if (fp != null) {
|
||||
fp.player = player;
|
||||
} else {
|
||||
fp = new FabricPlayer(this, player);
|
||||
players.put(name, fp);
|
||||
}
|
||||
return fp;
|
||||
}
|
||||
|
||||
static class ChatMessage {
|
||||
String message;
|
||||
ServerPlayerEntity sender;
|
||||
}
|
||||
|
||||
ConcurrentLinkedQueue<ChatMessage> msgqueue = new ConcurrentLinkedQueue<ChatMessage>();
|
||||
|
||||
public static class ChatHandler {
|
||||
private final DynmapPlugin plugin;
|
||||
|
||||
ChatHandler(DynmapPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void handleChat(ServerPlayerEntity player, String message) {
|
||||
if (!message.startsWith("/")) {
|
||||
ChatMessage cm = new ChatMessage();
|
||||
cm.message = message;
|
||||
cm.sender = player;
|
||||
plugin.msgqueue.add(cm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FabricServer getFabricServer() {
|
||||
return fserver;
|
||||
}
|
||||
|
||||
private void serverStart(MinecraftServer server) {
|
||||
// Set the server so we don't NPE during setup
|
||||
this.server = server;
|
||||
this.fserver = new FabricServer(this, server);
|
||||
this.onEnable();
|
||||
}
|
||||
|
||||
private void serverStarted(MinecraftServer server) {
|
||||
this.onStart();
|
||||
if (core != null) {
|
||||
core.serverStarted();
|
||||
}
|
||||
}
|
||||
|
||||
private void serverStop(MinecraftServer server) {
|
||||
this.onDisable();
|
||||
this.server = null;
|
||||
}
|
||||
|
||||
public boolean isOp(String player) {
|
||||
String[] ops = server.getPlayerManager().getOpList().getNames();
|
||||
|
||||
for (String op : ops) {
|
||||
if (op.equalsIgnoreCase(player)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Consider whether cheats are enabled for integrated server
|
||||
return server.isSingleplayer() && server.isHost(server.getPlayerManager().getPlayer(player).getGameProfile());
|
||||
}
|
||||
|
||||
boolean hasPerm(PlayerEntity psender, String permission) {
|
||||
PermissionsHandler ph = PermissionsHandler.getHandler();
|
||||
if ((ph != null) && (psender != null) && ph.hasPermission(psender.getName().getString(), permission)) {
|
||||
return true;
|
||||
}
|
||||
return permissions.has(psender, permission);
|
||||
}
|
||||
|
||||
boolean hasPermNode(PlayerEntity psender, String permission) {
|
||||
PermissionsHandler ph = PermissionsHandler.getHandler();
|
||||
if ((ph != null) && (psender != null) && ph.hasPermissionNode(psender.getName().getString(), permission)) {
|
||||
return true;
|
||||
}
|
||||
return permissions.hasPermissionNode(psender, permission);
|
||||
}
|
||||
|
||||
Set<String> hasOfflinePermissions(String player, Set<String> perms) {
|
||||
Set<String> rslt = null;
|
||||
PermissionsHandler ph = PermissionsHandler.getHandler();
|
||||
if (ph != null) {
|
||||
rslt = ph.hasOfflinePermissions(player, perms);
|
||||
}
|
||||
Set<String> rslt2 = hasOfflinePermissions(player, perms);
|
||||
if ((rslt != null) && (rslt2 != null)) {
|
||||
Set<String> newrslt = new HashSet<String>(rslt);
|
||||
newrslt.addAll(rslt2);
|
||||
rslt = newrslt;
|
||||
} else if (rslt2 != null) {
|
||||
rslt = rslt2;
|
||||
}
|
||||
return rslt;
|
||||
}
|
||||
|
||||
boolean hasOfflinePermission(String player, String perm) {
|
||||
PermissionsHandler ph = PermissionsHandler.getHandler();
|
||||
if (ph != null) {
|
||||
if (ph.hasOfflinePermission(player, perm)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return permissions.hasOfflinePermission(player, perm);
|
||||
}
|
||||
|
||||
void setChatHandler(ChatHandler chatHandler) {
|
||||
plugin.chathandler = chatHandler;
|
||||
}
|
||||
|
||||
public class TexturesPayload {
|
||||
public long timestamp;
|
||||
public String profileId;
|
||||
public String profileName;
|
||||
public boolean isPublic;
|
||||
public Map<String, ProfileTexture> textures;
|
||||
|
||||
}
|
||||
|
||||
public class ProfileTexture {
|
||||
public String url;
|
||||
}
|
||||
|
||||
public void loadExtraBiomes(String mcver) {
|
||||
int cnt = 0;
|
||||
BiomeMap.loadWellKnownByVersion(mcver);
|
||||
|
||||
Registry<Biome> biomeRegistry = getFabricServer().getBiomeRegistry();
|
||||
Biome[] list = getFabricServer().getBiomeList(biomeRegistry);
|
||||
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Biome bb = list[i];
|
||||
if (bb != null) {
|
||||
String id = biomeRegistry.getId(bb).getPath();
|
||||
String rl = biomeRegistry.getId(bb).toString();
|
||||
float tmp = bb.getTemperature(), hum = bb.weather.downfall();
|
||||
int watermult = ((BiomeEffectsAccessor) bb.getEffects()).getWaterColor();
|
||||
Log.verboseinfo("biome[" + i + "]: hum=" + hum + ", tmp=" + tmp + ", mult=" + Integer.toHexString(watermult));
|
||||
|
||||
BiomeMap bmap = BiomeMap.NULL;
|
||||
if (rl != null) { // If resource location, lookup by this
|
||||
bmap = BiomeMap.byBiomeResourceLocation(rl);
|
||||
}
|
||||
else {
|
||||
bmap = BiomeMap.byBiomeID(i);
|
||||
}
|
||||
if (bmap.isDefault() || (bmap == BiomeMap.NULL)) {
|
||||
bmap = new BiomeMap((rl != null) ? BiomeMap.NO_INDEX : i, id, tmp, hum, rl);
|
||||
Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ")");
|
||||
cnt++;
|
||||
}
|
||||
else {
|
||||
bmap.setTemperature(tmp);
|
||||
bmap.setRainfall(hum);
|
||||
}
|
||||
if (watermult != -1) {
|
||||
bmap.setWaterColorMultiplier(watermult);
|
||||
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
|
||||
}
|
||||
bmap.setBiomeObject(bb);
|
||||
}
|
||||
}
|
||||
if (cnt > 0)
|
||||
Log.info("Added " + cnt + " custom biome mappings");
|
||||
}
|
||||
|
||||
private String[] getBiomeNames() {
|
||||
Registry<Biome> biomeRegistry = getFabricServer().getBiomeRegistry();
|
||||
Biome[] list = getFabricServer().getBiomeList(biomeRegistry);
|
||||
String[] lst = new String[list.length];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
Biome bb = list[i];
|
||||
if (bb != null) {
|
||||
lst[i] = biomeRegistry.getId(bb).getPath();
|
||||
}
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
/* Get MC version */
|
||||
String mcver = server.getVersion();
|
||||
|
||||
/* Load extra biomes */
|
||||
loadExtraBiomes(mcver);
|
||||
/* Set up player login/quit event handler */
|
||||
registerPlayerLoginListener();
|
||||
|
||||
/* Initialize permissions handler */
|
||||
if (FabricLoader.getInstance().isModLoaded("luckperms")) {
|
||||
Log.info("Using luckperms for access control");
|
||||
permissions = new LuckPermissions();
|
||||
}
|
||||
else if (FabricLoader.getInstance().isModLoaded("fabric-permissions-api-v0")) {
|
||||
Log.info("Using fabric-permissions-api for access control");
|
||||
permissions = new FabricPermissions();
|
||||
} else {
|
||||
/* Initialize permissions handler */
|
||||
permissions = FilePermissions.create();
|
||||
if (permissions == null) {
|
||||
permissions = new OpPermissions(new String[]{"webchat", "marker.icons", "marker.list", "webregister", "stats", "hide.self", "show.self"});
|
||||
}
|
||||
}
|
||||
/* Get and initialize data folder */
|
||||
File dataDirectory = new File("dynmap");
|
||||
|
||||
if (!dataDirectory.exists()) {
|
||||
dataDirectory.mkdirs();
|
||||
}
|
||||
|
||||
/* Instantiate core */
|
||||
if (core == null) {
|
||||
core = new DynmapCore();
|
||||
}
|
||||
|
||||
/* Inject dependencies */
|
||||
core.setPluginJarFile(DynmapMod.jarfile);
|
||||
core.setPluginVersion(DynmapMod.ver);
|
||||
core.setMinecraftVersion(mcver);
|
||||
core.setDataFolder(dataDirectory);
|
||||
core.setServer(fserver);
|
||||
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
||||
core.setBiomeNames(getBiomeNames());
|
||||
|
||||
if (!core.initConfiguration(null)) {
|
||||
return;
|
||||
}
|
||||
// Extract default permission example, if needed
|
||||
File filepermexample = new File(core.getDataFolder(), "permissions.yml.example");
|
||||
core.createDefaultFileFromResource("/permissions.yml.example", filepermexample);
|
||||
|
||||
DynmapCommonAPIListener.apiInitialized(core);
|
||||
}
|
||||
|
||||
private DynmapCommand dynmapCmd;
|
||||
private DmapCommand dmapCmd;
|
||||
private DmarkerCommand dmarkerCmd;
|
||||
private DynmapExpCommand dynmapexpCmd;
|
||||
|
||||
public void registerCommands(CommandDispatcher<ServerCommandSource> cd) {
|
||||
dynmapCmd = new DynmapCommand(this);
|
||||
dmapCmd = new DmapCommand(this);
|
||||
dmarkerCmd = new DmarkerCommand(this);
|
||||
dynmapexpCmd = new DynmapExpCommand(this);
|
||||
dynmapCmd.register(cd);
|
||||
dmapCmd.register(cd);
|
||||
dmarkerCmd.register(cd);
|
||||
dynmapexpCmd.register(cd);
|
||||
|
||||
Log.info("Register commands");
|
||||
}
|
||||
|
||||
public void onStart() {
|
||||
initializeBlockStates();
|
||||
/* Enable core */
|
||||
if (!core.enableCore(null)) {
|
||||
return;
|
||||
}
|
||||
core_enabled = true;
|
||||
VersionCheck.runCheck(core);
|
||||
// Get per tick time limit
|
||||
perTickLimit = core.getMaxTickUseMS() * 1000000;
|
||||
// Prep TPS
|
||||
lasttick = System.nanoTime();
|
||||
tps = 20.0;
|
||||
|
||||
/* Register tick handler */
|
||||
if (!tickregistered) {
|
||||
ServerTickEvents.END_SERVER_TICK.register(server -> fserver.tickEvent(server));
|
||||
tickregistered = true;
|
||||
}
|
||||
|
||||
playerList = core.playerList;
|
||||
sscache = new GenericChunkCache(core.getSnapShotCacheSize(), core.useSoftRefInSnapShotCache());
|
||||
/* Get map manager from core */
|
||||
mapManager = core.getMapManager();
|
||||
|
||||
/* Load saved world definitions */
|
||||
loadWorlds();
|
||||
|
||||
for (FabricWorld w : worlds.values()) {
|
||||
if (core.processWorldLoad(w)) { /* Have core process load first - fire event listeners if good load after */
|
||||
if (w.isLoaded()) {
|
||||
core.listenerManager.processWorldEvent(DynmapListenerManager.EventType.WORLD_LOAD, w);
|
||||
}
|
||||
}
|
||||
}
|
||||
core.updateConfigHashcode();
|
||||
|
||||
/* Register our update trigger events */
|
||||
registerEvents();
|
||||
Log.info("Register events");
|
||||
|
||||
//DynmapCommonAPIListener.apiInitialized(core);
|
||||
|
||||
Log.info("Enabled");
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
DynmapCommonAPIListener.apiTerminated();
|
||||
|
||||
//if (metrics != null) {
|
||||
// metrics.stop();
|
||||
// metrics = null;
|
||||
//}
|
||||
/* Save worlds */
|
||||
saveWorlds();
|
||||
|
||||
/* Purge tick queue */
|
||||
fserver.clearTaskQueue();
|
||||
|
||||
/* Disable core */
|
||||
core.disableCore();
|
||||
core_enabled = false;
|
||||
|
||||
if (sscache != null) {
|
||||
sscache.cleanup();
|
||||
sscache = null;
|
||||
}
|
||||
|
||||
Log.info("Disabled");
|
||||
}
|
||||
|
||||
// TODO: Clean a bit
|
||||
public void handleCommand(ServerCommandSource commandSource, String cmd, String[] args) throws CommandSyntaxException {
|
||||
DynmapCommandSender dsender;
|
||||
ServerPlayerEntity psender = null;
|
||||
|
||||
// getPlayer throws a CommandSyntaxException, so getEntity and instanceof for safety
|
||||
if (commandSource.getEntity() instanceof ServerPlayerEntity) {
|
||||
psender = commandSource.getPlayerOrThrow();
|
||||
}
|
||||
|
||||
if (psender != null) {
|
||||
// FIXME: New Player? Why not query the current player list.
|
||||
dsender = new FabricPlayer(this, psender);
|
||||
} else {
|
||||
dsender = new FabricCommandSender(commandSource);
|
||||
}
|
||||
|
||||
core.processCommand(dsender, cmd, cmd, args);
|
||||
}
|
||||
|
||||
public class PlayerTracker {
|
||||
public void onPlayerLogin(ServerPlayerEntity player) {
|
||||
if (!core_enabled) return;
|
||||
final DynmapPlayer dp = getOrAddPlayer(player);
|
||||
/* This event can be called from off server thread, so push processing there */
|
||||
core.getServer().scheduleServerTask(new Runnable() {
|
||||
public void run() {
|
||||
core.listenerManager.processPlayerEvent(DynmapListenerManager.EventType.PLAYER_JOIN, dp);
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
|
||||
public void onPlayerLogout(ServerPlayerEntity player) {
|
||||
if (!core_enabled) return;
|
||||
final DynmapPlayer dp = getOrAddPlayer(player);
|
||||
final String name = player.getName().getString();
|
||||
/* This event can be called from off server thread, so push processing there */
|
||||
core.getServer().scheduleServerTask(new Runnable() {
|
||||
public void run() {
|
||||
core.listenerManager.processPlayerEvent(DynmapListenerManager.EventType.PLAYER_QUIT, dp);
|
||||
players.remove(name);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
public void onPlayerChangedDimension(ServerPlayerEntity player) {
|
||||
if (!core_enabled) return;
|
||||
getOrAddPlayer(player); // Freshen player object reference
|
||||
}
|
||||
|
||||
public void onPlayerRespawn(ServerPlayerEntity player) {
|
||||
if (!core_enabled) return;
|
||||
getOrAddPlayer(player); // Freshen player object reference
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerTracker playerTracker = null;
|
||||
|
||||
private void registerPlayerLoginListener() {
|
||||
if (playerTracker == null) {
|
||||
playerTracker = new PlayerTracker();
|
||||
PlayerEvents.PLAYER_LOGGED_IN.register(player -> playerTracker.onPlayerLogin(player));
|
||||
PlayerEvents.PLAYER_LOGGED_OUT.register(player -> playerTracker.onPlayerLogout(player));
|
||||
PlayerEvents.PLAYER_CHANGED_DIMENSION.register(player -> playerTracker.onPlayerChangedDimension(player));
|
||||
PlayerEvents.PLAYER_RESPAWN.register(player -> playerTracker.onPlayerRespawn(player));
|
||||
}
|
||||
}
|
||||
|
||||
public class WorldTracker {
|
||||
public void handleWorldLoad(MinecraftServer server, ServerWorld world) {
|
||||
if (!core_enabled) return;
|
||||
|
||||
final FabricWorld fw = getWorld(world);
|
||||
// This event can be called from off server thread, so push processing there
|
||||
core.getServer().scheduleServerTask(new Runnable() {
|
||||
public void run() {
|
||||
if (core.processWorldLoad(fw)) // Have core process load first - fire event listeners if good load after
|
||||
core.listenerManager.processWorldEvent(DynmapListenerManager.EventType.WORLD_LOAD, fw);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
||||
public void handleWorldUnload(MinecraftServer server, ServerWorld world) {
|
||||
if (!core_enabled) return;
|
||||
|
||||
final FabricWorld fw = getWorld(world);
|
||||
if (fw != null) {
|
||||
// This event can be called from off server thread, so push processing there
|
||||
core.getServer().scheduleServerTask(new Runnable() {
|
||||
public void run() {
|
||||
core.listenerManager.processWorldEvent(DynmapListenerManager.EventType.WORLD_UNLOAD, fw);
|
||||
core.processWorldUnload(fw);
|
||||
}
|
||||
}, 0);
|
||||
// Set world unloaded (needs to be immediate, since it may be invalid after event)
|
||||
fw.setWorldUnloaded();
|
||||
// Clean up tracker
|
||||
//WorldUpdateTracker wut = updateTrackers.remove(fw.getName());
|
||||
//if(wut != null) wut.world = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleChunkGenerate(ServerWorld world, Chunk chunk) {
|
||||
if (!onchunkgenerate) return;
|
||||
|
||||
FabricWorld fw = getWorld(world, false);
|
||||
ChunkPos chunkPos = chunk.getPos();
|
||||
|
||||
int ymax = Integer.MIN_VALUE;
|
||||
int ymin = Integer.MAX_VALUE;
|
||||
ChunkSection[] sections = chunk.getSectionArray();
|
||||
for (int i = 0; i < sections.length; i++) {
|
||||
if ((sections[i] != null) && (!sections[i].isEmpty())) {
|
||||
int sy = chunk.getBottomY() + i * ChunkSection.field_31407 /* Mojmap: SECTION_HEIGHT */;
|
||||
if (sy < ymin) ymin = sy;
|
||||
if ((sy+16) > ymax) ymax = sy + 16;
|
||||
}
|
||||
}
|
||||
if (ymax != Integer.MIN_VALUE) {
|
||||
mapManager.touchVolume(fw.getName(),
|
||||
chunkPos.getStartX(), ymin, chunkPos.getStartZ(),
|
||||
chunkPos.getEndX(), ymax, chunkPos.getEndZ(),
|
||||
"chunkgenerate");
|
||||
//Log.info("New generated chunk detected at %s[%s]".formatted(fw.getName(), chunkPos.getStartPos()));
|
||||
}
|
||||
}
|
||||
|
||||
public void handleBlockEvent(World world, BlockPos pos) {
|
||||
if (!core_enabled) return;
|
||||
if (!onblockchange) return;
|
||||
if (!(world instanceof ServerWorld)) return;
|
||||
|
||||
BlockUpdateRec r = new BlockUpdateRec();
|
||||
r.w = world;
|
||||
FabricWorld fw = getWorld(world, false);
|
||||
if (fw == null) return;
|
||||
r.wid = fw.getName();
|
||||
r.x = pos.getX();
|
||||
r.y = pos.getY();
|
||||
r.z = pos.getZ();
|
||||
blockupdatequeue.add(r);
|
||||
}
|
||||
}
|
||||
|
||||
private WorldTracker worldTracker = null;
|
||||
private boolean onblockchange = false;
|
||||
private boolean onchunkpopulate = false;
|
||||
private boolean onchunkgenerate = false;
|
||||
boolean onblockchange_with_id = false;
|
||||
|
||||
private void registerEvents() {
|
||||
// To trigger rendering.
|
||||
onblockchange = core.isTrigger("blockupdate");
|
||||
onchunkpopulate = core.isTrigger("chunkpopulate");
|
||||
onchunkgenerate = core.isTrigger("chunkgenerate");
|
||||
onblockchange_with_id = core.isTrigger("blockupdate-with-id");
|
||||
if (onblockchange_with_id)
|
||||
onblockchange = true;
|
||||
if (worldTracker == null)
|
||||
worldTracker = new WorldTracker();
|
||||
if (onchunkpopulate || onchunkgenerate) {
|
||||
CustomServerChunkEvents.CHUNK_GENERATE.register((world, chunk) -> worldTracker.handleChunkGenerate(world, chunk));
|
||||
}
|
||||
if (onblockchange) {
|
||||
BlockEvents.BLOCK_EVENT.register((world, pos) -> worldTracker.handleBlockEvent(world, pos));
|
||||
}
|
||||
|
||||
ServerWorldEvents.LOAD.register((server, world) -> worldTracker.handleWorldLoad(server, world));
|
||||
ServerWorldEvents.UNLOAD.register((server, world) -> worldTracker.handleWorldUnload(server, world));
|
||||
}
|
||||
|
||||
FabricWorld getWorldByName(String name) {
|
||||
return worlds.get(name);
|
||||
}
|
||||
|
||||
FabricWorld getWorld(World w) {
|
||||
return getWorld(w, true);
|
||||
}
|
||||
|
||||
private FabricWorld getWorld(World w, boolean add_if_not_found) {
|
||||
if (last_world == w) {
|
||||
return last_fworld;
|
||||
}
|
||||
String wname = FabricWorld.getWorldName(this, w);
|
||||
|
||||
for (FabricWorld fw : worlds.values()) {
|
||||
if (fw.getRawName().equals(wname)) {
|
||||
last_world = w;
|
||||
last_fworld = fw;
|
||||
if (!fw.isLoaded()) {
|
||||
fw.setWorldLoaded(w);
|
||||
}
|
||||
fw.updateWorld(w);
|
||||
return fw;
|
||||
}
|
||||
}
|
||||
FabricWorld fw = null;
|
||||
if (add_if_not_found) {
|
||||
/* Add to list if not found */
|
||||
fw = new FabricWorld(this, w);
|
||||
worlds.put(fw.getName(), fw);
|
||||
}
|
||||
last_world = w;
|
||||
last_fworld = fw;
|
||||
return fw;
|
||||
}
|
||||
|
||||
private void saveWorlds() {
|
||||
File f = new File(core.getDataFolder(), FabricWorld.SAVED_WORLDS_FILE);
|
||||
ConfigurationNode cn = new ConfigurationNode(f);
|
||||
ArrayList<HashMap<String, Object>> lst = new ArrayList<HashMap<String, Object>>();
|
||||
for (DynmapWorld fw : core.mapManager.getWorlds()) {
|
||||
HashMap<String, Object> vals = new HashMap<String, Object>();
|
||||
vals.put("name", fw.getRawName());
|
||||
vals.put("height", fw.worldheight);
|
||||
vals.put("miny", fw.minY);
|
||||
vals.put("sealevel", fw.sealevel);
|
||||
vals.put("nether", fw.isNether());
|
||||
vals.put("the_end", ((FabricWorld) fw).isTheEnd());
|
||||
vals.put("title", fw.getTitle());
|
||||
lst.add(vals);
|
||||
}
|
||||
cn.put("worlds", lst);
|
||||
cn.put("useSaveFolderAsName", useSaveFolder);
|
||||
cn.put("maxWorldHeight", FabricWorld.getMaxWorldHeight());
|
||||
|
||||
cn.save();
|
||||
}
|
||||
|
||||
private void loadWorlds() {
|
||||
File f = new File(core.getDataFolder(), FabricWorld.SAVED_WORLDS_FILE);
|
||||
if (f.canRead() == false) {
|
||||
useSaveFolder = true;
|
||||
return;
|
||||
}
|
||||
ConfigurationNode cn = new ConfigurationNode(f);
|
||||
cn.load();
|
||||
// If defined, use maxWorldHeight
|
||||
FabricWorld.setMaxWorldHeight(cn.getInteger("maxWorldHeight", 256));
|
||||
|
||||
// If setting defined, use it
|
||||
if (cn.containsKey("useSaveFolderAsName")) {
|
||||
useSaveFolder = cn.getBoolean("useSaveFolderAsName", useSaveFolder);
|
||||
}
|
||||
List<Map<String, Object>> lst = cn.getMapList("worlds");
|
||||
if (lst == null) {
|
||||
Log.warning(String.format("Discarding bad %s", FabricWorld.SAVED_WORLDS_FILE));
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map<String, Object> world : lst) {
|
||||
try {
|
||||
String name = (String) world.get("name");
|
||||
int height = (Integer) world.get("height");
|
||||
Integer miny = (Integer) world.get("miny");
|
||||
int sealevel = (Integer) world.get("sealevel");
|
||||
boolean nether = (Boolean) world.get("nether");
|
||||
boolean theend = (Boolean) world.get("the_end");
|
||||
String title = (String) world.get("title");
|
||||
if (name != null) {
|
||||
FabricWorld fw = new FabricWorld(this, name, height, sealevel, nether, theend, title, (miny != null) ? miny : 0);
|
||||
fw.setWorldUnloaded();
|
||||
core.processWorldLoad(fw);
|
||||
worlds.put(fw.getName(), fw);
|
||||
}
|
||||
} catch (Exception x) {
|
||||
Log.warning(String.format("Unable to load saved worlds from %s", FabricWorld.SAVED_WORLDS_FILE));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import org.dynmap.DynmapLocation;
|
||||
|
||||
public final class FabricAdapter {
|
||||
public static DynmapLocation toDynmapLocation(DynmapPlugin plugin, ServerWorld world, double x, double y, double z) {
|
||||
return new DynmapLocation(plugin.getWorld(world).getName(), x, y, z);
|
||||
}
|
||||
|
||||
private FabricAdapter() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralTextContent;
|
||||
import net.minecraft.text.Text;
|
||||
import org.dynmap.common.DynmapCommandSender;
|
||||
|
||||
/* Handler for generic console command sender */
|
||||
public class FabricCommandSender implements DynmapCommandSender {
|
||||
private ServerCommandSource sender;
|
||||
|
||||
protected FabricCommandSender() {
|
||||
sender = null;
|
||||
}
|
||||
|
||||
public FabricCommandSender(ServerCommandSource send) {
|
||||
sender = send;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrivilege(String privid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String msg) {
|
||||
if (sender != null) {
|
||||
sender.sendFeedback(() -> Text.literal(msg), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermissionNode(String node) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.dynmap.utils.DynmapLogger;
|
||||
|
||||
public class FabricLogger implements DynmapLogger {
|
||||
Logger log;
|
||||
public static final String DM = "[Dynmap] ";
|
||||
|
||||
FabricLogger() {
|
||||
log = LogManager.getLogger("Dynmap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String s) {
|
||||
log.info(DM + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(Throwable t) {
|
||||
log.fatal(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String s) {
|
||||
log.fatal(DM + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String s, Throwable t) {
|
||||
log.fatal(DM + s, t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verboseinfo(String s) {
|
||||
log.info(DM + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String s) {
|
||||
log.warn(DM + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String s, Throwable t) {
|
||||
log.warn(DM + s, t);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import net.minecraft.nbt.*;
|
||||
import net.minecraft.server.world.ServerChunkManager;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
|
||||
import net.minecraft.util.collection.PackedIntegerArray;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.WordPackedArray;
|
||||
import net.minecraft.world.ChunkSerializer;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
import net.minecraft.world.chunk.ChunkManager;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.common.BiomeMap;
|
||||
import org.dynmap.common.chunk.GenericChunk;
|
||||
import org.dynmap.common.chunk.GenericChunkSection;
|
||||
import org.dynmap.common.chunk.GenericMapChunkCache;
|
||||
import org.dynmap.hdmap.HDBlockModels;
|
||||
import org.dynmap.renderer.DynmapBlockState;
|
||||
import org.dynmap.renderer.RenderPatchFactory;
|
||||
import org.dynmap.utils.*;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
|
||||
*/
|
||||
public class FabricMapChunkCache extends GenericMapChunkCache {
|
||||
private World w;
|
||||
private ServerChunkManager cps;
|
||||
|
||||
/**
|
||||
* Construct empty cache
|
||||
*/
|
||||
public FabricMapChunkCache(DynmapPlugin plugin) {
|
||||
super(plugin.sscache);
|
||||
}
|
||||
|
||||
public void setChunks(FabricWorld dw, List<DynmapChunk> chunks) {
|
||||
this.w = dw.getWorld();
|
||||
if (dw.isLoaded()) {
|
||||
/* Check if world's provider is ServerChunkManager */
|
||||
ChunkManager cp = this.w.getChunkManager();
|
||||
|
||||
if (cp instanceof ServerChunkManager) {
|
||||
cps = (ServerChunkManager) cp;
|
||||
} else {
|
||||
Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
|
||||
}
|
||||
}
|
||||
super.setChunks(dw, chunks);
|
||||
}
|
||||
|
||||
// Load generic chunk from existing and already loaded chunk
|
||||
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
|
||||
GenericChunk gc = null;
|
||||
if (cps.isChunkLoaded(chunk.x, chunk.z)) {
|
||||
NbtCompound nbt = null;
|
||||
try {
|
||||
nbt = ChunkSerializer.serialize((ServerWorld) w, cps.getWorldChunk(chunk.x, chunk.z, false));
|
||||
} catch (NullPointerException e) {
|
||||
// TODO: find out why this is happening and why it only seems to happen since 1.16.2
|
||||
Log.severe("ChunkSerializer.serialize threw a NullPointerException", e);
|
||||
}
|
||||
if (nbt != null) {
|
||||
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
|
||||
}
|
||||
}
|
||||
return gc;
|
||||
}
|
||||
|
||||
private NbtCompound readChunk(int x, int z) {
|
||||
try {
|
||||
ThreadedAnvilChunkStorage acl = cps.threadedAnvilChunkStorage;
|
||||
|
||||
ChunkPos coord = new ChunkPos(x, z);
|
||||
// Async chunk reading is synchronized here. Perhaps we can do async and improve performance?
|
||||
return acl.getNbt(coord).join().orElse(null);
|
||||
} catch (Exception exc) {
|
||||
Log.severe(String.format("Error reading chunk: %s,%d,%d", dw.getName(), x, z), exc);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Load generic chunk from unloaded chunk
|
||||
protected GenericChunk loadChunk(DynmapChunk chunk) {
|
||||
GenericChunk gc = null;
|
||||
NbtCompound nbt = readChunk(chunk.x, chunk.z);
|
||||
// If read was good
|
||||
if (nbt != null) {
|
||||
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
|
||||
}
|
||||
return gc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
|
||||
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
|
||||
if (effects == null) return colormap[bm.biomeLookup()];
|
||||
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
|
||||
import net.minecraft.server.network.ServerPlayNetworkHandler;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.LiteralTextContent;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Player access abstraction class
|
||||
*/
|
||||
public class FabricPlayer extends FabricCommandSender implements DynmapPlayer {
|
||||
private static final Gson GSON = new GsonBuilder().create();
|
||||
private final DynmapPlugin plugin;
|
||||
// FIXME: Proper setter
|
||||
ServerPlayerEntity player;
|
||||
private final String skinurl;
|
||||
private final UUID uuid;
|
||||
|
||||
public FabricPlayer(DynmapPlugin plugin, ServerPlayerEntity player) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
String url = null;
|
||||
if (this.player != null) {
|
||||
uuid = this.player.getUuid();
|
||||
GameProfile prof = this.player.getGameProfile();
|
||||
if (prof != null) {
|
||||
Property textureProperty = Iterables.getFirst(prof.getProperties().get("textures"), null);
|
||||
|
||||
if (textureProperty != null) {
|
||||
DynmapPlugin.TexturesPayload result = null;
|
||||
try {
|
||||
String json = new String(Base64.getDecoder().decode(textureProperty.getValue()), StandardCharsets.UTF_8);
|
||||
result = GSON.fromJson(json, DynmapPlugin.TexturesPayload.class);
|
||||
} catch (JsonParseException e) {
|
||||
}
|
||||
if ((result != null) && (result.textures != null) && (result.textures.containsKey("SKIN"))) {
|
||||
url = result.textures.get("SKIN").url;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uuid = null;
|
||||
}
|
||||
skinurl = url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (player != null) {
|
||||
String n = player.getName().getString();
|
||||
;
|
||||
return n;
|
||||
} else
|
||||
return "[Server]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
if (player != null) {
|
||||
String n = player.getDisplayName().getString();
|
||||
return n;
|
||||
} else
|
||||
return "[Server]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynmapLocation getLocation() {
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Vec3d pos = player.getPos();
|
||||
return FabricAdapter.toDynmapLocation(plugin, player.getServerWorld(), pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorld() {
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
World world = player.getWorld();
|
||||
if (world != null) {
|
||||
return plugin.getWorld(world).getName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getAddress() {
|
||||
if (player != null) {
|
||||
ServerPlayNetworkHandler networkHandler = player.networkHandler;
|
||||
if (networkHandler != null) {
|
||||
SocketAddress sa = networkHandler.getConnectionAddress();
|
||||
if (sa instanceof InetSocketAddress) {
|
||||
return (InetSocketAddress) sa;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneaking() {
|
||||
if (player != null) {
|
||||
return player.isSneaking();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealth() {
|
||||
if (player != null) {
|
||||
double h = player.getHealth();
|
||||
if (h > 20) h = 20;
|
||||
return h; // Scale to 20 range
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorPoints() {
|
||||
if (player != null) {
|
||||
return player.getArmor();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynmapLocation getBedSpawnLocation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastLoginTime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFirstLoginTime() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPrivilege(String privid) {
|
||||
if (player != null)
|
||||
return plugin.hasPerm(player, privid);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return plugin.isOp(player.getName().getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String msg) {
|
||||
Text ichatcomponent = Text.literal(msg);
|
||||
player.sendMessage(ichatcomponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvisible() {
|
||||
if (player != null) {
|
||||
return player.isInvisible();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSortWeight() {
|
||||
return plugin.getSortWeight(getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSortWeight(int wt) {
|
||||
if (wt == 0) {
|
||||
plugin.dropSortWeight(getName());
|
||||
} else {
|
||||
plugin.setSortWeight(getName(), wt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermissionNode(String node) {
|
||||
return player != null && plugin.hasPermNode(player, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSkinURL() {
|
||||
return skinurl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send title and subtitle text (called from server thread)
|
||||
*/
|
||||
@Override
|
||||
public void sendTitleText(String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
|
||||
if (player != null) {
|
||||
ServerPlayerEntity player = this.player;
|
||||
TitleFadeS2CPacket times = new TitleFadeS2CPacket(fadeInTicks, stayTicks, fadeOutTicks);
|
||||
player.networkHandler.sendPacket(times);
|
||||
if (title != null) {
|
||||
TitleS2CPacket titlepkt = new TitleS2CPacket(Text.literal(title));
|
||||
player.networkHandler.sendPacket(titlepkt);
|
||||
}
|
||||
|
||||
if (subtitle != null) {
|
||||
SubtitleS2CPacket subtitlepkt = new SubtitleS2CPacket(Text.literal(subtitle));
|
||||
player.networkHandler.sendPacket(subtitlepkt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,610 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
import net.minecraft.block.AbstractSignBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.network.message.MessageType;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.server.BannedIpList;
|
||||
import net.minecraft.server.BannedPlayerList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerManager;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.LiteralTextContent;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.UserCache;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.DynmapCommonAPIListener;
|
||||
import org.dynmap.common.BiomeMap;
|
||||
import org.dynmap.common.DynmapListenerManager;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.common.DynmapServerInterface;
|
||||
import org.dynmap.fabric_1_20.event.BlockEvents;
|
||||
import org.dynmap.fabric_1_20.event.ServerChatEvents;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.VisibilityLimit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Server access abstraction class
|
||||
*/
|
||||
public class FabricServer extends DynmapServerInterface {
|
||||
/* Server thread scheduler */
|
||||
private final Object schedlock = new Object();
|
||||
private final DynmapPlugin plugin;
|
||||
private final MinecraftServer server;
|
||||
private final Registry<Biome> biomeRegistry;
|
||||
private long cur_tick;
|
||||
private long next_id;
|
||||
private long cur_tick_starttime;
|
||||
private PriorityQueue<TaskRecord> runqueue = new PriorityQueue<TaskRecord>();
|
||||
|
||||
public FabricServer(DynmapPlugin plugin, MinecraftServer server) {
|
||||
this.plugin = plugin;
|
||||
this.server = server;
|
||||
this.biomeRegistry = server.getRegistryManager().get(RegistryKeys.BIOME);
|
||||
}
|
||||
|
||||
private Optional<GameProfile> getProfileByName(String player) {
|
||||
UserCache cache = server.getUserCache();
|
||||
return cache.findByName(player);
|
||||
}
|
||||
|
||||
public final Registry<Biome> getBiomeRegistry() {
|
||||
return biomeRegistry;
|
||||
}
|
||||
|
||||
private Biome[] biomelist = null;
|
||||
|
||||
public final Biome[] getBiomeList(Registry<Biome> biomeRegistry) {
|
||||
if (biomelist == null) {
|
||||
biomelist = new Biome[256];
|
||||
Iterator<Biome> iter = biomeRegistry.iterator();
|
||||
while (iter.hasNext()) {
|
||||
Biome b = iter.next();
|
||||
int bidx = biomeRegistry.getRawId(b);
|
||||
if (bidx >= biomelist.length) {
|
||||
biomelist = Arrays.copyOf(biomelist, bidx + biomelist.length);
|
||||
}
|
||||
biomelist[bidx] = b;
|
||||
}
|
||||
}
|
||||
return biomelist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockIDAt(String wname, int x, int y, int z) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") /* Not much I can do... fix this if it breaks. */
|
||||
@Override
|
||||
public int isSignAt(String wname, int x, int y, int z) {
|
||||
World world = plugin.getWorldByName(wname).getWorld();
|
||||
|
||||
BlockPos pos = new BlockPos(x, y, z);
|
||||
if (!world.isChunkLoaded(pos))
|
||||
return -1;
|
||||
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
return (block instanceof AbstractSignBlock ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleServerTask(Runnable run, long delay) {
|
||||
/* Add task record to queue */
|
||||
synchronized (schedlock) {
|
||||
TaskRecord tr = new TaskRecord(cur_tick + delay, next_id++, new FutureTask<Object>(run, null));
|
||||
runqueue.add(tr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynmapPlayer[] getOnlinePlayers() {
|
||||
if (server.getPlayerManager() == null) return new DynmapPlayer[0];
|
||||
|
||||
List<ServerPlayerEntity> players = server.getPlayerManager().getPlayerList();
|
||||
int playerCount = players.size();
|
||||
DynmapPlayer[] dplay = new DynmapPlayer[players.size()];
|
||||
|
||||
for (int i = 0; i < playerCount; i++) {
|
||||
ServerPlayerEntity player = players.get(i);
|
||||
dplay[i] = plugin.getOrAddPlayer(player);
|
||||
}
|
||||
|
||||
return dplay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
plugin.onDisable();
|
||||
plugin.onEnable();
|
||||
plugin.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynmapPlayer getPlayer(String name) {
|
||||
List<ServerPlayerEntity> players = server.getPlayerManager().getPlayerList();
|
||||
|
||||
for (ServerPlayerEntity player : players) {
|
||||
|
||||
if (player.getName().getString().equalsIgnoreCase(name)) {
|
||||
return plugin.getOrAddPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getIPBans() {
|
||||
BannedIpList bl = server.getPlayerManager().getIpBanList();
|
||||
Set<String> ips = new HashSet<String>();
|
||||
|
||||
for (String s : bl.getNames()) {
|
||||
ips.add(s);
|
||||
}
|
||||
|
||||
return ips;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Future<T> callSyncMethod(Callable<T> task) {
|
||||
return callSyncMethod(task, 0);
|
||||
}
|
||||
|
||||
public <T> Future<T> callSyncMethod(Callable<T> task, long delay) {
|
||||
FutureTask<T> ft = new FutureTask<T>(task);
|
||||
|
||||
/* Add task record to queue */
|
||||
synchronized (schedlock) {
|
||||
TaskRecord tr = new TaskRecord(cur_tick + delay, next_id++, ft);
|
||||
runqueue.add(tr);
|
||||
}
|
||||
|
||||
return ft;
|
||||
}
|
||||
|
||||
void clearTaskQueue() {
|
||||
this.runqueue.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
String sn;
|
||||
if (server.isSingleplayer())
|
||||
sn = "Integrated";
|
||||
else
|
||||
sn = server.getServerIp();
|
||||
if (sn == null) sn = "Unknown Server";
|
||||
return sn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerBanned(String pid) {
|
||||
PlayerManager scm = server.getPlayerManager();
|
||||
BannedPlayerList bl = scm.getUserBanList();
|
||||
try {
|
||||
return bl.contains(getProfileByName(pid).get());
|
||||
} catch (NoSuchElementException e) {
|
||||
/* If this profile doesn't exist, default to "banned" for good measure. */
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String stripChatColor(String s) {
|
||||
return DynmapPlugin.patternControlCode.matcher(s).replaceAll("");
|
||||
}
|
||||
|
||||
private Set<DynmapListenerManager.EventType> registered = new HashSet<DynmapListenerManager.EventType>();
|
||||
|
||||
@Override
|
||||
public boolean requestEventNotification(DynmapListenerManager.EventType type) {
|
||||
if (registered.contains(type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case WORLD_LOAD:
|
||||
case WORLD_UNLOAD:
|
||||
/* Already called for normal world activation/deactivation */
|
||||
break;
|
||||
|
||||
case WORLD_SPAWN_CHANGE:
|
||||
/*TODO
|
||||
pm.registerEvents(new Listener() {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onSpawnChange(SpawnChangeEvent evt) {
|
||||
DynmapWorld w = new BukkitWorld(evt.getWorld());
|
||||
core.listenerManager.processWorldEvent(EventType.WORLD_SPAWN_CHANGE, w);
|
||||
}
|
||||
}, DynmapPlugin.this);
|
||||
*/
|
||||
break;
|
||||
|
||||
case PLAYER_JOIN:
|
||||
case PLAYER_QUIT:
|
||||
/* Already handled */
|
||||
break;
|
||||
|
||||
case PLAYER_BED_LEAVE:
|
||||
/*TODO
|
||||
pm.registerEvents(new Listener() {
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onPlayerBedLeave(PlayerBedLeaveEvent evt) {
|
||||
DynmapPlayer p = new BukkitPlayer(evt.getPlayer());
|
||||
core.listenerManager.processPlayerEvent(EventType.PLAYER_BED_LEAVE, p);
|
||||
}
|
||||
}, DynmapPlugin.this);
|
||||
*/
|
||||
break;
|
||||
|
||||
case PLAYER_CHAT:
|
||||
if (plugin.chathandler == null) {
|
||||
plugin.setChatHandler(new DynmapPlugin.ChatHandler(plugin));
|
||||
ServerChatEvents.EVENT.register((player, message) -> plugin.chathandler.handleChat(player, message));
|
||||
}
|
||||
break;
|
||||
|
||||
case BLOCK_BREAK:
|
||||
/* Already handled by BlockEvents logic */
|
||||
break;
|
||||
|
||||
case SIGN_CHANGE:
|
||||
BlockEvents.SIGN_CHANGE_EVENT.register((world, pos, lines, player, front) -> {
|
||||
plugin.core.processSignChange("fabric", FabricWorld.getWorldName(plugin, world),
|
||||
pos.getX(), pos.getY(), pos.getZ(), lines, player.getName().getString());
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
Log.severe("Unhandled event type: " + type);
|
||||
return false;
|
||||
}
|
||||
|
||||
registered.add(type);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendWebChatEvent(String source, String name, String msg) {
|
||||
return DynmapCommonAPIListener.fireWebChatEvent(source, name, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastMessage(String msg) {
|
||||
Text component = Text.literal(msg);
|
||||
server.getPlayerManager().broadcast(component, false);
|
||||
Log.info(stripChatColor(msg));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getBiomeIDs() {
|
||||
BiomeMap[] b = BiomeMap.values();
|
||||
String[] bname = new String[b.length];
|
||||
|
||||
for (int i = 0; i < bname.length; i++) {
|
||||
bname[i] = b[i].toString();
|
||||
}
|
||||
|
||||
return bname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCacheHitRate() {
|
||||
if (plugin.sscache != null)
|
||||
return plugin.sscache.getHitRate();
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCacheStats() {
|
||||
if (plugin.sscache != null)
|
||||
plugin.sscache.resetStats();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynmapWorld getWorldByName(String wname) {
|
||||
return plugin.getWorldByName(wname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynmapPlayer getOfflinePlayer(String name) {
|
||||
/*
|
||||
OfflinePlayer op = getServer().getOfflinePlayer(name);
|
||||
if(op != null) {
|
||||
return new BukkitPlayer(op);
|
||||
}
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> checkPlayerPermissions(String player, Set<String> perms) {
|
||||
if (isPlayerBanned(player)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
Set<String> rslt = plugin.hasOfflinePermissions(player, perms);
|
||||
if (rslt == null) {
|
||||
rslt = new HashSet<String>();
|
||||
if (plugin.isOp(player)) {
|
||||
rslt.addAll(perms);
|
||||
}
|
||||
}
|
||||
return rslt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPlayerPermission(String player, String perm) {
|
||||
if (isPlayerBanned(player)) {
|
||||
return false;
|
||||
}
|
||||
return plugin.hasOfflinePermission(player, perm);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render processor helper - used by code running on render threads to request chunk snapshot cache from server/sync thread
|
||||
*/
|
||||
@Override
|
||||
public MapChunkCache createMapChunkCache(DynmapWorld w, List<DynmapChunk> chunks,
|
||||
boolean blockdata, boolean highesty, boolean biome, boolean rawbiome) {
|
||||
FabricMapChunkCache c = (FabricMapChunkCache) w.getChunkCache(chunks);
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
if (w.visibility_limits != null) {
|
||||
for (VisibilityLimit limit : w.visibility_limits) {
|
||||
c.setVisibleRange(limit);
|
||||
}
|
||||
|
||||
c.setHiddenFillStyle(w.hiddenchunkstyle);
|
||||
}
|
||||
|
||||
if (w.hidden_limits != null) {
|
||||
for (VisibilityLimit limit : w.hidden_limits) {
|
||||
c.setHiddenRange(limit);
|
||||
}
|
||||
|
||||
c.setHiddenFillStyle(w.hiddenchunkstyle);
|
||||
}
|
||||
|
||||
if (!c.setChunkDataTypes(blockdata, biome, highesty, rawbiome)) {
|
||||
Log.severe("CraftBukkit build does not support biome APIs");
|
||||
}
|
||||
|
||||
if (chunks.size() == 0) /* No chunks to get? */ {
|
||||
c.loadChunks(0);
|
||||
return c;
|
||||
}
|
||||
|
||||
//Now handle any chunks in server thread that are already loaded (on server thread)
|
||||
final FabricMapChunkCache cc = c;
|
||||
Future<Boolean> f = this.callSyncMethod(new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
// Update busy state on world
|
||||
//FabricWorld fw = (FabricWorld) cc.getWorld();
|
||||
//TODO
|
||||
//setBusy(fw.getWorld());
|
||||
cc.getLoadedChunks();
|
||||
return true;
|
||||
}
|
||||
}, 0);
|
||||
try {
|
||||
f.get();
|
||||
} catch (CancellationException cx) {
|
||||
return null;
|
||||
} catch (InterruptedException cx) {
|
||||
return null;
|
||||
} catch (ExecutionException xx) {
|
||||
Log.severe("Exception while loading chunks", xx.getCause());
|
||||
return null;
|
||||
} catch (Exception ix) {
|
||||
Log.severe(ix);
|
||||
return null;
|
||||
}
|
||||
if (!w.isLoaded()) {
|
||||
return null;
|
||||
}
|
||||
// Now, do rest of chunk reading from calling thread
|
||||
c.readChunks(chunks.size());
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxPlayers() {
|
||||
return server.getMaxPlayerCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentPlayers() {
|
||||
return server.getPlayerManager().getCurrentPlayerCount();
|
||||
}
|
||||
|
||||
public void tickEvent(MinecraftServer server) {
|
||||
cur_tick_starttime = System.nanoTime();
|
||||
long elapsed = cur_tick_starttime - plugin.lasttick;
|
||||
plugin.lasttick = cur_tick_starttime;
|
||||
plugin.avgticklen = ((plugin.avgticklen * 99) / 100) + (elapsed / 100);
|
||||
plugin.tps = (double) 1E9 / (double) plugin.avgticklen;
|
||||
// Tick core
|
||||
if (plugin.core != null) {
|
||||
plugin.core.serverTick(plugin.tps);
|
||||
}
|
||||
|
||||
boolean done = false;
|
||||
TaskRecord tr = null;
|
||||
|
||||
while (!plugin.blockupdatequeue.isEmpty()) {
|
||||
DynmapPlugin.BlockUpdateRec r = plugin.blockupdatequeue.remove();
|
||||
BlockState bs = r.w.getBlockState(new BlockPos(r.x, r.y, r.z));
|
||||
int idx = Block.STATE_IDS.getRawId(bs);
|
||||
if (!org.dynmap.hdmap.HDBlockModels.isChangeIgnoredBlock(DynmapPlugin.stateByID[idx])) {
|
||||
if (plugin.onblockchange_with_id)
|
||||
plugin.mapManager.touch(r.wid, r.x, r.y, r.z, "blockchange[" + idx + "]");
|
||||
else
|
||||
plugin.mapManager.touch(r.wid, r.x, r.y, r.z, "blockchange");
|
||||
}
|
||||
}
|
||||
|
||||
long now;
|
||||
|
||||
synchronized (schedlock) {
|
||||
cur_tick++;
|
||||
now = System.nanoTime();
|
||||
tr = runqueue.peek();
|
||||
/* Nothing due to run */
|
||||
if ((tr == null) || (tr.getTickToRun() > cur_tick) || ((now - cur_tick_starttime) > plugin.perTickLimit)) {
|
||||
done = true;
|
||||
} else {
|
||||
tr = runqueue.poll();
|
||||
}
|
||||
}
|
||||
while (!done) {
|
||||
tr.run();
|
||||
|
||||
synchronized (schedlock) {
|
||||
tr = runqueue.peek();
|
||||
now = System.nanoTime();
|
||||
/* Nothing due to run */
|
||||
if ((tr == null) || (tr.getTickToRun() > cur_tick) || ((now - cur_tick_starttime) > plugin.perTickLimit)) {
|
||||
done = true;
|
||||
} else {
|
||||
tr = runqueue.poll();
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!plugin.msgqueue.isEmpty()) {
|
||||
DynmapPlugin.ChatMessage cm = plugin.msgqueue.poll();
|
||||
DynmapPlayer dp = null;
|
||||
if (cm.sender != null)
|
||||
dp = plugin.getOrAddPlayer(cm.sender);
|
||||
else
|
||||
dp = new FabricPlayer(plugin, null);
|
||||
|
||||
plugin.core.listenerManager.processChatEvent(DynmapListenerManager.EventType.PLAYER_CHAT, dp, cm.message);
|
||||
}
|
||||
// Check for generated chunks
|
||||
if ((cur_tick % 20) == 0) {
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<ModContainer> getModContainerById(String id) {
|
||||
return FabricLoader.getInstance().getModContainer(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String name) {
|
||||
return FabricLoader.getInstance().getModContainer(name).isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModVersion(String name) {
|
||||
Optional<ModContainer> mod = getModContainerById(name); // Try case sensitive lookup
|
||||
return mod.map(modContainer -> modContainer.getMetadata().getVersion().getFriendlyString()).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getServerTPS() {
|
||||
return plugin.tps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerIP() {
|
||||
if (server.isSingleplayer())
|
||||
return "0.0.0.0";
|
||||
else
|
||||
return server.getServerIp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getModContainerFile(String name) {
|
||||
Optional<ModContainer> container = getModContainerById(name); // Try case sensitive lookup
|
||||
if (container.isPresent()) {
|
||||
Path path = container.get().getRootPath();
|
||||
if (path.getFileSystem().provider().getScheme().equals("jar")) {
|
||||
path = Paths.get(path.getFileSystem().toString());
|
||||
}
|
||||
return path.toFile();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getModList() {
|
||||
return FabricLoader.getInstance()
|
||||
.getAllMods()
|
||||
.stream()
|
||||
.map(container -> container.getMetadata().getId())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, String> getBlockIDMap() {
|
||||
Map<Integer, String> map = new HashMap<Integer, String>();
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream openResource(String modid, String rname) {
|
||||
if (modid == null) modid = "minecraft";
|
||||
|
||||
if ("minecraft".equals(modid)) {
|
||||
return MinecraftServer.class.getClassLoader().getResourceAsStream(rname);
|
||||
} else {
|
||||
if (rname.startsWith("/") || rname.startsWith("\\")) {
|
||||
rname = rname.substring(1);
|
||||
}
|
||||
|
||||
final String finalModid = modid;
|
||||
final String finalRname = rname;
|
||||
return getModContainerById(modid).map(container -> {
|
||||
try {
|
||||
return Files.newInputStream(container.getPath(finalRname));
|
||||
} catch (IOException e) {
|
||||
Log.severe("Failed to load resource of mod :" + finalModid, e);
|
||||
return null;
|
||||
}
|
||||
}).orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get block unique ID map (module:blockid)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Integer> getBlockUniqueIDMap() {
|
||||
HashMap<String, Integer> map = new HashMap<String, Integer>();
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item unique ID map (module:itemid)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Integer> getItemUniqueIDMap() {
|
||||
HashMap<String, Integer> map = new HashMap<String, Integer>();
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,236 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.Heightmap;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.border.WorldBorder;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWorld;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.Polygon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FabricWorld extends DynmapWorld {
|
||||
// TODO: Store this relative to World saves for integrated server
|
||||
public static final String SAVED_WORLDS_FILE = "fabricworlds.yml";
|
||||
|
||||
private final DynmapPlugin plugin;
|
||||
private World world;
|
||||
private final boolean skylight;
|
||||
private final boolean isnether;
|
||||
private final boolean istheend;
|
||||
private final String env;
|
||||
private DynmapLocation spawnloc = new DynmapLocation();
|
||||
private static int maxWorldHeight = 320; // Maximum allows world height
|
||||
|
||||
public static int getMaxWorldHeight() {
|
||||
return maxWorldHeight;
|
||||
}
|
||||
|
||||
public static void setMaxWorldHeight(int h) {
|
||||
maxWorldHeight = h;
|
||||
}
|
||||
|
||||
public static String getWorldName(DynmapPlugin plugin, World w) {
|
||||
RegistryKey<World> rk = w.getRegistryKey();
|
||||
if (rk == World.OVERWORLD) { // Overworld?
|
||||
return w.getServer().getSaveProperties().getLevelName();
|
||||
} else if (rk == World.END) {
|
||||
return "DIM1";
|
||||
} else if (rk == World.NETHER) {
|
||||
return "DIM-1";
|
||||
} else {
|
||||
return rk.getValue().getNamespace() + "_" + rk.getValue().getPath();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWorld(World w) {
|
||||
this.updateWorldHeights(w.getHeight(), w.getBottomY(), w.getSeaLevel());
|
||||
}
|
||||
|
||||
public FabricWorld(DynmapPlugin plugin, World w) {
|
||||
this(plugin, getWorldName(plugin, w), w.getHeight(),
|
||||
w.getSeaLevel(),
|
||||
w.getRegistryKey() == World.NETHER,
|
||||
w.getRegistryKey() == World.END,
|
||||
w.getRegistryKey().getValue().getPath(),
|
||||
w.getBottomY());
|
||||
setWorldLoaded(w);
|
||||
}
|
||||
|
||||
public FabricWorld(DynmapPlugin plugin, String name, int height, int sealevel, boolean nether, boolean the_end, String deftitle, int miny) {
|
||||
super(name, (height > maxWorldHeight) ? maxWorldHeight : height, sealevel, miny);
|
||||
this.plugin = plugin;
|
||||
world = null;
|
||||
setTitle(deftitle);
|
||||
isnether = nether;
|
||||
istheend = the_end;
|
||||
skylight = !(isnether || istheend);
|
||||
|
||||
if (isnether) {
|
||||
env = "nether";
|
||||
} else if (istheend) {
|
||||
env = "the_end";
|
||||
} else {
|
||||
env = "normal";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Test if world is nether */
|
||||
@Override
|
||||
public boolean isNether() {
|
||||
return isnether;
|
||||
}
|
||||
|
||||
public boolean isTheEnd() {
|
||||
return istheend;
|
||||
}
|
||||
|
||||
/* Get world spawn location */
|
||||
@Override
|
||||
public DynmapLocation getSpawnLocation() {
|
||||
if (world != null) {
|
||||
spawnloc.x = world.getLevelProperties().getSpawnX();
|
||||
spawnloc.y = world.getLevelProperties().getSpawnY();
|
||||
spawnloc.z = world.getLevelProperties().getSpawnZ();
|
||||
spawnloc.world = this.getName();
|
||||
}
|
||||
return spawnloc;
|
||||
}
|
||||
|
||||
/* Get world time */
|
||||
@Override
|
||||
public long getTime() {
|
||||
if (world != null)
|
||||
return world.getTimeOfDay();
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* World is storming */
|
||||
@Override
|
||||
public boolean hasStorm() {
|
||||
if (world != null)
|
||||
return world.isRaining();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/* World is thundering */
|
||||
@Override
|
||||
public boolean isThundering() {
|
||||
if (world != null)
|
||||
return world.isThundering();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/* World is loaded */
|
||||
@Override
|
||||
public boolean isLoaded() {
|
||||
return (world != null);
|
||||
}
|
||||
|
||||
/* Set world to unloaded */
|
||||
@Override
|
||||
public void setWorldUnloaded() {
|
||||
getSpawnLocation();
|
||||
world = null;
|
||||
}
|
||||
|
||||
/* Set world to loaded */
|
||||
public void setWorldLoaded(World w) {
|
||||
world = w;
|
||||
this.sealevel = w.getSeaLevel(); // Read actual current sealevel from world
|
||||
// Update lighting table
|
||||
for (int lightLevel = 0; lightLevel < 16; lightLevel++) {
|
||||
// Algorithm based on LightmapTextureManager.getBrightness()
|
||||
// We can't call that method because it's client-only.
|
||||
// This means the code below can stop being correct if Mojang ever
|
||||
// updates the curve; in that case we should reflect the changes.
|
||||
float value = (float) lightLevel / 15.0f;
|
||||
float brightness = value / (4.0f - 3.0f * value);
|
||||
this.setBrightnessTableEntry(lightLevel, MathHelper.lerp(w.getDimension().ambientLight(), brightness, 1.0F));
|
||||
}
|
||||
}
|
||||
|
||||
/* Get light level of block */
|
||||
@Override
|
||||
public int getLightLevel(int x, int y, int z) {
|
||||
if (world != null)
|
||||
return world.getLightLevel(new BlockPos(x, y, z));
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Get highest Y coord of given location */
|
||||
@Override
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
if (world != null) {
|
||||
return world.getChunk(x >> 4, z >> 4).getHeightmap(Heightmap.Type.MOTION_BLOCKING).get(x & 15, z & 15);
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Test if sky light level is requestable */
|
||||
@Override
|
||||
public boolean canGetSkyLightLevel() {
|
||||
return skylight;
|
||||
}
|
||||
|
||||
/* Return sky light level */
|
||||
@Override
|
||||
public int getSkyLightLevel(int x, int y, int z) {
|
||||
if (world != null) {
|
||||
return world.getLightLevel(LightType.SKY, new BlockPos(x, y, z));
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get world environment ID (lower case - normal, the_end, nether)
|
||||
*/
|
||||
@Override
|
||||
public String getEnvironment() {
|
||||
return env;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get map chunk cache for world
|
||||
*/
|
||||
@Override
|
||||
public MapChunkCache getChunkCache(List<DynmapChunk> chunks) {
|
||||
if (world != null) {
|
||||
FabricMapChunkCache c = new FabricMapChunkCache(plugin);
|
||||
c.setChunks(this, chunks);
|
||||
return c;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Polygon getWorldBorder() {
|
||||
if (world != null) {
|
||||
WorldBorder wb = world.getWorldBorder();
|
||||
if ((wb != null) && (wb.getSize() < 5.9E7)) {
|
||||
Polygon p = new Polygon();
|
||||
p.addVertex(wb.getBoundWest(), wb.getBoundNorth());
|
||||
p.addVertex(wb.getBoundWest(), wb.getBoundSouth());
|
||||
p.addVertex(wb.getBoundEast(), wb.getBoundSouth());
|
||||
p.addVertex(wb.getBoundEast(), wb.getBoundNorth());
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import org.dynmap.common.chunk.GenericBitStorage;
|
||||
import org.dynmap.common.chunk.GenericNBTCompound;
|
||||
import org.dynmap.common.chunk.GenericNBTList;
|
||||
|
||||
import java.util.Set;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtList;
|
||||
import net.minecraft.util.collection.PackedIntegerArray;
|
||||
|
||||
public class NBT {
|
||||
|
||||
public static class NBTCompound implements GenericNBTCompound {
|
||||
private final NbtCompound obj;
|
||||
public NBTCompound(NbtCompound t) {
|
||||
this.obj = t;
|
||||
}
|
||||
@Override
|
||||
public Set<String> getAllKeys() {
|
||||
return obj.getKeys();
|
||||
}
|
||||
@Override
|
||||
public boolean contains(String s) {
|
||||
return obj.contains(s);
|
||||
}
|
||||
@Override
|
||||
public boolean contains(String s, int i) {
|
||||
return obj.contains(s, i);
|
||||
}
|
||||
@Override
|
||||
public byte getByte(String s) {
|
||||
return obj.getByte(s);
|
||||
}
|
||||
@Override
|
||||
public short getShort(String s) {
|
||||
return obj.getShort(s);
|
||||
}
|
||||
@Override
|
||||
public int getInt(String s) {
|
||||
return obj.getInt(s);
|
||||
}
|
||||
@Override
|
||||
public long getLong(String s) {
|
||||
return obj.getLong(s);
|
||||
}
|
||||
@Override
|
||||
public float getFloat(String s) {
|
||||
return obj.getFloat(s);
|
||||
}
|
||||
@Override
|
||||
public double getDouble(String s) {
|
||||
return obj.getDouble(s);
|
||||
}
|
||||
@Override
|
||||
public String getString(String s) {
|
||||
return obj.getString(s);
|
||||
}
|
||||
@Override
|
||||
public byte[] getByteArray(String s) {
|
||||
return obj.getByteArray(s);
|
||||
}
|
||||
@Override
|
||||
public int[] getIntArray(String s) {
|
||||
return obj.getIntArray(s);
|
||||
}
|
||||
@Override
|
||||
public long[] getLongArray(String s) {
|
||||
return obj.getLongArray(s);
|
||||
}
|
||||
@Override
|
||||
public GenericNBTCompound getCompound(String s) {
|
||||
return new NBTCompound(obj.getCompound(s));
|
||||
}
|
||||
@Override
|
||||
public GenericNBTList getList(String s, int i) {
|
||||
return new NBTList(obj.getList(s, i));
|
||||
}
|
||||
@Override
|
||||
public boolean getBoolean(String s) {
|
||||
return obj.getBoolean(s);
|
||||
}
|
||||
@Override
|
||||
public String getAsString(String s) {
|
||||
return obj.get(s).asString();
|
||||
}
|
||||
@Override
|
||||
public GenericBitStorage makeBitStorage(int bits, int count, long[] data) {
|
||||
return new OurBitStorage(bits, count, data);
|
||||
}
|
||||
public String toString() {
|
||||
return obj.toString();
|
||||
}
|
||||
}
|
||||
public static class NBTList implements GenericNBTList {
|
||||
private final NbtList obj;
|
||||
public NBTList(NbtList t) {
|
||||
obj = t;
|
||||
}
|
||||
@Override
|
||||
public int size() {
|
||||
return obj.size();
|
||||
}
|
||||
@Override
|
||||
public String getString(int idx) {
|
||||
return obj.getString(idx);
|
||||
}
|
||||
@Override
|
||||
public GenericNBTCompound getCompound(int idx) {
|
||||
return new NBTCompound(obj.getCompound(idx));
|
||||
}
|
||||
public String toString() {
|
||||
return obj.toString();
|
||||
}
|
||||
}
|
||||
public static class OurBitStorage implements GenericBitStorage {
|
||||
private final PackedIntegerArray bs;
|
||||
public OurBitStorage(int bits, int count, long[] data) {
|
||||
bs = new PackedIntegerArray(bits, count, data);
|
||||
}
|
||||
@Override
|
||||
public int get(int idx) {
|
||||
return bs.get(idx);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
class TaskRecord implements Comparable<TaskRecord> {
|
||||
TaskRecord(long ticktorun, long id, FutureTask<?> future) {
|
||||
this.ticktorun = ticktorun;
|
||||
this.id = id;
|
||||
this.future = future;
|
||||
}
|
||||
|
||||
private final long ticktorun;
|
||||
private final long id;
|
||||
private final FutureTask<?> future;
|
||||
|
||||
void run() {
|
||||
this.future.run();
|
||||
}
|
||||
|
||||
long getTickToRun() {
|
||||
return this.ticktorun;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TaskRecord o) {
|
||||
if (this.ticktorun < o.ticktorun) {
|
||||
return -1;
|
||||
} else if (this.ticktorun > o.ticktorun) {
|
||||
return 1;
|
||||
} else if (this.id < o.id) {
|
||||
return -1;
|
||||
} else if (this.id > o.id) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package org.dynmap.fabric_1_20;
|
||||
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.Log;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
public class VersionCheck {
|
||||
private static final String VERSION_URL = "http://mikeprimm.com/dynmap/releases.php";
|
||||
|
||||
public static void runCheck(final DynmapCore core) {
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
doCheck(core);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private static int getReleaseVersion(String s) {
|
||||
int index = s.lastIndexOf('-');
|
||||
if (index < 0)
|
||||
index = s.lastIndexOf('.');
|
||||
if (index >= 0)
|
||||
s = s.substring(0, index);
|
||||
String[] split = s.split("\\.");
|
||||
int v = 0;
|
||||
try {
|
||||
for (int i = 0; (i < split.length) && (i < 3); i++) {
|
||||
v += Integer.parseInt(split[i]) << (8 * (2 - i));
|
||||
}
|
||||
} catch (NumberFormatException nfx) {
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
private static int getBuildNumber(String s) {
|
||||
int index = s.lastIndexOf('-');
|
||||
if (index < 0)
|
||||
index = s.lastIndexOf('.');
|
||||
if (index >= 0)
|
||||
s = s.substring(index + 1);
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException nfx) {
|
||||
return 99999999;
|
||||
}
|
||||
}
|
||||
|
||||
private static void doCheck(DynmapCore core) {
|
||||
String pluginver = core.getDynmapPluginVersion();
|
||||
String platform = core.getDynmapPluginPlatform();
|
||||
String platver = core.getDynmapPluginPlatformVersion();
|
||||
if ((pluginver == null) || (platform == null) || (platver == null))
|
||||
return;
|
||||
HttpURLConnection conn = null;
|
||||
String loc = VERSION_URL;
|
||||
int cur_ver = getReleaseVersion(pluginver);
|
||||
int cur_bn = getBuildNumber(pluginver);
|
||||
try {
|
||||
while ((loc != null) && (!loc.isEmpty())) {
|
||||
URL url = new URL(loc);
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestProperty("User-Agent", "Dynmap (" + platform + "/" + platver + "/" + pluginver);
|
||||
conn.connect();
|
||||
loc = conn.getHeaderField("Location");
|
||||
}
|
||||
BufferedReader rdr = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line = null;
|
||||
while ((line = rdr.readLine()) != null) {
|
||||
String[] split = line.split(":");
|
||||
if (split.length < 4) continue;
|
||||
/* If our platform and version, or wildcard platform version */
|
||||
if (split[0].equals(platform) && (split[1].equals("*") || split[1].equals(platver))) {
|
||||
int recommended_ver = getReleaseVersion(split[2]);
|
||||
int recommended_bn = getBuildNumber(split[2]);
|
||||
if ((recommended_ver > cur_ver) || ((recommended_ver == cur_ver) && (recommended_bn > cur_bn))) { /* Newer recommended build */
|
||||
Log.info("Version obsolete: new recommended version " + split[2] + " is available.");
|
||||
} else if (cur_ver > recommended_ver) { /* Running dev or prerelease? */
|
||||
int prerel_ver = getReleaseVersion(split[3]);
|
||||
int prerel_bn = getBuildNumber(split[3]);
|
||||
if ((prerel_ver > cur_ver) || ((prerel_ver == cur_ver) && (prerel_bn > cur_bn))) {
|
||||
Log.info("Version obsolete: new prerelease version " + split[3] + " is available.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception x) {
|
||||
Log.info("Error checking for latest version");
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.dynmap.fabric_1_20.access;
|
||||
|
||||
public interface ProtoChunkAccessor {
|
||||
boolean getTouchedByWorldGen();
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.dynmap.fabric_1_20.command;
|
||||
|
||||
import org.dynmap.fabric_1_20.DynmapPlugin;
|
||||
|
||||
public class DmapCommand extends DynmapCommandExecutor {
|
||||
public DmapCommand(DynmapPlugin p) {
|
||||
super("dmap", p);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.dynmap.fabric_1_20.command;
|
||||
|
||||
import org.dynmap.fabric_1_20.DynmapPlugin;
|
||||
|
||||
public class DmarkerCommand extends DynmapCommandExecutor {
|
||||
public DmarkerCommand(DynmapPlugin p) {
|
||||
super("dmarker", p);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.dynmap.fabric_1_20.command;
|
||||
|
||||
import org.dynmap.fabric_1_20.DynmapPlugin;
|
||||
|
||||
public class DynmapCommand extends DynmapCommandExecutor {
|
||||
public DynmapCommand(DynmapPlugin p) {
|
||||
super("dynmap", p);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package org.dynmap.fabric_1_20.command;
|
||||
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.tree.ArgumentCommandNode;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import org.dynmap.fabric_1_20.DynmapPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
|
||||
import static net.minecraft.server.command.CommandManager.argument;
|
||||
import static net.minecraft.server.command.CommandManager.literal;
|
||||
|
||||
public class DynmapCommandExecutor implements Command<ServerCommandSource> {
|
||||
private final String cmd;
|
||||
private final DynmapPlugin plugin;
|
||||
|
||||
DynmapCommandExecutor(String cmd, DynmapPlugin plugin) {
|
||||
this.cmd = cmd;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void register(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||
final RootCommandNode<ServerCommandSource> root = dispatcher.getRoot();
|
||||
|
||||
final LiteralCommandNode<ServerCommandSource> command = literal(this.cmd)
|
||||
.executes(this)
|
||||
.build();
|
||||
|
||||
final ArgumentCommandNode<ServerCommandSource, String> args = argument("args", greedyString())
|
||||
.executes(this)
|
||||
.build();
|
||||
|
||||
// So this becomes "cmd" [args]
|
||||
command.addChild(args);
|
||||
|
||||
// Add command to the command dispatcher via root node.
|
||||
root.addChild(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
|
||||
// Commands in brigadier may be proxied in Minecraft via a syntax like `/execute ... ... run dmap [args]`
|
||||
// Dynmap will fail to parse this properly, so we find the starting position of the actual command being parsed after any forks or redirects.
|
||||
// The start position of the range specifies where the actual command dynmap has registered starts
|
||||
int start = context.getRange().getStart();
|
||||
String dynmapInput = context.getInput().substring(start);
|
||||
|
||||
String[] args = dynmapInput.split("\\s+");
|
||||
plugin.handleCommand(context.getSource(), cmd, Arrays.copyOfRange(args, 1, args.length));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// @Override // TODO: Usage?
|
||||
public String getUsage(ServerCommandSource commandSource) {
|
||||
return "Run /" + cmd + " help for details on using command";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package org.dynmap.fabric_1_20.command;
|
||||
|
||||
import org.dynmap.fabric_1_20.DynmapPlugin;
|
||||
|
||||
public class DynmapExpCommand extends DynmapCommandExecutor {
|
||||
public DynmapExpCommand(DynmapPlugin p) {
|
||||
super("dynmapexp", p);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.dynmap.fabric_1_20.event;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockEvents {
|
||||
private BlockEvents() {
|
||||
}
|
||||
|
||||
public static Event<BlockCallback> BLOCK_EVENT = EventFactory.createArrayBacked(BlockCallback.class,
|
||||
(listeners) -> (world, pos) -> {
|
||||
for (BlockCallback callback : listeners) {
|
||||
callback.onBlockEvent(world, pos);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static Event<SignChangeCallback> SIGN_CHANGE_EVENT = EventFactory.createArrayBacked(SignChangeCallback.class,
|
||||
(listeners) -> (world, pos, lines, player, front) -> {
|
||||
for (SignChangeCallback callback : listeners) {
|
||||
callback.onSignChange(world, pos, lines, player, front);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BlockCallback {
|
||||
void onBlockEvent(World world, BlockPos pos);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface SignChangeCallback {
|
||||
void onSignChange(ServerWorld world, BlockPos pos, String[] lines, ServerPlayerEntity player, boolean front);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.dynmap.fabric_1_20.event;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
public class CustomServerChunkEvents {
|
||||
public static Event<ChunkGenerate> CHUNK_GENERATE = EventFactory.createArrayBacked(ChunkGenerate.class,
|
||||
(listeners) -> (world, chunk) -> {
|
||||
for (ChunkGenerate callback : listeners) {
|
||||
callback.onChunkGenerate(world, chunk);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ChunkGenerate {
|
||||
void onChunkGenerate(ServerWorld world, Chunk chunk);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package org.dynmap.fabric_1_20.event;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
|
||||
public class CustomServerLifecycleEvents {
|
||||
public static final Event<ServerLifecycleEvents.ServerStarted> SERVER_STARTED_PRE_WORLD_LOAD =
|
||||
EventFactory.createArrayBacked(ServerLifecycleEvents.ServerStarted.class, (callbacks) -> (server) -> {
|
||||
for (ServerLifecycleEvents.ServerStarted callback : callbacks) {
|
||||
callback.onServerStarted(server);
|
||||
}
|
||||
});
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package org.dynmap.fabric_1_20.event;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
public class PlayerEvents {
|
||||
private PlayerEvents() {
|
||||
}
|
||||
|
||||
public static Event<PlayerLoggedIn> PLAYER_LOGGED_IN = EventFactory.createArrayBacked(PlayerLoggedIn.class,
|
||||
(listeners) -> (player) -> {
|
||||
for (PlayerLoggedIn callback : listeners) {
|
||||
callback.onPlayerLoggedIn(player);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static Event<PlayerLoggedOut> PLAYER_LOGGED_OUT = EventFactory.createArrayBacked(PlayerLoggedOut.class,
|
||||
(listeners) -> (player) -> {
|
||||
for (PlayerLoggedOut callback : listeners) {
|
||||
callback.onPlayerLoggedOut(player);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static Event<PlayerChangedDimension> PLAYER_CHANGED_DIMENSION = EventFactory.createArrayBacked(PlayerChangedDimension.class,
|
||||
(listeners) -> (player) -> {
|
||||
for (PlayerChangedDimension callback : listeners) {
|
||||
callback.onPlayerChangedDimension(player);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
public static Event<PlayerRespawn> PLAYER_RESPAWN = EventFactory.createArrayBacked(PlayerRespawn.class,
|
||||
(listeners) -> (player) -> {
|
||||
for (PlayerRespawn callback : listeners) {
|
||||
callback.onPlayerRespawn(player);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PlayerLoggedIn {
|
||||
void onPlayerLoggedIn(ServerPlayerEntity player);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PlayerLoggedOut {
|
||||
void onPlayerLoggedOut(ServerPlayerEntity player);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PlayerChangedDimension {
|
||||
void onPlayerChangedDimension(ServerPlayerEntity player);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface PlayerRespawn {
|
||||
void onPlayerRespawn(ServerPlayerEntity player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.dynmap.fabric_1_20.event;
|
||||
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
|
||||
public class ServerChatEvents {
|
||||
private ServerChatEvents() {
|
||||
}
|
||||
|
||||
public static Event<ServerChatCallback> EVENT = EventFactory.createArrayBacked(ServerChatCallback.class,
|
||||
(listeners) -> (player, message) -> {
|
||||
for (ServerChatCallback callback : listeners) {
|
||||
callback.onChatMessage(player, message);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ServerChatCallback {
|
||||
void onChatMessage(ServerPlayerEntity player, String message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.dynmap.fabric_1_20.mixin;
|
||||
|
||||
import net.minecraft.world.biome.BiomeEffects;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(BiomeEffects.class)
|
||||
public interface BiomeEffectsAccessor {
|
||||
@Accessor
|
||||
int getWaterColor();
|
||||
}
|