Formatting
All checks were successful
build / build (21) (push) Successful in 1m16s

This commit is contained in:
Soph :3 2024-09-13 21:10:03 +03:00
parent 2f5084010a
commit aa200b17c0
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
11 changed files with 91 additions and 57 deletions

View file

@ -29,7 +29,6 @@ import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class AnimalRP implements ModInitializer {
public static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
@ -40,6 +39,7 @@ public class AnimalRP implements ModInitializer {
public static final String MOD_ID = "animal-rp";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@Override
public void onInitialize() {
animals.put("cat", new Cat());
@ -47,10 +47,10 @@ public class AnimalRP implements ModInitializer {
animals.put("fox", new Fox());
animals.put("bee", new Bee());
HashmapStore.get("users.json").forEach((k,v) -> {
HashmapStore.get("users.json").forEach((k, v) -> {
users.put(UUID.fromString(k), animals.get(v));
});
HashmapStore.get("nochat.json").forEach((k,v) -> {
HashmapStore.get("nochat.json").forEach((k, v) -> {
noChat.put(UUID.fromString(k), Boolean.valueOf(v));
});
emotes = new Emote();
@ -61,9 +61,11 @@ public class AnimalRP implements ModInitializer {
if (!ctx.hasPlayer())
return PlaceholderResult.invalid("No player!");
Animal animal = users.get(ctx.player().getUuid());
if(animal == null)
if (animal == null)
return PlaceholderResult.value("");
return PlaceholderResult.value("<color "+animal.color+">");
if (noChat.get(ctx.player().getUuid()) != null)
return PlaceholderResult.value("");
return PlaceholderResult.value("<color " + animal.color + ">");
}
});
@ -72,12 +74,19 @@ public class AnimalRP implements ModInitializer {
(new NoChatCommand()).Command(dispatcher, registryAccess, environment);
(new EmoteCommand()).Command(dispatcher, registryAccess, environment);
(new InteractionCommand("headpats", Mood.HAPPY, "%s petted you! %s", "You petted %s! %s")).Command(dispatcher, registryAccess, environment);
(new InteractionCommand("kiss", Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s")).Command(dispatcher, registryAccess, environment);
(new InteractionCommand("bite", Mood.ANGRY, "%s bit you!! Σ(っ゚Д゚)っ %s", "You bit %s! (○`д´)ノシ %s")).Command(dispatcher, registryAccess, environment);
(new InteractionCommand("scratch", Mood.ANGRY, "%s SCRATCHES YOU! Ow! %s", "You channel your inner evil, and scratch %s! %s")).Command(dispatcher, registryAccess, environment);
(new InteractionCommand("hug", Mood.HAPPY, "%s hugs you! How heartwarming. %s", "You hug %s! How heartwarming. %s")).Command(dispatcher, registryAccess, environment);
(new InteractionCommand("cuddle", Mood.CUTE, "%s cuddles with you. %s", "You and %s start cuddling. How cute! %s")).Command(dispatcher, registryAccess, environment);
(new InteractionCommand("headpats", Mood.HAPPY, "%s petted you! %s", "You petted %s! %s"))
.Command(dispatcher, registryAccess, environment);
(new InteractionCommand("kiss", Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s"))
.Command(dispatcher, registryAccess, environment);
(new InteractionCommand("bite", Mood.ANGRY, "%s bit you!! Σ(っ゚Д゚)っ %s", "You bit %s! (○`д´)ノシ %s"))
.Command(dispatcher, registryAccess, environment);
(new InteractionCommand("scratch", Mood.ANGRY, "%s SCRATCHES YOU! Ow! %s",
"You channel your inner evil, and scratch %s! %s"))
.Command(dispatcher, registryAccess, environment);
(new InteractionCommand("hug", Mood.HAPPY, "%s hugs you! How heartwarming. %s",
"You hug %s! How heartwarming. %s")).Command(dispatcher, registryAccess, environment);
(new InteractionCommand("cuddle", Mood.CUTE, "%s cuddles with you. %s",
"You and %s start cuddling. How cute! %s")).Command(dispatcher, registryAccess, environment);
});
}
}

View file

@ -37,20 +37,22 @@ public class EmoteCommand {
try {
emote = Emotes.valueOf(arg.toUpperCase());
} catch(Exception e) {
} catch (Exception e) {
emote = null;
}
if(emote == null) {
if (emote == null) {
this.options(context.getSource());
return 0;
}
if(AnimalRP.emotes.isPlayerEmoting(player.getUuid())) {
context.getSource().sendFeedback(() -> Text.literal("<red>Stopped emoting.").withColor(8421504), false);
if (AnimalRP.emotes.isPlayerEmoting(player.getUuid())) {
context.getSource().sendFeedback(
() -> Text.literal("Stopped emoting.").withColor(8421504), false);
AnimalRP.emotes.stopEmote(player.getUuid());
} else {
context.getSource().sendFeedback(() -> Text.literal("<green>Emoting!").withColor(65280), false);
context.getSource().sendFeedback(() -> Text.literal("Emoting!").withColor(65280),
false);
AnimalRP.emotes.playEmote(player.getUuid(), context.getSource().getPlayer(), emote);
}
return 1;
@ -59,7 +61,15 @@ public class EmoteCommand {
@SuppressWarnings("deprecation")
private void options(ServerCommandSource player) {
player.sendFeedback(() -> TextParserUtils.formatText("<red>You have <green>" + String.join(", ", Emote.emotes.keySet().stream().map(Emote.Emotes::name).map(String::toLowerCase).collect(Collectors.toSet())) + "</green> as options."), false);
player.sendFeedback(
() -> TextParserUtils
.formatText(
"<red>You have <green>"
+ String.join(", ",
Emote.emotes.keySet().stream().map(Emote.Emotes::name)
.map(String::toLowerCase).collect(Collectors.toSet()))
+ "</green> as options."),
false);
}
}

View file

@ -48,7 +48,9 @@ public class InteractionCommand {
if (aplayer == null) {
context.getSource().sendFeedback(
() -> Text.literal("Only animals can interact with other animals :(").withColor(8421504), false);
() -> Text.literal("Only animals can interact with other animals :(")
.withColor(8421504),
false);
return 0;
}
@ -56,14 +58,18 @@ public class InteractionCommand {
if (splayer.getName() == player.getName()) {
context.getSource().sendFeedback(
() -> Text.literal("You can't " + this.command + " yourself.").withColor(8421504), false);
() -> Text.literal("You can't " + this.command + " yourself.")
.withColor(8421504),
false);
return 0;
}
Animal asplayer = AnimalRP.users.get(splayer.getUuid());
if (asplayer == null) {
context.getSource().sendFeedback(
() -> Text.literal(splayer.getName() + " is not an animal! :(").withColor(8421504), false);
() -> Text.literal(splayer.getName() + " is not an animal! :(")
.withColor(8421504),
false);
return 0;
}
@ -75,7 +81,8 @@ public class InteractionCommand {
String.format(this.toYou,
"<light_purple>" + splayer.getName().getString() + "</light_purple>",
"<italic><gray>" + asplayer.catchphrase)));
player.getWorld().playSound(splayer, splayer.getBlockPos(), asplayer.moodSounds.get(this.mood), SoundCategory.PLAYERS, 1F,
player.getWorld().playSound(splayer, splayer.getBlockPos(),
asplayer.moodSounds.get(this.mood), SoundCategory.PLAYERS, 1F,
1);
return 1;
})));

View file

@ -18,15 +18,19 @@ public class NoChatCommand {
UUID userUuid = context.getSource().getEntity().getUuid();
Boolean isDisabled = AnimalRP.noChat.get(context.getSource().getEntity().getUuid());
if(isDisabled == null) isDisabled = false;
if(isDisabled) { //
context.getSource().sendFeedback(() -> Text.literal("AnimalRP's chat modifications are now enabled for you.").withColor(65280), false);
if (isDisabled == null)
isDisabled = false;
if (isDisabled) { //
context.getSource().sendFeedback(
() -> Text.literal("AnimalRP's chat modifications are now enabled for you.").withColor(65280),
false);
AnimalRP.noChat.remove(userUuid);
} else {
context.getSource().sendFeedback(() -> Text.literal("AnimalRP's chat modifications are now disabled for you.").withColor(16711680), false);
context.getSource().sendFeedback(() -> Text
.literal("AnimalRP's chat modifications are now disabled for you.").withColor(16711680), false);
AnimalRP.noChat.put(userUuid, true);
}
HashmapStore.save("nochat.json", AnimalRP.noChat);
HashmapStore.save("nochat.json", AnimalRP.noChat);
return 0;
}));

View file

@ -27,7 +27,8 @@ public abstract class DecoratedMessage {
@ModifyVariable(method = "handleDecoratedMessage", at = @At(value = "HEAD"), argsOnly = true)
public @NotNull SignedMessage modifyChatMessageSentByPlayers(@NotNull SignedMessage original) {
if(AnimalRP.noChat.get(player.getUuid()) != null) return original;
if (AnimalRP.noChat.get(player.getUuid()) != null)
return original;
Animal animal = AnimalRP.users.get(player.getUuid());
if (animal == null)

View file

@ -22,14 +22,14 @@ public class FoodEating {
@Inject(method = "eatFood", at = @At("HEAD"))
public void eatFood(World world, ItemStack stack, FoodComponent foodComponent, CallbackInfoReturnable<?> cfr) {
LivingEntity entity = (LivingEntity) (Object) this;
if(entity.getType().equals(EntityType.PLAYER)) {
if (entity.getType().equals(EntityType.PLAYER)) {
ServerPlayerEntity player = (ServerPlayerEntity) entity;
Animal animal = AnimalRP.users.get(player.getUuid());
Animal animal = AnimalRP.users.get(player.getUuid());
if (animal != null) {
if(animal.name == "bee") {
((Bee)animal).onEat(player, stack);
if (animal != null) {
if (animal.name == "bee") {
((Bee) animal).onEat(player, stack);
}
if (animal.superfoods.contains(stack.getItem())) {
player.getHungerManager().add(4, 9.4f);

View file

@ -16,9 +16,9 @@ public class Sneaking {
@Inject(method = "setSneaking", at = @At("HEAD"))
public void setSneaking(boolean sneaking, CallbackInfo info) {
Entity entity = (Entity) (Object) this;
if(entity.getType() == EntityType.PLAYER) {
Bee bee = (Bee)AnimalRP.animals.get("bee");
bee.onSneak((ServerPlayerEntity)entity, sneaking);
if (entity.getType() == EntityType.PLAYER) {
Bee bee = (Bee) AnimalRP.animals.get("bee");
bee.onSneak((ServerPlayerEntity) entity, sneaking);
}
}
}

View file

@ -19,8 +19,8 @@ public class Emote {
ServerPlayerEntity entity;
Emotes emote;
PlayerEmote( ServerPlayerEntity entity,
Emotes emote) {
PlayerEmote(ServerPlayerEntity entity,
Emotes emote) {
this.entity = entity;
this.emote = emote;
}
@ -97,9 +97,10 @@ public class Emote {
List<Vec3d> locs = getEmoteLocs(player.getPos().subtract(0, player.isSneaking() ? .5 : 0, 0),
emotes.get(emote), player.getRotationVector());
for (Vec3d loc : locs) {
for(int i =0; i < 15; i ++) {
player.getWorld().addParticle(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f), loc.x,
loc.y, loc.z, 0, 0, 0);
for (int i = 0; i < 15; i++) {
player.getWorld().addParticle(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f),
loc.x,
loc.y, loc.z, 0, 0, 0);
}
}
}

View file

@ -1,5 +1,5 @@
package ovh.sad.animalrp.util;
public enum Mood {
HAPPY,SAD,STRESSED,ANGRY,CUTE
HAPPY, SAD, STRESSED, ANGRY, CUTE
}

View file

@ -20,23 +20,25 @@ public class TextDestroyer {
Random y = new Random();
for (String word : words) {
if((word.startsWith("[") && word.endsWith("]")) || word.startsWith("@")) {
if ((word.startsWith("[") && word.endsWith("]")) || word.startsWith("@")) {
out.add(word);
continue;
}
if(y.nextBoolean()){
if (y.nextBoolean()) {
out.add(word);
continue;
};
}
;
for(String[] replacing: this.replaces) {
for (String[] replacing : this.replaces) {
word = word.replace(replacing[0], replacing[1]);
}
out.add(word);
if(y.nextDouble() < 0.12) out.add(this.expressions[y.nextInt(this.expressions.length)]);
if (y.nextDouble() < 0.12)
out.add(this.expressions[y.nextInt(this.expressions.length)]);
}
return String.join(" ", out);