mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-29 22:23:59 +01:00
Add sittable support to /npc sitting, disable array pooling for now
This commit is contained in:
parent
ddc938a38c
commit
64b200837d
@ -32,6 +32,7 @@ import com.google.common.io.Files;
|
|||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
||||||
|
|
||||||
|
import ch.ethz.globis.phtree.PhTreeHelper;
|
||||||
import net.byteflux.libby.BukkitLibraryManager;
|
import net.byteflux.libby.BukkitLibraryManager;
|
||||||
import net.byteflux.libby.Library;
|
import net.byteflux.libby.Library;
|
||||||
import net.byteflux.libby.LibraryManager;
|
import net.byteflux.libby.LibraryManager;
|
||||||
@ -337,6 +338,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
lib.loadLibrary(Library.builder().groupId("org{}joml").artifactId("joml").version("1.10.5").build());
|
lib.loadLibrary(Library.builder().groupId("org{}joml").artifactId("joml").version("1.10.5").build());
|
||||||
}
|
}
|
||||||
|
PhTreeHelper.enablePooling(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2670,7 +2670,7 @@ public class NPCCommands {
|
|||||||
at = npc.getStoredLocation();
|
at = npc.getStoredLocation();
|
||||||
}
|
}
|
||||||
trait.setSitting(at);
|
trait.setSitting(at);
|
||||||
Messaging.sendTr(sender, Messages.SITTING_SET, npc.getName(), at);
|
Messaging.sendTr(sender, Messages.SITTING_SET, npc.getName(), Util.prettyPrintLocation(at));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
|
@ -174,19 +174,11 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
velocity.setX(motX).setY(motY).setZ(motZ).multiply(parameters.speed());
|
velocity.setX(motX).setY(motY).setZ(motZ).multiply(parameters.speed());
|
||||||
npc.getEntity().setVelocity(velocity);
|
npc.getEntity().setVelocity(velocity);
|
||||||
|
|
||||||
float targetYaw = (float) (Math.toDegrees(Math.atan2(motZ, motX))) - 90.0F;
|
|
||||||
float normalisedTargetYaw = (targetYaw - current.getYaw()) % 360;
|
|
||||||
if (normalisedTargetYaw >= 180.0F) {
|
|
||||||
normalisedTargetYaw -= 360.0F;
|
|
||||||
}
|
|
||||||
if (normalisedTargetYaw < -180.0F) {
|
|
||||||
normalisedTargetYaw += 360.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (npc.getEntity().getType() != EntityType.ENDER_DRAGON) {
|
if (npc.getEntity().getType() != EntityType.ENDER_DRAGON) {
|
||||||
NMS.setVerticalMovement(npc.getEntity(), 0.5);
|
NMS.setVerticalMovement(npc.getEntity(), 0.5);
|
||||||
Util.faceLocation(npc.getEntity(), centeredDest.toLocation(npc.getEntity().getWorld()));
|
Util.faceLocation(npc.getEntity(), centeredDest.toLocation(npc.getEntity().getWorld()));
|
||||||
}
|
}
|
||||||
|
|
||||||
plan.run(npc);
|
plan.run(npc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package net.citizensnpcs.trait;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Sittable;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
@ -29,6 +30,11 @@ public class SitTrait extends Trait {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDespawn() {
|
public void onDespawn() {
|
||||||
|
if (SUPPORT_SITTABLE && npc.getEntity() instanceof Sittable) {
|
||||||
|
((Sittable) npc.getEntity()).setSitting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (chair != null) {
|
if (chair != null) {
|
||||||
if (chair.getEntity() != null) {
|
if (chair.getEntity() != null) {
|
||||||
chair.getEntity().eject();
|
chair.getEntity().eject();
|
||||||
@ -48,6 +54,13 @@ public class SitTrait extends Trait {
|
|||||||
if (!npc.isSpawned() || !isSitting())
|
if (!npc.isSpawned() || !isSitting())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (SUPPORT_SITTABLE && npc.getEntity() instanceof Sittable) {
|
||||||
|
((Sittable) npc.getEntity()).setSitting(true);
|
||||||
|
if (npc.getEntity().getLocation().distance(sittingAt) > 0.05) {
|
||||||
|
npc.teleport(sittingAt, TeleportCause.PLUGIN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (chair == null) {
|
if (chair == null) {
|
||||||
NPCRegistry registry = CitizensAPI.getNamedNPCRegistry("SitRegistry");
|
NPCRegistry registry = CitizensAPI.getNamedNPCRegistry("SitRegistry");
|
||||||
if (registry == null) {
|
if (registry == null) {
|
||||||
@ -76,4 +89,13 @@ public class SitTrait extends Trait {
|
|||||||
onDespawn();
|
onDespawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean SUPPORT_SITTABLE = true;
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
Class.forName("org.bukkit.entity.Sittable");
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
SUPPORT_SITTABLE = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,8 @@ public class AnimationTriggerPrompt extends StringPrompt implements WaypointTrig
|
|||||||
at = CommandContext.parseLocation(
|
at = CommandContext.parseLocation(
|
||||||
context.getForWhom() instanceof Player ? ((Player) context.getForWhom()).getLocation() : null,
|
context.getForWhom() instanceof Player ? ((Player) context.getForWhom()).getLocation() : null,
|
||||||
input.replaceFirst("at ", ""));
|
input.replaceFirst("at ", ""));
|
||||||
|
Messaging.send((CommandSender) context.getForWhom(), Messages.WAYPOINT_TRIGGER_ANIMATION_AT_SET,
|
||||||
|
Util.prettyPrintLocation(at));
|
||||||
} catch (CommandException e) {
|
} catch (CommandException e) {
|
||||||
Messaging.send((CommandSender) context.getForWhom(), e.getMessage());
|
Messaging.send((CommandSender) context.getForWhom(), e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -457,6 +457,7 @@ public class Messages {
|
|||||||
public static final String WAYPOINT_TELEPORTING_ENABLED = "citizens.commands.waypoints.disableteleporting.enabled";
|
public static final String WAYPOINT_TELEPORTING_ENABLED = "citizens.commands.waypoints.disableteleporting.enabled";
|
||||||
public static final String WAYPOINT_TRIGGER_ADD_PROMPT = "citizens.editors.waypoints.triggers.add.prompt";
|
public static final String WAYPOINT_TRIGGER_ADD_PROMPT = "citizens.editors.waypoints.triggers.add.prompt";
|
||||||
public static final String WAYPOINT_TRIGGER_ADDED_SUCCESSFULLY = "citizens.editors.waypoints.triggers.add.added";
|
public static final String WAYPOINT_TRIGGER_ADDED_SUCCESSFULLY = "citizens.editors.waypoints.triggers.add.added";
|
||||||
|
public static final String WAYPOINT_TRIGGER_ANIMATION_AT_SET = "citizens.editors.waypoints.triggers.animation.at-set";
|
||||||
public static final String WAYPOINT_TRIGGER_CHAT_INVALID_RADIUS = "citizens.editors.waypoints.triggers.chat.invalid-radius";
|
public static final String WAYPOINT_TRIGGER_CHAT_INVALID_RADIUS = "citizens.editors.waypoints.triggers.chat.invalid-radius";
|
||||||
public static final String WAYPOINT_TRIGGER_CHAT_NO_RADIUS = "citizens.editors.waypoints.triggers.chat.missing-radius";
|
public static final String WAYPOINT_TRIGGER_CHAT_NO_RADIUS = "citizens.editors.waypoints.triggers.chat.missing-radius";
|
||||||
public static final String WAYPOINT_TRIGGER_EDITOR_EXIT = "citizens.editors.waypoints.triggers.main.exit";
|
public static final String WAYPOINT_TRIGGER_EDITOR_EXIT = "citizens.editors.waypoints.triggers.main.exit";
|
||||||
|
@ -431,6 +431,7 @@ citizens.editors.waypoints.triggers.add.added=Added waypoint trigger successfull
|
|||||||
citizens.editors.waypoints.triggers.add.invalid-trigger=Couldn''t create a trigger by the name [[{0}]].
|
citizens.editors.waypoints.triggers.add.invalid-trigger=Couldn''t create a trigger by the name [[{0}]].
|
||||||
citizens.editors.waypoints.triggers.add.prompt=Enter in a trigger name to add or type [[back]] to return to the edit prompt. Valid trigger names are {0}.
|
citizens.editors.waypoints.triggers.add.prompt=Enter in a trigger name to add or type [[back]] to return to the edit prompt. Valid trigger names are {0}.
|
||||||
citizens.editors.waypoints.triggers.animation.added=Animation [[{0}]] added.
|
citizens.editors.waypoints.triggers.animation.added=Animation [[{0}]] added.
|
||||||
|
citizens.editors.waypoints.triggers.animation.at-set=Animation location set to [[{0}]].
|
||||||
citizens.editors.waypoints.triggers.list=Current triggers are:{0}
|
citizens.editors.waypoints.triggers.list=Current triggers are:{0}
|
||||||
citizens.editors.waypoints.triggers.animation.prompt=Enter in animations to perform - valid animations are {0}.<br>[[at (x:y:z:world)]] optionally set a location to perform the animation at.<br>Type in [[finish]] to finish the animation trigger or [[back]] to return to the previous prompt.
|
citizens.editors.waypoints.triggers.animation.prompt=Enter in animations to perform - valid animations are {0}.<br>[[at (x:y:z:world)]] optionally set a location to perform the animation at.<br>Type in [[finish]] to finish the animation trigger or [[back]] to return to the previous prompt.
|
||||||
citizens.editors.waypoints.triggers.animation.invalid-animation=Invalid animation [[{0}]]. Valid animations are {1}.
|
citizens.editors.waypoints.triggers.animation.invalid-animation=Invalid animation [[{0}]]. Valid animations are {1}.
|
||||||
|
Loading…
Reference in New Issue
Block a user