同步西游的toolsutil

master_longzhu_new
DESKTOP-C3M45P4\dengdan 2026-04-05 18:10:13 +08:00
parent 09959ed6a3
commit 511fb8f41e
1 changed files with 34 additions and 7 deletions

View File

@ -86,6 +86,11 @@ public class ToolsUtil {
return timeLong + TimeUtils.DAY * dayOut;
}
/**
*
* @param array
* @return
*/
public static int getRandomInt(int[] array){
int sum = Arrays.stream(array).sum();
@ -102,9 +107,6 @@ public class ToolsUtil {
break;
}
}
// System.out.println("Random Value: " + randomValue);
// System.out.println("Start Index: " + startIndex);
return startIndex;
}
@ -148,6 +150,27 @@ public class ToolsUtil {
return object;
}
/**
* map
*/
public static long[][] getTwoArrayLong(Map<Long, Long> map) {
long[][] object = null;
if (map != null && !map.isEmpty()) {
int size = map.size();
object = new long[size][2];
Iterator<Map.Entry<Long, Long>> iterator = map.entrySet().iterator();
for (int i = 0; i < size; i++) {
Map.Entry<Long, Long> entry = iterator.next();
long key = entry.getKey();
long value = entry.getValue();
object[i][0] = key;
object[i][1] = value;
}
}
return object;
}
public static int findKeyWithMaxValueLessThanB(Map<Integer, Integer> a, int b) {
int maxKey = -1;
int maxValue = Integer.MIN_VALUE;
@ -205,6 +228,14 @@ public class ToolsUtil {
return -1; // 如果没有找到匹配的元素,则返回 -1
}
public static int getPackId(int id){
return 100000 + id;
}
public static int getOriginId(int id){
return id % 100000;
}
/**
* type 10
*/
@ -212,10 +243,6 @@ public class ToolsUtil {
return type * 100000 + id;
}
public static int getOriginId(int id){
return id % 100000;
}
public static int[] getOriginIds(int id){
int[] result = new int[2];
result[0] = Integer.parseInt(String.valueOf(String.valueOf(id).charAt(0)));