mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-09-11 21:45:26 -04:00
System messages for granted static items instead of the NGE loot box because it unfortunately doesn't exist pre-NGE
This commit is contained in:
+1
-2
@@ -82,7 +82,7 @@ public class TerminalCharacterBuilderRadial implements RadialHandlerInterface {
|
||||
CreatureObject creature = player.getCreatureObject();
|
||||
SWGObject inventory = creature.getSlottedObject("inventory");
|
||||
|
||||
new CreateStaticItemIntent(creature, inventory, new StaticItemService.LootBoxHandler(creature), items).broadcast();
|
||||
new CreateStaticItemIntent(creature, inventory, new StaticItemService.SystemMessageHandler(creature), items).broadcast();
|
||||
}
|
||||
|
||||
private static void handleCredits(Player player) {
|
||||
@@ -524,7 +524,6 @@ public class TerminalCharacterBuilderRadial implements RadialHandlerInterface {
|
||||
|
||||
private static void handleGoggle(Player player) {
|
||||
spawnItems(player,
|
||||
"item_clothing_goggles_anniversary_01_01",
|
||||
"item_clothing_goggles_goggles_01_01",
|
||||
"item_clothing_goggles_goggles_01_02",
|
||||
"item_clothing_goggles_goggles_01_03",
|
||||
|
||||
+1
-1
@@ -158,7 +158,7 @@ public class RareLootService extends Service {
|
||||
}
|
||||
|
||||
// Show items in loot box window
|
||||
new StaticItemService.LootBoxHandler(actor).success(createdObjects);
|
||||
new StaticItemService.SystemMessageHandler(actor).success(createdObjects);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+13
-32
@@ -26,16 +26,12 @@
|
||||
*/
|
||||
package com.projectswg.holocore.services.support.objects.items
|
||||
|
||||
import com.projectswg.common.network.packets.swg.zone.object_controller.ShowLootBox
|
||||
import com.projectswg.holocore.intents.support.global.chat.SystemMessageIntent
|
||||
import com.projectswg.holocore.intents.support.objects.items.CreateStaticItemIntent
|
||||
import com.projectswg.holocore.intents.support.objects.swg.ObjectCreatedIntent
|
||||
import com.projectswg.holocore.resources.support.objects.StaticItemCreator
|
||||
import com.projectswg.holocore.resources.support.objects.swg.SWGObject
|
||||
import com.projectswg.holocore.resources.support.objects.swg.creature.CreatureObject
|
||||
import me.joshlarson.jlcommon.concurrency.ScheduledThreadPool
|
||||
import me.joshlarson.jlcommon.control.Intent
|
||||
import me.joshlarson.jlcommon.control.IntentChain
|
||||
import me.joshlarson.jlcommon.control.IntentHandler
|
||||
import me.joshlarson.jlcommon.control.Service
|
||||
import me.joshlarson.jlcommon.log.Log
|
||||
@@ -43,18 +39,6 @@ import java.util.*
|
||||
|
||||
class StaticItemService : Service() {
|
||||
|
||||
private val delayedCallbackHandler = ScheduledThreadPool(1, "static-item-service")
|
||||
|
||||
override fun start(): Boolean {
|
||||
delayedCallbackHandler.start()
|
||||
return true
|
||||
}
|
||||
|
||||
override fun stop(): Boolean {
|
||||
delayedCallbackHandler.stop()
|
||||
return delayedCallbackHandler.awaitTermination(1000)
|
||||
}
|
||||
|
||||
@IntentHandler
|
||||
private fun handleCreateStaticItemIntent(csii: CreateStaticItemIntent) {
|
||||
val container = csii.container
|
||||
@@ -67,14 +51,13 @@ class StaticItemService : Service() {
|
||||
return
|
||||
}
|
||||
|
||||
val intentChain = IntentChain()
|
||||
val objects = ArrayList<SWGObject>()
|
||||
for (itemName in itemNames) {
|
||||
val obj = StaticItemCreator.createItem(itemName)
|
||||
if (obj != null) {
|
||||
objects.add(obj)
|
||||
obj.moveToContainer(container)
|
||||
intentChain.broadcastAfter(ObjectCreatedIntent(obj))
|
||||
ObjectCreatedIntent.broadcast(obj)
|
||||
} else {
|
||||
Log.d("%s could not be spawned because the item name is unknown", itemName)
|
||||
val requesterOwner = csii.requester.owner
|
||||
@@ -82,17 +65,10 @@ class StaticItemService : Service() {
|
||||
SystemMessageIntent.broadcastPersonal(requesterOwner, String.format("%s could not be spawned because the item name is unknown", itemName))
|
||||
}
|
||||
}
|
||||
|
||||
intentChain.broadcastAfter(CompletedStaticItemCreatedCallbacks(objects, objectCreationHandler::success))
|
||||
|
||||
objectCreationHandler.success(objects);
|
||||
}
|
||||
|
||||
@IntentHandler
|
||||
private fun handleCompletedStaticItemCreatedCallbacks(csicc: CompletedStaticItemCreatedCallbacks) {
|
||||
delayedCallbackHandler.execute(60000) {
|
||||
csicc.objectHandler(csicc.objects)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface ObjectCreationHandler {
|
||||
val isIgnoreVolume: Boolean
|
||||
fun success(createdObjects: List<SWGObject>)
|
||||
@@ -102,7 +78,7 @@ class StaticItemService : Service() {
|
||||
}
|
||||
}
|
||||
|
||||
class LootBoxHandler(private val receiver: CreatureObject) : ObjectCreationHandler {
|
||||
class SystemMessageHandler(private val receiver: CreatureObject) : ObjectCreationHandler {
|
||||
|
||||
override val isIgnoreVolume: Boolean
|
||||
get() = true
|
||||
@@ -113,11 +89,16 @@ class StaticItemService : Service() {
|
||||
for (i in objectIds.indices) {
|
||||
objectIds[i] = createdObjects[i].objectId
|
||||
}
|
||||
|
||||
receiver.sendSelf(ShowLootBox(receiver.objectId, objectIds))
|
||||
|
||||
for (createdObject in createdObjects) {
|
||||
val owner = receiver.owner
|
||||
|
||||
if (owner != null) {
|
||||
SystemMessageIntent.broadcastPersonal(owner, "${createdObject.stringId} has been placed in your inventory.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private data class CompletedStaticItemCreatedCallbacks(val objects: List<SWGObject>, val objectHandler: (createdObjects: List<SWGObject>) -> Unit): Intent()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user