Skip to content

Commit

Permalink
damage as point
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Dec 17, 2023
1 parent 36cf688 commit be23f87
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
18 changes: 9 additions & 9 deletions src/main/java/me/hsgamer/gamesinthebox/pinata/GameEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class GameEditor extends TemplateGameEditor {
private final SimpleBoundingOffsetFeature.Editor simpleBoundingOffsetFeatureEditor = SimpleBoundingOffsetFeature.editor();
private final List<String> nameTags = new ArrayList<>();
private EntityType entityType = EntityType.SHEEP;
private boolean damageAsScore = false;
private boolean damageAsPoint = false;
private boolean hasAI = true;

public GameEditor(@NotNull TemplateGame game) {
Expand Down Expand Up @@ -103,10 +103,10 @@ protected Optional<EntityType> parseValue(@NotNull CommandSender sender, String.
.collect(Collectors.toList());
}
});
map.put("set-damage-as-score", new ValueAction<Boolean>() {
map.put("set-damage-as-point", new ValueAction<Boolean>() {
@Override
protected boolean performAction(@NotNull CommandSender sender, @NotNull Boolean value, String... args) {
damageAsScore = value;
damageAsPoint = value;
return true;
}

Expand All @@ -127,7 +127,7 @@ protected Optional<Boolean> parseValue(@NotNull CommandSender sender, String...

@Override
public @NotNull String getDescription() {
return "Set whether to use damage as score";
return "Set whether to use damage as points";
}

@Override
Expand Down Expand Up @@ -181,7 +181,7 @@ protected Optional<Boolean> parseValue(@NotNull CommandSender sender, String...
public void sendStatus(@NotNull CommandSender sender) {
MessageUtils.sendMessage(sender, "&6&lPinata");
MessageUtils.sendMessage(sender, "&6Type: &f" + entityType.name());
MessageUtils.sendMessage(sender, "&6Damage As Score: &f" + damageAsScore);
MessageUtils.sendMessage(sender, "&6Damage As Point: &f" + damageAsPoint);
MessageUtils.sendMessage(sender, "&6AI: &f" + hasAI);
MessageUtils.sendMessage(sender, "&6Name Tags: ");
nameTags.forEach(nameTag -> MessageUtils.sendMessage(sender, "&f- " + nameTag));
Expand All @@ -191,7 +191,7 @@ public void sendStatus(@NotNull CommandSender sender) {
public void reset(@NotNull CommandSender sender) {
nameTags.clear();
entityType = EntityType.SHEEP;
damageAsScore = false;
damageAsPoint = false;
hasAI = true;
}

Expand All @@ -209,8 +209,8 @@ public Map<String, Object> toPathValueMap(@NotNull CommandSender sender) {
if (entityType != EntityType.SHEEP) {
map.put("pinata.type", entityType.name());
}
if (damageAsScore) {
map.put("damage-as-score", true);
if (damageAsPoint) {
map.put("damage-as-point", true);
}
if (!hasAI) {
map.put("pinata.ai", false);
Expand All @@ -236,7 +236,7 @@ public boolean migrate(@NotNull CommandSender sender, @NotNull GameArena gameAre
nameTags.addAll(gameArena.getFeature(PinataFeature.class).getNameTags());

entityType = gameArena.getFeature(PinataFeature.class).getEntityType();
damageAsScore = gameArena.getFeature(ListenerFeature.class).isDamageAsScore();
damageAsPoint = gameArena.getFeature(ListenerFeature.class).isDamageAsPoint();
hasAI = gameArena.getFeature(PinataFeature.class).isHasAI();

simpleBoundingFeatureEditor.migrate(gameArena.getFeature(SimpleBoundingFeature.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ListenerFeature implements Feature, Listener {
private final SimpleGameArena arena;
private PinataFeature pinataFeature;
private SimplePointFeature pointFeature;
private boolean damageAsScore = false;
private boolean damageAsPoint = false;

public ListenerFeature(Pinata expansion, SimpleGameArena arena) {
this.expansion = expansion;
Expand All @@ -41,7 +41,7 @@ public void postInit() {
GameConfigFeature gameConfigFeature = arena.getFeature(GameConfigFeature.class);

if (gameConfigFeature != null) {
damageAsScore = Optional.ofNullable(gameConfigFeature.getString("damage-as-score"))
damageAsPoint = Optional.ofNullable(gameConfigFeature.getString("damage-as-point"))
.map(Boolean::parseBoolean)
.orElse(false);
}
Expand All @@ -55,8 +55,8 @@ public void unregister() {
HandlerList.unregisterAll(this);
}

public boolean isDamageAsScore() {
return damageAsScore;
public boolean isDamageAsPoint() {
return damageAsPoint;
}

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
Expand All @@ -70,7 +70,7 @@ public void onPinataDamage(EntityDamageByEntityEvent event) {

event.setDamage(0);

if (damageAsScore) {
if (damageAsPoint) {
pointFeature.applyPoint(player.getUniqueId(), (int) event.getFinalDamage());
} else {
pointFeature.applyPoint(player.getUniqueId(), Pinata.POINT_HIT);
Expand Down

0 comments on commit be23f87

Please sign in to comment.