From 0f68d025bb72b7ef1c559b734e47f0270f5d09c7 Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Thu, 8 Sep 2016 18:11:12 +0200 Subject: [PATCH 1/5] Created FlourishIntent --- src/intents/FlourishIntent.java | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/intents/FlourishIntent.java diff --git a/src/intents/FlourishIntent.java b/src/intents/FlourishIntent.java new file mode 100644 index 000000000..e357c1cda --- /dev/null +++ b/src/intents/FlourishIntent.java @@ -0,0 +1,51 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package intents; + +import resources.control.Intent; + +/** + * + * @author Mads + */ +public class FlourishIntent extends Intent { + + public static final String TYPE = "FlourishIntent"; + + private final String flourishName; + + public FlourishIntent(String flourishName) { + super(TYPE); + this.flourishName = flourishName; + } + + public String getFlourishName() { + return flourishName; + } + +} From 633675c3b637da82b595f9521f49f844ba0f5c95 Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Thu, 8 Sep 2016 18:33:12 +0200 Subject: [PATCH 2/5] Added basic support for flourishes --- scripts/commands/generic/cmdFlourish.js | 30 +++++++++++++++++++ src/intents/FlourishIntent.java | 9 +++++- .../commands/EntertainmentService.java | 14 +++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 scripts/commands/generic/cmdFlourish.js diff --git a/scripts/commands/generic/cmdFlourish.js b/scripts/commands/generic/cmdFlourish.js new file mode 100644 index 000000000..0cbc87626 --- /dev/null +++ b/scripts/commands/generic/cmdFlourish.js @@ -0,0 +1,30 @@ +function executeCommand(galacticManager, player, target, args) { + + // No performance, no flourish! + if(!player.getCreatureObject().isPerforming()) { + intentFactory.sendSystemMessage(player, "@performance:flourish_not_performing"); + return; + } + + switch(args) { + case "1": + case "2": + case "3": + case "4": + case "5": + case "6": + case "7": + case "8": + flourishName = "skill_action_" + args; + break; + case "9": + flourishName = "mistake"; + break; + default: + intentFactory.sendSystemMessage(player, "@performance:flourish_not_valid"); + return; + } + + var FlourishIntent = Java.type("intents.FlourishIntent"); + new FlourishIntent(player, flourishName).broadcast(); +} diff --git a/src/intents/FlourishIntent.java b/src/intents/FlourishIntent.java index e357c1cda..f83e30b69 100644 --- a/src/intents/FlourishIntent.java +++ b/src/intents/FlourishIntent.java @@ -28,6 +28,7 @@ package intents; import resources.control.Intent; +import resources.player.Player; /** * @@ -37,13 +38,19 @@ public class FlourishIntent extends Intent { public static final String TYPE = "FlourishIntent"; + private final Player performer; private final String flourishName; - public FlourishIntent(String flourishName) { + public FlourishIntent(Player performer, String flourishName) { super(TYPE); + this.performer = performer; this.flourishName = flourishName; } + public Player getPerformer() { + return performer; + } + public String getFlourishName() { return flourishName; } diff --git a/src/services/commands/EntertainmentService.java b/src/services/commands/EntertainmentService.java index d21519433..ffb931462 100644 --- a/src/services/commands/EntertainmentService.java +++ b/src/services/commands/EntertainmentService.java @@ -28,6 +28,7 @@ package services.commands; import intents.DanceIntent; +import intents.FlourishIntent; import intents.PlayerEventIntent; import intents.chat.ChatBroadcastIntent; import intents.experience.ExperienceIntent; @@ -37,12 +38,14 @@ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import network.packets.swg.zone.object_controller.Animation; import resources.Posture; import resources.client_info.ClientFactory; import resources.client_info.visitors.DatatableData; import resources.control.Intent; import resources.control.Service; import resources.objects.creature.CreatureObject; +import resources.player.Player; import resources.server_info.Log; /** @@ -64,6 +67,7 @@ public class EntertainmentService extends Service { executorService = Executors.newSingleThreadScheduledExecutor(); registerForIntent(DanceIntent.TYPE); registerForIntent(PlayerEventIntent.TYPE); + registerForIntent(FlourishIntent.TYPE); } @Override @@ -97,6 +101,8 @@ public class EntertainmentService extends Service { case PlayerEventIntent.TYPE: handlePlayerEventIntent((PlayerEventIntent) i); break; + case FlourishIntent.TYPE: + handleFlourishIntent((FlourishIntent) i); } } @@ -151,6 +157,14 @@ public class EntertainmentService extends Service { } } + private void handleFlourishIntent(FlourishIntent i) { + Player performer = i.getPerformer(); + CreatureObject performerObject = performer.getCreatureObject(); + + // Send the flourish animation to the owner of the creature and owners of creatures observing + performerObject.sendObserversAndSelf(new Animation(performerObject.getObjectId(), i.getFlourishName())); + new ChatBroadcastIntent(performer, "@performance:flourish_perform").broadcast(); + } /** * Checks if the {@code CreatureObject} is a Novice Entertainer. From d9ff1baa14ab01daad14552469510e2638121e6e Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Thu, 8 Sep 2016 21:20:22 +0200 Subject: [PATCH 3/5] Added missing break statement in EntertainmentService --- src/services/commands/EntertainmentService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/services/commands/EntertainmentService.java b/src/services/commands/EntertainmentService.java index ffb931462..30910c922 100644 --- a/src/services/commands/EntertainmentService.java +++ b/src/services/commands/EntertainmentService.java @@ -103,6 +103,7 @@ public class EntertainmentService extends Service { break; case FlourishIntent.TYPE: handleFlourishIntent((FlourishIntent) i); + break; } } From d45289b41b7ce942a1b3ff7d723b4313168232ef Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Fri, 9 Sep 2016 00:08:27 +0200 Subject: [PATCH 4/5] Refactored flourish command from script to callback and enhanced performance of logic --- scripts/commands/generic/cmdFlourish.js | 30 -------- .../callbacks/FlourishCmdCallback.java | 68 +++++++++++++++++++ src/services/commands/CommandService.java | 1 + 3 files changed, 69 insertions(+), 30 deletions(-) delete mode 100644 scripts/commands/generic/cmdFlourish.js create mode 100644 src/resources/commands/callbacks/FlourishCmdCallback.java diff --git a/scripts/commands/generic/cmdFlourish.js b/scripts/commands/generic/cmdFlourish.js deleted file mode 100644 index 0cbc87626..000000000 --- a/scripts/commands/generic/cmdFlourish.js +++ /dev/null @@ -1,30 +0,0 @@ -function executeCommand(galacticManager, player, target, args) { - - // No performance, no flourish! - if(!player.getCreatureObject().isPerforming()) { - intentFactory.sendSystemMessage(player, "@performance:flourish_not_performing"); - return; - } - - switch(args) { - case "1": - case "2": - case "3": - case "4": - case "5": - case "6": - case "7": - case "8": - flourishName = "skill_action_" + args; - break; - case "9": - flourishName = "mistake"; - break; - default: - intentFactory.sendSystemMessage(player, "@performance:flourish_not_valid"); - return; - } - - var FlourishIntent = Java.type("intents.FlourishIntent"); - new FlourishIntent(player, flourishName).broadcast(); -} diff --git a/src/resources/commands/callbacks/FlourishCmdCallback.java b/src/resources/commands/callbacks/FlourishCmdCallback.java new file mode 100644 index 000000000..085525402 --- /dev/null +++ b/src/resources/commands/callbacks/FlourishCmdCallback.java @@ -0,0 +1,68 @@ +/************************************************************************************ + * Copyright (c) 2015 /// Project SWG /// www.projectswg.com * + * * + * ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * + * July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * + * Our goal is to create an emulator which will provide a server for players to * + * continue playing a game similar to the one they used to play. We are basing * + * it on the final publish of the game prior to end-game events. * + * * + * This file is part of Holocore. * + * * + * -------------------------------------------------------------------------------- * + * * + * Holocore is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * Holocore is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with Holocore. If not, see . * + * * + ***********************************************************************************/ +package resources.commands.callbacks; + +import intents.FlourishIntent; +import intents.chat.ChatBroadcastIntent; +import resources.commands.ICmdCallback; +import resources.objects.SWGObject; +import resources.player.Player; +import services.galaxy.GalacticManager; + +/** + * + * @author Mads + */ +public class FlourishCmdCallback implements ICmdCallback { + + @Override + public void execute(GalacticManager galacticManager, Player player, SWGObject target, String args) { + // No performance, no flourish! + if (!player.getCreatureObject().isPerforming()) { + new ChatBroadcastIntent(player, "@performance:flourish_not_performing").broadcast(); + return; + } + + try { + int flourishNumber = Integer.parseInt(args); + + if(flourishNumber < 0 || flourishNumber > 9) { + new ChatBroadcastIntent(player, "@performance:flourish_not_valid").broadcast(); + } else if(flourishNumber == 9) { + new FlourishIntent(player, "mistake").broadcast(); + } else { + new FlourishIntent(player, "skill_action_" + flourishNumber).broadcast(); + } + } catch (NumberFormatException e) { + new ChatBroadcastIntent(player, "@performance:flourish_not_valid").broadcast(); + } + + + } + +} diff --git a/src/services/commands/CommandService.java b/src/services/commands/CommandService.java index 71adee345..6c4cf0555 100644 --- a/src/services/commands/CommandService.java +++ b/src/services/commands/CommandService.java @@ -313,6 +313,7 @@ public class CommandService extends Service { registerCallback("goto", GotoCmdCallback.class); registerCallback("startDance", StartDanceCallback.class); registerCallback("requestBiography", RequestBiographyCmdCallback.class); + registerCallback("flourish", FlourishCmdCallback.class); } private void clearCommands() { From 3281f3d63039d7ed556503beb92029c26327ff75 Mon Sep 17 00:00:00 2001 From: Mads Boddum Date: Fri, 9 Sep 2016 00:09:08 +0200 Subject: [PATCH 5/5] Fixed a logic error with flourishes that allowed for /flourish 0 --- src/resources/commands/callbacks/FlourishCmdCallback.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/resources/commands/callbacks/FlourishCmdCallback.java b/src/resources/commands/callbacks/FlourishCmdCallback.java index 085525402..592067971 100644 --- a/src/resources/commands/callbacks/FlourishCmdCallback.java +++ b/src/resources/commands/callbacks/FlourishCmdCallback.java @@ -51,7 +51,7 @@ public class FlourishCmdCallback implements ICmdCallback { try { int flourishNumber = Integer.parseInt(args); - if(flourishNumber < 0 || flourishNumber > 9) { + if(flourishNumber < 1 || flourishNumber > 9) { new ChatBroadcastIntent(player, "@performance:flourish_not_valid").broadcast(); } else if(flourishNumber == 9) { new FlourishIntent(player, "mistake").broadcast();