mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 09:34:46 +00:00
Proper Reformating
This commit is contained in:
1 parent
ce75880aba
commit
180d257024
1179 files changed
+59847
-61583
No files matched your search
@@ -9,76 +9,75 @@ import noppes.npcs.NoppesStringUtils;
|
||||
import noppes.npcs.TextBlock;
|
||||
import noppes.npcs.controllers.data.Dialog;
|
||||
|
||||
public class TextBlockClient extends TextBlock{
|
||||
private ChatStyle style;
|
||||
public int color = 0xe0e0e0;
|
||||
public int titleColor = 0xe0e0e0;
|
||||
public int titlePos = 0;
|
||||
private String name;
|
||||
private ICommandSender sender;
|
||||
public class TextBlockClient extends TextBlock {
|
||||
private ChatStyle style;
|
||||
public int color = 0xe0e0e0;
|
||||
public int titleColor = 0xe0e0e0;
|
||||
public int titlePos = 0;
|
||||
private String name;
|
||||
private ICommandSender sender;
|
||||
|
||||
public TextBlockClient(ICommandSender sender, Dialog dialog, Object... obs) {
|
||||
this(dialog.text, dialog.textWidth, false, obs);
|
||||
this.color = dialog.color;
|
||||
this.titleColor = dialog.titleColor;
|
||||
this.titlePos = dialog.titlePos;
|
||||
this.sender = sender;
|
||||
}
|
||||
public TextBlockClient(ICommandSender sender, Dialog dialog, Object... obs) {
|
||||
this(dialog.text, dialog.textWidth, false, obs);
|
||||
this.color = dialog.color;
|
||||
this.titleColor = dialog.titleColor;
|
||||
this.titlePos = dialog.titlePos;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public TextBlockClient(String name, String text, int lineWidth, int color, Object... obs) {
|
||||
this(text, lineWidth, false, obs);
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
if(sender != null)
|
||||
return sender.getCommandSenderName();
|
||||
return name;
|
||||
}
|
||||
|
||||
public TextBlockClient(String text, int lineWidth, boolean mcFont, Object... obs){
|
||||
style = new ChatStyle();
|
||||
text = NoppesStringUtils.formatText(text, obs);
|
||||
|
||||
String line = "";
|
||||
text = text.replace("\n", " \n ");
|
||||
text = text.replace("\r", " \r ");
|
||||
String[] words = text.split(" ");
|
||||
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
for(String word : words){
|
||||
if(word.isEmpty())
|
||||
continue;
|
||||
if(word.length() == 1){
|
||||
char c = word.charAt(0);
|
||||
if(c == '\r' || c == '\n'){
|
||||
addLine(line);
|
||||
line = "";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
String newLine;
|
||||
if(line.isEmpty())
|
||||
newLine = word;
|
||||
else
|
||||
newLine = line + " " + word;
|
||||
public TextBlockClient(String name, String text, int lineWidth, int color, Object... obs) {
|
||||
this(text, lineWidth, false, obs);
|
||||
this.color = color;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
if((mcFont?font.getStringWidth(newLine): ClientProxy.Font.width(newLine)) > lineWidth){
|
||||
addLine(line);
|
||||
line = word.trim();
|
||||
}
|
||||
else{
|
||||
line = newLine;
|
||||
}
|
||||
}
|
||||
if(!line.isEmpty())
|
||||
addLine(line);
|
||||
}
|
||||
public String getName() {
|
||||
if (sender != null)
|
||||
return sender.getCommandSenderName();
|
||||
return name;
|
||||
}
|
||||
|
||||
private void addLine(String text){
|
||||
ChatComponentText line = new ChatComponentText(text);
|
||||
line.setChatStyle(style);
|
||||
lines.add(line);
|
||||
}
|
||||
public TextBlockClient(String text, int lineWidth, boolean mcFont, Object... obs) {
|
||||
style = new ChatStyle();
|
||||
text = NoppesStringUtils.formatText(text, obs);
|
||||
|
||||
String line = "";
|
||||
text = text.replace("\n", " \n ");
|
||||
text = text.replace("\r", " \r ");
|
||||
String[] words = text.split(" ");
|
||||
|
||||
FontRenderer font = Minecraft.getMinecraft().fontRenderer;
|
||||
for (String word : words) {
|
||||
if (word.isEmpty())
|
||||
continue;
|
||||
if (word.length() == 1) {
|
||||
char c = word.charAt(0);
|
||||
if (c == '\r' || c == '\n') {
|
||||
addLine(line);
|
||||
line = "";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
String newLine;
|
||||
if (line.isEmpty())
|
||||
newLine = word;
|
||||
else
|
||||
newLine = line + " " + word;
|
||||
|
||||
if ((mcFont ? font.getStringWidth(newLine) : ClientProxy.Font.width(newLine)) > lineWidth) {
|
||||
addLine(line);
|
||||
line = word.trim();
|
||||
} else {
|
||||
line = newLine;
|
||||
}
|
||||
}
|
||||
if (!line.isEmpty())
|
||||
addLine(line);
|
||||
}
|
||||
|
||||
private void addLine(String text) {
|
||||
ChatComponentText line = new ChatComponentText(text);
|
||||
line.setChatStyle(style);
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user