├── LICENSE ├── README.md ├── build.gradle ├── bukkit-all └── build.gradle ├── bukkit-backward-support ├── build.gradle └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── lightapi │ ├── LightAPI.java │ ├── LightType.java │ ├── chunks │ ├── ChunkCache.java │ └── ChunkInfo.java │ ├── events │ ├── DeleteLightEvent.java │ ├── SetLightEvent.java │ └── UpdateChunkEvent.java │ ├── request │ ├── DataRequest.java │ └── RequestSteamMachine.java │ └── server │ ├── ServerModInfo.java │ ├── ServerModManager.java │ ├── exceptions │ ├── ServerModException.java │ ├── UnknownModImplementationException.java │ └── UnknownNMSVersionException.java │ └── nms │ └── INMSHandler.java ├── bukkit-common ├── build.gradle └── src │ └── main │ ├── java │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ ├── BukkitPlugin.java │ │ ├── api │ │ └── extension │ │ │ └── IBukkitExtension.java │ │ └── internal │ │ ├── BukkitPlatformImpl.java │ │ ├── chunks │ │ └── observer │ │ │ └── sched │ │ │ └── BukkitScheduledChunkObserverImpl.java │ │ ├── engine │ │ └── sched │ │ │ └── BukkitScheduledLightEngineImpl.java │ │ ├── handler │ │ ├── CompatibilityHandler.java │ │ ├── IHandler.java │ │ ├── IHandlerFactory.java │ │ └── craftbukkit │ │ │ ├── HandlerFactory.java │ │ │ └── nms │ │ │ └── BaseNMSHandler.java │ │ ├── service │ │ └── BukkitBackgroundServiceImpl.java │ │ └── utils │ │ ├── UsageTest.java │ │ └── VersionUtil.java │ └── resources │ ├── plugin.yml │ └── storage.yml ├── bukkit-example ├── build.gradle └── src │ └── main │ ├── java │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── example │ │ ├── BukkitPlugin.java │ │ ├── ChunkUtils.java │ │ ├── DebugListener.java │ │ └── EntityTracker.java │ └── resources │ └── plugin.yml ├── bukkit-nms ├── v1_13_R2 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_13_R2 │ │ └── VanillaNMSHandler.java ├── v1_14_R1 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_14_R1 │ │ └── VanillaNMSHandler.java ├── v1_15_R1 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_15_R1 │ │ └── VanillaNMSHandler.java ├── v1_16_R1 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_16_R1 │ │ └── VanillaNMSHandler.java ├── v1_16_R2 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_16_R2 │ │ └── VanillaNMSHandler.java ├── v1_16_R3 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_16_R3 │ │ └── VanillaNMSHandler.java ├── v1_17_R1 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_17_R1 │ │ ├── StarlightNMSHandler.java │ │ └── VanillaNMSHandler.java ├── v1_18_R1 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_18_R1 │ │ ├── StarlightNMSHandler.java │ │ └── VanillaNMSHandler.java ├── v1_18_R2 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_18_R2 │ │ ├── StarlightNMSHandler.java │ │ └── VanillaNMSHandler.java ├── v1_19_R1 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_19_R1 │ │ ├── StarlightNMSHandler.java │ │ └── VanillaNMSHandler.java ├── v1_19_R2 │ ├── build.gradle │ └── src │ │ └── main │ │ └── java │ │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── internal │ │ └── handler │ │ └── craftbukkit │ │ └── nms │ │ └── v1_19_R2 │ │ ├── StarlightNMSHandler.java │ │ └── VanillaNMSHandler.java └── v1_19_R3 │ ├── build.gradle │ └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_19_R3 │ ├── StarlightNMSHandler.java │ └── VanillaNMSHandler.java ├── common ├── build.gradle └── src │ └── main │ ├── java │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── common │ │ ├── Build.java │ │ ├── IChunkData.java │ │ ├── LCallback.java │ │ ├── LReason.java │ │ ├── LStage.java │ │ ├── LightAPI.java │ │ ├── LightType.java │ │ ├── api │ │ ├── ResultCode.java │ │ ├── engine │ │ │ ├── EditPolicy.java │ │ │ ├── LightFlag.java │ │ │ ├── LightType.java │ │ │ ├── RelightPolicy.java │ │ │ ├── SendPolicy.java │ │ │ └── sched │ │ │ │ └── ICallback.java │ │ └── extension │ │ │ └── IExtension.java │ │ └── internal │ │ ├── IPlatformImpl.java │ │ ├── InternalCode.java │ │ ├── PlatformType.java │ │ ├── chunks │ │ ├── data │ │ │ ├── BitChunkData.java │ │ │ ├── ChunkData.java │ │ │ ├── IChunkData.java │ │ │ ├── IntChunkData.java │ │ │ └── LegacyIntChunkData.java │ │ └── observer │ │ │ ├── IChunkObserver.java │ │ │ └── sched │ │ │ ├── IScheduledChunkObserver.java │ │ │ └── ScheduledChunkObserverImpl.java │ │ ├── engine │ │ ├── ILightEngine.java │ │ ├── LightEngineType.java │ │ ├── LightEngineVersion.java │ │ └── sched │ │ │ ├── IScheduledLightEngine.java │ │ │ ├── IScheduler.java │ │ │ ├── PriorityScheduler.java │ │ │ ├── Request.java │ │ │ ├── RequestFlag.java │ │ │ └── ScheduledLightEngineImpl.java │ │ ├── service │ │ ├── BackgroundServiceImpl.java │ │ └── IBackgroundService.java │ │ └── utils │ │ ├── BlockPosition.java │ │ ├── ChunkUtils.java │ │ ├── FlagUtils.java │ │ └── UsageTest.java │ └── resources │ └── LICENSE ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle ├── sponge-all ├── pom.xml └── src │ └── main │ └── assembly │ └── all-jar.xml ├── sponge-common ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── impl │ └── sponge │ ├── ISpongeLightHandler.java │ ├── SpongeChunkData.java │ ├── SpongeHandlerFactory.java │ ├── SpongeLightHandler.java │ └── SpongePlugin.java └── sponge-mcp-v1_12_R1 ├── mappings ├── mcp2srg.srg └── obf2mcp.srg ├── pom.xml └── src └── main └── java └── ru └── beykerykt └── minecraft └── lightapi └── impl └── sponge └── mcp └── MCP_v1_12_R1.java /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Vladimir Mikhailov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LightrAPI - LightAPI Fork 2 | 3 | Bukkit Library for create invisible light source 4 | 5 | Based on [BeYkeRYkt/LightAPI](https://github.com/BeYkeRYkt/LightAPI), [ahdg6/LightAPI](https://github.com/ahdg6/LightAPI) 6 | 7 | ## Download 8 | https://github.com/IPECTER/LighterAPI/releases 9 | 10 | 11 | ## More LightWeight, Simple LightAPI Fork (WIP) 12 | https://github.com/IPECTER/PhotonAPI 13 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'maven-publish' 3 | id 'java-library' 4 | id 'io.papermc.paperweight.userdev' version "1.5.3" apply false 5 | } 6 | 7 | ext { 8 | pluginVersion = '5.5.0' 9 | } 10 | 11 | allprojects { 12 | group = 'ru.beykerykt.minecraft' 13 | java.sourceCompatibility = JavaVersion.VERSION_1_8 14 | 15 | apply plugin: 'java-library' 16 | 17 | repositories { 18 | mavenLocal() 19 | maven { url = uri('https://repo.maven.apache.org/maven2/') } 20 | maven { url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/') } 21 | maven { url = uri('https://repo.papermc.io/repository/maven-public/') } 22 | // codemc 23 | maven { url = uri('https://repo.codemc.org/repository/maven-public/') } 24 | // nms 25 | maven { url = uri('https://repo.codemc.io/repository/nms-local/') } 26 | maven { url = uri('https://repo.md-5.net/content/groups/public/') } 27 | maven { url = uri('https://libraries.minecraft.net/') } 28 | } 29 | 30 | tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } 31 | tasks.withType(Javadoc) { options.encoding = 'UTF-8' } 32 | } 33 | 34 | 35 | logger.lifecycle(""" 36 | ******************************************* 37 | You are building LightAPI! 38 | Output files will be in [Platform]-all/LightAPI-[Platform]-[Version].jar 39 | ******************************************* 40 | """) 41 | 42 | publishing { 43 | publications { 44 | maven(MavenPublication) { 45 | from(components.java) 46 | } 47 | } 48 | } 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /bukkit-all/build.gradle: -------------------------------------------------------------------------------- 1 | import java.text.SimpleDateFormat 2 | 3 | plugins { 4 | id 'java-library' 5 | id 'com.github.johnrengelman.shadow' version '8.1.1' 6 | } 7 | 8 | dependencies { 9 | implementation project(':common') 10 | implementation project(':bukkit-common') 11 | implementation project(':bukkit-backward-support') 12 | implementation project(':lightapi-craftbukkit-nms-v1_13_R2') 13 | implementation project(':lightapi-craftbukkit-nms-v1_14_R1') 14 | implementation project(':lightapi-craftbukkit-nms-v1_15_R1') 15 | implementation project(':lightapi-craftbukkit-nms-v1_16_R1') 16 | implementation project(':lightapi-craftbukkit-nms-v1_16_R2') 17 | implementation project(':lightapi-craftbukkit-nms-v1_16_R3') 18 | implementation project(':lightapi-craftbukkit-nms-v1_17_R1') 19 | implementation project(path: ':lightapi-craftbukkit-nms-v1_18_R1', configuration: 'reobf') 20 | implementation project(path: ':lightapi-craftbukkit-nms-v1_18_R2', configuration: 'reobf') 21 | implementation project(path: ':lightapi-craftbukkit-nms-v1_19_R1', configuration: 'reobf') 22 | implementation project(path: ':lightapi-craftbukkit-nms-v1_19_R2', configuration: 'reobf') 23 | implementation project(path: ':lightapi-craftbukkit-nms-v1_19_R3', configuration: 'reobf') 24 | } 25 | 26 | description = 'bukkit-all' 27 | 28 | tasks.withType(Jar) { 29 | destinationDirectory = file("$rootDir/bukkit-all") 30 | } 31 | 32 | artifacts { 33 | archives shadowJar 34 | } 35 | 36 | def pluginVersion = rootProject.ext.pluginVersion 37 | def SERVER_API = 'Bukkit' 38 | 39 | shadowJar { 40 | relocate("org.bstats", "ru.beykerykt.minecraft.lightapi.bukkit.bstats") 41 | 42 | version = pluginVersion 43 | archiveBaseName = 'LightAPI-Bukkit' 44 | archiveClassifier.set('SNAPSHOT') 45 | manifest { 46 | attributes( 47 | 'Built-By': System.properties['user.name'], 48 | 'Version': pluginVersion, 49 | 'Build-Timestamp': new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss.SSSZ").format(new Date()), 50 | 'Created-By': "Gradle ${gradle.gradleVersion}", 51 | 'Build-Jdk': "${System.properties['java.version']} " + 52 | "(${System.properties['java.vendor']} ${System.properties['java.vm.version']})", 53 | 'Build-OS': "${System.properties['os.name']} ${System.properties['os.arch']} " + 54 | "${System.properties['os.version']}" 55 | ) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /bukkit-backward-support/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly project(':common') 4 | compileOnly 'org.spigotmc:spigot-api:1.14.4-R0.1-SNAPSHOT' 5 | } 6 | 7 | description = 'bukkit-backward-support' 8 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/LightType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi; 25 | 26 | @Deprecated 27 | public enum LightType { 28 | SKY, 29 | BLOCK 30 | } 31 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/chunks/ChunkCache.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.chunks; 25 | 26 | import java.util.List; 27 | import java.util.concurrent.CopyOnWriteArrayList; 28 | 29 | @Deprecated 30 | public class ChunkCache { 31 | 32 | public static List CHUNK_INFO_QUEUE = new CopyOnWriteArrayList<>(); 33 | } 34 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/chunks/ChunkInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.chunks; 25 | 26 | import org.bukkit.World; 27 | import org.bukkit.entity.Player; 28 | 29 | import java.util.Collection; 30 | 31 | @Deprecated 32 | public class ChunkInfo { 33 | 34 | private final World world; 35 | private final int x; 36 | private final int z; 37 | private int y; 38 | private Collection receivers; 39 | 40 | public ChunkInfo(World world, int chunkX, int chunkZ, Collection players) { 41 | this(world, chunkX, 256, chunkZ, players); 42 | } 43 | 44 | public ChunkInfo(World world, int chunkX, int chunk_y_height, int chunkZ, Collection players) { 45 | this.world = world; 46 | this.x = chunkX; 47 | this.y = chunk_y_height; 48 | this.z = chunkZ; 49 | this.receivers = players; 50 | } 51 | 52 | public World getWorld() { 53 | return world; 54 | } 55 | 56 | public int getChunkX() { 57 | return x; 58 | } 59 | 60 | public int getChunkZ() { 61 | return z; 62 | } 63 | 64 | public int getChunkYHeight() { 65 | return y; 66 | } 67 | 68 | public void setChunkYHeight(int y) { 69 | this.y = y; 70 | } 71 | 72 | public Collection getReceivers() { 73 | return receivers; 74 | } 75 | 76 | public void setReceivers(Collection receivers) { 77 | this.receivers = receivers; 78 | } 79 | 80 | @Override 81 | public int hashCode() { 82 | final int prime = 31; 83 | int result = 1; 84 | result = prime * result + ((world == null) ? 0 : world.hashCode()); 85 | result = prime * result + x; 86 | result = prime * result + z; 87 | return result; 88 | } 89 | 90 | @Override 91 | public boolean equals(Object obj) { 92 | if (this == obj) { 93 | return true; 94 | } 95 | if (obj == null) { 96 | return false; 97 | } 98 | if (!(obj instanceof ChunkInfo)) { 99 | return false; 100 | } 101 | ChunkInfo other = (ChunkInfo) obj; 102 | if (world == null) { 103 | if (other.world != null) { 104 | return false; 105 | } 106 | } else if (!world.getName().equals(other.world.getName())) { 107 | return false; 108 | } 109 | if (x != other.x) { 110 | return false; 111 | } 112 | return z == other.z; 113 | } 114 | 115 | @Override 116 | public String toString() { 117 | return "ChunkInfo [world=" + world + ", x=" + x + ", y=" + y + ", z=" + z + "]"; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/events/DeleteLightEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.events; 25 | 26 | import org.bukkit.World; 27 | import org.bukkit.event.Cancellable; 28 | import org.bukkit.event.Event; 29 | import org.bukkit.event.HandlerList; 30 | 31 | @Deprecated 32 | public class DeleteLightEvent extends Event implements Cancellable { 33 | 34 | private static final HandlerList handlers = new HandlerList(); 35 | private boolean cancel; 36 | private World world; 37 | private int x; 38 | private int y; 39 | private int z; 40 | private boolean async; 41 | 42 | public DeleteLightEvent(World world, int x, int y, int z, boolean async) { 43 | this.world = world; 44 | this.x = x; 45 | this.y = y; 46 | this.z = z; 47 | this.async = async; 48 | } 49 | 50 | public static HandlerList getHandlerList() { 51 | return handlers; 52 | } 53 | 54 | @Override 55 | public HandlerList getHandlers() { 56 | return handlers; 57 | } 58 | 59 | @Override 60 | public boolean isCancelled() { 61 | return cancel; 62 | } 63 | 64 | @Override 65 | public void setCancelled(boolean arg0) { 66 | this.cancel = arg0; 67 | } 68 | 69 | public int getX() { 70 | return x; 71 | } 72 | 73 | public void setX(int x) { 74 | this.x = x; 75 | } 76 | 77 | public int getY() { 78 | return y; 79 | } 80 | 81 | public void setY(int y) { 82 | this.y = y; 83 | } 84 | 85 | public int getZ() { 86 | return z; 87 | } 88 | 89 | public void setZ(int z) { 90 | this.z = z; 91 | } 92 | 93 | public World getWorld() { 94 | return world; 95 | } 96 | 97 | public void setWorld(World world) { 98 | this.world = world; 99 | } 100 | 101 | public boolean isAsync() { 102 | return async; 103 | } 104 | 105 | public void setAsync(boolean flag) { 106 | this.async = flag; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/events/SetLightEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.events; 25 | 26 | import org.bukkit.World; 27 | import org.bukkit.event.Cancellable; 28 | import org.bukkit.event.Event; 29 | import org.bukkit.event.HandlerList; 30 | 31 | @Deprecated 32 | public class SetLightEvent extends Event implements Cancellable { 33 | 34 | private static final HandlerList handlers = new HandlerList(); 35 | private boolean cancel; 36 | private World world; 37 | private int x; 38 | private int y; 39 | private int z; 40 | private int level; 41 | private boolean async; 42 | 43 | public SetLightEvent(World world, int x, int y, int z, int level, boolean async) { 44 | this.world = world; 45 | this.x = x; 46 | this.y = y; 47 | this.z = z; 48 | this.level = level; 49 | this.async = async; 50 | } 51 | 52 | public static HandlerList getHandlerList() { 53 | return handlers; 54 | } 55 | 56 | @Override 57 | public HandlerList getHandlers() { 58 | return handlers; 59 | } 60 | 61 | @Override 62 | public boolean isCancelled() { 63 | return cancel; 64 | } 65 | 66 | @Override 67 | public void setCancelled(boolean arg0) { 68 | this.cancel = arg0; 69 | } 70 | 71 | public int getLightLevel() { 72 | return level; 73 | } 74 | 75 | public void setLightLevel(int level) { 76 | this.level = level; 77 | } 78 | 79 | public int getX() { 80 | return x; 81 | } 82 | 83 | public void setX(int x) { 84 | this.x = x; 85 | } 86 | 87 | public int getY() { 88 | return y; 89 | } 90 | 91 | public void setY(int y) { 92 | this.y = y; 93 | } 94 | 95 | public int getZ() { 96 | return z; 97 | } 98 | 99 | public void setZ(int z) { 100 | this.z = z; 101 | } 102 | 103 | public World getWorld() { 104 | return world; 105 | } 106 | 107 | public void setWorld(World world) { 108 | this.world = world; 109 | } 110 | 111 | public boolean isAsync() { 112 | return async; 113 | } 114 | 115 | public void setAsync(boolean flag) { 116 | this.async = flag; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/events/UpdateChunkEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.events; 25 | 26 | import org.bukkit.event.Cancellable; 27 | import org.bukkit.event.Event; 28 | import org.bukkit.event.HandlerList; 29 | import ru.beykerykt.lightapi.chunks.ChunkInfo; 30 | 31 | @Deprecated 32 | public class UpdateChunkEvent extends Event implements Cancellable { 33 | 34 | private static final HandlerList handlers = new HandlerList(); 35 | private boolean cancel; 36 | private ChunkInfo cCoord; 37 | 38 | public UpdateChunkEvent(ChunkInfo cCoord) { 39 | this.cCoord = cCoord; 40 | } 41 | 42 | public static HandlerList getHandlerList() { 43 | return handlers; 44 | } 45 | 46 | @Override 47 | public HandlerList getHandlers() { 48 | return handlers; 49 | } 50 | 51 | @Override 52 | public boolean isCancelled() { 53 | return cancel; 54 | } 55 | 56 | @Override 57 | public void setCancelled(boolean arg0) { 58 | this.cancel = arg0; 59 | } 60 | 61 | public ChunkInfo getChunkInfo() { 62 | return cCoord; 63 | } 64 | 65 | public void setChunkInfo(ChunkInfo cCoord) { 66 | this.cCoord = cCoord; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/request/DataRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.request; 25 | 26 | @Deprecated 27 | public interface DataRequest { 28 | 29 | void process(); 30 | } 31 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/request/RequestSteamMachine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.request; 25 | 26 | @Deprecated 27 | public class RequestSteamMachine implements Runnable { 28 | 29 | public void start(int ticks, int maxIterationsPerTick) { 30 | } 31 | 32 | public void shutdown() { 33 | } 34 | 35 | public boolean isStarted() { 36 | return false; 37 | } 38 | 39 | public boolean addToQueue(DataRequest request) { 40 | return false; 41 | } 42 | 43 | @Override 44 | public void run() { 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/server/ServerModInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.server; 25 | 26 | import ru.beykerykt.lightapi.server.nms.INMSHandler; 27 | 28 | import java.util.Map; 29 | 30 | @Deprecated 31 | public class ServerModInfo { 32 | 33 | public ServerModInfo(String modname) { 34 | } 35 | 36 | public String getModName() { 37 | return "UNKNOWN"; 38 | } 39 | 40 | public Map> getVersions() { 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/server/ServerModManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.server; 25 | 26 | import ru.beykerykt.lightapi.server.exceptions.UnknownModImplementationException; 27 | import ru.beykerykt.lightapi.server.exceptions.UnknownNMSVersionException; 28 | import ru.beykerykt.lightapi.server.nms.INMSHandler; 29 | 30 | import java.lang.reflect.InvocationTargetException; 31 | 32 | @Deprecated 33 | public class ServerModManager { 34 | 35 | public static void init() 36 | throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, 37 | NoSuchMethodException, SecurityException, UnknownNMSVersionException, UnknownModImplementationException { 38 | throw new UnknownModImplementationException("UNKNOWN"); 39 | } 40 | 41 | public static void shutdown() { 42 | } 43 | 44 | public static boolean isInitialized() { 45 | return false; 46 | } 47 | 48 | public static boolean registerServerMod(ServerModInfo info) { 49 | return false; 50 | } 51 | 52 | public static boolean unregisterServerMod(String modName) { 53 | return false; 54 | } 55 | 56 | public static INMSHandler getNMSHandler() { 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/server/exceptions/ServerModException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.server.exceptions; 25 | 26 | public class ServerModException extends Exception { 27 | 28 | /** 29 | * ??? 30 | */ 31 | private static final long serialVersionUID = -649256823875085117L; 32 | 33 | public ServerModException(String message) { 34 | super(message); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/server/exceptions/UnknownModImplementationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.server.exceptions; 25 | 26 | public class UnknownModImplementationException extends ServerModException { 27 | 28 | /** 29 | * ??? 30 | */ 31 | private static final long serialVersionUID = -1754539191843175633L; 32 | 33 | private final String modName; 34 | 35 | public UnknownModImplementationException(String modName) { 36 | super("Could not find handler for this Bukkit implementation: " + modName); 37 | this.modName = modName; 38 | } 39 | 40 | public String getModName() { 41 | return modName; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/server/exceptions/UnknownNMSVersionException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.server.exceptions; 25 | 26 | public class UnknownNMSVersionException extends ServerModException { 27 | 28 | /** 29 | * ??? 30 | */ 31 | private static final long serialVersionUID = -1927826763790232512L; 32 | 33 | private final String modName; 34 | private final String nmsVersion; 35 | 36 | public UnknownNMSVersionException(String modName, String nmsVersion) { 37 | super("Could not find handler for this Bukkit " + modName + " implementation " + nmsVersion + " version."); 38 | this.modName = modName; 39 | this.nmsVersion = nmsVersion; 40 | } 41 | 42 | public String getNmsVersion() { 43 | return nmsVersion; 44 | } 45 | 46 | public String getModName() { 47 | return modName; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /bukkit-backward-support/src/main/java/ru/beykerykt/lightapi/server/nms/INMSHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.lightapi.server.nms; 25 | 26 | import org.bukkit.World; 27 | import org.bukkit.entity.Player; 28 | import ru.beykerykt.lightapi.chunks.ChunkInfo; 29 | 30 | import java.util.Collection; 31 | import java.util.List; 32 | 33 | @Deprecated 34 | public interface INMSHandler { 35 | 36 | // Lights... 37 | void createLight(World world, int x, int y, int z, int light); 38 | 39 | void deleteLight(World world, int x, int y, int z); 40 | 41 | void recalculateLight(World world, int x, int y, int z); 42 | 43 | // Chunks... 44 | List collectChunks(World world, int x, int y, int z); 45 | 46 | void sendChunkUpdate(World world, int chunkX, int chunkZ, Collection players); 47 | 48 | void sendChunkUpdate(World world, int chunkX, int chunkZ, Player player); 49 | 50 | void sendChunkUpdate(World world, int chunkX, int y, int chunkZ, Collection players); 51 | 52 | void sendChunkUpdate(World world, int chunkX, int y, int chunkZ, Player player); 53 | } 54 | -------------------------------------------------------------------------------- /bukkit-common/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | api project(':common') 3 | implementation 'org.bstats:bstats-bukkit:2.2.1' 4 | compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT' 5 | } 6 | 7 | processResources { 8 | filesMatching(['plugin.yml']) { 9 | expand version: rootProject.ext.pluginVersion 10 | } 11 | } 12 | 13 | description = 'bukkit-common' 14 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/api/extension/IBukkitExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.api.extension; 25 | 26 | import org.bukkit.World; 27 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.IHandler; 28 | import ru.beykerykt.minecraft.lightapi.common.api.engine.EditPolicy; 29 | import ru.beykerykt.minecraft.lightapi.common.api.engine.SendPolicy; 30 | import ru.beykerykt.minecraft.lightapi.common.api.engine.sched.ICallback; 31 | import ru.beykerykt.minecraft.lightapi.common.api.extension.IExtension; 32 | 33 | public interface IBukkitExtension extends IExtension { 34 | 35 | /** 36 | * Gets the level of light from given coordinates with specific flags. 37 | */ 38 | int getLightLevel(World world, int blockX, int blockY, int blockZ); 39 | 40 | /** 41 | * Gets the level of light from given coordinates with specific flags. 42 | */ 43 | int getLightLevel(World world, int blockX, int blockY, int blockZ, int lightFlags); 44 | 45 | /** 46 | * Placement of a specific type of light with a given level of illumination in the named world in 47 | * certain coordinates with the return code result. 48 | */ 49 | int setLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel); 50 | 51 | /** 52 | * Placement of a specific type of light with a given level of illumination in the named world in 53 | * certain coordinates with the return code result. 54 | */ 55 | int setLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags); 56 | 57 | /** 58 | * Placement of a specific type of light with a given level of illumination in the named world in 59 | * certain coordinates with the return code result. 60 | */ 61 | int setLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags, 62 | ICallback callback); 63 | 64 | /** 65 | * Placement of a specific type of light with a given level of illumination in the named world in 66 | * certain coordinates with the return code result. 67 | */ 68 | int setLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags, 69 | EditPolicy editPolicy, SendPolicy sendPolicy, ICallback callback); 70 | 71 | /** 72 | * N/A 73 | */ 74 | boolean isBackwardAvailable(); 75 | 76 | /** 77 | * N/A 78 | */ 79 | boolean isCompatibilityMode(); 80 | 81 | /** 82 | * N/A 83 | */ 84 | IHandler getHandler(); 85 | } 86 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/chunks/observer/sched/BukkitScheduledChunkObserverImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.internal.chunks.observer.sched; 25 | 26 | import org.bukkit.Bukkit; 27 | import org.bukkit.World; 28 | import org.bukkit.configuration.file.FileConfiguration; 29 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.BukkitPlatformImpl; 30 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.IHandler; 31 | import ru.beykerykt.minecraft.lightapi.common.api.ResultCode; 32 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.data.IChunkData; 33 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.observer.sched.ScheduledChunkObserverImpl; 34 | import ru.beykerykt.minecraft.lightapi.common.internal.service.IBackgroundService; 35 | 36 | import java.util.ArrayList; 37 | import java.util.List; 38 | import java.util.concurrent.ScheduledFuture; 39 | import java.util.concurrent.TimeUnit; 40 | 41 | public class BukkitScheduledChunkObserverImpl extends ScheduledChunkObserverImpl { 42 | 43 | /** 44 | * CONFIG 45 | */ 46 | private final String CONFIG_TITLE = getClass().getSimpleName(); 47 | 48 | private final String CONFIG_TICK_PERIOD = CONFIG_TITLE + ".tick-period"; 49 | 50 | private final IHandler mHandler; 51 | private ScheduledFuture mScheduledFuture; 52 | 53 | public BukkitScheduledChunkObserverImpl(BukkitPlatformImpl platform, IBackgroundService service, IHandler handler) { 54 | super(platform, service); 55 | this.mHandler = handler; 56 | } 57 | 58 | private IHandler getHandler() { 59 | return mHandler; 60 | } 61 | 62 | @Override 63 | protected BukkitPlatformImpl getPlatformImpl() { 64 | return (BukkitPlatformImpl) super.getPlatformImpl(); 65 | } 66 | 67 | private void checkAndSetDefaults() { 68 | boolean needSave = false; 69 | FileConfiguration fc = getPlatformImpl().getPlugin().getConfig(); 70 | if (!fc.isSet(CONFIG_TICK_PERIOD)) { 71 | fc.set(CONFIG_TICK_PERIOD, 2); 72 | needSave = true; 73 | } 74 | 75 | if (needSave) { 76 | getPlatformImpl().getPlugin().saveConfig(); 77 | } 78 | } 79 | 80 | private void configure() { 81 | checkAndSetDefaults(); 82 | 83 | FileConfiguration fc = getPlatformImpl().getPlugin().getConfig(); 84 | int period = fc.getInt(CONFIG_TICK_PERIOD); 85 | mScheduledFuture = getBackgroundService().scheduleWithFixedDelay(this, 0, 50 * period, TimeUnit.MILLISECONDS); 86 | } 87 | 88 | @Override 89 | public void onStart() { 90 | configure(); 91 | super.onStart(); 92 | } 93 | 94 | @Override 95 | public void onShutdown() { 96 | if (mScheduledFuture != null) { 97 | mScheduledFuture.cancel(true); 98 | } 99 | super.onShutdown(); 100 | } 101 | 102 | @Override 103 | protected IChunkData createChunkData(String worldName, int chunkX, int chunkZ) { 104 | if (!getPlatformImpl().isWorldAvailable(worldName)) { 105 | return null; 106 | } 107 | return getHandler().createChunkData(worldName, chunkX, chunkZ); 108 | } 109 | 110 | @Override 111 | protected boolean isValidChunkSection(String worldName, int sectionY) { 112 | if (!getPlatformImpl().isWorldAvailable(worldName)) { 113 | return false; 114 | } 115 | World world = Bukkit.getWorld(worldName); 116 | return getHandler().isValidChunkSection(world, sectionY); 117 | } 118 | 119 | @Override 120 | protected boolean isChunkLoaded(String worldName, int chunkX, int chunkZ) { 121 | if (!getPlatformImpl().isWorldAvailable(worldName)) { 122 | return false; 123 | } 124 | World world = Bukkit.getWorld(worldName); 125 | return world.isChunkLoaded(chunkX, chunkZ); 126 | } 127 | 128 | @Override 129 | public List collectChunkSections(String worldName, int blockX, int blockY, int blockZ, int lightLevel, 130 | int lightFlags) { 131 | if (!getPlatformImpl().isWorldAvailable(worldName)) { 132 | return new ArrayList<>(); 133 | } 134 | World world = Bukkit.getWorld(worldName); 135 | return getHandler().collectChunkSections(world, blockX, blockY, blockZ, lightLevel, lightFlags); 136 | } 137 | 138 | @Override 139 | public int sendChunk(IChunkData data) { 140 | if (!getPlatformImpl().isWorldAvailable(data.getWorldName())) { 141 | return ResultCode.WORLD_NOT_AVAILABLE; 142 | } 143 | return getHandler().sendChunk(data); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/handler/IHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.internal.handler; 25 | 26 | import org.bukkit.World; 27 | import org.bukkit.event.world.WorldLoadEvent; 28 | import org.bukkit.event.world.WorldUnloadEvent; 29 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.BukkitPlatformImpl; 30 | import ru.beykerykt.minecraft.lightapi.common.internal.PlatformType; 31 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.data.IChunkData; 32 | import ru.beykerykt.minecraft.lightapi.common.internal.engine.LightEngineType; 33 | import ru.beykerykt.minecraft.lightapi.common.internal.engine.LightEngineVersion; 34 | 35 | import java.util.List; 36 | 37 | public interface IHandler { 38 | 39 | /** 40 | * N/A 41 | */ 42 | void onInitialization(BukkitPlatformImpl impl) throws Exception; 43 | 44 | /** 45 | * N/A 46 | */ 47 | void onShutdown(BukkitPlatformImpl impl); 48 | 49 | /** 50 | * Platform that is being used 51 | * 52 | * @return One of the proposed options from {@link PlatformType} 53 | */ 54 | PlatformType getPlatformType(); 55 | 56 | /** 57 | * N/A 58 | */ 59 | LightEngineType getLightEngineType(); 60 | 61 | /** 62 | * Used lighting engine version. 63 | * 64 | * @return One of the proposed options from {@link LightEngineVersion} 65 | */ 66 | LightEngineVersion getLightEngineVersion(); 67 | 68 | /** 69 | * N/A 70 | */ 71 | boolean isMainThread(); 72 | 73 | /** 74 | * N/A 75 | */ 76 | void onWorldLoad(WorldLoadEvent event); 77 | 78 | /** 79 | * N/A 80 | */ 81 | void onWorldUnload(WorldUnloadEvent event); 82 | 83 | /** 84 | * N/A 85 | */ 86 | boolean isLightingSupported(World world, int lightFlags); 87 | 88 | /** 89 | * Sets "directly" the level of light in given coordinates without additional processing. 90 | */ 91 | int setRawLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags); 92 | 93 | /** 94 | * Gets "directly" the level of light from given coordinates without additional processing. 95 | */ 96 | int getRawLightLevel(World world, int blockX, int blockY, int blockZ, int lightFlags); 97 | 98 | /** 99 | * Performs re-illumination of the light in the given coordinates. 100 | */ 101 | int recalculateLighting(World world, int blockX, int blockY, int blockZ, int lightFlags); 102 | 103 | /** 104 | * N/A 105 | */ 106 | IChunkData createChunkData(String worldName, int chunkX, int chunkZ); 107 | 108 | /** 109 | * Collects modified сhunks with sections around a given coordinate in the radius of the light 110 | * level. The light level is taken from the arguments. 111 | * 112 | * @return List changed chunk sections around the given coordinate. 113 | */ 114 | List collectChunkSections(World world, int blockX, int blockY, int blockZ, int lightLevel, 115 | int lightFlags); 116 | 117 | /** 118 | * N/A 119 | */ 120 | boolean isValidChunkSection(World world, int sectionY); 121 | 122 | /** 123 | * N/A 124 | */ 125 | int sendChunk(IChunkData data); 126 | 127 | /** 128 | * Can be used for specific commands 129 | */ 130 | int sendCmd(int cmdId, Object... args); 131 | } 132 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/handler/IHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.internal.handler; 25 | 26 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.BukkitPlatformImpl; 27 | 28 | public interface IHandlerFactory { 29 | 30 | /** 31 | * N/A 32 | */ 33 | IHandler createHandler(BukkitPlatformImpl impl) throws Exception; 34 | } 35 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/handler/craftbukkit/HandlerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.craftbukkit; 25 | 26 | import org.apache.commons.lang.NotImplementedException; 27 | import org.bukkit.Bukkit; 28 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.BukkitPlatformImpl; 29 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.IHandler; 30 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.IHandlerFactory; 31 | 32 | public class HandlerFactory implements IHandlerFactory { 33 | 34 | private static final String CRAFTBUKKIT_PKG = "org.bukkit.craftbukkit"; 35 | private static final String[] STARLIGHT_ENGINE_PKG = { 36 | "ca.spottedleaf.starlight.light.StarLightEngine", 37 | "ca.spottedleaf.starlight.common.light.StarLightEngine" 38 | }; 39 | private BukkitPlatformImpl mPlatformImpl; 40 | 41 | private BukkitPlatformImpl getPlatformImpl() { 42 | return mPlatformImpl; 43 | } 44 | 45 | private boolean isStarlight() { 46 | for (String pkg : STARLIGHT_ENGINE_PKG) { 47 | try { 48 | Class.forName(pkg); 49 | try { 50 | Class.forName("io.papermc.paper.chunk.system.ChunkSystem"); 51 | getPlatformImpl().debug("Found Class" + pkg + ", Start using Starlight with RewriteChunkSystem."); 52 | return true; 53 | } catch (ClassNotFoundException ignored) { 54 | } 55 | try { 56 | Class.forName("ca.spottedleaf.starlight.Starlight"); 57 | getPlatformImpl().debug("Found Class" + pkg + ", Start using Starlight with Mod."); 58 | return true; 59 | } catch (ClassNotFoundException ignored) { 60 | } 61 | getPlatformImpl().debug("Found Class" + pkg + ", Start using Starlight."); 62 | return true; 63 | } catch (ClassNotFoundException e) { 64 | getPlatformImpl().debug("Class " + pkg + " not found"); 65 | } 66 | } 67 | return false; 68 | } 69 | 70 | @Override 71 | public IHandler createHandler(BukkitPlatformImpl impl) throws Exception { 72 | this.mPlatformImpl = impl; 73 | IHandler handler = null; 74 | String serverImplPackage = Bukkit.getServer().getClass().getPackage().getName(); 75 | 76 | if (serverImplPackage.startsWith(CRAFTBUKKIT_PKG)) { // make sure it's craftbukkit 77 | String[] line = serverImplPackage.replace(".", ",").split(","); 78 | String version = line[3]; 79 | 80 | String handlerClassName = (isStarlight() ? "Starlight" : "Vanilla") + "NMSHandler"; 81 | String handlerPath = getClass().getPackage().getName() + ".nms." + version + "." + handlerClassName; 82 | // start using nms handler 83 | handler = (IHandler) Class.forName(handlerPath).getConstructor().newInstance(); 84 | } else { // something else 85 | throw new NotImplementedException(Bukkit.getName() + " is currently not supported."); 86 | } 87 | return handler; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/handler/craftbukkit/nms/BaseNMSHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.craftbukkit.nms; 25 | 26 | import org.bukkit.Bukkit; 27 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.BukkitPlatformImpl; 28 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.IHandler; 29 | import ru.beykerykt.minecraft.lightapi.common.internal.PlatformType; 30 | 31 | public abstract class BaseNMSHandler implements IHandler { 32 | 33 | private BukkitPlatformImpl mPlatformImpl; 34 | 35 | protected RuntimeException toRuntimeException(Throwable e) { 36 | if (e instanceof RuntimeException) { 37 | return (RuntimeException) e; 38 | } 39 | Class cls = e.getClass(); 40 | return new RuntimeException(String.format("(%s) %s", 41 | RuntimeException.class.getPackage().equals(cls.getPackage()) ? cls.getSimpleName() : cls.getName(), 42 | e.getMessage()), e); 43 | } 44 | 45 | @Override 46 | public void onInitialization(BukkitPlatformImpl impl) throws Exception { 47 | this.mPlatformImpl = impl; 48 | } 49 | 50 | protected BukkitPlatformImpl getPlatformImpl() { 51 | return mPlatformImpl; 52 | } 53 | 54 | @Override 55 | public PlatformType getPlatformType() { 56 | return PlatformType.CRAFTBUKKIT; 57 | } 58 | 59 | @Override 60 | public boolean isMainThread() { 61 | return Bukkit.isPrimaryThread(); 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/service/BukkitBackgroundServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.internal.service; 25 | 26 | import com.google.common.util.concurrent.ThreadFactoryBuilder; 27 | import org.bukkit.configuration.file.FileConfiguration; 28 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.BukkitPlatformImpl; 29 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.IHandler; 30 | import ru.beykerykt.minecraft.lightapi.common.internal.service.BackgroundServiceImpl; 31 | 32 | import java.util.concurrent.ThreadFactory; 33 | 34 | public class BukkitBackgroundServiceImpl extends BackgroundServiceImpl { 35 | 36 | /** 37 | * CONFIG 38 | */ 39 | private final String CONFIG_TITLE = getClass().getSimpleName(); 40 | 41 | @Deprecated 42 | private final String CONFIG_TICK_PERIOD = CONFIG_TITLE + ".tick-period"; 43 | private final String CONFIG_CORE_POOL_SIZE = CONFIG_TITLE + ".corePoolSize"; 44 | 45 | private final IHandler mHandler; 46 | private int taskId = -1; 47 | private long lastAliveTime = 0; 48 | 49 | public BukkitBackgroundServiceImpl(BukkitPlatformImpl platform, IHandler handler) { 50 | super(platform); 51 | mHandler = handler; 52 | } 53 | 54 | @Override 55 | protected BukkitPlatformImpl getPlatformImpl() { 56 | return (BukkitPlatformImpl) super.getPlatformImpl(); 57 | } 58 | 59 | private IHandler getHandler() { 60 | return mHandler; 61 | } 62 | 63 | private boolean upgradeConfig() { 64 | boolean needSave = false; 65 | FileConfiguration fc = getPlatformImpl().getPlugin().getConfig(); 66 | if (fc.isSet(CONFIG_TICK_PERIOD)) { 67 | fc.set(CONFIG_TICK_PERIOD, null); 68 | needSave = true; 69 | } 70 | return needSave; 71 | } 72 | 73 | private void checkAndSetDefaults() { 74 | boolean needSave = upgradeConfig(); 75 | FileConfiguration fc = getPlatformImpl().getPlugin().getConfig(); 76 | 77 | if (!fc.isSet(CONFIG_CORE_POOL_SIZE)) { 78 | fc.set(CONFIG_CORE_POOL_SIZE, 1); 79 | needSave = true; 80 | } 81 | 82 | if (needSave) { 83 | getPlatformImpl().getPlugin().saveConfig(); 84 | } 85 | } 86 | 87 | @Override 88 | public void onStart() { 89 | checkAndSetDefaults(); 90 | 91 | // executor service 92 | ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat( 93 | "lightapi-background-thread-%d").build(); 94 | FileConfiguration fc = getPlatformImpl().getPlugin().getConfig(); 95 | int corePoolSize = fc.getInt(CONFIG_CORE_POOL_SIZE); 96 | configureExecutorService(corePoolSize, namedThreadFactory); 97 | 98 | // heartbeat 99 | taskId = getPlatformImpl().getPlugin().getServer().getScheduler().runTaskTimer(getPlatformImpl().getPlugin(), 100 | () -> lastAliveTime = System.currentTimeMillis(), 0, 1).getTaskId(); 101 | } 102 | 103 | @Override 104 | public void onShutdown() { 105 | if (taskId != -1) { 106 | getPlatformImpl().getPlugin().getServer().getScheduler().cancelTask(taskId); 107 | } 108 | super.onShutdown(); 109 | } 110 | 111 | @Override 112 | public boolean canExecuteSync(long maxTime) { 113 | return ((System.currentTimeMillis() - lastAliveTime) < maxTime); 114 | } 115 | 116 | @Override 117 | public boolean isMainThread() { 118 | return getHandler().isMainThread(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/utils/UsageTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.internal.utils; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.LightAPI; 27 | import ru.beykerykt.minecraft.lightapi.common.api.ResultCode; 28 | import ru.beykerykt.minecraft.lightapi.common.api.engine.EditPolicy; 29 | import ru.beykerykt.minecraft.lightapi.common.api.engine.LightFlag; 30 | import ru.beykerykt.minecraft.lightapi.common.api.engine.SendPolicy; 31 | import ru.beykerykt.minecraft.lightapi.common.api.engine.sched.ICallback; 32 | import ru.beykerykt.minecraft.lightapi.common.internal.engine.sched.RequestFlag; 33 | 34 | public class UsageTest { 35 | 36 | private void setLightLevel(String world, int blockX, int blockY, int blockZ, int lightLevel) { 37 | int lightTypeFlags = LightFlag.BLOCK_LIGHTING; 38 | int oldBlockLight = LightAPI.get().getLightLevel(world, blockX, blockY, blockZ, lightTypeFlags); 39 | EditPolicy editPolicy = EditPolicy.DEFERRED; 40 | SendPolicy sendPolicy = SendPolicy.DEFERRED; 41 | LightAPI.get().setLightLevel(world, blockX, blockY, blockZ, lightLevel, lightTypeFlags, editPolicy, sendPolicy, 42 | new ICallback() { 43 | @Override 44 | public void onResult(int requestFlag, int resultCode) { 45 | switch (requestFlag) { 46 | case RequestFlag.EDIT: 47 | if (resultCode == ResultCode.SUCCESS) { 48 | System.out.println("Light level was edited."); 49 | } else { 50 | System.out.println("request (" + requestFlag + "): result code " + resultCode); 51 | } 52 | break; 53 | case RequestFlag.RECALCULATE: 54 | if (resultCode == ResultCode.SUCCESS) { 55 | int newBlockLight = LightAPI.get().getLightLevel(world, blockX, blockY, blockZ, 56 | lightTypeFlags); 57 | if (oldBlockLight != newBlockLight) { 58 | System.out.println("Light level was recalculated."); 59 | } else { 60 | System.out.println("Light level was not recalculated."); 61 | } 62 | } else { 63 | System.out.println("request (" + requestFlag + "): result code " + resultCode); 64 | } 65 | break; 66 | case RequestFlag.SEPARATE_SEND: 67 | System.out.println("request (" + requestFlag + "): result code " + resultCode); 68 | break; 69 | } 70 | } 71 | }); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/utils/VersionUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Qveshn 5 | * Copyright 2021 Vladimir Mikhailov 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 all 15 | * 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 THE 23 | * SOFTWARE. 24 | */ 25 | package ru.beykerykt.minecraft.lightapi.bukkit.internal.utils; 26 | 27 | import org.bukkit.Bukkit; 28 | 29 | import java.util.regex.Matcher; 30 | import java.util.regex.Pattern; 31 | 32 | public class VersionUtil { 33 | 34 | public static String serverVersion() { 35 | return Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3]; 36 | } 37 | 38 | public static String serverName() { 39 | return Bukkit.getVersion().split("-")[1]; 40 | } 41 | 42 | public static String bukkitName() { 43 | return Bukkit.getName(); 44 | } 45 | 46 | public static String bukkitVersion() { 47 | return (Bukkit.getBukkitVersion() + "-").split("-")[0]; 48 | } 49 | 50 | private static String paddedVersion(String value) { 51 | return VersionUtil.leftPad(value, "\\d+", '0', 8); 52 | } 53 | 54 | private static String paddedBukkitVersion() { 55 | return paddedVersion(bukkitVersion()); 56 | } 57 | 58 | public static int compareBukkitVersionTo(String version) { 59 | return paddedBukkitVersion().compareTo(paddedVersion(version)); 60 | } 61 | 62 | private static String leftPad(String text, String regex, char padCharacter, int width) { 63 | StringBuilder sb = new StringBuilder(); 64 | Matcher m = Pattern.compile(regex).matcher(text); 65 | String chars = String.format("%" + width + "s", "").replace(' ', padCharacter); 66 | int last = 0; 67 | while (m.find()) { 68 | int start = m.start(); 69 | int n = m.end() - start; 70 | if (n < width) { 71 | sb.append(text, last, start); 72 | sb.append(chars, n, width); 73 | last = start; 74 | } 75 | } 76 | if (last == 0) { 77 | return text; 78 | } 79 | if (last < text.length()) { 80 | sb.append(text, last, text.length()); 81 | } 82 | return sb.toString(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /bukkit-common/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: LightAPI 2 | main: ru.beykerykt.minecraft.lightapi.bukkit.BukkitPlugin 3 | version: ${version} 4 | description: Bukkit library for edit light levels 5 | api-version: 1.14 6 | author: BeYkeRYkt 7 | authors: [ other contributors in GitHub ] 8 | website: https://github.com/BeYkeRYkt/LightAPI 9 | commands: 10 | lightapi: 11 | description: Main command 12 | permissions: 13 | lightapi.debug: 14 | default: false -------------------------------------------------------------------------------- /bukkit-common/src/main/resources/storage.yml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IPECTER/LighterAPI/4b398ac2e4a0a69ac30456986a020f13b7060152/bukkit-common/src/main/resources/storage.yml -------------------------------------------------------------------------------- /bukkit-example/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly project(':common') 4 | compileOnly 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT' 5 | } 6 | 7 | description = 'lightapi-bukkit-example' 8 | -------------------------------------------------------------------------------- /bukkit-example/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/example/ChunkUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.bukkit.example; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.data.IChunkData; 27 | 28 | import java.util.ArrayList; 29 | import java.util.Iterator; 30 | import java.util.List; 31 | 32 | public class ChunkUtils { 33 | 34 | public static List mergeChunks(List input) { 35 | List output = new ArrayList<>(); 36 | Iterator it = input.iterator(); 37 | while (it.hasNext()) { 38 | IChunkData data = it.next(); 39 | Iterator itc = output.iterator(); 40 | boolean found = false; 41 | while (itc.hasNext()) { 42 | IChunkData data_c = itc.next(); 43 | if (data_c.getWorldName().equals(data.getWorldName()) && data_c.getChunkX() == data.getChunkX() 44 | && data_c.getChunkZ() == data.getChunkZ()) { 45 | // data_c.addSectionMaskBlock(data.getSectionMaskBlock()); 46 | // data_c.addSectionMaskSky(data.getSectionMaskSky()); 47 | found = true; 48 | break; 49 | } 50 | } 51 | if (!found) { 52 | output.add(data); 53 | } 54 | } 55 | return output; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /bukkit-example/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: LightTest 2 | main: ru.beykerykt.minecraft.lightapi.bukkit.example.BukkitPlugin 3 | version: ${SERVER_API}-${project.version} (build ${BUILD_NUMBER}) 4 | description: Test plugin for LightAPI 5 | api-version: 1.13 6 | depend: [ LightAPI ] 7 | author: BeYkeRYkt 8 | authors: [ other contributors in GitHub ] 9 | website: https://github.com/BeYkeRYkt/LightAPI 10 | commands: 11 | lighttest: 12 | description: Main command -------------------------------------------------------------------------------- /bukkit-nms/v1_13_R2/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly 'org.spigotmc:spigot:1.13.2-R0.1-SNAPSHOT' 4 | } 5 | 6 | description = 'lightapi-craftbukkit-nms-v1_13_R2' 7 | -------------------------------------------------------------------------------- /bukkit-nms/v1_14_R1/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly 'org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT' 4 | } 5 | 6 | description = 'lightapi-craftbukkit-nms-v1_14_R1' 7 | -------------------------------------------------------------------------------- /bukkit-nms/v1_15_R1/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly 'org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT' 4 | } 5 | 6 | description = 'lightapi-craftbukkit-nms-v1_15_R1' 7 | -------------------------------------------------------------------------------- /bukkit-nms/v1_16_R1/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly 'org.spigotmc:spigot:1.16.1-R0.1-SNAPSHOT' 4 | } 5 | 6 | description = 'lightapi-craftbukkit-nms-v1_16_R1' 7 | -------------------------------------------------------------------------------- /bukkit-nms/v1_16_R2/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly 'org.spigotmc:spigot:1.16.2-R0.1-SNAPSHOT' 4 | } 5 | 6 | description = 'lightapi-craftbukkit-nms-v1_16_R2' 7 | -------------------------------------------------------------------------------- /bukkit-nms/v1_16_R3/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly project(':common') 4 | compileOnly 'org.spigotmc:spigot:1.16.5-R0.1-SNAPSHOT' 5 | } 6 | 7 | description = 'lightapi-craftbukkit-nms-v1_16_R3' 8 | -------------------------------------------------------------------------------- /bukkit-nms/v1_17_R1/build.gradle: -------------------------------------------------------------------------------- 1 | dependencies { 2 | compileOnly project(':bukkit-common') 3 | compileOnly 'io.papermc.paper:paper:1.17.1-R0.1-SNAPSHOT' 4 | } 5 | 6 | description = 'lightapi-craftbukkit-nms-v1_17_R1' 7 | -------------------------------------------------------------------------------- /bukkit-nms/v1_18_R1/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'io.papermc.paperweight.userdev' version "1.5.3" 4 | } 5 | 6 | java { toolchain.languageVersion.set(JavaLanguageVersion.of(17)) } 7 | dependencies { 8 | compileOnly project(':bukkit-common') 9 | paperweight.paperDevBundle("1.18.1-R0.1-SNAPSHOT") 10 | } 11 | 12 | description = 'lightapi-craftbukkit-nms-v1_18_R1' 13 | -------------------------------------------------------------------------------- /bukkit-nms/v1_18_R2/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'io.papermc.paperweight.userdev' version "1.5.3" 4 | } 5 | 6 | java { toolchain.languageVersion.set(JavaLanguageVersion.of(17)) } 7 | dependencies { 8 | compileOnly project(':bukkit-common') 9 | paperweight.paperDevBundle("1.18.2-R0.1-SNAPSHOT") 10 | } 11 | 12 | description = 'lightapi-craftbukkit-nms-v1_18_R2' 13 | -------------------------------------------------------------------------------- /bukkit-nms/v1_19_R1/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'io.papermc.paperweight.userdev' version "1.5.3" 4 | } 5 | 6 | java { toolchain.languageVersion.set(JavaLanguageVersion.of(17)) } 7 | dependencies { 8 | compileOnly project(':bukkit-common') 9 | paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT") 10 | } 11 | 12 | description = 'lightapi-craftbukkit-nms-v1_19_R1' 13 | -------------------------------------------------------------------------------- /bukkit-nms/v1_19_R2/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'io.papermc.paperweight.userdev' version "1.5.3" 4 | } 5 | 6 | java { toolchain.languageVersion.set(JavaLanguageVersion.of(17)) } 7 | dependencies { 8 | compileOnly project(':bukkit-common') 9 | paperweight.paperDevBundle("1.19.3-R0.1-SNAPSHOT") 10 | } 11 | 12 | description = 'lightapi-craftbukkit-nms-v1_19_R2' 13 | -------------------------------------------------------------------------------- /bukkit-nms/v1_19_R3/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'io.papermc.paperweight.userdev' version "1.5.3" 4 | } 5 | 6 | java { toolchain.languageVersion.set(JavaLanguageVersion.of(17)) } 7 | dependencies { 8 | compileOnly project(':bukkit-common') 9 | paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT") 10 | } 11 | 12 | description = 'lightapi-craftbukkit-nms-v1_19_R3' 13 | -------------------------------------------------------------------------------- /common/build.gradle: -------------------------------------------------------------------------------- 1 | description = 'common' 2 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/Build.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.internal.PlatformType; 27 | 28 | /** 29 | * Information about the current LightAPI build 30 | */ 31 | public class Build { 32 | 33 | /** 34 | * ONLY FOR PREVIEW BUILD 35 | */ 36 | @Deprecated 37 | public static final int PREVIEW = 0; 38 | 39 | /** 40 | * Public version for users. May change during any changes in the API. The string should change 41 | * when common 'api' package is changed in from release to release. 42 | */ 43 | public static final int API_VERSION = 1; 44 | 45 | /** 46 | * {@link Build#API_VERSION} 47 | */ 48 | @Deprecated 49 | public static final int CURRENT_VERSION = API_VERSION; 50 | 51 | /** 52 | * Internal version. May change during any changes in the API. The string should change when 53 | * common 'internal' package is changed from release to release. 54 | */ 55 | public static final int INTERNAL_VERSION = 4; 56 | /** 57 | * Platform that is being used. 58 | */ 59 | public static PlatformType CURRENT_IMPLEMENTATION = LightAPI.get().getPlatformType(); 60 | } 61 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/IChunkData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package ru.beykerykt.minecraft.lightapi.common; 26 | 27 | @Deprecated 28 | public interface IChunkData { 29 | 30 | /** 31 | * @return World name 32 | */ 33 | String getWorldName(); 34 | 35 | /** 36 | * @return Chunk X Coordinate 37 | */ 38 | int getChunkX(); 39 | 40 | /** 41 | * @return Chunk Z Coordinate 42 | */ 43 | int getChunkZ(); 44 | } -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/LCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package ru.beykerykt.minecraft.lightapi.common; 26 | 27 | @Deprecated 28 | public interface LCallback { 29 | 30 | /** 31 | * Called after successful execution. 32 | * 33 | * @param worldName - World name 34 | * @param type - Light type 35 | * @param blockX - Block X coordinate 36 | * @param blockY - Block Y coordinate 37 | * @param blockZ - Block Z coordinate 38 | * @param lightlevel - light level. Default range - 0 - 15 39 | */ 40 | void onSuccess(String worldName, LightType type, int blockX, int blockY, int blockZ, int lightlevel, LStage stage); 41 | 42 | /** 43 | * Called if something went wrong during execution. 44 | * 45 | * @param worldName - World name 46 | * @param type - Light type 47 | * @param blockX - Block X coordinate 48 | * @param blockY - Block Y coordinate 49 | * @param blockZ - Block Z coordinate 50 | * @param reason - Reason 51 | */ 52 | void onFailed(String worldName, LightType type, int blockX, int blockY, int blockZ, int lightlevel, LStage stage, 53 | LReason reason); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/LReason.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package ru.beykerykt.minecraft.lightapi.common; 26 | 27 | @Deprecated 28 | public enum LReason { 29 | /** 30 | * N/A 31 | */ 32 | UNKNOWN(0), 33 | 34 | /** 35 | * N/A 36 | */ 37 | NO_LIGHT_CHANGES(1), 38 | 39 | /** 40 | * N/A 41 | */ 42 | THREADEDMAILBOX_IS_WORKING(2), 43 | 44 | /** 45 | * N/A 46 | */ 47 | THROW_EXCEPTION(3), 48 | 49 | /** 50 | * N/A 51 | */ 52 | NULL_ARGS(4); 53 | 54 | private final int id; 55 | 56 | LReason(int id) { 57 | this.id = id; 58 | } 59 | 60 | public int getId() { 61 | return id; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/LStage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package ru.beykerykt.minecraft.lightapi.common; 26 | 27 | @Deprecated 28 | public enum LStage { 29 | /** 30 | * Called from setRawLightLevel(). 31 | */ 32 | WRITTING(0), 33 | 34 | /** 35 | * Called from recalculateLighting(). 36 | */ 37 | RECALCULATING(1), 38 | 39 | /** 40 | * Called from createLight(). 41 | */ 42 | CREATING(2), 43 | 44 | /** 45 | * Called from deleteLight(). 46 | */ 47 | DELETING(3); 48 | 49 | private final int id; 50 | 51 | LStage(int id) { 52 | this.id = id; 53 | } 54 | 55 | public int getId() { 56 | return id; 57 | } 58 | } -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/LightType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package ru.beykerykt.minecraft.lightapi.common; 26 | 27 | @Deprecated 28 | public enum LightType { 29 | 30 | /** 31 | * Light emanates from the block (torch, glowstone, etc.) 32 | */ 33 | BLOCK(0), 34 | 35 | /** 36 | * N/A 37 | */ 38 | SKY(1); 39 | 40 | private final int id; 41 | 42 | LightType(int id) { 43 | this.id = id; 44 | } 45 | 46 | public int getId() { 47 | return id; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/api/ResultCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.api; 25 | 26 | /** 27 | * Result codes 28 | */ 29 | public class ResultCode { 30 | 31 | /** 32 | * N/A 33 | */ 34 | public static final int MOVED_TO_DEFERRED = 1; 35 | 36 | /** 37 | * The task has been successfully completed 38 | */ 39 | public static final int SUCCESS = 0; 40 | 41 | /** 42 | * The task has been failed 43 | */ 44 | public static final int FAILED = -1; 45 | 46 | /** 47 | * Current world is not available 48 | */ 49 | public static final int WORLD_NOT_AVAILABLE = -2; 50 | 51 | /** 52 | * (1.14+) No lighting changes in current world 53 | */ 54 | public static final int RECALCULATE_NO_CHANGES = -3; 55 | 56 | /** 57 | * (1.14+) SkyLight data is not available in current world 58 | */ 59 | public static final int SKYLIGHT_DATA_NOT_AVAILABLE = -4; 60 | 61 | /** 62 | * (1.14+) BlockLight data is not available in current world 63 | */ 64 | public static final int BLOCKLIGHT_DATA_NOT_AVAILABLE = -5; 65 | 66 | /** 67 | * Current function is not implemented 68 | */ 69 | public static final int NOT_IMPLEMENTED = -6; 70 | 71 | /** 72 | * Chunk is not loaded 73 | */ 74 | public static final int CHUNK_NOT_LOADED = -7; 75 | } 76 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/api/engine/EditPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.api.engine; 25 | 26 | public enum EditPolicy { 27 | 28 | /** 29 | * Changes are made immediately, regardless of the state of the server. It can cause the server to 30 | * freeze with a large number of requests. 31 | */ 32 | FORCE_IMMEDIATE(0), 33 | 34 | /** 35 | * Changes are made immediately depending on the state of the server. If the server cannot perform 36 | * this task right now, then the policy changes to {@link EditPolicy#DEFERRED}. It can cause a 37 | * drop in the TPS server with a large number of requests. 38 | */ 39 | IMMEDIATE(1), 40 | 41 | /** 42 | * The change request is added to the queue. The result will be available after a while. 43 | */ 44 | DEFERRED(2); 45 | 46 | private final int id; 47 | 48 | EditPolicy(int id) { 49 | this.id = id; 50 | } 51 | 52 | public int getId() { 53 | return id; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/api/engine/LightFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.api.engine; 25 | 26 | public class LightFlag { 27 | 28 | /** 29 | * N/A 30 | */ 31 | public static final int NONE = 0; 32 | 33 | /** 34 | * A flag for editing block light layer 35 | */ 36 | public static final int BLOCK_LIGHTING = 1; 37 | 38 | /** 39 | * A flag for editing sky light layer 40 | */ 41 | public static final int SKY_LIGHTING = 2; 42 | 43 | /** 44 | * A flag for storing the light level in the storage provider 45 | */ 46 | @Deprecated 47 | public static final int USE_STORAGE_PROVIDER = 4; 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/api/engine/LightType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.api.engine; 25 | 26 | @Deprecated 27 | public class LightType { 28 | 29 | /** 30 | * N/A 31 | */ 32 | public static final int NONE = LightFlag.NONE; 33 | 34 | /** 35 | * Light from the blocks (torch, glowstone, etc.) 36 | */ 37 | public static final int BLOCK_LIGHTING = LightFlag.BLOCK_LIGHTING; 38 | 39 | /** 40 | * Light from sky 41 | */ 42 | public static final int SKY_LIGHTING = LightFlag.SKY_LIGHTING; 43 | } -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/api/engine/RelightPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.api.engine; 25 | 26 | public enum RelightPolicy { 27 | 28 | /** 29 | * Recalculation of world lighting occurs immediately after the change 30 | *

31 | * - EDIT_LIGHT_LEVEL 32 | * - RECALCULATE 33 | * - EDIT_LIGHT_LEVEL 34 | * - RECALCULATE 35 | * - ... 36 | */ 37 | FORWARD(1), 38 | 39 | /** 40 | * Recalculation of world lighting occurs after edit changes 41 | *

42 | * - 1'st EDIT_LIGHT_LEVEL 43 | * - 2'st EDIT_LIGHT_LEVEL 44 | * - 3'st EDIT_LIGHT_LEVEL 45 | * - RECALCULATE 46 | * - ... 47 | */ 48 | DEFERRED(2); 49 | 50 | private final int id; 51 | 52 | RelightPolicy(int id) { 53 | this.id = id; 54 | } 55 | 56 | public int getId() { 57 | return id; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/api/engine/SendPolicy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.api.engine; 25 | 26 | public enum SendPolicy { 27 | 28 | /** 29 | * Updated chunks are collected in a local pool after the light level changes, but are not 30 | * automatically sent. 31 | */ 32 | @Deprecated 33 | MANUAL(0), 34 | 35 | /** 36 | * Updated chunks are immediately collected and sent to players after the light level changes. 37 | */ 38 | IMMEDIATE(1), 39 | 40 | /** 41 | * Updated chunks are collected in a common pool after the light level changes. Then they are 42 | * automatically sent to players at regular intervals. 43 | */ 44 | DEFERRED(2), 45 | 46 | /** 47 | * Chunks are not collected after the changes are applied. 48 | */ 49 | IGNORE(3); 50 | 51 | private final int id; 52 | 53 | SendPolicy(int id) { 54 | this.id = id; 55 | } 56 | 57 | public int getId() { 58 | return id; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/api/engine/sched/ICallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.api.engine.sched; 25 | 26 | /** 27 | * Callback interface for async light engine operations 28 | */ 29 | public interface ICallback { 30 | 31 | /** 32 | * N/A 33 | */ 34 | void onResult(int requestFlag, int resultCode); 35 | } 36 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/api/extension/IExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.api.extension; 25 | 26 | /** 27 | * Extends class to expand platform-specific functions 28 | */ 29 | public interface IExtension { 30 | } 31 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/IPlatformImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.api.extension.IExtension; 27 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.observer.IChunkObserver; 28 | import ru.beykerykt.minecraft.lightapi.common.internal.engine.ILightEngine; 29 | import ru.beykerykt.minecraft.lightapi.common.internal.service.IBackgroundService; 30 | 31 | import java.util.UUID; 32 | 33 | public interface IPlatformImpl { 34 | 35 | /** 36 | * N/A 37 | */ 38 | int prepare(); 39 | 40 | /** 41 | * N/A 42 | */ 43 | int initialization(); 44 | 45 | /** 46 | * N/A 47 | */ 48 | void shutdown(); 49 | 50 | /** 51 | * N/A 52 | */ 53 | boolean isInitialized(); 54 | 55 | /** 56 | * Log message in console 57 | * 58 | * @param msg - message 59 | */ 60 | void log(String msg); 61 | 62 | /** 63 | * Info message in console 64 | * 65 | * @param msg - message 66 | */ 67 | void info(String msg); 68 | 69 | /** 70 | * Debug message in console 71 | * 72 | * @param msg - message 73 | */ 74 | void debug(String msg); 75 | 76 | /** 77 | * Error message in console 78 | * 79 | * @param msg - message 80 | */ 81 | void error(String msg); 82 | 83 | /** 84 | * N/A 85 | */ 86 | UUID getUUID(); 87 | 88 | /** 89 | * Platform that is being used 90 | * 91 | * @return One of the proposed options from {@link PlatformType} 92 | */ 93 | PlatformType getPlatformType(); 94 | 95 | /** 96 | * N/A 97 | */ 98 | ILightEngine getLightEngine(); 99 | 100 | /** 101 | * N/A 102 | */ 103 | IChunkObserver getChunkObserver(); 104 | 105 | /** 106 | * N/A 107 | */ 108 | IBackgroundService getBackgroundService(); 109 | 110 | /** 111 | * N/A 112 | */ 113 | IExtension getExtension(); 114 | 115 | /** 116 | * N/A 117 | */ 118 | boolean isWorldAvailable(String worldName); 119 | 120 | /** 121 | * Can be used for specific commands 122 | */ 123 | int sendCmd(int cmdId, Object... args); 124 | } 125 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/InternalCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal; 25 | 26 | public class InternalCode { 27 | 28 | /** 29 | * N/A 30 | */ 31 | public static final int UPDATE_UUID = 5; 32 | 33 | public static int RESERVED_LENGTH = 1000; 34 | } 35 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/PlatformType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal; 25 | 26 | /** 27 | * Supported Platforms 28 | * 29 | * @author BeYkeRYkt 30 | */ 31 | public enum PlatformType { 32 | 33 | /** 34 | * UNKNOWN 35 | */ 36 | UNKNOWN(0), 37 | 38 | /** 39 | * Platforms built on the Bukkit API. The implication is that pure Bukkit API is used without NMS 40 | * and other implementations. 41 | */ 42 | BUKKIT(1), 43 | 44 | /** 45 | * Platforms built on CraftBukkit. Spigot, Paper and etc 46 | */ 47 | CRAFTBUKKIT(2), 48 | 49 | /** 50 | * Platforms built on SpongePowered. 51 | */ 52 | @Deprecated SPONGE(3); 53 | 54 | // TODO 55 | // GLOWSTONE(4) 56 | 57 | private final int id; 58 | 59 | PlatformType(int id) { 60 | this.id = id; 61 | } 62 | 63 | public int getId() { 64 | return id; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/chunks/data/BitChunkData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.chunks.data; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.api.engine.LightFlag; 27 | import ru.beykerykt.minecraft.lightapi.common.internal.utils.FlagUtils; 28 | 29 | import java.util.BitSet; 30 | 31 | /** 32 | * ChunkData with BitSet data 33 | */ 34 | public class BitChunkData extends ChunkData { 35 | 36 | private static final int DEFAULT_SIZE = 2048; 37 | private final BitSet skyLightUpdateBits; 38 | private final BitSet blockLightUpdateBits; 39 | 40 | private final int topSection; 41 | private final int bottomSection; 42 | 43 | public BitChunkData(String worldName, int chunkX, int chunkZ, int topSection, int bottomSection) { 44 | super(worldName, chunkX, chunkZ); 45 | this.skyLightUpdateBits = new BitSet(DEFAULT_SIZE); 46 | this.blockLightUpdateBits = new BitSet(DEFAULT_SIZE); 47 | this.topSection = topSection; 48 | this.bottomSection = bottomSection; 49 | } 50 | 51 | public BitSet getSkyLightUpdateBits() { 52 | return skyLightUpdateBits; 53 | } 54 | 55 | public BitSet getBlockLightUpdateBits() { 56 | return blockLightUpdateBits; 57 | } 58 | 59 | /** 60 | * Max chunk section 61 | */ 62 | // getHeight() - this.world.countVerticalSections() + 2; 63 | // getTopY() - this.getBottomY() + this.getHeight(); 64 | public int getTopSection() { 65 | return topSection; 66 | } 67 | 68 | /** 69 | * Min chunk section 70 | */ 71 | // getBottomY() - this.world.getBottomSectionCoord() - 1 72 | public int getBottomSection() { 73 | return bottomSection; 74 | } 75 | 76 | @Override 77 | public void markSectionForUpdate(int lightFlags, int sectionY) { 78 | int minY = getBottomSection(); 79 | int maxY = getTopSection(); 80 | if (sectionY < minY || sectionY > maxY) { 81 | return; 82 | } 83 | int l = sectionY - minY; 84 | 85 | if (FlagUtils.isFlagSet(lightFlags, LightFlag.SKY_LIGHTING)) { 86 | skyLightUpdateBits.set(l); 87 | } 88 | 89 | if (FlagUtils.isFlagSet(lightFlags, LightFlag.BLOCK_LIGHTING)) { 90 | blockLightUpdateBits.set(l); 91 | } 92 | } 93 | 94 | @Override 95 | public void clearUpdate() { 96 | this.skyLightUpdateBits.clear(); 97 | this.blockLightUpdateBits.clear(); 98 | } 99 | 100 | @Override 101 | public void setFullSections() { 102 | // TODO: Mark full sections 103 | for (int i = getBottomSection(); i < getTopSection(); i++) { 104 | markSectionForUpdate(LightFlag.SKY_LIGHTING | LightFlag.BLOCK_LIGHTING, i); 105 | } 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return "BitChunkData{" + "worldName=" + getWorldName() + ", chunkX=" + getChunkX() + ", chunkZ=" + getChunkZ() 111 | + ", skyLightUpdateBits=" + skyLightUpdateBits + ", blockLightUpdateBits=" + blockLightUpdateBits + '}'; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/chunks/data/ChunkData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.chunks.data; 25 | 26 | import java.util.Objects; 27 | 28 | public abstract class ChunkData implements IChunkData { 29 | 30 | private final String worldName; 31 | private int chunkX; 32 | private int chunkZ; 33 | 34 | public ChunkData(String worldName, int chunkX, int chunkZ) { 35 | this.worldName = worldName; 36 | this.chunkX = chunkX; 37 | this.chunkZ = chunkZ; 38 | } 39 | 40 | @Override 41 | public String getWorldName() { 42 | return worldName; 43 | } 44 | 45 | @Override 46 | public int getChunkX() { 47 | return chunkX; 48 | } 49 | 50 | @Override 51 | public int getChunkZ() { 52 | return chunkZ; 53 | } 54 | 55 | @Override 56 | public boolean equals(Object o) { 57 | if (this == o) { 58 | return true; 59 | } 60 | if (o == null || getClass() != o.getClass()) { 61 | return false; 62 | } 63 | IChunkData chunkData = (IChunkData) o; 64 | return getChunkX() == chunkData.getChunkX() && getChunkZ() == chunkData.getChunkZ() && Objects.equals( 65 | getWorldName(), chunkData.getWorldName()); 66 | } 67 | 68 | @Override 69 | public int hashCode() { 70 | return Objects.hash(getWorldName(), getChunkX(), getChunkZ()); 71 | } 72 | 73 | public long toLong() { 74 | long l = chunkX; 75 | l = (l << 32) | (chunkZ & 0xFFFFFFFFL); 76 | return l; 77 | } 78 | 79 | public void applyLong(long l) { 80 | this.chunkX = (int) ((l >> 32) & 0xFFFFFFFF); 81 | this.chunkZ = (int) (l & 0xFFFFFFFFL); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/chunks/data/IChunkData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.chunks.data; 25 | 26 | public interface IChunkData { 27 | 28 | /** 29 | * @return World name 30 | */ 31 | String getWorldName(); 32 | 33 | /** 34 | * @return Chunk X Coordinate 35 | */ 36 | int getChunkX(); 37 | 38 | /** 39 | * @return Chunk Z Coordinate 40 | */ 41 | int getChunkZ(); 42 | 43 | /** 44 | * N/A 45 | */ 46 | void markSectionForUpdate(int lightFlags, int sectionY); 47 | 48 | /** 49 | * N/A 50 | */ 51 | void clearUpdate(); 52 | 53 | /** 54 | * N/A 55 | */ 56 | void setFullSections(); 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/chunks/data/IntChunkData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.chunks.data; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.api.engine.LightFlag; 27 | import ru.beykerykt.minecraft.lightapi.common.internal.utils.FlagUtils; 28 | 29 | public class IntChunkData extends ChunkData { 30 | 31 | public static final int FULL_MASK = 0x1ffff; 32 | 33 | protected int skyLightUpdateBits; 34 | protected int blockLightUpdateBits; 35 | 36 | public IntChunkData(String worldName, int chunkX, int chunkZ, int skyLightUpdateBits, int blockLightUpdateBits) { 37 | super(worldName, chunkX, chunkZ); 38 | this.skyLightUpdateBits = skyLightUpdateBits; 39 | this.blockLightUpdateBits = blockLightUpdateBits; 40 | } 41 | 42 | public int getSkyLightUpdateBits() { 43 | return skyLightUpdateBits; 44 | } 45 | 46 | public int getBlockLightUpdateBits() { 47 | return blockLightUpdateBits; 48 | } 49 | 50 | @Override 51 | public void markSectionForUpdate(int lightFlags, int sectionY) { 52 | if (FlagUtils.isFlagSet(lightFlags, LightFlag.SKY_LIGHTING)) { 53 | skyLightUpdateBits |= 1 << sectionY + 1; 54 | } 55 | 56 | if (FlagUtils.isFlagSet(lightFlags, LightFlag.BLOCK_LIGHTING)) { 57 | blockLightUpdateBits |= 1 << sectionY + 1; 58 | } 59 | } 60 | 61 | @Override 62 | public void clearUpdate() { 63 | this.skyLightUpdateBits = 0; 64 | this.blockLightUpdateBits = 0; 65 | } 66 | 67 | @Override 68 | public void setFullSections() { 69 | this.skyLightUpdateBits = FULL_MASK; 70 | this.blockLightUpdateBits = FULL_MASK; 71 | } 72 | 73 | @Override 74 | public String toString() { 75 | return "IntChunkData{" + "worldName=" + getWorldName() + ", chunkX=" + getChunkX() + ", chunkZ=" + getChunkZ() 76 | + ", skyLightUpdateBits=" + skyLightUpdateBits + ", blockLightUpdateBits=" + blockLightUpdateBits + '}'; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/chunks/data/LegacyIntChunkData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.chunks.data; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.api.engine.LightFlag; 27 | import ru.beykerykt.minecraft.lightapi.common.internal.utils.FlagUtils; 28 | 29 | /** 30 | * Legacy chunk data for < 1.14 31 | */ 32 | public class LegacyIntChunkData extends IntChunkData { 33 | 34 | public LegacyIntChunkData(String worldName, int chunkX, int chunkZ, int skyLightUpdateBits, 35 | int blockLightUpdateBits) { 36 | super(worldName, chunkX, chunkZ, skyLightUpdateBits, blockLightUpdateBits); 37 | } 38 | 39 | @Override 40 | public void markSectionForUpdate(int lightFlags, int sectionY) { 41 | if (FlagUtils.isFlagSet(lightFlags, LightFlag.SKY_LIGHTING)) { 42 | skyLightUpdateBits |= 1 << sectionY; 43 | } 44 | 45 | if (FlagUtils.isFlagSet(lightFlags, LightFlag.BLOCK_LIGHTING)) { 46 | blockLightUpdateBits |= 1 << sectionY; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/chunks/observer/IChunkObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.chunks.observer; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.data.IChunkData; 27 | 28 | import java.util.List; 29 | 30 | public interface IChunkObserver { 31 | 32 | /** 33 | * N/A 34 | */ 35 | void onStart(); 36 | 37 | /** 38 | * N/A 39 | */ 40 | void onShutdown(); 41 | 42 | /** 43 | * Collects modified сhunks with sections around a given coordinate in the radius of the light 44 | * level. The light level is taken from the arguments. 45 | * 46 | * @return List changed chunk sections around the given coordinate. 47 | */ 48 | List collectChunkSections(String worldName, int blockX, int blockY, int blockZ, int lightLevel, 49 | int lightFlags); 50 | 51 | /** 52 | * N/A 53 | */ 54 | int sendChunk(IChunkData data); 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/chunks/observer/sched/IScheduledChunkObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.chunks.observer.sched; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.observer.IChunkObserver; 27 | 28 | public interface IScheduledChunkObserver extends IChunkObserver, Runnable { 29 | 30 | /** 31 | * N/A 32 | */ 33 | boolean isBusy(); 34 | 35 | /** 36 | * N/A 37 | */ 38 | int notifyUpdateChunks(String worldName, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags); 39 | } 40 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/engine/ILightEngine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.engine; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.api.engine.EditPolicy; 27 | import ru.beykerykt.minecraft.lightapi.common.api.engine.RelightPolicy; 28 | import ru.beykerykt.minecraft.lightapi.common.api.engine.SendPolicy; 29 | import ru.beykerykt.minecraft.lightapi.common.api.engine.sched.ICallback; 30 | 31 | public interface ILightEngine { 32 | 33 | /** 34 | * N/A 35 | */ 36 | void onStart(); 37 | 38 | /** 39 | * N/A 40 | */ 41 | void onShutdown(); 42 | 43 | /** 44 | * N/A 45 | */ 46 | LightEngineType getLightEngineType(); 47 | 48 | /** 49 | * Used lighting engine version. 50 | * 51 | * @return One of the proposed options from {@link LightEngineVersion} 52 | */ 53 | LightEngineVersion getLightEngineVersion(); 54 | 55 | /** 56 | * N/A 57 | */ 58 | RelightPolicy getRelightPolicy(); 59 | 60 | /** 61 | * Checks the light level and restores it if available. 62 | */ 63 | @Deprecated 64 | int checkLight(String worldName, int blockX, int blockY, int blockZ, int lightFlags); 65 | 66 | /** 67 | * Gets the level of light from given coordinates with specific flags. 68 | */ 69 | int getLightLevel(String worldName, int blockX, int blockY, int blockZ, int lightFlags); 70 | 71 | /** 72 | * Placement of a specific type of light with a given level of illumination in the named world in 73 | * certain coordinates with the return code result. 74 | */ 75 | int setLightLevel(String worldName, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags, 76 | EditPolicy editPolicy, SendPolicy sendPolicy, ICallback callback); 77 | 78 | /** 79 | * Sets "directly" the level of light in given coordinates without additional processing. 80 | */ 81 | int setRawLightLevel(String worldName, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags); 82 | 83 | /** 84 | * Performs re-illumination of the light in the given coordinates. 85 | */ 86 | int recalculateLighting(String worldName, int blockX, int blockY, int blockZ, int lightFlags); 87 | } 88 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/engine/LightEngineType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.engine; 25 | 26 | public enum LightEngineType { 27 | UNKNOWN(0), 28 | VANILLA(1), 29 | STARLIGHT(2), 30 | PAPER_RCS(2), 31 | COMPATIBILITY(4); 32 | 33 | private final int id; 34 | 35 | LightEngineType(int id) { 36 | this.id = id; 37 | } 38 | 39 | public int getId() { 40 | return id; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/engine/LightEngineVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.engine; 25 | 26 | /** 27 | * @hide 28 | */ 29 | public enum LightEngineVersion { 30 | 31 | /** 32 | * N/A 33 | */ 34 | UNKNOWN(0), 35 | 36 | /** 37 | * Minecraft version is before 1.14. For update lighting in client-side, need send full chunk. 38 | */ 39 | V1(1), 40 | 41 | /** 42 | * Minecraft version is equals or after 1.14. For update lighting in client-side, need send only 43 | * light update packet. 44 | */ 45 | V2(2); 46 | 47 | private final int id; 48 | 49 | LightEngineVersion(int id) { 50 | this.id = id; 51 | } 52 | 53 | public int getId() { 54 | return id; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/engine/sched/IScheduledLightEngine.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.engine.sched; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.internal.engine.ILightEngine; 27 | 28 | public interface IScheduledLightEngine extends ILightEngine, Runnable { 29 | 30 | /** 31 | * N/A 32 | */ 33 | IScheduler getScheduler(); 34 | 35 | /** 36 | * N/A 37 | */ 38 | void setScheduler(IScheduler scheduler); 39 | 40 | /** 41 | * Tell the engine the task of changing the light level 42 | */ 43 | int notifyChangeLightLevel(Request request); 44 | 45 | /** 46 | * Tell the engine the task of recalculating the light level 47 | */ 48 | int notifyRecalculate(Request request); 49 | 50 | /** 51 | * Tell the engine the task of sending packets 52 | */ 53 | int notifySend(Request request); 54 | } 55 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/engine/sched/IScheduler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.engine.sched; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.api.engine.EditPolicy; 27 | import ru.beykerykt.minecraft.lightapi.common.api.engine.SendPolicy; 28 | import ru.beykerykt.minecraft.lightapi.common.api.engine.sched.ICallback; 29 | 30 | /** 31 | * A scheduler interface for scheduled light engine logic 32 | */ 33 | public interface IScheduler { 34 | 35 | /** 36 | * N/A 37 | */ 38 | boolean canExecute(); 39 | 40 | /** 41 | * Creates requests. The function must return only a request with specific flags. 42 | */ 43 | Request createEmptyRequest(String worldName, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags, 44 | EditPolicy editPolicy, SendPolicy sendPolicy, ICallback callback); 45 | 46 | /** 47 | * Creates requests. The function must return only a request with specific flags. 48 | */ 49 | Request createRequest(int defaultFlag, String worldName, int blockX, int blockY, int blockZ, int lightLevel, 50 | int lightFlags, EditPolicy editPolicy, SendPolicy sendPolicy, ICallback callback); 51 | 52 | /** 53 | * Processes light requests. The function should only process requests without changes in flags. 54 | */ 55 | int handleLightRequest(Request request); 56 | 57 | /** 58 | * Processes relight requests. The function should only process requests without changes in flags. 59 | */ 60 | int handleRelightRequest(Request request); 61 | 62 | /** 63 | * Processes send requests. The function should only process requests without changes in flags. 64 | */ 65 | int handleSendRequest(Request request); 66 | } 67 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/engine/sched/Request.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.engine.sched; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.api.engine.sched.ICallback; 27 | import ru.beykerykt.minecraft.lightapi.common.internal.utils.FlagUtils; 28 | 29 | public class Request implements Comparable { 30 | 31 | public static final int HIGH_PRIORITY = 10; 32 | public static final int DEFAULT_PRIORITY = 5; 33 | public static final int LOW_PRIORITY = 0; 34 | 35 | private final String mWorldName; 36 | private final int mBlockX; 37 | private final int mBlockY; 38 | private final int mBlockZ; 39 | private final int mLightLevel; 40 | private final int mOldLightLevel; 41 | private final int mLightFlags; 42 | private final ICallback mCallback; 43 | private int mRequestFlags; 44 | private int mPriority; 45 | 46 | public Request(int priority, int requestFlags, String worldName, int blockX, int blockY, int blockZ, 47 | int oldLightLevel, int lightLevel, int lightFlags, ICallback callback) { 48 | this.mPriority = priority; 49 | this.mRequestFlags = requestFlags; 50 | this.mWorldName = worldName; 51 | this.mBlockX = blockX; 52 | this.mBlockY = blockY; 53 | this.mBlockZ = blockZ; 54 | this.mOldLightLevel = oldLightLevel; 55 | this.mLightLevel = lightLevel; 56 | this.mLightFlags = lightFlags; 57 | this.mCallback = callback; 58 | } 59 | 60 | public int getPriority() { 61 | return mPriority; 62 | } 63 | 64 | public void setPriority(int priority) { 65 | this.mPriority = priority; 66 | } 67 | 68 | public int getRequestFlags() { 69 | return mRequestFlags; 70 | } 71 | 72 | public void setRequestFlags(int requestFlags) { 73 | this.mRequestFlags = requestFlags; 74 | } 75 | 76 | public void addRequestFlag(int targetFlag) { 77 | this.mRequestFlags = FlagUtils.addFlag(mRequestFlags, targetFlag); 78 | } 79 | 80 | public void removeRequestFlag(int targetFlag) { 81 | this.mRequestFlags = FlagUtils.removeFlag(mRequestFlags, targetFlag); 82 | } 83 | 84 | public String getWorldName() { 85 | return mWorldName; 86 | } 87 | 88 | public int getBlockX() { 89 | return mBlockX; 90 | } 91 | 92 | public int getBlockY() { 93 | return mBlockY; 94 | } 95 | 96 | public int getBlockZ() { 97 | return mBlockZ; 98 | } 99 | 100 | public int getOldLightLevel() { 101 | return mOldLightLevel; 102 | } 103 | 104 | public int getLightLevel() { 105 | return mLightLevel; 106 | } 107 | 108 | public int getLightFlags() { 109 | return mLightFlags; 110 | } 111 | 112 | public ICallback getCallback() { 113 | return mCallback; 114 | } 115 | 116 | @Override 117 | public int compareTo(Request o) { 118 | return this.getPriority() - o.getPriority(); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/engine/sched/RequestFlag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.engine.sched; 25 | 26 | public class RequestFlag { 27 | 28 | /** 29 | * N/A 30 | */ 31 | public static final int EDIT = 1; 32 | 33 | /** 34 | * N/A 35 | */ 36 | public static final int RECALCULATE = 2; 37 | 38 | /** 39 | * N/A 40 | */ 41 | public static final int DEFERRED_RECALCULATE = 4; 42 | 43 | /** 44 | * N/A 45 | */ 46 | public static final int SEPARATE_SEND = 8; 47 | 48 | /** 49 | * N/A 50 | */ 51 | public static final int COMBINED_SEND = 16; 52 | 53 | /** 54 | * N/A 55 | */ 56 | public static final int FORCE_SEND = 32; 57 | } 58 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/service/BackgroundServiceImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package ru.beykerykt.minecraft.lightapi.common.internal.service; 26 | 27 | import ru.beykerykt.minecraft.lightapi.common.internal.IPlatformImpl; 28 | 29 | import java.util.concurrent.*; 30 | 31 | public abstract class BackgroundServiceImpl implements IBackgroundService { 32 | private ScheduledExecutorService executorService; 33 | private IPlatformImpl mPlatform; 34 | 35 | public BackgroundServiceImpl(IPlatformImpl platform) { 36 | this.mPlatform = platform; 37 | } 38 | 39 | protected IPlatformImpl getPlatformImpl() { 40 | return this.mPlatform; 41 | } 42 | 43 | protected void configureExecutorService(int corePoolSize, ThreadFactory namedThreadFactory) { 44 | if (this.executorService == null) { 45 | this.executorService = Executors.newScheduledThreadPool(corePoolSize, namedThreadFactory); 46 | } 47 | } 48 | 49 | protected ScheduledExecutorService getExecutorService() { 50 | return this.executorService; 51 | } 52 | 53 | @Override 54 | public void onShutdown() { 55 | if (getExecutorService() != null) { 56 | getExecutorService().shutdown(); 57 | try { 58 | if (!getExecutorService().awaitTermination(10, TimeUnit.SECONDS)) { 59 | getPlatformImpl().info("Still waiting after 10 seconds: Shutdown now."); 60 | getExecutorService().shutdownNow(); 61 | } 62 | } catch (InterruptedException e) { 63 | // (Re-)Cancel if current thread also interrupted 64 | getExecutorService().shutdownNow(); 65 | // Preserve interrupt status 66 | Thread.currentThread().interrupt(); 67 | } 68 | } 69 | } 70 | 71 | @Override 72 | public ScheduledFuture scheduleWithFixedDelay(Runnable runnable, int initialDelay, int delay, TimeUnit unit) { 73 | return getExecutorService().scheduleWithFixedDelay(runnable, initialDelay, delay, unit); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/service/IBackgroundService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.service; 25 | 26 | import java.util.concurrent.ScheduledFuture; 27 | import java.util.concurrent.TimeUnit; 28 | 29 | public interface IBackgroundService { 30 | 31 | /** 32 | * N/A 33 | */ 34 | void onStart(); 35 | 36 | /** 37 | * N/A 38 | */ 39 | void onShutdown(); 40 | 41 | /** 42 | * N/A 43 | */ 44 | boolean canExecuteSync(long maxTime); 45 | 46 | /** 47 | * N/A 48 | */ 49 | boolean isMainThread(); 50 | 51 | /** 52 | * N/A 53 | */ 54 | ScheduledFuture scheduleWithFixedDelay(Runnable runnable, int initialDelay, int delay, TimeUnit unit); 55 | } 56 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/utils/BlockPosition.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.utils; 25 | 26 | public class BlockPosition { 27 | 28 | // from NMS 1.15.2 29 | private static final int SIZE_BITS_X = 26; 30 | private static final int SIZE_BITS_Z = 26; 31 | private static final int SIZE_BITS_Y = 12; 32 | private static final long BITS_X = 0x3FFFFFF; // hex to dec: 67108863 33 | private static final long BITS_Y = 0xFFF; // hex to dec: 4095 34 | private static final long BITS_Z = 0x3FFFFFF; // hex to dec: 67108863 35 | private static final int BIT_SHIFT_Z = 12; 36 | private static final int BIT_SHIFT_X = 38; 37 | 38 | private int blockX; 39 | private int blockY; 40 | private int blockZ; 41 | 42 | public BlockPosition(int blockX, int blockY, int blockZ) { 43 | this.blockX = blockX; 44 | this.blockY = blockY; 45 | this.blockZ = blockZ; 46 | } 47 | 48 | public static long asLong(int blockX, int blockY, int blockZ) { 49 | long long4 = 0L; 50 | long4 |= ((long) blockX & BITS_X) << BIT_SHIFT_X; 51 | long4 |= ((long) blockY & BITS_Y) << 0; 52 | long4 |= ((long) blockZ & BITS_Z) << BIT_SHIFT_Z; 53 | return long4; 54 | } 55 | 56 | public static int unpackLongX(final long long1) { 57 | return (int) (long1 << 64 - BIT_SHIFT_X - SIZE_BITS_X >> 64 - SIZE_BITS_X); 58 | } 59 | 60 | public static int unpackLongY(final long long1) { 61 | return (int) (long1 << 64 - SIZE_BITS_Y >> 64 - SIZE_BITS_Y); 62 | } 63 | 64 | public static int unpackLongZ(final long long1) { 65 | return (int) (long1 << 64 - BIT_SHIFT_Z - SIZE_BITS_Z >> 64 - SIZE_BITS_Z); 66 | } 67 | 68 | public static BlockPosition fromLong(final long value) { 69 | return new BlockPosition(unpackLongX(value), unpackLongY(value), unpackLongZ(value)); 70 | } 71 | 72 | public int getBlockX() { 73 | return blockX; 74 | } 75 | 76 | public void setBlockX(int blockX) { 77 | this.blockX = blockX; 78 | } 79 | 80 | public int getBlockY() { 81 | return blockY; 82 | } 83 | 84 | public void setBlockY(int blockY) { 85 | this.blockY = blockY; 86 | } 87 | 88 | public int getBlockZ() { 89 | return blockZ; 90 | } 91 | 92 | public void setBlockZ(int blockZ) { 93 | this.blockZ = blockZ; 94 | } 95 | 96 | public long asLong() { 97 | return asLong(getBlockX(), getBlockY(), getBlockZ()); 98 | } 99 | 100 | @Override 101 | public int hashCode() { 102 | final int prime = 31; 103 | int result = 1; 104 | result = prime * result + blockX; 105 | result = prime * result + blockY; 106 | result = prime * result + blockZ; 107 | return result; 108 | } 109 | 110 | @Override 111 | public boolean equals(Object obj) { 112 | if (this == obj) { 113 | return true; 114 | } 115 | if (obj == null) { 116 | return false; 117 | } 118 | if (getClass() != obj.getClass()) { 119 | return false; 120 | } 121 | BlockPosition other = (BlockPosition) obj; 122 | if (blockX != other.blockX) { 123 | return false; 124 | } 125 | if (blockY != other.blockY) { 126 | return false; 127 | } 128 | return blockZ == other.blockZ; 129 | } 130 | 131 | @Override 132 | public String toString() { 133 | return "BlockPosition [blockX=" + blockX + ", blockY=" + blockY + ", blockZ=" + blockZ + "]"; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/utils/ChunkUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package ru.beykerykt.minecraft.lightapi.common.internal.utils; 26 | 27 | public class ChunkUtils { 28 | 29 | public static int getLocalCoord(int coord) { 30 | return coord & 15; 31 | } 32 | 33 | public static long getChunkKey(int chunkX, int chunkZ) { 34 | return (long) chunkX & 0xffffffffL | ((long) chunkZ & 0xffffffffL) << 32; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/utils/FlagUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.utils; 25 | 26 | public class FlagUtils { 27 | 28 | /** 29 | * N/A 30 | */ 31 | public static int addFlag(int flags, int targetFlag) { 32 | return flags |= targetFlag; 33 | } 34 | 35 | /** 36 | * N/A 37 | */ 38 | public static int removeFlag(int flags, int targetFlag) { 39 | return flags &= ~targetFlag; 40 | } 41 | 42 | /** 43 | * N/A 44 | */ 45 | public static boolean isFlagSet(int flags, int targetFlag) { 46 | return (flags & targetFlag) == targetFlag; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /common/src/main/java/ru/beykerykt/minecraft/lightapi/common/internal/utils/UsageTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.common.internal.utils; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.Build; 27 | import ru.beykerykt.minecraft.lightapi.common.LightAPI; 28 | import ru.beykerykt.minecraft.lightapi.common.api.engine.EditPolicy; 29 | import ru.beykerykt.minecraft.lightapi.common.api.engine.LightFlag; 30 | import ru.beykerykt.minecraft.lightapi.common.api.engine.SendPolicy; 31 | 32 | public class UsageTest { 33 | 34 | private LightAPI mLightAPI; 35 | 36 | private void initClient() { 37 | mLightAPI = LightAPI.get(); 38 | 39 | // internal use 40 | switch (Build.CURRENT_IMPLEMENTATION) { 41 | case UNKNOWN: 42 | // unknown implementation 43 | break; 44 | case BUKKIT: 45 | // bukkit implementation 46 | break; 47 | case CRAFTBUKKIT: 48 | // craftbukkit implementation 49 | break; 50 | case SPONGE: 51 | // sponge implementation 52 | break; 53 | } 54 | int apiVersion = Build.API_VERSION; 55 | int internalVersion = Build.INTERNAL_VERSION; 56 | } 57 | 58 | // for clients 59 | public void test(String world, int blockX, int blockY, int blockZ, int lightLevel) { 60 | int lightType = LightFlag.BLOCK_LIGHTING; 61 | EditPolicy editPolicy = EditPolicy.DEFERRED; 62 | SendPolicy sendPolicy = SendPolicy.DEFERRED; 63 | mLightAPI.setLightLevel(world, blockX, blockY, blockZ, lightLevel, lightType, editPolicy, sendPolicy, 64 | (requestFlag, resultCode) -> { 65 | // test 66 | }); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /common/src/main/resources/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 Vladimir Mikhailov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Dfile.encoding=UTF-8 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IPECTER/LighterAPI/4b398ac2e4a0a69ac30456986a020f13b7060152/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | maven { url = uri("https://repo.papermc.io/repository/maven-public/") } 5 | } 6 | } 7 | 8 | rootProject.name = 'lightapi' 9 | 10 | include(':bukkit-all') 11 | include(':common') 12 | include(':bukkit-common') 13 | include(':bukkit-backward-support') 14 | include(':bukkit-example') 15 | 16 | include(':lightapi-craftbukkit-nms-v1_13_R2') 17 | include(':lightapi-craftbukkit-nms-v1_14_R1') 18 | include(':lightapi-craftbukkit-nms-v1_15_R1') 19 | include(':lightapi-craftbukkit-nms-v1_16_R1') 20 | include(':lightapi-craftbukkit-nms-v1_16_R2') 21 | include(':lightapi-craftbukkit-nms-v1_16_R3') 22 | include(':lightapi-craftbukkit-nms-v1_17_R1') 23 | include(':lightapi-craftbukkit-nms-v1_18_R1') 24 | include(':lightapi-craftbukkit-nms-v1_18_R2') 25 | include(':lightapi-craftbukkit-nms-v1_19_R1') 26 | include(':lightapi-craftbukkit-nms-v1_19_R2') 27 | include(':lightapi-craftbukkit-nms-v1_19_R3') 28 | 29 | project(":lightapi-craftbukkit-nms-v1_13_R2").projectDir = file('bukkit-nms/v1_13_R2') 30 | project(":lightapi-craftbukkit-nms-v1_14_R1").projectDir = file('bukkit-nms/v1_14_R1') 31 | project(":lightapi-craftbukkit-nms-v1_15_R1").projectDir = file('bukkit-nms/v1_15_R1') 32 | project(":lightapi-craftbukkit-nms-v1_16_R1").projectDir = file('bukkit-nms/v1_16_R1') 33 | project(":lightapi-craftbukkit-nms-v1_16_R2").projectDir = file('bukkit-nms/v1_16_R2') 34 | project(":lightapi-craftbukkit-nms-v1_16_R3").projectDir = file('bukkit-nms/v1_16_R3') 35 | project(":lightapi-craftbukkit-nms-v1_17_R1").projectDir = file('bukkit-nms/v1_17_R1') 36 | project(":lightapi-craftbukkit-nms-v1_18_R1").projectDir = file('bukkit-nms/v1_18_R1') 37 | project(":lightapi-craftbukkit-nms-v1_18_R2").projectDir = file('bukkit-nms/v1_18_R2') 38 | project(":lightapi-craftbukkit-nms-v1_19_R1").projectDir = file('bukkit-nms/v1_19_R1') 39 | project(":lightapi-craftbukkit-nms-v1_19_R2").projectDir = file('bukkit-nms/v1_19_R2') 40 | project(":lightapi-craftbukkit-nms-v1_19_R3").projectDir = file('bukkit-nms/v1_19_R3') 41 | 42 | //craftbukkit-common: bukkit-common/src/main/java/ru/beykerykt/minecraft/lightapi/bukkit/internal/handler/craftbukkit 43 | include(':lightapi-craftbukkit-common') 44 | project(":lightapi-craftbukkit-common").projectDir = file('craftbukkit-common') 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /sponge-all/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-sponge-mcp-all 36 | pom 37 | 38 | 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-assembly-plugin 43 | ${maven-assembly-plugin.version} 44 | 45 | false 46 | LightAPI-${SERVER_API}-${project.version} 47 | 48 | 49 | 50 | 51 | false 52 | 53 | src/main/assembly/all-jar.xml 54 | 55 | 56 | 57 | single 58 | 59 | package-all 60 | package 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | ${project.groupId} 71 | lightapi-common 72 | ${project.version} 73 | compile 74 | jar 75 | 76 | 77 | 78 | ${project.groupId} 79 | lightapi-sponge-common 80 | ${project.version} 81 | compile 82 | jar 83 | 84 | 85 | 86 | ${project.groupId} 87 | lightapi-sponge-mcp-v1_12_R1 88 | ${project.version} 89 | compile 90 | jar 91 | 92 | 93 | 94 | 95 | Sponge 96 | 3.1.1 97 | UTF-8 98 | 99 | 100 | -------------------------------------------------------------------------------- /sponge-all/src/main/assembly/all-jar.xml: -------------------------------------------------------------------------------- 1 | 24 | 25 | 29 | 30 | 31 | true 32 | false 33 | 34 | 35 | 36 | jar 37 | 38 | all-jar 39 | 40 | false 41 | -------------------------------------------------------------------------------- /sponge-common/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-sponge-common 36 | 37 | 38 | clean package install 39 | 40 | 41 | org.apache.maven.plugins 42 | maven-compiler-plugin 43 | ${maven-compiler-plugin.version} 44 | 45 | 1.8 46 | 1.8 47 | 48 | 49 | 50 | org.apache.maven.plugins 51 | maven-jar-plugin 52 | ${maven-jar-plugin.version} 53 | 54 | 55 | org.apache.maven.plugins 56 | maven-shade-plugin 57 | ${maven-shade-plugin.version} 58 | 59 | 60 | 61 | false 62 | 63 | 64 | ru.beykerykt.minecraft:lightapi-common 65 | 66 | ** 67 | 68 | 69 | 70 | true 71 | 72 | 73 | shade 74 | 75 | package 76 | 77 | 78 | 79 | 80 | 81 | 82 | src/main/resources/ 83 | true 84 | 85 | 86 | ${basedir}/src/main/java 87 | 88 | 89 | 90 | 91 | 92 | ${project.groupId} 93 | lightapi-common 94 | ${project.version} 95 | compile 96 | jar 97 | 98 | 99 | 100 | org.spongepowered 101 | spongeapi 102 | ${spongeapi.version} 103 | provided 104 | jar 105 | 106 | 107 | 108 | 109 | sponge 110 | 3.8.1 111 | 3.1.2 112 | 3.2.1 113 | UTF-8 114 | 7.1.0 115 | 116 | 117 | 118 | 119 | sponge-repo 120 | Sponge Maven Repository 121 | https://repo.spongepowered.org/maven 122 | 123 | 124 | md_5-repo 125 | http://repo.md-5.net/content/groups/public/ 126 | 127 | 128 | 129 | -------------------------------------------------------------------------------- /sponge-common/src/main/java/ru/beykerykt/minecraft/lightapi/impl/sponge/ISpongeLightHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.impl.sponge; 25 | 26 | import org.spongepowered.api.entity.living.player.Player; 27 | import org.spongepowered.api.world.World; 28 | 29 | import java.util.List; 30 | 31 | import ru.beykerykt.minecraft.lightapi.common.IChunkData; 32 | import ru.beykerykt.minecraft.lightapi.common.ILightHandler; 33 | import ru.beykerykt.minecraft.lightapi.common.LightType; 34 | 35 | /** 36 | * Extended common interface for Sponge 37 | * 38 | * @author BeYkeRYkt 39 | */ 40 | public interface ISpongeLightHandler extends ILightHandler { 41 | 42 | /** 43 | * Placement of a certain type of light with a given level of illumination in the named world in 44 | * certain coordinates with the return result. 45 | * 46 | * @param world - World 47 | * @param type - Light type 48 | * @param blockX - Block X coordinate 49 | * @param blockY - Block Y coordinate 50 | * @param blockZ - Block Z coordinate 51 | * @param lightlevel - light level. Default range - 0 - 15 52 | * @return true - if the light in the given coordinates has changed, false - if not 53 | */ 54 | public boolean createLight(World world, LightType type, int blockX, int blockY, int blockZ, int lightlevel); 55 | 56 | /** 57 | * Removing a certain type of light in the named world in certain coordinates with the return 58 | * result. 59 | * 60 | * @param world - World 61 | * @param type - Light type 62 | * @param blockX - Block X coordinate 63 | * @param blockY - Block Y coordinate 64 | * @param blockZ - Block Z coordinate 65 | * @return true - if the light in the given coordinates has changed, false - if not 66 | */ 67 | public boolean deleteLight(World world, LightType type, int blockX, int blockY, int blockZ); 68 | 69 | /** 70 | * Sets "directly" the level of light in given coordinates without additional processing. 71 | * 72 | * @param world - World 73 | * @param type - Light type 74 | * @param blockX - Block X coordinate 75 | * @param blockY - Block Y coordinate 76 | * @param blockZ - Block Z coordinate 77 | * @param lightlevel - light level. Default range - 0 - 15 78 | */ 79 | public void setRawLightLevel(World world, LightType type, int blockX, int blockY, int blockZ, int lightlevel); 80 | 81 | /** 82 | * Gets "directly" the level of light from given coordinates without additional processing. 83 | * 84 | * @param world - World 85 | * @param type - Light type 86 | * @param blockX - Block X coordinate 87 | * @param blockY - Block Y coordinate 88 | * @param blockZ - Block Z coordinate 89 | * @return lightlevel - Light level. Default range - 0 - 15 90 | */ 91 | public int getRawLightLevel(World world, LightType type, int blockX, int blockY, int blockZ); 92 | 93 | /** 94 | * Performs re-illumination of the light in the given coordinates. 95 | * 96 | * @param world - World 97 | * @param type - Light type 98 | * @param blockX - Block X coordinate 99 | * @param blockY - Block Y coordinate 100 | * @param blockZ - Block Z coordinate 101 | */ 102 | public void recalculateLighting(World world, LightType type, int blockX, int blockY, int blockZ); 103 | 104 | /** 105 | * Collects changed chunks in the list around the given coordinate. 106 | * 107 | * @param world - World 108 | * @param blockX - Block X coordinate 109 | * @param blockY - Block Y coordinate 110 | * @param blockZ - Block Z coordinate 111 | * @param lightlevel - Light level. Default range - 0 - 15 112 | * @return List changed chunks around the given coordinate. 113 | */ 114 | public List collectChunks(World world, int blockX, int blockY, int blockZ, int lightlevel); 115 | 116 | /** 117 | * Collects changed chunks in the list around the given coordinate. 118 | * 119 | * @param world - World 120 | * @param blockX - Block X coordinate 121 | * @param blockY - Block Y coordinate 122 | * @param blockZ - Block Z coordinate 123 | * @return List changed chunks around the given coordinate. 124 | */ 125 | public List collectChunks(World world, int blockX, int blockY, int blockZ); 126 | 127 | /** 128 | * Sending changes to a player by name 129 | * 130 | * @param world - World 131 | * @param chunkX - Chunk X coordinate 132 | * @param chunkZ - Chunk Z coordinate 133 | * @param player - Player 134 | */ 135 | public void sendChanges(World world, int chunkX, int chunkZ, Player player); 136 | 137 | /** 138 | * Sending changes to a player by name 139 | * 140 | * @param world - World 141 | * @param chunkX - Chunk X coordinate 142 | * @param blockY - Block Y coordinate 143 | * @param chunkZ - Chunk Z coordinate 144 | * @param player - Player 145 | */ 146 | public void sendChanges(World world, int chunkX, int blockY, int chunkZ, Player player); 147 | 148 | /** 149 | * Sending changes to a player by name 150 | * 151 | * @param chunkData - {@link IChunkData} 152 | * @param player - Player 153 | */ 154 | public void sendChanges(IChunkData chunkData, Player player); 155 | 156 | /** 157 | * Sending changes to world 158 | * 159 | * @param world - World 160 | * @param chunkX - Chunk X coordinate 161 | * @param chunkZ - Chunk Z coordinate 162 | */ 163 | public void sendChanges(World world, int chunkX, int chunkZ); 164 | 165 | /** 166 | * Sending changes to world 167 | * 168 | * @param world - World 169 | * @param chunkX - Chunk X coordinate 170 | * @param blockY - Block Y coordinate 171 | * @param chunkZ - Chunk Z coordinate 172 | */ 173 | public void sendChanges(World world, int chunkX, int blockY, int chunkZ); 174 | } 175 | -------------------------------------------------------------------------------- /sponge-common/src/main/java/ru/beykerykt/minecraft/lightapi/impl/sponge/SpongeChunkData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.impl.sponge; 25 | 26 | import org.spongepowered.api.entity.living.player.Player; 27 | import org.spongepowered.api.world.World; 28 | 29 | import java.util.Collection; 30 | 31 | import ru.beykerykt.minecraft.lightapi.common.IChunkData; 32 | 33 | /** 34 | * https://wiki.vg/Chunk_Format#Packet_structure 35 | * 36 | * @author BeYkeRYkt 37 | */ 38 | public class SpongeChunkData implements IChunkData { 39 | 40 | private World world; 41 | private int x; 42 | private int y; 43 | private int z; 44 | private Collection receivers; 45 | 46 | public SpongeChunkData(World world, int chunkX, int chunkZ, Collection playersName) { 47 | this(world, chunkX, 255, chunkZ, playersName); 48 | } 49 | 50 | public SpongeChunkData(World world, int chunkX, int chunk_y_height, int chunkZ, Collection playersName) { 51 | this.world = world; 52 | this.x = chunkX; 53 | this.y = chunk_y_height; 54 | this.z = chunkZ; 55 | this.receivers = playersName; 56 | } 57 | 58 | public World getWorld() { 59 | return world; 60 | } 61 | 62 | /** 63 | * @return World name 64 | */ 65 | @Override 66 | public String getWorldName() { 67 | return world.getName(); 68 | } 69 | 70 | /** 71 | * @return Chunk X Coordinate 72 | */ 73 | @Override 74 | public int getChunkX() { 75 | return x; 76 | } 77 | 78 | /** 79 | * @return Chunk Z Coordinate 80 | */ 81 | @Override 82 | public int getChunkZ() { 83 | return z; 84 | } 85 | 86 | /** 87 | * Bitmask with bits set to 1 for every 16×16×16 chunk section whose data is included in Data. The 88 | * least significant bit represents the chunk section at the bottom of the chunk column (from y=0 89 | * to y=15). 90 | * 91 | * @return The height (0 - 255) on which the chunk column depends 92 | */ 93 | public int getChunkYHeight() { 94 | return y; 95 | } 96 | 97 | public void setChunkYHeight(int y) { 98 | this.y = y; 99 | } 100 | 101 | /** 102 | * @return A list of player to which this chunk can be sent. 103 | */ 104 | public Collection getReceivers() { 105 | return receivers; 106 | } 107 | 108 | public void setReceivers(Collection receivers) { 109 | this.receivers = receivers; 110 | } 111 | 112 | @Override 113 | public int hashCode() { 114 | final int prime = 31; 115 | int result = 1; 116 | result = prime * result + ((world == null) ? 0 : world.hashCode()); 117 | result = prime * result + x; 118 | result = prime * result + (y >> 4); 119 | result = prime * result + z; 120 | return result; 121 | } 122 | 123 | @Override 124 | public boolean equals(Object obj) { 125 | if (this == obj) { 126 | return true; 127 | } 128 | if (obj == null) { 129 | return false; 130 | } 131 | if (getClass() != obj.getClass()) { 132 | return false; 133 | } 134 | SpongeChunkData other = (SpongeChunkData) obj; 135 | if (world == null) { 136 | if (other.world != null) { 137 | return false; 138 | } 139 | } else if (!world.getName().equals(other.world.getName())) { 140 | return false; 141 | } 142 | if (x != other.x) { 143 | return false; 144 | } 145 | if ((y >> 4) != (other.y >> 4)) { 146 | return false; 147 | } 148 | if (z != other.z) { 149 | return false; 150 | } 151 | return true; 152 | } 153 | 154 | @Override 155 | public String toString() { 156 | return "SpongeChunkData [worldName=" + world.getName() + ", x=" + x + ", y=" + y + ", z=" + z + "]"; 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /sponge-common/src/main/java/ru/beykerykt/minecraft/lightapi/impl/sponge/SpongeHandlerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.impl.sponge; 25 | 26 | import org.spongepowered.api.MinecraftVersion; 27 | import org.spongepowered.api.Sponge; 28 | 29 | import java.lang.reflect.InvocationTargetException; 30 | 31 | import ru.beykerykt.minecraft.lightapi.common.IHandlerFactory; 32 | import ru.beykerykt.minecraft.lightapi.common.ILightHandler; 33 | 34 | public class SpongeHandlerFactory implements IHandlerFactory { 35 | 36 | private SpongePlugin plugin; 37 | 38 | public SpongeHandlerFactory(SpongePlugin plugin) { 39 | this.plugin = plugin; 40 | } 41 | 42 | @Override 43 | public ILightHandler createHandler() { 44 | MinecraftVersion version = Sponge.getGame().getPlatform().getMinecraftVersion(); 45 | plugin.getLogger().info("Your server is using version " + version.getName()); 46 | String ver = "UNKNOWN"; 47 | if (version.getName().equals("1.12.2")) { 48 | ver = "v1_12_R1"; 49 | } 50 | try { 51 | return (ISpongeLightHandler) Class.forName( 52 | "ru.beykerykt.minecraft.lightapi.impl.sponge.mcp.MCP_" + ver).getConstructor().newInstance(); 53 | } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | 54 | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException e) { 55 | e.printStackTrace(); 56 | } 57 | return null; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sponge-common/src/main/java/ru/beykerykt/minecraft/lightapi/impl/sponge/SpongeLightHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.impl.sponge; 25 | 26 | import ru.beykerykt.minecraft.lightapi.common.ImplementationPlatform; 27 | 28 | /** 29 | * Interface implementation for MCP NMS (Net Minecraft Server) 30 | * 31 | * @author BeYkeRYkt 32 | */ 33 | public abstract class SpongeLightHandler implements ISpongeLightHandler { 34 | 35 | @Override 36 | public ImplementationPlatform getImplementationPlatform() { 37 | return ImplementationPlatform.SPONGE; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sponge-common/src/main/java/ru/beykerykt/minecraft/lightapi/impl/sponge/SpongePlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * The MIT License (MIT) 3 | * 4 | * Copyright 2021 Vladimir Mikhailov 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | package ru.beykerykt.minecraft.lightapi.impl.sponge; 25 | 26 | import com.google.inject.Inject; 27 | 28 | import org.slf4j.Logger; 29 | import org.spongepowered.api.entity.living.player.Player; 30 | import org.spongepowered.api.event.Listener; 31 | import org.spongepowered.api.event.block.InteractBlockEvent; 32 | import org.spongepowered.api.event.filter.cause.First; 33 | import org.spongepowered.api.event.game.state.GameStartedServerEvent; 34 | import org.spongepowered.api.event.message.MessageChannelEvent; 35 | import org.spongepowered.api.plugin.Plugin; 36 | import org.spongepowered.api.text.Text; 37 | import org.spongepowered.api.world.Location; 38 | import org.spongepowered.api.world.World; 39 | 40 | import java.util.List; 41 | import java.util.concurrent.CopyOnWriteArrayList; 42 | 43 | import ru.beykerykt.minecraft.lightapi.common.IChunkData; 44 | import ru.beykerykt.minecraft.lightapi.common.LightAPI; 45 | import ru.beykerykt.minecraft.lightapi.common.LightType; 46 | 47 | @Plugin(id = "lightapi", name = "LightAPI", description = "Library for create invisible light", authors = { 48 | "BeYkeRYkt" 49 | }, version = "Sponge-5.0.0") 50 | public class SpongePlugin { 51 | 52 | private static SpongePlugin plugin; 53 | @Inject 54 | private Logger log; 55 | private Location prevLoc; 56 | // testing 57 | private boolean debug = false; 58 | private boolean flag = false; 59 | 60 | public static SpongePlugin getInstance() { 61 | return plugin; 62 | } 63 | 64 | @Listener 65 | public void onServerStart(GameStartedServerEvent event) { 66 | this.plugin = this; 67 | LightAPI.setLightHandler(new SpongeHandlerFactory(this).createHandler()); 68 | } 69 | 70 | public Logger getLogger() { 71 | return log; 72 | } 73 | 74 | @Listener 75 | public void onPlayerChat(MessageChannelEvent.Chat event, @First final Player p) { 76 | if (!flag || !debug) { 77 | return; 78 | } 79 | Text message = event.getRawMessage(); 80 | 81 | if (message.toPlain().equals("enable")) { 82 | flag = true; 83 | p.sendMessage(Text.of("Enabled!")); 84 | } else if (message.toPlain().equals("disable")) { 85 | flag = false; 86 | p.sendMessage(Text.of("Disabled!")); 87 | } else if (message.toPlain().equals("create")) { 88 | Location playerLoc = p.getLocation(); 89 | World world = (World) playerLoc.getExtent(); 90 | if (LightAPI.createLight(world.getName(), LightType.BLOCK, playerLoc.getBlockX(), playerLoc.getBlockY(), 91 | playerLoc.getBlockZ(), 12)) { 92 | if (LightAPI.isRequireManuallySendingChanges()) { 93 | for (IChunkData data : LightAPI.collectChunks(world.getName(), playerLoc.getBlockX(), 94 | playerLoc.getBlockY(), playerLoc.getBlockZ(), 12 / 2)) { 95 | LightAPI.sendChanges(data); 96 | } 97 | } 98 | } 99 | } else if (message.toPlain().equals("delete")) { 100 | Location playerLoc = p.getLocation(); 101 | World world = (World) playerLoc.getExtent(); 102 | if (LightAPI.deleteLight(world.getName(), LightType.BLOCK, playerLoc.getBlockX(), playerLoc.getBlockY(), 103 | playerLoc.getBlockZ())) { 104 | if (LightAPI.isRequireManuallySendingChanges()) { 105 | for (IChunkData data : LightAPI.collectChunks(world.getName(), playerLoc.getBlockX(), 106 | playerLoc.getBlockY(), playerLoc.getBlockZ(), 12 / 2)) { 107 | LightAPI.sendChanges(data); 108 | } 109 | } 110 | } 111 | } 112 | } 113 | 114 | @Listener 115 | public void onRightClick(InteractBlockEvent.Secondary event, @First Player p) { 116 | if (!flag || !debug) { 117 | return; 118 | } 119 | 120 | List chunkQueue = new CopyOnWriteArrayList(); 121 | if (prevLoc != null) { 122 | World world = (World) prevLoc.getExtent(); 123 | if (LightAPI.isRequireManuallySendingChanges()) { 124 | if (LightAPI.deleteLight(world.getName(), LightType.BLOCK, prevLoc.getBlockX(), prevLoc.getBlockY(), 125 | prevLoc.getBlockZ())) { 126 | for (IChunkData data : LightAPI.collectChunks(world.getName(), prevLoc.getBlockX(), 127 | prevLoc.getBlockY(), prevLoc.getBlockZ(), 12 / 2)) { 128 | if (!chunkQueue.contains(data)) { 129 | chunkQueue.add(data); 130 | } 131 | } 132 | } 133 | } 134 | } 135 | prevLoc = event.getTargetBlock().getLocation().get(); 136 | World world = (World) prevLoc.getExtent(); 137 | 138 | if (LightAPI.isRequireManuallySendingChanges()) { 139 | if (LightAPI.createLight(world.getName(), LightType.BLOCK, prevLoc.getBlockX(), prevLoc.getBlockY(), 140 | prevLoc.getBlockZ(), 12)) { 141 | for (IChunkData data : LightAPI.collectChunks(world.getName(), prevLoc.getBlockX(), prevLoc.getBlockY(), 142 | prevLoc.getBlockZ(), 12 / 2)) { 143 | if (!chunkQueue.contains(data)) { 144 | chunkQueue.add(data); 145 | } 146 | } 147 | if (!chunkQueue.isEmpty()) { 148 | for (IChunkData data : chunkQueue) { 149 | LightAPI.sendChanges(data); 150 | } 151 | } 152 | chunkQueue.clear(); 153 | } 154 | } 155 | } 156 | } 157 | --------------------------------------------------------------------------------