From c68d4ef3dbf0140e513a4e7605bad09ba7b770e2 Mon Sep 17 00:00:00 2001 From: okx-code Date: Tue, 2 Jun 2026 01:35:57 +0100 Subject: [PATCH] wip --- PrivateConfig | 2 +- .../plugins/FactoryMod/config.yml | 457 ++++++++++++++++++ .../plugins/RandomSpawn/worlds.yml | 73 --- .../zorweth-config/plugins/Zorweth/config.yml | 4 +- ansible/templates/stacks/minecraft.yml.j2 | 11 + docker-compose.private.yml | 10 + .../FactoryMod/recipes/ProductionRecipe.java | 4 +- .../spawn/BlockingSpawnSelector.java | 116 +++-- .../src/main/resources/worlds.yml | 2 + .../net/civmc/zorweth/GravityListener.java | 22 + .../java/net/civmc/zorweth/ZorwethPlugin.java | 9 +- .../civmc/zorweth/flight/LaunchHandler.java | 67 ++- .../net/civmc/zorweth/mechanics/Fuel.java | 17 + .../civmc/zorweth/oxygen/ActivityManager.java | 22 +- .../civmc/zorweth/oxygen/OxygenBladder.java | 69 ++- .../oxygen/OxygenBladderMechanics.java | 16 +- .../civmc/zorweth/oxygen/OxygenBottle.java | 2 +- .../civmc/zorweth/oxygen/OxygenDisplay.java | 2 +- .../civmc/zorweth/oxygen/OxygenManager.java | 32 +- 19 files changed, 745 insertions(+), 192 deletions(-) delete mode 100644 ansible/files/zorweth-config/plugins/RandomSpawn/worlds.yml create mode 100644 plugins/zorweth-paper/src/main/java/net/civmc/zorweth/GravityListener.java diff --git a/PrivateConfig b/PrivateConfig index 9d49d402f..522181fe7 160000 --- a/PrivateConfig +++ b/PrivateConfig @@ -1 +1 @@ -Subproject commit 9d49d402f3e76c5c637293677f76a503d088268d +Subproject commit 522181fe7fb7b85f6947073468b2bf9fe87e2377 diff --git a/ansible/files/paper-config/plugins/FactoryMod/config.yml b/ansible/files/paper-config/plugins/FactoryMod/config.yml index 810219667..6ef6edd1e 100644 --- a/ansible/files/paper-config/plugins/FactoryMod/config.yml +++ b/ansible/files/paper-config/plugins/FactoryMod/config.yml @@ -16,6 +16,39 @@ log_inventories: true force_include_default: true can_upgrade: true factories: + oxygen: + type: FCC + name: Oxygen Factory + citadelBreakReduction: 1.0 + setupcost: + pitcher_plant: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: PITCHER_PLANT + amount: 24 + iron: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: IRON_INGOT + amount: 64 + copper: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: COPPER_INGOT + amount: 32 + essence: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: ENDER_EYE + amount: 16 + meta: + meta-type: UNSPECIFIC + ==: ItemMeta + display-name: Player Essence + lore: + - Activity reward used to fuel pearls + recipes: + - repair_oxygen_factory space_chem: type: FCC name: Space Chemistry Factory @@ -658,9 +691,14 @@ factories: recipes: - smelt_coal_ore - smelt_raw_copper + - smelt_raw_copper_catalyst + - smelt_bauxite - smelt_raw_iron + - smelt_raw_iron_catalyst - smelt_diamond_ore + - smelt_diamond_ore_catalyst - smelt_deepslate_diamond_ore + - smelt_deepslate_diamond_ore_catalyst - smelt_raw_gold - smelt_nether_gold_ore - smelt_redstone_ore @@ -681,9 +719,14 @@ factories: - adv_smelt_ancient_debris - smelt_coal_ore - adv_smelt_raw_copper + - adv_smelt_raw_copper_catalyst + - adv_smelt_bauxite - adv_smelt_raw_iron + - adv_smelt_raw_iron_catalyst - adv_smelt_diamond_ore + - adv_smelt_diamond_ore_catalyst - adv_smelt_deepslate_diamond_ore + - adv_smelt_deepslate_diamond_ore_catalyst - adv_smelt_raw_gold - adv_smelt_nether_gold_ore - adv_smelt_redstone_ore @@ -705,9 +748,14 @@ factories: - elite_smelt_ancient_debris - smelt_coal_ore - elite_smelt_raw_copper + - elite_smelt_raw_copper_catalyst + - elite_smelt_bauxite - elite_smelt_raw_iron + - elite_smelt_raw_iron_catalyst - elite_smelt_diamond_ore + - elite_smelt_diamond_ore_catalyst - elite_smelt_deepslate_diamond_ore + - elite_smelt_deepslate_diamond_ore_catalyst - elite_smelt_raw_gold - elite_smelt_nether_gold_ore - elite_smelt_redstone_ore @@ -2345,6 +2393,54 @@ recipes: ==: org.bukkit.inventory.ItemStack type: COPPER_BLOCK amount: 16 + smelt_raw_copper_catalyst: + production_time: 4s + name: Smelt Copper Ore with Catalyst + type: PRODUCTION + input: + raw_copper: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: RAW_COPPER + amount: 128 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + copper: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: COPPER_BLOCK + amount: 24 + smelt_bauxite: + production_time: 4s + name: Smelt Bauxite + type: PRODUCTION + input: + bauxite: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: COPPER_NUGGET + amount: 16 + meta: + meta-type: UNSPECIFIC + ==: ItemMeta + display-name: Bauxite + lore: + - Rock found on Zorweth + - Can be refined into aluminium + output: + aluminium_ingot: + custom-key: aluminium_ingot + amount: 16 adv_smelt_raw_copper: production_time: 4s name: Advanced Smelt Copper Ore @@ -2361,6 +2457,54 @@ recipes: ==: org.bukkit.inventory.ItemStack type: COPPER_BLOCK amount: 20 + adv_smelt_raw_copper_catalyst: + production_time: 4s + name: Smelt Copper Ore with Catalyst + type: PRODUCTION + input: + raw_copper: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: RAW_COPPER + amount: 128 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + copper: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: COPPER_BLOCK + amount: 28 + adv_smelt_bauxite: + production_time: 4s + name: Advanced Smelt Bauxite + type: PRODUCTION + input: + bauxite: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: COPPER_NUGGET + amount: 16 + meta: + meta-type: UNSPECIFIC + ==: ItemMeta + display-name: Bauxite + lore: + - Rock found on Zorweth + - Can be refined into aluminium + output: + aluminium_ingot: + custom-key: aluminium_ingot + amount: 20 elite_smelt_raw_copper: production_time: 4s name: Elite Smelt Copper Ore @@ -2377,6 +2521,54 @@ recipes: ==: org.bukkit.inventory.ItemStack type: COPPER_BLOCK amount: 22 + elite_smelt_raw_copper_catalyst: + production_time: 4s + name: Smelt Copper Ore with Catalyst + type: PRODUCTION + input: + raw_copper: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: RAW_COPPER + amount: 128 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + copper: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: COPPER_BLOCK + amount: 30 + elite_smelt_bauxite: + production_time: 4s + name: Elite Smelt Bauxite + type: PRODUCTION + input: + bauxite: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: COPPER_NUGGET + amount: 16 + meta: + meta-type: UNSPECIFIC + ==: ItemMeta + display-name: Bauxite + lore: + - Rock found on Zorweth + - Can be refined into aluminium + output: + aluminium_ingot: + custom-key: aluminium_ingot + amount: 22 smelt_raw_iron: production_time: 4s name: Smelt Iron Ore @@ -2393,6 +2585,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: IRON_INGOT amount: 64 + smelt_raw_iron_catalyst: + production_time: 4s + name: Smelt Iron Ore with Catalyst + type: PRODUCTION + input: + raw_iron: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: RAW_IRON + amount: 48 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + iron: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: IRON_INGOT + amount: 80 adv_smelt_raw_iron: production_time: 4s name: Advanced Smelt Iron Ore @@ -2409,6 +2628,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: IRON_INGOT amount: 80 + adv_smelt_raw_iron_catalyst: + production_time: 4s + name: Smelt Iron Ore with Catalyst + type: PRODUCTION + input: + raw_iron: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: RAW_IRON + amount: 48 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + iron: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: IRON_INGOT + amount: 96 elite_smelt_raw_iron: production_time: 4s name: Elite Smelt Iron Ore @@ -2425,6 +2671,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: IRON_INGOT amount: 88 + elite_smelt_raw_iron_catalyst: + production_time: 4s + name: Smelt Iron Ore with Catalyst + type: PRODUCTION + input: + raw_iron: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: RAW_IRON + amount: 48 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + iron: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: IRON_INGOT + amount: 104 smelt_diamond_ore: production_time: 4s name: Smelt Diamond Ore @@ -2441,6 +2714,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: DIAMOND amount: 48 + smelt_diamond_ore_catalyst: + production_time: 4s + name: Smelt Diamond Ore with Catalyst + type: PRODUCTION + input: + diamond_ore: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND_ORE + amount: 16 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + diamond: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND + amount: 52 smelt_deepslate_diamond_ore: production_time: 4s name: Smelt Deepslate Diamond Ore @@ -2457,6 +2757,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: DIAMOND amount: 48 + smelt_deepslate_diamond_ore_catalyst: + production_time: 4s + name: Smelt Deepslate Diamond Ore with Catalyst + type: PRODUCTION + input: + deepslate_diamond_ore: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DEEPSLATE_DIAMOND_ORE + amount: 16 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + diamond: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND + amount: 52 adv_smelt_diamond_ore: production_time: 4s name: Advanced Smelt Diamond Ore @@ -2473,6 +2800,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: DIAMOND amount: 56 + adv_smelt_diamond_ore_catalyst: + production_time: 4s + name: Smelt Diamond Ore with Catalyst + type: PRODUCTION + input: + diamond_ore: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND_ORE + amount: 16 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + diamond: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND + amount: 60 elite_smelt_diamond_ore: production_time: 4s name: Elite Smelt Diamond Ore @@ -2489,6 +2843,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: DIAMOND amount: 60 + elite_smelt_diamond_ore_catalyst: + production_time: 4s + name: Smelt Diamond Ore with Catalyst + type: PRODUCTION + input: + diamond_ore: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND_ORE + amount: 16 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + diamond: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND + amount: 64 adv_smelt_deepslate_diamond_ore: production_time: 4s name: Advanced Smelt Deepslate Diamond Ore @@ -2505,6 +2886,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: DIAMOND amount: 56 + adv_smelt_deepslate_diamond_ore_catalyst: + production_time: 4s + name: Smelt Deepslate Diamond Ore with Catalyst + type: PRODUCTION + input: + deepslate_diamond_ore: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DEEPSLATE_DIAMOND_ORE + amount: 16 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + diamond: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND + amount: 60 elite_smelt_deepslate_diamond_ore: production_time: 4s name: Elite Smelt Deepslate Diamond Ore @@ -2521,6 +2929,33 @@ recipes: ==: org.bukkit.inventory.ItemStack type: DIAMOND amount: 60 + elite_smelt_deepslate_diamond_ore_catalyst: + production_time: 4s + name: Smelt Deepslate Diamond Ore with Catalyst + type: PRODUCTION + input: + deepslate_diamond_ore: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DEEPSLATE_DIAMOND_ORE + amount: 16 + salt: + ==: org.bukkit.inventory.ItemStack + v: 3839 + type: SUGAR + amount: 16 + meta: + ==: ItemMeta + meta-type: UNSPECIFIC + display-name: Salt + lore: + - Gathered from the Zorweth salt flats + output: + diamond: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: DIAMOND + amount: 64 smelt_raw_gold: production_time: 4s name: Smelt Gold Ore @@ -17905,6 +18340,28 @@ recipes: lore: - Activity reward used to fuel pearls health_gained: 10000 + repair_oxygen_factory: + production_time: 4s + name: Repair Factory + type: REPAIR + input: + pitcher: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: PITCHER_PLANT + amount: 8 + essence: + v: 3839 + ==: org.bukkit.inventory.ItemStack + type: ENDER_EYE + amount: 4 + meta: + meta-type: UNSPECIFIC + ==: ItemMeta + display-name: Player Essence + lore: + - Activity reward used to fuel pearls + health_gained: 10000 refine_crude_oil: production_time: 4s name: Refine Crude Oil diff --git a/ansible/files/zorweth-config/plugins/RandomSpawn/worlds.yml b/ansible/files/zorweth-config/plugins/RandomSpawn/worlds.yml deleted file mode 100644 index b03a84bfa..000000000 --- a/ansible/files/zorweth-config/plugins/RandomSpawn/worlds.yml +++ /dev/null @@ -1,73 +0,0 @@ -world: - randomspawnon: - - firstjoin - keeprandomspawns: false - spawnpointson: [] - spawnbyplayer: false - spawnarea: - type: circle - radius: 5000 - spawnblacklist: - - "WATER" # 8, 9 # water - - "LAVA" # 10, 11 # lava - # - 18 # leaves - - "FIRE" # 51 # fire - - "CACTUS" # 81 # cactus - - "OBSIDIAN" # 49 # obsidian - don't spawn in military infrastructure - - "BEDROCK" - - "MAGMA_BLOCK" - - "BLACK_CARPET" # 171 # carpet - don't spawn in military infrastructure - - "BLUE_CARPET" - - "BROWN_CARPET" - - "CYAN_CARPET" - - "GRAY_CARPET" - - "GREEN_CARPET" - - "LIGHT_BLUE_CARPET" - - "LIGHT_GRAY_CARPET" - - "LIME_CARPET" - - "MAGENTA_CARPET" - - "ORANGE_CARPET" - - "PINK_CARPET" - - "PURPLE_CARPET" - - "RED_CARPET" - - "WHITE_CARPET" - - "YELLOW_CARPET" - - "END_STONE" - -world_nether: - randomspawnon: - - respawn - keeprandomspawns: false - newplayertime: 3000 - spawnarea: - type: "circle" - radius: 5000 - spawnbyplayer: false - spawnbyplayerarea: - exclusionradius: 300 - radius: 900 - spawnblacklist: - - "WATER" # 8, 9 # water - - "LAVA" # 10, 11 # lava - # - 18 # leaves - - "FIRE" # 51 # fire - - "CACTUS" # 81 # cactus - - "OBSIDIAN" # 49 # obsidian - don't spawn in military infrastructure - - "BEDROCK" - - "MAGMA_BLOCK" - - "BLACK_CARPET" # 171 # carpet - don't spawn in military infrastructure - - "BLUE_CARPET" - - "BROWN_CARPET" - - "CYAN_CARPET" - - "GRAY_CARPET" - - "GREEN_CARPET" - - "LIGHT_BLUE_CARPET" - - "LIGHT_GRAY_CARPET" - - "LIME_CARPET" - - "MAGENTA_CARPET" - - "ORANGE_CARPET" - - "PINK_CARPET" - - "PURPLE_CARPET" - - "RED_CARPET" - - "WHITE_CARPET" - - "YELLOW_CARPET" diff --git a/ansible/files/zorweth-config/plugins/Zorweth/config.yml b/ansible/files/zorweth-config/plugins/Zorweth/config.yml index 6347fb24c..f123151bf 100644 --- a/ansible/files/zorweth-config/plugins/Zorweth/config.yml +++ b/ansible/files/zorweth-config/plugins/Zorweth/config.yml @@ -26,13 +26,15 @@ mechanics: research: enabled: false +gravity: 0.04 + oxygen: enabled: true world: world consumption_per_second: 0.006 biomes: + "minecraft:pale_garden": 0.5 "minecraft:end_highlands": 1 - "minecraft:pale_garden": 2 "minecraft:end_midlands": 3 "minecraft:end_barrens": 4 "minecraft:basalt_deltas": 8 diff --git a/ansible/templates/stacks/minecraft.yml.j2 b/ansible/templates/stacks/minecraft.yml.j2 index c9c402011..967a6eb08 100644 --- a/ansible/templates/stacks/minecraft.yml.j2 +++ b/ansible/templates/stacks/minecraft.yml.j2 @@ -220,6 +220,17 @@ services: - /opt/PrivateConfig/paper/plugins/Vulcan.jar:/config/plugins/Vulcan.jar - /opt/PrivateConfig/paper/config/Vulcan/config.yml:/config/plugins/Vulcan/config.yml - /opt/PrivateConfig/paper/config/CivChat2/banned-words.txt:/config/plugins/CivChat2/banned-words.txt + - /opt/PrivateConfig/paper/config/EvenMoreFish/baits:/config/plugins/EvenMoreFish/baits + - /opt/PrivateConfig/paper/config/EvenMoreFish/rods:/config/plugins/EvenMoreFish/rods + - /opt/PrivateConfig/paper/config/EvenMoreFish/rarities:/config/plugins/EvenMoreFish/rarities + - /opt/PrivateConfig/paper/config/EvenMoreFish/competitions:/config/plugins/EvenMoreFish/competitions + - /opt/PrivateConfig/paper/config/EvenMoreFish/config.yml:/config/plugins/EvenMoreFish/config.yml + - /opt/PrivateConfig/paper/config/BreweryX/config.yml:/config/plugins/BreweryX/config.yml + - /opt/PrivateConfig/paper/config/BreweryX/cauldron.yml:/config/plugins/BreweryX/cauldron.yml + - /opt/PrivateConfig/paper/config/BreweryX/custom-items.yml:/config/plugins/BreweryX/custom-items.yml + - /opt/PrivateConfig/paper/config/BreweryX/recipes.yml:/config/plugins/BreweryX/recipes.yml + - /opt/PrivateConfig/zorweth/config/HiddenOre/config.yml:/config/plugins/HiddenOre/config.yml + - /opt/PrivateConfig/zorweth/config/RandomSpawn/worlds.yml:/config/plugins/RandomSpawn/worlds.yml deploy: placement: constraints: [node.role == manager] diff --git a/docker-compose.private.yml b/docker-compose.private.yml index d67793d07..d33d7aff6 100644 --- a/docker-compose.private.yml +++ b/docker-compose.private.yml @@ -46,10 +46,20 @@ services: environment: COPY_CONFIG_SRC: /config,/privateconfig volumes: + - ./PrivateConfig/paper/plugins/Vulcan.jar:/privateconfig/plugins/Vulcan.jar + - ./PrivateConfig/paper/config/Vulcan/config.yml:/privateconfig/plugins/Vulcan/config.yml + - ./PrivateConfig/paper/config/CivChat2/banned-words.txt:/privateconfig/plugins/CivChat2/banned-words.txt + - ./PrivateConfig/paper/config/EvenMoreFish/baits:/privateconfig/plugins/EvenMoreFish/baits + - ./PrivateConfig/paper/config/EvenMoreFish/rods:/privateconfig/plugins/EvenMoreFish/rods + - ./PrivateConfig/paper/config/EvenMoreFish/rarities:/privateconfig/plugins/EvenMoreFish/rarities + - ./PrivateConfig/paper/config/EvenMoreFish/competitions:/privateconfig/plugins/EvenMoreFish/competitions + - ./PrivateConfig/paper/config/EvenMoreFish/config.yml:/privateconfig/plugins/EvenMoreFish/config.yml - ./PrivateConfig/paper/config/BreweryX/config.yml:/privateconfig/plugins/BreweryX/config.yml - ./PrivateConfig/paper/config/BreweryX/cauldron.yml:/privateconfig/plugins/BreweryX/cauldron.yml - ./PrivateConfig/paper/config/BreweryX/custom-items.yml:/privateconfig/plugins/BreweryX/custom-items.yml - ./PrivateConfig/paper/config/BreweryX/recipes.yml:/privateconfig/plugins/BreweryX/recipes.yml + - ./PrivateConfig/zorweth/config/HiddenOre/config.yml:/privateconfig/plugins/HiddenOre/config.yml + - ./PrivateConfig/zorweth/config/RandomSpawn/worlds.yml:/privateconfig/plugins/RandomSpawn/worlds.yml pvp: environment: diff --git a/plugins/factorymod-paper/src/main/java/com/github/igotyou/FactoryMod/recipes/ProductionRecipe.java b/plugins/factorymod-paper/src/main/java/com/github/igotyou/FactoryMod/recipes/ProductionRecipe.java index 82c239e35..64d413fee 100644 --- a/plugins/factorymod-paper/src/main/java/com/github/igotyou/FactoryMod/recipes/ProductionRecipe.java +++ b/plugins/factorymod-paper/src/main/java/com/github/igotyou/FactoryMod/recipes/ProductionRecipe.java @@ -143,7 +143,9 @@ public class ProductionRecipe extends InputRecipe { @Override public ItemStack getRecipeRepresentationType() { - return new ItemStack(this.recipeRepresentation); + ItemStack itemStack = new ItemStack(this.recipeRepresentation); + itemStack.setAmount(1); + return itemStack; } public ProductionRecipeModifier getModifier() { diff --git a/plugins/randomspawn-paper/src/main/java/me/josvth/randomspawn/spawn/BlockingSpawnSelector.java b/plugins/randomspawn-paper/src/main/java/me/josvth/randomspawn/spawn/BlockingSpawnSelector.java index 5bb9cede0..380d8fb1f 100644 --- a/plugins/randomspawn-paper/src/main/java/me/josvth/randomspawn/spawn/BlockingSpawnSelector.java +++ b/plugins/randomspawn-paper/src/main/java/me/josvth/randomspawn/spawn/BlockingSpawnSelector.java @@ -41,6 +41,7 @@ public class BlockingSpawnSelector implements SpawnSelector { protected CompletableFuture getRandomSpawnLocationAsync(World world, boolean block) { String worldName = world.getName(); Set blacklist = getMaterialBlackList(worldName); + Set biomeBlacklist = getBiomeBlackList(worldName); if (yamlHandler.worlds.getBoolean(worldName + ".spawnbyplayer")) { List playersOnline = world.getPlayers(); @@ -53,7 +54,7 @@ public class BlockingSpawnSelector implements SpawnSelector { double exclusionRadius = yamlHandler.worlds.getDouble(worldName + ".spawnbyplayerarea.exclusionradius", 0); - return chooseSpawn(radius, exclusionRadius, spawnNear, blacklist, block); + return chooseSpawn(radius, exclusionRadius, spawnNear, blacklist, biomeBlacklist, block); } } @@ -68,14 +69,16 @@ public class BlockingSpawnSelector implements SpawnSelector { int thickness = yamlHandler.worlds.getInt(worldName + ".spawnarea.thickness", 0); // square can block too bad (TODO fix) - ret = CompletableFuture.completedFuture(chooseSpawn(world, xmin, xmax, zmin, zmax, thickness, blacklist, true)); + ret = CompletableFuture.completedFuture(chooseSpawn(world, xmin, xmax, zmin, zmax, thickness, + blacklist, biomeBlacklist, true)); } else if (type.equalsIgnoreCase("circle")) { double exclusionRadius = yamlHandler.worlds.getDouble(worldName + ".spawnarea.exclusionradius", 0); double radius = yamlHandler.worlds.getDouble(worldName + ".spawnarea.radius", 100); double xcenter = yamlHandler.worlds.getDouble(worldName + ".spawnarea.xcenter", 0); double zcenter = yamlHandler.worlds.getDouble(worldName + ".spawnarea.zcenter", 0); - ret = chooseSpawn(radius, exclusionRadius, new Location(world, xcenter, 0, zcenter), blacklist, block); + ret = chooseSpawn(radius, exclusionRadius, new Location(world, xcenter, 0, zcenter), blacklist, + biomeBlacklist, block); } else { return CompletableFuture.completedFuture(null); } @@ -113,6 +116,7 @@ public class BlockingSpawnSelector implements SpawnSelector { } Set blacklist = getMaterialBlackList(world.getName()); + Set biomeBlacklist = getBiomeBlackList(world.getName()); // For each potential spawn location ... ConfigurationSection spawnpoints = yamlHandler.worlds.getConfigurationSection(worldName + ".spawnpoints"); @@ -123,23 +127,30 @@ public class BlockingSpawnSelector implements SpawnSelector { List keys = new ArrayList<>(spawnpoints.getKeys(false)); Collections.shuffle(keys, random); - return getSpawnPoint(new AtomicInteger(0), keys, spawnpoints, world, blacklist, block); + return getSpawnPoint(new AtomicInteger(0), keys, spawnpoints, world, blacklist, biomeBlacklist, block); } - private CompletableFuture getSpawnPoint(AtomicInteger index, List keys, ConfigurationSection spawnpoints, World world, Set blacklist, boolean block) { - return getSpawnPointAttempt(spawnpoints, keys.get(index.get()), world, blacklist, block).thenCompose(location -> { - if (location == null) { - if (index.incrementAndGet() >= keys.size()) { - return CompletableFuture.completedFuture(null); + private CompletableFuture getSpawnPoint(AtomicInteger index, List keys, + ConfigurationSection spawnpoints, World world, + Set blacklist, Set biomeBlacklist, + boolean block) { + return getSpawnPointAttempt(spawnpoints, keys.get(index.get()), world, blacklist, biomeBlacklist, block) + .thenCompose(location -> { + if (location == null) { + if (index.incrementAndGet() >= keys.size()) { + return CompletableFuture.completedFuture(null); + } + return getSpawnPointAttempt(spawnpoints, keys.get(index.get()), world, blacklist, biomeBlacklist, + block); + } else { + return CompletableFuture.completedFuture(location); } - return getSpawnPointAttempt(spawnpoints, keys.get(index.get()), world, blacklist, block); - } else { - return CompletableFuture.completedFuture(location); - } - }); + }); } - private CompletableFuture getSpawnPointAttempt(ConfigurationSection spawnpoints, String label, World world, Set blacklist, boolean block) { + private CompletableFuture getSpawnPointAttempt(ConfigurationSection spawnpoints, String label, + World world, Set blacklist, + Set biomeBlacklist, boolean block) { ConfigurationSection spawnpoint = spawnpoints.getConfigurationSection(label); Location location = new Location(world, spawnpoint.getDouble("x"), spawnpoint.getDouble("y"), spawnpoint.getDouble("z")); @@ -159,35 +170,44 @@ public class BlockingSpawnSelector implements SpawnSelector { if (!skip) { // Now pick a location to spawn the player. return chooseSpawn(spawnpoint.getDouble("radius"), spawnpoint.getDouble("exclusion"), - location, blacklist, block); + location, blacklist, biomeBlacklist, block); } return CompletableFuture.completedFuture(null); } - private CompletableFuture chooseSpawn(double radius, double exclusionRadius, Location center, Set blacklist, boolean block) { - return chooseSpawnAttempt(block, new AtomicInteger(1000), radius, exclusionRadius, center, blacklist).thenApply(validSpawn -> { - if (validSpawn != null) { - return validSpawn.toLocation(center.getWorld()); - } else { - return center; - } - }); - } - - private CompletableFuture chooseSpawnAttempt(boolean block, AtomicInteger attempts, double radius, double exclusionRadius, Location center, Set blacklist) { - return chooseOneSpawn(block, radius, exclusionRadius, center, blacklist).thenCompose(validSpawn -> { - if (validSpawn == null) { - if (attempts.decrementAndGet() <= 0) { - return CompletableFuture.completedFuture(null); + private CompletableFuture chooseSpawn(double radius, double exclusionRadius, Location center, + Set blacklist, Set biomeBlacklist, + boolean block) { + return chooseSpawnAttempt(block, new AtomicInteger(1000), radius, exclusionRadius, center, blacklist, + biomeBlacklist).thenApply(validSpawn -> { + if (validSpawn != null) { + return validSpawn.toLocation(center.getWorld()); + } else { + return center; } - return chooseSpawnAttempt(block, attempts, radius, exclusionRadius, center, blacklist); - } else { - return CompletableFuture.completedFuture(validSpawn); - } - }); + }); } - private CompletableFuture chooseOneSpawn(boolean block, double radius, double exclusionRadius, Location center, Set blacklist) { + private CompletableFuture chooseSpawnAttempt(boolean block, AtomicInteger attempts, double radius, + double exclusionRadius, Location center, + Set blacklist, Set biomeBlacklist) { + return chooseOneSpawn(block, radius, exclusionRadius, center, blacklist, biomeBlacklist) + .thenCompose(validSpawn -> { + if (validSpawn == null) { + if (attempts.decrementAndGet() <= 0) { + return CompletableFuture.completedFuture(null); + } + return chooseSpawnAttempt(block, attempts, radius, exclusionRadius, center, blacklist, + biomeBlacklist); + } else { + return CompletableFuture.completedFuture(validSpawn); + } + }); + } + + private CompletableFuture chooseOneSpawn(boolean block, double radius, double exclusionRadius, + Location center, Set blacklist, + Set biomeBlacklist) { // Uniformly distributed in "annulus". Explanation: https://forum.unity.com/threads/random-point-within-circle-with-min-max-radius.597523/#post-8524934 final double ex2 = exclusionRadius * exclusionRadius; final double r2 = radius * radius; @@ -197,18 +217,19 @@ public class BlockingSpawnSelector implements SpawnSelector { final double x = Math.round(center.getX() + Math.cos(phi) * r); final double z = Math.round(center.getZ() + Math.sin(phi) * r); - return getValidY(center.getWorld(), x, z, blacklist, block).thenApply(y -> y == null ? null : new Vector(x, y, z)); + return getValidY(center.getWorld(), x, z, blacklist, biomeBlacklist, block) + .thenApply(y -> y == null ? null : new Vector(x, y, z)); } private Location chooseSpawn(World world, double xmin, double xmax, double zmin, double zmax, double thickness, - Set blacklist, boolean block) { + Set blacklist, Set biomeBlacklist, boolean block) { if (thickness <= 0) { for (int attempts = 1000; --attempts > 0; ) { final double x = xmin + Math.random() * (xmax - xmin + 1); final double z = zmin + Math.random() * (zmax - zmin + 1); - final Double y = getValidY(world, x, z, blacklist, block).join(); + final Double y = getValidY(world, x, z, blacklist, biomeBlacklist, block).join(); if (y == null) { continue; } @@ -235,7 +256,7 @@ public class BlockingSpawnSelector implements SpawnSelector { z = zmax - borderOffset; } - final Double y = getValidY(world, x, z, blacklist, block).join(); + final Double y = getValidY(world, x, z, blacklist, biomeBlacklist, block).join(); if (y == null) { continue; } @@ -257,6 +278,7 @@ public class BlockingSpawnSelector implements SpawnSelector { final double x, final double z, final @NotNull Set blacklist, + final @NotNull Set biomeBlacklist, boolean block ) { CompletableFuture chunkAtAsync = block @@ -278,7 +300,7 @@ public class BlockingSpawnSelector implements SpawnSelector { feetBlock = floorBlock.getRelative(0, 1, 0); headBlock = floorBlock.getRelative(0, 2, 0); while (headBlock.getY() < netherMaxHeight) { - if (isValidSpawnLocation(headBlock, feetBlock, floorBlock, blacklist)) { + if (isValidSpawnLocation(headBlock, feetBlock, floorBlock, blacklist, biomeBlacklist)) { return (double) feetBlock.getY(); } final Block nextBlock = headBlock.getRelative(0, 1, 0); @@ -300,7 +322,7 @@ public class BlockingSpawnSelector implements SpawnSelector { feetBlock = headBlock.getRelative(0, -1, 0); floorBlock = headBlock.getRelative(0, -2, 0); while (floorBlock.getY() >= otherMinHeight) { - if (isValidSpawnLocation(headBlock, feetBlock, floorBlock, blacklist)) { + if (isValidSpawnLocation(headBlock, feetBlock, floorBlock, blacklist, biomeBlacklist)) { return (double) feetBlock.getY(); } final Block nextBlock = floorBlock.getRelative(0, -1, 0); @@ -323,13 +345,19 @@ public class BlockingSpawnSelector implements SpawnSelector { final @NotNull Block headBlock, final @NotNull Block feetBlock, final @NotNull Block floorBlock, - final @NotNull Set blackListedMaterials + final @NotNull Set blackListedMaterials, + final @NotNull Set blackListedBiomes ) { return floorBlock.isSolid() && !blackListedMaterials.contains(floorBlock.getType()) + && !blackListedBiomes.contains(floorBlock.getBiome().getKey().asString()) && !feetBlock.isSolid() && !blackListedMaterials.contains(feetBlock.getType()) && !headBlock.isSolid() && !blackListedMaterials.contains(headBlock.getType()); } + private Set getBiomeBlackList(String worldName) { + return new HashSet<>(yamlHandler.worlds.getStringList(worldName + ".spawnblacklistbiomes")); + } + private Set getMaterialBlackList(String worldName) { if (yamlHandler.worlds.isList(worldName + ".spawnblacklist")) { Set result = new HashSet<>(); diff --git a/plugins/randomspawn-paper/src/main/resources/worlds.yml b/plugins/randomspawn-paper/src/main/resources/worlds.yml index 030bd1776..fae42de6b 100644 --- a/plugins/randomspawn-paper/src/main/resources/worlds.yml +++ b/plugins/randomspawn-paper/src/main/resources/worlds.yml @@ -35,3 +35,5 @@ exampleworld: - 18 - 51 - 81 + spawnblacklistbiomes: + - "minecraft:plains" diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/GravityListener.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/GravityListener.java new file mode 100644 index 000000000..65e913224 --- /dev/null +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/GravityListener.java @@ -0,0 +1,22 @@ +package net.civmc.zorweth; + +import org.bukkit.attribute.Attribute; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + +public class GravityListener implements Listener { + + private final double gravity; + + public GravityListener(double gravity) { + this.gravity = gravity; + } + + @EventHandler + public void on(PlayerJoinEvent event) { + Player player = event.getPlayer(); + player.getAttribute(Attribute.GRAVITY).setBaseValue(gravity); + } +} diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/ZorwethPlugin.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/ZorwethPlugin.java index 4718bd0c7..5be8a446e 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/ZorwethPlugin.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/ZorwethPlugin.java @@ -16,6 +16,7 @@ import java.util.logging.Level; import net.civmc.zorweth.database.RocketTransferDao; import net.civmc.zorweth.database.ZorwethDatabase; import net.civmc.zorweth.flight.FlightComputerGui; +import net.civmc.zorweth.mechanics.Fuel; import net.civmc.zorweth.mechanics.OilMechanics; import net.civmc.zorweth.oxygen.ActivityManager; import net.civmc.zorweth.oxygen.OxygenCommand; @@ -59,6 +60,7 @@ public final class ZorwethPlugin extends JavaPlugin { getServer().getPluginManager().disablePlugin(this); return; } + Fuel.registerCustomItems(); getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); this.rocketClipboard = loadRocketClipboard(); this.stasisHandler = new StasisHandler(); @@ -76,11 +78,16 @@ public final class ZorwethPlugin extends JavaPlugin { } loadOxygen(); + + double gravity = getConfig().getDouble("gravity"); + if (gravity != 0) { + getServer().getPluginManager().registerEvents(new GravityListener(gravity), this); + } } private void loadOxygen() { ConfigurationSection oxygenSection = getConfig().getConfigurationSection("oxygen"); - if (!oxygenSection.getBoolean("enabled")) { + if (oxygenSection == null || !oxygenSection.getBoolean("enabled")) { return; } diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/flight/LaunchHandler.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/flight/LaunchHandler.java index 08100df9b..71fd6ac7c 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/flight/LaunchHandler.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/flight/LaunchHandler.java @@ -32,6 +32,7 @@ import org.bukkit.block.Block; import org.bukkit.block.Chest; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.java.JavaPlugin; import vg.civcraft.mc.citadel.ReinforcementLogic; @@ -44,10 +45,11 @@ public class LaunchHandler { public static final double EXHAUST_VELOCITY_METERS_PER_SECOND = 5_000.0; public static final double ROCKET_DRY_MASS_KG = 100.0; public static final double SITTING_PLAYER_MASS_KG = 50.0; + private static final String COMPACTED_LORE = "Compacted Item"; public static FuelStatus calculateFuelStatus(final Block computer, final List passengers, final List chests) { - final double cargoMass = calculateCargoMass(chests); + final double cargoMass = calculateCargoMass(chests, passengers); final int sittingPlayers = Math.max(1, passengers.size()); final double nonFuelMass = ROCKET_DRY_MASS_KG + cargoMass + sittingPlayers * SITTING_PLAYER_MASS_KG; final double requiredFuelKg = nonFuelMass * (Math.exp(getDeltaVMetersPerSecond() / EXHAUST_VELOCITY_METERS_PER_SECOND) - 1.0); @@ -117,23 +119,62 @@ public class LaunchHandler { return new RocketWeightPayload(passengers, chests, getRemainingFuel(chests, passengers, computer)); } - private static double calculateCargoMass(final List chests) { + private static double calculateCargoMass(final List chests, + final List passengers) { double mass = 0.0; for (final RocketManifestChest chest : chests) { - for (final ItemStack item : chest.contents()) { - if (item == null || item.getType().isAir()) { - continue; - } - double itemMass = item.getAmount() / (double) item.getMaxStackSize(); - if (FlightComputer.isFuel(item)) { - itemMass *= FUEL_ITEM_MASS_KG * item.getMaxStackSize(); - } - mass += itemMass; - } + mass += calculateItemMass(chest.contents()); + } + for (final RocketManifestPassenger passenger : passengers) { + mass += calculateItemMass(passenger.inventoryContents()); } return mass; } + private static double calculateItemMass(final ItemStack[] items) { + double mass = 0.0; + for (final ItemStack item : items) { + if (item == null || item.getType().isAir()) { + continue; + } + int itemAmount = item.getAmount(); + if (isCompacted(item)) { + itemAmount *= getCompactStackSize(item.getType()); + } + double itemMass = itemAmount / (double) item.getMaxStackSize(); + if (FlightComputer.isFuel(item)) { + itemMass = itemAmount * FUEL_ITEM_MASS_KG; + } + mass += itemMass; + } + return mass; + } + + private static int getCompactStackSize(final Material material) { + return switch (material.getMaxStackSize()) { + case 64 -> 64; + case 16 -> 16; + case 1 -> 8; + default -> 1; + }; + } + + private static boolean isCompacted(final ItemStack item) { + if (!item.hasItemMeta()) { + return false; + } + final ItemMeta meta = item.getItemMeta(); + if (!meta.hasLore()) { + return false; + } + for (final String lore : meta.getLore()) { + if (COMPACTED_LORE.equals(lore)) { + return true; + } + } + return false; + } + public static RocketManifestResult collectLaunchManifest(final ZorwethPlugin plugin, final Block computer, final Player player, Clipboard rocket) { final Region region = rocket.getRegion(); final BlockVector3 schematicNorthWestCorner = region.getMinimumPoint(); @@ -196,7 +237,7 @@ public class LaunchHandler { private static double getRemainingFuel(final List chests, final List passengers, final Block computer) { - final double cargoMass = calculateCargoMass(chests); + final double cargoMass = calculateCargoMass(chests, passengers); final double dryMass = ROCKET_DRY_MASS_KG + cargoMass + passengers.size() * SITTING_PLAYER_MASS_KG; final double wetMass = FlightComputer.getFuelKg(computer) + dryMass; return wetMass / (Math.exp(getDeltaVMetersPerSecond() / EXHAUST_VELOCITY_METERS_PER_SECOND)) - dryMass; diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/mechanics/Fuel.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/mechanics/Fuel.java index 40a8dbaa4..0608ca090 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/mechanics/Fuel.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/mechanics/Fuel.java @@ -13,6 +13,12 @@ import vg.civcraft.mc.civmodcore.inventory.CustomItem; public class Fuel { + public static void registerCustomItems() { + createCrudeOil(); + createRocketFuel(); + createAluminiumIngot(); + } + public static ItemStack createCrudeOil() { ItemStack item = new ItemStack(Material.RECOVERY_COMPASS); item.setData(DataComponentTypes.ITEM_MODEL, new NamespacedKey("minecraft", "charcoal")); @@ -41,6 +47,17 @@ public class Fuel { return item; } + public static ItemStack createAluminiumIngot() { + ItemStack item = new ItemStack(Material.IRON_INGOT); + ItemMeta meta = item.getItemMeta(); + meta.itemName(Component.text("Aluminium Ingot", TextColor.color(211, 131, 59))); + meta.setEnchantmentGlintOverride(true); + item.setItemMeta(meta); + CustomItem.registerCustomItem("aluminium_ingot", item); + + return item; + } + public static boolean isRocketFuel(final ItemStack item) { return CustomItem.isCustomItem(item, "rocket_fuel"); } diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/ActivityManager.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/ActivityManager.java index e7444bcaa..4ed9145a2 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/ActivityManager.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/ActivityManager.java @@ -1,9 +1,9 @@ package net.civmc.zorweth.oxygen; -import java.util.Comparator; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; -import java.util.TreeMap; +import java.util.Set; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -11,7 +11,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityRegainHealthEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -23,14 +22,19 @@ public class ActivityManager implements Listener { // last time activity was detected private final Map> activities = new HashMap<>(); - public Activity getActivity(Player player) { + public Set getActivities(Player player) { + Set playerActivities = new HashSet<>(); for (Map.Entry entry : activities.get(player).entrySet()) { if (entry.getValue() + ACTIVITY_DURATION_MS > System.currentTimeMillis()) { - return entry.getKey(); + playerActivities.add(entry.getKey()); } } - return Activity.IDLE; + if (playerActivities.isEmpty()) { + playerActivities.add(Activity.IDLE); + } + + return playerActivities; } @EventHandler @@ -69,10 +73,6 @@ public class ActivityManager implements Listener { if (event.getDamager() instanceof Player player) { recordActivity(player, Activity.COMBAT); } - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void on(EntityDamageEvent event) { if (event.getEntity() instanceof Player player) { recordActivity(player, Activity.COMBAT); } @@ -95,7 +95,7 @@ public class ActivityManager implements Listener { } private void recordActivity(Player player, Activity activity) { - activities.computeIfAbsent(player, k -> new TreeMap<>(Comparator.reverseOrder())) + activities.computeIfAbsent(player, k -> new HashMap<>()) .put(activity, System.currentTimeMillis()); } diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBladder.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBladder.java index a01b18524..4ec34b806 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBladder.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBladder.java @@ -1,12 +1,15 @@ package net.civmc.zorweth.oxygen; import io.papermc.paper.datacomponent.DataComponentTypes; +import java.util.HashMap; import java.util.List; +import java.util.Map; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.TextColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; import org.bukkit.inventory.CraftingRecipe; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ShapelessRecipe; @@ -18,7 +21,8 @@ import vg.civcraft.mc.civmodcore.inventory.CustomItem; public final class OxygenBladder { - private static final String CUSTOM_ITEM_KEY = "small_oxygen_bladder"; + private static final String SMALL_OXYGEN_BLADDER = "small_oxygen_bladder"; + private static final String OXYGEN_REBREATHER = "oxygen_rebreather"; private static final NamespacedKey RESERVE_KEY = new NamespacedKey("zorweth", "oxygen_bladder_reserve"); private OxygenBladder() { @@ -37,36 +41,75 @@ public final class OxygenBladder { )); meta.setEnchantmentGlintOverride(true); item.setItemMeta(meta); - CustomItem.registerCustomItem(CUSTOM_ITEM_KEY, item); + CustomItem.registerCustomItem(SMALL_OXYGEN_BLADDER, item); return item; } - public static boolean isSmallOxygenBladder(final ItemStack item) { - if (item == null || item.isEmpty()) { - return false; + public static ItemStack createOxygenRebreather() { + final ItemStack item = new ItemStack(Material.RECOVERY_COMPASS); + item.setData(DataComponentTypes.ITEM_MODEL, NamespacedKey.minecraft("conduit")); + item.setData(DataComponentTypes.MAX_STACK_SIZE, 1); + final ItemMeta meta = item.getItemMeta(); + meta.itemName(Component.text("Oxygen Rebreather", TextColor.color(140, 163, 177))); + meta.lore(List.of( + Component.text("An efficient apparatus for recycling oxygen.", NamedTextColor.WHITE), + Component.text("Increases max oxygen to 16000", NamedTextColor.WHITE), + Component.text("Automatically consumes oxygen items below 1000 oxygen", NamedTextColor.WHITE) + )); + meta.setEnchantmentGlintOverride(true); + item.setItemMeta(meta); + CustomItem.registerCustomItem(OXYGEN_REBREATHER, item); + return item; + } + + private static final Map BLADDER_MAX = new HashMap<>(); + + static { + BLADDER_MAX.put(SMALL_OXYGEN_BLADDER, 3D); + BLADDER_MAX.put(OXYGEN_REBREATHER, 16D); + } + + public static ItemStack getOxygenBladder(Player player) { + ItemStack bladder = null; + double max = 0; + + for (final ItemStack item : player.getInventory().getContents()) { + String key = CustomItem.getCustomItemKey(item); + if (BLADDER_MAX.containsKey(key) && BLADDER_MAX.get(key) > max) { + max = BLADDER_MAX.get(key); + bladder = item; + } } - return CustomItem.isCustomItem(item, CUSTOM_ITEM_KEY); + + return bladder; + } + + public static double getMaxOxygen(Player player) { + double max = OxygenManager.DEFAULT_MAX_OXYGEN; + + for (final ItemStack item : player.getInventory().getContents()) { + String key = CustomItem.getCustomItemKey(item); + if (BLADDER_MAX.containsKey(key) && BLADDER_MAX.get(key) > max) { + max = BLADDER_MAX.get(key); + } + } + + return max; } public static double getReserve(final ItemStack item) { - if (!isSmallOxygenBladder(item)) { - return 0; - } final ItemMeta meta = item.getItemMeta(); return Math.max(0, meta.getPersistentDataContainer().getOrDefault(RESERVE_KEY, PersistentDataType.DOUBLE, 0D)); } public static void setReserve(final ItemStack item, final double reserve) { - if (!isSmallOxygenBladder(item)) { - return; - } final ItemMeta meta = item.getItemMeta(); meta.getPersistentDataContainer().set(RESERVE_KEY, PersistentDataType.DOUBLE, Math.max(0, reserve)); item.setItemMeta(meta); } public static CraftingRecipe getRecipe(final Plugin plugin) { - final ShapelessRecipe recipe = new ShapelessRecipe(new NamespacedKey(plugin, CUSTOM_ITEM_KEY), + final ShapelessRecipe recipe = new ShapelessRecipe(new NamespacedKey(plugin, SMALL_OXYGEN_BLADDER), createSmallOxygenBladder()) .addIngredient(Material.STICK) .addIngredient(Material.STRING) diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBladderMechanics.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBladderMechanics.java index 2cb980ed2..1d950881e 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBladderMechanics.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBladderMechanics.java @@ -8,7 +8,6 @@ import org.bukkit.inventory.ItemStack; public final class OxygenBladderMechanics { - public static final double MAX_OXYGEN = 3; public static final double CONSUME_ITEM_PLAYER_OXYGEN_THRESHOLD = 1; public double drainOxygen(final Player player, final double amount, final double oxygenPerItem, @@ -28,7 +27,7 @@ public final class OxygenBladderMechanics { private double drawOxygen(final Player player, final double amount, final double oxygenPerItem, final boolean canConsumeItem) { double remaining = amount; - final ItemStack bladder = getSmallOxygenBladder(player); + final ItemStack bladder = OxygenBladder.getOxygenBladder(player); if (bladder == null) { return 0; } @@ -54,10 +53,6 @@ public final class OxygenBladderMechanics { return amount - remaining; } - public double getMaxOxygen(final Player player, final double defaultMaxOxygen) { - return getSmallOxygenBladder(player) == null ? defaultMaxOxygen : MAX_OXYGEN; - } - private double consumeOneOxygenItem(final Player player, final double oxygenPerItem) { for (final ItemStack item : player.getInventory().getContents()) { if (!OxygenBottle.isCrudeOxygen(item)) { @@ -73,13 +68,4 @@ public final class OxygenBladderMechanics { } return 0; } - - private ItemStack getSmallOxygenBladder(final Player player) { - for (final ItemStack item : player.getInventory().getContents()) { - if (OxygenBladder.isSmallOxygenBladder(item)) { - return item; - } - } - return null; - } } diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBottle.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBottle.java index f378865b6..2bf1e20b3 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBottle.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenBottle.java @@ -45,7 +45,7 @@ public class OxygenBottle { .addIngredient(Material.GLASS_BOTTLE) .addIngredient(Material.COAL) .addIngredient(Material.PITCHER_PLANT); - recipe.setCategory(CraftingBookCategory.EQUIPMENT); + recipe.setCategory(CraftingBookCategory.MISC); return recipe; } } diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenDisplay.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenDisplay.java index 77fde034d..fe7d88662 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenDisplay.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenDisplay.java @@ -67,7 +67,7 @@ public class OxygenDisplay implements Listener { public void updateScoreboardHUD(Player p) { double oxygen = oxygenManager.getOxygen(p); - if (!showOxygen.hasValue(p.getUniqueId()) || oxygen >= oxygenManager.getMaxOxygen(p)) { + if (!showOxygen.hasValue(p.getUniqueId()) || oxygen >= OxygenBladder.getMaxOxygen(p)) { oxygenScoreboard.hide(p); oxygenBottomLine.removePlayer(p); return; diff --git a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenManager.java b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenManager.java index c018e250c..b86fb04eb 100644 --- a/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenManager.java +++ b/plugins/zorweth-paper/src/main/java/net/civmc/zorweth/oxygen/OxygenManager.java @@ -10,6 +10,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Set; import java.util.WeakHashMap; import net.civmc.zorweth.ZorwethPlugin; import net.kyori.adventure.text.Component; @@ -36,8 +37,8 @@ public class OxygenManager implements Listener { private static final String OXYGEN_BREW_RECIPE_NAME = "Oxygen"; private static final double CRUDE_OXYGEN_AMOUNT = 0.09; - private static final double OXYGEN_BREW_AMOUNT = 1.8; - private static final double DEFAULT_MAX_OXYGEN = 1; + private static final double OXYGEN_BREW_AMOUNT = 1.6; + public static final double DEFAULT_MAX_OXYGEN = 1; private static final double REGENERATION_PREVENTION_OXYGEN = -0.15; public static final NamespacedKey NO_HEALTH_REGEN = new NamespacedKey("finale", "no_health_regen"); @@ -59,15 +60,18 @@ public class OxygenManager implements Listener { double oxygen = getOxygen(player); - ActivityManager.Activity activity = activityManager.getActivity(player); - player.sendMessage("activity -> " + activity); - double playerActivityMultiplier = activityMultiplier.getOrDefault(activity, 0D); + Set activities = activityManager.getActivities(player); + double playerActivityMultiplier = activities + .stream() + .mapToDouble(activityMultiplier::get) + .max() + .orElse(0D); double biomeMultiplier = biomeMultipliers.getOrDefault(player.getLocation().getBlock().getBiome(), 0D); double loss = playerActivityMultiplier * biomeMultiplier; if (loss == 0) { - if (activity == ActivityManager.Activity.IDLE) { + if (activities.contains(ActivityManager.Activity.IDLE)) { oxygen += baseOxygenConsumptionPerSecond; } else { oxygen += baseOxygenConsumptionPerSecond / 2; @@ -97,12 +101,10 @@ public class OxygenManager implements Listener { @EventHandler public void on(PlayerItemConsumeEvent event) { - if (!OxygenBottle.isCrudeOxygen(event.getItem())) { - return; - } - Player player = event.getPlayer(); - addOxygen(player, CRUDE_OXYGEN_AMOUNT); + if (OxygenBottle.isCrudeOxygen(event.getItem())) { + addOxygen(player, CRUDE_OXYGEN_AMOUNT); + } } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -209,16 +211,12 @@ public class OxygenManager implements Listener { public void setOxygen(final Player player, final double oxygen) { player.getPersistentDataContainer().set(oxygenKey, PersistentDataType.DOUBLE, - Math.clamp(oxygen, -1, this.oxygenBladderMechanics.getMaxOxygen(player, DEFAULT_MAX_OXYGEN))); - } - - public double getMaxOxygen(final Player player) { - return this.oxygenBladderMechanics.getMaxOxygen(player, DEFAULT_MAX_OXYGEN); + Math.clamp(oxygen, -1, OxygenBladder.getMaxOxygen(player))); } private void sendDebouncedMessage(Player player, Component message) { Long lastMessageTime = lastMessage.get(player); - if (lastMessageTime != null && lastMessageTime + 30_000 > System.currentTimeMillis()) { + if (lastMessageTime != null && lastMessageTime + 15_000 > System.currentTimeMillis()) { return; }