Scripted player tick events are functional, GUI for player events is complete. Global player events run as they should now, just need to start implementing more of them.

This commit is contained in:
luisc committed 2021-10-11 06:49:30 -05:00
1 parent 6aa98aecf3
commit 1ee14920ff
26 files changed
+1223 -1091

No files matched your search

@@ -1,535 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.client.gui.script;
import com.google.common.collect.Lists;
import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post;
import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre;
import net.minecraftforge.common.MinecraftForge;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
public abstract class EventGuiNPCInterface extends GuiScreen {
public EntityPlayerSP player;
public boolean drawDefaultBackground;
public EntityNPCInterface npc;
private Map<Integer, GuiNpcButton> buttons;
private Map<Integer, GuiMenuTopButton> topbuttons;
private Map<Integer, GuiMenuSideButton> sidebuttons;
private Map<Integer, GuiNpcTextField> textfields;
private Map<Integer, GuiNpcLabel> labels;
private Map<Integer, GuiCustomScroll> scrolls;
private Map<Integer, GuiNpcSlider> sliders;
private Map<Integer, GuiScreen> extra;
private List<IGui> components;
public String title;
public ResourceLocation background;
public boolean closeOnEsc;
public int guiLeft;
public int guiTop;
public int xSize;
public int ySize;
private SubGuiInterface subgui;
public int mouseX;
public int mouseY;
public float bgScale;
private GuiButton selectedButton;
public EventGuiNPCInterface(EntityNPCInterface npc) {
this.drawDefaultBackground = true;
this.buttons = new ConcurrentHashMap();
this.topbuttons = new ConcurrentHashMap();
this.sidebuttons = new ConcurrentHashMap();
this.textfields = new ConcurrentHashMap();
this.labels = new ConcurrentHashMap();
this.scrolls = new ConcurrentHashMap();
this.sliders = new ConcurrentHashMap();
this.extra = new ConcurrentHashMap();
this.components = new ArrayList();
this.background = null;
this.closeOnEsc = false;
this.bgScale = 1.0F;
this.player = Minecraft.getMinecraft().thePlayer;
this.npc = npc;
this.title = "";
this.xSize = 200;
this.ySize = 222;
this.drawDefaultBackground = false;
this.mc = Minecraft.getMinecraft();
this.itemRender = RenderItem.getInstance();
this.fontRendererObj = this.mc.fontRenderer;
}
public EventGuiNPCInterface() {
this((EntityNPCInterface)null);
}
public void setBackground(String texture) {
this.background = new ResourceLocation("customnpcs", "textures/gui/" + texture);
}
public ResourceLocation getResource(String texture) {
return new ResourceLocation("customnpcs", "textures/gui/" + texture);
}
public void setWorldAndResolution(Minecraft mc, int width, int height) {
super.setWorldAndResolution(mc, width, height);
this.initPacket();
}
public void initPacket() {
}
public void initGui() {
super.initGui();
GuiNpcTextField.unfocus();
if (this.subgui != null) {
this.subgui.setWorldAndResolution(this.mc, this.width, this.height);
this.subgui.initGui();
}
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
this.buttonList = Lists.newArrayList();
this.buttons = new ConcurrentHashMap();
this.topbuttons = new ConcurrentHashMap();
this.sidebuttons = new ConcurrentHashMap();
this.textfields = new ConcurrentHashMap();
this.labels = new ConcurrentHashMap();
this.scrolls = new ConcurrentHashMap();
this.sliders = new ConcurrentHashMap();
this.extra = new ConcurrentHashMap();
this.components = new ArrayList();
}
public void updateScreen() {
if (this.subgui != null) {
this.subgui.updateScreen();
} else {
Iterator var1 = (new ArrayList(this.textfields.values())).iterator();
while(var1.hasNext()) {
GuiNpcTextField tf = (GuiNpcTextField)var1.next();
if (tf.enabled) {
tf.updateCursorCounter();
}
}
var1 = (new ArrayList(this.components)).iterator();
while(var1.hasNext()) {
IGui comp = (IGui)var1.next();
comp.updateScreen();
}
super.updateScreen();
}
}
public void addExtra(GuiHoverText gui) {
gui.setWorldAndResolution(this.mc, 350, 250);
this.extra.put(gui.id, gui);
}
public void mouseClicked(int i, int j, int k) {
if (this.subgui != null) {
this.subgui.mouseClicked(i, j, k);
} else {
Iterator var4 = (new ArrayList(this.textfields.values())).iterator();
while(var4.hasNext()) {
GuiNpcTextField tf = (GuiNpcTextField)var4.next();
if (tf.enabled) {
tf.mouseClicked(i, j, k);
}
}
var4 = (new ArrayList(this.components)).iterator();
while(var4.hasNext()) {
IGui comp = (IGui)var4.next();
if (comp instanceof IMouseListener) {
((IMouseListener)comp).mouseClicked(i, j, k);
}
}
this.mouseEvent(i, j, k);
if (k == 0) {
var4 = (new ArrayList(this.scrolls.values())).iterator();
while(var4.hasNext()) {
GuiCustomScroll scroll = (GuiCustomScroll)var4.next();
scroll.mouseClicked(i, j, k);
}
var4 = this.buttonList.iterator();
while(var4.hasNext()) {
GuiButton guibutton = (GuiButton)var4.next();
if (guibutton.mousePressed(this.mc, this.mouseX, this.mouseY)) {
Pre event = new Pre(this, guibutton, this.buttonList);
if (!MinecraftForge.EVENT_BUS.post(event)) {
this.selectedButton = guibutton;
guibutton.func_146113_a(this.mc.getSoundHandler());
this.actionPerformed(guibutton);
if (this.equals(this.mc.currentScreen)) {
MinecraftForge.EVENT_BUS.post(new Post(this, guibutton, this.buttonList));
}
}
break;
}
}
}
}
}
public void mouseReleased(int mouseX, int mouseY, int state) {
if (this.selectedButton != null && state == 0) {
this.selectedButton.mouseReleased(mouseX, mouseY);
this.selectedButton = null;
}
}
public void mouseEvent(int i, int j, int k) {
}
protected void actionPerformed(GuiButton guibutton) {
if (this.subgui != null) {
this.subgui.buttonEvent(guibutton);
} else {
this.buttonEvent(guibutton);
}
}
public void buttonEvent(GuiButton guibutton){};
public void keyTyped(char c, int i) {
if (this.subgui != null) {
this.subgui.keyTyped(c, i);
} else {
boolean active = false;
Iterator var4 = this.components.iterator();
IGui comp;
while(var4.hasNext()) {
comp = (IGui)var4.next();
if (comp.isActive()) {
active = true;
break;
}
}
active = active || GuiNpcTextField.isFieldActive();
if (!this.closeOnEsc || i != 1 && (active || !this.isInventoryKey(i))) {
var4 = (new ArrayList(this.textfields.values())).iterator();
while(var4.hasNext()) {
GuiNpcTextField tf = (GuiNpcTextField)var4.next();
tf.textboxKeyTyped(c, i);
}
var4 = (new ArrayList(this.components)).iterator();
while(var4.hasNext()) {
comp = (IGui)var4.next();
if (comp instanceof IKeyListener) {
((IKeyListener)comp).keyTyped(c, i);
}
}
} else {
this.close();
}
}
}
public void onGuiClosed() {
GuiNpcTextField.unfocus();
}
public void close() {
this.displayGuiScreen((GuiScreen)null);
this.mc.setIngameFocus();
this.save();
}
public void addButton(GuiNpcButton button) {
this.buttons.put(button.id, button);
this.buttonList.add(button);
}
public void addTopButton(GuiMenuTopButton button) {
this.topbuttons.put(button.id, button);
this.buttonList.add(button);
}
public void addSideButton(GuiMenuSideButton button) {
this.sidebuttons.put(button.id, button);
this.buttonList.add(button);
}
public GuiNpcButton getButton(int i) {
return (GuiNpcButton)this.buttons.get(i);
}
public GuiMenuSideButton getSideButton(int i) {
return (GuiMenuSideButton)this.sidebuttons.get(i);
}
public GuiMenuTopButton getTopButton(int i) {
return (GuiMenuTopButton)this.topbuttons.get(i);
}
public void addTextField(GuiNpcTextField tf) {
this.textfields.put(tf.id, tf);
}
public GuiNpcTextField getTextField(int i) {
return (GuiNpcTextField)this.textfields.get(i);
}
public void add(IGui gui) {
this.components.add(gui);
}
public IGui get(int id) {
Iterator var2 = this.components.iterator();
IGui comp;
do {
if (!var2.hasNext()) {
return null;
}
comp = (IGui)var2.next();
} while(comp.getID() != id);
return comp;
}
public void addLabel(GuiNpcLabel label) {
this.labels.put(label.id, label);
}
public GuiNpcLabel getLabel(int i) {
return (GuiNpcLabel)this.labels.get(i);
}
public void addSlider(GuiNpcSlider slider) {
this.sliders.put(slider.id, slider);
this.buttonList.add(slider);
}
public GuiNpcSlider getSlider(int i) {
return (GuiNpcSlider)this.sliders.get(i);
}
public void addScroll(GuiCustomScroll scroll) {
scroll.setWorldAndResolution(this.mc, 350, 250);
this.scrolls.put(scroll.id, scroll);
}
public GuiCustomScroll getScroll(int id) {
return (GuiCustomScroll)this.scrolls.get(id);
}
public abstract void save();
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.mouseX = mouseX;
this.mouseY = mouseY;
int x = mouseX;
int y = mouseY;
if (this.subgui != null) {
y = 0;
x = 0;
}
if (this.drawDefaultBackground && this.subgui == null) {
this.drawDefaultBackground();
}
if (this.background != null && this.mc.renderEngine != null) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushMatrix();
GL11.glTranslatef((float) this.guiLeft, (float) this.guiTop, 0.0F);
GL11.glScalef(this.bgScale, this.bgScale, this.bgScale);
this.mc.renderEngine.bindTexture(this.background);
if (this.xSize > 256) {
this.drawTexturedModalRect(0, 0, 0, 0, 250, this.ySize);
this.drawTexturedModalRect(250, 0, 256 - (this.xSize - 250), 0, this.xSize - 250, this.ySize);
} else {
this.drawTexturedModalRect(0, 0, 0, 0, this.xSize, this.ySize);
}
GL11.glPopMatrix();
}
this.drawCenteredString(this.fontRendererObj, this.title, this.width / 2, 8, 16777215);
Iterator var6 = (new ArrayList(this.labels.values())).iterator();
while(var6.hasNext()) {
GuiNpcLabel label = (GuiNpcLabel)var6.next();
label.drawLabel(this, this.fontRendererObj);
}
var6 = (new ArrayList(this.textfields.values())).iterator();
while(var6.hasNext()) {
GuiNpcTextField tf = (GuiNpcTextField)var6.next();
tf.drawTextBox(x, y);
}
var6 = (new ArrayList(this.components)).iterator();
while(var6.hasNext()) {
IGui comp = (IGui)var6.next();
comp.drawScreen(x, y);
}
var6 = (new ArrayList(this.scrolls.values())).iterator();
while(var6.hasNext()) {
GuiCustomScroll scroll = (GuiCustomScroll)var6.next();
scroll.drawScreen(x, y, partialTicks, !this.hasSubGui() && scroll.isMouseOver(x, y) ? Mouse.getDWheel() : 0);
}
var6 = (new ArrayList(this.extra.values())).iterator();
while(var6.hasNext()) {
GuiScreen gui = (GuiScreen)var6.next();
gui.drawScreen(x, y, partialTicks);
}
super.drawScreen(x, y, partialTicks);
if (this.subgui != null) {
this.subgui.drawScreen(mouseX, mouseY, partialTicks);
}
}
public FontRenderer getFontRenderer() {
return this.fontRendererObj;
}
public void elementClicked() {
if (this.subgui != null) {
this.subgui.elementClicked();
}
}
public boolean doesGuiPauseGame() {
return false;
}
public void doubleClicked() {
}
public boolean isInventoryKey(int i) {
return i == this.mc.gameSettings.keyBindInventory.getKeyCode();
}
public void drawDefaultBackground() {
super.drawDefaultBackground();
}
public void displayGuiScreen(GuiScreen gui) {
this.mc.displayGuiScreen(gui);
}
public void setSubGui(SubGuiInterface gui) {
this.subgui = gui;
this.subgui.npc = this.npc;
this.subgui.setWorldAndResolution(this.mc, this.width, this.height);
this.subgui.parent = this;
this.initGui();
}
public void closeSubGui(SubGuiInterface gui) {
this.subgui = null;
}
public boolean hasSubGui() {
return this.subgui != null;
}
public SubGuiInterface getSubGui() {
return this.hasSubGui() && this.subgui.hasSubGui() ? this.subgui.getSubGui() : this.subgui;
}
public void drawNpc(int x, int y) {
this.drawNpc(this.npc, x, y, 1.0F, 0);
}
public void drawNpc(EntityLivingBase entity, int x, int y, float zoomed, int rotation) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glColorMaterial(0,1);
GL11.glPushMatrix();
GL11.glTranslatef((float)(this.guiLeft + x), (float)(this.guiTop + y), 50.0F);
float scale = 1.0F;
if ((double)entity.height > 2.4D) {
scale = 2.0F / entity.height;
}
GL11.glScalef(-30.0F * scale * zoomed, 30.0F * scale * zoomed, 30.0F * scale * zoomed);
GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
RenderHelper.enableStandardItemLighting();
float f2 = entity.renderYawOffset;
float f3 = entity.rotationYaw;
float f4 = entity.rotationPitch;
float f7 = entity.rotationYawHead;
float f5 = (float)(this.guiLeft + x) - (float)this.mouseX;
float f6 = (float)(this.guiTop + y) - 50.0F * scale * zoomed - (float)this.mouseY;
GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(-((float) Math.atan((double) (f6 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
entity.renderYawOffset = (float)rotation;
entity.rotationYaw = (float)Math.atan((double)(f5 / 80.0F)) * 40.0F + (float)rotation;
entity.rotationPitch = -((float)Math.atan((double)(f6 / 40.0F))) * 20.0F;
entity.rotationYawHead = entity.rotationYaw;
RenderItem.getInstance().zLevel = 180.0F;
RenderItem.getInstance().doRender(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
entity.prevRenderYawOffset = entity.renderYawOffset = f2;
entity.prevRotationYaw = entity.rotationYaw = f3;
entity.prevRotationPitch = entity.rotationPitch = f4;
entity.prevRotationYawHead = entity.rotationYawHead = f7;
GL11.glPopMatrix();
RenderHelper.disableStandardItemLighting();
}
public void openLink(String link) {
try {
Class oclass = Class.forName("java.awt.Desktop");
Object object = oclass.getMethod("getDesktop").invoke((Object)null);
oclass.getMethod("browse", URI.class).invoke(object, new URI(link));
} catch (Throwable var4) {
}
}
}
@@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.PlayerScriptContainer;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -18,10 +18,10 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
public class EventGuiScriptList extends SubGuiInterface {
private GuiCustomScroll scroll1;
private GuiCustomScroll scroll2;
private EventScriptContainer container;
private PlayerScriptContainer container;
private List<String> scripts;
public EventGuiScriptList(List<String> scripts, EventScriptContainer container) {
public EventGuiScriptList(List<String> scripts, PlayerScriptContainer container) {
this.container = container;
this.setBackground("menubg.png");
this.xSize = 346;
@@ -11,7 +11,7 @@ import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import org.lwjgl.opengl.GL11;
public class GuiScriptGlobal extends EventGuiNPCInterface {
public class GuiScriptGlobal extends GuiNPCInterface {
private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/smallbg.png");
public GuiScriptGlobal() {
@@ -18,14 +18,16 @@ import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.PlayerScriptContainer;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.swing.GuiJTextArea;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener {
public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener {
private int activeTab = 0;
public IScriptHandler handler;
public Map<String, List<String>> languages = new HashMap();
@@ -38,7 +40,7 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
}
public void initGui() {
this.xSize = (int)((double)this.width * 0.88D);
//this.xSize = (int)((double)this.width * 0.88D);
this.ySize = (int)((double)this.xSize * 0.56D);
if((double)this.ySize > (double)this.height * 0.95D) {
this.ySize = (int)((double)this.height * 0.95D);
@@ -53,7 +55,7 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings"));
for(int ta = 0; ta < this.handler.getScripts().size(); ++ta) {
EventScriptContainer var10000 = (EventScriptContainer)this.handler.getScripts().get(ta);
PlayerScriptContainer var10000 = (PlayerScriptContainer)this.handler.getScripts().get(ta);
this.addTopButton(top = new GuiMenuTopButton(ta + 1, top, ta + 1 + ""));
}
@@ -67,17 +69,43 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
top = this.getTopButton(0);
}
List<String> list = new ArrayList<String>();
list.add("playerscript.init");
list.add("playerscript.tick");
list.add("playerscript.interact");
list.add("playerscript.damaged");
list.add("playerscript.killed");
list.add("playerscript.attack");
list.add("playerscript.kills");
list.add("playerscript.chat");
list.add("playerscript.toss");
list.add("playerscript.containeropen");
list.add("playerscript.containerclosed");
list.add("playerscript.login");
list.add("playerscript.logout");
list.add("playerscript.chat");
list.add("playerscript.damagedentity");
list.add("playerscript.factionupdate");
list.add("playerscript.keypressed");
list.add("playerscript.levelup");
list.add("playerscript.pickup");
list.add("playerscript.rangedlaunched");
//list.add("playerscript.break");
top.active = true;
if(this.activeTab > 0) {
EventScriptContainer var7 = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
GuiNpcTextArea left = new GuiNpcTextArea(2, this, this.guiLeft + 1 + yoffset, this.guiTop + yoffset, this.xSize - 108 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
this.add(left);
/*
GuiTextArea left = new GuiTextArea(2, this.guiLeft + 1 + yoffset, this.guiTop + yoffset, this.xSize - 108 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
left.enableCodeHighlighting();
left.setListener(this);
this.add(left);
*/
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
hooks.setSize(68, 198);
hooks.guiLeft = guiLeft + 4;
hooks.guiTop = guiTop + 14;
hooks.setUnsortedList(list);
hooks.selected = getScriptHook(this.handler.getScripts().get(this.activeTab - 1),list);
addScroll(hooks);
PlayerScriptContainer var7 = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
GuiNpcTextArea left = new GuiNpcTextArea(2, this, this.guiLeft + 72 + yoffset, this.guiTop + yoffset, this.xSize - 180 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
this.addTextField(left);
int left1 = this.guiLeft + this.xSize - 104;
this.addButton(new GuiNpcButton(102, left1, this.guiTop + yoffset, 60, 20, "gui.clear"));
this.addButton(new GuiNpcButton(101, left1 + 61, this.guiTop + yoffset, 60, 20, "gui.paste"));
@@ -96,12 +124,7 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
} else {
GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int)((float)this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
var8.enabled = false;
this.add(var8);
/*
GuiTextArea var8 = new GuiTextArea(2, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset, this.xSize - 160 - yoffset, (int)((float)this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
var8.enabled = false;
this.add(var8);
*/
this.addTextField(var8);
int var9 = this.guiLeft + this.xSize - 150;
this.addButton(new GuiNpcButton(100, var9, this.guiTop + 125, 60, 20, "gui.copy"));
this.addButton(new GuiNpcButton(102, var9, this.guiTop + 146, 60, 20, "gui.clear"));
@@ -124,6 +147,20 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
this.ySize = 256;
}
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
this.handler.getScripts().get(this.activeTab - 1).setType(scroll.getSelected().replace("playerscript.",""));
}
private int getScriptHook(PlayerScriptContainer playerScriptContainer, List<String> list) {
for(String s : list) {
if (s.replace("playerscript.", "").equals(playerScriptContainer.type)) {
return list.indexOf(s);
}
}
return 0;
}
private String getConsoleText() {
Map map = this.handler.getConsoleText();
StringBuilder builder = new StringBuilder();
@@ -185,7 +222,7 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
}
if(guibutton.id == 12) {
this.handler.getScripts().add(new EventScriptContainer(this.handler));
this.handler.getScripts().add(new PlayerScriptContainer(this.handler));
this.activeTab = this.handler.getScripts().size();
this.initGui();
}
@@ -207,17 +244,17 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
}
if(guibutton.id == 100) {
NoppesStringUtils.setClipboardContents(((GuiTextArea)this.get(2)).getText());
NoppesStringUtils.setClipboardContents((this.getTextField(2)).getText());
}
if(guibutton.id == 101) {
((GuiTextArea)this.get(2)).setText(NoppesStringUtils.getClipboardContents());
(this.getTextField(2)).setText(NoppesStringUtils.getClipboardContents());
}
EventScriptContainer container;
PlayerScriptContainer container;
if(guibutton.id == 102) {
if(this.activeTab > 0) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container.script = "";
} else {
this.handler.clearConsole();
@@ -244,18 +281,19 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
}
if(guibutton.id == 107) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container == null) {
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
this.handler.getScripts().add(container = new PlayerScriptContainer(this.handler));
}
this.setSubGui(new EventGuiScriptList((List)this.languages.get(this.handler.getLanguage()), container));
}
if(guibutton.id == 108) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container != null) {
this.setScript();
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
}
}
@@ -263,12 +301,12 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
private void setScript() {
if(this.activeTab > 0) {
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
PlayerScriptContainer container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container == null) {
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
this.handler.getScripts().add(container = new PlayerScriptContainer(this.handler));
}
String text = ((GuiTextArea)this.get(2)).getText();
String text = (this.getTextField(2)).getText();
text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n");
container.script = text;
@@ -301,10 +339,18 @@ public class GuiScriptInterface extends EventGuiNPCInterface implements GuiYesNo
}
public void textUpdate(String text) {
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
PlayerScriptContainer container = (PlayerScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container != null) {
container.script = text;
}
}
@Override
public void saveText(String text) {
PlayerScriptContainer container = handler.getScripts().get(activeTab);
if(container != null)
container.script = text;
initGui();
}
}
@@ -9,10 +9,10 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.data.PlayerScriptData;
import noppes.npcs.controllers.data.PlayerDataScript;
public class GuiScriptPlayers extends GuiScriptInterface {
private PlayerScriptData script = new PlayerScriptData((EntityPlayer)null);
private PlayerDataScript script = new PlayerDataScript((EntityPlayer)null);
public GuiScriptPlayers() {
this.handler = this.script;