Skip to content

Commit

Permalink
Add config comments, remove subplugins, remove NPCEnderTeleportEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Mar 14, 2023
1 parent 6a19f19 commit e6f8a47
Show file tree
Hide file tree
Showing 684 changed files with 1,251 additions and 3,340 deletions.
30 changes: 0 additions & 30 deletions main/src/main/java/net/citizensnpcs/Citizens.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,33 +203,6 @@ private void despawnNPCs(boolean save) {
}
}

private void enableSubPlugins() {
File root = new File(getDataFolder(), Setting.SUBPLUGIN_FOLDER.asString());
if (!root.exists() || !root.isDirectory())
return;
File[] files = root.listFiles();
for (File file : files) {
Plugin plugin;
try {
plugin = Bukkit.getPluginManager().loadPlugin(file);
} catch (Exception e) {
continue;
}
if (plugin == null)
continue;
// code beneath modified from CraftServer
try {
Messaging.logTr(Messages.LOADING_SUB_PLUGIN, plugin.getDescription().getFullName());
plugin.onLoad();
} catch (Throwable ex) {
Messaging.severeTr(Messages.ERROR_INITALISING_SUB_PLUGIN, ex.getMessage(),
plugin.getDescription().getFullName());
ex.printStackTrace();
}
}
NMS.loadPlugins();
}

