├── lib └── MobPlugin-1.15.0.jar ├── src └── main │ ├── resources │ ├── schematics │ │ ├── double.schematic │ │ ├── harder.schematic │ │ ├── island.schematic │ │ ├── nether.schematic │ │ ├── featured.schematic │ │ └── configuration.yml │ ├── worlds.yml │ ├── plugin.yml │ └── locale │ │ ├── en_US.yml │ │ └── de_DE.yml │ └── java │ ├── com │ └── larryTheCoder │ │ ├── utils │ │ ├── MoneyUtils.java │ │ ├── integration │ │ │ ├── economy │ │ │ │ ├── Economy.java │ │ │ │ └── EconomyAPI.java │ │ │ └── luckperms │ │ │ │ ├── InternalPermission.java │ │ │ │ ├── Permission.java │ │ │ │ └── LuckPermsPermission.java │ │ ├── Pair.java │ │ ├── BlockUtil.java │ │ ├── IslandAwaitStore.java │ │ ├── Settings.java │ │ └── classpath │ │ │ └── Autoloader.java │ │ ├── events │ │ ├── SkyBlockPlayerEvent.java │ │ ├── IslandCalculateLevelEvent.java │ │ ├── IslandTeleportEvent.java │ │ ├── IslandCalculateFinishEvent.java │ │ ├── IslandEnterEvent.java │ │ ├── IslandExitEvent.java │ │ ├── IslandCreateEvent.java │ │ └── SkyBlockEvent.java │ │ ├── database │ │ ├── QueryInfo.java │ │ └── config │ │ │ ├── AbstractConfig.java │ │ │ ├── SQLiteConfig.java │ │ │ └── MySQLConfig.java │ │ ├── command │ │ └── category │ │ │ ├── QuestCategory.java │ │ │ ├── SubCategory.java │ │ │ ├── ChatCategory.java │ │ │ └── IslandCategory.java │ │ ├── ASkyBlockAPI.java │ │ ├── cache │ │ ├── builder │ │ │ ├── IslandDataBuilder.java │ │ │ └── WorldSettingsBuilder.java │ │ ├── settings │ │ │ └── WorldSettings.java │ │ └── CoopData.java │ │ ├── listener │ │ ├── nms │ │ │ └── MobPluginListener.java │ │ ├── Action.java │ │ └── invitation │ │ │ ├── InvitationHandler.java │ │ │ └── Invitation.java │ │ ├── task │ │ ├── SimpleFancyTitle.java │ │ ├── TaskManager.java │ │ └── UpdateBiomeTask.java │ │ ├── SkyBlockGenerator.java │ │ ├── locales │ │ └── FileLister.java │ │ └── Messages.java │ └── org │ └── jnbt │ ├── EndTag.java │ ├── Tag.java │ ├── IntTag.java │ ├── ByteTag.java │ ├── LongTag.java │ ├── FloatTag.java │ ├── ShortTag.java │ ├── DoubleTag.java │ ├── StringTag.java │ ├── NBTConstants.java │ ├── ByteArrayTag.java │ ├── CompoundTag.java │ ├── ListTag.java │ └── NBTUtils.java ├── .gitignore └── LICENSE /lib/MobPlugin-1.15.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larryTheCoder/ASkyBlock/HEAD/lib/MobPlugin-1.15.0.jar -------------------------------------------------------------------------------- /src/main/resources/schematics/double.schematic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larryTheCoder/ASkyBlock/HEAD/src/main/resources/schematics/double.schematic -------------------------------------------------------------------------------- /src/main/resources/schematics/harder.schematic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larryTheCoder/ASkyBlock/HEAD/src/main/resources/schematics/harder.schematic -------------------------------------------------------------------------------- /src/main/resources/schematics/island.schematic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larryTheCoder/ASkyBlock/HEAD/src/main/resources/schematics/island.schematic -------------------------------------------------------------------------------- /src/main/resources/schematics/nether.schematic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larryTheCoder/ASkyBlock/HEAD/src/main/resources/schematics/nether.schematic -------------------------------------------------------------------------------- /src/main/resources/schematics/featured.schematic: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/larryTheCoder/ASkyBlock/HEAD/src/main/resources/schematics/featured.schematic -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | 3 | # Intellij Platforms 4 | *.iml 5 | .idea 6 | .idea/* 7 | 8 | # Eclipse Platforms 9 | .classpath 10 | .project 11 | .settings 12 | .settings/* 13 | 14 | # Others 15 | *.txt 16 | /test/ 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Adapted from the Wizardry License 2 | 3 | Copyright (c) 2016-2020 larryTheCoder and contributors 4 | 5 | Permission is hereby granted to any persons and/or organizations 6 | using this software to copy, modify, merge, publish, and distribute it. 7 | Said persons and/or organizations are not allowed to use the software or 8 | any derivatives of the work for commercial use or any other means to generate 9 | income, nor are they allowed to claim this software as their own. 10 | 11 | The persons and/or organizations are also disallowed from sub-licensing 12 | and/or trademarking this software without explicit permission from larryTheCoder. 13 | 14 | Any persons and/or organizations using this software must disclose their 15 | source code and have it publicly available, include this license, 16 | provide sufficient credit to the original authors of the project (IE: larryTheCoder), 17 | as well as provide a link to the original project. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 20 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 21 | PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 24 | USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/MoneyUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.utils; 28 | 29 | /** 30 | * @author larryTheCoder 31 | */ 32 | class MoneyUtils { 33 | //todo 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/integration/economy/Economy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.utils.integration.economy; 28 | 29 | import cn.nukkit.Player; 30 | 31 | /** 32 | * @author larryTheCoder 33 | */ 34 | public interface Economy { 35 | 36 | boolean reduceMoney(Player p, double amount); 37 | 38 | boolean addMoney(Player p, double amount); 39 | 40 | double getMoney(Player p); 41 | } 42 | -------------------------------------------------------------------------------- /src/main/resources/worlds.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################### 2 | # This is a YML file. Be careful when editing. Check your edits in a YAML checker like # 3 | # the one at http://yaml-online-parser.appspot.com # 4 | ########################################################################################### 5 | # This is an worlds modifier (This is a config for your worlds) 6 | # New feature for multi world, Of course for ranked servers 7 | --- 8 | # Name must be an exact name with level 9 | # create level before attempting to do this 10 | # Island file will be auto generated when u create a new island world 11 | SkyBlock: 12 | # This is your island Permission 13 | permission: "is.create" 14 | # Maximum island in this world 15 | maxHome: 2 16 | # This is your island plot size 17 | plotSize: 200 18 | # Same in the config. 19 | # This is a default protection range (even number). Min = 0, Recommended = 100 20 | # Larger values will take longer to calculate the island level 21 | # For optimal performance, keep protection range at least 16 blocks less than distance. 22 | protectionRange: 100 23 | # Level Information 24 | # Stop the time in island world 25 | # Recommended to not set this to 'true' because it will change the game 26 | # Environment. 27 | stopTime: false 28 | # Sea level height (don't changes this mid-game unless you delete the world) 29 | # Minimum is 0, which means you are playing sky block! 30 | # If sea level is less than about 10, then players will drop right through it 31 | # if it exists. Makes for an interesting variation on SkyBlock. 32 | seaLevel: 0 33 | # As requested, custom sign configurations. This section must be an array, 34 | # you can also use '&' as colour codes. The configuration are as follow: 35 | # [player] -> The player name 36 | signConfig: 37 | - "&aWelcome to" 38 | - "&e[player]'s" 39 | - "&aIsland! Enjoy." 40 | - "" -------------------------------------------------------------------------------- /src/main/java/org/jnbt/EndTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_End tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class EndTag extends Tag { 36 | 37 | /** 38 | * Creates the tag. 39 | */ 40 | public EndTag() { 41 | super(""); 42 | } 43 | 44 | @Override 45 | public Object getValue() { 46 | return null; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "TAG_End"; 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/events/SkyBlockPlayerEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.events; 29 | 30 | import cn.nukkit.Player; 31 | import com.larryTheCoder.cache.IslandData; 32 | import lombok.Getter; 33 | 34 | public class SkyBlockPlayerEvent extends SkyBlockEvent { 35 | 36 | /** 37 | * The player class 38 | */ 39 | @Getter 40 | private final Player player; 41 | 42 | public SkyBlockPlayerEvent(Player player, IslandData island) { 43 | super(island); 44 | 45 | this.player = player; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/events/IslandCalculateLevelEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.events; 29 | 30 | import cn.nukkit.event.Cancellable; 31 | import com.larryTheCoder.cache.IslandData; 32 | 33 | /** 34 | * An island level calculation event. This event will be called before 35 | * the island is being calculated, you can cancel this event if its needed. 36 | */ 37 | public class IslandCalculateLevelEvent extends SkyBlockEvent implements Cancellable { 38 | public IslandCalculateLevelEvent(IslandData island) { 39 | super(island); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.utils; 28 | 29 | public class Pair { 30 | private final int left; 31 | private final int right; 32 | 33 | public Pair(int left, int right) { 34 | this.left = left; 35 | this.right = right; 36 | } 37 | 38 | public int getLeft() { 39 | return left; 40 | } 41 | 42 | public int getRight() { 43 | return right; 44 | } 45 | 46 | @Override 47 | public boolean equals(Object o) { 48 | if (o == null) 49 | return false; 50 | if (!(o instanceof Pair)) 51 | return false; 52 | Pair pairo = (Pair) o; 53 | return (this.left == pairo.getLeft()) && (this.right == pairo.getRight()); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/BlockUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.utils; 28 | 29 | import cn.nukkit.block.Block; 30 | 31 | import java.util.Arrays; 32 | import java.util.Collection; 33 | 34 | /** 35 | * @author larryTheCoder 36 | */ 37 | public enum BlockUtil { 38 | ; 39 | private static final Collection FLUIDS = Arrays.asList(Block.STILL_WATER, Block.WATER, Block.LAVA, Block.STILL_LAVA); 40 | 41 | public static boolean isBreathable(Block block) { 42 | return !block.isSolid() && !isFluid(block); 43 | } 44 | 45 | public static boolean isFluid(Block block) { 46 | return FLUIDS.contains(block.getId()); 47 | } 48 | 49 | public static boolean isFluid(int type) { 50 | return FLUIDS.contains(type); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/jnbt/Tag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * Represents a single NBT tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public abstract class Tag { 36 | 37 | /** 38 | * The name of this tag. 39 | */ 40 | private final String name; 41 | 42 | /** 43 | * Creates the tag with the specified name. 44 | * 45 | * @param name The name. 46 | */ 47 | public Tag(String name) { 48 | this.name = name; 49 | } 50 | 51 | /** 52 | * Gets the name of this tag. 53 | * 54 | * @return The name of this tag. 55 | */ 56 | public final String getName() { 57 | return name; 58 | } 59 | 60 | /** 61 | * Gets the value of this tag. 62 | * 63 | * @return The value of this tag. 64 | */ 65 | public abstract Object getValue(); 66 | 67 | } -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/events/IslandTeleportEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.events; 29 | 30 | import cn.nukkit.Player; 31 | import cn.nukkit.event.Cancellable; 32 | import cn.nukkit.level.Location; 33 | import com.larryTheCoder.cache.IslandData; 34 | import lombok.Getter; 35 | import lombok.Setter; 36 | 37 | /** 38 | * This event will be called when the player are attempting to teleport to the 39 | * desired island location. The island can be the player's island or another island. 40 | */ 41 | public class IslandTeleportEvent extends SkyBlockPlayerEvent implements Cancellable { 42 | 43 | @Getter @Setter 44 | private Location teleportLocation; 45 | 46 | public IslandTeleportEvent(Player player, IslandData island, Location targetLocation) { 47 | super(player, island); 48 | 49 | this.teleportLocation = targetLocation; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/database/QueryInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.database; 28 | 29 | import lombok.Builder; 30 | import lombok.Getter; 31 | import lombok.NonNull; 32 | 33 | import java.util.List; 34 | import java.util.Vector; 35 | 36 | public class QueryInfo { 37 | 38 | @Getter 39 | public final String query; 40 | @Getter 41 | public final List parameter = new Vector<>(); 42 | 43 | public QueryInfo(@NonNull String query) { 44 | this.query = query; 45 | } 46 | 47 | public QueryInfo addParameter(@NonNull String data, Object object) { 48 | parameter.add(Parameter.builder().paramName(data).value(object).build()); 49 | 50 | return this; 51 | } 52 | 53 | @Builder 54 | public static class Parameter { 55 | @Getter @NonNull 56 | public String paramName; 57 | @Getter 58 | public Object value; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/events/IslandCalculateFinishEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.events; 29 | 30 | import cn.nukkit.event.Cancellable; 31 | import com.larryTheCoder.cache.IslandData; 32 | import lombok.Getter; 33 | import lombok.Setter; 34 | 35 | /** 36 | * An event in which the island has successfully calculates their island 37 | * level, this event will be called so that the developers can modify the amount of 38 | * scores that the player's island will get. 39 | */ 40 | public class IslandCalculateFinishEvent extends SkyBlockEvent implements Cancellable { 41 | 42 | @Getter 43 | private final int lastLevel; 44 | @Getter @Setter 45 | private int islandLevel; 46 | 47 | public IslandCalculateFinishEvent(IslandData island, int islandLevel, int lastLevel) { 48 | super(island); 49 | 50 | this.islandLevel = islandLevel; 51 | this.lastLevel = lastLevel; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/jnbt/IntTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_Int tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class IntTag extends Tag { 36 | 37 | /** 38 | * The value. 39 | */ 40 | private final int value; 41 | 42 | /** 43 | * Creates the tag. 44 | * 45 | * @param name The name. 46 | * @param value The value. 47 | */ 48 | public IntTag(String name, int value) { 49 | super(name); 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public Integer getValue() { 55 | return value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String name = getName(); 61 | String append = ""; 62 | if (name != null && !name.equals("")) { 63 | append = "(\"" + this.getName() + "\")"; 64 | } 65 | return "TAG_Int" + append + ": " + value; 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/org/jnbt/ByteTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_Byte tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class ByteTag extends Tag { 36 | 37 | /** 38 | * The value. 39 | */ 40 | private final byte value; 41 | 42 | /** 43 | * Creates the tag. 44 | * 45 | * @param name The name. 46 | * @param value The value. 47 | */ 48 | public ByteTag(String name, byte value) { 49 | super(name); 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public Byte getValue() { 55 | return value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String name = getName(); 61 | String append = ""; 62 | if (name != null && !name.equals("")) { 63 | append = "(\"" + this.getName() + "\")"; 64 | } 65 | return "TAG_Byte" + append + ": " + value; 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/org/jnbt/LongTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_Long tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class LongTag extends Tag { 36 | 37 | /** 38 | * The value. 39 | */ 40 | private final long value; 41 | 42 | /** 43 | * Creates the tag. 44 | * 45 | * @param name The name. 46 | * @param value The value. 47 | */ 48 | public LongTag(String name, long value) { 49 | super(name); 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public Long getValue() { 55 | return value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String name = getName(); 61 | String append = ""; 62 | if (name != null && !name.equals("")) { 63 | append = "(\"" + this.getName() + "\")"; 64 | } 65 | return "TAG_Long" + append + ": " + value; 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/org/jnbt/FloatTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_Float tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class FloatTag extends Tag { 36 | 37 | /** 38 | * The value. 39 | */ 40 | private final float value; 41 | 42 | /** 43 | * Creates the tag. 44 | * 45 | * @param name The name. 46 | * @param value The value. 47 | */ 48 | public FloatTag(String name, float value) { 49 | super(name); 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public Float getValue() { 55 | return value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String name = getName(); 61 | String append = ""; 62 | if (name != null && !name.equals("")) { 63 | append = "(\"" + this.getName() + "\")"; 64 | } 65 | return "TAG_Float" + append + ": " + value; 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/org/jnbt/ShortTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_Short tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class ShortTag extends Tag { 36 | 37 | /** 38 | * The value. 39 | */ 40 | private final short value; 41 | 42 | /** 43 | * Creates the tag. 44 | * 45 | * @param name The name. 46 | * @param value The value. 47 | */ 48 | public ShortTag(String name, short value) { 49 | super(name); 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public Short getValue() { 55 | return value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String name = getName(); 61 | String append = ""; 62 | if (name != null && !name.equals("")) { 63 | append = "(\"" + this.getName() + "\")"; 64 | } 65 | return "TAG_Short" + append + ": " + value; 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/org/jnbt/DoubleTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_Double tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class DoubleTag extends Tag { 36 | 37 | /** 38 | * The value. 39 | */ 40 | private final double value; 41 | 42 | /** 43 | * Creates the tag. 44 | * 45 | * @param name The name. 46 | * @param value The value. 47 | */ 48 | public DoubleTag(String name, double value) { 49 | super(name); 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public Double getValue() { 55 | return value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String name = getName(); 61 | String append = ""; 62 | if (name != null && !name.equals("")) { 63 | append = "(\"" + this.getName() + "\")"; 64 | } 65 | return "TAG_Double" + append + ": " + value; 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/org/jnbt/StringTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_String tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class StringTag extends Tag { 36 | 37 | /** 38 | * The value. 39 | */ 40 | private final String value; 41 | 42 | /** 43 | * Creates the tag. 44 | * 45 | * @param name The name. 46 | * @param value The value. 47 | */ 48 | public StringTag(String name, String value) { 49 | super(name); 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public String getValue() { 55 | return value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | String name = getName(); 61 | String append = ""; 62 | if (name != null && !name.equals("")) { 63 | append = "(\"" + this.getName() + "\")"; 64 | } 65 | return "TAG_String" + append + ": " + value; 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/events/IslandEnterEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.events; 28 | 29 | import cn.nukkit.Player; 30 | import cn.nukkit.level.Location; 31 | import com.larryTheCoder.cache.IslandData; 32 | import lombok.Getter; 33 | 34 | /** 35 | * Fired when a player enters an island's area 36 | * 37 | * @author larryTheCoder 38 | * @author tastybento 39 | */ 40 | public class IslandEnterEvent extends SkyBlockPlayerEvent { 41 | 42 | /** 43 | * Location of where the player entered the island or tried to enter 44 | */ 45 | @Getter 46 | private final Location location; 47 | 48 | /** 49 | * Called to create the event 50 | * 51 | * @param island The island where the player is entering to 52 | * @param loc Location of where the player entered the island or tried to enter 53 | */ 54 | public IslandEnterEvent(Player player, IslandData island, Location loc) { 55 | super(player, island); 56 | this.location = loc; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/events/IslandExitEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.events; 28 | 29 | import cn.nukkit.Player; 30 | import cn.nukkit.level.Location; 31 | import com.larryTheCoder.cache.IslandData; 32 | import lombok.Getter; 33 | 34 | /** 35 | * Fired when a player exits an island's protected area 36 | * 37 | * @author larryTheCoder 38 | * @author tastybento 39 | */ 40 | public class IslandExitEvent extends SkyBlockPlayerEvent { 41 | 42 | /** 43 | * Location of where the player exited the island's protected area. 44 | */ 45 | @Getter 46 | private final Location location; 47 | 48 | /** 49 | * @param player The player who is leaving the island 50 | * @param island The island that the player is leaving 51 | * @param location Location of where the player exited the island's protected area 52 | */ 53 | public IslandExitEvent(Player player, IslandData island, Location location) { 54 | super(player, island); 55 | this.location = location; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/jnbt/NBTConstants.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | import java.nio.charset.Charset; 31 | import java.nio.charset.StandardCharsets; 32 | 33 | /** 34 | * A class which holds constant values. 35 | * 36 | * @author Graham Edgecombe 37 | */ 38 | public final class NBTConstants { 39 | 40 | /** 41 | * The character set used by NBT (UTF-8). 42 | */ 43 | public static final Charset CHARSET = StandardCharsets.UTF_8; 44 | 45 | /** 46 | * Tag type constants. 47 | */ 48 | public static final int 49 | TYPE_END = 0x0, 50 | TYPE_BYTE = 0x1, 51 | TYPE_SHORT = 0x2, 52 | TYPE_INT = 0x3, 53 | TYPE_LONG = 0x4, 54 | TYPE_FLOAT = 0x5, 55 | TYPE_DOUBLE = 0x6, 56 | TYPE_BYTE_ARRAY = 0x7, 57 | TYPE_STRING = 0x8, 58 | TYPE_LIST = 0x9, 59 | TYPE_COMPOUND = 0xa; 60 | 61 | /** 62 | * Default private constructor. 63 | */ 64 | private NBTConstants() { 65 | 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/integration/economy/EconomyAPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.utils.integration.economy; 28 | 29 | import cn.nukkit.Player; 30 | 31 | /** 32 | * @author larryTheCoder 33 | */ 34 | public class EconomyAPI implements Economy { 35 | 36 | @Override 37 | public boolean reduceMoney(Player p, double amount) { 38 | double money = me.onebone.economyapi.EconomyAPI.getInstance().myMoney(p); 39 | if (money < amount) { 40 | int ret = me.onebone.economyapi.EconomyAPI.getInstance().reduceMoney(p, amount); 41 | return ret == me.onebone.economyapi.EconomyAPI.RET_SUCCESS; 42 | } 43 | return false; 44 | } 45 | 46 | @Override 47 | public boolean addMoney(Player p, double amount) { 48 | return me.onebone.economyapi.EconomyAPI.getInstance().addMoney(p, amount, true) == me.onebone.economyapi.EconomyAPI.RET_SUCCESS; 49 | } 50 | 51 | @Override 52 | public double getMoney(Player p) { 53 | return me.onebone.economyapi.EconomyAPI.getInstance().myMoney(p); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/integration/luckperms/InternalPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.utils.integration.luckperms; 29 | 30 | import cn.nukkit.Player; 31 | import cn.nukkit.Server; 32 | import cn.nukkit.command.CommandSender; 33 | import cn.nukkit.permission.PermissionAttachmentInfo; 34 | 35 | import java.util.HashMap; 36 | import java.util.Map; 37 | 38 | public class InternalPermission extends Permission { 39 | 40 | @Override 41 | public boolean hasPermission(CommandSender player, String permission) { 42 | return player.hasPermission(permission); 43 | } 44 | 45 | @Override 46 | public Map getPermissions(String playerName) { 47 | Player player = Server.getInstance().getPlayer(playerName); 48 | if (player == null) return null; 49 | 50 | Map parsedData = new HashMap<>(); 51 | for (Map.Entry pType : player.getEffectivePermissions().entrySet()) { 52 | parsedData.put(pType.getKey(), pType.getValue().getValue()); 53 | } 54 | 55 | return parsedData; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/events/IslandCreateEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.events; 28 | 29 | import cn.nukkit.Player; 30 | import cn.nukkit.event.Cancellable; 31 | import cn.nukkit.event.HandlerList; 32 | import com.larryTheCoder.cache.IslandData; 33 | import lombok.Getter; 34 | 35 | /** 36 | * @author larryTheCoder 37 | * @author tastybento 38 | */ 39 | public class IslandCreateEvent extends SkyBlockPlayerEvent implements Cancellable { 40 | 41 | private static final HandlerList HANDLERS = new HandlerList(); 42 | 43 | /** 44 | * The schematic id of the island. 45 | */ 46 | @Getter 47 | private final int schematicId; 48 | 49 | /** 50 | * @param player The player class who is involved in this event 51 | * @param schematicId The schematic id of the island. 52 | * @param island The data of the island. 53 | */ 54 | public IslandCreateEvent(Player player, int schematicId, IslandData island) { 55 | super(player, island); 56 | this.schematicId = schematicId; 57 | } 58 | 59 | public static HandlerList getHandlers() { 60 | return HANDLERS; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/command/category/QuestCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.command.category; 29 | 30 | import cn.nukkit.command.CommandSender; 31 | import com.larryTheCoder.ASkyBlock; 32 | 33 | import java.util.List; 34 | 35 | /** 36 | * A Quest, or called as challenges, commands. This category is 37 | * being revised as some of the commands are considered useless or obsolete to our 38 | * SkyBlock gameplay. 39 | */ 40 | public class QuestCategory extends SubCategory { 41 | 42 | protected QuestCategory(ASkyBlock plugin) { 43 | super(plugin); 44 | } 45 | 46 | @Override 47 | public List getCommands() { 48 | return null; 49 | } 50 | 51 | @Override 52 | public void execute(CommandSender sender, String commandLabel, String[] args) { 53 | 54 | } 55 | 56 | @Override 57 | public boolean canUse(CommandSender sender, String command) { 58 | return false; 59 | } 60 | 61 | @Override 62 | public String getDescription(String commandName) { 63 | return null; 64 | } 65 | 66 | @Override 67 | public String getParameters(String commandName) { 68 | return null; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/integration/luckperms/Permission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.utils.integration.luckperms; 29 | 30 | import cn.nukkit.command.CommandSender; 31 | 32 | import java.util.Map; 33 | 34 | public abstract class Permission { 35 | 36 | /** 37 | * Check either the sender has the permission for the given string 38 | * 39 | * @param sender The command sender class itself. 40 | * @param permission The permission that need to be checked. 41 | * @return {@code true} if the sender has the permission to execute this. 42 | */ 43 | public abstract boolean hasPermission(CommandSender sender, String permission); 44 | 45 | /** 46 | * Gets all permissions nodes from the player name given. This might 47 | * also return {@code null} if the player were not found. This function is a 48 | * blocking-thread operation and which should NEVER be called other 49 | * than an async tasks or threads. 50 | * 51 | * @param playerName The player unique name that needs to be checked. 52 | * @return {@code true} the list of permissions that the player had. 53 | */ 54 | public abstract Map getPermissions(String playerName); 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/jnbt/ByteArrayTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * The TAG_Byte_Array tag. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class ByteArrayTag extends Tag { 36 | 37 | /** 38 | * The value. 39 | */ 40 | private final byte[] value; 41 | 42 | /** 43 | * Creates the tag. 44 | * 45 | * @param name The name. 46 | * @param value The value. 47 | */ 48 | public ByteArrayTag(String name, byte[] value) { 49 | super(name); 50 | this.value = value; 51 | } 52 | 53 | @Override 54 | public byte[] getValue() { 55 | return value; 56 | } 57 | 58 | @Override 59 | public String toString() { 60 | StringBuilder hex = new StringBuilder(); 61 | for (byte b : value) { 62 | String hexDigits = Integer.toHexString(b).toUpperCase(); 63 | if (hexDigits.length() == 1) { 64 | hex.append("0"); 65 | } 66 | hex.append(hexDigits).append(" "); 67 | } 68 | String name = getName(); 69 | String append = ""; 70 | if (name != null && !name.equals("")) { 71 | append = "(\"" + this.getName() + "\")"; 72 | } 73 | return "TAG_Byte_Array" + append + ": " + hex.toString(); 74 | } 75 | 76 | } -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/database/config/AbstractConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.database.config; 28 | 29 | import org.sql2o.Sql2o; 30 | 31 | import java.sql.SQLException; 32 | 33 | /** 34 | * @author larryTheCoder 35 | */ 36 | public interface AbstractConfig { 37 | 38 | Sql2o forceConnection(); 39 | 40 | /** 41 | * Opens a connection with the database. 42 | * 43 | * @return Opened connection 44 | * @throws SQLException if the connection can not be opened 45 | * @throws ClassNotFoundException if the driver cannot be found 46 | */ 47 | Sql2o openConnection() throws SQLException, ClassNotFoundException; 48 | 49 | /** 50 | * Checks if a connection is open with the database. 51 | * 52 | * @return true if the connection is open 53 | * @throws SQLException if the connection cannot be checked 54 | */ 55 | boolean checkConnection() throws SQLException; 56 | 57 | /** 58 | * Gets the connection with the database. 59 | * 60 | * @return Connection with the database, null if none 61 | */ 62 | Sql2o getConnection(); 63 | 64 | /** 65 | * Closes the connection with the database. 66 | * 67 | * @return true if successful 68 | * @throws SQLException if the connection cannot be closed 69 | */ 70 | boolean closeConnection() throws SQLException; 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/jnbt/CompoundTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | import java.util.Collections; 31 | import java.util.Map; 32 | 33 | /** 34 | * The TAG_Compound tag. 35 | * 36 | * @author Graham Edgecombe 37 | */ 38 | public final class CompoundTag extends Tag { 39 | 40 | /** 41 | * The value. 42 | */ 43 | private final Map value; 44 | 45 | /** 46 | * Creates the tag. 47 | * 48 | * @param name The name. 49 | * @param value The value. 50 | */ 51 | public CompoundTag(String name, Map value) { 52 | super(name); 53 | this.value = Collections.unmodifiableMap(value); 54 | } 55 | 56 | @Override 57 | public Map getValue() { 58 | return value; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | String name = getName(); 64 | String append = ""; 65 | if (name != null && !name.equals("")) { 66 | append = "(\"" + this.getName() + "\")"; 67 | } 68 | StringBuilder bldr = new StringBuilder(); 69 | bldr.append("TAG_Compound" + append + ": " + value.size() + " entries\r\n{\r\n"); 70 | for (Map.Entry entry : value.entrySet()) { 71 | bldr.append(" " + entry.getValue().toString().replaceAll("\r\n", "\r\n ") + "\r\n"); 72 | } 73 | bldr.append("}"); 74 | return bldr.toString(); 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/ASkyBlockAPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder; 29 | 30 | import cn.nukkit.plugin.PluginBase; 31 | import com.larryTheCoder.cache.FastCache; 32 | import com.larryTheCoder.database.Database; 33 | import com.larryTheCoder.island.GridManager; 34 | import com.larryTheCoder.island.IslandManager; 35 | import com.larryTheCoder.island.TeleportLogic; 36 | import com.larryTheCoder.listener.ChatHandler; 37 | import com.larryTheCoder.listener.invitation.InvitationHandler; 38 | import com.larryTheCoder.locales.LocaleManager; 39 | import com.larryTheCoder.schematic.SchematicHandler; 40 | import com.larryTheCoder.utils.integration.luckperms.Permission; 41 | import lombok.Getter; 42 | 43 | public class ASkyBlockAPI extends PluginBase { 44 | 45 | @Getter 46 | protected Database database = null; 47 | @Getter 48 | protected ChatHandler chatHandler; 49 | @Getter 50 | protected InvitationHandler invitationHandler; 51 | @Getter 52 | protected IslandManager islandManager; 53 | @Getter 54 | protected GridManager grid; 55 | @Getter 56 | protected TeleportLogic teleportLogic; 57 | @Getter 58 | protected Messages messages; 59 | @Getter 60 | protected ServerPanel panel; 61 | @Getter 62 | protected FastCache fastCache; 63 | @Getter 64 | protected SchematicHandler schematics; 65 | @Getter 66 | protected Permission permissionHandler; 67 | @Getter 68 | protected LocaleManager localeManager; 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/cache/builder/IslandDataBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.cache.builder; 29 | 30 | import cn.nukkit.math.Vector2; 31 | import com.larryTheCoder.cache.IslandData; 32 | 33 | public class IslandDataBuilder { 34 | 35 | private IslandData data = new IslandData(); 36 | 37 | public IslandDataBuilder setGridCoordinates(Vector2 vec) { 38 | data.setCenter(vec); 39 | 40 | return this; 41 | } 42 | 43 | public IslandDataBuilder setIslandUniquePlotId(int generatedData) { 44 | data.setIslandUniquePlotId(generatedData); 45 | 46 | return this; 47 | } 48 | 49 | public IslandDataBuilder setPlotOwner(String plotOwner) { 50 | data.setPlotOwner(plotOwner); 51 | 52 | return this; 53 | } 54 | 55 | public IslandDataBuilder setLevelName(String levelName) { 56 | data.setLevelName(levelName); 57 | 58 | return this; 59 | } 60 | 61 | public IslandDataBuilder setProtectionSize(int gridSize) { 62 | data.setProtectionRange(gridSize); 63 | 64 | return this; 65 | } 66 | 67 | public IslandDataBuilder setLocked(boolean isLocked) { 68 | data.setLocked(isLocked); 69 | return this; 70 | } 71 | 72 | public IslandDataBuilder setPlotBiome(String biomeName) { 73 | data.setPlotBiome(biomeName); 74 | return this; 75 | } 76 | 77 | public IslandDataBuilder setIslandName(String islandName) { 78 | data.setIslandName(islandName); 79 | return this; 80 | } 81 | 82 | public IslandData build() { 83 | return data; 84 | } 85 | 86 | public IslandDataBuilder setIslandHomeId(int islandHomeId) { 87 | data.setHomeCountId(islandHomeId); 88 | return this; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/org/jnbt/ListTag.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | import java.util.Collections; 31 | import java.util.List; 32 | 33 | /** 34 | * The TAG_List tag. 35 | * 36 | * @author Graham Edgecombe 37 | */ 38 | public final class ListTag extends Tag { 39 | 40 | /** 41 | * The type. 42 | */ 43 | private final Class type; 44 | 45 | /** 46 | * The value. 47 | */ 48 | private final List value; 49 | 50 | /** 51 | * Creates the tag. 52 | * 53 | * @param name The name. 54 | * @param type The type of item in the list. 55 | * @param value The value. 56 | */ 57 | public ListTag(String name, Class type, List value) { 58 | super(name); 59 | this.type = type; 60 | this.value = Collections.unmodifiableList(value); 61 | } 62 | 63 | /** 64 | * Gets the type of item in this list. 65 | * 66 | * @return The type of item in this list. 67 | */ 68 | public Class getType() { 69 | return type; 70 | } 71 | 72 | @Override 73 | public List getValue() { 74 | return value; 75 | } 76 | 77 | @Override 78 | public String toString() { 79 | String name = getName(); 80 | String append = ""; 81 | if (name != null && !name.equals("")) { 82 | append = "(\"" + this.getName() + "\")"; 83 | } 84 | StringBuilder bldr = new StringBuilder(); 85 | bldr.append("TAG_List" + append + ": " + value.size() + " entries of type " + NBTUtils.getTypeName(type) + "\r\n{\r\n"); 86 | for (Tag t : value) { 87 | bldr.append(" " + t.toString().replaceAll("\r\n", "\r\n ") + "\r\n"); 88 | } 89 | bldr.append("}"); 90 | return bldr.toString(); 91 | } 92 | 93 | } -------------------------------------------------------------------------------- /src/main/resources/schematics/configuration.yml: -------------------------------------------------------------------------------- 1 | # The configuration of handling the schematic 2 | # Under development and still not working 3 | --- 4 | # Enable this features 5 | # If false, the plugin will use build-in generation 6 | enable: true 7 | # Versioning, DO NOT CHANGE 8 | version: 1 9 | # Schematic list 10 | # Here is the hints for you (Case sensitive): 11 | # - FILE_NAME* (String): The name of the folder (including .schematic) 12 | # - BLOCK_SPAWN (String): he type of block that will be needed to spawn player 13 | # Must be one. Eg. '115:3' - Indicating to black wool 14 | # - PERMISSION (String): The permission that will be needed for player to attempt to 15 | # use this schematic. 16 | # - DESCRIPTION* (String): You know what is this mean for right? 17 | # - RATING (double): This might be unimplemented yet but this usage are to count 18 | # Player rating on challenges. 19 | # - USE_CONFIG_CHEST (boolean): Use the default chest in config.yml 20 | # - PASTE_ENTITIES (boolean): Still under development. But work on minecarts 21 | # - BIOME (String): The Biome of the island. Eg: 'Plains' 22 | # - DEFAULT_PRIORITY** (boolean): Set the template to be default template 23 | # - LEVEL_HANDICAP (Integer): Level handicap zeros the initial island level. 24 | # - Note: ' * ' means required 25 | # ' ** ' means required to be used once 26 | # You can leave other variables to indicate that you don't want them 27 | schematicList: 28 | # Schematic list 29 | schematic: 30 | # This is a key for your island. This key is not be used in this plugin 31 | # You can make your own private schematic types (Saved in integers) 32 | # This is the order of your schematic (1) 33 | island: 34 | # This is an example of the island name 35 | FILE_NAME: "island.schematic" 36 | # This island name 37 | # You can use & as color codes 38 | NAME: "&eThe Original" 39 | # This is an example of a description 40 | # This will be used in sign and others (Must be not long 25 char, otherwise the sign will be empty) 41 | DESCRIPTION: "The default island for starters. Great resource with extreme height." 42 | # Permission base 43 | PERMISSION: "is.create" 44 | # Rating 45 | RATING: 1.8 46 | # Biome 47 | BIOME: "PLAINS" 48 | # Default priority 49 | DEFAULT_PRIORITY: true 50 | USE_CONFIG_CHEST: true 51 | # level handicap 52 | LEVEL_HANDICAP: 3 53 | # This is the order of your schematic (2) 54 | featured: 55 | FILE_NAME: "featured.schematic" 56 | NAME: "&eFeatured &cOne" 57 | DESCRIPTION: "&Wow, Featured..." 58 | PERMISSION: "is.create" 59 | RATING: 5 60 | BIOME: "FOREST" 61 | LEVEL_HANDICAP: 13 62 | # Double island (3) 63 | double: 64 | FILE_NAME: "double.schematic" 65 | NAME: "&eIsland &dDuo" 66 | DESCRIPTION: "Pretty much for double islands. Two close islands. Double more fun. But a little easier. Credit: Antal1609" 67 | PERMISSION: "is.create" 68 | RATING: 9 69 | BIOME: "FOREST" 70 | DEFAULT_PRIORITY: false 71 | USE_CONFIG_CHEST: true 72 | LEVEL_HANDICAP: 3 73 | # Harder schematic (4) 74 | extrahard: 75 | FILE_NAME: "harder.schematic" 76 | NAME: "&lBlack &bDiamonds" 77 | DESCRIPTION: "&cExperts only! &aMinimal resources. &aWith a few diamonds." 78 | PERMISSION: "is.create" 79 | RATING: 1 80 | BIOME: "FOREST" 81 | DEFAULT_PRIORITY: false 82 | USE_CONFIG_CHEST: true 83 | LEVEL_HANDICAP: 1 -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/listener/nms/MobPluginListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.listener.nms; 29 | 30 | import cn.nukkit.Player; 31 | import cn.nukkit.entity.Entity; 32 | import cn.nukkit.entity.mob.EntityMob; 33 | import cn.nukkit.entity.passive.EntityAnimal; 34 | import cn.nukkit.event.EventHandler; 35 | import cn.nukkit.event.EventPriority; 36 | import cn.nukkit.event.Listener; 37 | import cn.nukkit.event.entity.EntityDamageByEntityEvent; 38 | import cn.nukkit.event.entity.EntityDamageEvent; 39 | import com.larryTheCoder.ASkyBlock; 40 | import com.larryTheCoder.listener.Action; 41 | import com.larryTheCoder.utils.SettingsFlag; 42 | import lombok.extern.log4j.Log4j2; 43 | import nukkitcoders.mobplugin.entities.animal.Animal; 44 | import nukkitcoders.mobplugin.entities.monster.Monster; 45 | 46 | @Log4j2 47 | public class MobPluginListener extends Action implements Listener { 48 | 49 | public MobPluginListener(ASkyBlock plugin) { 50 | super(plugin); 51 | 52 | log.debug("Using MobPlugin"); 53 | } 54 | 55 | @EventHandler(priority = EventPriority.LOWEST) 56 | public void onPlayerHitEvent(EntityDamageEvent e) { 57 | log.debug("DEBUG: " + e.getEventName()); 58 | log.debug("DEBUG: NMS MobPlugin notation."); 59 | 60 | Entity target = e.getEntity(); 61 | 62 | if (notInWorld(target)) return; 63 | if (e instanceof EntityDamageByEntityEvent) { 64 | // Identifier for player mobs attack. 65 | if (!(target instanceof Player)) { 66 | log.debug("Target is not a player."); 67 | 68 | if (target instanceof Animal) { 69 | log.debug("Target is not an animal."); 70 | 71 | if (actionAllowed(target.getLocation(), SettingsFlag.HURT_MOBS)) return; 72 | } else if (target instanceof Monster) { 73 | log.debug("Target is not a monster."); 74 | 75 | if (actionAllowed(target.getLocation(), SettingsFlag.HURT_MONSTERS)) return; 76 | } 77 | } else { 78 | log.debug("Target is a player"); 79 | if (actionAllowed(target.getLocation(), SettingsFlag.PVP)) return; 80 | } 81 | 82 | log.debug("Target cancelled."); 83 | 84 | e.setCancelled(); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/task/SimpleFancyTitle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.task; 28 | 29 | import cn.nukkit.Player; 30 | import cn.nukkit.level.Position; 31 | import cn.nukkit.scheduler.Task; 32 | import cn.nukkit.utils.TextFormat; 33 | import com.larryTheCoder.ASkyBlock; 34 | import com.larryTheCoder.island.TeleportLogic; 35 | 36 | public class SimpleFancyTitle extends Task { 37 | 38 | private final ASkyBlock plugin; 39 | private final Player p; 40 | private Position lastPos; 41 | private int times = 0; 42 | 43 | public SimpleFancyTitle(ASkyBlock plugin, Player player) { 44 | this.plugin = plugin; 45 | this.p = player; 46 | } 47 | 48 | @Override 49 | public void onRun(int currentTick) { 50 | if (lastPos == null) { 51 | lastPos = p.clone(); 52 | } 53 | 54 | boolean shouldLoopBack; 55 | 56 | // Automatically cancel this task when player moved or something 57 | if (TeleportLogic.isPlayerMoved(p.getName())) { 58 | this.cancel(); 59 | return; 60 | } 61 | 62 | double shouldDo = Math.sqrt(Math.pow(lastPos.x - p.x, 2) + Math.pow(lastPos.z - p.z, 2)); 63 | // Now let wait till player moved or something 64 | // Do not count on it height. It might be falling from spawn pedestal 65 | shouldLoopBack = !plugin.inIslandWorld(p) || !(shouldDo >= 0.5); 66 | 67 | if (shouldLoopBack) { 68 | // If player still not moving or something. Cancel this task 69 | if (times >= 30) { 70 | return; 71 | } 72 | // This class interfered to task class 73 | // Keep this task in here until player moved 74 | TaskManager.runTaskLater(this, 20); 75 | lastPos = p.clone(); 76 | times++; 77 | return; 78 | } 79 | 80 | plugin.getFastCache().getIslandData(p.getLocation(), ownership -> { 81 | if (!plugin.getLocale(p).islandSubTitle.isEmpty()) { 82 | p.setSubtitle(TextFormat.GOLD + plugin.getLocale(p).islandSubTitle.replace("[player]", ownership.getPlotOwner())); 83 | } 84 | if (!plugin.getLocale(p).islandTitle.isEmpty()) { 85 | p.sendTitle(TextFormat.GOLD + plugin.getLocale(p).islandTitle.replace("[player]", ownership.getPlotOwner())); 86 | } 87 | }); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/task/TaskManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.task; 28 | 29 | import com.larryTheCoder.ASkyBlock; 30 | 31 | public class TaskManager { 32 | 33 | public static TaskManager IMP; 34 | 35 | public static void runTaskRepeatAsync(Runnable runnable, int interval) { 36 | if (runnable != null) { 37 | if (IMP == null) { 38 | throw new IllegalArgumentException("disabled"); 39 | } 40 | IMP.taskRepeatAsync(runnable, interval); 41 | } 42 | } 43 | 44 | public static void runTaskAsync(Runnable runnable) { 45 | if (runnable != null) { 46 | if (IMP == null) { 47 | runnable.run(); 48 | return; 49 | } 50 | IMP.taskAsync(runnable); 51 | } 52 | } 53 | 54 | public static void runTask(Runnable runnable) { 55 | if (runnable != null) { 56 | if (IMP == null) { 57 | runnable.run(); 58 | return; 59 | } 60 | IMP.task(runnable); 61 | } 62 | } 63 | 64 | /** 65 | * Run task later. 66 | * 67 | * @param runnable The task 68 | * @param delay The delay in ticks (milliseconds) 69 | */ 70 | public static void runTaskLater(Runnable runnable, int delay) { 71 | if (runnable != null) { 72 | if (IMP == null) { 73 | runnable.run(); 74 | return; 75 | } 76 | IMP.taskLater(runnable, delay); 77 | } 78 | } 79 | 80 | private void taskRepeatAsync(Runnable r, int interval) { 81 | ASkyBlock.get().getServer().getScheduler().scheduleRepeatingTask(ASkyBlock.get(), r, interval, true); 82 | } 83 | 84 | private void taskAsync(Runnable r) { 85 | if (r == null) { 86 | return; 87 | } 88 | ASkyBlock.get().getServer().getScheduler().scheduleTask(ASkyBlock.get(), r, true); 89 | } 90 | 91 | private void task(Runnable r) { 92 | if (r == null) { 93 | return; 94 | } 95 | ASkyBlock.get().getServer().getScheduler().scheduleTask(ASkyBlock.get(), r, false); 96 | } 97 | 98 | private void taskLater(Runnable r, int delay) { 99 | if (r == null) { 100 | return; 101 | } 102 | ASkyBlock.get().getServer().getScheduler().scheduleDelayedTask(ASkyBlock.get(), r, delay); 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/database/config/SQLiteConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.database.config; 28 | 29 | import cn.nukkit.utils.Config; 30 | import com.larryTheCoder.ASkyBlock; 31 | import com.larryTheCoder.utils.Utils; 32 | import org.sql2o.Sql2o; 33 | 34 | import java.io.File; 35 | import java.io.IOException; 36 | import java.sql.SQLException; 37 | 38 | /** 39 | * @author larryTheCoder 40 | */ 41 | public class SQLiteConfig implements AbstractConfig { 42 | 43 | private final String dbLocation; 44 | private final File file; 45 | private Sql2o connection; 46 | 47 | public SQLiteConfig(Config data) { 48 | this.file = new File(ASkyBlock.get().getDataFolder(), data.getString("database.SQLite.file-name")); 49 | this.dbLocation = file.getAbsolutePath(); 50 | } 51 | 52 | public String getAbsolutePath() { 53 | return dbLocation; 54 | } 55 | 56 | @Override 57 | public Sql2o forceConnection() { 58 | return new Sql2o("jdbc:sqlite:" + this.dbLocation, null, null); 59 | } 60 | 61 | @Override 62 | @SuppressWarnings("ResultOfMethodCallIgnored") 63 | public Sql2o openConnection() throws SQLException { 64 | if (checkConnection()) return this.connection; 65 | 66 | File file = new File(this.dbLocation); 67 | if (!file.exists()) { 68 | try { 69 | file.createNewFile(); 70 | } catch (IOException ignored) { 71 | Utils.send("&cUnable to create database!"); 72 | } 73 | } 74 | 75 | return new Sql2o("jdbc:sqlite:" + this.dbLocation, null, null); 76 | } 77 | 78 | @Override 79 | public boolean checkConnection() throws SQLException { 80 | if (connection == null) return false; 81 | 82 | try (java.sql.Connection con = connection.getConnectionSource().getConnection()) { 83 | return !con.isClosed(); 84 | } 85 | } 86 | 87 | @Override 88 | public Sql2o getConnection() { 89 | return this.connection; 90 | } 91 | 92 | @Override 93 | public boolean closeConnection() throws SQLException { 94 | if (this.connection == null) { 95 | return false; 96 | } 97 | this.connection.getConnectionSource().getConnection().close(); 98 | this.connection = null; 99 | return true; 100 | } 101 | 102 | @Override 103 | public String toString() { 104 | return "SQLite, " + file.getName(); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/IslandAwaitStore.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.utils; 29 | 30 | import cn.nukkit.Player; 31 | import com.larryTheCoder.ASkyBlock; 32 | import com.larryTheCoder.database.QueryDb; 33 | import com.larryTheCoder.database.QueryInfo; 34 | import org.sql2o.data.Table; 35 | 36 | import java.util.HashMap; 37 | import java.util.Map; 38 | import java.util.concurrent.TimeUnit; 39 | 40 | /** 41 | * Awaits class, this class stores a temporary player island reset data. This class 42 | * may benefit the owner by restricting the amount of island created by a certain amount of time. 43 | */ 44 | public class IslandAwaitStore { 45 | 46 | public static final Map playerLimit = new HashMap<>(); 47 | 48 | /** 49 | * Stores a temporary await data key into a hash mapping data. 50 | * This data will be saved later by an async database. 51 | * 52 | * @param player The player unique id. 53 | */ 54 | public static void storeAwaitData(String playerName) { 55 | if (playerLimit.containsKey(playerName)) return; 56 | 57 | long currentTime; 58 | playerLimit.put(playerName, currentTime = System.currentTimeMillis()); 59 | 60 | ASkyBlock.get().getDatabase().executeUpdate(new QueryInfo(QueryDb.getInstance().awaitStore) 61 | .addParameter("plUniqueId", playerName) 62 | .addParameter("timestamp", currentTime)); 63 | } 64 | 65 | /** 66 | * Checks if the player can bypass the await timer. 67 | * 68 | * @param player The player class itself. 69 | * @return The time that player needs in order to bypass 70 | */ 71 | public static long canBypassAwait(Player player) { 72 | String plName = player.getName(); 73 | if (ASkyBlock.get().getPermissionHandler().hasPermission(player, "is.timer.bypass")) return -1; 74 | if (!playerLimit.containsKey(plName)) return -1; 75 | 76 | long totalTime = TimeUnit.MINUTES.toMillis(Settings.resetTime) - (System.currentTimeMillis() - playerLimit.get(plName)); 77 | if (totalTime <= 0) { 78 | ASkyBlock.get().getDatabase().executeUpdate(new QueryInfo("DELETE FROM lastExecution WHERE playerUniqueId = :plName").addParameter("plName", plName)); 79 | return -1; 80 | } 81 | 82 | return totalTime; 83 | } 84 | 85 | /** 86 | * Initializes the IslandAwaitStore class. 87 | */ 88 | public static void init() { 89 | Table table = ASkyBlock.get().getDatabase().fetchData(new QueryInfo("SELECT * FROM lastExecution")).join(); 90 | 91 | table.rows().forEach(row -> playerLimit.put(row.getString("playerUniqueId"), row.getLong("lastQueried"))); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/cache/builder/WorldSettingsBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.cache.builder; 29 | 30 | 31 | import cn.nukkit.level.Level; 32 | import com.google.common.base.Preconditions; 33 | import com.larryTheCoder.cache.settings.WorldSettings; 34 | import lombok.Getter; 35 | 36 | import java.util.List; 37 | 38 | public class WorldSettingsBuilder { 39 | 40 | @Getter 41 | private int levelId; 42 | 43 | @Getter 44 | private Level level; 45 | @Getter 46 | private String permission; 47 | @Getter 48 | private int plotMax; 49 | @Getter 50 | private int plotSize; 51 | @Getter 52 | private boolean stopTime; 53 | @Getter 54 | private int seaLevel; 55 | @Getter 56 | private int plotRange; 57 | @Getter 58 | private boolean useDefaultChest; 59 | @Getter 60 | private String[] signConfig; 61 | 62 | public WorldSettingsBuilder setPermission(String permission) { 63 | this.permission = permission; 64 | return this; 65 | } 66 | 67 | public WorldSettingsBuilder setPlotMax(int plotMax) { 68 | this.plotMax = plotMax; 69 | return this; 70 | } 71 | 72 | public WorldSettingsBuilder setPlotSize(int plotSize) { 73 | this.plotSize = plotSize; 74 | return this; 75 | } 76 | 77 | public WorldSettingsBuilder setPlotRange(int plotRange) { 78 | this.plotRange = plotRange; 79 | return this; 80 | } 81 | 82 | public WorldSettingsBuilder isStopTime(boolean isStopTime) { 83 | this.stopTime = isStopTime; 84 | return this; 85 | } 86 | 87 | public WorldSettingsBuilder useDefaultChest(boolean defaultChest) { 88 | this.useDefaultChest = defaultChest; 89 | return this; 90 | } 91 | 92 | public WorldSettingsBuilder setSeaLevel(int seaLevel) { 93 | this.seaLevel = seaLevel; 94 | return this; 95 | } 96 | 97 | public WorldSettingsBuilder setLevel(Level level) { 98 | this.level = level; 99 | return this; 100 | } 101 | 102 | @SuppressWarnings("rawtypes") 103 | public WorldSettingsBuilder setSignSettings(List section) { 104 | this.signConfig = (String[]) section.toArray(new String[0]); 105 | 106 | return this; 107 | } 108 | 109 | public WorldSettingsBuilder setLevelId(int value) { 110 | this.levelId = value; 111 | 112 | return this; 113 | } 114 | 115 | public WorldSettings build() { 116 | Preconditions.checkState(this.level != null, "World level cannot be null!"); 117 | 118 | return new WorldSettings(this); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/Settings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.utils; 28 | 29 | import cn.nukkit.block.Block; 30 | import cn.nukkit.item.Item; 31 | 32 | import java.util.*; 33 | 34 | /** 35 | * @author larryTheCoder 36 | */ 37 | public class Settings { 38 | 39 | // system config 40 | public static List challengeLevels = new ArrayList<>(); 41 | 42 | // config config 43 | public static boolean verboseCode = false; 44 | public static boolean autoUpdate = false; 45 | public static boolean checkUpdate; 46 | public static int islandHeight = 60; 47 | public static int islandMaxNameLong; 48 | public static int cleanRate; 49 | public static boolean respawnOnIsland; 50 | public static int deathPenalty; 51 | public static boolean sumTeamDeaths; 52 | public static final ArrayList bannedCommands = new ArrayList<>(); 53 | public static int gameMode; 54 | public static int memberTimeOut; 55 | public static Item[] chestItems = new Item[0]; 56 | public static boolean broadcastMessages; 57 | public static boolean teamChat; 58 | public static int resetTime; 59 | public static String defaultLanguage; 60 | public static int loadCacheBefore = 30; 61 | 62 | // Levels 63 | // The format are as 'FullID => Level' 64 | public final static Map blockLimits = new HashMap<>(); 65 | public final static Map blockValues = new HashMap<>(); 66 | 67 | // default config 68 | public static Set challengeList = new HashSet<>(); 69 | public static List freeLevels = new ArrayList<>(); 70 | public static int waiverAmount = 0; 71 | 72 | /** 73 | * Default world protection settings 74 | */ 75 | public static final HashMap defaultWorldSettings = new HashMap<>(); 76 | /** 77 | * Default island protection settings 78 | */ 79 | public static final HashMap defaultIslandSettings = new HashMap<>(); 80 | /** 81 | * Default spawn protection settings 82 | */ 83 | public static final HashMap defaultSpawnSettings = new HashMap<>(); 84 | 85 | public static boolean useEconomy = false; 86 | public static double islandCost = 10D; 87 | public static boolean firstIslandFree = true; 88 | 89 | // Magic Cobble Generator 90 | public static boolean useMagicCobbleGen; 91 | public static TreeMap> magicCobbleGenChances; 92 | 93 | // Level configuration settings. 94 | public static int levelCost; 95 | public static int maxDeaths; 96 | public static boolean islandResetDeathReset; 97 | public static boolean teamJoinDeathReset; 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/SkyBlockGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder; 28 | 29 | import cn.nukkit.block.Block; 30 | import cn.nukkit.level.ChunkManager; 31 | import cn.nukkit.level.Level; 32 | import cn.nukkit.level.biome.EnumBiome; 33 | import cn.nukkit.level.format.generic.BaseFullChunk; 34 | import cn.nukkit.level.generator.Generator; 35 | import cn.nukkit.math.NukkitRandom; 36 | import cn.nukkit.math.Vector3; 37 | import com.larryTheCoder.cache.settings.WorldSettings; 38 | 39 | import java.util.Map; 40 | 41 | /** 42 | * @author larryTheCoder 43 | */ 44 | public class SkyBlockGenerator extends Generator { 45 | 46 | public static final int TYPE_SKYBLOCK = 0x7eabbff; 47 | private final Map options; 48 | private ChunkManager level; 49 | 50 | public SkyBlockGenerator(Map options) { 51 | this.options = options; 52 | } 53 | 54 | @Override 55 | public int getId() { 56 | return TYPE_SKYBLOCK; 57 | } 58 | 59 | @Override 60 | public void init(ChunkManager cm, NukkitRandom nr) { 61 | this.level = cm; 62 | } 63 | 64 | @Override 65 | public void generateChunk(int chunkX, int chunkZ) { 66 | BaseFullChunk chunk = level.getChunk(chunkX, chunkZ); 67 | for (int x = 0; x < 16; x++) { 68 | for (int z = 0; z < 16; z++) { 69 | chunk.setBiomeId(x, z, EnumBiome.PLAINS.id); 70 | } 71 | } 72 | 73 | WorldSettings settings = ASkyBlock.get().getSettings(chunk.getProvider().getLevel().getName()); 74 | // Sometime it could be null. 75 | if (settings == null) { 76 | return; 77 | } 78 | // making island in this section has been removed 79 | for (int x = 0; x < 16; x++) { 80 | for (int z = 0; z < 16; z++) { 81 | for (int y = 0; y < settings.getSeaLevel(); y++) { 82 | chunk.setBlock(x, y, z, Block.STILL_WATER); // Water Allows stuff 83 | // to fall through into oblivion, thus keeping lag to a minimum 84 | } 85 | } 86 | } 87 | } 88 | 89 | @Override 90 | public void populateChunk(int chunkX, int chunkZ) { 91 | // ??? do wut Xd 92 | } 93 | 94 | @Override 95 | public Map getSettings() { 96 | return options; 97 | } 98 | 99 | @Override 100 | public String getName() { 101 | return "island"; 102 | } 103 | 104 | @Override 105 | public Vector3 getSpawn() { 106 | return new Vector3(15, 60, 15); 107 | } 108 | 109 | @Override 110 | public ChunkManager getChunkManager() { 111 | return level; 112 | } 113 | 114 | @Override 115 | public int getDimension() { 116 | return Level.DIMENSION_OVERWORLD; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/integration/luckperms/LuckPermsPermission.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.utils.integration.luckperms; 29 | 30 | import cn.nukkit.Player; 31 | import cn.nukkit.command.CommandSender; 32 | import com.larryTheCoder.task.TaskManager; 33 | import com.larryTheCoder.utils.Utils; 34 | import net.luckperms.api.LuckPerms; 35 | import net.luckperms.api.LuckPermsProvider; 36 | import net.luckperms.api.cacheddata.CachedPermissionData; 37 | import net.luckperms.api.context.ContextManager; 38 | import net.luckperms.api.model.user.User; 39 | import net.luckperms.api.model.user.UserManager; 40 | import net.luckperms.api.query.QueryOptions; 41 | 42 | import java.util.Map; 43 | import java.util.concurrent.CompletableFuture; 44 | 45 | /** 46 | * Implementation to LuckPermsPermission 47 | * aka, PermissionEx 48 | */ 49 | public class LuckPermsPermission extends Permission { 50 | 51 | private LuckPerms luckPerms; 52 | 53 | public LuckPermsPermission() { 54 | getLuckPerms(); 55 | } 56 | 57 | private void getLuckPerms() { 58 | try { 59 | luckPerms = LuckPermsProvider.get(); 60 | 61 | Utils.send("&7Successfully integrated with LuckPerms &7plugin."); 62 | } catch (IllegalStateException ignored) { 63 | TaskManager.runTaskLater(this::getLuckPerms, 60); 64 | } 65 | } 66 | 67 | @Override 68 | public boolean hasPermission(CommandSender sender, String permission) { 69 | if (!(sender instanceof Player)) return true; 70 | 71 | User user = luckPerms.getUserManager().getUser(((Player) sender).getUniqueId()); 72 | if (user == null) { 73 | Utils.sendDebug("The user " + sender.getName() + " were not found in LuckPermsAPI"); 74 | return false; 75 | } 76 | 77 | ContextManager cm = luckPerms.getContextManager(); 78 | 79 | QueryOptions queryOptions = cm.getQueryOptions(user).orElse(cm.getStaticQueryOptions()); 80 | CachedPermissionData permissionData = user.getCachedData().getPermissionData(queryOptions); 81 | 82 | return permissionData.checkPermission(permission).asBoolean(); 83 | } 84 | 85 | public Map getPermissions(String playerName) { 86 | UserManager userManager = luckPerms.getUserManager(); 87 | CompletableFuture userFuture = userManager.loadUser(userManager.lookupUniqueId(playerName).join()); 88 | 89 | User user = userFuture.join(); 90 | if (user == null) { 91 | Utils.sendDebug("The player " + playerName + " were not found in LuckPermsAPI"); 92 | return null; 93 | } 94 | 95 | ContextManager cm = luckPerms.getContextManager(); 96 | 97 | QueryOptions queryOptions = cm.getQueryOptions(user).orElse(cm.getStaticQueryOptions()); 98 | CachedPermissionData permissionData = user.getCachedData().getPermissionData(queryOptions); 99 | 100 | return permissionData.getPermissionMap(); 101 | 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/locales/FileLister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.locales; 28 | 29 | import cn.nukkit.plugin.PluginBase; 30 | import com.larryTheCoder.ASkyBlock; 31 | 32 | import java.io.File; 33 | import java.io.FilenameFilter; 34 | import java.io.IOException; 35 | import java.lang.reflect.InvocationTargetException; 36 | import java.lang.reflect.Method; 37 | import java.util.ArrayList; 38 | import java.util.Enumeration; 39 | import java.util.List; 40 | import java.util.Objects; 41 | import java.util.jar.JarEntry; 42 | import java.util.jar.JarFile; 43 | 44 | /** 45 | * @author larryTheCoder 46 | * @author tastybento 47 | */ 48 | public final class FileLister { 49 | 50 | private final String folderPath; 51 | private final boolean filterYML; 52 | 53 | public FileLister(String folderPath) { 54 | this(folderPath, true); 55 | } 56 | 57 | public FileLister(String folderPath, boolean filterYML) { 58 | this.filterYML = filterYML; 59 | this.folderPath = folderPath; 60 | } 61 | 62 | public List list() throws IOException { 63 | ASkyBlock plugin = ASkyBlock.get(); 64 | List result = new ArrayList<>(); 65 | 66 | // Check if the locale folder exists 67 | File localeDir = new File(plugin.getDataFolder(), folderPath); 68 | if (localeDir.exists()) { 69 | FilenameFilter ymlFilter = (File dir, String name) -> { 70 | String lowercaseName = name.toLowerCase(); 71 | if (filterYML) { 72 | return lowercaseName.endsWith(".yml"); 73 | } 74 | 75 | return true; 76 | }; 77 | 78 | for (String fileName : Objects.requireNonNull(localeDir.list(ymlFilter))) { 79 | result.add(fileName.replace(".yml", "")); 80 | } 81 | 82 | if (!result.isEmpty()) { 83 | return result; 84 | } 85 | } 86 | // Else look in the JAR 87 | File jarfile; 88 | 89 | try { 90 | Method method = PluginBase.class.getDeclaredMethod("getFile"); 91 | method.setAccessible(true); 92 | 93 | jarfile = (File) method.invoke(ASkyBlock.get()); 94 | } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { 95 | throw new IOException(e); 96 | } 97 | 98 | try (JarFile jar = new JarFile(jarfile)) { 99 | Enumeration entries = jar.entries(); 100 | while (entries.hasMoreElements()) { 101 | JarEntry entry = entries.nextElement(); 102 | String path = entry.getName(); 103 | 104 | if (!path.startsWith(folderPath)) { 105 | continue; 106 | } 107 | 108 | if (entry.getName().endsWith(".yml")) { 109 | result.add((entry.getName().replace(".yml", "")).replace("locale/", "")); 110 | } 111 | 112 | } 113 | } 114 | return result; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/database/config/MySQLConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.database.config; 28 | 29 | import cn.nukkit.utils.Config; 30 | import com.larryTheCoder.utils.Utils; 31 | import org.sql2o.Sql2o; 32 | 33 | import java.sql.SQLException; 34 | 35 | /** 36 | * @author larryTheCoder 37 | */ 38 | public class MySQLConfig implements AbstractConfig { 39 | 40 | private final String user; 41 | private final String database; 42 | private final String password; 43 | private final int port; 44 | private final String hostname; 45 | private Sql2o connection; 46 | 47 | /** 48 | * Creates a new MySQL instance. 49 | * 50 | * @param hostname Name of the host 51 | * @param port Port number 52 | * @param database Database name 53 | * @param username Username 54 | * @param password Password 55 | */ 56 | public MySQLConfig(String hostname, int port, String database, String username, String password) { 57 | this.hostname = hostname; 58 | this.port = port; 59 | this.database = database; 60 | this.user = username; 61 | this.password = password; 62 | this.connection = null; 63 | } 64 | 65 | public MySQLConfig(Config config) { 66 | this.hostname = config.getString("database.MySQL.host"); 67 | this.port = config.getInt("database.MySQL.port"); 68 | this.database = config.getString("database.MySQL.database"); 69 | this.user = config.getString("database.MySQL.username"); 70 | this.password = config.getString("database.MySQL.password"); 71 | this.connection = null; 72 | } 73 | 74 | @Override 75 | public Sql2o forceConnection() { 76 | return new Sql2o("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database, this.user, this.password); 77 | } 78 | 79 | @Override 80 | public Sql2o openConnection() throws SQLException { 81 | if (checkConnection()) { 82 | return this.connection; 83 | } 84 | 85 | Utils.send("&aConnecting to: jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database); 86 | return new Sql2o("jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database, this.user, this.password); 87 | } 88 | 89 | @Override 90 | public boolean checkConnection() throws SQLException { 91 | if (connection == null) return false; 92 | 93 | try (java.sql.Connection con = connection.getConnectionSource().getConnection()) { 94 | return !con.isClosed(); 95 | } 96 | } 97 | 98 | @Override 99 | public Sql2o getConnection() { 100 | return this.connection; 101 | } 102 | 103 | @Override 104 | public boolean closeConnection() throws SQLException { 105 | if (this.connection == null) { 106 | return false; 107 | } 108 | this.connection.getConnectionSource().getConnection().close(); 109 | this.connection = null; 110 | return true; 111 | } 112 | 113 | @Override 114 | public String toString() { 115 | return "jdbc:mysql://" + this.hostname + ':' + this.port + '/' + this.database; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/events/SkyBlockEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2016-2020 larryTheCoder and contributors 3 | * 4 | * Permission is hereby granted to any persons and/or organizations 5 | * using this software to copy, modify, merge, publish, and distribute it. 6 | * Said persons and/or organizations are not allowed to use the software or 7 | * any derivatives of the work for commercial use or any other means to generate 8 | * income, nor are they allowed to claim this software as their own. 9 | * 10 | * The persons and/or organizations are also disallowed from sub-licensing 11 | * and/or trademarking this software without explicit permission from larryTheCoder. 12 | * 13 | * Any persons and/or organizations using this software must disclose their 14 | * source code and have it publicly available, include this license, 15 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 16 | * as well as provide a link to the original project. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 20 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 23 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package com.larryTheCoder.events; 27 | 28 | import cn.nukkit.Player; 29 | import cn.nukkit.Server; 30 | import cn.nukkit.event.Cancellable; 31 | import cn.nukkit.event.Event; 32 | import cn.nukkit.event.HandlerList; 33 | import cn.nukkit.level.Location; 34 | import cn.nukkit.math.Vector2; 35 | import com.larryTheCoder.ASkyBlock; 36 | import com.larryTheCoder.cache.IslandData; 37 | import lombok.Getter; 38 | import lombok.extern.log4j.Log4j2; 39 | 40 | @Log4j2 41 | public abstract class SkyBlockEvent extends Event { 42 | 43 | @Getter 44 | private static final HandlerList handlers = new HandlerList(); 45 | 46 | /** 47 | * The island involved in the event. 48 | */ 49 | @Getter 50 | private final IslandData island; 51 | 52 | public SkyBlockEvent(IslandData island) { 53 | this.island = island; 54 | } 55 | 56 | 57 | /** 58 | * Convenience function to obtain the island's protection size 59 | * 60 | * @return the protectionSize 61 | */ 62 | public int getProtectionSize() { 63 | return ASkyBlock.get().getSettings(island.getLevelName()).getIslandDistance() / 2; 64 | } 65 | 66 | /** 67 | * Convenience function to obtain the island's locked status 68 | * 69 | * @return the isLocked 70 | */ 71 | public boolean isLocked() { 72 | return island.isLocked(); 73 | } 74 | 75 | /** 76 | * Convenience function to obtain the island's distance 77 | * 78 | * @return the islandDistance 79 | */ 80 | public int getIslandDistance() { 81 | return ASkyBlock.get().getSettings(island.getLevelName()).getIslandDistance(); 82 | } 83 | 84 | /** 85 | * Convenience function to obtain the island's owner 86 | * 87 | * @return UUID of owner 88 | */ 89 | public Player getIslandOwner() { 90 | return Server.getInstance().getPlayer(island.getPlotOwner()); 91 | } 92 | 93 | /** 94 | * Convenience function to obtain the island's center location 95 | * 96 | * @return the island location 97 | */ 98 | public Location getIslandLocation() { 99 | Vector2 cartesianPlane = island.getCenter(); 100 | 101 | return new Location(cartesianPlane.getFloorX(), 0, cartesianPlane.getFloorY(), Server.getInstance().getLevelByName(island.getLevelName())); 102 | } 103 | 104 | /** 105 | * Calls an event statically. This is function is to cut off the amount 106 | * of code required just to call this event. 107 | * 108 | * @param event The SkyBlock event. 109 | */ 110 | public static void eventCall(SkyBlockEvent event) { 111 | log.debug("Calling an event..."); 112 | 113 | Server.getInstance().getPluginManager().callEvent(event); 114 | } 115 | 116 | /** 117 | * Calls an event in which the event is an instanceof {@linkplain cn.nukkit.event.Cancellable} class. 118 | * As the above, it is just a convenience tool to cut off the amount of code required to call 119 | * this event. 120 | * 121 | * @return {@code true} if the event is cancelled. 122 | */ 123 | public static boolean eventCancellableCall(SkyBlockEvent event) { 124 | eventCall(event); 125 | 126 | return event instanceof Cancellable && event.isCancelled(); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/listener/Action.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.listener; 29 | 30 | import cn.nukkit.Player; 31 | import cn.nukkit.api.API; 32 | import cn.nukkit.level.Location; 33 | import com.larryTheCoder.ASkyBlock; 34 | import com.larryTheCoder.cache.CoopData; 35 | import com.larryTheCoder.cache.IslandData; 36 | import com.larryTheCoder.utils.Settings; 37 | import com.larryTheCoder.utils.SettingsFlag; 38 | import lombok.NonNull; 39 | import lombok.extern.log4j.Log4j2; 40 | 41 | /** 42 | * A simple utility abstract class that determines if the action done 43 | * by the player is allowed or not. 44 | */ 45 | @Log4j2 46 | @API(definition = API.Definition.UNIVERSAL, usage = API.Usage.STABLE) 47 | public abstract class Action { 48 | 49 | private final ASkyBlock plugin; 50 | 51 | public Action(ASkyBlock plugin) { 52 | this.plugin = plugin; 53 | } 54 | 55 | /** 56 | * Determines if a location is in the island world or not or in the new 57 | * nether if it is activated 58 | * 59 | * @param loc Location of the entity to be checked 60 | * @return true if in the island world 61 | */ 62 | protected boolean notInWorld(@NonNull Location loc) { 63 | return !ASkyBlock.get().getLevels().contains(loc.getLevel().getName()); 64 | } 65 | 66 | /** 67 | * Action allowed in this location 68 | * 69 | * @param location The location to be checked 70 | * @param flag Kind of flag to be checked 71 | * @return true if allowed 72 | */ 73 | protected boolean actionAllowed(Location location, SettingsFlag flag) { 74 | IslandData island = plugin.getGrid().getProtectedIslandAt(location); 75 | if (island != null) { 76 | log.debug("DEBUG: Action is determined by settings"); 77 | return island.getIgsSettings().getIgsFlag(flag); 78 | } 79 | log.debug("DEBUG: Action is defined by settings"); 80 | return Settings.defaultWorldSettings.get(flag); 81 | } 82 | 83 | /** 84 | * Checks if action is allowed for player in location for flag 85 | * 86 | * @param player The player or entity 87 | * @param location The location to be checked 88 | * @return true if allowed 89 | */ 90 | protected boolean actionAllowed(Player player, Location location, SettingsFlag flag) { 91 | if (player == null) return actionAllowed(location, flag); 92 | 93 | // This permission bypasses protection 94 | if (player.isOp() || hasPermission(player, "is.mod.bypassprotect")) { 95 | return true; 96 | } 97 | 98 | IslandData island = plugin.getGrid().getProtectedIslandAt(location); 99 | CoopData pd = plugin.getFastCache().getRelations(location); 100 | if (island != null && (island.getIgsSettings().getIgsFlag(flag) || (pd != null && pd.isMember(player.getName())))) { 101 | return true; 102 | } 103 | 104 | if (island == null || island.getPlotOwner() == null) return false; 105 | if (island.getPlotOwner().equalsIgnoreCase(player.getName())) return true; 106 | 107 | return Settings.defaultWorldSettings.get(flag); 108 | } 109 | 110 | protected boolean hasPermission(Player player, String permission) { 111 | return plugin.getPermissionHandler().hasPermission(player, permission); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/listener/invitation/InvitationHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.listener.invitation; 28 | 29 | import cn.nukkit.Player; 30 | import cn.nukkit.Server; 31 | import cn.nukkit.command.CommandSender; 32 | import com.larryTheCoder.ASkyBlock; 33 | import com.larryTheCoder.cache.IslandData; 34 | 35 | import java.util.ArrayDeque; 36 | import java.util.ArrayList; 37 | import java.util.List; 38 | import java.util.Queue; 39 | 40 | /** 41 | * Handles all the invites for the server. 42 | * 43 | * @author larryTheCoder 44 | */ 45 | public class InvitationHandler { 46 | 47 | private final ASkyBlock plugin; 48 | private final List invitation = new ArrayList<>(); 49 | 50 | public InvitationHandler(ASkyBlock plugin) { 51 | this.plugin = plugin; 52 | Server.getInstance().getScheduler().scheduleRepeatingTask(plugin, () -> { 53 | if (invitation.isEmpty()) { 54 | return; 55 | } 56 | Queue removeQuery = new ArrayDeque<>(invitation.size()); 57 | // We can't remove the invite while in forEach 58 | // We store it in Queue and then stores them in it 59 | // After we done dealing with it. 60 | invitation.forEach(invite -> { 61 | if (!invite.tick()) { 62 | removeQuery.add(invite); 63 | } 64 | }); 65 | 66 | // Deal with these things. 67 | while (!removeQuery.isEmpty()) { 68 | removeInvitation(removeQuery.poll()); 69 | } 70 | }, 20); 71 | } 72 | 73 | /** 74 | * Removes an invite from a invite. 75 | * 76 | * @param invite The invitation class. 77 | */ 78 | void removeInvitation(Invitation invite) { 79 | invitation.remove(invite); 80 | } 81 | 82 | /** 83 | * Gets an invite by the receiver. 84 | * 85 | * @param player The receiver of the invite 86 | * @return The invite class itself, otherwise null. 87 | */ 88 | public Invitation getInvitation(Player player) { 89 | return getInvitation(player, ""); 90 | } 91 | 92 | /** 93 | * Get an invites given by a specific player towards 94 | * the target player. 95 | * 96 | * @param player The receiver of the invite 97 | * @return The invite class itself, otherwise null. 98 | */ 99 | public Invitation getInvitation(Player player, String playerName) { 100 | return invitation.stream() 101 | .filter(invite -> invite.getReceiver().getName().equalsIgnoreCase(playerName)) 102 | .filter(invite -> invite.getSender().equals(player)) 103 | .findFirst() 104 | .orElse(null); 105 | } 106 | 107 | /** 108 | * Create a new invitation 109 | * 110 | * @param sender The sender itself 111 | * @param receiver The receiver of the invitation 112 | */ 113 | public void addInvitation(CommandSender sender, Player receiver, IslandData islandData) { 114 | sender.sendMessage(plugin.getPrefix() + plugin.getLocale(sender.isPlayer() ? (Player) sender : null).inviteSuccess); 115 | receiver.sendMessage(plugin.getPrefix() + plugin.getLocale(receiver).newInvitation.replace("[player]", sender.getName())); 116 | 117 | // Add into the list. 118 | invitation.add(new Invitation(this, sender, receiver, islandData)); 119 | } 120 | } -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/cache/settings/WorldSettings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.cache.settings; 28 | 29 | import cn.nukkit.level.GameRule; 30 | import cn.nukkit.level.Level; 31 | import cn.nukkit.utils.Config; 32 | import com.larryTheCoder.cache.builder.WorldSettingsBuilder; 33 | import com.larryTheCoder.utils.Utils; 34 | import lombok.Getter; 35 | 36 | /** 37 | * @author larryTheCoder 38 | */ 39 | public class WorldSettings { 40 | 41 | @Getter 42 | private final int levelId; 43 | 44 | @Getter 45 | private final Level level; 46 | @Getter 47 | private String permission = "is.create"; 48 | @Getter 49 | private int maximumIsland = 5; 50 | @Getter 51 | private int islandDistance = 200; 52 | @Getter 53 | private int protectionRange = 100; 54 | @Getter 55 | private boolean stopTime = false; 56 | @Getter 57 | private int seaLevel = 0; 58 | @Getter 59 | private String[] signConfig = new String[]{"&aWelcome to", "&e[player]'s", "&aIsland! Enjoy.", ""}; 60 | @Getter 61 | private boolean useDefaultChest = false; 62 | 63 | public WorldSettings(Level level) { 64 | this.level = level; 65 | 66 | this.levelId = Utils.generateLevelId(); 67 | } 68 | 69 | public WorldSettings(WorldSettingsBuilder builder) { 70 | this.level = builder.getLevel(); 71 | 72 | this.permission = builder.getPermission(); 73 | this.maximumIsland = builder.getPlotMax(); 74 | this.islandDistance = builder.getPlotSize(); 75 | this.stopTime = builder.isStopTime(); 76 | this.seaLevel = builder.getSeaLevel(); 77 | this.protectionRange = builder.getPlotRange(); 78 | this.useDefaultChest = builder.isUseDefaultChest(); 79 | this.signConfig = builder.getSignConfig(); 80 | 81 | this.levelId = builder.getLevelId(); 82 | } 83 | 84 | public void verifyWorldSettings() { 85 | if (isStopTime()) { 86 | level.setTime(1600); 87 | level.stopTime(); 88 | 89 | level.getGameRules().setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false); 90 | } 91 | 92 | if (protectionRange % 2 != 0) { 93 | protectionRange--; 94 | Utils.send("&cThe protection range must be even, using " + protectionRange); 95 | } 96 | 97 | if (protectionRange > islandDistance) { 98 | Utils.send("&cThe protection range cannot be bigger then the island distance. Setting them to be half equal."); 99 | protectionRange = islandDistance / 2; // Avoiding players from CANNOT break their island 100 | } 101 | 102 | if (protectionRange < 0) { 103 | protectionRange = 0; 104 | } 105 | } 106 | 107 | public void saveConfig(Config cfg) { 108 | String levelName = level.getName(); 109 | 110 | cfg.set(levelName + ".permission", permission); 111 | cfg.set(levelName + ".maxHome", 5); 112 | cfg.set(levelName + ".plotSize", islandDistance); 113 | cfg.set(levelName + ".protectionRange", protectionRange); 114 | cfg.set(levelName + ".stopTime", stopTime); 115 | cfg.set(levelName + ".seaLevel", seaLevel); 116 | cfg.set(levelName + ".useDefaultChest", useDefaultChest); 117 | cfg.set(levelName + ".signConfig", new String[]{"&aWelcome to", "&e[player]'s", "&aIsland! Enjoy.", ""}); 118 | cfg.save(); 119 | } 120 | 121 | public static WorldSettingsBuilder builder() { 122 | return new WorldSettingsBuilder(); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/command/category/SubCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.command.category; 29 | 30 | import cn.nukkit.Player; 31 | import cn.nukkit.command.CommandSender; 32 | import com.google.common.base.Preconditions; 33 | import com.larryTheCoder.ASkyBlock; 34 | import com.larryTheCoder.locales.LocaleInstance; 35 | import lombok.Getter; 36 | 37 | import java.util.Arrays; 38 | import java.util.List; 39 | 40 | /** 41 | * A better way to express a SubCommand class. 42 | *

