Add JNI Methods for collectionSlotMaxValue & Warning

This commit is contained in:
AconiteGodOfSWG
2020-11-19 22:41:41 -05:00
parent be88a4de4f
commit 25a4b9363d
2 changed files with 31 additions and 0 deletions
@@ -43,6 +43,7 @@ namespace ScriptMethodsCollectionNamespace
jobjectArray JNICALL getCollectionSlotCategoryInfo(JNIEnv *env, jobject self, jstring slotName);
jobjectArray JNICALL getCollectionSlotPrereqInfo(JNIEnv *env, jobject self, jstring slotName);
jstring JNICALL getCollectionSlotName(JNIEnv *env, jobject self, jint collectionSlotId);
jlong JNICALL getCollectionSlotMaxValue(JNIEnv *env, jobject self, jstring slotName);
jobjectArray JNICALL getAllCollectionSlotsInCollection(JNIEnv *env, jobject self, jstring collectionName);
jobjectArray JNICALL getAllCollectionSlotsInPage(JNIEnv *env, jobject self, jstring pageName);
jobjectArray JNICALL getAllCollectionsInPage(JNIEnv *env, jobject self, jstring pageName);
@@ -89,6 +90,7 @@ bool ScriptMethodsCollectionNamespace::install()
JF("getCollectionSlotCategoryInfo", "(Ljava/lang/String;)[Ljava/lang/String;", getCollectionSlotCategoryInfo),
JF("getCollectionSlotPrereqInfo", "(Ljava/lang/String;)[Ljava/lang/String;", getCollectionSlotPrereqInfo),
JF("getCollectionSlotName", "(I)Ljava/lang/String;", getCollectionSlotName),
JF("getCollectionSlotMaxValue", "(Ljava/lang/String;)J", getCollectionSlotMaxValue),
JF("getAllCollectionSlotsInCollection", "(Ljava/lang/String;)[Ljava/lang/String;", getAllCollectionSlotsInCollection),
JF("getAllCollectionSlotsInPage", "(Ljava/lang/String;)[Ljava/lang/String;", getAllCollectionSlotsInPage),
JF("getAllCollectionsInPage", "(Ljava/lang/String;)[Ljava/lang/String;", getAllCollectionsInPage),
@@ -632,6 +634,23 @@ jstring JNICALL ScriptMethodsCollectionNamespace::getCollectionSlotName(JNIEnv *
// ----------------------------------------------------------------------
jlong JNICALL ScriptMethodsCollectionNamespace::getCollectionSlotMaxValue(JNIEnv *env, jobject self, jstring slotName)
{
UNREF(self);
JavaStringParam localSlotName(slotName);
std::string slotNameString;
JavaLibrary::convert(localSlotName, slotNameString);
CollectionsDataTable::CollectionInfoSlot const * slot = CollectionsDataTable::getSlotByName(slotNameString);
if (!slot)
return -1;
return static_cast<int64>(slot->maxSlotValue);
}
// ----------------------------------------------------------------------
jobjectArray JNICALL ScriptMethodsCollectionNamespace::getAllCollectionSlotsInCollection(JNIEnv *env, jobject self, jstring collectionName)
{
UNREF(self);
@@ -31,6 +31,7 @@ namespace ScriptMethodsSystemNamespace
void JNICALL saveBytesOnClient(JNIEnv * env, jobject self, jlong jclient, jstring jfilename, jbyteArray bytes);
void JNICALL launchClientWebBrowser(JNIEnv *env, jobject self, jlong player, jstring url);
void JNICALL playCutScene(JNIEnv * env, jobject self, jlong jclient, jstring jfilename);
void JNICALL triggerServerWarning(JNIEnv * env, jobject self, jstring message);
}
@@ -49,6 +50,7 @@ const JNINativeMethod NATIVES[] = {
JF("_saveBytesOnClient", "(JLjava/lang/String;[B)V", saveBytesOnClient),
JF("_launchClientWebBrowser", "(JLjava/lang/String;)V", launchClientWebBrowser),
JF("_playCutScene", "(JLjava/lang/String;)V", playCutScene),
JF("_triggerServerWarning", "(Ljava/lang/String;)V", triggerServerWarning),
};
return JavaLibrary::registerNatives(NATIVES, sizeof(NATIVES)/sizeof(NATIVES[0]));
@@ -234,5 +236,15 @@ void JNICALL ScriptMethodsSystemNamespace::playCutScene(JNIEnv * env, jobject se
}
}
// ----------------------------------------------------------------------
void JNICALL ScriptMethodsSystemNamespace::triggerServerWarning(JNIEnv * env, jobject self, jstring message)
{
JavaStringParam localMessage(message);
std::string messageString;
JavaLibrary::convert(localMessage, messageString);
WARNING(true, (messageString.c_str()));
}
// ======================================================================