Remove apache dependency from ShockPacketIncoming

This commit is contained in:
UnfamiliarLegacy 2024-06-24 04:28:34 +02:00
parent 9f28eec447
commit c7fcc596da
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,57 @@
package gearth.misc;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class ArrayUtils {
/**
* The index value when an element is not found in a list or array: {@code -1}.
* This value is returned by methods in this class and can also be used in comparisons with values returned by
* various method from {@link java.util.List}.
*/
public static final int INDEX_NOT_FOUND = -1;
/**
* <p>Finds the index of the given value in the array starting at the given index.
*
* <p>This method returns {@link #INDEX_NOT_FOUND} ({@code -1}) for a {@code null} input array.
*
* <p>A negative startIndex is treated as zero. A startIndex larger than the array
* length will return {@link #INDEX_NOT_FOUND} ({@code -1}).
*
* @param array the array to search through for the object, may be {@code null}
* @param valueToFind the value to find
* @param startIndex the index to start searching at
* @return the index of the value within the array,
* {@link #INDEX_NOT_FOUND} ({@code -1}) if not found or {@code null} array input
*/
public static int indexOf(final byte[] array, final byte valueToFind, int startIndex) {
if (array == null) {
return INDEX_NOT_FOUND;
}
if (startIndex < 0) {
startIndex = 0;
}
for (int i = startIndex; i < array.length; i++) {
if (valueToFind == array[i]) {
return i;
}
}
return INDEX_NOT_FOUND;
}
}

View File

@ -1,9 +1,9 @@
package gearth.protocol.packethandler.shockwave.packets;
import gearth.encoding.VL64Encoding;
import gearth.misc.ArrayUtils;
import gearth.protocol.HPacket;
import gearth.protocol.HPacketFormat;
import org.apache.commons.lang3.ArrayUtils;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;