implement dog + fix sex
This commit is contained in:
parent
8eb328b0f7
commit
2604e8f4dc
|
@ -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,7 +198,8 @@ 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());
|
||||||
getCommand("sex").setExecutor(new SexCommand());
|
getCommand("sex").setExecutor(new SexCommand());
|
||||||
|
|
|
@ -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*",
|
||||||
|
|
54
src/main/java/lv/pi/animalrp/animals/Dog.java
Normal file
54
src/main/java/lv/pi/animalrp/animals/Dog.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,68 +29,23 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import lv.pi.animalrp.AnimalRP;
|
import lv.pi.animalrp.AnimalRP;
|
||||||
|
|
||||||
enum Yaw {
|
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>();
|
||||||
|
|
||||||
public SexCommand() {
|
public SexCommand() {
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(AnimalRP.getProvidingPlugin(AnimalRP.class), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(AnimalRP.getProvidingPlugin(AnimalRP.class), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Set<Entry<UUID, SexModel>> modelset = models.entrySet();
|
Set<Entry<UUID, SexModel>> modelset = models.entrySet();
|
||||||
|
|
||||||
for (Iterator<Entry<UUID, SexModel>> iterator = modelset.iterator(); iterator.hasNext(); ) {
|
for (Iterator<Entry<UUID, SexModel>> iterator = modelset.iterator(); iterator.hasNext();) {
|
||||||
Entry<UUID, SexModel> value = iterator.next();
|
Entry<UUID, SexModel> value = iterator.next();
|
||||||
Player plr = Bukkit.getPlayer(value.getKey());
|
Player plr = Bukkit.getPlayer(value.getKey());
|
||||||
if(plr == null || value.getValue().finished) {
|
if (plr == null || value.getValue().finished) {
|
||||||
value.getValue().removeModel();
|
value.getValue().removeModel();
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,7 +55,7 @@ public class SexCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
}, 5, 5);
|
}, 5, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Location faceLocation(Entity entity, Location to) {
|
public static Location faceLocation(Entity entity, Location to) {
|
||||||
if (entity.getWorld() != to.getWorld()) {
|
if (entity.getWorld() != to.getWorld()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -147,52 +102,53 @@ public class SexCommand implements CommandExecutor {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector getVector(Yaw yaw, Double amount) {
|
public static Vector getVector(Yaw yaw, Double amount) {
|
||||||
if(yaw == Yaw.NORTH) {
|
if (yaw == Yaw.NORTH) {
|
||||||
return new Vector(0, 0, -amount);
|
return new Vector(0, 0, -amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(yaw == Yaw.SOUTH) {
|
if (yaw == Yaw.SOUTH) {
|
||||||
return new Vector(0, 0, amount);
|
return new Vector(0, 0, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(yaw == Yaw.EAST) {
|
if (yaw == Yaw.EAST) {
|
||||||
return new Vector(amount, 0, 0);
|
return new Vector(amount, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(yaw == Yaw.WEST) {
|
if (yaw == Yaw.WEST) {
|
||||||
return new Vector(-amount, 0, 0);
|
return new Vector(-amount, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Vector(0, 0,0);
|
return new Vector(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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,
|
||||||
if(!(arg0 instanceof Player)) {
|
@NotNull String[] arg3) {
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player)arg0;
|
|
||||||
|
|
||||||
if(!player.isOp()) {
|
Player player = (Player) arg0;
|
||||||
|
|
||||||
|
if (!player.isOp()) {
|
||||||
arg0.sendMessage(AnimalRP.mm.deserialize("<red>You are not an OP!"));
|
arg0.sendMessage(AnimalRP.mm.deserialize("<red>You are not an OP!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(arg3.length == 0) {
|
if (arg3.length == 0) {
|
||||||
arg0.sendMessage(AnimalRP.mm.deserialize("<red>Include player!"));
|
arg0.sendMessage(AnimalRP.mm.deserialize("<red>Include player!"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String playerName = arg3[0];
|
String playerName = arg3[0];
|
||||||
OfflinePlayer of = Bukkit.getOfflinePlayer(playerName);
|
OfflinePlayer of = Bukkit.getOfflinePlayer(playerName);
|
||||||
if(of == null) {
|
if (of == null) {
|
||||||
arg0.sendMessage(AnimalRP.mm.deserialize("<red>User has never joined."));
|
arg0.sendMessage(AnimalRP.mm.deserialize("<red>User has never joined."));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SexCommand.models.containsKey(player.getUniqueId())) {
|
if (SexCommand.models.containsKey(player.getUniqueId())) {
|
||||||
arg0.sendMessage(AnimalRP.mm.deserialize("<red>You are already in progress."));
|
arg0.sendMessage(AnimalRP.mm.deserialize("<red>You are already in progress."));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +169,7 @@ public class SexCommand implements CommandExecutor {
|
||||||
as.setGravity(false);
|
as.setGravity(false);
|
||||||
as.setHeadPose(new EulerAngle(0.15, 0, 0));
|
as.setHeadPose(new EulerAngle(0.15, 0, 0));
|
||||||
as.setInvulnerable(true);
|
as.setInvulnerable(true);
|
||||||
|
|
||||||
as.addEquipmentLock(EquipmentSlot.HEAD, LockType.ADDING);
|
as.addEquipmentLock(EquipmentSlot.HEAD, LockType.ADDING);
|
||||||
as.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING);
|
as.addEquipmentLock(EquipmentSlot.CHEST, LockType.ADDING);
|
||||||
as.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING);
|
as.addEquipmentLock(EquipmentSlot.FEET, LockType.ADDING);
|
||||||
|
@ -227,5 +183,55 @@ public class SexCommand implements CommandExecutor {
|
||||||
SexCommand.models.put(player.getUniqueId(), new SexModel(as, yaw, player.getLocation()));
|
SexCommand.models.put(player.getUniqueId(), new SexModel(as, yaw, player.getLocation()));
|
||||||
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
src/main/java/lv/pi/animalrp/listeners/PlayerLeave.java
Normal file
19
src/main/java/lv/pi/animalrp/listeners/PlayerLeave.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue