Add and apply .editorconfig from P2 (#1195)

* Consistenty use javax annotations.
 - Unfortunately jetbrains annotations seem to be exposed transitively via core somewhere, but with the correct IDE settings, annotations can be defaulted to javax
 - Cleaning up of import order in #1195
 - Must be merged before #1195

* Add and apply .editorconfig from P2
 - Does not rearrange entries

* Address some comments

* add back some javadoc comments

* Address final comments

Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
dordsor21
2021-07-24 16:34:05 +01:00
committed by GitHub
parent 3b4beba7d6
commit 8c0195970b
1143 changed files with 143599 additions and 9952 deletions

View File

@ -9,9 +9,11 @@ import org.enginehub.piston.util.ValueProvider;
import java.lang.reflect.Method;
public class MethodInjector implements CommandCallListener {
@Override
public void beforeCall(Method commandMethod, CommandParameters parameters) {
InjectedValueStore store = parameters.injectedValue(Key.of(InjectedValueStore.class)).get();
store.injectValue(Key.of(Method.class), ValueProvider.constant(commandMethod));
}
}

View File

@ -3,7 +3,9 @@ package com.fastasyncworldedit.core.internal.exception;
import com.fastasyncworldedit.core.configuration.Caption;
public class FaweBlockBagException extends FaweException {
public FaweBlockBagException() {
super(Caption.of("fawe.error.worldedit.some.fails.blockbag"));
}
}

View File

@ -3,7 +3,9 @@ package com.fastasyncworldedit.core.internal.exception;
import com.fastasyncworldedit.core.configuration.Caption;
public class FaweChunkLoadException extends FaweException {
public FaweChunkLoadException() {
super(Caption.of("fawe.cancel.worldedit.failed.load.chunk"));
}
}

View File

@ -7,6 +7,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import java.util.Locale;
public class FaweException extends RuntimeException {
// DEBUG
public static final FaweException _enableQueue = new FaweException("enableQueue");
public static final FaweException _disableQueue = new FaweException("disableQueue");
@ -50,4 +51,5 @@ public class FaweException extends RuntimeException {
public Throwable fillInStackTrace() {
return this;
}
}

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.io.OutputStream;
public class AbstractDelegateOutputStream extends OutputStream {
private final OutputStream parent;
@Override
@ -34,4 +35,5 @@ public class AbstractDelegateOutputStream extends OutputStream {
public AbstractDelegateOutputStream(OutputStream os) {
this.parent = os;
}
}

View File

@ -223,4 +223,5 @@ public class FastByteArrayOutputStream extends OutputStream {
size = 0;
buffers.clear();
}
}

View File

@ -3,6 +3,7 @@ package com.fastasyncworldedit.core.internal.io;
import java.io.InputStream;
public class FastByteArraysInputStream extends InputStream {
private final byte[][] buffers;
private final int length;
@ -107,4 +108,5 @@ public class FastByteArraysInputStream extends InputStream {
public long length() {
return this.length;
}
}

View File

@ -74,4 +74,5 @@ public class FaweInputStream extends DataInputStream {
}
parent.close();
}
}

View File

@ -92,4 +92,5 @@ public class FaweOutputStream extends DataOutputStream {
}
parent.close();
}
}

View File

