Jump to content
Sign in to follow this  
Fuzenseth

[MATRIX] Title Manager by Fuzen Seth

Recommended Posts

Why this was done?
To make it easier for you; you know which title you are giving to player instead of checking them all trought live game. I have a different use for this though, and I want to contribrute RSPS community.


TitleManager.java (com.rs.game.player.content)

[CODE]package com.enso.game.player.content;

import com.enso.game.player.Player;
/**
*
* @author Fuzen Seth
* @information Represents a title manager.
* @since 22.6.2014
*/
public class TitleManager {

/**
* Title instance.
*/
private Titles title;

/**
* @author Fuzen Seth
* @information Holds the title ids.
*/
public enum Titles {
JR_CADET(1),SEARJANT(2),COMMMANDER(3),WAR_CHIEF(4),
SIR(5),LORD(6),DUDERINO(7),LIONHEART(8),HELLRAISER(9),RUSADOR(10),
DESPORADO(11),BARON(12),COUNT(13),OVERLORD(14),BANDITO(15),DUKE(16),
KING(17),BIG_CHEESE(18),BIGWIG(19),WUNDERKIND(20),VYRELING(21),VYREGRUNT(22),
VYREWATCH(23), VYRELORD(24), EMPEROR(26), PRINCE(27), WITCH_KING(28), ARCHON(29),
JUSTICIAR(30), THE_AWESOME(31);

private int titleId;

private Titles(int titleId) {
this.titleId = titleId;
}

public int getTitleId() {
return titleId;
}

public void setTitleId(int titleId) {
this.titleId = titleId;
}
}

/**
* Get the titles.
* @return
*/
public Titles getTitle() {
return title;
}
/**
* Removes the title from player.
* @param player
*/
public void removeTitle(Player player) {
if (!(player.getAppearence().getTitle() > 0)) {
player.getDialogueManager().startDialogue("SimpleMessage", "You don't have a title.");
return;
}
player.getAppearence().setTitle(-1);
player.getAppearence().getAppeareanceData();
player.getDialogueManager().startDialogue("SimpleMessage", "Your title has been removed.");
}

/**
* Adds player a title next to his username.
* @param player
* @param title
*/
public void setTitle(Player player, Titles title) {
this.title = title;
player.getAppearence().setTitle(title.getTitleId());
player.getDialogueManager().startDialogue("SimpleMessage", "Your title has been changed.");
}

}
[/CODE]

Add this stuff in player java:
[CODE]private TitleManager titleManager = new TitleManager();[/CODE]

Now this with other getters.
[CODE] public TitleManager getTitleManager() {
return titleManager;
}[/CODE]

Add this in Appearence.java
[CODE] public int getTitle() {
return title;
}[/CODE]

Little tutorial:

How would I now call a title / how I set it to player?
Super easy, this is how you do it.
[CODE]player.getTitleManager().setTitle(Titles.THE_AWESOME);[/CODE]

Hope it helps. ;) Edited by FUZENSETH

Share this post


Link to post
Share on other sites
Nice work Fuzen :) Keep up the great work :)

Share this post


Link to post
Share on other sites
Using an enumeration is a little overkill for this.

Share this post


Link to post
Share on other sites
[quote name='Hope']Using an enumeration is a little overkill for this.[/QUOTE]

What should I use then? add 100 x ints?

Share this post


Link to post
Share on other sites
[quote name='Fuzen Seth']What should I use then? add 100 x ints?[/QUOTE]

I'm actually double thinking my previous answer since literally all that's being used is an integer. Not sure what you have in your appearance file, but it doesn't really matter. You created a whole system to change an integer.

So to change my previous answer:

[B]everything[/B] is overkill for this.

If you had the title string sequence in the appearance file, then I'd consider plopping those into the enum along with the title id's, then it would be logical to use an enumeration.

Share this post


Link to post
Share on other sites
[quote name='Hope']I'm actually double thinking my previous answer since literally all that's being used is an integer. Not sure what you have in your appearance file, but it doesn't really matter. You created a whole system to change an integer.

So to change my previous answer:

[B]everything[/B] is overkill for this.

If you had the title string sequence in the appearance file, then I'd consider plopping those into the enum along with the title id's, then it would be logical to use an enumeration.[/QUOTE]

What would you have used then for this?

Share this post


Link to post
Share on other sites
[quote name='Fuzen Seth']What would you have used then for this?[/QUOTE]

As I said, it really depends on what's in your appearance file and how you edit your titles (if they're in your client or you're sending them to your client).

Share this post


Link to post
Share on other sites
[quote name='Hope']I'm actually double thinking my previous answer since literally all that's being used is an integer. Not sure what you have in your appearance file, but it doesn't really matter. You created a whole system to change an integer.

So to change my previous answer:

[B]everything[/B] is overkill for this.

If you had the title string sequence in the appearance file, then I'd consider plopping those into the enum along with the title id's, then it would be logical to use an enumeration.[/QUOTE]

Why would you have a title string sequence? The title stream in the appearance block is an int so using an enumeration for this is just fine.

Share this post


Link to post
Share on other sites
[quote name='_Jordan']Why would you have a title string sequence? The title stream in the appearance block is an int so using an enumeration for this is just fine.[/QUOTE]

Yeah shame I have bad english haha I was wondering the same.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×