├── .gitignore ├── LICENSE ├── README.md ├── bukkit-backward-support ├── pom.xml └── 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 ├── pom.xml └── 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 │ │ ├── service │ │ └── BukkitBackgroundServiceImpl.java │ │ └── utils │ │ ├── UsageTest.java │ │ └── VersionUtil.java │ └── resources │ ├── plugin.yml │ └── storage.yml ├── bukkit-example ├── pom.xml └── src │ └── main │ ├── java │ └── ru │ │ └── beykerykt │ │ └── minecraft │ │ └── lightapi │ │ └── bukkit │ │ └── example │ │ ├── BukkitPlugin.java │ │ ├── ChunkUtils.java │ │ ├── DebugListener.java │ │ └── EntityTracker.java │ └── resources │ └── plugin.yml ├── bukkit-nms-all ├── pom.xml └── src │ └── main │ └── assembly │ └── all-jar.xml ├── common ├── pom.xml └── 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 ├── craftbukkit-common ├── dependency-reduced-pom.xml ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ ├── HandlerFactory.java │ └── nms │ └── BaseNMSHandler.java ├── craftbukkit-nms-v1_13_R2 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_13_R2 │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_14_R1 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_14_R1 │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_15_R1 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_15_R1 │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_16_R1 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_16_R1 │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_16_R2 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_16_R2 │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_16_R3 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_16_R3 │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_17_R1 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_17_R1 │ ├── StarlightNMSHandler.java │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_18_R1 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_18_R1 │ ├── StarlightNMSHandler.java │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_18_R2 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_18_R2 │ ├── StarlightNMSHandler.java │ └── VanillaNMSHandler.java ├── craftbukkit-nms-v1_19_R1 ├── pom.xml └── src │ └── main │ └── java │ └── ru │ └── beykerykt │ └── minecraft │ └── lightapi │ └── bukkit │ └── internal │ └── handler │ └── craftbukkit │ └── nms │ └── v1_19_R1 │ ├── StarlightNMSHandler.java │ └── VanillaNMSHandler.java ├── images └── logo5.png ├── pom.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-all ├── pom.xml └── src │ └── main │ └── assembly │ └── all-jar.xml └── 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 /.gitignore: -------------------------------------------------------------------------------- 1 | ### Intellij ### 2 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm 3 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 4 | 5 | # User-specific stuff 6 | .idea/**/workspace.xml 7 | .idea/**/tasks.xml 8 | .idea/**/usage.statistics.xml 9 | .idea/**/dictionaries 10 | .idea/**/shelf 11 | 12 | # Generated files 13 | .idea/**/contentModel.xml 14 | 15 | # Sensitive or high-churn files 16 | .idea/**/dataSources/ 17 | .idea/**/dataSources.ids 18 | .idea/**/dataSources.local.xml 19 | .idea/**/sqlDataSources.xml 20 | .idea/**/dynamic.xml 21 | .idea/**/uiDesigner.xml 22 | .idea/**/dbnavigator.xml 23 | 24 | # Gradle 25 | .idea/**/gradle.xml 26 | .idea/**/libraries 27 | 28 | # Gradle and Maven with auto-import 29 | # When using Gradle or Maven with auto-import, you should exclude module files, 30 | # since they will be recreated, and may cause churn. Uncomment if using 31 | # auto-import. 32 | # .idea/artifacts 33 | # .idea/compiler.xml 34 | # .idea/jarRepositories.xml 35 | # .idea/modules.xml 36 | # .idea/*.iml 37 | # .idea/modules 38 | # *.iml 39 | # *.ipr 40 | 41 | # CMake 42 | cmake-build-*/ 43 | 44 | # Mongo Explorer plugin 45 | .idea/**/mongoSettings.xml 46 | 47 | # File-based project format 48 | *.iws 49 | 50 | # IntelliJ 51 | out/ 52 | 53 | # mpeltonen/sbt-idea plugin 54 | .idea_modules/ 55 | 56 | # JIRA plugin 57 | atlassian-ide-plugin.xml 58 | 59 | # Cursive Clojure plugin 60 | .idea/replstate.xml 61 | 62 | # Crashlytics plugin (for Android Studio and IntelliJ) 63 | com_crashlytics_export_strings.xml 64 | crashlytics.properties 65 | crashlytics-build.properties 66 | fabric.properties 67 | 68 | # Editor-based Rest Client 69 | .idea/httpRequests 70 | 71 | # Android studio 3.1+ serialized cache file 72 | .idea/caches/build_file_checksums.ser 73 | 74 | ### Intellij+all Patch ### 75 | # Ignores the whole .idea folder and all .iml files 76 | # See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360 77 | 78 | .idea/ 79 | 80 | # Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023 81 | 82 | *.iml 83 | modules.xml 84 | .idea/misc.xml 85 | *.ipr 86 | 87 | # Sonarlint plugin 88 | .idea/sonarlint 89 | 90 | ### Java ### 91 | # Compiled class file 92 | *.class 93 | 94 | # Log file 95 | *.log 96 | 97 | # BlueJ files 98 | *.ctxt 99 | 100 | # Mobile Tools for Java (J2ME) 101 | .mtj.tmp/ 102 | 103 | # Package Files # 104 | *.jar 105 | *.war 106 | *.nar 107 | *.ear 108 | *.zip 109 | *.tar.gz 110 | *.rar 111 | 112 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 113 | hs_err_pid* 114 | 115 | # End of https://www.gitignore.io/api/java,intellij 116 | 117 | # Eclipse files 118 | /bin 119 | .classpath 120 | /.settings 121 | */.settings 122 | .project 123 | 124 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 125 | hs_err_pid* 126 | */target/ 127 | 128 | dependency-reduced-pom.xml 129 | .flattened-pom.xml 130 | -------------------------------------------------------------------------------- /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 | ![Image](/images/logo5.png) 2 | 3 | # LightAPI 4 | 5 | Bukkit Library for create invisible light source 6 | 7 | - [CONTRIBUTORS](https://github.com/BeYkeRYkt/LightAPI/graphs/contributors) 8 | 9 | # License 10 | 11 | ``` 12 | The MIT License (MIT) 13 | 14 | Copyright (c) 2019 Vladimir Mikhailov 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy 17 | of this software and associated documentation files (the "Software"), to deal 18 | in the Software without restriction, including without limitation the rights 19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 | copies of the Software, and to permit persons to whom the Software is 21 | furnished to do so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in all 24 | copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 | SOFTWARE. -------------------------------------------------------------------------------- /bukkit-backward-support/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-bukkit-backward-support 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 | shade 62 | 63 | package 64 | 65 | 66 | 67 | 68 | ${basedir}/src/main/java 69 | 70 | 71 | 72 | 73 | 74 | ${project.groupId} 75 | lightapi-bukkit-common 76 | ${project.version} 77 | provided 78 | jar 79 | 80 | 81 | 82 | org.spigotmc 83 | spigot-api 84 | ${spigot-api.version} 85 | provided 86 | jar 87 | 88 | 89 | 90 | 91 | 3.8.1 92 | 3.1.2 93 | 3.2.1 94 | UTF-8 95 | 1.14.4-R0.1-SNAPSHOT 96 | 97 | 98 | 99 | 100 | spigot-repo 101 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/ 102 | 103 | 104 | md_5-repo 105 | http://repo.md-5.net/content/groups/public/ 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /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 | 30 | import ru.beykerykt.lightapi.chunks.ChunkInfo; 31 | 32 | @Deprecated 33 | public class UpdateChunkEvent extends Event implements Cancellable { 34 | 35 | private static final HandlerList handlers = new HandlerList(); 36 | private boolean cancel; 37 | private ChunkInfo cCoord; 38 | 39 | public UpdateChunkEvent(ChunkInfo cCoord) { 40 | this.cCoord = cCoord; 41 | } 42 | 43 | public static HandlerList getHandlerList() { 44 | return handlers; 45 | } 46 | 47 | @Override 48 | public HandlerList getHandlers() { 49 | return handlers; 50 | } 51 | 52 | @Override 53 | public boolean isCancelled() { 54 | return cancel; 55 | } 56 | 57 | @Override 58 | public void setCancelled(boolean arg0) { 59 | this.cancel = arg0; 60 | } 61 | 62 | public ChunkInfo getChunkInfo() { 63 | return cCoord; 64 | } 65 | 66 | public void setChunkInfo(ChunkInfo cCoord) { 67 | this.cCoord = cCoord; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /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 java.util.Map; 27 | 28 | import ru.beykerykt.lightapi.server.nms.INMSHandler; 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 java.lang.reflect.InvocationTargetException; 27 | 28 | import ru.beykerykt.lightapi.server.exceptions.UnknownModImplementationException; 29 | import ru.beykerykt.lightapi.server.exceptions.UnknownNMSVersionException; 30 | import ru.beykerykt.lightapi.server.nms.INMSHandler; 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 | 29 | import java.util.Collection; 30 | import java.util.List; 31 | 32 | import ru.beykerykt.lightapi.chunks.ChunkInfo; 33 | 34 | @Deprecated 35 | public interface INMSHandler { 36 | 37 | // Lights... 38 | void createLight(World world, int x, int y, int z, int light); 39 | 40 | void deleteLight(World world, int x, int y, int z); 41 | 42 | void recalculateLight(World world, int x, int y, int z); 43 | 44 | // Chunks... 45 | List collectChunks(World world, int x, int y, int z); 46 | 47 | void sendChunkUpdate(World world, int chunkX, int chunkZ, Collection players); 48 | 49 | void sendChunkUpdate(World world, int chunkX, int chunkZ, Player player); 50 | 51 | void sendChunkUpdate(World world, int chunkX, int y, int chunkZ, Collection players); 52 | 53 | void sendChunkUpdate(World world, int chunkX, int y, int chunkZ, Player player); 54 | } 55 | -------------------------------------------------------------------------------- /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 | 28 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.IHandler; 29 | import ru.beykerykt.minecraft.lightapi.common.api.engine.EditPolicy; 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.api.extension.IExtension; 33 | 34 | public interface IBukkitExtension extends IExtension { 35 | 36 | /** 37 | * Gets the level of light from given coordinates with specific flags. 38 | */ 39 | int getLightLevel(World world, int blockX, int blockY, int blockZ); 40 | 41 | /** 42 | * Gets the level of light from given coordinates with specific flags. 43 | */ 44 | int getLightLevel(World world, int blockX, int blockY, int blockZ, int lightFlags); 45 | 46 | /** 47 | * Placement of a specific type of light with a given level of illumination in the named world in 48 | * certain coordinates with the return code result. 49 | */ 50 | int setLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel); 51 | 52 | /** 53 | * Placement of a specific type of light with a given level of illumination in the named world in 54 | * certain coordinates with the return code result. 55 | */ 56 | int setLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags); 57 | 58 | /** 59 | * Placement of a specific type of light with a given level of illumination in the named world in 60 | * certain coordinates with the return code result. 61 | */ 62 | int setLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags, 63 | ICallback callback); 64 | 65 | /** 66 | * Placement of a specific type of light with a given level of illumination in the named world in 67 | * certain coordinates with the return code result. 68 | */ 69 | int setLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags, 70 | EditPolicy editPolicy, SendPolicy sendPolicy, ICallback callback); 71 | 72 | /** 73 | * N/A 74 | */ 75 | boolean isBackwardAvailable(); 76 | 77 | /** 78 | * N/A 79 | */ 80 | boolean isCompatibilityMode(); 81 | 82 | /** 83 | * N/A 84 | */ 85 | IHandler getHandler(); 86 | } 87 | -------------------------------------------------------------------------------- /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 | 30 | import java.util.List; 31 | 32 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.BukkitPlatformImpl; 33 | import ru.beykerykt.minecraft.lightapi.common.internal.PlatformType; 34 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.data.IChunkData; 35 | import ru.beykerykt.minecraft.lightapi.common.internal.engine.LightEngineType; 36 | import ru.beykerykt.minecraft.lightapi.common.internal.engine.LightEngineVersion; 37 | 38 | public interface IHandler { 39 | 40 | /** 41 | * N/A 42 | */ 43 | void onInitialization(BukkitPlatformImpl impl) throws Exception; 44 | 45 | /** 46 | * N/A 47 | */ 48 | void onShutdown(BukkitPlatformImpl impl); 49 | 50 | /** 51 | * Platform that is being used 52 | * 53 | * @return One of the proposed options from {@link PlatformType} 54 | */ 55 | PlatformType getPlatformType(); 56 | 57 | /** 58 | * N/A 59 | */ 60 | LightEngineType getLightEngineType(); 61 | 62 | /** 63 | * Used lighting engine version. 64 | * 65 | * @return One of the proposed options from {@link LightEngineVersion} 66 | */ 67 | LightEngineVersion getLightEngineVersion(); 68 | 69 | /** 70 | * N/A 71 | */ 72 | boolean isMainThread(); 73 | 74 | /** 75 | * N/A 76 | */ 77 | void onWorldLoad(WorldLoadEvent event); 78 | 79 | /** 80 | * N/A 81 | */ 82 | void onWorldUnload(WorldUnloadEvent event); 83 | 84 | /** 85 | * N/A 86 | */ 87 | boolean isLightingSupported(World world, int lightFlags); 88 | 89 | /** 90 | * Sets "directly" the level of light in given coordinates without additional processing. 91 | */ 92 | int setRawLightLevel(World world, int blockX, int blockY, int blockZ, int lightLevel, int lightFlags); 93 | 94 | /** 95 | * Gets "directly" the level of light from given coordinates without additional processing. 96 | */ 97 | int getRawLightLevel(World world, int blockX, int blockY, int blockZ, int lightFlags); 98 | 99 | /** 100 | * Performs re-illumination of the light in the given coordinates. 101 | */ 102 | int recalculateLighting(World world, int blockX, int blockY, int blockZ, int lightFlags); 103 | 104 | /** 105 | * N/A 106 | */ 107 | IChunkData createChunkData(String worldName, int chunkX, int chunkZ); 108 | 109 | /** 110 | * Collects modified сhunks with sections around a given coordinate in the radius of the light 111 | * level. The light level is taken from the arguments. 112 | * 113 | * @return List changed chunk sections around the given coordinate. 114 | */ 115 | List collectChunkSections(World world, int blockX, int blockY, int blockZ, int lightLevel, 116 | int lightFlags); 117 | 118 | /** 119 | * N/A 120 | */ 121 | boolean isValidChunkSection(World world, int sectionY); 122 | 123 | /** 124 | * N/A 125 | */ 126 | int sendChunk(IChunkData data); 127 | 128 | /** 129 | * Can be used for specific commands 130 | */ 131 | int sendCmd(int cmdId, Object... args); 132 | } 133 | -------------------------------------------------------------------------------- /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/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 | 28 | import org.bukkit.configuration.file.FileConfiguration; 29 | 30 | import java.util.concurrent.ThreadFactory; 31 | 32 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.BukkitPlatformImpl; 33 | import ru.beykerykt.minecraft.lightapi.bukkit.internal.handler.IHandler; 34 | import ru.beykerykt.minecraft.lightapi.common.internal.service.BackgroundServiceImpl; 35 | 36 | public class BukkitBackgroundServiceImpl extends BackgroundServiceImpl { 37 | 38 | /** 39 | * CONFIG 40 | */ 41 | private final String CONFIG_TITLE = getClass().getSimpleName(); 42 | 43 | @Deprecated 44 | private final String CONFIG_TICK_PERIOD = CONFIG_TITLE + ".tick-period"; 45 | private final String CONFIG_CORE_POOL_SIZE = CONFIG_TITLE + ".corePoolSize"; 46 | 47 | private final IHandler mHandler; 48 | private int taskId = -1; 49 | private long lastAliveTime = 0; 50 | 51 | public BukkitBackgroundServiceImpl(BukkitPlatformImpl platform, IHandler handler) { 52 | super(platform); 53 | mHandler = handler; 54 | } 55 | 56 | @Override 57 | protected BukkitPlatformImpl getPlatformImpl() { 58 | return (BukkitPlatformImpl) super.getPlatformImpl(); 59 | } 60 | 61 | private IHandler getHandler() { 62 | return mHandler; 63 | } 64 | 65 | private boolean upgradeConfig() { 66 | boolean needSave = false; 67 | FileConfiguration fc = getPlatformImpl().getPlugin().getConfig(); 68 | if (fc.isSet(CONFIG_TICK_PERIOD)) { 69 | fc.set(CONFIG_TICK_PERIOD, null); 70 | needSave = true; 71 | } 72 | return needSave; 73 | } 74 | 75 | private void checkAndSetDefaults() { 76 | boolean needSave = upgradeConfig(); 77 | FileConfiguration fc = getPlatformImpl().getPlugin().getConfig(); 78 | 79 | if (!fc.isSet(CONFIG_CORE_POOL_SIZE)) { 80 | fc.set(CONFIG_CORE_POOL_SIZE, 1); 81 | needSave = true; 82 | } 83 | 84 | if (needSave) { 85 | getPlatformImpl().getPlugin().saveConfig(); 86 | } 87 | } 88 | 89 | @Override 90 | public void onStart() { 91 | checkAndSetDefaults(); 92 | 93 | // executor service 94 | ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat( 95 | "lightapi-background-thread-%d").build(); 96 | FileConfiguration fc = getPlatformImpl().getPlugin().getConfig(); 97 | int corePoolSize = fc.getInt(CONFIG_CORE_POOL_SIZE); 98 | configureExecutorService(corePoolSize, namedThreadFactory); 99 | 100 | // heartbeat 101 | taskId = getPlatformImpl().getPlugin().getServer().getScheduler().runTaskTimer(getPlatformImpl().getPlugin(), 102 | () -> lastAliveTime = System.currentTimeMillis(), 0, 1).getTaskId(); 103 | } 104 | 105 | @Override 106 | public void onShutdown() { 107 | if (taskId != -1) { 108 | getPlatformImpl().getPlugin().getServer().getScheduler().cancelTask(taskId); 109 | } 110 | super.onShutdown(); 111 | } 112 | 113 | @Override 114 | public boolean canExecuteSync(long maxTime) { 115 | return ((System.currentTimeMillis() - lastAliveTime) < maxTime); 116 | } 117 | 118 | @Override 119 | public boolean isMainThread() { 120 | return getHandler().isMainThread(); 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /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: ${SERVER_API}-${project.version} (build ${BUILD_NUMBER}) 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/BeYkeRYkt/LightAPI/4c8e01d509db1da0cf2ab437b1e92ade6b5c673c/bukkit-common/src/main/resources/storage.yml -------------------------------------------------------------------------------- /bukkit-example/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-bukkit-example 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 | 56 | 57 | src/main/resources/ 58 | true 59 | 60 | 61 | ${basedir}/src/main/java 62 | 63 | 64 | 65 | 66 | 67 | ${project.groupId} 68 | lightapi-bukkit-common 69 | ${project.version} 70 | compile 71 | jar 72 | 73 | 74 | 75 | ${project.groupId} 76 | lightapi-common 77 | ${project.version} 78 | compile 79 | jar 80 | 81 | 82 | 83 | org.spigotmc 84 | spigot-api 85 | ${spigot-api.version} 86 | provided 87 | jar 88 | 89 | 90 | 91 | 92 | bukkit 93 | 3.8.1 94 | 3.1.2 95 | UTF-8 96 | 1.13.2-R0.1-SNAPSHOT 97 | 98 | 99 | 100 | 101 | spigot-repo 102 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/ 103 | 104 | 105 | md_5-repo 106 | http://repo.md-5.net/content/groups/public/ 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /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 java.util.ArrayList; 27 | import java.util.Iterator; 28 | import java.util.List; 29 | 30 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.data.IChunkData; 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-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 | -------------------------------------------------------------------------------- /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-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.codehaus.mojo 56 | buildnumber-maven-plugin 57 | ${buildnumber-maven-plugin.version} 58 | 59 | 60 | 61 | create 62 | 63 | validate 64 | 65 | 66 | 67 | 68 | 69 | 70 | src/main/resources/ 71 | true 72 | 73 | 74 | ${basedir}/src/main/java 75 | 76 | 77 | 78 | 1.4 79 | 3.8.1 80 | 3.1.2 81 | UTF-8 82 | 83 | 84 | -------------------------------------------------------------------------------- /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 java.util.UUID; 27 | 28 | import ru.beykerykt.minecraft.lightapi.common.api.extension.IExtension; 29 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.observer.IChunkObserver; 30 | import ru.beykerykt.minecraft.lightapi.common.internal.engine.ILightEngine; 31 | import ru.beykerykt.minecraft.lightapi.common.internal.service.IBackgroundService; 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 java.util.BitSet; 27 | 28 | import ru.beykerykt.minecraft.lightapi.common.api.engine.LightFlag; 29 | import ru.beykerykt.minecraft.lightapi.common.internal.utils.FlagUtils; 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 java.util.List; 27 | 28 | import ru.beykerykt.minecraft.lightapi.common.internal.chunks.data.IChunkData; 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 | COMPATIBILITY(3); 31 | 32 | private final int id; 33 | 34 | LightEngineType(int id) { 35 | this.id = id; 36 | } 37 | 38 | public int getId() { 39 | return id; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /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 java.util.concurrent.Executors; 28 | import java.util.concurrent.ScheduledExecutorService; 29 | import java.util.concurrent.ScheduledFuture; 30 | import java.util.concurrent.ThreadFactory; 31 | import java.util.concurrent.TimeUnit; 32 | 33 | import ru.beykerykt.minecraft.lightapi.common.internal.IPlatformImpl; 34 | 35 | public abstract class BackgroundServiceImpl implements IBackgroundService { 36 | private ScheduledExecutorService executorService; 37 | private IPlatformImpl mPlatform; 38 | 39 | public BackgroundServiceImpl(IPlatformImpl platform) { 40 | this.mPlatform = platform; 41 | } 42 | 43 | protected IPlatformImpl getPlatformImpl() { 44 | return this.mPlatform; 45 | } 46 | 47 | protected void configureExecutorService(int corePoolSize, ThreadFactory namedThreadFactory) { 48 | if (this.executorService == null) { 49 | this.executorService = Executors.newScheduledThreadPool(corePoolSize, namedThreadFactory); 50 | } 51 | } 52 | 53 | protected ScheduledExecutorService getExecutorService() { 54 | return this.executorService; 55 | } 56 | 57 | @Override 58 | public void onShutdown() { 59 | if (getExecutorService() != null) { 60 | getExecutorService().shutdown(); 61 | try { 62 | if (!getExecutorService().awaitTermination(10, TimeUnit.SECONDS)) { 63 | getPlatformImpl().info("Still waiting after 10 seconds: Shutdown now."); 64 | getExecutorService().shutdownNow(); 65 | } 66 | } catch (InterruptedException e) { 67 | // (Re-)Cancel if current thread also interrupted 68 | getExecutorService().shutdownNow(); 69 | // Preserve interrupt status 70 | Thread.currentThread().interrupt(); 71 | } 72 | } 73 | } 74 | 75 | @Override 76 | public ScheduledFuture scheduleWithFixedDelay(Runnable runnable, int initialDelay, int delay, TimeUnit unit) { 77 | return getExecutorService().scheduleWithFixedDelay(runnable, initialDelay, delay, unit); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /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/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. -------------------------------------------------------------------------------- /craftbukkit-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-craftbukkit-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 | 56 | 57 | src/main/resources/ 58 | true 59 | 60 | 61 | ${basedir}/src/main/java 62 | 63 | 64 | 65 | 66 | 67 | ${project.groupId} 68 | lightapi-bukkit-common 69 | ${project.version} 70 | compile 71 | jar 72 | 73 | 74 | 75 | org.bukkit 76 | bukkit 77 | ${bukkit.version} 78 | provided 79 | jar 80 | 81 | 82 | 83 | org.spigotmc 84 | spigot-api 85 | ${spigot-api.version} 86 | provided 87 | jar 88 | 89 | 90 | 91 | 92 | 1.13.2-R0.1-SNAPSHOT 93 | 3.8.1 94 | 3.1.2 95 | UTF-8 96 | 1.13.2-R0.1-SNAPSHOT 97 | 98 | 99 | 100 | 101 | spigot-repo 102 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/ 103 | 104 | 105 | md_5-repo 106 | http://repo.md-5.net/content/groups/public/ 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /craftbukkit-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 | 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.bukkit.internal.handler.IHandlerFactory; 32 | 33 | public class HandlerFactory implements IHandlerFactory { 34 | 35 | private static final String CRAFTBUKKIT_PKG = "org.bukkit.craftbukkit"; 36 | private static final String[] STARLIGHT_ENGINE_PKG = { 37 | "ca.spottedleaf.starlight.light.StarLightEngine", 38 | "ca.spottedleaf.starlight.common.light.StarLightEngine" 39 | }; 40 | private BukkitPlatformImpl mPlatformImpl; 41 | 42 | private BukkitPlatformImpl getPlatformImpl() { 43 | return mPlatformImpl; 44 | } 45 | 46 | private boolean isStarlight() { 47 | for (String pkg : STARLIGHT_ENGINE_PKG) { 48 | try { 49 | Class.forName(pkg); 50 | return true; 51 | } catch (ClassNotFoundException e) { 52 | getPlatformImpl().debug("Class " + pkg + " not found"); 53 | } 54 | } 55 | return false; 56 | } 57 | 58 | @Override 59 | public IHandler createHandler(BukkitPlatformImpl impl) throws Exception { 60 | this.mPlatformImpl = impl; 61 | IHandler handler = null; 62 | String serverImplPackage = Bukkit.getServer().getClass().getPackage().getName(); 63 | 64 | if (serverImplPackage.startsWith(CRAFTBUKKIT_PKG)) { // make sure it's craftbukkit 65 | String[] line = serverImplPackage.replace(".", ",").split(","); 66 | String version = line[3]; 67 | 68 | String handlerClassName = (isStarlight() ? "Starlight" : "Vanilla") + "NMSHandler"; 69 | String handlerPath = getClass().getPackage().getName() + ".nms." + version + "." + handlerClassName; 70 | // start using nms handler 71 | handler = (IHandler) Class.forName(handlerPath).getConstructor().newInstance(); 72 | } else { // something else 73 | throw new NotImplementedException(Bukkit.getName() + " is currently not supported."); 74 | } 75 | return handler; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /craftbukkit-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 | 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.PlatformType; 31 | 32 | public abstract class BaseNMSHandler implements IHandler { 33 | 34 | private BukkitPlatformImpl mPlatformImpl; 35 | 36 | @Override 37 | public void onInitialization(BukkitPlatformImpl impl) throws Exception { 38 | this.mPlatformImpl = impl; 39 | } 40 | 41 | protected BukkitPlatformImpl getPlatformImpl() { 42 | return mPlatformImpl; 43 | } 44 | 45 | @Override 46 | public PlatformType getPlatformType() { 47 | return PlatformType.CRAFTBUKKIT; 48 | } 49 | 50 | @Override 51 | public boolean isMainThread() { 52 | return Bukkit.isPrimaryThread(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /craftbukkit-nms-v1_13_R2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-craftbukkit-nms-v1_13_R2 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 | shade 62 | 63 | package 64 | 65 | 66 | 67 | 68 | ${basedir}/src/main/java 69 | 70 | 71 | 72 | 73 | 74 | ${project.groupId} 75 | lightapi-craftbukkit-common 76 | ${project.version} 77 | provided 78 | jar 79 | 80 | 81 | 82 | org.spigotmc 83 | spigot 84 | ${spigot.version} 85 | provided 86 | 87 | 88 | 89 | 90 | 3.8.1 91 | 3.1.2 92 | 3.2.1 93 | UTF-8 94 | 1.13.2-R0.1-SNAPSHOT 95 | 96 | 97 | -------------------------------------------------------------------------------- /craftbukkit-nms-v1_14_R1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-craftbukkit-nms-v1_14_R1 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 | shade 62 | 63 | package 64 | 65 | 66 | 67 | 68 | ${basedir}/src/main/java 69 | 70 | 71 | 72 | 73 | 74 | ${project.groupId} 75 | lightapi-craftbukkit-common 76 | ${project.version} 77 | provided 78 | jar 79 | 80 | 81 | 82 | org.spigotmc 83 | spigot 84 | ${spigot.version} 85 | provided 86 | 87 | 88 | 89 | 90 | 3.8.1 91 | 3.1.2 92 | 3.2.1 93 | UTF-8 94 | 1.14.4-R0.1-SNAPSHOT 95 | 96 | 97 | -------------------------------------------------------------------------------- /craftbukkit-nms-v1_15_R1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-craftbukkit-nms-v1_15_R1 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 | shade 62 | 63 | package 64 | 65 | 66 | 67 | 68 | ${basedir}/src/main/java 69 | 70 | 71 | 72 | 73 | 74 | ${project.groupId} 75 | lightapi-craftbukkit-common 76 | ${project.version} 77 | provided 78 | jar 79 | 80 | 81 | 82 | org.spigotmc 83 | spigot 84 | ${spigot.version} 85 | provided 86 | 87 | 88 | 89 | 90 | 3.8.1 91 | 3.1.2 92 | 3.2.1 93 | UTF-8 94 | 1.15.2-R0.1-SNAPSHOT 95 | 96 | 97 | -------------------------------------------------------------------------------- /craftbukkit-nms-v1_16_R1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-craftbukkit-nms-v1_16_R1 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 | shade 62 | 63 | package 64 | 65 | 66 | 67 | 68 | ${basedir}/src/main/java 69 | 70 | 71 | 72 | 73 | 74 | ${project.groupId} 75 | lightapi-craftbukkit-common 76 | ${project.version} 77 | provided 78 | jar 79 | 80 | 81 | 82 | org.spigotmc 83 | spigot 84 | ${spigot.version} 85 | provided 86 | 87 | 88 | 89 | 90 | 3.8.1 91 | 3.1.2 92 | 3.2.1 93 | UTF-8 94 | 1.16.1-R0.1-SNAPSHOT 95 | 96 | 97 | -------------------------------------------------------------------------------- /craftbukkit-nms-v1_16_R2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-craftbukkit-nms-v1_16_R2 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 | shade 62 | 63 | package 64 | 65 | 66 | 67 | 68 | ${basedir}/src/main/java 69 | 70 | 71 | 72 | 73 | 74 | ${project.groupId} 75 | lightapi-craftbukkit-common 76 | ${project.version} 77 | provided 78 | jar 79 | 80 | 81 | 82 | org.spigotmc 83 | spigot 84 | ${spigot.version} 85 | provided 86 | 87 | 88 | 89 | 90 | 3.8.1 91 | 3.1.2 92 | 3.2.1 93 | UTF-8 94 | 1.16.2-R0.1-SNAPSHOT 95 | 96 | 97 | -------------------------------------------------------------------------------- /craftbukkit-nms-v1_16_R3/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-craftbukkit-nms-v1_16_R3 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 | shade 62 | 63 | package 64 | 65 | 66 | 67 | 68 | ${basedir}/src/main/java 69 | 70 | 71 | 72 | 73 | 74 | ${project.groupId} 75 | lightapi-craftbukkit-common 76 | ${project.version} 77 | provided 78 | jar 79 | 80 | 81 | 82 | org.spigotmc 83 | spigot 84 | ${spigot.version} 85 | provided 86 | 87 | 88 | 89 | 90 | 3.8.1 91 | 3.1.2 92 | 3.2.1 93 | UTF-8 94 | 1.16.5-R0.1-SNAPSHOT 95 | 96 | 97 | -------------------------------------------------------------------------------- /craftbukkit-nms-v1_17_R1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 29 | 30 | ru.beykerykt.minecraft 31 | lightapi-parent 32 | ${revision} 33 | 34 | 4.0.0 35 | lightapi-craftbukkit-nms-v1_17_R1 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 | shade 62 | 63 | package 64 | 65 | 66 | 67 | 68 | ${basedir}/src/main/java 69 | 70 | 71 | 72 | 73 | 74 | ${project.groupId} 75 | lightapi-craftbukkit-common 76 | ${project.version} 77 | provided 78 | jar 79 | 80 | 81 | 82 | io.papermc.paper 83 | paper 84 | ${paper.version} 85 | system 86 | ${project.basedir}/lib/Paper-Server-reobf.jar 87 | 88 | 89 | 90 | 91 | 3.8.1 92 | 3.1.2 93 | 3.2.1 94 | 1.17.1-R0.1-SNAPSHOT 95 | UTF-8 96 | 97 | 98 | -------------------------------------------------------------------------------- /images/logo5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BeYkeRYkt/LightAPI/4c8e01d509db1da0cf2ab437b1e92ade6b5c673c/images/logo5.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 28 | 4.0.0 29 | ru.beykerykt.minecraft 30 | lightapi-parent 31 | ${revision} 32 | pom 33 | 34 | 35 | clean compile install 36 | 37 | 38 | org.codehaus.mojo 39 | flatten-maven-plugin 40 | ${flatten-maven-plugin.version} 41 | 42 | true 43 | resolveCiFriendliesOnly 44 | 45 | 46 | 47 | flatten 48 | process-resources 49 | 50 | flatten 51 | 52 | 53 | 54 | flatten.clean 55 | clean 56 | 57 | clean 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | common 68 | 69 | bukkit-common 70 | bukkit-example 71 | bukkit-nms-all 72 | bukkit-backward-support 73 | 74 | craftbukkit-common 75 | craftbukkit-nms-v1_13_R2 76 | craftbukkit-nms-v1_14_R1 77 | craftbukkit-nms-v1_15_R1 78 | craftbukkit-nms-v1_16_R1 79 | craftbukkit-nms-v1_16_R2 80 | craftbukkit-nms-v1_16_R3 81 | craftbukkit-nms-v1_17_R1 82 | craftbukkit-nms-v1_18_R1 83 | craftbukkit-nms-v1_18_R2 84 | craftbukkit-nms-v1_19_R1 85 | 86 | 89 | 90 | 91 | 92 | SNAPSHOT 93 | Unknown 94 | 1.1.0 95 | UTF-8 96 | 5.3.0 97 | 98 | 99 | 100 | scm:git:ssh://github.com/BeYkeRYkt/LightAPI 101 | scm:git:ssh://github.com/BeYkeRYkt/LightAPI 102 | 103 | 104 | -------------------------------------------------------------------------------- /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 | InvocationTargetException | NoSuchMethodException | SecurityException | ClassNotFoundException e) { 54 | e.printStackTrace(); 55 | } 56 | return null; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /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-mcp-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-mcp-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 | --------------------------------------------------------------------------------