mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-29 12:37:37 +01:00
Bugfix
This commit is contained in:
parent
07edf17dae
commit
080e652124
@ -8,6 +8,8 @@ import java.util.Iterator;
|
||||
import net.citizensnpcs.Settings.Setting;
|
||||
import net.citizensnpcs.api.CitizensAPI;
|
||||
import net.citizensnpcs.api.CitizensPlugin;
|
||||
import net.citizensnpcs.api.event.CitizensDisableEvent;
|
||||
import net.citizensnpcs.api.event.CitizensEnableEvent;
|
||||
import net.citizensnpcs.api.event.CitizensReloadEvent;
|
||||
import net.citizensnpcs.api.exception.NPCLoadException;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
@ -225,6 +227,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
startMetrics();
|
||||
enableSubPlugins();
|
||||
scheduleSaveTask(Setting.SAVE_TASK_DELAY.asInt());
|
||||
Bukkit.getPluginManager().callEvent(new CitizensEnableEvent());
|
||||
}
|
||||
}) == -1) {
|
||||
Messaging.severe("NPC load task couldn't be scheduled - disabling...");
|
||||
|
@ -1,18 +0,0 @@
|
||||
package net.citizensnpcs;
|
||||
|
||||
import net.citizensnpcs.api.event.CitizensEvent;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class CitizensDisableEvent extends CitizensEvent {
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -89,7 +89,7 @@ public class CommandContext {
|
||||
}
|
||||
List<String> copied = Lists.newArrayList();
|
||||
for (String arg : args) {
|
||||
if (arg == null || arg.isEmpty())
|
||||
if (arg == null || arg.trim().isEmpty())
|
||||
continue;
|
||||
copied.add(arg);
|
||||
}
|
||||
@ -178,7 +178,7 @@ public class CommandContext {
|
||||
StringBuilder buffer = new StringBuilder(args[initialIndex]);
|
||||
for (int i = initialIndex + 1; i < args.length; i++)
|
||||
buffer.append(delimiter).append(args[i]);
|
||||
return buffer.toString();
|
||||
return buffer.toString().trim();
|
||||
}
|
||||
|
||||
public String[] getPaddedSlice(int index, int padding) {
|
||||
|
@ -22,8 +22,10 @@ public class AdminCommands {
|
||||
|
||||
@Command(aliases = { "citizens" }, desc = "Show basic plugin information", max = 0, permission = "admin")
|
||||
public void citizens(CommandContext args, CommandSender player, NPC npc) {
|
||||
Messaging.send(player,
|
||||
" " + StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
|
||||
Messaging.send(
|
||||
player,
|
||||
" "
|
||||
+ StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
|
||||
Messaging.send(player, " <7>-- <c>Written by fullwall and aPunch");
|
||||
Messaging.send(player, " <7>-- <c>Source: http://github.com/CitizensDev");
|
||||
Messaging.send(player, " <7>-- <c>Website: " + plugin.getDescription().getWebsite());
|
||||
|
@ -202,11 +202,13 @@ public class NPCCommands {
|
||||
}
|
||||
}
|
||||
if (args.hasValueFlag("trait")) {
|
||||
msg += " with traits ";
|
||||
Iterable<String> parts = Splitter.on(",").trimResults().split(args.getFlag("trait"));
|
||||
for (String tr : parts) {
|
||||
Class<? extends Trait> clazz = CitizensAPI.getTraitFactory().getTraitClass(tr);
|
||||
if (clazz != null)
|
||||
if (clazz != null) {
|
||||
npc.addTrait(clazz);
|
||||
}
|
||||
}
|
||||
msg += " with the specified traits";
|
||||
}
|
||||
@ -374,6 +376,12 @@ public class NPCCommands {
|
||||
Messaging.send(sender, StringHelper.wrapHeader(npc.getName()));
|
||||
Messaging.send(sender, " <a>ID: <e>" + npc.getId());
|
||||
Messaging.send(sender, " <a>Type: <e>" + npc.getTrait(MobType.class).getType());
|
||||
Messaging.send(sender, " <a>Traits<e>");
|
||||
for (Trait trait : npc.getTraits()) {
|
||||
if (CitizensAPI.getTraitFactory().isInternalTrait(trait))
|
||||
continue;
|
||||
Messaging.send(sender, " <e>- <a>" + trait.getName() + "<e>");
|
||||
}
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
@ -104,7 +104,12 @@ public class CitizensTraitFactory implements TraitFactory {
|
||||
|
||||
@Override
|
||||
public Class<? extends Trait> getTraitClass(String name) {
|
||||
return registered.get(name);
|
||||
return registered.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInternalTrait(Trait trait) {
|
||||
return INTERNAL_TRAITS.contains(trait.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,6 +41,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
|
||||
netServerHandler = new EmptyNetHandler(minecraftServer, netMgr, this);
|
||||
netMgr.a(netServerHandler);
|
||||
W = STEP_HEIGHT; // fix moving up slabs and steps
|
||||
|
||||
try {
|
||||
socket.close();
|
||||
@ -89,7 +90,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
navigation.e();
|
||||
moveOnCurrentHeading();
|
||||
} else if (motX != 0 || motZ != 0 || motY != 0) {
|
||||
// a(0, 0);
|
||||
// e(0, 0); is this necessary? it does gravity/controllable but
|
||||
// sometimes players sink into the ground
|
||||
}
|
||||
if (noDamageTicks > 0)
|
||||
--noDamageTicks;
|
||||
@ -101,7 +103,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
getControllerLook().a();
|
||||
getControllerJump().b();
|
||||
|
||||
// taken from EntityLiving
|
||||
// taken from EntityLiving update method
|
||||
if (bu) {
|
||||
boolean inLiquid = H() || J();
|
||||
if (inLiquid) {
|
||||
@ -114,10 +116,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
||||
} else {
|
||||
bE = 0;
|
||||
}
|
||||
|
||||
br *= 0.98F;
|
||||
bs *= 0.98F;
|
||||
bt *= 0.9F;
|
||||
|
||||
float prev = aG;
|
||||
aG *= bs();
|
||||
e(br, bs);
|
||||
as = yaw;
|
||||
e(br, bs); // movement method
|
||||
aG = prev;
|
||||
as = yaw; // update head yaw to match entity yaw
|
||||
}
|
||||
|
||||
private static final float STEP_HEIGHT = 1F;
|
||||
}
|
Loading…
Reference in New Issue
Block a user