Update to 1.20 + vault integration + several fixes
This commit is contained in:
parent
94973b8296
commit
8eb328b0f7
42
pom.xml
42
pom.xml
|
@ -39,7 +39,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.papermc.paper</groupId>
|
<groupId>io.papermc.paper</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paper-api</artifactId>
|
||||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -51,6 +51,12 @@
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||||
<version>4.13.0</version>
|
<version>4.13.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -93,40 +99,6 @@
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
|
||||||
<plugin>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
<artifactId>specialsource-maven-plugin</artifactId>
|
|
||||||
<version>1.2.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-obf</id>
|
|
||||||
<configuration>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
|
|
||||||
<reverse>true</reverse>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
|
|
||||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
|
||||||
<remappedClassifierName>remapped-obf</remappedClassifierName>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>remap</goal>
|
|
||||||
</goals>
|
|
||||||
<id>remap-spigot</id>
|
|
||||||
<configuration>
|
|
||||||
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
|
|
||||||
<srgIn>org.spigotmc:minecraft-server:1.19.4-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
|
|
||||||
<remappedDependencies>org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -7,11 +7,9 @@ Doubleclicking shift you will float (levitation 5 for 1 second), allowing for be
|
||||||
You take significantly less damage when falling (5 hearts). You can still die, don't count on your cat-powers catching you every time. **Your superfood is all types of eatable fish.**
|
You take significantly less damage when falling (5 hearts). You can still die, don't count on your cat-powers catching you every time. **Your superfood is all types of eatable fish.**
|
||||||
3. Fox
|
3. Fox
|
||||||
You do more damage to mobs (25%). **Your superfood is all types of berry.**
|
You do more damage to mobs (25%). **Your superfood is all types of berry.**
|
||||||
4. Phantom
|
|
||||||
You can use elytras, however you burn in daylight and your elytra speed is capped at half of the normal one. **Your superfoods are all uncooked meats.**
|
|
||||||
|
|
||||||
## **Chat**
|
## **Chat**
|
||||||
Chat while you are a animal is very different. When you speak, your words will become furry-ified and every time you talk you'll have animal sounds come out of you.
|
Chat while you are a animal is very different. When you speak, your words will become furry-ified and every time you talk you'll have animal sounds come out of you. You can disable this via /chatmodoff, and turn it back on via /chatmodon.
|
||||||
|
|
||||||
## **Superfoods**
|
## **Superfoods**
|
||||||
Superfoods are items that when eaten, give you stackable **Speed II** and insane amounts of saturation (9.4 points) and hunger (4 points).
|
Superfoods are items that when eaten, give you stackable **Speed II** and insane amounts of saturation (9.4 points) and hunger (4 points).
|
||||||
|
|
|
@ -37,6 +37,7 @@ import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
@ -55,20 +56,23 @@ import lv.pi.animalrp.commands.ChatModCommand;
|
||||||
import lv.pi.animalrp.commands.ClearCooldownCommand;
|
import lv.pi.animalrp.commands.ClearCooldownCommand;
|
||||||
import lv.pi.animalrp.commands.SexCommand;
|
import lv.pi.animalrp.commands.SexCommand;
|
||||||
import lv.pi.animalrp.commands.TfCommand;
|
import lv.pi.animalrp.commands.TfCommand;
|
||||||
import lv.pi.animalrp.listeners.AntiElytra;
|
|
||||||
import lv.pi.animalrp.listeners.PlayerChat;
|
import lv.pi.animalrp.listeners.PlayerChat;
|
||||||
import lv.pi.animalrp.util.Cooldown;
|
import lv.pi.animalrp.util.Cooldown;
|
||||||
import lv.pi.animalrp.util.Emote;
|
import lv.pi.animalrp.util.Emote;
|
||||||
import lv.pi.animalrp.util.Mood;
|
import lv.pi.animalrp.util.Mood;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.milkbowl.vault.chat.Chat;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
public class AnimalRP extends JavaPlugin {
|
public class AnimalRP extends JavaPlugin {
|
||||||
public static HashMap<UUID, Animal> users = new HashMap<UUID, Animal>();
|
public static HashMap<UUID, Animal> users;
|
||||||
public static HashMap<UUID, Boolean> isChatModOff = new HashMap<UUID, Boolean>();
|
public static HashMap<UUID, Boolean> isChatModOff;
|
||||||
public static HashMap<UUID, Cooldown> cooldowns = new HashMap<UUID, Cooldown>();
|
public static HashMap<UUID, Cooldown> cooldowns;
|
||||||
public static HashMap<String, Animal> animals = new HashMap<String, Animal>();
|
public static HashMap<String, Animal> animals;
|
||||||
public static Emote emotes;
|
public static Emote emotes;
|
||||||
|
|
||||||
|
public static Chat vaultChat;
|
||||||
|
|
||||||
public static Boolean configEnabled = true;
|
public static Boolean configEnabled = true;
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
public static MiniMessage mm = MiniMessage.miniMessage();
|
public static MiniMessage mm = MiniMessage.miniMessage();
|
||||||
|
@ -120,15 +124,25 @@ public class AnimalRP extends JavaPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
PluginManager pm = getServer().getPluginManager();
|
RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
|
||||||
|
if(rsp != null) {
|
||||||
|
AnimalRP.vaultChat = rsp.getProvider();
|
||||||
|
} else {
|
||||||
|
System.out.println("[AnimalRP] !!! Missing vault, prefix/suffix will not be included in chat formatting.");
|
||||||
|
}
|
||||||
|
AnimalRP.users = new HashMap<UUID, Animal>();
|
||||||
|
AnimalRP.isChatModOff = new HashMap<UUID, Boolean>();
|
||||||
|
AnimalRP.cooldowns = new HashMap<UUID, Cooldown>();
|
||||||
|
AnimalRP.animals = new HashMap<String, Animal>();
|
||||||
|
|
||||||
AnimalRP.emotes = new Emote();
|
AnimalRP.emotes = new Emote();
|
||||||
|
PluginManager pm = getServer().getPluginManager();
|
||||||
|
|
||||||
this.gson = new Gson();
|
this.gson = new Gson();
|
||||||
|
|
||||||
animals.put("cat", new Cat());
|
animals.put("cat", new Cat());
|
||||||
animals.put("fox", new Fox());
|
animals.put("fox", new Fox());
|
||||||
animals.put("bee", new Bee());
|
animals.put("bee", new Bee());
|
||||||
// animals.put("phantom", new Phantom()); // finish Phantom
|
|
||||||
|
|
||||||
animals.forEach((z,b) -> {
|
animals.forEach((z,b) -> {
|
||||||
pm.registerEvents(b, this);
|
pm.registerEvents(b, this);
|
||||||
|
@ -181,7 +195,6 @@ public class AnimalRP extends JavaPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
pm.registerEvents(new PlayerChat(), this);
|
pm.registerEvents(new PlayerChat(), this);
|
||||||
pm.registerEvents(new AntiElytra(), this);
|
|
||||||
|
|
||||||
getCommand("tf").setExecutor(new TfCommand());
|
getCommand("tf").setExecutor(new TfCommand());
|
||||||
getCommand("emote").setExecutor(new EmoteCommand());
|
getCommand("emote").setExecutor(new EmoteCommand());
|
||||||
|
@ -197,9 +210,9 @@ public class AnimalRP extends JavaPlugin {
|
||||||
getCommand("headpats").setExecutor(new InteractionCommand(Mood.HAPPY, "%s petted you! %s", "You petted %s! %s"));
|
getCommand("headpats").setExecutor(new InteractionCommand(Mood.HAPPY, "%s petted you! %s", "You petted %s! %s"));
|
||||||
getCommand("kiss").setExecutor(new InteractionCommand(Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s"));
|
getCommand("kiss").setExecutor(new InteractionCommand(Mood.CUTE, "%s kissed you.. 0////0 %s", "You kissed %s.. 0////0 %s"));
|
||||||
getCommand("bite").setExecutor(new InteractionCommand(Mood.ANGRY, "%s bit you!! Σ(っ゚Д゚)っ %s", "You bit %s! (○`д´)ノシ %s"));
|
getCommand("bite").setExecutor(new InteractionCommand(Mood.ANGRY, "%s bit you!! Σ(っ゚Д゚)っ %s", "You bit %s! (○`д´)ノシ %s"));
|
||||||
|
getCommand("bzz").setExecutor(new InteractionCommand(Mood.ANGRY, "%s bzzs at you!! :3 %s", "You bzzed at %s :3 %s"));
|
||||||
getCommand("purr").setExecutor(new InteractionCommand(Mood.CUTE, "You hear the soft sound of %s purring on you... %s", "You jump on %s, and start purring. %s"));
|
getCommand("purr").setExecutor(new InteractionCommand(Mood.CUTE, "You hear the soft sound of %s purring on you... %s", "You jump on %s, and start purring. %s"));
|
||||||
getCommand("scratch").setExecutor(new InteractionCommand(Mood.ANGRY, "%s SCRATCHES YOU! Ow! %s", "You channel your inner evil, and scratch %s! %s"));
|
getCommand("scratch").setExecutor(new InteractionCommand(Mood.ANGRY, "%s SCRATCHES YOU! Ow! %s", "You channel your inner evil, and scratch %s! %s"));
|
||||||
|
|
||||||
/* Contributed by Simo__28 */
|
/* Contributed by Simo__28 */
|
||||||
getCommand("hug").setExecutor(new InteractionCommand(Mood.HAPPY, "%s hugs you! How heartwarming. %s", "You hug %s! How heartwarming. %s"));
|
getCommand("hug").setExecutor(new InteractionCommand(Mood.HAPPY, "%s hugs you! How heartwarming. %s", "You hug %s! How heartwarming. %s"));
|
||||||
getCommand("cuddle").setExecutor(new InteractionCommand(Mood.CUTE, "%s cuddles with you. %s", "You and %s start cuddling. How cute! %s"));
|
getCommand("cuddle").setExecutor(new InteractionCommand(Mood.CUTE, "%s cuddles with you. %s", "You and %s start cuddling. How cute! %s"));
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package lv.pi.animalrp.animals;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
|
|
||||||
import lv.pi.animalrp.util.Mood;
|
|
||||||
import lv.pi.animalrp.util.TextDestroyer;
|
|
||||||
|
|
||||||
public class Phantom extends Animal {
|
|
||||||
TextDestroyer destroyer = new TextDestroyer(new String[]{
|
|
||||||
"*shows wings*",
|
|
||||||
"*flap flap*",
|
|
||||||
"*screech*",
|
|
||||||
":3"
|
|
||||||
}, new String[][]{
|
|
||||||
{"you", "u"},
|
|
||||||
{"o", "sho"},
|
|
||||||
{"i", "ish"},
|
|
||||||
{"!", "! "},
|
|
||||||
{"?", "? "}
|
|
||||||
});
|
|
||||||
Random rand = new Random();
|
|
||||||
|
|
||||||
public Phantom() {
|
|
||||||
super("phantom", "~screech~", "#FF8000");
|
|
||||||
this.moodSounds.put(Mood.HAPPY, Sound.ENTITY_PHANTOM_FLAP);
|
|
||||||
this.moodSounds.put(Mood.CUTE, Sound.ENTITY_PHANTOM_SWOOP);
|
|
||||||
this.moodSounds.put(Mood.SAD, Sound.ENTITY_PHANTOM_SWOOP);
|
|
||||||
this.moodSounds.put(Mood.STRESSED, Sound.ENTITY_PHANTOM_HURT);
|
|
||||||
this.moodSounds.put(Mood.ANGRY, Sound.ENTITY_PHANTOM_BITE);
|
|
||||||
|
|
||||||
this.superfoods.add(Material.CHICKEN);
|
|
||||||
this.superfoods.add(Material.BEEF);
|
|
||||||
this.superfoods.add(Material.PORKCHOP);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String chatTransformations(String message) {
|
|
||||||
return this.destroyer.destroy(message);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,7 +25,7 @@ public class ChatModCommand implements CommandExecutor {
|
||||||
|
|
||||||
boolean isDisabled = false;
|
boolean isDisabled = false;
|
||||||
|
|
||||||
if(AnimalRP.isChatModOff.get(player.getUniqueId())) {
|
if(AnimalRP.isChatModOff.get(player.getUniqueId()) != null) {
|
||||||
isDisabled = true;
|
isDisabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class ClearCooldownCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
AnimalRP.cooldowns.remove(of.getUniqueId());
|
AnimalRP.cooldowns.remove(of.getUniqueId());
|
||||||
sender.sendMessage(AnimalRP.mm.deserialize("<red>Removed" + of.getName() + "'s cooldown (type: " + cooldown.type + ")!"));
|
sender.sendMessage(AnimalRP.mm.deserialize("<red>Removed " + of.getName() + "'s cooldown (type: " + cooldown.type + ")!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class TfCommand implements CommandExecutor {
|
||||||
Animal previous = AnimalRP.users.get(player.getUniqueId());
|
Animal previous = AnimalRP.users.get(player.getUniqueId());
|
||||||
player.sendMessage(AnimalRP.mm.deserialize("<green>You start splitting apart, dropping your <blue>" + previous.name+"-like<green> appearence.."));
|
player.sendMessage(AnimalRP.mm.deserialize("<green>You start splitting apart, dropping your <blue>" + previous.name+"-like<green> appearence.."));
|
||||||
AnimalRP.users.remove(player.getUniqueId());
|
AnimalRP.users.remove(player.getUniqueId());
|
||||||
if(AnimalRP.isChatModOff.get(player.getUniqueId()))
|
if(AnimalRP.isChatModOff.get(player.getUniqueId()) != null)
|
||||||
AnimalRP.isChatModOff.remove(player.getUniqueId());
|
AnimalRP.isChatModOff.remove(player.getUniqueId());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
package lv.pi.animalrp.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.block.Action;
|
|
||||||
import org.bukkit.event.entity.EntityToggleGlideEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import lv.pi.animalrp.AnimalRP;
|
|
||||||
import lv.pi.animalrp.animals.Animal;
|
|
||||||
|
|
||||||
public class AntiElytra implements Listener {
|
|
||||||
|
|
||||||
public AntiElytra() {
|
|
||||||
JavaPlugin plugin = AnimalRP.getProvidingPlugin(AnimalRP.class);
|
|
||||||
|
|
||||||
new BukkitRunnable(){
|
|
||||||
public void run(){
|
|
||||||
for(Player p : plugin.getServer().getOnlinePlayers())
|
|
||||||
dequipElytra(p);
|
|
||||||
}
|
|
||||||
}.runTaskTimer(plugin, 20 * 5, 20 * 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void message(Player player) {
|
|
||||||
player.sendMessage(AnimalRP.mm.deserialize("<red>Elytras are not allowed to be worn. You <green>can still trade with them <red>as they might have a use in the future."));
|
|
||||||
}
|
|
||||||
@EventHandler
|
|
||||||
public void onGlide(EntityToggleGlideEvent event) {
|
|
||||||
if (event.getEntity().getType().equals(EntityType.PLAYER))
|
|
||||||
dequipElytra((Player) event.getEntity());
|
|
||||||
}
|
|
||||||
|
|
||||||
private int firstEmptyFromBack(PlayerInventory inv) {
|
|
||||||
int z = -1;
|
|
||||||
|
|
||||||
for(int i = 35; i >= 9; i--) {
|
|
||||||
if(inv.getItem(i) == null) {
|
|
||||||
z = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return z;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dequipElytra(Player player) {
|
|
||||||
Animal animal = AnimalRP.users.get(player.getUniqueId());
|
|
||||||
|
|
||||||
if(animal != null) {
|
|
||||||
if(animal.name == "phantom") return; // phantom-ians can use elytra
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerInventory i = player.getInventory();
|
|
||||||
if (!( (i.getChestplate() != null) && i.getChestplate().getType().equals(Material.ELYTRA))) return;
|
|
||||||
if(player.getGameMode() == GameMode.CREATIVE) return;
|
|
||||||
|
|
||||||
ItemStack elytra = i.getChestplate();
|
|
||||||
i.setChestplate(null);
|
|
||||||
message(player);
|
|
||||||
|
|
||||||
// inventory full?
|
|
||||||
if (firstEmptyFromBack(i) != -1) {
|
|
||||||
i.setItem(firstEmptyFromBack(i), elytra);
|
|
||||||
player.updateInventory();
|
|
||||||
} else {
|
|
||||||
Location l = i.getLocation();
|
|
||||||
l.getWorld().dropItemNaturally(l, elytra);
|
|
||||||
player.updateInventory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onInteract(PlayerInteractEvent event) {
|
|
||||||
Action a = event.getAction();
|
|
||||||
if(a == Action.PHYSICAL || a == Action.LEFT_CLICK_AIR || a == Action.LEFT_CLICK_BLOCK) return;
|
|
||||||
|
|
||||||
if(event.getItem() == null) return;
|
|
||||||
if(event.getItem().getType() != Material.ELYTRA) return;
|
|
||||||
if(event.getPlayer().getGameMode() == GameMode.CREATIVE) return;
|
|
||||||
message(event.getPlayer());
|
|
||||||
dequipElytra(event.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,10 +2,12 @@ package lv.pi.animalrp.listeners;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import io.papermc.paper.chat.ChatRenderer;
|
import io.papermc.paper.chat.ChatRenderer;
|
||||||
|
@ -20,20 +22,42 @@ import lv.pi.animalrp.AnimalRP;
|
||||||
|
|
||||||
class CustomChatRenderer implements ChatRenderer {
|
class CustomChatRenderer implements ChatRenderer {
|
||||||
Animal animal;
|
Animal animal;
|
||||||
|
Team team;
|
||||||
|
Component suffix;
|
||||||
|
Component prefix;
|
||||||
|
|
||||||
public CustomChatRenderer(Animal animal) {
|
public CustomChatRenderer(Animal animal, Team team, Component suffix, Component prefix) {
|
||||||
this.animal = animal;
|
this.animal = animal;
|
||||||
|
this.team = team;
|
||||||
|
this.suffix = suffix;
|
||||||
|
this.prefix = prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message,
|
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message,
|
||||||
@NotNull Audience viewer) {
|
@NotNull Audience viewer) {
|
||||||
return Component
|
Component name = sourceDisplayName;
|
||||||
.text("<")
|
|
||||||
.append(sourceDisplayName.color(TextColor.fromHexString(animal.color)))
|
if(team != null) {
|
||||||
.append(Component.text(">"))
|
name = name.color(team.color());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(animal != null) {
|
||||||
|
name = name.color(TextColor.fromHexString(animal.color));
|
||||||
|
}
|
||||||
|
|
||||||
|
Component msg = message;
|
||||||
|
|
||||||
|
if(animal != null) {
|
||||||
|
msg = AnimalRP.mm.deserialize(animal.chatTransformations(AnimalRP.mm.serialize(message)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.prefix
|
||||||
|
.append(name)
|
||||||
|
.append(this.suffix)
|
||||||
|
.append(Component.text(":"))
|
||||||
.appendSpace()
|
.appendSpace()
|
||||||
.append(AnimalRP.mm.deserialize(animal.chatTransformations(AnimalRP.mm.serialize(message))));
|
.append(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,16 +66,41 @@ public class PlayerChat implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerChat(final AsyncChatEvent event) {
|
public void onPlayerChat(final AsyncChatEvent event) {
|
||||||
Animal animal = AnimalRP.users.get(event.getPlayer().getUniqueId());
|
final Animal animal = AnimalRP.users.get(event.getPlayer().getUniqueId());
|
||||||
|
Boolean chatModOff = false;
|
||||||
|
Team team = Bukkit.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(event.getPlayer());
|
||||||
|
|
||||||
if(animal != null) {
|
if(animal != null) {
|
||||||
if(AnimalRP.isChatModOff.get(event.getPlayer().getUniqueId())) return;
|
if(AnimalRP.isChatModOff.get(event.getPlayer().getUniqueId()) != null) {
|
||||||
|
chatModOff = true;
|
||||||
|
} else {
|
||||||
if(random.nextDouble() < 0.08) {
|
if(random.nextDouble() < 0.08) {
|
||||||
|
Bukkit.getScheduler().runTask(AnimalRP.getPlugin(AnimalRP.class), () -> {
|
||||||
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), animal.moodSounds.get(Mood.HAPPY), 10F, 1);
|
event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), animal.moodSounds.get(Mood.HAPPY), 10F, 1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.renderer(new CustomChatRenderer(animal));
|
Component csuffix = Component.text("");
|
||||||
|
Component cprefix = Component.text("");
|
||||||
|
|
||||||
|
if(AnimalRP.vaultChat != null) {
|
||||||
|
String suffix = AnimalRP.vaultChat.getPlayerSuffix(event.getPlayer());
|
||||||
|
String prefix = AnimalRP.vaultChat.getPlayerPrefix(event.getPlayer());
|
||||||
|
|
||||||
|
if(suffix != null) {
|
||||||
|
csuffix = Component.text(suffix);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(prefix != null) {
|
||||||
|
cprefix = Component.text(prefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(chatModOff) {
|
||||||
|
event.renderer(new CustomChatRenderer(null, team, csuffix, cprefix));
|
||||||
|
} else {
|
||||||
|
event.renderer(new CustomChatRenderer(animal, team, csuffix, cprefix));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
name: animalrp
|
name: animalrp
|
||||||
main: lv.pi.animalrp.AnimalRP
|
main: lv.pi.animalrp.AnimalRP
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
api-version: 1.19
|
api-version: 1.20
|
||||||
commands:
|
commands:
|
||||||
tf:
|
tf:
|
||||||
usage: Become the animal of your dreams!
|
usage: Become the animal of your dreams!
|
||||||
|
@ -30,5 +30,7 @@ commands:
|
||||||
usage: Cuddle a person.
|
usage: Cuddle a person.
|
||||||
emote:
|
emote:
|
||||||
usage: Emote!
|
usage: Emote!
|
||||||
|
bzz:
|
||||||
|
usage: Bzz at someone :3
|
||||||
sex:
|
sex:
|
||||||
usage: This command can only be used by Operators.
|
usage: This command can only be used by Operators.
|
Loading…
Reference in a new issue