implement dog + fix sex

This commit is contained in:
yourfriendoss 2024-03-31 22:05:37 +03:00
parent 8eb328b0f7
commit 2604e8f4dc
6 changed files with 156 additions and 89 deletions

View file

@ -49,6 +49,7 @@ import com.google.gson.JsonSyntaxException;
import lv.pi.animalrp.animals.Animal; import lv.pi.animalrp.animals.Animal;
import lv.pi.animalrp.animals.Bee; import lv.pi.animalrp.animals.Bee;
import lv.pi.animalrp.animals.Cat; import lv.pi.animalrp.animals.Cat;
import lv.pi.animalrp.animals.Dog;
import lv.pi.animalrp.animals.Fox; import lv.pi.animalrp.animals.Fox;
import lv.pi.animalrp.commands.EmoteCommand; import lv.pi.animalrp.commands.EmoteCommand;
import lv.pi.animalrp.commands.InteractionCommand; import lv.pi.animalrp.commands.InteractionCommand;
@ -57,6 +58,7 @@ 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.PlayerChat; import lv.pi.animalrp.listeners.PlayerChat;
import lv.pi.animalrp.listeners.PlayerLeave;
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;
@ -142,6 +144,7 @@ public class AnimalRP extends JavaPlugin {
animals.put("cat", new Cat()); animals.put("cat", new Cat());
animals.put("fox", new Fox()); animals.put("fox", new Fox());
animals.put("dog", new Dog());
animals.put("bee", new Bee()); animals.put("bee", new Bee());
animals.forEach((z,b) -> { animals.forEach((z,b) -> {
@ -195,6 +198,7 @@ public class AnimalRP extends JavaPlugin {
} }
pm.registerEvents(new PlayerChat(), this); pm.registerEvents(new PlayerChat(), this);
pm.registerEvents(new PlayerLeave(), this);
getCommand("tf").setExecutor(new TfCommand()); getCommand("tf").setExecutor(new TfCommand());
getCommand("emote").setExecutor(new EmoteCommand()); getCommand("emote").setExecutor(new EmoteCommand());

View file

@ -17,19 +17,6 @@ import lv.pi.animalrp.AnimalRP;
import lv.pi.animalrp.util.Mood; import lv.pi.animalrp.util.Mood;
import lv.pi.animalrp.util.TextDestroyer; import lv.pi.animalrp.util.TextDestroyer;
class Cooldown {
Integer duration;
Long executionTime;
public Cooldown(Integer duration, Long executionTime) {
this.duration = duration;
this.executionTime = executionTime;
}
public boolean isExpired() {
return this.executionTime-(System.currentTimeMillis()-this.duration) <= 0;
}
}
public class Bee extends Animal { public class Bee extends Animal {
TextDestroyer destroyer = new TextDestroyer(new String[]{ TextDestroyer destroyer = new TextDestroyer(new String[]{
">_<", "*buzz*", ">_<", "*buzz*",

View file

@ -0,0 +1,54 @@
package lv.pi.animalrp.animals;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
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;
public class Dog extends Animal {
TextDestroyer destroyer = new TextDestroyer(new String[]{
"Woof!", "Bark :3",
"Arf", "bark bark bark", "arf~"
}, new String[][]{
});
public Dog() {
super("dog", "Arf!", "#ff8c00");
this.moodSounds.put(Mood.HAPPY, Sound.ENTITY_WOLF_AMBIENT);
this.moodSounds.put(Mood.CUTE, Sound.ENTITY_WOLF_STEP);
this.moodSounds.put(Mood.SAD, Sound.ENTITY_WOLF_WHINE);
this.moodSounds.put(Mood.STRESSED, Sound.ENTITY_WOLF_SHAKE);
this.moodSounds.put(Mood.ANGRY, Sound.ENTITY_WOLF_GROWL);
this.superfoods.add(Material.CHICKEN);
this.superfoods.add(Material.BEEF);
this.superfoods.add(Material.PORKCHOP);
}
@EventHandler
public void onDamage(EntityDamageByEntityEvent event) {
if(event.getEntity() instanceof Player) {
Player player = (Player)event.getEntity();
Animal animal = AnimalRP.users.get(player.getUniqueId());
if(animal == null) return;
if(animal.name != this.name) return;
player.removePotionEffect(PotionEffectType.SPEED);
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 20, 2));
}
}
@Override
public String chatTransformations(String message) {
return destroyer.destroy(message);
}
}

View file

@ -32,51 +32,6 @@ enum Yaw {
NORTH, EAST, WEST, SOUTH; NORTH, EAST, WEST, SOUTH;
} }
class SexModel {
ArmorStand as;
Yaw yaw;
int sexTicks = 0;
boolean finished = false;
Location playerLocation;
public SexModel(ArmorStand as, Yaw yaw, Location playerLocation) {
this.as = as; this.yaw = yaw; this.playerLocation = playerLocation;
}
public void tickSex(Player player) {
player.teleport(this.playerLocation);
this.sexTicks ++;
if(this.sexTicks %2 == 0) {
Yaw opposite = Yaw.NORTH;
if(this.yaw == Yaw.NORTH) opposite = Yaw.SOUTH;
if(this.yaw == Yaw.WEST) opposite = Yaw.EAST;
if(this.yaw == Yaw.EAST) opposite = Yaw.WEST;
if(this.yaw == Yaw.SOUTH) opposite = Yaw.NORTH;
this.yaw = opposite;
Location asl = this.as.getLocation();
asl.add(SexCommand.getVector(this.yaw, 0.2));
as.teleport(asl);
}
if(this.sexTicks == 30) {
player.sendMessage(AnimalRP.mm.deserialize("<#FFC0CB>I'm about to.."));
}
if(this.sexTicks == 50) {
player.sendMessage(AnimalRP.mm.deserialize("<#FFC0CB>cum!!"));
player.getWorld().spawnParticle(Particle.END_ROD, player.getLocation(), 999, 0, 0, 0);
this.removeModel();
finished = true;
}
}
public void removeModel() {
this.as.remove();
}
}
public class SexCommand implements CommandExecutor { public class SexCommand implements CommandExecutor {
static public HashMap<UUID, SexModel> models = new HashMap<UUID, SexModel>(); static public HashMap<UUID, SexModel> models = new HashMap<UUID, SexModel>();
@ -167,7 +122,8 @@ public class SexCommand implements CommandExecutor {
} }
@Override @Override
public boolean onCommand(@NotNull CommandSender arg0, @NotNull Command arg1, @NotNull String arg2, @NotNull String[] arg3) { public boolean onCommand(@NotNull CommandSender arg0, @NotNull Command arg1, @NotNull String arg2,
@NotNull String[] arg3) {
if (!(arg0 instanceof Player)) { if (!(arg0 instanceof Player)) {
arg0.sendMessage(AnimalRP.mm.deserialize("<gray>I'm sorry console. :(</gray>")); arg0.sendMessage(AnimalRP.mm.deserialize("<gray>I'm sorry console. :(</gray>"));
return true; return true;
@ -228,4 +184,54 @@ public class SexCommand implements CommandExecutor {
return true; return true;
} }
public class SexModel {
ArmorStand as;
Yaw yaw;
int sexTicks = 0;
boolean finished = false;
Location playerLocation;
public SexModel(ArmorStand as, Yaw yaw, Location playerLocation) {
this.as = as;
this.yaw = yaw;
this.playerLocation = playerLocation;
}
public void tickSex(Player player) {
player.teleport(this.playerLocation);
this.sexTicks++;
if (this.sexTicks % 2 == 0) {
Yaw opposite = Yaw.NORTH;
if (this.yaw == Yaw.NORTH)
opposite = Yaw.SOUTH;
if (this.yaw == Yaw.WEST)
opposite = Yaw.EAST;
if (this.yaw == Yaw.EAST)
opposite = Yaw.WEST;
if (this.yaw == Yaw.SOUTH)
opposite = Yaw.NORTH;
this.yaw = opposite;
Location asl = this.as.getLocation();
asl.add(SexCommand.getVector(this.yaw, 0.2));
as.teleport(asl);
}
if (this.sexTicks == 30) {
player.sendMessage(AnimalRP.mm.deserialize("<#FFC0CB>I'm about to.."));
}
if (this.sexTicks == 50) {
player.sendMessage(AnimalRP.mm.deserialize("<#FFC0CB>cum!!"));
player.getWorld().spawnParticle(Particle.END_ROD, player.getLocation(), 999, 0, 0, 0);
this.removeModel();
finished = true;
}
}
public void removeModel() {
this.as.remove();
}
}
} }

View file

@ -97,11 +97,8 @@ public class PlayerChat implements Listener {
cprefix = Component.text(prefix); cprefix = Component.text(prefix);
} }
} }
if(chatModOff) {
event.renderer(new CustomChatRenderer(null, team, csuffix, cprefix)); event.renderer(new CustomChatRenderer(chatModOff ? null : animal, team, csuffix, cprefix));
} else {
event.renderer(new CustomChatRenderer(animal, team, csuffix, cprefix));
}
} }
} }

View file

@ -0,0 +1,19 @@
package lv.pi.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;
public class PlayerLeave implements Listener {
@EventHandler
public void onLeavePlayer(PlayerQuitEvent event) {
SexModel model = SexCommand.models.get(event.getPlayer().getUniqueId());
if(model != null) {
model.removeModel();
SexCommand.models.remove(event.getPlayer().getUniqueId());
}
}
}