Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
Soph :3 | 4c09e501b4 | ||
Soph :3 | d12c3e5769 | ||
Soph :3 | 6898039c61 | ||
Soph :3 | aa200b17c0 | ||
Soph :3 | 2f5084010a |
|
@ -13,6 +13,7 @@ import ovh.sad.animalrp.commands.InteractionCommand;
|
||||||
import ovh.sad.animalrp.commands.NoChatCommand;
|
import ovh.sad.animalrp.commands.NoChatCommand;
|
||||||
import ovh.sad.animalrp.commands.TfCommand;
|
import ovh.sad.animalrp.commands.TfCommand;
|
||||||
import ovh.sad.animalrp.util.Emote;
|
import ovh.sad.animalrp.util.Emote;
|
||||||
|
import ovh.sad.animalrp.util.HashmapStore;
|
||||||
import ovh.sad.animalrp.util.Mood;
|
import ovh.sad.animalrp.util.Mood;
|
||||||
import eu.pb4.placeholders.api.PlaceholderContext;
|
import eu.pb4.placeholders.api.PlaceholderContext;
|
||||||
import eu.pb4.placeholders.api.PlaceholderHandler;
|
import eu.pb4.placeholders.api.PlaceholderHandler;
|
||||||
|
@ -28,7 +29,6 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
public class AnimalRP implements ModInitializer {
|
public class AnimalRP implements ModInitializer {
|
||||||
public static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
public static ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
|
||||||
|
|
||||||
|
@ -39,12 +39,30 @@ public class AnimalRP implements ModInitializer {
|
||||||
|
|
||||||
public static final String MOD_ID = "animal-rp";
|
public static final String MOD_ID = "animal-rp";
|
||||||
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
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("cat", new Cat());
|
||||||
animals.put("dog", new Dog());
|
animals.put("dog", new Dog());
|
||||||
animals.put("fox", new Fox());
|
animals.put("fox", new Fox());
|
||||||
animals.put("bee", new Bee());
|
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();
|
emotes = new Emote();
|
||||||
|
|
||||||
Placeholders.register(Identifier.of("animalrp", "animalcolor"), new PlaceholderHandler() {
|
Placeholders.register(Identifier.of("animalrp", "animalcolor"), new PlaceholderHandler() {
|
||||||
|
@ -55,7 +73,9 @@ public class AnimalRP implements ModInitializer {
|
||||||
Animal animal = users.get(ctx.player().getUuid());
|
Animal animal = users.get(ctx.player().getUuid());
|
||||||
if (animal == null)
|
if (animal == null)
|
||||||
return PlaceholderResult.value("");
|
return PlaceholderResult.value("");
|
||||||
return PlaceholderResult.value("<color "+animal.color+">");
|
if (noChat.get(ctx.player().getUuid()) != null)
|
||||||
|
return PlaceholderResult.value("");
|
||||||
|
return PlaceholderResult.value(animal.color);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -64,12 +84,19 @@ public class AnimalRP implements ModInitializer {
|
||||||
(new NoChatCommand()).Command(dispatcher, registryAccess, environment);
|
(new NoChatCommand()).Command(dispatcher, registryAccess, environment);
|
||||||
(new EmoteCommand()).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("headpats", Mood.HAPPY, "%s petted you! %s", "You petted %s! %s"))
|
||||||
(new InteractionCommand("kiss", Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s")).Command(dispatcher, registryAccess, environment);
|
.Command(dispatcher, registryAccess, environment);
|
||||||
(new InteractionCommand("bite", Mood.ANGRY, "%s bit you!! Σ(っ゚Д゚)っ %s", "You bit %s! (○`д´)ノシ %s")).Command(dispatcher, registryAccess, environment);
|
(new InteractionCommand("kiss", Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s"))
|
||||||
(new InteractionCommand("scratch", Mood.ANGRY, "%s SCRATCHES YOU! Ow! %s", "You channel your inner evil, and scratch %s! %s")).Command(dispatcher, registryAccess, environment);
|
.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("bite", Mood.ANGRY, "%s bit you!! Σ(っ゚Д゚)っ %s", "You bit %s! (○`д´)ノシ %s"))
|
||||||
(new InteractionCommand("cuddle", Mood.CUTE, "%s cuddles with you. %s", "You and %s start cuddling. How cute! %s")).Command(dispatcher, registryAccess, environment);
|
.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,6 +14,10 @@ public abstract class Animal {
|
||||||
public HashMap<Mood, SoundEvent> moodSounds = new HashMap<Mood, SoundEvent>();
|
public HashMap<Mood, SoundEvent> moodSounds = new HashMap<Mood, SoundEvent>();
|
||||||
public ArrayList<Item> superfoods = new ArrayList<Item>();
|
public ArrayList<Item> superfoods = new ArrayList<Item>();
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
Animal(String name, String catchphrase, String color) {
|
Animal(String name, String catchphrase, String color) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.catchphrase = catchphrase;
|
this.catchphrase = catchphrase;
|
||||||
|
|
|
@ -47,10 +47,12 @@ public class EmoteCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AnimalRP.emotes.isPlayerEmoting(player.getUuid())) {
|
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());
|
AnimalRP.emotes.stopEmote(player.getUuid());
|
||||||
} else {
|
} 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);
|
AnimalRP.emotes.playEmote(player.getUuid(), context.getSource().getPlayer(), emote);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -59,7 +61,15 @@ public class EmoteCommand {
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private void options(ServerCommandSource player) {
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -48,7 +48,9 @@ public class InteractionCommand {
|
||||||
|
|
||||||
if (aplayer == null) {
|
if (aplayer == null) {
|
||||||
context.getSource().sendFeedback(
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,14 +58,18 @@ public class InteractionCommand {
|
||||||
|
|
||||||
if (splayer.getName() == player.getName()) {
|
if (splayer.getName() == player.getName()) {
|
||||||
context.getSource().sendFeedback(
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
Animal asplayer = AnimalRP.users.get(splayer.getUuid());
|
Animal asplayer = AnimalRP.users.get(splayer.getUuid());
|
||||||
|
|
||||||
if (asplayer == null) {
|
if (asplayer == null) {
|
||||||
context.getSource().sendFeedback(
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +81,8 @@ public class InteractionCommand {
|
||||||
String.format(this.toYou,
|
String.format(this.toYou,
|
||||||
"<light_purple>" + splayer.getName().getString() + "</light_purple>",
|
"<light_purple>" + splayer.getName().getString() + "</light_purple>",
|
||||||
"<italic><gray>" + asplayer.catchphrase)));
|
"<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);
|
1);
|
||||||
return 1;
|
return 1;
|
||||||
})));
|
})));
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import ovh.sad.animalrp.AnimalRP;
|
import ovh.sad.animalrp.AnimalRP;
|
||||||
|
import ovh.sad.animalrp.util.HashmapStore;
|
||||||
|
|
||||||
public class NoChatCommand {
|
public class NoChatCommand {
|
||||||
public void Command(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess,
|
public void Command(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess,
|
||||||
|
@ -17,14 +18,19 @@ public class NoChatCommand {
|
||||||
UUID userUuid = context.getSource().getEntity().getUuid();
|
UUID userUuid = context.getSource().getEntity().getUuid();
|
||||||
|
|
||||||
Boolean isDisabled = AnimalRP.noChat.get(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) { //
|
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);
|
AnimalRP.noChat.remove(userUuid);
|
||||||
} else {
|
} 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);
|
AnimalRP.noChat.put(userUuid, true);
|
||||||
}
|
}
|
||||||
|
HashmapStore.save("nochat.json", AnimalRP.noChat);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -14,6 +14,7 @@ import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import ovh.sad.animalrp.AnimalRP;
|
import ovh.sad.animalrp.AnimalRP;
|
||||||
import ovh.sad.animalrp.animals.Animal;
|
import ovh.sad.animalrp.animals.Animal;
|
||||||
|
import ovh.sad.animalrp.util.HashmapStore;
|
||||||
|
|
||||||
public class TfCommand {
|
public class TfCommand {
|
||||||
public void Command(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess,
|
public void Command(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess registryAccess,
|
||||||
|
@ -23,8 +24,6 @@ public class TfCommand {
|
||||||
.executes(context -> {
|
.executes(context -> {
|
||||||
final Entity entity = context.getSource().getEntity();
|
final Entity entity = context.getSource().getEntity();
|
||||||
final String animalString = StringArgumentType.getString(context, "animal");
|
final String animalString = StringArgumentType.getString(context, "animal");
|
||||||
System.out.println(animalString);
|
|
||||||
System.out.println(animalString.length());
|
|
||||||
|
|
||||||
Animal animal = AnimalRP.animals.get(animalString);
|
Animal animal = AnimalRP.animals.get(animalString);
|
||||||
|
|
||||||
|
@ -54,6 +53,7 @@ public class TfCommand {
|
||||||
Integer.parseInt(animal.color.substring(1),
|
Integer.parseInt(animal.color.substring(1),
|
||||||
16))),
|
16))),
|
||||||
false);
|
false);
|
||||||
|
HashmapStore.save("users.json", AnimalRP.users);
|
||||||
return 1;
|
return 1;
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@ public abstract class DecoratedMessage {
|
||||||
|
|
||||||
@ModifyVariable(method = "handleDecoratedMessage", at = @At(value = "HEAD"), argsOnly = true)
|
@ModifyVariable(method = "handleDecoratedMessage", at = @At(value = "HEAD"), argsOnly = true)
|
||||||
public @NotNull SignedMessage modifyChatMessageSentByPlayers(@NotNull SignedMessage original) {
|
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());
|
Animal animal = AnimalRP.users.get(player.getUuid());
|
||||||
if (animal == null)
|
if (animal == null)
|
||||||
|
|
|
@ -97,10 +97,8 @@ public class Emote {
|
||||||
List<Vec3d> locs = getEmoteLocs(player.getPos().subtract(0, player.isSneaking() ? .5 : 0, 0),
|
List<Vec3d> locs = getEmoteLocs(player.getPos().subtract(0, player.isSneaking() ? .5 : 0, 0),
|
||||||
emotes.get(emote), player.getRotationVector());
|
emotes.get(emote), player.getRotationVector());
|
||||||
for (Vec3d loc : locs) {
|
for (Vec3d loc : locs) {
|
||||||
for(int i =0; i < 15; i ++) {
|
player.getServerWorld().spawnParticles(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f),
|
||||||
player.getWorld().addParticle(new DustParticleEffect(Vec3d.unpackRgb(16777215).toVector3f(), 0.5f), loc.x,
|
loc.x, loc.y, loc.z, 15, 0, 0, 0, 0);
|
||||||
loc.y, loc.z, 0, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +113,7 @@ public class Emote {
|
||||||
float y2 = (float) y / ((float) distance / 2);
|
float y2 = (float) y / ((float) distance / 2);
|
||||||
float side = (((float) emoteTextLine.get(x) / distance) - ((float) ttEmote[0].length()) / 2 / distance);
|
float side = (((float) emoteTextLine.get(x) / distance) - ((float) ttEmote[0].length()) / 2 / distance);
|
||||||
Vec3d idfk = rotationLoc.normalize();
|
Vec3d idfk = rotationLoc.normalize();
|
||||||
Vec3d rotation = new Vec3d(idfk.x, 0, idfk.y);
|
Vec3d rotation = new Vec3d(idfk.x, 0, idfk.z);
|
||||||
Vec3d rot = rotation.crossProduct(new Vec3d(0, side, 0));
|
Vec3d rot = rotation.crossProduct(new Vec3d(0, side, 0));
|
||||||
Vec3d addLoc = loc.add(rot);
|
Vec3d addLoc = loc.add(rot);
|
||||||
Vec3d newAloc = new Vec3d(addLoc.x, loc.getY() + ((float) ttEmote.length / distance - y2 + 2.25),
|
Vec3d newAloc = new Vec3d(addLoc.x, loc.getY() + ((float) ttEmote.length / distance - y2 + 2.25),
|
||||||
|
@ -149,7 +147,6 @@ public class Emote {
|
||||||
|
|
||||||
public void playEmote(UUID uuid, ServerPlayerEntity entity, Emotes emote) {
|
public void playEmote(UUID uuid, ServerPlayerEntity entity, Emotes emote) {
|
||||||
this.players.put(uuid, new PlayerEmote(entity, emote));
|
this.players.put(uuid, new PlayerEmote(entity, emote));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopEmote(UUID uuid) {
|
public void stopEmote(UUID uuid) {
|
||||||
|
|
65
src/main/java/ovh/sad/animalrp/util/HashmapStore.java
Normal file
65
src/main/java/ovh/sad/animalrp/util/HashmapStore.java
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,7 +28,8 @@ public class TextDestroyer {
|
||||||
if (y.nextBoolean()) {
|
if (y.nextBoolean()) {
|
||||||
out.add(word);
|
out.add(word);
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
|
|
||||||
for (String[] replacing : this.replaces) {
|
for (String[] replacing : this.replaces) {
|
||||||
word = word.replace(replacing[0], replacing[1]);
|
word = word.replace(replacing[0], replacing[1]);
|
||||||
|
@ -36,7 +37,8 @@ public class TextDestroyer {
|
||||||
|
|
||||||
out.add(word);
|
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);
|
return String.join(" ", out);
|
||||||
|
|
Loading…
Reference in a new issue