lv.pi -> ovh.sad, remove fox superfood, add bee flower eating and fatigue, fix buggy bee levitation (water height)
All checks were successful
/ build (push) Successful in 43s

This commit is contained in:
Soph :3 2024-07-10 14:07:24 +03:00
parent 86538da090
commit e983626b9a
Signed by: sophie
GPG key ID: EDA5D222A0C270F2
23 changed files with 274 additions and 156 deletions

View file

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lv.pi.animalrp</groupId>
<groupId>ovh.sad.animalrp</groupId>
<artifactId>animalrp</artifactId>
<version>1.0.0</version>

View file

@ -1,82 +0,0 @@
package lv.pi.animalrp.animals;
import java.util.ArrayList;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.util.Mood;
import lv.pi.animalrp.util.TextDestroyer;
public class Bee extends Animal {
TextDestroyer destroyer = new TextDestroyer(new String[]{
">_<", "*buzz*",
";3", ":3", "εწз", " ≧◠◡◠≦ ", "*stings you*", "*humms*",
"*i'm a bee*"
}, new String[][]{
{"e", "ee"},
{"b", "bzz"},
{"h", "hh"},
{"ie", "ee"},
{"be", "bee"},
{"E", "EE"},
{"B", "BZZ"},
{"H", "HH"},
{"IE", "EE"},
{"BE", "BEE"}
});
ArrayList<UUID> sneakers = new ArrayList<UUID>();
public Bee() {
super("bee", "Buzz...", "#FFFF00");
this.moodSounds.put(Mood.HAPPY, Sound.ENTITY_BEE_LOOP);
this.moodSounds.put(Mood.CUTE, Sound.ENTITY_BEE_LOOP);
this.moodSounds.put(Mood.SAD, Sound.ENTITY_BEE_HURT);
this.moodSounds.put(Mood.STRESSED, Sound.ENTITY_BEE_STING);
this.moodSounds.put(Mood.ANGRY, Sound.ENTITY_BEE_LOOP_AGGRESSIVE);
this.superfoods.add(Material.HONEY_BOTTLE);
this.superfoods.add(Material.CHORUS_FLOWER);
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event) {
Animal animal = AnimalRP.users.get(event.getPlayer().getUniqueId());
if(animal == null) return;
if(animal.name != this.name) return;
if (event.isSneaking() && event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR) {
Player player = event.getPlayer();
if (!sneakers.contains(player.getUniqueId())) {
sneakers.add(player.getUniqueId());
new BukkitRunnable() {
@Override
public void run() {
if(sneakers.contains(player.getUniqueId())) sneakers.remove(player.getUniqueId());
}
}.runTaskLater(AnimalRP.getProvidingPlugin(Animal.class), 20);
} else {
sneakers.remove(player.getUniqueId());
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, 20*1, 5, true));
player.getWorld().playSound(player.getLocation(), this.moodSounds.get(Mood.HAPPY), 1F, 1);
}
}
}
@Override
public String chatTransformations(String message) {
return destroyer.destroy(message);
}
}

View file

