From aaf6bd00b1682ce22bab036ccd1d1c280d312a4a Mon Sep 17 00:00:00 2001 From: Leonard Kugis Date: Sat, 24 Dec 2016 05:09:24 +0100 Subject: initial commit --- .../java/com/encrox/instanceddungeons/Section.java | 263 +++++++++++++++++++++ 1 file changed, 263 insertions(+) create mode 100644 src/main/java/com/encrox/instanceddungeons/Section.java (limited to 'src/main/java/com/encrox/instanceddungeons/Section.java') diff --git a/src/main/java/com/encrox/instanceddungeons/Section.java b/src/main/java/com/encrox/instanceddungeons/Section.java new file mode 100644 index 0000000..0c40b24 --- /dev/null +++ b/src/main/java/com/encrox/instanceddungeons/Section.java @@ -0,0 +1,263 @@ +package com.encrox.instanceddungeons; + +import java.io.File; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.plugin.Plugin; +import org.json.JSONArray; +import org.json.JSONObject; + +import com.encrox.instancedregions.InstancedProtectedCuboidRegion; +import com.sk89q.worldedit.BlockVector; + +public class Section { + + private Schematic schematic; + private String schematicFileName; + private Map exitMap; + private ArrayList players; + private BlockVector[] exits; + private BlockVector size; + private int index, depth; + private InstancedProtectedCuboidRegion region; + private Listener moveOutOfLoadingZoneListener, moveIntoLoadingZoneListener; + private volatile boolean justEntered, portal; + + public Section(JSONObject descriptor, int index, int depth) { + this.index = index; + this.depth = depth; + players = new ArrayList(); + schematicFileName = descriptor.getString("file"); + JSONArray size = descriptor.getJSONArray("size"); + this.size = new BlockVector(size.getInt(0), size.getInt(1), size.getInt(2)); + JSONArray exits = descriptor.getJSONArray("exits"); + this.exits = new BlockVector[exits.length()]; + for(int i = 0; i(); + this.schematic = new Schematic(new File(InstancedDungeons.schematicsDirectory, schematicFileName)); + if(index <= depth) { + Section next; + ArrayList
usable = new ArrayList
(); + for(int i = 0; i sections = exitMap.values().iterator(); + while(sections.hasNext()) + sections.next().addPlayer(player); + } + } + + public void removePlayer(Player player) { + players.add(player); + if(region != null) + region.removePlayer(player); + if(exitMap != null) { + Iterator
sections = exitMap.values().iterator(); + while(sections.hasNext()) + sections.next().removePlayer(player); + } + } + +} -- cgit v1.2.1