@ -1,7 +1,6 @@
package com.fastasyncworldedit.core.internal.io;
import javax.annotation.Nonnull;
import java.io.DataOutput;
import java.io.FilterOutputStream;
import java.io.IOException;
@ -19,8 +18,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Creates a new little endian output stream and chains it to the
* output stream specified by the out argument.
*
* @param out the underlying output stream.
* @see FilterOutputStream#out
* @param out the underlying output stream.
* @see FilterOutputStream#out
*/
public LittleEndianOutputStream(OutputStream out) {
super(out);
@ -29,8 +28,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
/**
* Writes the specified byte value to the underlying output stream.
*
* @param b the {@code byte} value to be written.
* @exception IOException if the underlying stream throws an IOException.
* @param b the {@code byte} value to be written.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public synchronized void write(int b) throws IOException {
@ -42,10 +41,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes {@code length} bytes from the specified byte array
* starting at {@code offset} to the underlying output stream.
*
* @param data the data.
* @param offset the start offset in the data.
* @param length the number of bytes to write.
* @exception IOException if the underlying stream throws an IOException.
* @param data the data.
* @param offset the start offset in the data.
* @param length the number of bytes to write.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public synchronized void write(@Nonnull byte[] data, int offset, int length)
@ -60,8 +59,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* a single byte. If the argument is true, the byte value 1 is written.
* If the argument is false, the byte value {@code 0} in written.
*
* @param b the {@code boolean} value to be written.
* @exception IOException if the underlying stream throws an IOException.
* @param b the {@code boolean} value to be written.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public void writeBoolean(boolean b) throws IOException {
@ -77,8 +76,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
/**
* Writes out a {@code byte} to the underlying output stream
*
* @param b the {@code byte} value to be written.
* @exception IOException if the underlying stream throws an IOException.
* @param b the {@code byte} value to be written.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public void writeByte(int b) throws IOException {
@ -90,8 +89,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes a two byte {@code short} to the underlying output stream in
* little endian order, low byte first.
*
* @param s the {@code short} to be written.
* @exception IOException if the underlying stream throws an IOException.
* @param s the {@code short} to be written.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public void writeShort(int s) throws IOException {
@ -106,8 +105,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes a two byte {@code char} to the underlying output stream
* in little endian order, low byte first.
*
* @param c the {@code char} value to be written.
* @exception IOException if the underlying stream throws an IOException.
* @param c the {@code char} value to be written.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public void writeChar(int c) throws IOException {
@ -122,8 +121,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes a four-byte {@code int} to the underlying output stream
* in little endian order, low byte first, high byte last
*
* @param i the {@code int} to be written.
* @exception IOException if the underlying stream throws an IOException.
* @param i the {@code int} to be written.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public void writeInt(int i) throws IOException {
@ -140,8 +139,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes an eight-byte {@code long} to the underlying output stream
* in little endian order, low byte first, high byte last
*
* @param l the {@code long} to be written.
* @exception IOException if the underlying stream throws an IOException.
* @param l the {@code long} to be written.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public void writeLong(long l) throws IOException {
@ -162,8 +161,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes a 4 byte Java float to the underlying output stream in
* little endian order.
*
* @param f the {@code float} value to be written.
* @exception IOException if an I/O error occurs.
* @param f the {@code float} value to be written.
* @throws IOException if an I/O error occurs.
*/
@Override
public final void writeFloat(float f) throws IOException {
@ -176,8 +175,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* Writes an 8 byte Java double to the underlying output stream in
* little endian order.
*
* @param d the {@code double} value to be written.
* @exception IOException if an I/O error occurs.
* @param d the {@code double} value to be written.
* @throws IOException if an I/O error occurs.
*/
@Override
public final void writeDouble(double d) throws IOException {
@ -191,10 +190,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* bytes. Each character is written to the data output stream as
* if by the {@code writeByte()} method.
*
* @param s the {@code String} value to be written.
* @exception IOException if the underlying stream throws an IOException.
* @see java.io.DataOutputStream#writeByte(int)
* @see java.io.DataOutputStream#out
* @param s the {@code String} value to be written.
* @throws IOException if the underlying stream throws an IOException.
* @see java.io.DataOutputStream#writeByte(int)
* @see java.io.DataOutputStream#out
*/
@Override
public void writeBytes(String s) throws IOException {
@ -211,10 +210,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* characters. Each character is written to the data output stream as
* if by the {@code writeChar} method.
*
* @param s a {@code String} value to be written.
* @exception IOException if the underlying stream throws an IOException.
* @see java.io.DataOutputStream#writeChar(int)
* @see java.io.DataOutputStream#out
* @param s a {@code String} value to be written.
* @throws IOException if the underlying stream throws an IOException.
* @see java.io.DataOutputStream#writeChar(int)
* @see java.io.DataOutputStream#out
*/
@Override
public void writeChars(String s) throws IOException {
@ -239,10 +238,10 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* in the string. Next each character of the string is written
* using the UTF-8 encoding for the character.
*
* @param s the string to be written.
* @exception UTFDataFormatException if the string is longer than
* 65,535 characters.
* @exception IOException if the underlying stream throws an IOException.
* @param s the string to be written.
* @throws UTFDataFormatException if the string is longer than
* 65,535 characters.
* @throws IOException if the underlying stream throws an IOException.
*/
@Override
public void writeUTF(String s) throws IOException {
@ -250,7 +249,7 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
int numchars = s.length();
int numbytes = 0;
for (int i = 0 ; i < numchars ; i++) {
for (int i = 0; i < numchars; i++) {
int c = s.charAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
numbytes++;
@ -267,19 +266,17 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
out.write((numbytes >>> 8) & 0xFF);
out.write(numbytes & 0xFF);
for (int i = 0 ; i < numchars ; i++) {
for (int i = 0; i < numchars; i++) {
int c = s.charAt(i);
if ((c >= 0x0001) && (c <= 0x007F)) {
out.write(c);
}
else if (c > 0x07FF) {
} else if (c > 0x07FF) {
out.write(0xE0 | ((c >> 12) & 0x0F));
out.write(0x80 | ((c >> 6) & 0x3F));
out.write(0x80 | ((c >> 6) & 0x3F));
out.write(0x80 | (c & 0x3F));
written += 2;
}
else {
out.write(0xC0 | ((c >> 6) & 0x1F));
} else {
out.write(0xC0 | ((c >> 6) & 0x1F));
out.write(0x80 | (c & 0x3F));
written += 1;
}
@ -294,7 +291,8 @@ public class LittleEndianOutputStream extends FilterOutputStream implements Data
* (This class is not thread-safe with respect to this method. It is
* possible that this number is temporarily less than the actual
* number of bytes written.)
* @return the value of the {@code written} field.
*
* @return the value of the {@code written} field.
*/
public int size() {
return this.written;

View File

@ -10,6 +10,7 @@ public class NonCloseableInputStream extends InputStream {
public NonCloseableInputStream(InputStream parent) {
this.parent = parent;
}
@Override
public int read() throws IOException {
return parent.read();
@ -53,4 +54,5 @@ public class NonCloseableInputStream extends InputStream {
public boolean markSupported() {
return parent.markSupported();
}
}

View File

@ -6,6 +6,7 @@ import java.io.IOException;
import java.nio.channels.FileChannel;
public class ResettableFileInputStream extends FilterInputStream {
private final FileChannel myFileChannel;
private long mark = 0;
@ -36,4 +37,5 @@ public class ResettableFileInputStream extends FilterInputStream {
}
myFileChannel.position(mark);
}
}
}