@ -26,7 +26,7 @@
*/
package lv.pi.animalrp;
package ovh.sad.animalrp;
import java.io.File;
import java.io.IOException;
@ -47,24 +47,24 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import lv.pi.animalrp.animals.Animal;
import lv.pi.animalrp.animals.Bee;
import lv.pi.animalrp.animals.Cat;
import lv.pi.animalrp.animals.Dog;
import lv.pi.animalrp.animals.Fox;
import lv.pi.animalrp.commands.EmoteCommand;
import lv.pi.animalrp.commands.InteractionCommand;
import lv.pi.animalrp.commands.ChatModClientCommand;
import lv.pi.animalrp.commands.ChatModCommand;
import lv.pi.animalrp.commands.ClearCooldownCommand;
import lv.pi.animalrp.commands.SexCommand;
import lv.pi.animalrp.commands.TfCommand;
import lv.pi.animalrp.listeners.LeashPlayers;
import lv.pi.animalrp.listeners.PlayerChat;
import lv.pi.animalrp.listeners.PlayerLeave;
import lv.pi.animalrp.util.Cooldown;
import lv.pi.animalrp.util.Emote;
import lv.pi.animalrp.util.Mood;
import ovh.sad.animalrp.animals.Animal;
import ovh.sad.animalrp.animals.Bee;
import ovh.sad.animalrp.animals.Cat;
import ovh.sad.animalrp.animals.Dog;
import ovh.sad.animalrp.animals.Fox;
import ovh.sad.animalrp.commands.EmoteCommand;
import ovh.sad.animalrp.commands.InteractionCommand;
import ovh.sad.animalrp.commands.ChatModClientCommand;
import ovh.sad.animalrp.commands.ChatModCommand;
import ovh.sad.animalrp.commands.ClearCooldownCommand;
import ovh.sad.animalrp.commands.SexCommand;
import ovh.sad.animalrp.commands.TfCommand;
import ovh.sad.animalrp.listeners.LeashPlayers;
import ovh.sad.animalrp.listeners.PlayerChat;
import ovh.sad.animalrp.listeners.PlayerLeave;
import ovh.sad.animalrp.util.Cooldown;
import ovh.sad.animalrp.util.Emote;
import ovh.sad.animalrp.util.Mood;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.milkbowl.vault.chat.Chat;

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.animals;
package ovh.sad.animalrp.animals;
import java.util.ArrayList;
import java.util.HashMap;
@ -10,8 +10,8 @@ import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.util.Mood;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.util.Mood;
import org.bukkit.Sound;
import org.bukkit.entity.Player;

View file

