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());
@ -63,6 +63,8 @@ public class AnimalRP implements ModInitializer {
Animal animal = users.get(ctx.player().getUuid());
if (animal == null)
return PlaceholderResult.value("");
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

@ -47,10 +47,12 @@ public class EmoteCommand {
}
if (AnimalRP.emotes.isPlayerEmoting(player.getUuid())) {
context.getSource().sendFeedback(() -> Text.literal("<red>Stopped emoting.").withColor(8421504), false);
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,12 +18,16 @@ 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 == null)
isDisabled = false;
if (isDisabled) { //
context.getSource().sendFeedback(() -> Text.literal("AnimalRP's chat modifications are now enabled for you.").withColor(65280), false);
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);

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

@ -98,7 +98,8 @@ public class Emote {
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,
player.getWorld().addParticle(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f),
loc.x,
loc.y, loc.z, 0, 0, 0);
}
}

View file

@ -28,7 +28,8 @@ public class TextDestroyer {
if (y.nextBoolean()) {
out.add(word);
continue;
};
}
;
for (String[] replacing : this.replaces) {
word = word.replace(replacing[0], replacing[1]);
@ -36,7 +37,8 @@ public class TextDestroyer {
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);