Jump to content

Spree Kills aCis 382


Williams

Recommended Posts

Good night, I come to share a code that I made for my project, I will give a simple tutorial how to use the music part of it.

 

Code: https://pastebin.com/raw/ezfEX1kJ

 

Well I made the code simple and very easy to edit, you only need to edit in one place to add messages, music, PVP amount !!

 

The format is PVP, Message and Music quantity.

 

PVP amount = 2

Generated Message = Double Kill

Music = "" here the music.

DOUBLE_KILL (2, "Double Kill", "YOUR MUSIC"),

 

h9p8okO.jpg

 

The song is on you, I hope you like it and don't forget to like it.

 

here is version 2 in xml and totally redone by Tryskell's tips

 

thanks to @StinkyMadness for the idea of creating in xml

 

Version 2 https://pastebin.com/raw/5cwXuTTc

 

Credits for the idea @Kara`

Unfinished credits @Williams

 

ATTENTION : I'm sorry for some BR messages

Edited by Williams
Link to comment
Share on other sites

I guess you want to unhardcode that

if (kills.getKills() == 15)

and instead use the highest available number from your enum.

--------

public void setIncreaseKills()

should be renamed

public void increaseSpreeKills()

-------

While not impacting performance with such low amount of options, it is recommended and, you still should

break;

once a valid number has been found on your

for (SpreeKills kills : SpreeKills.values())

To avoid to iterate the whole thing.

-------

You probably want to check if

kills.getSound()

is empty before sending a pointless empty packet.

if (!kills.getSound().isEmpty())
	sendPacket(new PlaySound(kills.getSound()));

------

Your configs are different than the default version. As a share, you should unify them.

+		ENABLE_SPREEKILLS = players.getProperty("EnableSpreeKills", false);
+		SPREEKILLS_REWARD = players.parseIntIntList("RewardSpreeKills", "9209-1");

!=

+EnableSpreeKills = True
+RewardSpreeKills = 9217-5

------

The sound String on your enum is currently empty, and there is no config to edit it. I suppose people have to set their own sounds in the enum, but still you should at least give some default sounds, or at least // quote them somewhere for easier use.

Edited by Tryskell
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Tryskell said:

I guess you want to unhardcode that


if (kills.getKills() == 15)

and instead use the highest available number from your enum.

--------


public void setIncreaseKills()

should be renamed


public void increaseSpreeKills()

-------

While not impacting performance with such low amount of options, it is recommended and, you still should


break;

once a valid number has been found on your


for (SpreeKills kills : SpreeKills.values())

To avoid to iterate the whole thing.

-------

You probably want to check if


kills.getSound()

is empty before sending a pointless empty packet.


if (!kills.getSound().isEmpty())
	sendPacket(new PlaySound(kills.getSound()));

------

Your configs are different than the default version. As a share, you should unify them.


+		ENABLE_SPREEKILLS = players.getProperty("EnableSpreeKills", false);
+		SPREEKILLS_REWARD = players.parseIntIntList("RewardSpreeKills", "9209-1");

!=


+EnableSpreeKills = True
+RewardSpreeKills = 9217-5

------

The sound String on your enum is currently empty, and there is no config to edit it. I suppose people have to set their own sounds in the enum, but still you should at least give some default sounds, or at least // quote them somewhere for easier use.

 

the bad is trysekll dosent undestand greek but im sure someone can translate him  :P

p.s on topic thank you for share my friend keep on.

Link to comment
Share on other sites

12 hours ago, Tryskell said:

I guess you want to unhardcode that


if (kills.getKills() == 15)

and instead use the highest available number from your enum.

--------


public void setIncreaseKills()

should be renamed


public void increaseSpreeKills()

-------

While not impacting performance with such low amount of options, it is recommended and, you still should


break;

once a valid number has been found on your


for (SpreeKills kills : SpreeKills.values())

To avoid to iterate the whole thing.

-------

You probably want to check if


kills.getSound()

is empty before sending a pointless empty packet.


if (!kills.getSound().isEmpty())
	sendPacket(new PlaySound(kills.getSound()));

------

Your configs are different than the default version. As a share, you should unify them.


+		ENABLE_SPREEKILLS = players.getProperty("EnableSpreeKills", false);
+		SPREEKILLS_REWARD = players.parseIntIntList("RewardSpreeKills", "9209-1");

!=


+EnableSpreeKills = True
+RewardSpreeKills = 9217-5

------

The sound String on your enum is currently empty, and there is no config to edit it. I suppose people have to set their own sounds in the enum, but still you should at least give some default sounds, or at least // quote them somewhere for easier use.

 

topic updated with version 2 at a glance now written in xml

Link to comment
Share on other sites

Still missing the

break;

Should be

 

+					for (SpreeKills kills : SpreeKillsData.getInstance().getSpreeKills())
+					{
+						if (kills.getKills() == _spreeKills)
+						{
+							World.announceToOnlinePlayers(getName() + " marked " + kills.getMsg(), true);
+							
+							if (!kills.getSound().isEmpty())
+								sendPacket(new PlaySound(2, kills.getSound()));
+							
+							if (kills.getItemId() > 0)
+								addItem("Reward", kills.getItemId(), kills.getItemCount(), null, true);
+							
+							break;
+						}
+					}

-------

 

You could add an empty check for getMsg() use as you did before

 

if (!kills.getMsg().isEmpty())
	World.announceToOnlinePlayers(getName() + " marked " + kills.getMsg(), true);

 

Edited by Tryskell
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock