Skip to content

Commit b8f66d7

Browse files
committed
Merge branch 'mc/1.13' into mc/1.12
2 parents d0c6c00 + 015b383 commit b8f66d7

File tree

11 files changed

+146
-14
lines changed

11 files changed

+146
-14
lines changed

BlueMapBukkit/src/main/java/de/bluecolored/bluemap/bukkit/BukkitPlugin.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ public void unregisterAllListeners() {
7878

7979
@Override
8080
public UUID getUUIDForWorld(File worldFolder) throws IOException {
81+
//if it is a dimension folder
82+
if (!new File(worldFolder, "level.dat").exists()) {
83+
worldFolder = worldFolder.getParentFile();
84+
}
85+
8186
final File normalizedWorldFolder = worldFolder.getCanonicalFile();
8287

8388
Future<UUID> futureUUID;

BlueMapBukkit/src/main/resources/bluemap-bukkit.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ maps: [
134134
{
135135
id: "end"
136136
name: "End"
137-
world: "world_the_end"
137+
world: "world_the_end/DIM1"
138138

139139
# We dont want a blue sky in the end
140140
skyColor: "#080010"
@@ -150,7 +150,7 @@ maps: [
150150
{
151151
id: "nether"
152152
name: "Nether"
153-
world: "world_nether"
153+
world: "world_nether/DIM-1"
154154

155155
skyColor: "#290000"
156156

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil112.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public LightData getLightData(Vector3i pos) {
9898
int sectionY = MCAUtil.blockToChunk(pos.getY());
9999

100100
Section section = this.sections[sectionY];
101-
if (section == null) return LightData.FULL;
101+
if (section == null) return LightData.SKY;
102102

103103
return section.getLightData(pos);
104104
}

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public LightData getLightData(Vector3i pos) {
107107
int sectionY = MCAUtil.blockToChunk(pos.getY());
108108

109109
Section section = this.sections[sectionY];
110-
if (section == null) return LightData.FULL;
110+
if (section == null) return LightData.SKY;
111111

112112
return section.getLightData(pos);
113113
}

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public LightData getLightData(Vector3i pos) {
107107
int sectionY = MCAUtil.blockToChunk(pos.getY());
108108

109109
Section section = this.sections[sectionY];
110-
if (section == null) return LightData.FULL;
110+
if (section == null) return LightData.SKY;
111111

112112
return section.getLightData(pos);
113113
}

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/MCAWorld.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public Block getBlock(Vector3i pos) {
169169
}
170170

171171
if (pos.getY() > getMaxY()) {
172-
return new Block(this, BlockState.AIR, LightData.FULL, Biome.DEFAULT, BlockProperties.TRANSPARENT, pos);
172+
return new Block(this, BlockState.AIR, LightData.SKY, Biome.DEFAULT, BlockProperties.TRANSPARENT, pos);
173173
}
174174

175175
try {

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resourcepack/ResourcePack.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import de.bluecolored.bluemap.core.logger.Logger;
4646
import de.bluecolored.bluemap.core.resourcepack.BlockStateResource.Builder;
4747
import de.bluecolored.bluemap.core.resourcepack.fileaccess.BluemapAssetOverrideFileAccess;
48+
import de.bluecolored.bluemap.core.resourcepack.fileaccess.CaseInsensitiveFileAccess;
4849
import de.bluecolored.bluemap.core.resourcepack.fileaccess.CombinedFileAccess;
4950
import de.bluecolored.bluemap.core.resourcepack.fileaccess.FileAccess;
5051
import de.bluecolored.bluemap.core.world.BlockState;
@@ -140,7 +141,7 @@ public void load(File... sources) {
140141
}
141142
}
142143

143-
FileAccess sourcesAccess = new BluemapAssetOverrideFileAccess(combinedSources);
144+
FileAccess sourcesAccess = new CaseInsensitiveFileAccess(new BluemapAssetOverrideFileAccess(combinedSources));
144145

145146
textures.reloadAllTextures(sourcesAccess);
146147

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.core.resourcepack.fileaccess;
26+
27+
import java.io.FileNotFoundException;
28+
import java.io.IOException;
29+
import java.io.InputStream;
30+
import java.util.Collection;
31+
32+
/**
33+
* This {@link FileAccess} maps its parent {@link FileAccess} to first look in assets/[namespace]/bluemap/... instead of assets/[namespace]/...
34+
*/
35+
public class CaseInsensitiveFileAccess implements FileAccess {
36+
37+
public FileAccess parent;
38+
39+
public CaseInsensitiveFileAccess(FileAccess parent) {
40+
this.parent = parent;
41+
}
42+
43+
@Override
44+
public InputStream readFile(String path) throws FileNotFoundException, IOException {
45+
try {
46+
return parent.readFile(path);
47+
} catch (FileNotFoundException ex) {
48+
try {
49+
return parent.readFile(path.toLowerCase());
50+
} catch (FileNotFoundException ex2) {
51+
path = correctPathCase(path);
52+
return parent.readFile(path);
53+
}
54+
}
55+
}
56+
57+
private String correctPathCase(String path) throws FileNotFoundException, IOException {
58+
path = FileAccess.normalize(path);
59+
String[] pathParts = path.split("/");
60+
61+
String correctPath = "";
62+
for (int i = 0; i < pathParts.length; i++) {
63+
String part = correctPath + pathParts[i];
64+
65+
boolean found = false;
66+
for(String folder : listFolders(correctPath)) {
67+
if (!folder.equalsIgnoreCase(part)) continue;
68+
69+
part = folder;
70+
found = true;
71+
break;
72+
}
73+
74+
if (!found && i == pathParts.length - 1) {
75+
for(String folder : listFiles(correctPath, false)) {
76+
if (!folder.equalsIgnoreCase(part)) continue;
77+
78+
part = folder;
79+
found = true;
80+
break;
81+
}
82+
}
83+
84+
if (!found) throw new FileNotFoundException();
85+
86+
correctPath = part + "/";
87+
}
88+
89+
correctPath = FileAccess.normalize(correctPath);
90+
return correctPath;
91+
}
92+
93+
@Override
94+
public Collection<String> listFiles(String path, boolean recursive) {
95+
return parent.listFiles(path, recursive);
96+
}
97+
98+
@Override
99+
public Collection<String> listFolders(String path) {
100+
return parent.listFolders(path);
101+
}
102+
103+
@Override
104+
public void close() throws IOException {
105+
parent.close();
106+
}
107+
108+
}

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resourcepack/fileaccess/ZipFileAccess.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.ArrayList;
3232
import java.util.Collection;
3333
import java.util.Enumeration;
34+
import java.util.HashSet;
3435
import java.util.zip.ZipEntry;
3536
import java.util.zip.ZipException;
3637
import java.util.zip.ZipFile;
@@ -85,14 +86,20 @@ public Collection<String> listFiles(String path, boolean recursive) {
8586
public Collection<String> listFolders(String path) {
8687
path = normalizeFolderPath(path);
8788

88-
Collection<String> folders = new ArrayList<String>();
89+
Collection<String> folders = new HashSet<String>();
8990
for (Enumeration<? extends ZipEntry> entries = file.entries(); entries.hasMoreElements();) {
9091
ZipEntry entry = entries.nextElement();
9192

92-
if (!entry.isDirectory()) continue;
93-
9493
String file = entry.getName();
95-
file = file.substring(0, file.length() - 1); //strip last /
94+
if (!entry.isDirectory()) {
95+
int nameSplit = file.lastIndexOf('/');
96+
if (nameSplit == -1) continue;
97+
file = file.substring(0, nameSplit);
98+
}
99+
file = normalizeFolderPath(file);
100+
101+
//strip last /
102+
file = file.substring(0, file.length() - 1);
96103

97104
int nameSplit = file.lastIndexOf('/');
98105
String filePath = "/";
@@ -101,7 +108,17 @@ public Collection<String> listFolders(String path) {
101108
}
102109
filePath = normalizeFolderPath(filePath);
103110

104-
if (!path.equals(filePath)) continue;
111+
if (!filePath.startsWith(path)) continue;
112+
113+
int subFolderMark = file.indexOf('/', path.length());
114+
if (subFolderMark != -1) {
115+
file = file.substring(0, subFolderMark);
116+
}
117+
118+
file = normalizeFolderPath(file);
119+
120+
//strip last /
121+
file = file.substring(0, file.length() - 1);
105122

106123
folders.add(file);
107124
}

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/LightData.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
public class LightData {
2828

2929
public static final LightData ZERO = new LightData(0, 0);
30-
public static final LightData FULL = new LightData(15, 15);
30+
public static final LightData SKY = new LightData(15, 0);
31+
public static final LightData FULL = new LightData(15, 15);
3132

3233
private final int skyLight, blockLight;
3334

0 commit comments

Comments
 (0)