Added null resource checks to survey/sample scripts

This commit is contained in:
Obique PSWG
2017-06-02 21:38:29 -05:00
parent 25527b6333
commit c5383d6507
2 changed files with 20 additions and 0 deletions
@@ -0,0 +1,16 @@
import resources.objects.SWGObject
import resources.player.Player
import services.galaxy.GalacticManager
import com.projectswg.common.debug.Log
import services.crafting.resource.galactic.storage.GalacticResourceContainer
import intents.crafting.survey.SampleResourceIntent
import intents.chat.ChatBroadcastIntent
static def execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
def resource = GalacticResourceContainer.getContainer().getGalacticResourceByName(args)
if (resource == null) {
new ChatBroadcastIntent(player, "Unknown resource: " + args).broadcast()
return
}
new SampleResourceIntent(player.getCreatureObject(), resource).broadcast()
}
@@ -8,6 +8,10 @@ import intents.chat.ChatBroadcastIntent
static def execute(GalacticManager galacticManager, Player player, SWGObject target, String args) {
def resource = GalacticResourceContainer.getContainer().getGalacticResourceByName(args)
if (resource == null) {
new ChatBroadcastIntent(player, "Unknown resource: " + args).broadcast()
return
}
if (player.getCreatureObject().hasAbility("admin")) {
def spawns = GalacticResourceContainer.getContainer().getTerrainResourceSpawns(resource, player.getCreatureObject().getTerrain());
for (int i = 0; i < spawns.size(); i++) {