diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ae77cee --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ + Copyright (c) + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, + copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following + conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100755 index 0000000..ae3724b --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# PlayerShops +___ + +## **Downloads** +Downloads can be obtained on GitHub actions page. + +## **Building** + +#### Initial setup +Clone the repo using `git clone https://github.com/Altitude-Devs/PlayerShops.git`. + +#### Building +Use the command `./gradlew build --stacktrace` in the project root directory. +The compiled jar will be placed in directory `/build/libs/`. + +## **Commands** + +| Command | Description | Permission | +|---------------------|-----------------------------|-----------------------------| + +## **Permissions** + +| Permission | Description | +|-----------------------------|------------------------------------------------| + +## **Configuration** + +```yaml +# Magic value used to determine auto configuration updates, do not change this value +config-version: 1 +``` + +## **Support** + +## **License** +[LICENSE](LICENSE) diff --git a/build.gradle.kts b/build.gradle.kts index 1d91c36..7fa735c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,6 +34,9 @@ dependencies { exclude("org.bukkit","bukkit") } compileOnly("com.github.TechFortress:GriefPrevention:16.17.1") + + compileOnly("org.projectlombok:lombok:1.18.24") + annotationProcessor("org.projectlombok:lombok:1.18.24") } bukkit { diff --git a/src/main/java/com/alttd/playershops/PlayerShops.java b/src/main/java/com/alttd/playershops/PlayerShops.java index 3c36ab4..02f8c7d 100644 --- a/src/main/java/com/alttd/playershops/PlayerShops.java +++ b/src/main/java/com/alttd/playershops/PlayerShops.java @@ -1,6 +1,8 @@ package com.alttd.playershops; import com.alttd.playershops.config.Config; +import com.alttd.playershops.handler.ShopHandler; +import lombok.Getter; import net.milkbowl.vault.economy.Economy; import org.bukkit.Bukkit; import org.bukkit.plugin.RegisteredServiceProvider; @@ -8,8 +10,12 @@ import org.bukkit.plugin.java.JavaPlugin; public class PlayerShops extends JavaPlugin { + @Getter private static PlayerShops instance; + @Getter private Economy econ; + @Getter + private ShopHandler shopHandler; public void onEnable() { instance = this; @@ -23,6 +29,8 @@ public class PlayerShops extends JavaPlugin { registerListeners(); registerCommands(); + + shopHandler = new ShopHandler(instance); } private boolean setupEconomy() { @@ -56,8 +64,4 @@ public class PlayerShops extends JavaPlugin { Config.reload(); } - public static PlayerShops getInstance() { - return instance; - } - } diff --git a/src/main/java/com/alttd/playershops/config/Config.java b/src/main/java/com/alttd/playershops/config/Config.java index 9bf7c9a..f996bf8 100644 --- a/src/main/java/com/alttd/playershops/config/Config.java +++ b/src/main/java/com/alttd/playershops/config/Config.java @@ -23,4 +23,10 @@ public class Config extends AbstractConfiguration { config.readConfig(Config.class, null); } + public static int shopLimit = 100; + private static void shopSettings() { + String path = "shop-settings."; + shopLimit = config.getInt(path + "player-shop-limit", shopLimit); + } + } diff --git a/src/main/java/com/alttd/playershops/config/ShopMessageConfig.java b/src/main/java/com/alttd/playershops/config/ShopTypeConfig.java similarity index 69% rename from src/main/java/com/alttd/playershops/config/ShopMessageConfig.java rename to src/main/java/com/alttd/playershops/config/ShopTypeConfig.java index 04c6c9f..e86fd7b 100644 --- a/src/main/java/com/alttd/playershops/config/ShopMessageConfig.java +++ b/src/main/java/com/alttd/playershops/config/ShopTypeConfig.java @@ -1,20 +1,20 @@ package com.alttd.playershops.config; -public class ShopMessageConfig { +public class ShopTypeConfig { private final String shopType; private final String configPath; private final String defaultPath; - public ShopMessageConfig(String shopType) { + public ShopTypeConfig(String shopType) { this.shopType = shopType; - this.configPath = "shop.text." + this.shopType + "."; - this.defaultPath = "shop.text.default."; + this.configPath = "shop.type." + this.shopType + "."; + this.defaultPath = "shop.type.default."; init(); } public void init() { - Config.config.readConfig(ShopMessageConfig.class, this); + Config.config.readConfig(ShopTypeConfig.class, this); } private static void set(String path, Object def) { diff --git a/src/main/java/com/alttd/playershops/handler/ShopHandler.java b/src/main/java/com/alttd/playershops/handler/ShopHandler.java new file mode 100644 index 0000000..b7bbd0a --- /dev/null +++ b/src/main/java/com/alttd/playershops/handler/ShopHandler.java @@ -0,0 +1,23 @@ +package com.alttd.playershops.handler; + +import com.alttd.playershops.PlayerShops; +import com.alttd.playershops.config.Config; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import lombok.Getter; + +import java.util.UUID; + +public class ShopHandler { + + private final PlayerShops plugin; + @Getter + private final Object2IntMap shopBuildLimits; + + public ShopHandler(PlayerShops instance) { + plugin = instance; + shopBuildLimits = new Object2IntOpenHashMap<>(); + shopBuildLimits.defaultReturnValue(Config.shopLimit); + } + +} diff --git a/src/main/java/com/alttd/playershops/shop/AbstractShop.java b/src/main/java/com/alttd/playershops/shop/AbstractShop.java new file mode 100644 index 0000000..211d7d9 --- /dev/null +++ b/src/main/java/com/alttd/playershops/shop/AbstractShop.java @@ -0,0 +1,5 @@ +package com.alttd.playershops.shop; + +public abstract class AbstractShop { + +} diff --git a/src/main/java/com/alttd/playershops/shop/ShopType.java b/src/main/java/com/alttd/playershops/shop/ShopType.java index 945d31c..8d495f3 100644 --- a/src/main/java/com/alttd/playershops/shop/ShopType.java +++ b/src/main/java/com/alttd/playershops/shop/ShopType.java @@ -1,6 +1,6 @@ package com.alttd.playershops.shop; -import com.alttd.playershops.config.ShopMessageConfig; +import com.alttd.playershops.config.ShopTypeConfig; public enum ShopType { @@ -9,10 +9,10 @@ public enum ShopType { GAMBLE, BARTER; - private final ShopMessageConfig shopMessageConfig; + private final ShopTypeConfig shopTypeConfig; ShopType() { - this.shopMessageConfig = new ShopMessageConfig(toString()); + this.shopTypeConfig = new ShopTypeConfig(toString()); } @Override