Skip to content

Commit aecd454

Browse files
committed
v3.4.0
- Improved formatting slightly from my dumb ass when I was a kid and wrote this code - Fixed outstanding issues with legacy code and deprecated methods - Now built against the latest Paper API and Java 21
1 parent 3aee262 commit aecd454

6 files changed

Lines changed: 310 additions & 328 deletions

File tree

pom.xml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
6-
76
<groupId>net.forestfire</groupId>
87
<artifactId>Elevators</artifactId>
9-
<version>3.3.4</version>
8+
<version>3.4.0</version>
109
<packaging>jar</packaging>
11-
1210
<name>Elevators</name>
13-
1411
<properties>
15-
<java.version>1.8</java.version>
12+
<java.version>21</java.version>
1613
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1714
</properties>
18-
1915
<build>
2016
<plugins>
2117
<plugin>
@@ -51,24 +47,23 @@
5147
</resource>
5248
</resources>
5349
</build>
54-
5550
<repositories>
5651
<repository>
57-
<id>papermc-repo</id>
58-
<url>https://papermc.io/repo/repository/maven-public/</url>
59-
</repository>
60-
<repository>
61-
<id>sonatype</id>
62-
<url>https://oss.sonatype.org/content/groups/public/</url>
52+
<id>papermc</id>
53+
<url>https://repo.papermc.io/repository/maven-public/</url>
6354
</repository>
6455
</repositories>
65-
6656
<dependencies>
6757
<dependency>
6858
<groupId>io.papermc.paper</groupId>
6959
<artifactId>paper-api</artifactId>
70-
<version>1.18.1-R0.1-SNAPSHOT</version>
60+
<version>1.21.3-R0.1-SNAPSHOT</version>
7161
<scope>provided</scope>
7262
</dependency>
63+
<dependency>
64+
<groupId>org.apache.commons</groupId>
65+
<artifactId>commons-text</artifactId>
66+
<version>1.13.0</version>
67+
</dependency>
7368
</dependencies>
74-
</project>
69+
</project>

src/main/java/net/forestfire/elevators/ChuList.java

Lines changed: 26 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
1-
//ChuList v1.9, ©2020 Pecacheu. Licensed under GNU GPL 3.0
2-
1+
//ChuList v1.9.1, ©2024 Pecacheu. Licensed under GNU GPL 3.0
32
//An actually properly implemented List class? With error checking!? Imagine that!
43

54
package net.forestfire.elevators;
65

7-
import java.util.ArrayList;
8-
import java.util.Collection;
9-
import java.util.Comparator;
10-
import java.util.Iterator;
11-
import java.util.List;
12-
import java.util.ListIterator;
13-
import java.util.NoSuchElementException;
14-
import java.util.Spliterator;
15-
import java.util.function.Predicate;
16-
import java.util.function.UnaryOperator;
17-
18-
@SuppressWarnings("serial")
6+
import java.util.*;
7+
198
public class ChuList<E> extends ArrayList<E> {
209
public int length=0; //<- JavaScript Compatibility (Maybe not the best idea, though)
21-
public ChuList() {
22-
super();
23-
}
24-
public ChuList(int initialCapacity) {
25-
super(initialCapacity);
26-
}
27-
public ChuList(Collection<? extends E> c) {
28-
super(c); length=super.size();
29-
}
10+
public ChuList() { super(); }
11+
public ChuList(int initialCapacity) { super(initialCapacity); }
12+
public ChuList(Collection<? extends E> c) { super(c); length=super.size(); }
3013

31-
//Construct with initial elements:
14+
//Construct with initial elements
3215
@SafeVarargs
3316
public ChuList(E... elements) {
34-
super();
35-
for(int i=0,l=elements.length; i<l; i++) super.add(elements[i]);
17+
super(); super.addAll(Arrays.asList(elements));
3618
length = super.size();
3719
}
3820

@@ -41,15 +23,14 @@ public boolean add(E item) {
4123
super.add(item); length = super.size(); return true;
4224
}
4325

44-
//JavaScript Compatibility:
45-
public void push(E item) {
46-
add(item);
47-
}
26+
//JavaScript Compatibility
27+
public void push(E item) { add(item); }
4828

49-
//Now, this is just common-sense functionality:
29+
//Now, this is just common-sense functionality
5030
public String join(String sep) {
51-
String str = ""; for(int i=0,l=super.size(); i<l; i++)
52-
str += (i==0?"":sep)+super.get(i); return str;
31+
StringBuilder sb = new StringBuilder();
32+
for(int i=0, l=super.size(); i<l; ++i) sb.append(i==0?"":sep).append(super.get(i));
33+
return sb.toString();
5334
}
5435

5536
@Override
@@ -93,26 +74,21 @@ public void clear() {
9374
super.clear(); length = 0;
9475
}
9576

96-
//Actually Working toString For Debugging:
77+
//Actually working toString for debugging
9778
@Override
98-
public String toString() {
99-
String str = "["; for(int i=0,l=super.size(); i<l; i++)
100-
str += (i==0?"":", ")+super.get(i); str += "]"; return str;
101-
}
79+
public String toString() { return "["+this.join(", ")+"]"; }
10280

10381
public ChuList<E> addAll(int index, E[] arr) {
104-
for(int i=0,l=arr.length; i<l; i++) add(index+i, arr[i]);
82+
for(int i=0,l=arr.length; i<l; ++i) add(index+i, arr[i]);
10583
return this;
10684
}
10785

10886
public ChuList<E> addAll(E[] arr) {
109-
for(int i=0,l=arr.length; i<l; i++) super.add(arr[i]);
110-
return this;
87+
for(E e: arr) super.add(e); return this;
11188
}
11289

11390
public ChuList<E> addAll(ArrayList<E> arr) {
114-
for(int i=0,l=arr.size(); i<l; i++) super.add(arr.get(i));
115-
return this;
91+
for(E e: arr) super.add(e); return this;
11692
}
11793

11894
@Override
@@ -122,76 +98,9 @@ public ChuList<E> subList(int fromIndex, int toIndex) {
12298
else list = super.subList(fromIndex, toIndex); return new ChuList<E>(list);
12399
}
124100

125-
/*@SuppressWarnings("unchecked")
126-
@Override
127-
public E[] toArray() {
128-
int size = super.size(); Object[] arr = new Object[size];
129-
for(int i=0; i<size; i++) arr[i] = super.get(i); return ((E[])arr);
130-
}*/
131-
132-
//Unchanged Methods:
133-
134-
//size()
135-
//ensureCapacity()
136-
//trimToSize()
137-
//indexOf()
138-
//lastIndexOf()
139-
//forEach()
140-
//isEmpty()
141-
//equals()
142-
//toArray()
143-
//hashCode()
144-
145-
//--------- Unimplemented Methods:
146-
147-
//TODO Add Error-Checking To These Methods:
148-
149-
@Override
150-
public boolean addAll(Collection<? extends E> c) {
151-
//return super.addAll(c);
152-
return false;
153-
}
154-
@Override
155-
public boolean addAll(int index, Collection<? extends E> c) {
156-
//return super.addAll(index, c);
157-
return false;
158-
}
159-
@Override
160-
public boolean removeAll(Collection<?> c) {
161-
//return super.removeAll(c);
162-
return false;
163-
}
164-
@Override
165-
public boolean removeIf(Predicate<? super E> filter) {
166-
//return super.removeIf(filter);
167-
return false;
168-
}
169-
@Override
170-
protected void removeRange(int fromIndex, int toIndex) {
171-
//super.removeRange(fromIndex, toIndex);
172-
}
173-
@Override
174-
public void replaceAll(UnaryOperator<E> operator) {
175-
//super.replaceAll(operator);
176-
}
177-
@Override
178-
public boolean retainAll(Collection<?> c) {
179-
//return super.retainAll(c);
180-
return false;
181-
}
182-
@Override
183-
public boolean containsAll(Collection<?> c) {
184-
//return super.containsAll(c);
185-
return false;
186-
}
187-
@Override
188-
public void sort(Comparator<? super E> c) {
189-
//super.sort(c);
190-
}
191-
192101
//Iterators. These are only provided to maximize compatibility. Please use a standard for statement instead!
193102

194-
//Better Iterator Class:
103+
//Better Iterator Class
195104
public ChuIterator<E> chuIterator() { return new ChuIterator<E>(this); }
196105

197106
@Override
@@ -204,38 +113,27 @@ public void sort(Comparator<? super E> c) {
204113
public Spliterator<E> spliterator() { return super.spliterator(); }
205114
}
206115

207-
//Here's a better Iterator class to match:
116+
//Here's a better Iterator class to match
208117
class ChuIterator<E> implements Iterator<E> {
209118
public final ChuList<E> list;
210119
public int index = -1;
211120

212121
ChuIterator(ChuList<E> l) { list = l; }
213122

214123
@Override
215-
public boolean hasNext() {
216-
return index < list.size()-1;
217-
}
124+
public boolean hasNext() { return index < list.size()-1; }
218125

219126
@Override
220127
public E next() {
221128
index++; E item = list.get(index); if(item==null)
222129
throw new NoSuchElementException(); return item;
223130
}
224131

225-
public void goBack() {
226-
if(index > -1) index--;
227-
}
228-
229-
public E last() {
230-
return list.get(index-1);
231-
}
232-
233-
public E lookAhead() {
234-
return lookAhead(1);
235-
}
132+
public void goBack() { if(index > -1) index--; }
133+
public E last() { return list.get(index-1); }
134+
public E lookAhead() { return lookAhead(1); }
236135
public E lookAhead(int by) {
237-
if(by < 1) return null;
238-
return list.get(index+by);
136+
if(by < 1) return null; return list.get(index+by);
239137
}
240138
}
241139

0 commit comments

Comments
 (0)