-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from patheloper/provider
Renamed NMSInterface to ChunkDataProvider
- Loading branch information
Showing
18 changed files
with
163 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...g/patheloper/paper/PaperNMSInterface.java → ...rovider/paper/PaperChunkDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 0 additions & 104 deletions
104
pathetic-nms/src/main/java/org/patheloper/nms/NMSUtils.java
This file was deleted.
Oops, something went wrong.
104 changes: 104 additions & 0 deletions
104
pathetic-nms/src/main/java/org/patheloper/provider/ChunkDataProviderResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package org.patheloper.provider; | ||
|
||
import lombok.Getter; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.patheloper.api.snapshot.ChunkDataProvider; | ||
import org.patheloper.provider.v1_12.OneTwelveChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_15.OneFifteenChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_16.OneSixteenChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_17.OneSeventeenChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_18.OneEighteenChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_18_R2.OneEighteenTwoChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_19_R2.OneNineteenTwoChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_19_R3.OneNineteenThreeChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_20_R1.OneTwentyOneChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_20_R2.OneTwentyTwoChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_20_R3.OneTwentyThreeChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_20_R4.OneTwentyFourChunkDataProviderImpl; | ||
import org.patheloper.provider.v1_8.OneEightChunkDataProviderImpl; | ||
import org.patheloper.provider.paper.PaperChunkDataProvider; | ||
|
||
@Getter | ||
@Slf4j | ||
public class ChunkDataProviderResolver { | ||
|
||
private final ChunkDataProvider chunkDataProvider; | ||
|
||
public ChunkDataProviderResolver(int major, int minor) { | ||
String version = "1." + major + "." + minor; | ||
|
||
if (isPaper()) { | ||
chunkDataProvider = new PaperChunkDataProvider(); | ||
} else { | ||
chunkDataProvider = determineChunkDataProvider(major, minor); | ||
} | ||
|
||
log.info( | ||
"Detected version v{}, using {}", version, chunkDataProvider.getClass().getSimpleName()); | ||
} | ||
|
||
private ChunkDataProvider determineChunkDataProvider(int major, int minor) { | ||
final ChunkDataProvider chunkDataProvider; | ||
switch (major) { | ||
case 20: | ||
if (minor == 5 || minor == 6) { | ||
chunkDataProvider = new OneTwentyFourChunkDataProviderImpl(); | ||
break; | ||
} else if (minor == 3 || minor == 4) { | ||
chunkDataProvider = new OneTwentyThreeChunkDataProviderImpl(); | ||
break; | ||
} else if (minor == 2) { | ||
chunkDataProvider = new OneTwentyTwoChunkDataProviderImpl(); | ||
break; | ||
} else if (minor == 1) { | ||
chunkDataProvider = new OneTwentyOneChunkDataProviderImpl(); | ||
break; | ||
} | ||
throw new IllegalArgumentException("Unsupported version: " + major + "." + minor); | ||
case 19: | ||
if (minor == 2 || minor == 3) { | ||
chunkDataProvider = new OneNineteenTwoChunkDataProviderImpl(); | ||
break; | ||
} | ||
if (minor == 4) { | ||
chunkDataProvider = new OneNineteenThreeChunkDataProviderImpl(); | ||
break; | ||
} | ||
throw new IllegalArgumentException("Unsupported version: " + major + "." + minor); | ||
case 18: | ||
if (minor == 2) { | ||
chunkDataProvider = new OneEighteenTwoChunkDataProviderImpl(); | ||
break; | ||
} | ||
chunkDataProvider = new OneEighteenChunkDataProviderImpl(); | ||
break; | ||
case 17: | ||
chunkDataProvider = new OneSeventeenChunkDataProviderImpl(); | ||
break; | ||
case 16: | ||
chunkDataProvider = new OneSixteenChunkDataProviderImpl(); | ||
break; | ||
case 15: | ||
chunkDataProvider = new OneFifteenChunkDataProviderImpl(); | ||
break; | ||
case 12: | ||
chunkDataProvider = new OneTwelveChunkDataProviderImpl(); | ||
break; | ||
case 8: | ||
chunkDataProvider = new OneEightChunkDataProviderImpl(); | ||
break; | ||
default: | ||
throw new IllegalArgumentException("Unsupported version: " + major + "." + minor); | ||
} | ||
return chunkDataProvider; | ||
} | ||
|
||
private boolean isPaper() { | ||
try { | ||
Class.forName("io.papermc.paper.configuration.GlobalConfiguration"); | ||
return true; | ||
} catch (ClassNotFoundException e) { | ||
return false; | ||
} | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...oper/nms/v1_12/OneTwelveNMSInterface.java → ...v1_12/OneTwelveChunkDataProviderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.