43 | * SubCommand was a class where commands are being separated from the base command. 44 | * However, if a new command need to be added, a new class extending SubCommand class is needed 45 | * in order to have full functionality of the command. 46 | *

47 | * This class adds all commands into few different categories where the commands can be added 48 | * or removed within category class at the same time without having to create another SubCommand class. 49 | */ 50 | public abstract class SubCategory { 51 | 52 | @Getter 53 | private final ASkyBlock plugin; 54 | 55 | protected SubCategory(ASkyBlock plugin) { 56 | Preconditions.checkNotNull(plugin, "ASkyBlock cannot be nullified"); 57 | 58 | this.plugin = plugin; 59 | } 60 | 61 | protected LocaleInstance getLocale(Player key) { 62 | return plugin.getLocale(key); 63 | } 64 | 65 | protected String getPrefix() { 66 | return plugin.getPrefix(); 67 | } 68 | 69 | public List baseCommands() { 70 | return Arrays.asList("is", "island"); 71 | } 72 | 73 | /** 74 | * Return a list of command provided by this category. 75 | * 76 | * @return a set of string provided by this category. 77 | */ 78 | public abstract List getCommands(); 79 | 80 | /** 81 | * Execute a command provided by this category. 82 | * 83 | * @param sender The sender requests to execute this category. 84 | * @param commandLabel The label of the command, usually it will returns 'is' 85 | * @param args The command arguments 86 | */ 87 | public abstract void execute(CommandSender sender, String commandLabel, String[] args); 88 | 89 | /** 90 | * Checks either these commands can be used by this sender or not. 91 | * 92 | * @param sender CommandSender 93 | * @return boolean 94 | */ 95 | public abstract boolean canUse(CommandSender sender, String command); 96 | 97 | /** 98 | * Get a description of a command. This is useful when it comes to know 99 | * what command does this do. 100 | * 101 | * @param commandName The command name 102 | * @return The description of the command. 103 | */ 104 | public abstract String getDescription(String commandName); 105 | 106 | /** 107 | * Get the parameters required for the command. 108 | * 109 | * @param commandName The command name 110 | * @return The parameters required for the command. 111 | */ 112 | public abstract String getParameters(String commandName); 113 | 114 | /** 115 | * Check either the sender has the permission to execute this command 116 | * using the libraries present in the server. 117 | * 118 | * @param sender The command sender that executes this command. 119 | * @param permission The permission node name. 120 | * @return {@code true} if the player has the permission. 121 | */ 122 | public boolean hasPermission(CommandSender sender, String permission) { 123 | return ASkyBlock.get().getPermissionHandler().hasPermission(sender, permission); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: "${name}" 2 | version: "${version}" 3 | author: "larryTheCoder" 4 | api: 5 | - "1.0.6" 6 | - "1.0.7" 7 | - "1.0.8" 8 | - "1.0.9" 9 | - "1.0.10" 10 | - "1.0.11" 11 | main: com.larryTheCoder.ASkyBlock 12 | website: http://github.com/larryTheCoder/ASkyBlock 13 | authors: 14 | - PikyCZ 15 | - Skull3x 16 | - Adam1609 17 | softdepend: 18 | - EconomyAPI 19 | - LuckPerms 20 | - DbLib 21 | - MobPlugin 22 | 23 | description: "Advanced minecraft PE SkyBlock plugin!" 24 | 25 | permissions: 26 | # Island create perm 27 | is.create: 28 | default: true 29 | description: "Create an island" 30 | is.home.1: 31 | default: true 32 | description: "Allow the player to create an island with home 1" 33 | # On /is command perm 34 | is.command: 35 | default: true 36 | description: "SkyBlock main command" 37 | is.gamemode.bypass: 38 | default: op 39 | description: "Enables gamemode bypass to teleport into the SkyBlock world." 40 | # Island team chatting command 41 | is.command.teamChat: 42 | default: true 43 | description: "Enable chatting with team" 44 | # Island messages command 45 | is.command.message: 46 | default: true 47 | description: "Read the offline messages" 48 | # Kick player from owner's island 49 | is.command.expel: 50 | default: true 51 | description: "Kick a player from your island" 52 | # Island leave permission 53 | is.command.leave: 54 | default: true 55 | description: "leave island" 56 | # Message language (this is what I am waiting for!) 57 | is.command.lang: 58 | default: true 59 | description: "Set your default language" 60 | # Island spawn 61 | is.command.setspawn: 62 | default: op 63 | description: "Set the island main spawn." 64 | # Reset island command? or Delete island command... 65 | is.command.reset: 66 | default: true 67 | description: "Reset player island" 68 | # Island home permission 69 | is.command.home: 70 | default: true 71 | description: "Teleport back to home" 72 | # Get island info 73 | is.command.info: 74 | default: true 75 | description: "get the players island info" 76 | # Teleport or warp? Hmmm... 77 | is.command.teleport: 78 | default: true 79 | description: "Teleport to other island!" 80 | # Has an invitation? Of course! 81 | is.command.accept: 82 | default: true 83 | description: "accept an invitation" 84 | # Sorry I didn't like to join you 85 | is.command.reject: 86 | default: true 87 | description: "Reject an invitation" 88 | # Edit island. eg biome, name 89 | is.command.edit: 90 | default: true 91 | description: "Edit your island information" 92 | # Invite me please! 93 | is.command.invite: 94 | default: true 95 | description: "Invite a player" 96 | # I did like this world please 97 | is.command.setworld: 98 | default: true 99 | description: "Set the player default world (Where island were generated)" 100 | # This is the setting panel 101 | is.panel.setting: 102 | default: true 103 | description: "A Setting panel for your island" 104 | is.panel.protection: 105 | default: true 106 | description: "Set your island protection settings" 107 | # These are bypass perm 108 | is.mod.bypassprotect: 109 | default: op 110 | description: "Bypass the island Guard settings" 111 | is.mod.bypasslock: 112 | default: op 113 | description: "Bypass the island Lock settings" 114 | is.craft.enderchest: 115 | default: op 116 | description: "Bypass the enderchest usage" 117 | is.bypass.wait: 118 | default: op 119 | description: "Bypass the reset timer" 120 | # Admin on /isa command 121 | is.admin.command: 122 | default: op 123 | description: "Admin main command" 124 | # Admin Island Command 125 | is.admin.generate: 126 | default: op 127 | description: "Generate a new island world" 128 | # Admin kick command 129 | is.admin.kick: 130 | default: op 131 | description: "Kick a player from island world" 132 | is.admin.rename: 133 | default: op 134 | description: "Rename other players island" 135 | is.admin.setspawn: 136 | default: op 137 | description: "Set the world island location" 138 | is.admin.delete: 139 | default: op 140 | description: "Delete an island" 141 | is.admin.clear: 142 | default: op 143 | description: "Flushes all he memory in the plugin" 144 | is.admin.cobblestats: 145 | default: op 146 | description: "Get all the cobblestone generator stats" 147 | is.admin.completechallenge: 148 | default: op 149 | description: "Complete the challenge for a player." 150 | is.admin.resetchallenge: 151 | default: op 152 | description: "Reset the challenge for a player." 153 | is.admin.challanges: 154 | default: op 155 | description: "Check information on the given player." 156 | is.topten: 157 | default: true 158 | description: "Be able to get into topten leaderboard." 159 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/listener/invitation/Invitation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.listener.invitation; 28 | 29 | import cn.nukkit.Player; 30 | import cn.nukkit.command.CommandSender; 31 | import cn.nukkit.utils.TextFormat; 32 | import com.larryTheCoder.ASkyBlock; 33 | import com.larryTheCoder.cache.IslandData; 34 | import com.larryTheCoder.utils.Settings; 35 | 36 | /** 37 | * @author larryTheCoder 38 | */ 39 | public class Invitation { 40 | 41 | private final InvitationHandler handler; 42 | private final CommandSender sender; 43 | private final Player receiver; 44 | private final ASkyBlock plugin; 45 | private final IslandData islandData; 46 | 47 | private int time; 48 | 49 | /** 50 | * Invitation constructor. 51 | * 52 | * @param handler The classloader for invite handler 53 | * @param sender The sender of this invite 54 | * @param receiver The receiver of this invite 55 | */ 56 | Invitation(InvitationHandler handler, CommandSender sender, Player receiver, IslandData islandData) { 57 | this.handler = handler; 58 | this.sender = sender; 59 | this.receiver = receiver; 60 | this.islandData = islandData; 61 | this.time = Settings.memberTimeOut; 62 | this.plugin = ASkyBlock.get(); 63 | } 64 | 65 | /** 66 | * Return invitation sender 67 | * 68 | * @return CommandSender 69 | */ 70 | public CommandSender getSender() { 71 | return sender; 72 | } 73 | 74 | /** 75 | * Return invitation receiver 76 | * 77 | * @return Player 78 | */ 79 | Player getReceiver() { 80 | return receiver; 81 | } 82 | 83 | public void acceptInvitation() { 84 | sender.sendMessage(plugin.getPrefix() + plugin.getLocale(sender.isPlayer() ? (Player) sender : null).acceptedTo.replace("[player]", receiver.getName())); 85 | receiver.sendMessage(plugin.getPrefix() + plugin.getLocale(receiver).acceptedFrom.replace("[player]", sender.getName())); 86 | 87 | // TODO: Compliance under Co-Op regulatory and settings. 88 | // List dataList = plugin.getIslandsInfo(receiver.getName()); 89 | // // Check if the player has an island 90 | // if (!dataList.isEmpty()) { 91 | // receiver.sendMessage(plugin.getPrefix() + "Deleting all of your islands"); 92 | // //dataList.forEach((island) -> plugin.getDatabase().deleteIsland(island)); 93 | // } 94 | // 95 | // // Set the team from the sender and the receiver. 96 | // plugin.getTManager().setTeam(sender.getName(), receiver.getName()); 97 | // handler.removeInvitation(this); 98 | } 99 | 100 | public void denyInvitation() { 101 | sender.sendMessage(plugin.getPrefix() + TextFormat.RED + receiver.getName() + " denied your invitation!"); 102 | receiver.sendMessage(plugin.getPrefix() + TextFormat.RED + "You denied " + sender.getName() + "'s invitation!"); 103 | 104 | // Otherwise remove this. 105 | handler.removeInvitation(this); 106 | } 107 | 108 | private void expire() { 109 | receiver.sendMessage(plugin.getPrefix() + TextFormat.RED + "The invitation from " + sender.getName() + " expired!"); 110 | sender.sendMessage(plugin.getPrefix() + TextFormat.RED + "The invitation to " + receiver + " expired!"); 111 | } 112 | 113 | boolean tick() { 114 | // Fix infinite expire time 115 | time--; 116 | if (time <= 0) { 117 | expire(); 118 | return false; 119 | } 120 | return true; 121 | } 122 | 123 | @Override 124 | public int hashCode() { 125 | int userData = sender.getName().hashCode(); 126 | int receiverData = sender.getName().hashCode(); 127 | 128 | return (userData / receiverData) + super.hashCode(); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/cache/CoopData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.cache; 29 | 30 | import cn.nukkit.Player; 31 | import com.larryTheCoder.ASkyBlock; 32 | import com.larryTheCoder.database.QueryInfo; 33 | import com.larryTheCoder.utils.Utils; 34 | import lombok.Getter; 35 | import org.sql2o.data.Row; 36 | 37 | import java.util.List; 38 | 39 | /** 40 | * Stores coop data. 41 | */ 42 | public class CoopData { 43 | 44 | @Getter 45 | private final String islandUniqueId; 46 | 47 | @Getter 48 | private String leaderName; 49 | @Getter 50 | private String teamName; 51 | @Getter 52 | private final List members; 53 | @Getter 54 | private final List admins; 55 | 56 | public CoopData(Row coopData) { 57 | this.islandUniqueId = coopData.getString("defaultIsland"); 58 | this.leaderName = coopData.getString("islandLeader"); 59 | this.teamName = coopData.getString("islandLeader"); 60 | this.members = Utils.stringToArray(coopData.getString("islandMembers"), ", "); 61 | this.admins = Utils.stringToArray(coopData.getString("islandAdmins"), ", "); 62 | } 63 | 64 | /** 65 | * Sets this island leader name, this overrides 66 | * the original island owner from island data. 67 | * 68 | * @param playerName The player name. 69 | */ 70 | public void setLeaderName(String playerName) { 71 | this.leaderName = playerName; 72 | 73 | updateData(); 74 | } 75 | 76 | /** 77 | * Sets the name for this coop island. 78 | * Self-explanatory. 79 | * 80 | * @param teamName The name of the team. 81 | */ 82 | public void setTeamName(String teamName) { 83 | this.teamName = teamName; 84 | 85 | updateData(); 86 | } 87 | 88 | /** 89 | * Check either this player is an admin in this island. 90 | * 91 | * @param pl The player class 92 | * @return true if the player is an admin, false if otherwise. 93 | */ 94 | public boolean isAdmin(Player pl) { 95 | return admins.stream().anyMatch(o -> o.equalsIgnoreCase(pl.getName())); 96 | } 97 | 98 | /** 99 | * Check if the player with this name is a member of this 100 | * island relations. 101 | * 102 | * @param plName The player name itself. 103 | * @return {@code true} if the player is the member of this island 104 | */ 105 | public boolean isMember(String plName) { 106 | return members.stream().anyMatch(i -> i.equalsIgnoreCase(plName)) || plName.equalsIgnoreCase(leaderName); 107 | } 108 | 109 | /** 110 | * Adds a player name into this coop list, the new member will 111 | * always be related to this island. 112 | * 113 | * @param plName self-explanatory 114 | */ 115 | public void addMember(String plName) { 116 | this.members.add(plName); 117 | 118 | updateData(); 119 | } 120 | 121 | /** 122 | * Removes a player from this coop list. 123 | * 124 | * @param member self-explanatory 125 | */ 126 | public void removeMember(String member) { 127 | this.members.remove(member); 128 | 129 | updateData(); 130 | } 131 | 132 | private void updateData() { 133 | ASkyBlock.get().getDatabase().executeUpdate(new QueryInfo("UPDATE islandRelations SET islandLeader = :teamName, islandLeader = :leaderName, islandMembers = :members WHERE defaultIsland = :islandUniqueId") 134 | .addParameter("islandUniqueId", islandUniqueId) 135 | .addParameter("leaderName", leaderName) 136 | .addParameter("teamName", teamName) 137 | .addParameter("admins", Utils.arrayToString(admins)) 138 | .addParameter("members", Utils.arrayToString(members)) 139 | ); 140 | } 141 | 142 | @Override 143 | public int hashCode() { 144 | int i = 60; 145 | i += leaderName.hashCode(); 146 | i += teamName.hashCode() / 32; 147 | 148 | return i + super.hashCode(); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/main/resources/locale/en_US.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################### 2 | # This is a YML file. Be careful when editing. Check your edits in a YAML checker like # 3 | # the one at http://yaml-online-parser.appspot.com # 4 | ########################################################################################### 5 | # Note: looking for translators to help translate all of these 6 | --- 7 | firstIslandFree: "§aYour first island are free!" 8 | nextIslandPrice: "§aNext time you may need $§e[price] to buy other island" 9 | # Help defaults 10 | adminHelpGenerate: "§aAttempt to create a new level." 11 | adminHelpKick: "§aTo kick player from island worlds." 12 | adminHelpRename: "§aAttempt to rename other player's island." 13 | adminHelpSpawn: "§aSet the island's spawn point!" 14 | adminHelpDelete: "§aDelete other player island" 15 | # Errors defaults 16 | errorUnknownPlayer: "§cThat player is unknown." 17 | errorNoPermission: "§cYou don't have permission to use that command!" 18 | errorNoIsland: "§cYou do not have an island!" 19 | errorNoIslandOther: "§cThat player does not have an island!" 20 | errorCommandNotReady: "§cYou can't use that command right now." 21 | errorCommandBlocked: "§cYou can't use that command here." 22 | errorOfflinePlayer: "§cThat player is offline or doesn't exist." 23 | errorNotOnIsland: "§cYou are not in your/other's island space!" 24 | errorTooLong: "§cToo long. Maximum size is [length]." 25 | errorTooShort: "§cToo short. Minimum size is [length]." 26 | adminSetSpawnOverride: "§cThere a player owned this plot. Admin override this command" 27 | errorTooSoon: "§cYou need to wait [secs] to [cmd] your island" 28 | errorUseInGame: "§cThis command must be used in-game." 29 | errorWrongWorld: "§cYou cannot do that in this world." 30 | errorUnknownWorld: "§cUnknown world. Possible worlds are:" 31 | errorMaxIsland: "§cSorry you cant create island at this world any more" 32 | errorNotPending: "§cNo invitation pending! Try again later" 33 | errorInTeam: "§cThe player [player] are already in team!" 34 | errorBlockedByAPI: "§cA plugin using the API blocked this action." 35 | errorKickOwner: "§cYou cant kick yourself out your own island!" 36 | errorAdminOnly: "§cYou cant kick admins from your island!" 37 | errorFailedNormal: "§cInvalid or wrong parameters" 38 | errorFailedCritical: "§cFailed to attempt this command. Contact admin!" 39 | errorLevelGenerated: "§cThe level has already generated" 40 | errorNotEnoughMoney: "§cYou don't have enough money! Default price: $[price]" 41 | errorIslandPC: "§cCannot attempt to generate level. PC Type of schematic" 42 | # Commands messages 43 | kickSuccess: "§aKicked [player] from SkyBlock world!" 44 | createSuccess: "§aSuccessfully created you an island!" 45 | resetSuccess: "§aSuccessfully cleared your island!" 46 | renameSuccess: "§aSuccessfully renamed island!" 47 | setWorldSuccess: "§aSuccessfully changed island world location!" 48 | setHomeSuccess: "§aSuccessfully changed island home location!" 49 | generalSuccess: "§aSuccess!" 50 | biomeChangeComplete: "§aChanged your island biome to: [biome]" 51 | # Teleport messages 52 | teleportDelay: "§aYou will be teleported in {0} seconds." 53 | teleportCancelled: "§cTeleport cancelled" 54 | # Admin commands message 55 | adminOverride: "§aYou override this command" 56 | adminDeleteIslandError: "§cUse §ldelete confirm §r§cto delete the [player]'s island." 57 | adminDeleteIslandnoid: "§cCannot identify island." 58 | adminDeleteIslandUse: "§rUse §ldelete [name] §r§cto delete the player instead." 59 | adminSetSpawnOwnedBy: "§cThis island space is owned by [name]" 60 | # Team messages 61 | teamChatStatusOff: "§aTeam chat is off" 62 | teamChatStatusOn: "§aTeam chat is on" 63 | teamChatNoTeamAround: "§cNone of your team are online!" 64 | # Others 65 | hangInThere: "§eHang in there. Finding your best safe teleport position..." 66 | deleteRemoving: "§cRemoving [name]'s island." 67 | kickedFromOwner: "§eYou were kicked from island owned by [name]." 68 | kickedFromAdmin: "§eYou were kicked by Admin on duty." 69 | kickedFromTeam: "§eYou were kicked from [name]'s team" 70 | newsHeadline: "§aWhile you were §eOffline§a:" 71 | newsEmpty: "§aThere no messages for you today. Check back later!" 72 | newNews: "§eWelcome back! There's [count] news today! Use /is messages to see all messages" 73 | newInvitation: "§aNew invitation from [player]'s island" 74 | acceptedFrom: "§eYou accepted [player]'s invitation." 75 | acceptedTo: "§e[player] has accepted your invitation!" 76 | panelCancelled: "§cYou cancelled your island panel!" 77 | # Titles 78 | islandSubTitle: "&eNice and cosy" 79 | islandDonate: "§aSource code made by §e@larryTheCoder" 80 | islandURL: "§aLink: http://github.com/larryTheCoder/ASkyBlock-Nukkit" 81 | islandSupport: "§aLove it? Give us a star on GitHub!" 82 | islandTitle: "[player]'s island" 83 | groundNoAir: "§eWhat do you think you are? You can't set home on air!" 84 | # Guard island 85 | islandProtected: "§cThat island is protected" 86 | # Panels 87 | panelIslandHeader: "§eWelcome to the Island Panel. Please fill in these forms." 88 | panelIslandHome: "§dYour Home Name." 89 | panelIslandTemplate: "§dIsland Templates" 90 | panelIslandDefault: "§eThese are your island Settings." 91 | panelIslandWorld: "§dChoose your world" 92 | panelChallengesHeader: "§aChoose your toppings! All of these are your challenges to complete! You will be awarded with an amazing prize!" 93 | panelHomeHeader: "§dHere are all of the list of your islands. Choose one of these to [function]" 94 | panelSettingHeader: "§eYou can make an simple changes for your island. You can set your island any time." 95 | deleteIslandSure: "§aAre you sure to delete your island? This is an irreversible!" 96 | deleteIslandCancelled: "§cYou just cancelled your delete island confirmation" 97 | # Public error 98 | errorResponseUnknown: "§eAn error just occured. Try again later" -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/command/category/ChatCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.command.category; 29 | 30 | import cn.nukkit.Player; 31 | import cn.nukkit.Server; 32 | import cn.nukkit.command.CommandSender; 33 | import com.larryTheCoder.ASkyBlock; 34 | 35 | import java.util.Arrays; 36 | import java.util.List; 37 | 38 | /** 39 | * ChatCategory, command that handles everything that is related 40 | * to chat-interaction. 41 | *

42 | * The commands are as follows: 43 | * - /is chat => Allows members to chat within their member teams. 44 | * - /is messages => Get the news from a server/leader. 45 | *

46 | * This category is TBD. 47 | */ 48 | public class ChatCategory extends SubCategory { 49 | 50 | public ChatCategory(ASkyBlock plugin) { 51 | super(plugin); 52 | } 53 | 54 | @Override 55 | public List getCommands() { 56 | return Arrays.asList("chat", "messages"); 57 | } 58 | 59 | @Override 60 | public boolean canUse(CommandSender sender, String command) { 61 | switch (command.toLowerCase()) { 62 | case "chat": 63 | return hasPermission(sender, "is.command.teamChat") && sender.isPlayer(); 64 | case "messages": 65 | return hasPermission(sender, "is.command.messages") && sender.isPlayer(); 66 | default: 67 | return false; 68 | } 69 | } 70 | 71 | @Override 72 | public String getDescription(String commandName) { 73 | switch (commandName.toLowerCase()) { 74 | case "chat": 75 | return "Chat with your island members."; 76 | case "messages": 77 | return "Read a new messages from island leader."; 78 | default: 79 | return null; 80 | } 81 | } 82 | 83 | @Override 84 | public String getParameters(String commandName) { 85 | return ""; 86 | } 87 | 88 | @Override 89 | public void execute(CommandSender sender, String commandLabel, String[] args) { 90 | Player p = Server.getInstance().getPlayer(sender.getName()); 91 | 92 | switch (args[0].toLowerCase()) { 93 | case "chat": 94 | if (getPlugin().getIslandManager().checkIsland(p)) { 95 | sender.sendMessage(getPrefix() + getLocale(p).errorNoIsland); 96 | break; 97 | } 98 | 99 | getPlugin().getFastCache().getRelations(p.getName(), pd -> { 100 | if (pd == null) { 101 | return; 102 | } 103 | 104 | // Check if team members are online 105 | boolean online = false; 106 | for (String teamMember : pd.getMembers()) { 107 | if (!teamMember.equals(p.getName()) && getPlugin().getServer().getPlayer(teamMember) != null) { 108 | online = true; 109 | } 110 | } 111 | if (!online) { 112 | p.sendMessage(getPrefix() + getLocale(p).teamChatNoTeamAround); 113 | p.sendMessage(getPrefix() + getLocale(p).teamChatStatusOff); 114 | getPlugin().getChatHandler().unSetPlayer(p); 115 | return; 116 | } 117 | 118 | if (getPlugin().getChatHandler().isTeamChat(p)) { 119 | // Toggle 120 | p.sendMessage(getPrefix() + getLocale(p).teamChatStatusOff); 121 | getPlugin().getChatHandler().unSetPlayer(p); 122 | } else { 123 | p.sendMessage(getPrefix() + getLocale(p).teamChatStatusOn); 124 | getPlugin().getChatHandler().setPlayer(p); 125 | } 126 | }); 127 | break; 128 | case "messages": 129 | List list = getPlugin().getMessages().getMessages(p.getName()); 130 | if (!list.isEmpty()) { 131 | p.sendMessage(getPlugin().getLocale(p).newsHeadline); 132 | list.forEach((i) -> p.sendMessage("- §e" + i)); 133 | getPlugin().getMessages().clearMessages(p.getName()); 134 | } else { 135 | p.sendMessage(getPrefix() + getPlugin().getLocale(p).newsEmpty); 136 | } 137 | break; 138 | } 139 | 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/utils/classpath/Autoloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.utils.classpath; 29 | 30 | import cn.nukkit.utils.TextFormat; 31 | import com.google.common.collect.Maps; 32 | import com.larryTheCoder.ASkyBlock; 33 | import com.larryTheCoder.locales.FileLister; 34 | import com.larryTheCoder.utils.Utils; 35 | import lombok.Cleanup; 36 | import lombok.SneakyThrows; 37 | import lombok.extern.log4j.Log4j2; 38 | 39 | import java.io.File; 40 | import java.io.FileOutputStream; 41 | import java.io.IOException; 42 | import java.lang.reflect.Method; 43 | import java.net.URL; 44 | import java.net.URLClassLoader; 45 | import java.nio.channels.Channels; 46 | import java.nio.channels.ReadableByteChannel; 47 | import java.util.List; 48 | import java.util.Map; 49 | 50 | /** 51 | * Attempts to load the required libraries and inject its classpath 52 | * into the server/plugin. 53 | */ 54 | @Log4j2 55 | public class Autoloader { 56 | 57 | private final Map reqLib = Maps.newHashMap(); 58 | private final String targetFolder; 59 | 60 | private List files; 61 | 62 | public Autoloader(String targetFolder) { 63 | reqLib.put("sql2o-1.6.0.jar", "https://repo1.maven.org/maven2/org/sql2o/sql2o/1.6.0/sql2o-1.6.0.jar"); 64 | reqLib.put("mysql-connector-java-8.0.16.jar", "https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.16/mysql-connector-java-8.0.16.jar"); 65 | reqLib.put("sqlite-jdbc-3.27.2.1.jar", "https://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.27.2.1/sqlite-jdbc-3.27.2.1.jar"); 66 | 67 | this.targetFolder = targetFolder; 68 | 69 | searchDirectory(targetFolder); 70 | attemptAutoloadMerge(); 71 | } 72 | 73 | private void searchDirectory(String targetFolder) { 74 | try { 75 | files = new FileLister(targetFolder, false).list(); 76 | } catch (IOException e) { 77 | throw new RuntimeException(e); 78 | } 79 | } 80 | 81 | private void attemptAutoloadMerge() { 82 | // Step 1: Attempts to check if database libraries are present. 83 | try { 84 | Class.forName("com.mysql.cj.jdbc.Driver"); 85 | Class.forName("org.sqlite.JDBC"); 86 | Class.forName("org.sql2o.Sql2o"); 87 | 88 | log.debug("Found required libraries, no download needed."); 89 | return; 90 | } catch (ClassNotFoundException ignored) { 91 | } 92 | 93 | // Step 2: Attempt to download the required libraries from desired site. 94 | reqLib.keySet().stream().filter(lib -> files.stream().noneMatch(i -> i.equalsIgnoreCase(lib))).forEach(libs -> { 95 | log.info(ASkyBlock.get().getPrefix() + TextFormat.YELLOW + "Attempting to download library: " + libs); 96 | 97 | try { 98 | final URL website = new URL(reqLib.get(libs)); 99 | 100 | @Cleanup final ReadableByteChannel rbc = Channels.newChannel(website.openStream()); 101 | 102 | @Cleanup final FileOutputStream fos = new FileOutputStream(Utils.DIRECTORY + targetFolder + File.separator + libs); 103 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 104 | } catch (IOException exception) { 105 | throw new RuntimeException("Please check your internet connection before installing...", exception); 106 | } 107 | }); 108 | 109 | File mysqlDriver = new File(Utils.DIRECTORY + targetFolder + File.separator + "mysql-connector-java-8.0.16.jar"); 110 | File sqliteDriver = new File(Utils.DIRECTORY + targetFolder + File.separator + "sqlite-jdbc-3.27.2.1.jar"); 111 | File sql2oDriver = new File(Utils.DIRECTORY + targetFolder + File.separator + "sql2o-1.6.0.jar"); 112 | 113 | try { 114 | // Step 3: Merge these libraries 115 | injectClass(mysqlDriver, "com.mysql.cj.jdbc.Driver"); 116 | injectClass(sqliteDriver, "org.sqlite.JDBC"); 117 | injectClass(sql2oDriver, "org.sql2o.Sql2o"); 118 | 119 | log.debug("Injected database libraries."); 120 | } catch (Throwable err) { 121 | err.printStackTrace(); 122 | } 123 | } 124 | 125 | @SneakyThrows 126 | private void injectClass(File file, String classLoader) { 127 | log.debug("Attempting to reflect " + classLoader + " classpath"); 128 | 129 | URLClassLoader autoload = (URLClassLoader) ClassLoader.getSystemClassLoader(); 130 | Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); 131 | method.setAccessible(true); 132 | method.invoke(autoload, file.toURI().toURL()); 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/resources/locale/de_DE.yml: -------------------------------------------------------------------------------- 1 | ########################################################################################### 2 | # This is a YML file. Be careful when editing. Check your edits in a YAML checker like # 3 | # the one at http://yaml-online-parser.appspot.com # 4 | ########################################################################################### 5 | # Note: looking for translators to help translate all of these 6 | --- 7 | firstIslandFree: "§aDeine erste Insel ist kostenlos!" 8 | nextIslandPrice: "§aWenn du eine weitere Insel kaufen möchtest kostet diese $§e[price]" 9 | # Help defaults 10 | adminHelpGenerate: "§aErstellt eine neue Welt." 11 | adminHelpKick: "§aSchmeißt Spiele von einer Insel." 12 | adminHelpRename: "§aVerändert den Namen der Insel eines Spielers." 13 | adminHelpSpawn: "§aSetzt den Insel Spawn." 14 | adminHelpDelete: "§aLöscht eine Insel eines Spielers." 15 | # Errors defaults 16 | errorUnknownPlayer: "§cDieser Spieler ist Unbekannt!" 17 | errorNoPermission: "§cDu hast keine Berechtigung diesen Command zu benutzen!" 18 | errorNoIsland: "§cDu hast noch keine Insel! Benutze /is help für mehr Informationen." 19 | errorNoIslandOther: "§cDieser Spieler hat keine Insel!" 20 | errorCommandNotReady: "§cDu kannst diesen Command gerade nicht benutzen!" 21 | errorCommandBlocked: "§cDu kannst diesen Command hier nicht nutzen!" 22 | errorOfflinePlayer: "§cDieser Spieler ist offline oder existiert nicht!" 23 | errorNotOnIsland: "§cDu bist nicht auf deiner/einer Insel!" 24 | errorTooLong: "§cZu lang. Die Maximale Länge beträgt [length]." 25 | errorTooShort: "§cZu kurz. Die minimalste länge beträgt [length]." 26 | adminSetSpawnOverride: "§cDort besitzt ein Spieler ein Grundsück. Ein Admin überschreibt diesen Command." 27 | errorTooSoon: "§cWarte noch [secs] um [cmd] zu deiner Insel." 28 | errorUseInGame: "§cDieser Command funktioniert nur Ingame." 29 | errorWrongWorld: "§cDas kannst du in dieser Welt nicht machen." 30 | errorUnknownWorld: "§cUnbekannte Welt. Mögliche Welten:" 31 | errorMaxIsland: "§cEntschuldigung, du kannst keine weitere Insel in dieser Welt erstellen." 32 | errorNotPending: "§cEs steht keine Einladung aus! Versuche es später nochmal." 33 | errorInTeam: "§cDer Spieler [player] ist bereits im Team!" 34 | errorBlockedByAPI: "§cEin Plugin, das die API benutzt blockt diesen Command!" 35 | errorKickOwner: "§cDu kannst dich nicht selber von deiner Insel werfen!" 36 | errorAdminOnly: "§cDu kannst keine Admins von deiner Insel werfen!" 37 | errorFailedNormal: "§cUngültige oder falsche Parameter!" 38 | errorFailedCritical: "§cDieser Command funktioniert nicht, da ein Fehler aufgetreten ist. Kontaktiere einen Admin!" 39 | errorLevelGenerated: "§cDiese Welt wurde bereits erstellt!" 40 | errorNotEnoughMoney: "§cDu hast nicht genug Geld! Normal Preis: $[price]" 41 | errorIslandPC: "§cLevel konnte nicht erstellt werden." 42 | # Commands messages 43 | kickSuccess: "§a[player] wurde erfolgreich aus der SkyBlock Welt geworfen!" 44 | createSuccess: "§aDie Insel wurde erfolgreich erstellt! " 45 | resetSuccess: "§aDie Insel wurde erfolgreich geleert!" 46 | renameSuccess: "§aDie Insel wurde erfolgreich umgenannt!" 47 | setWorldSuccess: "§aDer Inselstandort wurde erfolgreiche geändert!" 48 | setHomeSuccess: "§aZuhause erfolgreich geändert!" 49 | generalSuccess: "§aErfolgreich!" 50 | biomeChangeComplete: "§aDein Insel Biom wurde erfolgreich geändert! Neues Biom: [biome]" 51 | # Teleport messages 52 | teleportDelay: "§aDu wirst in {0} Sekunden teleportiert!" 53 | teleportCancelled: "§cTeleportation abgebrochen." 54 | # Admin commands message 55 | adminOverride: "§aDu hast diesen Command überschrieben" 56 | adminDeleteIslandError: "§cBenutze §ldelete confirm um zu bestätigen §r§cdas [player]'s Insel gelöscht wird." 57 | adminDeleteIslandnoid: "§cKonnte Insel nicht identifizieren." 58 | adminDeleteIslandUse: "§rBenutze §ldelete [name] §r§cum den Spieler zu entfernen." 59 | adminSetSpawnOwnedBy: "§cDiese Insel gehört nun [name]" 60 | # Team messages 61 | teamChatStatusOff: "§aTeam-chat ist offline" 62 | teamChatStatusOn: "§aTeam-chat ist online" 63 | teamChatNoTeamAround: "§cNiemand aus deinem Team ist online!" 64 | # Others 65 | hangInThere: "§eWarte einen Moment. Suche die sicherste Teleport-Position..." 66 | deleteRemoving: "§cEntferne [name]'s Insel." 67 | kickedFromOwner: "§eDu wurdest von der Insel geworfen. Name: [name]." 68 | kickedFromAdmin: "§eDu wurdest von einem Admin rausgeworfen." 69 | kickedFromTeam: "§eDu wurdest aus [name]'s Team geworfen" 70 | newsHeadline: "§aWährend du §eOffline§a warst:" 71 | newsEmpty: "§aKeine neue Nachrichten für dich. Prüfe sie später nochmal!" 72 | newNews: "§eWillkommen zurück!! Es gibt [count] neue Nachrichten! Benutze /is messages um alle Nachrichten zu sehen." 73 | newInvitation: "§aNeue Einladung von [player]'s Insel!" 74 | acceptedFrom: "§eDu hast [player]'s Einladung akzeptiert!" 75 | acceptedTo: "§e[player] hat deine Einladung angenommen!" 76 | panelCancelled: "§cDu hast das Panel verlassen." 77 | # Titles 78 | islandSubTitle: "&eSchön & Gemütlich" 79 | islandDonate: "§aQuellcode: §e@larryTheCoder" 80 | islandURL: "§aLink: http://github.com/larryTheCoder/ASkyBlock-Nukkit" 81 | islandSupport: "§aDu magst es? Gib uns einen Stern auf GitHub!" 82 | islandTitle: "[player]'s Insel" 83 | groundNoAir: "§eDu kannst keine Zuhause in der Luft setzen..." 84 | # Guard island 85 | islandProtected: "§cDie Insel ist geschützt!" 86 | # Panels 87 | panelIslandHeader: "§eWillkommen zum Insel Panel. Bitte alles ausfüllen!" 88 | panelIslandHome: "§dDein Insel Name" 89 | panelIslandTemplate: "§dInsel Vorlage" 90 | panelIslandDefault: "§eDas sind deine Insel-Einstellungen" 91 | panelIslandWorld: "§dWähle deine Welt" 92 | panelChallengesHeader: "§aWähle deine Beläge! Das sind alle Herausforderungen die du erledigen musst! Du wirst mit Preisen belohnt!" 93 | panelHomeHeader: "§dHier ist eine Liste von all deinen Inseln. Wähle eine um [function]" 94 | panelSettingHeader: "§eDu kannst eine einfache Änderungen für deine Insel vornehmen. Du kannst immer deine Insel setzen!" 95 | deleteIslandSure: "§aBist du dir sicher das deine Insel gelöscht werden soll? Es kann nichts Rückgängig gemacht werden!" 96 | deleteIslandCancelled: "§cAbbruch. Deine Insel wurde nicht gelösch!" 97 | # Public error 98 | errorResponseUnknown: "§eEin Fehler ist aufgetreten. Versuche es später nochmal!" 99 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/command/category/IslandCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package com.larryTheCoder.command.category; 29 | 30 | import cn.nukkit.Player; 31 | import cn.nukkit.command.CommandSender; 32 | import com.larryTheCoder.ASkyBlock; 33 | import com.larryTheCoder.utils.BlockUtil; 34 | 35 | import java.util.Arrays; 36 | import java.util.List; 37 | 38 | public class IslandCategory extends SubCategory { 39 | 40 | public IslandCategory(ASkyBlock plugin) { 41 | super(plugin); 42 | } 43 | 44 | @Override 45 | public List getCommands() { 46 | return Arrays.asList("create", "reset", "delete", "home", "sethome", "teleport"); 47 | } 48 | 49 | @Override 50 | public boolean canUse(CommandSender sender, String command) { 51 | switch (command) { 52 | case "create": 53 | return hasPermission(sender, "is.create") && sender.isPlayer(); 54 | case "reset": 55 | case "delete": 56 | return hasPermission(sender, "is.command.reset") && sender.isPlayer(); 57 | case "home": 58 | case "sethome": 59 | return hasPermission(sender, "is.command.home") && sender.isPlayer(); 60 | case "teleport": 61 | return hasPermission(sender, "is.command.teleport") && sender.isPlayer(); 62 | } 63 | 64 | return false; 65 | } 66 | 67 | @Override 68 | public String getDescription(String commandName) { 69 | switch (commandName.toLowerCase()) { 70 | case "create": 71 | return "Start to create a new island."; 72 | case "reset": 73 | return "Reset your original island."; 74 | case "home": 75 | case "sethome": 76 | return "Set your island main spawn position."; 77 | case "teleport": 78 | return "Teleport to your island spawn position."; 79 | default: 80 | return null; 81 | } 82 | } 83 | 84 | @Override 85 | public String getParameters(String commandName) { 86 | if (commandName.toLowerCase().equals("teleport")) { 87 | return "[Home Number]"; 88 | } 89 | 90 | return ""; 91 | } 92 | 93 | @Override 94 | public void execute(CommandSender sender, String commandLabel, String[] args) { 95 | Player p = sender.getServer().getPlayer(sender.getName()); 96 | 97 | switch (args[0].toLowerCase()) { 98 | case "create": 99 | getPlugin().getPanel().addIslandFormOverlay(p); 100 | break; 101 | case "delete": 102 | case "reset": 103 | getPlugin().getPanel().addDeleteFormOverlay(p); 104 | break; 105 | case "home": 106 | // Only one home? Don't worry. we wont open the form overlay 107 | getPlugin().getFastCache().getIslandsFrom(p.getName(), listHome -> { 108 | if (listHome == null) { 109 | p.sendMessage(getPlugin().getLocale(p).errorFailedCritical); 110 | return; 111 | } 112 | 113 | if (listHome.size() == 1) { 114 | getPlugin().getGrid().homeTeleport(p); 115 | return; 116 | } 117 | 118 | getPlugin().getPanel().addHomeFormOverlay(p, listHome); 119 | }); 120 | break; 121 | case "sethome": 122 | getPlugin().getFastCache().getIslandData(p.getLocation(), pd -> { 123 | // Check if the ground is an air 124 | if (!BlockUtil.isBreathable(p.clone().add(p.down()).getLevelBlock())) { 125 | p.sendMessage(getLocale(p).groundNoAir); 126 | return; 127 | } 128 | // Check if the player on their own island or not 129 | if (pd != null && pd.getPlotOwner().equalsIgnoreCase(sender.getName())) { 130 | pd.setHomeLocation(p.getLocation()); 131 | pd.saveIslandData(); 132 | 133 | p.sendMessage(getLocale(p).setHomeSuccess); 134 | } else { 135 | p.sendMessage(getLocale(p).errorNotOnIsland); 136 | } 137 | }); 138 | break; 139 | case "teleport": 140 | if (args.length != 2) { 141 | break; 142 | } 143 | 144 | getPlugin().getIslandManager().teleportPlayer(p, args[1]); 145 | break; 146 | } 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/org/jnbt/NBTUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | package org.jnbt; 29 | 30 | /** 31 | * A class which contains NBT-related utility methods. 32 | * 33 | * @author Graham Edgecombe 34 | */ 35 | public final class NBTUtils { 36 | 37 | /** 38 | * Default private constructor. 39 | */ 40 | private NBTUtils() { 41 | 42 | } 43 | 44 | /** 45 | * Gets the type name of a tag. 46 | * 47 | * @param clazz The tag class. 48 | * @return The type name. 49 | */ 50 | public static String getTypeName(Class clazz) { 51 | if (clazz.equals(ByteArrayTag.class)) { 52 | return "TAG_Byte_Array"; 53 | } else if (clazz.equals(ByteTag.class)) { 54 | return "TAG_Byte"; 55 | } else if (clazz.equals(CompoundTag.class)) { 56 | return "TAG_Compound"; 57 | } else if (clazz.equals(DoubleTag.class)) { 58 | return "TAG_Double"; 59 | } else if (clazz.equals(EndTag.class)) { 60 | return "TAG_End"; 61 | } else if (clazz.equals(FloatTag.class)) { 62 | return "TAG_Float"; 63 | } else if (clazz.equals(IntTag.class)) { 64 | return "TAG_Int"; 65 | } else if (clazz.equals(ListTag.class)) { 66 | return "TAG_List"; 67 | } else if (clazz.equals(LongTag.class)) { 68 | return "TAG_Long"; 69 | } else if (clazz.equals(ShortTag.class)) { 70 | return "TAG_Short"; 71 | } else if (clazz.equals(StringTag.class)) { 72 | return "TAG_String"; 73 | } else { 74 | throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ")."); 75 | } 76 | } 77 | 78 | /** 79 | * Gets the type code of a tag class. 80 | * 81 | * @param clazz The tag class. 82 | * @return The type code. 83 | * @throws IllegalArgumentException if the tag class is invalid. 84 | */ 85 | public static int getTypeCode(Class clazz) { 86 | if (clazz.equals(ByteArrayTag.class)) { 87 | return NBTConstants.TYPE_BYTE_ARRAY; 88 | } else if (clazz.equals(ByteTag.class)) { 89 | return NBTConstants.TYPE_BYTE; 90 | } else if (clazz.equals(CompoundTag.class)) { 91 | return NBTConstants.TYPE_COMPOUND; 92 | } else if (clazz.equals(DoubleTag.class)) { 93 | return NBTConstants.TYPE_DOUBLE; 94 | } else if (clazz.equals(EndTag.class)) { 95 | return NBTConstants.TYPE_END; 96 | } else if (clazz.equals(FloatTag.class)) { 97 | return NBTConstants.TYPE_FLOAT; 98 | } else if (clazz.equals(IntTag.class)) { 99 | return NBTConstants.TYPE_INT; 100 | } else if (clazz.equals(ListTag.class)) { 101 | return NBTConstants.TYPE_LIST; 102 | } else if (clazz.equals(LongTag.class)) { 103 | return NBTConstants.TYPE_LONG; 104 | } else if (clazz.equals(ShortTag.class)) { 105 | return NBTConstants.TYPE_SHORT; 106 | } else if (clazz.equals(StringTag.class)) { 107 | return NBTConstants.TYPE_STRING; 108 | } else { 109 | throw new IllegalArgumentException("Invalid tag classs (" + clazz.getName() + ")."); 110 | } 111 | } 112 | 113 | /** 114 | * Gets the class of a type of tag. 115 | * 116 | * @param type The type. 117 | * @return The class. 118 | * @throws IllegalArgumentException if the tag type is invalid. 119 | */ 120 | public static Class getTypeClass(int type) { 121 | switch (type) { 122 | case NBTConstants.TYPE_END: 123 | return EndTag.class; 124 | case NBTConstants.TYPE_BYTE: 125 | return ByteTag.class; 126 | case NBTConstants.TYPE_SHORT: 127 | return ShortTag.class; 128 | case NBTConstants.TYPE_INT: 129 | return IntTag.class; 130 | case NBTConstants.TYPE_LONG: 131 | return LongTag.class; 132 | case NBTConstants.TYPE_FLOAT: 133 | return FloatTag.class; 134 | case NBTConstants.TYPE_DOUBLE: 135 | return DoubleTag.class; 136 | case NBTConstants.TYPE_BYTE_ARRAY: 137 | return ByteArrayTag.class; 138 | case NBTConstants.TYPE_STRING: 139 | return StringTag.class; 140 | case NBTConstants.TYPE_LIST: 141 | return ListTag.class; 142 | case NBTConstants.TYPE_COMPOUND: 143 | return CompoundTag.class; 144 | default: 145 | throw new IllegalArgumentException("Invalid tag type : " + type + "."); 146 | } 147 | } 148 | 149 | } -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/task/UpdateBiomeTask.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder.task; 28 | 29 | import cn.nukkit.Player; 30 | import cn.nukkit.command.CommandSender; 31 | import cn.nukkit.level.Level; 32 | import cn.nukkit.level.Position; 33 | import cn.nukkit.level.biome.Biome; 34 | import cn.nukkit.level.biome.EnumBiome; 35 | import cn.nukkit.level.format.generic.BaseFullChunk; 36 | import cn.nukkit.scheduler.NukkitRunnable; 37 | import cn.nukkit.scheduler.Task; 38 | import com.larryTheCoder.ASkyBlock; 39 | import com.larryTheCoder.cache.IslandData; 40 | import com.larryTheCoder.cache.settings.WorldSettings; 41 | import com.larryTheCoder.utils.Settings; 42 | import com.larryTheCoder.utils.Utils; 43 | 44 | import java.util.ArrayList; 45 | import java.util.Iterator; 46 | import java.util.List; 47 | 48 | class UpdateBiomeTask extends Task { 49 | 50 | private final IslandData pd; 51 | private final CommandSender player; 52 | private final ASkyBlock plugin; 53 | 54 | public UpdateBiomeTask(ASkyBlock plugin, IslandData pd, CommandSender player) { 55 | this.plugin = plugin; 56 | this.pd = pd; 57 | this.player = player; 58 | } 59 | 60 | @Override 61 | public void onRun(int currentTick) { 62 | Player p = player.isPlayer() ? (Player) player : null; 63 | Level level = plugin.getServer().getLevelByName(pd.getLevelName()); 64 | WorldSettings settings = plugin.getSettings(pd.getLevelName()); 65 | 66 | int minX = pd.getMinProtectedX(); 67 | int minZ = pd.getMinProtectedZ(); 68 | int maxX = pd.getMinProtectedX() + pd.getProtectionSize(); 69 | int maxZ = pd.getMinProtectedZ() + pd.getProtectionSize(); 70 | 71 | // get the chunks for these locations 72 | final BaseFullChunk minChunk = level.getChunk(minX >> 4, minZ >> 4, true); 73 | final BaseFullChunk maxChunk = level.getChunk(maxX >> 4, maxZ >> 4, true); 74 | 75 | if (!minChunk.isGenerated() || !maxChunk.isGenerated()) { 76 | level.regenerateChunk(minChunk.getX(), minChunk.getZ()); 77 | level.regenerateChunk(maxChunk.getX(), maxChunk.getZ()); 78 | } 79 | 80 | List biomeToChanged = new ArrayList<>(); 81 | 82 | // Find out what chunks are within the island protection range 83 | for (int x = minChunk.getX(); x <= maxChunk.getX(); x++) { 84 | for (int z = minChunk.getZ(); z <= maxChunk.getZ(); z++) { 85 | Utils.loadChunkAt(new Position(x, 0, z, level)); 86 | // Loop in loop are not recommended. 87 | // So we separate some chunks and let the task do it works 88 | biomeToChanged.add(level.getChunk(x, z)); 89 | } 90 | } 91 | 92 | // Clear up any chunks in list 93 | if (!biomeToChanged.isEmpty()) { 94 | new NukkitRunnable() { 95 | 96 | @Override 97 | public void run() { 98 | Iterator iChunk = biomeToChanged.iterator(); 99 | int count = 0; 100 | while (iChunk.hasNext() && count++ < Settings.cleanRate) { 101 | BaseFullChunk chunk = iChunk.next(); 102 | for (int y = settings.getSeaLevel(); y < 255 - settings.getSeaLevel(); y++) { 103 | for (int x = 0; x < 16; x++) { 104 | for (int z = 0; z < 16; z++) { 105 | chunk.setBiomeId(x, z, getBiome(pd.getPlotBiome()).getId()); 106 | } 107 | } 108 | } 109 | level.generateChunkCallback(chunk.getX(), chunk.getZ(), chunk); 110 | iChunk.remove(); 111 | } 112 | if (biomeToChanged.isEmpty()) { 113 | player.sendMessage(plugin.getPrefix() + plugin.getLocale(p).biomeChangeComplete.replace("[biome]", pd.getPlotBiome())); 114 | this.cancel(); 115 | } 116 | } 117 | 118 | }.runTaskTimerAsynchronously(plugin, 0, 20); 119 | } 120 | } 121 | 122 | /** 123 | * Get Biome by name. 124 | * 125 | * @param name Name of biome. Name could contain symbol "_" instead of space 126 | * @return Biome. Null - when biome was not found 127 | */ 128 | private Biome getBiome(String name) { 129 | for (Biome biome : Biome.biomes) { 130 | if (biome != null) { 131 | if (biome.getName().equalsIgnoreCase(name.replace("_", " "))) return biome; 132 | } 133 | } 134 | return EnumBiome.PLAINS.biome; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/main/java/com/larryTheCoder/Messages.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Adapted from the Wizardry License 3 | * 4 | * Copyright (c) 2016-2020 larryTheCoder and contributors 5 | * 6 | * Permission is hereby granted to any persons and/or organizations 7 | * using this software to copy, modify, merge, publish, and distribute it. 8 | * Said persons and/or organizations are not allowed to use the software or 9 | * any derivatives of the work for commercial use or any other means to generate 10 | * income, nor are they allowed to claim this software as their own. 11 | * 12 | * The persons and/or organizations are also disallowed from sub-licensing 13 | * and/or trademarking this software without explicit permission from larryTheCoder. 14 | * 15 | * Any persons and/or organizations using this software must disclose their 16 | * source code and have it publicly available, include this license, 17 | * provide sufficient credit to the original authors of the project (IE: larryTheCoder), 18 | * as well as provide a link to the original project. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 21 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR 22 | * PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 23 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 25 | * USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | package com.larryTheCoder; 28 | 29 | import cn.nukkit.Player; 30 | import cn.nukkit.utils.Config; 31 | import com.larryTheCoder.utils.Utils; 32 | 33 | import java.util.ArrayList; 34 | import java.util.Collections; 35 | import java.util.HashMap; 36 | import java.util.List; 37 | 38 | /** 39 | * Handles offline messaging to players and teams 40 | * 41 | * @author tastybento 42 | * @author: larryTheCoder 43 | */ 44 | public class Messages { 45 | 46 | // TODO: REFACTOR THESE CODES 47 | 48 | // Offline Messages 49 | private final HashMap> messages = new HashMap<>(); 50 | private final ASkyBlock plugin; 51 | private Config messageStore; 52 | 53 | /** 54 | * @param plugin 55 | */ 56 | Messages(ASkyBlock plugin) { 57 | this.plugin = plugin; 58 | } 59 | 60 | /** 61 | * Returns what messages are waiting for the player or null if none 62 | * 63 | * @param p 64 | * @return List of messages 65 | */ 66 | public List getMessages(String p) { 67 | List playerMessages = messages.get(p); 68 | return playerMessages; 69 | } 70 | 71 | /** 72 | * Clears any messages for player 73 | * 74 | * @param p 75 | */ 76 | public void clearMessages(String p) { 77 | messages.remove(p); 78 | } 79 | 80 | void saveMessages() { 81 | if (messageStore == null) { 82 | return; 83 | } 84 | Utils.send("&7Saving offline messages..."); 85 | try { 86 | // Convert to a serialized string 87 | final HashMap offlineMessages = new HashMap<>(); 88 | messages.keySet().forEach((p) -> offlineMessages.put(p, messages.get(p))); 89 | // Convert to YAML 90 | messageStore.set("messages", offlineMessages); 91 | } catch (Exception e) { 92 | e.printStackTrace(); 93 | } 94 | } 95 | 96 | void loadMessages() { 97 | Utils.send("&7Loading offline messages..."); 98 | try { 99 | messageStore = Utils.loadYamlFile("messages.yml"); 100 | HashMap temp = messageStore.getSections("messages"); 101 | temp.keySet().forEach((s) -> { 102 | List messageList = messageStore.getStringList("messages." + s); 103 | if (!messageList.isEmpty()) { 104 | messages.put(s, messageList); 105 | } 106 | }); 107 | 108 | } catch (Exception e) { 109 | e.printStackTrace(); 110 | } 111 | } 112 | 113 | /** 114 | * Provides the messages for the player 115 | * 116 | * @param p 117 | * @return List of messages 118 | */ 119 | private List get(String p) { 120 | return messages.get(p); 121 | } 122 | 123 | /** 124 | * Stores a message for player 125 | * 126 | * @param p The Player name 127 | * @param playerMessages Message to be given for the player 128 | */ 129 | public void put(String p, List playerMessages) { 130 | messages.put(p, playerMessages); 131 | } 132 | 133 | /** 134 | * Sends a message to every player in the team that is offline 135 | * 136 | * @param player 137 | * @param message 138 | */ 139 | public void tellOfflineTeam(String player, String message) { 140 | 141 | } 142 | 143 | /** 144 | * Tells all online team members something happened 145 | * 146 | * @param player 147 | * @param message 148 | */ 149 | public void tellTeam(String player, String message) { 150 | 151 | } 152 | 153 | /** 154 | * Sets a message for the player to receive next time they login 155 | * 156 | * @param p 157 | * @param message 158 | * @return true if player is offline, false if online 159 | */ 160 | public void setMessage(String p, String message) { 161 | // getLogger().info("DEBUG: received message - " + message); 162 | Player player = plugin.getServer().getPlayer(p); 163 | // Check if player is online 164 | if (player != null) { 165 | if (player.isOnline()) { 166 | player.sendMessage(message); 167 | return; 168 | } 169 | } 170 | // Player is offline so store the message 171 | // getLogger().info("DEBUG: player is offline - storing message"); 172 | List playerMessages = get(p); 173 | if (playerMessages != null) { 174 | playerMessages.add(message); 175 | } else { 176 | playerMessages = new ArrayList<>(Collections.singletonList(message)); 177 | } 178 | put(p, playerMessages); 179 | } 180 | } 181 | --------------------------------------------------------------------------------