Fix typos

This commit is contained in:
fullwall 2015-09-11 20:33:57 +08:00
parent a61479f669
commit 3950b273a5
2 changed files with 59 additions and 55 deletions

View File

@ -4,6 +4,16 @@ import java.io.IOException;
import java.net.Socket;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
import com.google.common.base.Preconditions;
import com.mojang.authlib.GameProfile;
@ -45,16 +55,6 @@ import net.minecraft.server.v1_8_R3.PlayerInteractManager;
import net.minecraft.server.v1_8_R3.WorldServer;
import net.minecraft.server.v1_8_R3.WorldSettings.EnumGamemode;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.util.Vector;
public class EntityHumanNPC extends EntityPlayer implements NPCHolder, SkinnableEntity {
private PlayerControllerJump controllerJump;
private PlayerControllerLook controllerLook;
@ -67,7 +67,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
private final SkinPacketTracker skinTracker;
public EntityHumanNPC(MinecraftServer minecraftServer, WorldServer world, GameProfile gameProfile,
PlayerInteractManager playerInteractManager, NPC npc) {
PlayerInteractManager playerInteractManager, NPC npc) {
super(minecraftServer, world, gameProfile, playerInteractManager);
this.npc = (CitizensNPC) npc;
@ -75,8 +75,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
skinTracker = new SkinPacketTracker(this);
playerInteractManager.setGameMode(EnumGamemode.SURVIVAL);
initialise(minecraftServer);
}
else {
} else {
skinTracker = null;
}
}
@ -196,11 +195,6 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
return npc;
}
@Override
public SkinPacketTracker getSkinTracker() {
return skinTracker;
}
@Override
public String getSkinName() {
@ -214,11 +208,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
}
@Override
public void setSkinName(String name) {
Preconditions.checkNotNull(name);
npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, name.toLowerCase());
skinTracker.notifySkinChange();
public SkinPacketTracker getSkinTracker() {
return skinTracker;
}
private void initialise(MinecraftServer minecraftServer) {
@ -287,6 +278,14 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
controllerJump.a();
}
@Override
public void setSkinName(String name) {
Preconditions.checkNotNull(name);
npc.data().setPersistent(NPC.PLAYER_SKIN_UUID_METADATA, name.toLowerCase());
skinTracker.notifySkinChange();
}
public void setTargetLook(Entity target, float yawOffset, float renderOffset) {
controllerLook.a(target, yawOffset, renderOffset);
}
@ -352,6 +351,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
for (int i = 0; i < 5; i++) {
packets[i] = new PacketPlayOutEntityEquipment(getId(), i, getEquipment(i));
}
boolean removeFromPlayerList = npc.data().get("removefromplayerlist",
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), removeFromPlayerList);
NMS.sendPacketsNearby(getBukkitEntity(), current, packets);
}
@ -372,6 +373,11 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
npc.getTrait(Inventory.class);
}
@Override
public Player getBukkitEntity() {
return this;
}
@Override
public EntityHumanNPC getHandle() {
return (EntityHumanNPC) this.entity;
@ -387,6 +393,16 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
return npc;
}
@Override
public String getSkinName() {
return ((SkinnableEntity) this.entity).getSkinName();
}
@Override
public SkinPacketTracker getSkinTracker() {
return ((SkinnableEntity) this.entity).getSkinTracker();
}
@Override
public boolean hasMetadata(String metadataKey) {
return cserver.getEntityMetadata().hasMetadata(this, metadataKey);
@ -406,24 +422,9 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable
cserver.getEntityMetadata().setMetadata(this, metadataKey, newMetadataValue);
}
@Override
public SkinPacketTracker getSkinTracker() {
return ((SkinnableEntity)this.entity).getSkinTracker();
}
@Override
public Player getBukkitEntity() {
return this;
}
@Override
public String getSkinName() {
return ((SkinnableEntity)this.entity).getSkinName();
}
@Override
public void setSkinName(String name) {
((SkinnableEntity)this.entity).setSkinName(name);
((SkinnableEntity) this.entity).setSkinName(name);
}
}

View File

@ -3,18 +3,6 @@ package net.citizensnpcs.npc.entity;
import java.util.UUID;
import java.util.regex.Pattern;
import com.mojang.authlib.GameProfile;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.npc.AbstractEntityController;
import net.citizensnpcs.npc.skin.Skin;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.util.NMS;
import net.minecraft.server.v1_8_R3.PlayerInteractManager;
import net.minecraft.server.v1_8_R3.WorldServer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -24,6 +12,19 @@ import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import com.mojang.authlib.GameProfile;
import net.citizensnpcs.Settings.Setting;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.Colorizer;
import net.citizensnpcs.npc.AbstractEntityController;
import net.citizensnpcs.npc.skin.Skin;
import net.citizensnpcs.npc.skin.SkinnableEntity;
import net.citizensnpcs.util.NMS;
import net.minecraft.server.v1_8_R3.PlayerInteractManager;
import net.minecraft.server.v1_8_R3.WorldServer;
public class HumanController extends AbstractEntityController {
public HumanController() {
super();
@ -77,7 +78,7 @@ public class HumanController extends AbstractEntityController {
}
GameProfile profile = new GameProfile(uuid, coloredName);
final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
new PlayerInteractManager(nmsWorld), npc);
@ -92,9 +93,11 @@ public class HumanController extends AbstractEntityController {
@Override
public void run() {
if (getBukkitEntity() == null || !getBukkitEntity().isValid())
return;
boolean removeFromPlayerList = npc.data().get("removefromplayerlist", Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
NMS.addOrRemoveFromPlayerList(getBukkitEntity(), npc.data().get("removefromplayerlist", removeFromPlayerList));
return;
boolean removeFromPlayerList = npc.data().get("removefromplayerlist",
Setting.REMOVE_PLAYERS_FROM_PLAYER_LIST.asBoolean());
NMS.addOrRemoveFromPlayerList(getBukkitEntity(),
npc.data().get("removefromplayerlist", removeFromPlayerList));
if (prefixCapture != null) {
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
String teamName = UUID.randomUUID().toString().substring(0, 16);