-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DNM] Initial Astreaus Dialogue System Rip #631
Open
Dark98
wants to merge
1
commit into
2006-Scape:master
Choose a base branch
from
Dark98:dialogue-plugin-system
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
2006Scape Server/plugins/plugin/buttons/DialogueOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package plugin.buttons; | ||
|
||
import com.rs2.event.SubscribesTo; | ||
import com.rs2.event.impl.ButtonActionEvent; | ||
import com.rs2.game.dialog.Dialogue; | ||
import com.rs2.game.players.Player; | ||
|
||
@SubscribesTo(ButtonActionEvent.class) | ||
public final class DialogueOptions extends ButtonClick { | ||
|
||
@Override | ||
protected void execute(Player player, ButtonActionEvent event) { | ||
switch (event.getButton()) { | ||
|
||
// First Option (Option Interfaces 2, 3, 4, and 5) | ||
case 9157: | ||
case 9167: | ||
case 9178: | ||
case 9190: | ||
player.getDialogueFactory().executeOption(0, player.getOptionDialogue()); | ||
break; | ||
// Second Option (Option Interfaces 2, 3, 4, and 5) | ||
case 9158: | ||
case 9168: | ||
case 9179: | ||
case 9191: | ||
player.getDialogueFactory().executeOption(1, player.getOptionDialogue()); | ||
break; | ||
// Third Option (Option Interfaces 3, 4, and 5) | ||
case 9169: | ||
case 9180: | ||
case 9192: | ||
player.getDialogueFactory().executeOption(2, player.getOptionDialogue()); | ||
break; | ||
// Fourth Option (Option Interfaces 4 and 5) | ||
case 9181: | ||
case 9193: | ||
player.getDialogueFactory().executeOption(3, player.getOptionDialogue()); | ||
break; | ||
// Fifth Option (Option Interface 5) | ||
case 9194: | ||
player.getDialogueFactory().executeOption(4, player.getOptionDialogue()); | ||
break; | ||
|
||
} | ||
} | ||
|
||
@Override | ||
public boolean test(ButtonActionEvent event) { | ||
return Dialogue.isDialogueButton(event.getButton()); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
2006Scape Server/plugins/plugin/npc/shopkeeper/FirstClick.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package plugin.npc.shopkeeper; | ||
|
||
import com.rs2.event.EventContext; | ||
import com.rs2.event.EventSubscriber; | ||
import com.rs2.event.SubscribesTo; | ||
import com.rs2.event.impl.NpcFirstClickEvent; | ||
import com.rs2.game.players.Player; | ||
|
||
import static com.rs2.game.content.StaticNpcList.SHOP_KEEPER_528; | ||
|
||
@SubscribesTo(NpcFirstClickEvent.class) | ||
public final class FirstClick implements EventSubscriber<NpcFirstClickEvent> { | ||
|
||
@Override | ||
public void subscribe(EventContext context, Player player, NpcFirstClickEvent event) { | ||
if (player.playerRights == 3) { | ||
player.getPacketSender().sendMessage("[click= npc], [type = first], [id= " + event.getNpc() + "], [Type= " + event.getNpc() + "]"); | ||
} | ||
|
||
switch (event.getNpc()) { | ||
|
||
case SHOP_KEEPER_528: | ||
player.getDialogueFactory().sendDialogue(new GeneralStoreDialogue()); | ||
break; | ||
} | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
2006Scape Server/plugins/plugin/npc/shopkeeper/GeneralStoreDialogue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package plugin.npc.shopkeeper; | ||
|
||
import com.rs2.game.dialog.Dialogue; | ||
import com.rs2.game.dialog.DialogueFactory; | ||
|
||
|
||
public final class GeneralStoreDialogue extends Dialogue { | ||
@Override | ||
public void sendDialogues(DialogueFactory factory) { | ||
factory.getPlayer().dialoguePlugin = true; | ||
factory.sendNpcChat("Can I help you at all?") | ||
.sendOption("Yes please. What are you selling?", () -> { | ||
factory.onAction(() -> { | ||
factory.getPlayer().getShopAssistant().openShop(88); | ||
}); | ||
}, "No thanks.", () -> { | ||
factory.sendPlayerChat("No thanks."); | ||
}).execute(); | ||
} | ||
|
||
} | ||
|
13 changes: 13 additions & 0 deletions
13
2006Scape Server/src/main/java/com/rs2/game/dialog/Chainable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.rs2.game.dialog; | ||
|
||
import java.util.function.Consumer; | ||
|
||
/** | ||
* The chain-able interface that allows implementing dialogue factories the ability to chain together. | ||
* | ||
* @author Vult-R | ||
*/ | ||
public interface Chainable extends Consumer<DialogueFactory> { | ||
|
||
} | ||
|
45 changes: 45 additions & 0 deletions
45
2006Scape Server/src/main/java/com/rs2/game/dialog/Dialogue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.rs2.game.dialog; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.rs2.game.players.Player; | ||
|
||
/** | ||
* Represents an abstract dialogue, in which extending classes will be able to construct and send dialogues | ||
* to a player. | ||
* | ||
* @author Vult-R | ||
*/ | ||
public abstract class Dialogue { | ||
|
||
private static Player player; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be static. |
||
|
||
/** | ||
* The action buttons responsible for dialogues. | ||
*/ | ||
public static final ImmutableList<Integer> DIALOGUE_BUTTONS = ImmutableList.of(9157, 9167, 9178, 9190, | ||
9158, 9168, 9179, 9191, 9169, 9180, 9192, 9181, 9193, 9194); | ||
|
||
/** | ||
* Sends a player a dialogue. | ||
* | ||
* @param factory | ||
* The factory for this dialogue. | ||
*/ | ||
public abstract void sendDialogues(DialogueFactory factory); | ||
|
||
/** | ||
* Checks if the button triggered is an optional dialogue button. | ||
* | ||
* @param button | ||
* The index of the button being checked. | ||
* | ||
* @return The result of the operation. | ||
*/ | ||
public static final boolean isDialogueButton(int button) { | ||
if (player.dialoguePlugin) { | ||
return DIALOGUE_BUTTONS.stream().anyMatch(search -> search == button); | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name the variable here dialogue, not factory, since dialogue is a more descriptive name of what it is.