Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Sep 11, 2015
1 parent 72ba146 commit 76fd4c4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 52 deletions.
79 changes: 40 additions & 39 deletions src/main/java/net/citizensnpcs/npc/entity/EntityHumanNPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
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;

Expand Down Expand Up @@ -45,16 +55,6 @@
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;
Expand All @@ -67,16 +67,15 @@ 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;
if (npc != null) {
skinTracker = new SkinPacketTracker(this);
playerInteractManager.setGameMode(EnumGamemode.SURVIVAL);
initialise(minecraftServer);
}
else {
} else {
skinTracker = null;
}
}
Expand Down Expand Up @@ -196,11 +195,6 @@ public NPC getNPC() {
return npc;
}

@Override
public SkinPacketTracker getSkinTracker() {
return skinTracker;
}

@Override
public String getSkinName() {

Expand All @@ -214,11 +208,8 @@ public String getSkinName() {
}

@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) {
Expand Down Expand Up @@ -287,6 +278,14 @@ public void setShouldJump() {
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);
}
Expand Down Expand Up @@ -352,6 +351,8 @@ private void updatePackets(boolean navigating) {
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);
}
Expand All @@ -372,6 +373,11 @@ private PlayerNPC(EntityHumanNPC entity) {
npc.getTrait(Inventory.class);
}

@Override
public Player getBukkitEntity() {
return this;
}

@Override
public EntityHumanNPC getHandle() {
return (EntityHumanNPC) this.entity;
Expand All @@ -387,6 +393,16 @@ public NPC getNPC() {
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);
Expand All @@ -406,24 +422,9 @@ public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
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);
}
}

Expand Down
29 changes: 16 additions & 13 deletions src/main/java/net/citizensnpcs/npc/entity/HumanController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
import java.util.UUID;
import java.util.regex.Pattern;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Entity;
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;
Expand All @@ -15,15 +25,6 @@
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;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

public class HumanController extends AbstractEntityController {
public HumanController() {
super();
Expand Down Expand Up @@ -77,7 +78,7 @@ protected Entity createEntity(final Location at, final NPC npc) {
}

GameProfile profile = new GameProfile(uuid, coloredName);

final EntityHumanNPC handle = new EntityHumanNPC(nmsWorld.getServer().getServer(), nmsWorld, profile,
new PlayerInteractManager(nmsWorld), npc);

Expand All @@ -92,9 +93,11 @@ protected Entity createEntity(final Location at, final NPC npc) {
@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);
Expand Down

0 comments on commit 76fd4c4

Please sign in to comment.