Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
2d19c77199 |
17 changed files with 62 additions and 193 deletions
|
@ -39,7 +39,7 @@ dependencies {
|
|||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation include("eu.pb4:placeholder-api:2.5.1+1.21.3")
|
||||
modImplementation include("eu.pb4:placeholder-api:2.4.1+1.21")
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
|
|
@ -4,14 +4,14 @@ org.gradle.parallel=true
|
|||
|
||||
# Fabric Properties
|
||||
# check these on https://fabricmc.net/develop
|
||||
minecraft_version=1.21.4
|
||||
yarn_mappings=1.21.4+build.7
|
||||
loader_version=0.16.9
|
||||
minecraft_version=1.21.1
|
||||
yarn_mappings=1.21.1+build.3
|
||||
loader_version=0.16.4
|
||||
|
||||
# Mod Properties
|
||||
mod_version=2.0.0
|
||||
mod_version=1.0.0
|
||||
maven_group=ovh.sad.animalrp
|
||||
archives_base_name=animal-rp
|
||||
|
||||
# Dependencies
|
||||
fabric_version=0.114.0+1.21.4
|
||||
fabric_version=0.103.0+1.21.1
|
||||
|
|
|
@ -2,7 +2,6 @@ package ovh.sad.animalrp;
|
|||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.minecraft.util.Identifier;
|
||||
import ovh.sad.animalrp.animals.Animal;
|
||||
import ovh.sad.animalrp.animals.Cat;
|
||||
|
@ -12,7 +11,6 @@ import ovh.sad.animalrp.animals.Bee;
|
|||
import ovh.sad.animalrp.commands.InteractionCommand;
|
||||
import ovh.sad.animalrp.commands.NoChatCommand;
|
||||
import ovh.sad.animalrp.commands.TfCommand;
|
||||
import ovh.sad.animalrp.util.HashmapStore;
|
||||
import ovh.sad.animalrp.util.Mood;
|
||||
import eu.pb4.placeholders.api.PlaceholderContext;
|
||||
import eu.pb4.placeholders.api.PlaceholderHandler;
|
||||
|
@ -28,6 +26,7 @@ import org.jetbrains.annotations.Nullable;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
public class AnimalRP implements ModInitializer {
|
||||
public static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
|
@ -37,42 +36,22 @@ 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() {
|
||||
|
||||
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));
|
||||
});
|
||||
|
||||
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+">");
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -80,26 +59,12 @@ ZZZzz /,`.-'`' -. ;-;;,_
|
|||
(new TfCommand()).Command(dispatcher, registryAccess, environment);
|
||||
(new NoChatCommand()).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("boop", Mood.CUTE, "%s boops your nose! %s", "You boop %s's nose! %s"))
|
||||
.Command(dispatcher, registryAccess, environment);
|
||||
(new InteractionCommand("nuzzle", Mood.CUTE, "%s nuzzles you! %s", "You nuzzle %s! %s"))
|
||||
.Command(dispatcher, registryAccess, environment);
|
||||
});
|
||||
ServerLifecycleEvents.SERVER_STOPPING.register((server) -> {
|
||||
executor.shutdownNow();
|
||||
(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;
|
||||
|
|
|
@ -11,21 +11,17 @@ import net.fabricmc.fabric.api.event.player.UseItemCallback;
|
|||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.ConsumableComponent;
|
||||
import net.minecraft.component.type.ConsumableComponents;
|
||||
import net.minecraft.component.type.FoodComponent;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.entity.effect.StatusEffects;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.item.consume.ApplyEffectsConsumeEffect;
|
||||
import net.minecraft.item.consume.ConsumeEffect;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.TypedActionResult;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
import ovh.sad.animalrp.util.Mood;
|
||||
import ovh.sad.animalrp.util.TextDestroyer;
|
||||
|
@ -80,10 +76,10 @@ public class Bee extends Animal {
|
|||
ItemStack item = player.getStackInHand(hand);
|
||||
|
||||
if (item == null) // air interact
|
||||
return ActionResult.PASS;
|
||||
return TypedActionResult.pass(item);
|
||||
|
||||
if (!allFlowers.contains(item.getItem())) { // not a flower
|
||||
return ActionResult.PASS;
|
||||
return TypedActionResult.pass(item);
|
||||
}
|
||||
|
||||
Boolean incorrect = false;
|
||||
|
@ -100,30 +96,25 @@ public class Bee extends Animal {
|
|||
if (Bee.isItemARP(item)) {
|
||||
item.remove(DataComponentTypes.FOOD);
|
||||
|
||||
return ActionResult.PASS;
|
||||
return TypedActionResult.pass(item);
|
||||
}
|
||||
return ActionResult.PASS;
|
||||
return TypedActionResult.pass(item);
|
||||
}
|
||||
|
||||
if (Bee.isItemARP(item)) { // correct animal, but foodkey already set
|
||||
return ActionResult.PASS;
|
||||
return TypedActionResult.pass(item);
|
||||
}
|
||||
|
||||
|
||||
FoodComponent food = new FoodComponent.Builder()
|
||||
.statusEffect(new StatusEffectInstance(StatusEffects.SPEED, 20 * 4, 1, true, true, true), 1)
|
||||
.alwaysEdible()
|
||||
.nutrition(4)
|
||||
.saturationModifier(9.4f)
|
||||
.build();
|
||||
|
||||
ConsumableComponent consumable = ConsumableComponents.food()
|
||||
.consumeEffect(new ApplyEffectsConsumeEffect(new StatusEffectInstance(StatusEffects.SPEED, 20 * 4, 1, true, true, true)))
|
||||
.build();
|
||||
|
||||
item.set(DataComponentTypes.FOOD, food);
|
||||
item.set(DataComponentTypes.CONSUMABLE, consumable);
|
||||
|
||||
return ActionResult.PASS;
|
||||
return TypedActionResult.pass(item);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@ package ovh.sad.animalrp.animals;
|
|||
import java.util.Random;
|
||||
|
||||
import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.sound.SoundEvents;
|
||||
import ovh.sad.animalrp.AnimalRP;
|
||||
import ovh.sad.animalrp.util.Mood;
|
||||
|
@ -45,7 +44,7 @@ public class Fox extends Animal {
|
|||
if(!(source.getSource() instanceof ServerPlayerEntity)) return;
|
||||
if(entity instanceof PlayerEntity) return;
|
||||
|
||||
LivingEntity victim = entity;
|
||||
Entity victim = entity;
|
||||
ServerPlayerEntity damager = (ServerPlayerEntity) source.getSource();
|
||||
|
||||
Animal animal = AnimalRP.users.get(damager.getUuid());
|
||||
|
@ -54,7 +53,7 @@ public class Fox extends Animal {
|
|||
return;
|
||||
}
|
||||
|
||||
victim.damage((ServerWorld)victim.getWorld(), victim.getDamageSources().playerAttack(damager), dmg * 0.25F);
|
||||
victim.damage(victim.getDamageSources().playerAttack(damager), dmg * 0.25F);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
@ -36,7 +37,6 @@ public class TfCommand {
|
|||
AnimalRP.users.remove(entity.getUuid());
|
||||
context.getSource().sendFeedback(
|
||||
() -> Text.literal("You no longer have a animal set."), false);
|
||||
HashmapStore.save("users.json", AnimalRP.users);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,6 @@ public class TfCommand {
|
|||
Integer.parseInt(animal.color.substring(1),
|
||||
16))),
|
||||
false);
|
||||
HashmapStore.save("users.json", AnimalRP.users);
|
||||
return 1;
|
||||
})));
|
||||
}
|
||||
|
|
|
@ -27,9 +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)
|
||||
return original;
|
||||
|
@ -37,7 +36,7 @@ public abstract class DecoratedMessage {
|
|||
player.getWorld().playSound(player, player.getBlockPos(),
|
||||
animal.moodSounds.get(Mood.HAPPY), SoundCategory.PLAYERS, 10F, 1);
|
||||
}
|
||||
|
||||
|
||||
return original
|
||||
.withUnsignedContent(Text.literal(animal.chatTransformations(original.getContent().getString())));
|
||||
}
|
||||
|
|
|
@ -18,18 +18,18 @@ import ovh.sad.animalrp.animals.Animal;
|
|||
import ovh.sad.animalrp.animals.Bee;
|
||||
|
||||
@Mixin(value = LivingEntity.class)
|
||||
public class FoodEating {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ public class Cooldown {
|
|||
public long getTime() {
|
||||
return this.timeCreated - (System.currentTimeMillis() - this.length);
|
||||
}
|
||||
|
||||
|
||||
public boolean isExpired() {
|
||||
return this.getTime() <= 0;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
"id": "animal-rp",
|
||||
"version": "${version}",
|
||||
"name": "Animal RP",
|
||||
"description": "furry minecraft mod",
|
||||
"description": "This is an example description! Tell everyone what your mod is about!",
|
||||
"authors": [
|
||||
"sophie"
|
||||
"Me!"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://sad.ovh",
|
||||
"sources": "https://git.sad.ovh/sophie/animalrpfabric"
|
||||
"homepage": "https://fabricmc.net/",
|
||||
"sources": "https://github.com/FabricMC/fabric-example-mod"
|
||||
},
|
||||
"license": "CC0-1.0",
|
||||
"icon": "assets/animal-rp/icon.png",
|
||||
|
@ -24,7 +24,7 @@
|
|||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.16.4",
|
||||
"minecraft": "~1.21.4",
|
||||
"minecraft": "~1.21.1",
|
||||
"java": ">=21",
|
||||
"fabric-api": "*"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue