[REQUEST] Domination system tutorial?

Discussion in 'Plugin Development' started by EnchantedMiners, Mar 15, 2016.

Thread Status:
Not open for further replies.
  1. Offline


    I was wondering if anyone can do a tutorial of a Domination call of duty gamemode if you dont know what it is then its besically standing on a area for certain amount of time until you capture it and if there is an enemy team in the area then it would pause the capturing and when your team have killed them the capturing may resume where it left of. If someone would make a tutorial on how to do this in a efficient way would be awesome, thanks! also the area is a cubeoid using the following cuboid class reference

    package com.loco_x_killer.kingdoms.utils.region;
    import org.bukkit.*;
    import org.bukkit.block.Block;
    import org.bukkit.configuration.serialization.ConfigurationSerializable;
    import org.bukkit.util.Vector;
    import java.util.*;
    public class Cuboid implements Cloneable, ConfigurationSerializable, Iterable<Block> {
        protected String worldName;
        protected final Vector minimumPoint, maximumPoint;
        public Cuboid(Cuboid cuboid) {
            this(cuboid.worldName, cuboid.minimumPoint.getX(), cuboid.minimumPoint.getY(), cuboid.minimumPoint.getZ(), cuboid.maximumPoint.getX(), cuboid.maximumPoint.getY(), cuboid.maximumPoint.getZ());
        public Cuboid(Location loc) {
            this(loc, loc);
        public Cuboid(Location loc1, Location loc2) {
            if (loc1 != null && loc2 != null) {
                if (loc1.getWorld() != null && loc2.getWorld() != null) {
                    if (!loc1.getWorld().getUID().equals(loc2.getWorld().getUID()))
                        throw new IllegalStateException("The 2 locations of the cuboid must be in the same world!");
                } else {
                    throw new NullPointerException("One/both of the worlds is/are null!");
                this.worldName = loc1.getWorld().getName();
                double xPos1 = Math.min(loc1.getX(), loc2.getX());
                double yPos1 = Math.min(loc1.getY(), loc2.getY());
                double zPos1 = Math.min(loc1.getZ(), loc2.getZ());
                double xPos2 = Math.max(loc1.getX(), loc2.getX());
                double yPos2 = Math.max(loc1.getY(), loc2.getY());
                double zPos2 = Math.max(loc1.getZ(), loc2.getZ());
                this.minimumPoint = new Vector(xPos1, yPos1, zPos1);
                this.maximumPoint = new Vector(xPos2, yPos2, zPos2);
            } else {
                throw new NullPointerException("One/both of the locations is/are null!");
        public Cuboid(String worldName, double x1, double y1, double z1, double x2, double y2, double z2) {
            if (worldName == null || Bukkit.getServer().getWorld(worldName) == null)
                throw new NullPointerException("One/both of the worlds is/are null!");
            this.worldName = worldName;
            double xPos1 = Math.min(x1, x2);
            double xPos2 = Math.max(x1, x2);
            double yPos1 = Math.min(y1, y2);
            double yPos2 = Math.max(y1, y2);
            double zPos1 = Math.min(z1, z2);
            double zPos2 = Math.max(z1, z2);
            this.minimumPoint = new Vector(xPos1, yPos1, zPos1);
            this.maximumPoint = new Vector(xPos2, yPos2, zPos2);
        public boolean containsLocation(Location location) {
            return location != null && location.toVector().isInAABB(this.minimumPoint, this.maximumPoint);
        public boolean containsVector(Vector vector) {
            return vector != null && vector.isInAABB(this.minimumPoint, this.maximumPoint);
        public List<Block> getBlocks() {
            List<Block> blockList = new ArrayList<>();
            World world = this.getWorld();
            if (world != null) {
                for (int x = this.minimumPoint.getBlockX(); x <= this.maximumPoint.getBlockX(); x++) {
                    for (int y = this.minimumPoint.getBlockY(); y <= this.maximumPoint.getBlockY() && y <= world.getMaxHeight(); y++) {
                        for (int z = this.minimumPoint.getBlockZ(); z <= this.maximumPoint.getBlockZ(); z++) {
                            blockList.add(world.getBlockAt(x, y, z));
            return blockList;
        public Location getLowerLocation() {
            return this.minimumPoint.toLocation(this.getWorld());
        public double getLowerX() {
            return this.minimumPoint.getX();
        public double getLowerY() {
            return this.minimumPoint.getY();
        public double getLowerZ() {
            return this.minimumPoint.getZ();
        public Location getUpperLocation() {
            return this.maximumPoint.toLocation(this.getWorld());
        public double getUpperX() {
            return this.maximumPoint.getX();
        public double getUpperY() {
            return this.maximumPoint.getY();
        public double getUpperZ() {
            return this.maximumPoint.getZ();
        public double getVolume() {
            return (this.getUpperX() - this.getLowerX() + 1) * (this.getUpperY() - this.getLowerY() + 1) * (this.getUpperZ() - this.getLowerZ() + 1);
        public World getWorld() {
            World world = Bukkit.getServer().getWorld(this.worldName);
            if (world == null) throw new NullPointerException("World '" + this.worldName + "' is not loaded.");
            return world;
        public void setWorld(World world) {
            if (world != null) this.worldName = world.getName();
            else throw new NullPointerException("The world cannot be null.");
        public Cuboid clone() {
            return new Cuboid(this);
        public ListIterator<Block> iterator() {
            return this.getBlocks().listIterator();
        public Map<String, Object> serialize() {
            Map<String, Object> serializedCuboid = new HashMap<>();
            serializedCuboid.put("worldName", this.worldName);
            serializedCuboid.put("x1", this.minimumPoint.getX());
            serializedCuboid.put("x2", this.maximumPoint.getX());
            serializedCuboid.put("y1", this.minimumPoint.getY());
            serializedCuboid.put("y2", this.maximumPoint.getY());
            serializedCuboid.put("z1", this.minimumPoint.getZ());
            serializedCuboid.put("z2", this.maximumPoint.getZ());
            return serializedCuboid;
        public static Cuboid deserialize(Map<String, Object> serializedCuboid) {
            try {
                String worldName = (String) serializedCuboid.get("worldName");
                double xPos1 = (Double) serializedCuboid.get("x1");
                double xPos2 = (Double) serializedCuboid.get("x2");
                double yPos1 = (Double) serializedCuboid.get("y1");
                double yPos2 = (Double) serializedCuboid.get("y2");
                double zPos1 = (Double) serializedCuboid.get("z1");
                double zPos2 = (Double) serializedCuboid.get("z2");
                return new Cuboid(worldName, xPos1, yPos1, zPos1, xPos2, yPos2, zPos2);
            } catch (Exception ex) {
                return null;
  2. Offline


    1. This is not the right location for this type of thread. The PD thread is solving problems with your code. We are not guide people through entire projects.
    2. You are asking for a tutorial on how to make a whole gamemode. This is a lot more work and covers more subjects (Making a GameModeManager, All the classes for the gamemode, Making the rules for the gamemode itself,ect.) than would should be in a single tutorial. Most likely, no one will make this tutorial.
    3. You should do this on your own. At the very least, make a mock design of the gamemode. If anything goes wrong, post it here and we will help fix the problem.
  3. Offline


    @Zombie_Striker ok i forgot to mention NO i didnt mean the entire gamemode i only meant the capturing of the area methods...
    and if you would kindly point me to the forum i should move this into that would be more help than just putting this
  4. Offline


    If you want someone to help you with a whole gamemode/guide you on how to do something ,this thread should be used to Offtopic. If you do not know where it goes, it should go there. But if your problem is that you only want to know how to capture an area, you should write up some code first and then post whatever problem you encounter.

    If you're really stuck with it, my suggestion would be to create a "CapturedArea" class that stored who owns that area. From there, add some listeners to test if anyone else claims the CapturedArea.
  5. Offline


    -Have a repeating task that checks if players from either team are in an area of the objective
    -Get the number of players at each flag from both teams
    -If there are more players of one team than another at an objective slowly increment a variable in favor of that team
    -Once that variable hits a certain point, stop increasing it, and display which team captured it.
    -Every so often give points to the teams for the amount of objectives they own
    -To constantly display who has what objective you could use a scoreboard or something
    -If a team hits a certain number of points, they win.
    -Send players to a lobby or something

    ^Just an idea^ ... Give it your best shot and come back here if you have any problems.
  6. Offline


    @Evonoucono Thanks dude you see @Zombie_Striker thats what i needed thanks for the "Help" anyway. @Evonoucono i will try those and if i have any problem or if i successfully manage to make it work i will come back to this thread, thanks!
Thread Status:
Not open for further replies.

Share This Page