Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
Soph :3 | 2d19c77199 |
|
@ -8,12 +8,9 @@ import ovh.sad.animalrp.animals.Cat;
|
|||
import ovh.sad.animalrp.animals.Dog;
|
||||
import ovh.sad.animalrp.animals.Fox;
|
||||
import ovh.sad.animalrp.animals.Bee;
|
||||
import ovh.sad.animalrp.commands.EmoteCommand;
|
||||
import ovh.sad.animalrp.commands.InteractionCommand;
|
||||
import ovh.sad.animalrp.commands.NoChatCommand;
|
||||
import ovh.sad.animalrp.commands.TfCommand;
|
||||
import ovh.sad.animalrp.util.Emote;
|
||||
import ovh.sad.animalrp.util.HashmapStore;
|
||||
import ovh.sad.animalrp.util.Mood;
|
||||
import eu.pb4.placeholders.api.PlaceholderContext;
|
||||
import eu.pb4.placeholders.api.PlaceholderHandler;
|
||||
|
@ -29,74 +26,45 @@ import org.jetbrains.annotations.Nullable;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class AnimalRP implements ModInitializer {
|
||||
public static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
public static HashMap<UUID, Animal> users = new HashMap<>();
|
||||
public static HashMap<UUID, Boolean> noChat = new HashMap<>();
|
||||
public static HashMap<String, Animal> animals = new HashMap<>();
|
||||
public static Emote emotes;
|
||||
|
||||
public static final String MOD_ID = "animal-rp";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
|
||||
String catAscii = """
|
||||
|\\ _,,,---,,_
|
||||
ZZZzz /,`.-'`' -. ;-;;,_
|
||||
|,4- ) )-,_. ,\\ ( `'-'
|
||||
'---''(_/--' `-'\\_)
|
||||
""";
|
||||
LOGGER.info(catAscii);
|
||||
LOGGER.info("furry animal mod for fabric");
|
||||
LOGGER.info("by @fucksophie - est. Sept 2024");
|
||||
animals.put("cat", new Cat());
|
||||
animals.put("dog", new Dog());
|
||||
animals.put("fox", new Fox());
|
||||
animals.put("bee", new Bee());
|
||||
|
||||
HashmapStore.get("users.json").forEach((k, v) -> {
|
||||
users.put(UUID.fromString(k), animals.get(v));
|
||||
});
|
||||
HashmapStore.get("nochat.json").forEach((k, v) -> {
|
||||
noChat.put(UUID.fromString(k), Boolean.valueOf(v));
|
||||
});
|
||||
emotes = new Emote();
|
||||
|
||||
Placeholders.register(Identifier.of("animalrp", "animalcolor"), new PlaceholderHandler() {
|
||||
@Override
|
||||
public PlaceholderResult onPlaceholderRequest(PlaceholderContext ctx, @Nullable String arg) {
|
||||
if (!ctx.hasPlayer())
|
||||
return PlaceholderResult.invalid("No player!");
|
||||
Animal animal = users.get(ctx.player().getUuid());
|
||||
if (animal == null)
|
||||
if(animal == null)
|
||||
return PlaceholderResult.value("");
|
||||
if (noChat.get(ctx.player().getUuid()) != null)
|
||||
return PlaceholderResult.value("");
|
||||
return PlaceholderResult.value(animal.color);
|
||||
return PlaceholderResult.value("<color "+animal.color+">");
|
||||
}
|
||||
});
|
||||
|
||||
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> {
|
||||
(new TfCommand()).Command(dispatcher, registryAccess, environment);
|
||||
(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);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -14,10 +14,6 @@ public abstract class Animal {
|
|||
public HashMap<Mood, SoundEvent> moodSounds = new HashMap<Mood, SoundEvent>();
|
||||
public ArrayList<Item> superfoods = new ArrayList<Item>();
|
||||
|
||||
public String toString() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
Animal(String name, String catchphrase, String color) {
|
||||
this.name = name;
|
||||
this.catchphrase = catchphrase;
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
package ovh.sad.animalrp.commands;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
|
||||
import eu.pb4.placeholders.api.TextParserUtils;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
import ovh.sad.animalrp.util.Emote;
|
||||
import ovh.sad.animalrp.util.Emote.Emotes;
|
||||
|
||||
public class EmoteCommand {
|
||||
public void Command(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess,
|
||||
CommandManager.RegistrationEnvironment environment) {
|
||||
dispatcher.register(CommandManager.literal("emote")
|
||||
.then(CommandManager.argument("emote", StringArgumentType.string())
|
||||
.executes((context) -> {
|
||||
Entity sender = context.getSource().getEntity();
|
||||
final String arg = StringArgumentType.getString(context, "emote");
|
||||
|
||||
if (!(sender instanceof ServerPlayerEntity)) {
|
||||
context.getSource().sendFeedback(
|
||||
() -> Text.literal("I'm sorry console.").withColor(8421504), false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ServerPlayerEntity player = context.getSource().getPlayer();
|
||||
|
||||
Emote.Emotes emote;
|
||||
|
||||
try {
|
||||
emote = Emotes.valueOf(arg.toUpperCase());
|
||||
} catch (Exception e) {
|
||||
emote = null;
|
||||
}
|
||||
|
||||
if (emote == null) {
|
||||
this.options(context.getSource());
|
||||
return 0;
|
||||
}
|
||||
|
||||
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("Emoting!").withColor(65280),
|
||||
false);
|
||||
AnimalRP.emotes.playEmote(player.getUuid(), context.getSource().getPlayer(), emote);
|
||||
}
|
||||
return 1;
|
||||
})));
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
|
@ -48,9 +48,7 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -58,18 +56,14 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -81,8 +75,7 @@ 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;
|
||||
})));
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.minecraft.server.command.CommandManager;
|
|||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.Text;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
import ovh.sad.animalrp.util.HashmapStore;
|
||||
|
||||
public class NoChatCommand {
|
||||
public void Command(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess,
|
||||
|
@ -18,19 +17,14 @@ 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);
|
||||
|
||||
return 0;
|
||||
}));
|
||||
|
|
|
@ -14,7 +14,6 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.Formatting;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
import ovh.sad.animalrp.animals.Animal;
|
||||
import ovh.sad.animalrp.util.HashmapStore;
|
||||
|
||||
public class TfCommand {
|
||||
public void Command(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess,
|
||||
|
@ -24,6 +23,8 @@ public class TfCommand {
|
|||
.executes(context -> {
|
||||
final Entity entity = context.getSource().getEntity();
|
||||
final String animalString = StringArgumentType.getString(context, "animal");
|
||||
System.out.println(animalString);
|
||||
System.out.println(animalString.length());
|
||||
|
||||
Animal animal = AnimalRP.animals.get(animalString);
|
||||
|
||||
|
@ -53,7 +54,6 @@ public class TfCommand {
|
|||
Integer.parseInt(animal.color.substring(1),
|
||||
16))),
|
||||
false);
|
||||
HashmapStore.save("users.json", AnimalRP.users);
|
||||
return 1;
|
||||
})));
|
||||
}
|
||||
|
|
|
@ -27,8 +27,7 @@ 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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,159 +0,0 @@
|
|||
package ovh.sad.animalrp.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.minecraft.particle.DustParticleEffect;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
|
||||
public class Emote {
|
||||
class PlayerEmote {
|
||||
ServerPlayerEntity entity;
|
||||
Emotes emote;
|
||||
|
||||
PlayerEmote(ServerPlayerEntity entity,
|
||||
Emotes emote) {
|
||||
this.entity = entity;
|
||||
this.emote = emote;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Emotes {
|
||||
HAPPY, UWU, RAWR, LOVE, RAWR2, HAPPY2
|
||||
}
|
||||
|
||||
public static HashMap<Emotes, String[]> emotes = new HashMap<Emotes, String[]>();
|
||||
private HashMap<UUID, PlayerEmote> players = new HashMap<UUID, PlayerEmote>();
|
||||
{
|
||||
emotes.put(Emotes.HAPPY, new String[] { // Emote by PotionOfHarming!
|
||||
"0010000000100",
|
||||
"0101000001010",
|
||||
"0000000000000",
|
||||
"0000011100000"
|
||||
});
|
||||
emotes.put(Emotes.UWU, new String[] {
|
||||
"0101000001010",
|
||||
"0010000000100",
|
||||
"0000000000000",
|
||||
"0000011100000"
|
||||
});
|
||||
|
||||
emotes.put(Emotes.RAWR, new String[] {
|
||||
"0000100",
|
||||
"0100010",
|
||||
"0000100",
|
||||
"0100010",
|
||||
"0000100",
|
||||
});
|
||||
emotes.put(Emotes.RAWR2, new String[] {
|
||||
"001000000010",
|
||||
"010100000101",
|
||||
"001000000010",
|
||||
"000010101000",
|
||||
"000001010000",
|
||||
});
|
||||
emotes.put(Emotes.LOVE, new String[] {
|
||||
"0001001000",
|
||||
"0010000100",
|
||||
"0100001000",
|
||||
"0010000100",
|
||||
"0001001000",
|
||||
});
|
||||
emotes.put(Emotes.HAPPY2, new String[] {
|
||||
"010011100",
|
||||
"000010010",
|
||||
"000010010",
|
||||
"010011100"
|
||||
});
|
||||
}
|
||||
|
||||
public Emote() {
|
||||
AnimalRP.executor.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Set<Entry<UUID, PlayerEmote>> playerset = players.entrySet();
|
||||
|
||||
for (Iterator<Entry<UUID, PlayerEmote>> iterator = playerset.iterator(); iterator.hasNext();) {
|
||||
Entry<UUID, PlayerEmote> value = iterator.next();
|
||||
if (value.getValue().entity.isDisconnected()) {
|
||||
iterator.remove();
|
||||
} else {
|
||||
drawEmote(value.getValue().entity, value.getValue().emote);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, 250, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void drawEmote(ServerPlayerEntity player, Emotes emote) {
|
||||
List<Vec3d> locs = getEmoteLocs(player.getPos().subtract(0, player.isSneaking() ? .5 : 0, 0),
|
||||
emotes.get(emote), player.getRotationVector());
|
||||
for (Vec3d loc : locs) {
|
||||
player.getServerWorld().spawnParticles(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f),
|
||||
loc.x, loc.y, loc.z, 15, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<Vec3d> getEmoteLocs(Vec3d loc, String[] ttEmote, Vec3d rotationLoc) {
|
||||
List<List<Vec3d>> locations = new ArrayList<>();
|
||||
int y = 0;
|
||||
int distance = 10;
|
||||
for (String s : ttEmote) {
|
||||
List<Integer> emoteTextLine = textToEmote(s);
|
||||
List<Vec3d> addLocs = new ArrayList<>();
|
||||
for (int x = 0; x < emoteTextLine.size(); x++) {
|
||||
float y2 = (float) y / ((float) distance / 2);
|
||||
float side = (((float) emoteTextLine.get(x) / distance) - ((float) ttEmote[0].length()) / 2 / distance);
|
||||
Vec3d idfk = rotationLoc.normalize();
|
||||
Vec3d rotation = new Vec3d(idfk.x, 0, idfk.z);
|
||||
Vec3d rot = rotation.crossProduct(new Vec3d(0, side, 0));
|
||||
Vec3d addLoc = loc.add(rot);
|
||||
Vec3d newAloc = new Vec3d(addLoc.x, loc.getY() + ((float) ttEmote.length / distance - y2 + 2.25),
|
||||
addLoc.y);
|
||||
addLocs.add(newAloc);
|
||||
}
|
||||
locations.add(addLocs);
|
||||
y++;
|
||||
}
|
||||
|
||||
List<Vec3d> locs = new ArrayList<>();
|
||||
|
||||
for (List<Vec3d> listLocs : locations) {
|
||||
locs.addAll(listLocs);
|
||||
}
|
||||
|
||||
return locs;
|
||||
}
|
||||
|
||||
private static List<Integer> textToEmote(String textToEmote) {
|
||||
List<Integer> locs = new ArrayList<>();
|
||||
for (int i = 0; i < textToEmote.length(); i++) {
|
||||
char l = textToEmote.charAt(i);
|
||||
String letter = String.valueOf(l);
|
||||
if (letter.equals("1")) {
|
||||
locs.add(i);
|
||||
}
|
||||
}
|
||||
return locs;
|
||||
}
|
||||
|
||||
public void playEmote(UUID uuid, ServerPlayerEntity entity, Emotes emote) {
|
||||
this.players.put(uuid, new PlayerEmote(entity, emote));
|
||||
}
|
||||
|
||||
public void stopEmote(UUID uuid) {
|
||||
this.players.remove(uuid);
|
||||
}
|
||||
|
||||
public boolean isPlayerEmoting(UUID uuid) {
|
||||
return this.players.containsKey(uuid);
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package ovh.sad.animalrp.util;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonIOException;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
|
||||
public class HashmapStore {
|
||||
static public Gson gson = new Gson();
|
||||
static public Path folder = FabricLoader.getInstance().getConfigDir().resolve(AnimalRP.MOD_ID).toAbsolutePath();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static public HashMap<String, String> get(String name) {
|
||||
Path filePath = folder.resolve(name);
|
||||
if (!Files.exists(filePath)) {
|
||||
return new HashMap<String, String>();
|
||||
}
|
||||
try {
|
||||
return gson.fromJson(new FileReader(filePath.toString()), HashMap.class);
|
||||
} catch (JsonSyntaxException | JsonIOException | FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return new HashMap<String, String>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static public void save(String name, @SuppressWarnings("rawtypes") HashMap hashmap) {
|
||||
if (!Files.exists(folder)) {
|
||||
try {
|
||||
Files.createDirectory(folder);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Path filePath = folder.resolve(name);
|
||||
if (!Files.exists(filePath))
|
||||
try {
|
||||
Files.createFile(filePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JsonObject jsobj = new JsonObject();
|
||||
hashmap.forEach((a, b) -> {
|
||||
jsobj.addProperty(a.toString(), b.toString());
|
||||
});
|
||||
|
||||
try {
|
||||
Files.write(filePath, gson.toJson(jsobj).getBytes());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
package ovh.sad.animalrp.util;
|
||||
|
||||
public enum Mood {
|
||||
HAPPY, SAD, STRESSED, ANGRY, CUTE
|
||||
HAPPY,SAD,STRESSED,ANGRY,CUTE
|
||||
}
|
|
@ -20,25 +20,23 @@ 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);
|
||||
|
|
Loading…
Reference in a new issue