Skip to content

Commit

Permalink
added Collar option
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTheTech committed Sep 29, 2023
1 parent 3327921 commit 7c14c51
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
4 changes: 1 addition & 3 deletions src/main/java/lee/code/pets/enums/DyeColorChatColor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.DyeColor;

@AllArgsConstructor
public enum DyeColorChatColor {
Expand All @@ -21,8 +20,7 @@ public enum DyeColorChatColor {
ORANGE("&#FFA500"),
MAGENTA("&#FF00FF"),
LIGHT_BLUE("&#ADD8E6"),
YELLOW("&e"),

YELLOW("&e")
;
@Getter private String color;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public enum OptionSelector {
BAT(new String[] {Option.NAME.name()}),
BEE(new String[] {Option.NAME.name(), Option.BABY.name(), Option.ANGRY.name(), Option.NECTAR.name(), Option.STUNG.name()}),
CAMEL(new String[] {Option.NAME.name(), Option.BABY.name(), Option.SADDLE.name()}),
CAT(new String[] {Option.NAME.name(), Option.BABY.name(), Option.VARIANT.name(), Option.COLOR.name()}),
CAT(new String[] {Option.NAME.name(), Option.BABY.name(), Option.VARIANT.name(), Option.COLLAR.name(), Option.COLOR.name()}),
CHICKEN(new String[] {Option.NAME.name(), Option.BABY.name()}),
DONKEY(new String[] {Option.NAME.name(), Option.BABY.name(), Option.CHEST.name(), Option.SADDLE.name()}),
FOX(new String[] {Option.NAME.name(), Option.BABY.name(), Option.VARIANT.name()}),
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/lee/code/pets/pets/pet/animal/CatPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ public CatPet(Player player, String[] data) {
setCustomNameVisible(true);
setPersistenceRequired(true);
setCanPickUpLoot(false);
setTame(true);
setMaxUpStep(1.0F);
collides = false;
ageLocked = true;
setCustomName(Component.Serializer.fromJson(CoreUtil.serializeColorComponentJson(data[1])));
setBaby(Boolean.parseBoolean(data[2]));
setVariant(CatVariantUtil.valueOf(data[3]).getCatVariant());
setCollarColor(DyeColor.valueOf(data[4]));
if (Boolean.parseBoolean(data[4])) {
setTame(true);
setCollarColor(DyeColor.valueOf(data[5]));
}
setTarget(((CraftPlayer) player).getHandle(), EntityTargetEvent.TargetReason.CUSTOM, false);
moveControl = new ControllerWASD(this, player.getUniqueId(), 0.4F);
targetSelector.getAvailableGoals().clear();
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/lee/code/pets/utils/PetDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public static String getPetData(EntityType entityType, String[] data, Option opt
case NAME -> {return data[1];}
case BABY -> {return data[2];}
case VARIANT -> {return data[3];}
case COLOR -> {return data[4];}
case COLLAR -> {return data[4];}
case COLOR -> {return data[5];}
}
}
case WOLF -> {
Expand Down Expand Up @@ -237,7 +238,8 @@ public static String serializePetData(Entity entity) {
case CAT -> {
final Cat.Type catType = entity instanceof Cat cat ? cat.getCatType() : Cat.Type.ALL_BLACK;
final DyeColor color = entity instanceof Cat cat ? cat.getCollarColor() : DyeColor.RED;
return startingData + sep + isBaby + sep + catType.name() + sep + color.name();
final boolean hasCollar = entity instanceof Cat cat && cat.isTamed();
return startingData + sep + isBaby + sep + catType.name() + sep + hasCollar + sep + color.name();
}
case RABBIT -> {
final RabbitVariantUtil rabbitVariant = RabbitVariantUtil.getVariant(entity);
Expand Down Expand Up @@ -374,10 +376,11 @@ public static String addNewPetData(EntityType entityType, String[] data, String
}
case CAT -> {
switch (option) {
case NAME -> {return data[0] + sep + newData + sep + data[2] + sep + data[3] + sep + data[4];}
case BABY -> {return data[0] + sep + data[1] + sep + newData + sep + data[3] + sep + data[4];}
case VARIANT -> {return data[0] + sep + data[1] + sep + data[2] + sep + newData + sep + data[4];}
case COLOR -> {return data[0] + sep + data[1] + sep + data[2] + sep + data[3] + sep + newData;}
case NAME -> {return data[0] + sep + newData + sep + data[2] + sep + data[3] + sep + data[4] + sep + data[5];}
case BABY -> {return data[0] + sep + data[1] + sep + newData + sep + data[3] + sep + data[4] + sep + data[5];}
case VARIANT -> {return data[0] + sep + data[1] + sep + data[2] + sep + newData + sep + data[4] + sep + data[5];}
case COLLAR -> {return data[0] + sep + data[1] + sep + data[2] + sep + data[3] + sep + newData + sep + data[5];}
case COLOR -> {return data[0] + sep + data[1] + sep + data[2] + sep + data[3] + sep + data[4] + sep + newData;}
}
}
case BEE -> {
Expand Down

0 comments on commit 7c14c51

Please sign in to comment.