From a92256008c8c1ca241bb4cdc3c32694098ef26a1 Mon Sep 17 00:00:00 2001 From: Khalid Ali Date: Thu, 17 Sep 2020 23:47:19 -0400 Subject: [PATCH] Added Radioactive Obstacle to map with WorldCreationListener --- .../event/WorldCreationListener.java | 32 +++++++++++++++++++ Server/src/main/resources/config.properties | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud/event/WorldCreationListener.java diff --git a/Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud/event/WorldCreationListener.java b/Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud/event/WorldCreationListener.java new file mode 100644 index 0000000..1876fc3 --- /dev/null +++ b/Plugin Radioactive Cloud/src/main/java/net/simon987/pluginradioactivecloud/event/WorldCreationListener.java @@ -0,0 +1,32 @@ +package net.simon987.pluginradioactivecloud.event; + +import net.simon987.pluginradioactivecloud.RadioactiveObstacle; +import net.simon987.pluginradioactivecloud.RadioactiveWorldUtils; +import net.simon987.server.GameServer; +import net.simon987.server.event.GameEvent; +import net.simon987.server.event.GameEventListener; +import net.simon987.server.event.WorldGenerationEvent; + +import java.util.ArrayList; + +public class WorldCreationListener implements GameEventListener { + @Override + public Class getListenedEventType() { + return WorldGenerationEvent.class; + } + + @Override + public void handle(GameEvent event) { + + int minCount = GameServer.INSTANCE.getConfig().getInt("min_radioactive_obstacle_count"); + int maxCount = GameServer.INSTANCE.getConfig().getInt("max_radioactive_obstacle_count"); + + ArrayList radioactiveObstacles = RadioactiveWorldUtils + .generateRadioactiveObstacles(((WorldGenerationEvent) event).getWorld(), minCount, maxCount); + + for (RadioactiveObstacle radioactiveObstacle : radioactiveObstacles) { + ((WorldGenerationEvent) event).getWorld().addObject(radioactiveObstacle); + } + + } +} diff --git a/Server/src/main/resources/config.properties b/Server/src/main/resources/config.properties index 7bf0cf6..5509ffe 100644 --- a/Server/src/main/resources/config.properties +++ b/Server/src/main/resources/config.properties @@ -94,6 +94,8 @@ electric_box_energy_given=70 #RadioactiveObstacle radioactive_obstacle_corruption_block_size=10 radioactive_cloud_corruption_block_size=40 +min_radioactive_obstacle_count=0 +max_radioactive_obstacle_count=1 #SecretKey secret_key=