mirror of
https://github.com/2006-Scape/Parabot-317-API-Minified.git
synced 2026-07-07 16:49:11 +00:00
[FEATURE] Made it easier to call int/long id methods
This commit is contained in:
@@ -18,26 +18,45 @@ public class NpcDef {
|
|||||||
* @return id of this item
|
* @return id of this item
|
||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
return getId(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets id of this item
|
||||||
|
*
|
||||||
|
* @param avoidLong defines if it should check if long id exists
|
||||||
|
* @return id of this item
|
||||||
|
*/
|
||||||
|
private int getId(boolean avoidLong) {
|
||||||
|
if (avoidLong) {
|
||||||
|
return accessor.getId();
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
return (int) getLongId();
|
long id = getLongId();
|
||||||
|
if (id > Integer.MAX_VALUE){
|
||||||
|
throw new NoSuchMethodException("This server only supports long ids; change NpcDef#getId to NpcDef#getLongId");
|
||||||
|
}
|
||||||
|
return (int) id;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
return accessor.getId();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets id of this item
|
||||||
|
* Meant for servers with longs as ids, instead of ints
|
||||||
|
*
|
||||||
|
* @return id of this item
|
||||||
|
*/
|
||||||
private long getLongId() {
|
private long getLongId() {
|
||||||
if (accessor != null) {
|
try {
|
||||||
if (accessor.getLongId() < Integer.MAX_VALUE) {
|
return accessor.getLongId();
|
||||||
return (long) accessor.getId();
|
} catch (Exception e) {
|
||||||
|
return getId(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the accessor class
|
* Gets the accessor class
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user