Skip to content

Commit cfbb333

Browse files
thibaulthenrydualspiral
authored andcommitted
Add missing scoreboard criteria and getTeamColor
1 parent 975ffb1 commit cfbb333

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

src/main/java/org/spongepowered/api/GameRegistry.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
import org.spongepowered.api.registry.RegistryModule;
4545
import org.spongepowered.api.registry.RegistryModuleAlreadyRegisteredException;
4646
import org.spongepowered.api.resourcepack.ResourcePack;
47+
import org.spongepowered.api.scoreboard.critieria.Criterion;
4748
import org.spongepowered.api.scoreboard.displayslot.DisplaySlot;
49+
import org.spongepowered.api.scoreboard.objective.Objective;
4850
import org.spongepowered.api.statistic.BlockStatistic;
4951
import org.spongepowered.api.statistic.EntityStatistic;
5052
import org.spongepowered.api.statistic.ItemStatistic;
@@ -351,6 +353,28 @@ <T extends CatalogType> GameRegistry registerModule(Class<T> catalogClass, Catal
351353
*/
352354
Optional<ResourcePack> getResourcePackById(String id);
353355

356+
/**
357+
* Gets a {@link Criterion} which causes an {@link Objective}
358+
* to have a score for a player incremented when he kills a member of
359+
* the given colored team.
360+
*
361+
* @param color The color for the criterion
362+
* @return The team kill {@link Criterion} with the provided color,
363+
* or <tt>Optional.empty()</tt> if not found
364+
*/
365+
Optional<Criterion> getTeamKillCriterionForColor(TextColor color);
366+
367+
/**
368+
* Gets a {@link Criterion} which causes an {@link Objective}
369+
* to have a score for a player incremented when he has been killed by
370+
* a member of the given colored team.
371+
*
372+
* @param color The color for the criterion
373+
* @return The killed by team {@link Criterion} with the provided color,
374+
* or <tt>Optional.empty()</tt> if not found
375+
*/
376+
Optional<Criterion> getKilledByTeamCriterionForColor(TextColor color);
377+
354378
/**
355379
* Gets a {@link DisplaySlot} which displays only for teams with the
356380
* provided color.

src/main/java/org/spongepowered/api/scoreboard/critieria/Criteria.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ public final class Criteria {
3535

3636
// SORTFIELDS:ON
3737

38+
/**
39+
* Represents a {@link Criterion} which causes an {@link Objective}
40+
* to have a score that represents the amount of air the player has
41+
* left from swimming under water, matches the air nbt tag of the
42+
* player, on a scale of 0-300.
43+
*/
44+
public static final Criterion AIR = DummyObjectProvider.createFor(Criterion.class, "AIR");
45+
46+
/**
47+
* Represents a {@link Criterion} which causes an {@link Objective}
48+
* to have a score for a player represent their amount of armor points,
49+
* on a scale of 0-20. May appear as 0 for players before their armor
50+
* has changed for the first time.
51+
*/
52+
public static final Criterion ARMOR = DummyObjectProvider.createFor(Criterion.class, "ARMOR");
53+
3854
/**
3955
* Represents a {@link Criteria} which causes an {@link Objective}
4056
* to have a score for a player incremented when they die.
@@ -47,6 +63,14 @@ public final class Criteria {
4763
*/
4864
public static final Criterion DUMMY = DummyObjectProvider.createFor(Criterion.class, "DUMMY");
4965

66+
/**
67+
* Represents a {@link Criterion} which causes an {@link Objective}
68+
* to have a score that represents the amount of hunger points the
69+
* player has, on a scale of 0-20. May appear as 0 for players before
70+
* their foodLevel has changed for the first time.
71+
*/
72+
public static final Criterion FOOD = DummyObjectProvider.createFor(Criterion.class, "FOOD");
73+
5074
/**
5175
* Represents a {@link Criteria} which causes an {@link Objective} to have
5276
* a score for a player represent their current health, on a scale of 0-20
@@ -55,6 +79,12 @@ public final class Criteria {
5579
*/
5680
public static final Criterion HEALTH = DummyObjectProvider.createFor(Criterion.class, "HEALTH");
5781

82+
/**
83+
* Represents a {@link Criteria} which causes an {@link Objective} to have
84+
* a score that matches the current experience level of the player.
85+
*/
86+
public static final Criterion LEVEL = DummyObjectProvider.createFor(Criterion.class, "LEVEL");
87+
5888
/**
5989
* Represents a {@link Criteria} which causes an {@link Objective}
6090
* to have a score for a player incremented when they kill a player.
@@ -74,6 +104,13 @@ public final class Criteria {
74104
*/
75105
public static final Criterion TRIGGER = DummyObjectProvider.createFor(Criterion.class, "TRIGGER");
76106

107+
/**
108+
* Represents a {@link Criteria} which causes an {@link Objective} to have
109+
* a score that matches the total amount of experience the player has
110+
* collected since their last death (or in other words, their score).
111+
*/
112+
public static final Criterion XP = DummyObjectProvider.createFor(Criterion.class, "XP");
113+
77114
// SORTFIELDS:OFF
78115

79116
// Suppress default constructor to ensure non-instantiability.

src/main/java/org/spongepowered/api/scoreboard/critieria/Criterion.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@
2525
package org.spongepowered.api.scoreboard.critieria;
2626

2727
import org.spongepowered.api.CatalogType;
28+
import org.spongepowered.api.scoreboard.Team;
29+
import org.spongepowered.api.text.format.TextColor;
2830
import org.spongepowered.api.util.annotation.CatalogedBy;
2931

32+
import java.util.Optional;
33+
3034
/**
3135
* Represents a set of behaviours for an objective, which may cause it to be
3236
* automatically updated.
@@ -42,4 +46,11 @@ public interface Criterion extends CatalogType {
4246
@Override
4347
String getName();
4448

49+
/**
50+
* Gets the {@link Team} color that this criterion depending on, if set.
51+
*
52+
* @return The {@link Team} color that this criterion depending on, if set
53+
*/
54+
Optional<TextColor> getTeamColor();
55+
4556
}

0 commit comments

Comments
 (0)