mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-26 20:53:08 +00:00
Added line support for ICustomNpc
This commit is contained in:
1 parent
8fe2bb89ea
commit
eed9dbb92e
5 files changed
+104
-20
No files matched your search
@@ -2,9 +2,11 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import noppes.npcs.api.entity.IEntityLivingBase;
|
||||
import noppes.npcs.api.handler.data.ILine;
|
||||
|
||||
|
||||
public class Line {
|
||||
public class Line implements ILine {
|
||||
|
||||
public Line(){
|
||||
|
||||
@@ -17,21 +19,55 @@ public class Line {
|
||||
public String sound = "";
|
||||
public boolean hideText = false;
|
||||
|
||||
public Line copy() {
|
||||
public ILine copy() {
|
||||
Line line = new Line(text);
|
||||
line.sound = sound;
|
||||
line.hideText = hideText;
|
||||
return line;
|
||||
}
|
||||
|
||||
public Line formatTarget(EntityLivingBase entity) {
|
||||
public ILine formatTarget(EntityLivingBase entity) {
|
||||
if(entity == null)
|
||||
return this;
|
||||
Line line = copy();
|
||||
Line line = (Line) copy();
|
||||
if(entity instanceof EntityPlayer)
|
||||
line.text = line.text.replace("@target", ((EntityPlayer) entity).getDisplayName());
|
||||
else
|
||||
line.text = line.text.replace("@target", entity.getCommandSenderName());
|
||||
return line;
|
||||
}
|
||||
|
||||
public ILine formatTarget(IEntityLivingBase entityLivingBase) {
|
||||
return this.formatTarget(entityLivingBase.getMCEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSound() {
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSound(String sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideText(boolean hide) {
|
||||
this.hideText = hide;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hideText() {
|
||||
return this.hideText;
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,15 @@ package noppes.npcs.controllers.data;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.api.handler.data.ILine;
|
||||
import noppes.npcs.api.handler.data.ILines;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class Lines {
|
||||
public class Lines implements ILines {
|
||||
private static final Random random = new Random();
|
||||
private int lastLine = -1;
|
||||
|
||||
@@ -49,7 +51,11 @@ public class Lines {
|
||||
lines = map;
|
||||
}
|
||||
|
||||
public Line getLine(boolean isRandom) {
|
||||
public ILine createLine(String text) {
|
||||
return new Line(text);
|
||||
}
|
||||
|
||||
public ILine getLine(boolean isRandom) {
|
||||
if(lines.isEmpty())
|
||||
return null;
|
||||
if(isRandom){
|
||||
@@ -66,7 +72,27 @@ public class Lines {
|
||||
}
|
||||
}
|
||||
|
||||
public ILine getLine(int lineIndex) {
|
||||
return lines.get(lineIndex);
|
||||
}
|
||||
|
||||
public void setLine(int lineIndex, ILine line) {
|
||||
lines.put(lineIndex, (Line) line);
|
||||
}
|
||||
|
||||
public void removeLine(int lineIndex) {
|
||||
lines.remove(lineIndex);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
lines.clear();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return lines.isEmpty();
|
||||
}
|
||||
|
||||
public Integer[] getKeys() {
|
||||
return lines.keySet().toArray(new Integer[0]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user