From 478d374548cae871cb133042dda0b650e36997e4 Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Thu, 8 Oct 2015 22:27:38 +0200 Subject: [PATCH 1/2] Refactored the broadcast command scripts to use the IntentFactory --- scripts/commands/generic/cmdBroadcast.js | 4 +--- scripts/commands/generic/cmdBroadcastArea.js | 4 +--- scripts/commands/generic/cmdBroadcastGalaxy.js | 4 +--- scripts/commands/generic/cmdBroadcastPlanet.js | 4 +--- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/scripts/commands/generic/cmdBroadcast.js b/scripts/commands/generic/cmdBroadcast.js index 19b48fb33..16378cd02 100644 --- a/scripts/commands/generic/cmdBroadcast.js +++ b/scripts/commands/generic/cmdBroadcast.js @@ -1,5 +1,3 @@ function executeCommand(galacticManager, player, target, args) { - var ChatBroadcastIntent = Java.type("intents.chat.ChatBroadcastIntent"); - var BroadcastType = Java.type("intents.chat.ChatBroadcastIntent.BroadcastType"); - new ChatBroadcastIntent(args, player, player.getCreatureObject().getLocation().getTerrain(), BroadcastType.PLANET).broadcast(); + intentFactory.broadcastPlanet(player.getCreatureObject().getLocation().getTerrain(), args); } \ No newline at end of file diff --git a/scripts/commands/generic/cmdBroadcastArea.js b/scripts/commands/generic/cmdBroadcastArea.js index 627c7663b..c2fa67f92 100644 --- a/scripts/commands/generic/cmdBroadcastArea.js +++ b/scripts/commands/generic/cmdBroadcastArea.js @@ -1,5 +1,3 @@ function executeCommand(galacticManager, player, target, args) { - var ChatBroadcastIntent = Java.type("intents.chat.ChatBroadcastIntent"); - var BroadcastType = Java.type("intents.chat.ChatBroadcastIntent.BroadcastType"); - new ChatBroadcastIntent(args, player, player.getCreatureObject().getLocation().getTerrain(), BroadcastType.AREA).broadcast(); + intentFactory.broadcastArea(args, player); } \ No newline at end of file diff --git a/scripts/commands/generic/cmdBroadcastGalaxy.js b/scripts/commands/generic/cmdBroadcastGalaxy.js index e2b78cbd5..e17872097 100644 --- a/scripts/commands/generic/cmdBroadcastGalaxy.js +++ b/scripts/commands/generic/cmdBroadcastGalaxy.js @@ -1,5 +1,3 @@ function executeCommand(galacticManager, player, target, args) { - var ChatBroadcastIntent = Java.type("intents.chat.ChatBroadcastIntent"); - var BroadcastType = Java.type("intents.chat.ChatBroadcastIntent.BroadcastType"); - new ChatBroadcastIntent(args, player, player.getCreatureObject().getLocation().getTerrain(), BroadcastType.GALAXY).broadcast(); + intentFactory.broadcastGalaxy(args); } \ No newline at end of file diff --git a/scripts/commands/generic/cmdBroadcastPlanet.js b/scripts/commands/generic/cmdBroadcastPlanet.js index 19b48fb33..16378cd02 100644 --- a/scripts/commands/generic/cmdBroadcastPlanet.js +++ b/scripts/commands/generic/cmdBroadcastPlanet.js @@ -1,5 +1,3 @@ function executeCommand(galacticManager, player, target, args) { - var ChatBroadcastIntent = Java.type("intents.chat.ChatBroadcastIntent"); - var BroadcastType = Java.type("intents.chat.ChatBroadcastIntent.BroadcastType"); - new ChatBroadcastIntent(args, player, player.getCreatureObject().getLocation().getTerrain(), BroadcastType.PLANET).broadcast(); + intentFactory.broadcastPlanet(player.getCreatureObject().getLocation().getTerrain(), args); } \ No newline at end of file From f5d8eeaa703e3846b963ed8c0b4853c6ebdfeda4 Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Fri, 9 Oct 2015 18:57:47 +0200 Subject: [PATCH 2/2] Fixed an issue which prevented galaxy-wide system messages from being broadcasted --- scripts/commands/generic/cmdBroadcastGalaxy.js | 2 +- src/utilities/IntentFactory.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/commands/generic/cmdBroadcastGalaxy.js b/scripts/commands/generic/cmdBroadcastGalaxy.js index e17872097..87f68d666 100644 --- a/scripts/commands/generic/cmdBroadcastGalaxy.js +++ b/scripts/commands/generic/cmdBroadcastGalaxy.js @@ -1,3 +1,3 @@ function executeCommand(galacticManager, player, target, args) { - intentFactory.broadcastGalaxy(args); + intentFactory.broadcastGalaxy(args, player); } \ No newline at end of file diff --git a/src/utilities/IntentFactory.java b/src/utilities/IntentFactory.java index e90d4df35..07fca1c1b 100644 --- a/src/utilities/IntentFactory.java +++ b/src/utilities/IntentFactory.java @@ -37,9 +37,10 @@ public final class IntentFactory { /** * Sends a system message to the entire galaxy. * @param message System message to broadcast. + * @param source The source of this system message. */ - public void broadcastGalaxy(String message) { - broadcast(message, null, BroadcastType.GALAXY); + public void broadcastGalaxy(String message, Player source) { + broadcast(message, source, BroadcastType.GALAXY); } /**