@Override
public CommandManager getCommandManager() {
return commands;
Expand Down Expand Up @@ -457,7 +430,6 @@ public void onEnable() {
setupEconomy();

registerCommands();
enableSubPlugins();
NMS.load(commands);
Template.migrate();
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Expand Down Expand Up @@ -622,8 +594,6 @@ public void run() {

Messaging.logTr(Messages.NUM_LOADED_NOTIFICATION, Iterables.size(npcRegistry), "?");
startMetrics();
System.out.println(Setting.SAVE_TASK_DELAY.asTicks());
System.out.println(Setting.SAVE_TASK_DELAY.asTicks() / 20);
scheduleSaveTask(Setting.SAVE_TASK_DELAY.asTicks());
Bukkit.getPluginManager().callEvent(new CitizensEnableEvent());
new PlayerUpdateTask().runTaskTimer(Citizens.this, 0, 1);
Expand Down
252 changes: 170 additions & 82 deletions main/src/main/java/net/citizensnpcs/Settings.java

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions main/src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -2935,8 +2935,6 @@ public void speak(CommandContext args, CommandSender sender, NPC npc, @Flag("typ
permission = "citizens.npc.speed")
public void speed(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
float newSpeed = (float) Math.abs(args.getDouble(1));
if (newSpeed >= Setting.MAX_SPEED.asDouble())
throw new CommandException(Messages.SPEED_MODIFIER_ABOVE_LIMIT);
npc.getNavigator().getDefaultParameters().speedModifier(newSpeed);

Messaging.sendTr(sender, Messages.SPEED_MODIFIER_SET, newSpeed);
Expand Down
12 changes: 8 additions & 4 deletions main/src/main/java/net/citizensnpcs/trait/BoundingBoxTrait.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.BoundingBox;
import net.citizensnpcs.api.util.EntityDim;
import net.citizensnpcs.util.NMS;

@TraitName("boundingbox")
public class BoundingBoxTrait extends Trait implements Supplier<BoundingBox> {
Expand All @@ -31,15 +32,18 @@ public BoundingBoxTrait() {
public BoundingBox get() {
Location location = npc.getEntity().getLocation();
if (function != null) {
return function.apply(getAdjustedBoundingBox()).add(location);
BoundingBox bb = function.apply(getAdjustedBoundingBox());
NMS.setDimensions(npc.getEntity(), bb.toDimensions());
return bb.add(location);
}
EntityDim dim = getAdjustedBoundingBox();
NMS.setDimensions(npc.getEntity(), dim);
return new BoundingBox(location.getX() - dim.width / 2, location.getY(), location.getZ() - dim.width / 2,
location.getX() + dim.width / 2, location.getY() + dim.height, location.getZ() + dim.width / 2);
}

public EntityDim getAdjustedBoundingBox() {
EntityDim desired = base.clone();
EntityDim desired = base;
if (scale != -1) {
desired = desired.mul(scale);
}
Expand Down Expand Up @@ -70,8 +74,8 @@ public void setHeight(float height) {
this.height = height;
}

public void setScale(float s) {
this.scale = s;
public void setScale(float scale) {
this.scale = scale;
}

public void setWidth(float width) {
Expand Down
6 changes: 4 additions & 2 deletions main/src/main/java/net/citizensnpcs/trait/HologramTrait.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ public void clear() {
private NPC createHologram(String line, double heightOffset) {
NPC hologramNPC = registry.createNPC(EntityType.ARMOR_STAND, line);
hologramNPC.getOrAddTrait(ArmorStandTrait.class).setAsHelperEntityWithName(npc);
if (Setting.PACKET_HOLOGRAMS.asBoolean()) {
hologramNPC.addTrait(PacketNPC.class);
}
hologramNPC.spawn(currentLoc.clone().add(0,
getEntityHeight()
+ (direction == HologramDirection.BOTTOM_UP ? heightOffset : getMaxHeight() - heightOffset),
Expand Down Expand Up @@ -269,8 +272,7 @@ public void run() {
|| currentLoc.distance(npc.getStoredLocation()) >= 0.001 || lastNameplateVisible != nameplateVisible
|| Math.abs(lastEntityHeight - getEntityHeight()) >= 0.05;
boolean updateName = false;
if (t++ >= Setting.HOLOGRAM_UPDATE_RATE.asTicks()
+ Util.getFastRandom().nextInt(3) /* add some jitter */) {
if (t++ >= Setting.HOLOGRAM_UPDATE_RATE.asTicks() + Util.getFastRandom().nextInt(3) /* add some jitter */) {
t = 0;
updateName = true;
}
Expand Down
2 changes: 0 additions & 2 deletions main/src/main/java/net/citizensnpcs/util/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public class Messages {
public static final String ERROR_GETTING_FIELD = "citizens.nms-errors.getting-field";
public static final String ERROR_GETTING_ID_MAPPING = "citizens.nms-errors.getting-id-mapping";
public static final String ERROR_GETTING_METHOD = "citizens.nms-errors.getting-method";
public static final String ERROR_INITALISING_SUB_PLUGIN = "citizens.sub-plugins.error-on-load";
public static final String ERROR_RESTORING_GOALS = "citizens.nms-errors.restoring-goals";
public static final String ERROR_SETTING_LOOKCLOSE_RANGE = "citizens.commands.npc.lookclose.error-random-range";
public static final String ERROR_SETTING_SKIN_URL = "citizens.commands.npc.skin.error-setting-url";
Expand Down Expand Up @@ -216,7 +215,6 @@ public class Messages {
public static final String LOAD_TASK_NOT_SCHEDULED = "citizens.load-task-error";
public static final String LOAD_UNKNOWN_NPC_TYPE = "citizens.notifications.unknown-npc-type";
public static final String LOADED_ECONOMY = "citizens.economy.loaded";
public static final String LOADING_SUB_PLUGIN = "citizens.sub-plugins.load";
public static final String LOCALE_NOTIFICATION = "citizens.notifications.locale";
public static final String LOOKCLOSE_DISABLE_WHEN_NAVIGATING = "citizens.commands.npc.lookclose.disable-when-navigating";
public static final String LOOKCLOSE_ENABLE_WHEN_NAVIGATING = "citizens.commands.npc.lookclose.enable-when-navigating";
Expand Down
17 changes: 0 additions & 17 deletions main/src/main/java/net/citizensnpcs/util/NMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import net.citizensnpcs.api.astar.pathfinder.SwimmingExaminer;
import net.citizensnpcs.api.command.CommandManager;
import net.citizensnpcs.api.command.exception.CommandException;
import net.citizensnpcs.api.event.NPCEnderTeleportEvent;
import net.citizensnpcs.api.event.NPCKnockbackEvent;
import net.citizensnpcs.api.jnbt.CompoundTag;
import net.citizensnpcs.api.npc.BlockBreaker;
Expand Down Expand Up @@ -95,18 +94,6 @@ public static EntityPacketTracker createPacketTracker(Entity entity) {
return BRIDGE.createPacketTracker(entity);
}

public static void enderTeleportTo(NPC npc, Runnable cb) {
if (npc == null) {
cb.run();
return;
}
NPCEnderTeleportEvent event = new NPCEnderTeleportEvent(npc);
Bukkit.getPluginManager().callEvent(event);
if (!event.isCancelled()) {
cb.run();
}
}

public static GameProfile fillProfileProperties(GameProfile profile, boolean requireSecure) throws Throwable {
return BRIDGE.fillProfileProperties(profile, requireSecure);
}
Expand Down Expand Up @@ -518,10 +505,6 @@ public static void loadBridge(String rev) throws Exception {
.newInstance();
}

public static void loadPlugins() {
BRIDGE.loadPlugins();
}

public static void look(Entity entity, float yaw, float pitch) {
BRIDGE.look(entity, yaw, pitch);
}
Expand Down
2 changes: 0 additions & 2 deletions main/src/main/java/net/citizensnpcs/util/NMSBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ public default Object getBossBar(Entity entity) {

public void load(CommandManager commands);

public void loadPlugins();

public void look(Entity from, Entity to);

public void look(Entity entity, float yaw, float pitch);
Expand Down
4 changes: 4 additions & 0 deletions main/src/main/java/net/citizensnpcs/util/Quaternion.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public static Quaternion fromEuler(double x, double y, double z) {
c1c2 * c3 - s1s2 * s3);
}

public static Quaternion fromEuler(EulerAngle angle) {
return fromEuler(angle.getX(), angle.getY(), angle.getZ());
}

public static Quaternion nlerp(Quaternion a, Quaternion b, double t) {
if (a.dot(b) < 0) {
b = b.mul(-1);
Expand Down
Loading

0 comments on commit e6f8a47

Please sign in to comment.