|
16 | 16 | * You should have received a copy of the GNU General Public License
|
17 | 17 | * along with this program. If not, see <https://www.gnu.org/licenses/>.
|
18 | 18 | */
|
19 |
| -package com.xpdustry.domination.commands; |
| 19 | +package com.xpdustry.domination; |
20 | 20 |
|
21 | 21 | import com.xpdustry.distributor.api.command.CommandSender;
|
22 |
| -import com.xpdustry.domination.DominationPlugin; |
23 |
| -import com.xpdustry.domination.Zone; |
24 | 22 | import mindustry.Vars;
|
25 | 23 | import org.incendo.cloud.annotation.specifier.Range;
|
26 | 24 | import org.incendo.cloud.annotations.Argument;
|
27 | 25 | import org.incendo.cloud.annotations.Command;
|
| 26 | +import org.incendo.cloud.annotations.CommandDescription; |
28 | 27 | import org.incendo.cloud.annotations.Flag;
|
29 | 28 | import org.incendo.cloud.annotations.Permission;
|
| 29 | +import org.incendo.cloud.annotations.ProxiedBy; |
30 | 30 |
|
31 |
| -public final class EditCommands { |
| 31 | +public final class ZoneCommands { |
32 | 32 |
|
33 | 33 | private final DominationPlugin domination;
|
34 | 34 |
|
35 |
| - public EditCommands(final DominationPlugin domination) { |
| 35 | + public ZoneCommands(final DominationPlugin domination) { |
36 | 36 | this.domination = domination;
|
37 | 37 | }
|
38 | 38 |
|
| 39 | + @Command("domination zone list") |
| 40 | + @CommandDescription("Get the data about the zones.") |
| 41 | + @ProxiedBy("zones") |
| 42 | + public void listZones(final CommandSender sender) { |
| 43 | + final var builder = new StringBuilder(); |
| 44 | + final var captured = domination.getState().getZones().stream() |
| 45 | + .map(Zone::getTeam) |
| 46 | + .filter(sender.getPlayer().team()::equals) |
| 47 | + .count(); |
| 48 | + builder.append("[orange]"); |
| 49 | + if (captured == domination.getState().getZones().size()) { |
| 50 | + builder.append("Your team is about to capture all the zones :\n"); |
| 51 | + } else { |
| 52 | + builder.append("Your team has [red]") |
| 53 | + .append(domination.getState().getZones().size() - captured) |
| 54 | + .append("[] more zones to capture :\n"); |
| 55 | + } |
| 56 | + final var iterator = domination.getState().getZones().iterator(); |
| 57 | + while (iterator.hasNext()) { |
| 58 | + final var zone = iterator.next(); |
| 59 | + builder.append("[white]- Zone at (") |
| 60 | + .append(zone.getX() / 8) |
| 61 | + .append(", ") |
| 62 | + .append(zone.getY() / 8) |
| 63 | + .append(") is captured by ") |
| 64 | + .append("[#") |
| 65 | + .append(zone.getTeam().color) |
| 66 | + .append("]") |
| 67 | + .append(zone.getTeam().name) |
| 68 | + .append("[] at ") |
| 69 | + .append(zone.getCapture()) |
| 70 | + .append("% percent."); |
| 71 | + if (iterator.hasNext()) { |
| 72 | + builder.append('\n'); |
| 73 | + } |
| 74 | + } |
| 75 | + sender.reply(builder.toString()); |
| 76 | + } |
| 77 | + |
39 | 78 | @Command("domination zone radius <x> <y> <radius>")
|
40 | 79 | @Permission("com.xpdustry.domination.zone.edit")
|
41 | 80 | public void setZoneSize(
|
|
0 commit comments