Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added per Arena Whitelist/BlackList (optional feature) and Compass Track #71

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions src/main/java/org/mcsg/survivalgames/Arena.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,74 @@
package org.mcsg.survivalgames;

import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;

public class Arena {

Location min;
Location max;

boolean isWhite = true;
boolean useGeneral;
ArrayList<Integer> allowedBreak = new ArrayList<Integer>();
ArrayList<Integer> allowedPlace = new ArrayList<Integer>();

public Arena(Location min, Location max) {
public Arena(Location min, Location max, List<Integer> allowedBreak, List<Integer> allowedPlace) {
this.max = max;
this.min = min;
this.allowedBreak.addAll(allowedBreak);
this.allowedPlace.addAll(allowedPlace);
this.useGeneral = false;
}

public Arena(Location min, Location max, List<Integer> allowedBreak, List<Integer> allowedPlace, boolean isWhite) {
this(min, max, allowedBreak, allowedPlace);
this.isWhite = isWhite;
}

public Arena(Location min, Location max) {
this(min, max, new ArrayList<Integer>(), new ArrayList<Integer>());

useGeneral = true;
}

public boolean containsBlock(Location v) {
if (v.getWorld() != min.getWorld()) return false;
if (v.getWorld() != min.getWorld()) {
return false;
}
final double x = v.getX();
final double y = v.getY();
final double z = v.getZ();
return x >= min.getBlockX() && x < max.getBlockX() + 1 && y >= min.getBlockY() && y < max.getBlockY() + 1 && z >= min.getBlockZ() && z < max.getBlockZ() + 1;
return x >= min.getBlockX() && x < max.getBlockX() + 1 && y >= min.getBlockY() && y < max.getBlockY() + 1 && z >= min.getBlockZ() && z < max.getBlockZ() + 1;
}

public Location getMax() {
Runtime.getRuntime().freeMemory();
Runtime.getRuntime().freeMemory();
return max;
}

public Location getMin() {
return min;
}

public boolean useGeneral(){
return this.useGeneral;
}

public boolean canPlace(int id) {
if (allowedPlace.contains(-1)) {
return true;
} else {
return (isWhite) ? allowedPlace.contains(id) : !allowedPlace.contains(id);
}
}

public boolean canBreak(int id) {
if (allowedBreak.contains(-1)) {
return true;
} else {
return (isWhite) ? allowedBreak.contains(id) : !allowedBreak.contains(id);
}
}
}
2 changes: 0 additions & 2 deletions src/main/java/org/mcsg/survivalgames/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.mcsg.survivalgames.commands.Spectate;
import org.mcsg.survivalgames.commands.SubCommand;
import org.mcsg.survivalgames.commands.Teleport;
import org.mcsg.survivalgames.commands.Test;
import org.mcsg.survivalgames.commands.Vote;


Expand Down Expand Up @@ -72,7 +71,6 @@ private void loadCommands() {
commands.put("list", new ListPlayers());
commands.put("tp", new Teleport());
commands.put("reload", new Reload());
commands.put("test", new Test());

// commands.put("sponsor", new Sponsor());
}
Expand Down
Loading