@ -0,0 +1,200 @@
package ovh.sad.animalrp.animals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.Sound;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.FoodComponent;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.util.Mood;
import ovh.sad.animalrp.util.TextDestroyer;
public class Bee extends Animal {
class Row {
Material mat;
Integer times;
}
private static Material[] _allFlowers = { Material.ALLIUM, Material.AZURE_BLUET, Material.BLUE_ORCHID,
Material.CORNFLOWER, Material.DANDELION, Material.LILY_OF_THE_VALLEY, Material.OXEYE_DAISY,
Material.POPPY, Material.TORCHFLOWER, Material.ORANGE_TULIP, Material.PINK_TULIP, Material.RED_TULIP,
Material.WHITE_TULIP };
public static List<Material> allFlowers = Arrays.asList(_allFlowers);
public static NamespacedKey beeFoodKey = NamespacedKey.fromString("animalrp:bee_food");
public static HashMap<UUID, Row> inARow = new HashMap<UUID, Row>();
TextDestroyer destroyer = new TextDestroyer(new String[] {
">_<", "*buzz*",
";3", ":3", "εწз", " ≧◠◡◠≦ ", "*stings you*", "*humms*",
"*i'm a bee*"
}, new String[][] {
{ "e", "ee" },
{ "b", "bzz" },
{ "h", "hh" },
{ "ie", "ee" },
{ "be", "bee" },
{ "E", "EE" },
{ "B", "BZZ" },
{ "H", "HH" },
{ "IE", "EE" },
{ "BE", "BEE" }
});
ArrayList<UUID> sneakers = new ArrayList<UUID>();
public Bee() {
super("bee", "Buzz...", "#FFFF00");
this.moodSounds.put(Mood.HAPPY, Sound.ENTITY_BEE_LOOP);
this.moodSounds.put(Mood.CUTE, Sound.ENTITY_BEE_LOOP);
this.moodSounds.put(Mood.SAD, Sound.ENTITY_BEE_HURT);
this.moodSounds.put(Mood.STRESSED, Sound.ENTITY_BEE_STING);
this.moodSounds.put(Mood.ANGRY, Sound.ENTITY_BEE_LOOP_AGGRESSIVE);
}
@EventHandler
public void onConsume(PlayerItemConsumeEvent event) {
Player player = event.getPlayer();
Animal animal = AnimalRP.users.get(player.getUniqueId());
ItemStack item = event.getItem();
if (!allFlowers.contains(item.getType())) { // not a flower
return;
}
if (animal == null)
return;
if (animal.name != this.name)
return;
Row row = inARow.get(player.getUniqueId()); // make a new row
if (row == null) { // none yet
row = new Row();
row.mat = item.getType();
row.times = 1;
} else {
if (row.mat.equals(item.getType())) { // mat is same as in row, increase time
row.times += 1;
} else {
row.mat = item.getType(); // mat not same, change mat, reset time
row.times = 1;
}
}
if (row.times > 20) {
player.addPotionEffect(new PotionEffect(PotionEffectType.NAUSEA, 20 * 10, 1, true));
}
if (row.times > 30) {
if (row.times > 40) {
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 20 * 10, 3, true));
} else {
player.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 20 * 5, 2, true));
}
}
inARow.put(player.getUniqueId(), row);
}
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Animal animal = AnimalRP.users.get(player.getUniqueId());
ItemStack item = event.getItem();
if (item == null) // air interact
return;
if (!allFlowers.contains(item.getType())) { // not a flower
return;
}
ItemMeta meta = item.getItemMeta();
Boolean incorrect = false;
if (animal == null) {
incorrect = true;
} else {
if (animal.name != this.name) {
incorrect = true;
}
}
if (incorrect) {
if (meta.getPersistentDataContainer().has(beeFoodKey)) {
meta.getPersistentDataContainer().remove(beeFoodKey);
meta.setFood(null);
item.setItemMeta(meta);
event.setCancelled(true);
}
return;
}
if (meta.getPersistentDataContainer().has(beeFoodKey)) { // correct animal, but foodkey already set
return;
}
FoodComponent food = meta.getFood();
food.addEffect(new PotionEffect(PotionEffectType.SPEED, 20 * 4, 1, true), 1);
food.setCanAlwaysEat(true);
food.setNutrition(4); // these values match the 'superfood' of animalrps
food.setSaturation(9.4f);
meta.getPersistentDataContainer().set(beeFoodKey, PersistentDataType.BOOLEAN, true);
meta.setFood(food);
item.setItemMeta(meta);
}
@EventHandler
public void onSneak(PlayerToggleSneakEvent event) {
Animal animal = AnimalRP.users.get(event.getPlayer().getUniqueId());
if (animal == null)
return;
if (animal.name != this.name)
return;
Material type = event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType();
if (event.isSneaking()
&& type != Material.AIR && type != Material.WATER) {
Player player = event.getPlayer();
if (!sneakers.contains(player.getUniqueId())) {
sneakers.add(player.getUniqueId());
new BukkitRunnable() {
@Override
public void run() {
if (sneakers.contains(player.getUniqueId()))
sneakers.remove(player.getUniqueId());
}
}.runTaskLater(AnimalRP.getProvidingPlugin(Animal.class), 20);
} else {
sneakers.remove(player.getUniqueId());
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, 20 * 1, 5, true));
player.getWorld().playSound(player.getLocation(), this.moodSounds.get(Mood.HAPPY), 1F, 1);
}
}
}
@Override
public String chatTransformations(String message) {
return destroyer.destroy(message);
}
}

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.animals;
package ovh.sad.animalrp.animals;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -7,9 +7,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.util.Mood;
import lv.pi.animalrp.util.TextDestroyer;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.util.Mood;
import ovh.sad.animalrp.util.TextDestroyer;
public class Cat extends Animal {
TextDestroyer destroyer = new TextDestroyer(new String[]{

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.animals;
package ovh.sad.animalrp.animals;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -8,9 +8,9 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.util.Mood;
import lv.pi.animalrp.util.TextDestroyer;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.util.Mood;
import ovh.sad.animalrp.util.TextDestroyer;
public class Dog extends Animal {

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.animals;
package ovh.sad.animalrp.animals;
import java.util.Random;
@ -10,9 +10,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.util.Mood;
import lv.pi.animalrp.util.TextDestroyer;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.util.Mood;
import ovh.sad.animalrp.util.TextDestroyer;
public class Fox extends Animal {
TextDestroyer destroyer = new TextDestroyer(new String[]{
@ -39,7 +39,7 @@ public class Fox extends Animal {
this.moodSounds.put(Mood.STRESSED, Sound.ENTITY_FOX_AGGRO);
this.moodSounds.put(Mood.ANGRY, Sound.ENTITY_FOX_BITE);
this.superfoods.add(Material.SWEET_BERRIES);
this.superfoods.add(Material.APPLE);
this.superfoods.add(Material.GLOW_BERRIES);
}

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.commands;
package ovh.sad.animalrp.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import lv.pi.animalrp.AnimalRP;
import ovh.sad.animalrp.AnimalRP;
public class ChatModClientCommand implements CommandExecutor {
@Override

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.commands;
package ovh.sad.animalrp.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import lv.pi.animalrp.AnimalRP;
import ovh.sad.animalrp.AnimalRP;
public class ChatModCommand implements CommandExecutor {
@Override

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.commands;
package ovh.sad.animalrp.commands;
import org.bukkit.command.CommandExecutor;
@ -8,8 +8,8 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.util.Cooldown;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.util.Cooldown;
public class ClearCooldownCommand implements CommandExecutor {
@Override

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.commands;
package ovh.sad.animalrp.commands;
import java.util.stream.Collectors;
@ -8,9 +8,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.util.Emote;
import lv.pi.animalrp.util.Emote.Emotes;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.util.Emote;
import ovh.sad.animalrp.util.Emote.Emotes;
public class EmoteCommand implements CommandExecutor {
private void options(Player player) {

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.commands;
package ovh.sad.animalrp.commands;
import org.bukkit.command.CommandExecutor;
@ -8,9 +8,9 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.animals.Animal;
import lv.pi.animalrp.util.Mood;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.animals.Animal;
import ovh.sad.animalrp.util.Mood;
public class InteractionCommand implements CommandExecutor {
String toThem;

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.commands;
package ovh.sad.animalrp.commands;
import java.util.HashMap;
import java.util.Iterator;
@ -26,7 +26,7 @@ import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import lv.pi.animalrp.AnimalRP;
import ovh.sad.animalrp.AnimalRP;
enum Yaw {
NORTH, EAST, WEST, SOUTH;

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.commands;
package ovh.sad.animalrp.commands;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@ -10,9 +10,9 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.animals.Animal;
import lv.pi.animalrp.util.Cooldown;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.animals.Animal;
import ovh.sad.animalrp.util.Cooldown;
public class TfCommand implements CommandExecutor {
public void options(Player player) {

View file

@ -1,5 +1,5 @@
package lv.pi.animalrp.listeners;
package ovh.sad.animalrp.listeners;
// Code from:
// (warning, NSFW) https://github.com/ApherFox/MC-leash-players-plugin/blob/master/main/Pair.java
@ -23,9 +23,9 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.animals.Animal;
import lv.pi.animalrp.util.Mood;
import ovh.sad.animalrp.AnimalRP;
import ovh.sad.animalrp.animals.Animal;
import ovh.sad.animalrp.util.Mood;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.listeners;
package ovh.sad.animalrp.listeners;
import java.util.Optional;
import java.util.Random;
@ -14,13 +14,13 @@ import org.jetbrains.annotations.NotNull;
import io.papermc.paper.chat.ChatRenderer;
import io.papermc.paper.event.player.AsyncChatEvent;
import lv.pi.animalrp.animals.Animal;
import lv.pi.animalrp.util.Mood;
import ovh.sad.animalrp.animals.Animal;
import ovh.sad.animalrp.util.Mood;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import lv.pi.animalrp.AnimalRP;
import ovh.sad.animalrp.AnimalRP;
class CustomChatRenderer implements ChatRenderer {
String message;

View file

@ -1,11 +1,11 @@
package lv.pi.animalrp.listeners;
package ovh.sad.animalrp.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import lv.pi.animalrp.commands.SexCommand;
import lv.pi.animalrp.commands.SexCommand.SexModel;
import ovh.sad.animalrp.commands.SexCommand;
import ovh.sad.animalrp.commands.SexCommand.SexModel;
public class PlayerLeave implements Listener {
@EventHandler

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.util;
package ovh.sad.animalrp.util;
import com.google.gson.JsonObject;

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.util;
package ovh.sad.animalrp.util;
import java.util.ArrayList;
import java.util.HashMap;
@ -15,7 +15,7 @@ import org.bukkit.Particle;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import lv.pi.animalrp.AnimalRP;
import ovh.sad.animalrp.AnimalRP;
public class Emote {

View file

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

View file

@ -1,4 +1,4 @@
package lv.pi.animalrp.util;
package ovh.sad.animalrp.util;
import java.util.ArrayList;
import java.util.List;

View file

@ -1,5 +1,5 @@
name: animalrp
main: lv.pi.animalrp.AnimalRP
main: ovh.sad.animalrp.AnimalRP
version: 1.0.0
api-version: 1.21
commands: