blob: 69cd8477422f566bc00fd6419a715ba66099275b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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<Player> 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;
}
}
|