mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-01 14:08:08 +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.Settings.Setting;
|
||||||
import net.citizensnpcs.api.CitizensAPI;
|
import net.citizensnpcs.api.CitizensAPI;
|
||||||
import net.citizensnpcs.api.CitizensPlugin;
|
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.event.CitizensReloadEvent;
|
||||||
import net.citizensnpcs.api.exception.NPCLoadException;
|
import net.citizensnpcs.api.exception.NPCLoadException;
|
||||||
import net.citizensnpcs.api.npc.NPC;
|
import net.citizensnpcs.api.npc.NPC;
|
||||||
@ -225,6 +227,7 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
|||||||
startMetrics();
|
startMetrics();
|
||||||
enableSubPlugins();
|
enableSubPlugins();
|
||||||
scheduleSaveTask(Setting.SAVE_TASK_DELAY.asInt());
|
scheduleSaveTask(Setting.SAVE_TASK_DELAY.asInt());
|
||||||
|
Bukkit.getPluginManager().callEvent(new CitizensEnableEvent());
|
||||||
}
|
}
|
||||||
}) == -1) {
|
}) == -1) {
|
||||||
Messaging.severe("NPC load task couldn't be scheduled - disabling...");
|
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();
|
List<String> copied = Lists.newArrayList();
|
||||||
for (String arg : args) {
|
for (String arg : args) {
|
||||||
if (arg == null || arg.isEmpty())
|
if (arg == null || arg.trim().isEmpty())
|
||||||
continue;
|
continue;
|
||||||
copied.add(arg);
|
copied.add(arg);
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ public class CommandContext {
|
|||||||
StringBuilder buffer = new StringBuilder(args[initialIndex]);
|
StringBuilder buffer = new StringBuilder(args[initialIndex]);
|
||||||
for (int i = initialIndex + 1; i < args.length; i++)
|
for (int i = initialIndex + 1; i < args.length; i++)
|
||||||
buffer.append(delimiter).append(args[i]);
|
buffer.append(delimiter).append(args[i]);
|
||||||
return buffer.toString();
|
return buffer.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getPaddedSlice(int index, int padding) {
|
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")
|
@Command(aliases = { "citizens" }, desc = "Show basic plugin information", max = 0, permission = "admin")
|
||||||
public void citizens(CommandContext args, CommandSender player, NPC npc) {
|
public void citizens(CommandContext args, CommandSender player, NPC npc) {
|
||||||
Messaging.send(player,
|
Messaging.send(
|
||||||
" " + StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
|
player,
|
||||||
|
" "
|
||||||
|
+ StringHelper.wrapHeader("<e>Citizens v" + plugin.getDescription().getVersion()));
|
||||||
Messaging.send(player, " <7>-- <c>Written by fullwall and aPunch");
|
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>Source: http://github.com/CitizensDev");
|
||||||
Messaging.send(player, " <7>-- <c>Website: " + plugin.getDescription().getWebsite());
|
Messaging.send(player, " <7>-- <c>Website: " + plugin.getDescription().getWebsite());
|
||||||
|
@ -202,11 +202,13 @@ public class NPCCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.hasValueFlag("trait")) {
|
if (args.hasValueFlag("trait")) {
|
||||||
|
msg += " with traits ";
|
||||||
Iterable<String> parts = Splitter.on(",").trimResults().split(args.getFlag("trait"));
|
Iterable<String> parts = Splitter.on(",").trimResults().split(args.getFlag("trait"));
|
||||||
for (String tr : parts) {
|
for (String tr : parts) {
|
||||||
Class<? extends Trait> clazz = CitizensAPI.getTraitFactory().getTraitClass(tr);
|
Class<? extends Trait> clazz = CitizensAPI.getTraitFactory().getTraitClass(tr);
|
||||||
if (clazz != null)
|
if (clazz != null) {
|
||||||
npc.addTrait(clazz);
|
npc.addTrait(clazz);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
msg += " with the specified traits";
|
msg += " with the specified traits";
|
||||||
}
|
}
|
||||||
@ -374,6 +376,12 @@ public class NPCCommands {
|
|||||||
Messaging.send(sender, StringHelper.wrapHeader(npc.getName()));
|
Messaging.send(sender, StringHelper.wrapHeader(npc.getName()));
|
||||||
Messaging.send(sender, " <a>ID: <e>" + npc.getId());
|
Messaging.send(sender, " <a>ID: <e>" + npc.getId());
|
||||||
Messaging.send(sender, " <a>Type: <e>" + npc.getTrait(MobType.class).getType());
|
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(
|
@Command(
|
||||||
|
@ -104,7 +104,12 @@ public class CitizensTraitFactory implements TraitFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<? extends Trait> getTraitClass(String name) {
|
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
|
@Override
|
||||||
|
@ -41,6 +41,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
|
|
||||||
netServerHandler = new EmptyNetHandler(minecraftServer, netMgr, this);
|
netServerHandler = new EmptyNetHandler(minecraftServer, netMgr, this);
|
||||||
netMgr.a(netServerHandler);
|
netMgr.a(netServerHandler);
|
||||||
|
W = STEP_HEIGHT; // fix moving up slabs and steps
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
@ -89,7 +90,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
navigation.e();
|
navigation.e();
|
||||||
moveOnCurrentHeading();
|
moveOnCurrentHeading();
|
||||||
} else if (motX != 0 || motZ != 0 || motY != 0) {
|
} 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)
|
if (noDamageTicks > 0)
|
||||||
--noDamageTicks;
|
--noDamageTicks;
|
||||||
@ -101,7 +103,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
getControllerLook().a();
|
getControllerLook().a();
|
||||||
getControllerJump().b();
|
getControllerJump().b();
|
||||||
|
|
||||||
// taken from EntityLiving
|
// taken from EntityLiving update method
|
||||||
if (bu) {
|
if (bu) {
|
||||||
boolean inLiquid = H() || J();
|
boolean inLiquid = H() || J();
|
||||||
if (inLiquid) {
|
if (inLiquid) {
|
||||||
@ -114,10 +116,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
|
|||||||
} else {
|
} else {
|
||||||
bE = 0;
|
bE = 0;
|
||||||
}
|
}
|
||||||
|
br *= 0.98F;
|
||||||
bs *= 0.98F;
|
bs *= 0.98F;
|
||||||
|
bt *= 0.9F;
|
||||||
|
|
||||||
|
float prev = aG;
|
||||||
aG *= bs();
|
aG *= bs();
|
||||||
e(br, bs);
|
e(br, bs); // movement method
|
||||||
as = yaw;
|
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