From 9420b8c5ef71dee01d7e19160992c34d5feef154 Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Mon, 25 Apr 2022 18:40:22 +0200 Subject: . --- .../java/com/encrox/instanceddungeons/Dungeon.java | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/com/encrox/instanceddungeons/Dungeon.java (limited to 'src/main/java/com/encrox/instanceddungeons/Dungeon.java') diff --git a/src/main/java/com/encrox/instanceddungeons/Dungeon.java b/src/main/java/com/encrox/instanceddungeons/Dungeon.java new file mode 100644 index 0000000..a94ba36 --- /dev/null +++ b/src/main/java/com/encrox/instanceddungeons/Dungeon.java @@ -0,0 +1,48 @@ +package com.encrox.instanceddungeons; + +import java.util.ArrayList; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.json.JSONObject; + +import com.sk89q.worldedit.BlockVector; + +public class Dungeon { + + private Section section; + private String id; + private int depth; + private ArrayList players; + + public Dungeon(Player player, String id, int depth) { + this.id = id; + this.depth = depth; + section = new Section(InstancedDungeons.startDescriptors.getJSONObject((int)Math.round(Math.random()*(InstancedDungeons.startDescriptors.length()-1))), 0, depth); + try { + section.load(); + section.instantiate(); + BlockVector[] destinations = section.getAbsoluteExits(); + BlockVector destination = destinations[(int)Math.round(Math.random()*(destinations.length-1))]; + addPlayer(player); + player.teleport(new Location(InstancedDungeons.dungeonWorld.getWorld(), destination.getBlockX(), destination.getBlockY(), destination.getBlockZ())); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void addPlayer(Player player) { + section.addPlayer(player); + } + + public void removePlayer(Player player) { + section.removePlayer(player); + } + + public String getId() { + return id; + } + +} -- cgit v1.2.1