File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
src/main/java/nge/lk/mods/simpletabs/tabs Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 88import net .minecraft .util .math .MathHelper ;
99import org .lwjgl .input .Mouse ;
1010
11- import java .util .Iterator ;
1211import java .util .Map .Entry ;
1312
1413/**
@@ -110,9 +109,7 @@ public void handleClick(final int mouseButton) {
110109 assert tabUnderMouse >= 0 : "unchecked flag value" ;
111110
112111 int skip = tabManager .getTabOffset () + tabUnderMouse ;
113- final Iterator <Entry <String , ChatTab >> it = tabManager .getActiveTabGroup ().iterator ();
114- while (it .hasNext ()) {
115- final Entry <String , ChatTab > tab = it .next ();
112+ for (final Entry <String , ChatTab > tab : tabManager .getActiveTabGroup ()) {
116113 if (skip -- > 0 ) {
117114 continue ;
118115 }
@@ -126,7 +123,7 @@ public void handleClick(final int mouseButton) {
126123 tabManager .editTab (tab .getKey (), tab .getValue ());
127124 } else if (mouseButton == 2 ) {
128125 // Middle mouse button.
129- it . remove ( );
126+ tabManager . deleteTab ( tab . getKey () );
130127 resetSelectedTab ();
131128 tabManager .saveState ();
132129 }
Original file line number Diff line number Diff line change @@ -214,6 +214,17 @@ public void makeTabActive(final String key) {
214214 // Invariant: The current tab is valid, so no change is needed even if the tab name doesn't exist.
215215 }
216216
217+ /**
218+ * Deletes the tab with the given name.
219+ *
220+ * @param key The name.
221+ */
222+ public void deleteTab (final String key ) {
223+ if (doesTabExistInActiveGroup (key )) {
224+ tabs .get (activeGroup ).remove (key );
225+ }
226+ }
227+
217228 public void resetSelectedTab () {
218229 activeTab = tabs .get (activeGroup ).isEmpty () ? null : tabs .get (activeGroup ).keySet ().stream ().findFirst ().get ();
219230 tabOffset = 0 ;
@@ -279,6 +290,11 @@ public ChatTab getActiveChat() {
279290 return tabs .get (activeGroup ).get (activeTab );
280291 }
281292
293+ /**
294+ * Fetches the prefix of the active tab.
295+ *
296+ * @return The prefix.
297+ */
282298 public String getActivePrefix () {
283299 if (getActiveChat () != null ) {
284300 return getActiveChat ().getPrefix ();
You can’t perform that action at this time.
0 commit comments