Jump to content

Question

Posted

hello I have a doubt I'm creating a configuration to limit casting speed for each class but if the value of a class is different from the other I have the value of the last configuration.

 

I created a loop to map all configuration:

int val = (int) calcStat(Stats.MAGIC_ATTACK_SPEED, base, null, null);
		for (String className : Config.LIMIT_CASTING_SPEED.keySet())
		{
			if (Config.LIMIT_CASTING_SPEED.containsKey(_actor.getClassId().toString()) && val > Config.LIMIT_CASTING_SPEED.get(className))
				val = Config.LIMIT_CASTING_SPEED.get(className);
		}

 

 

Cardinal-1000;Arcana Lord-1300

 

let's say if the value is like this I get 1300 for all.

Fixed I used the java 17 documentation to understand a little about Maps Map (Java SE 17 & JDK 17) (oracle.com)

3 answers to this question

Recommended Posts

  • 0
Posted
				final Map<String, Integer> map = new HashMap<>();
				final String[] input = "Cardinal-1000;Arcana Lord-1300".split(";");
				for (String s : input) {
					final String[] split2 = s.split("-");
					map.put(split2[0], Integer.parseInt(split2[1]));
				}
                  
                // to test
				for (Entry<String, Integer> ent : map.entrySet()) {
					Announcements.announceToAll("k " + ent.getKey());
					Announcements.announceToAll("v " + ent.getValue());
				}
                  
                  // to use				
                int val = activeChar.getMAtkSpd();
				if (map.containsKey(activeChar.getClassId().getName()))
					val = Math.min(map.getOrDefault(activeChar.getClassId().getName(), activeChar.getMAtkSpd()), activeChar.getMAtkSpd());

 

image.png.502b98abbce2652a6f270da3b7e40a40.png

 

this?

  • 0
Posted
34 minutes ago, eMommy said:
				final Map<String, Integer> map = new HashMap<>();
				final String[] input = "Cardinal-1000;Arcana Lord-1300".split(";");
				for (String s : input) {
					final String[] split2 = s.split("-");
					map.put(split2[0], Integer.parseInt(split2[1]));
				}
                  
                // to test
				for (Entry<String, Integer> ent : map.entrySet()) {
					Announcements.announceToAll("k " + ent.getKey());
					Announcements.announceToAll("v " + ent.getValue());
				}
                  
                  // to use				
                int val = activeChar.getMAtkSpd();
				if (map.containsKey(activeChar.getClassId().getName()))
					val = Math.min(map.getOrDefault(activeChar.getClassId().getName(), activeChar.getMAtkSpd()), activeChar.getMAtkSpd());

 

image.png.502b98abbce2652a6f270da3b7e40a40.png

 

this?

 

I used keySet() found it more viable

 

Screenshot_29.png.981eb51c2a292493e07130ca30ea6f5c.png

 


        for (String className : Config.LIMIT_CASTING_SPEED.keySet())
        {
            if (className.equals(_actor.getClassId().toString()))
                val = Config.LIMIT_CASTING_SPEED.get(className);
        }
        

  • 0
Posted (edited)

I strongly recommend you to build around dynamic arrays, even a Set<> will be using quite less memory (even if that may already be insignificant), and might be excesivelly efficient on cpu-consuming tasks. A primitive ArrayOf[Object()] will be really faster and more convenient using the ClassID as the key for the value.


This kind of evaluations are sortta unnecessary
 

int val = (int) calcStat(Stats.MAGIC_ATTACK_SPEED, base, null, null);
		for (String className : Config.LIMIT_CASTING_SPEED.keySet())
		{
			if (Config.LIMIT_CASTING_SPEED.containsKey(_actor.getClassId().toString()) && val > Config.LIMIT_CASTING_SPEED.get(className))
				val = Config.LIMIT_CASTING_SPEED.get(className);
		}

 

Have in mind that, FOR EACH String inside your Config, the loop will be doing X function in order to find the requested value, repeating this for every Class that is requested to acquire the desired value.

Meanwhile, a simple Array[Int[]] will be faster and much more efficient:

Int[][] class_castSpd_value;

int val = class_castSpd_value[classId];

 

Edited by Bellion_Epica

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   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.



  • Posts

    • SocNet is looking for new suppliers! — Snapchat accounts  — Reddit accounts with karma  — LinkedIn accounts with real connections Message us or contact support — let’s discuss terms! We’re also open to other partnership opportunities. Our Online Store Offers: ➡ Accounts: Telegram, Facebook, Reddit, Twitter (X), Instagram, YouTube, TikTok, Discord, VK, LinkedIn, GitHub, Snapchat, Gmail, Emails (Outlook, Firstmail, Rambler, Onet, Gazeta, GMX, Yahoo, Proton, Web.de), Google Voice, Google Ads ➡ Premium Subscriptions: Telegram Premium, Twitter Premium X, YouTube Premium, Spotify Premium, Netflix Premium, Discord Nitro, ChatGPT Plus/PRO, XBOX Game Pass ➡ Additional Services: Telegram Stars, Proxies (IPv4, IPv6, ISP, Mobile), VPN (Outline, WireGuard, etc.), VDS/RDP Servers SMM Panel Services: ➡ Use our SMM Panel to boost Facebook, Instagram, Telegram, Spotify, Soundcloud, YouTube, Reddit, Threads, Kick, Discord, LinkedIn, Likee, VK, Twitch, Kwai, Reddit, website traffic, TikTok, TrustPilot, Apple Music, Tripadvisor, Snapchat, and more. Promo code for store discount: PARTNER8 (8% off) Get $1 trial balance for the SMM Panel: Submit a ticket titled “Get Trial Bonus” via our website (Support) ➡ Go to the SMM Panel (clickable) or contact us through the bot Our Key Products: ➡ Online Store: Click ➡ Telegram Shop Bot: Click ➡ SMM Panel: Click Payments accepted: Bank cards · Crypto · Other popular methods Returning buyers receive extra discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store ➡ Telegram Channel: https://t.me/accsforyou_shop You can also use these contacts to: — Discuss bulk orders — Form partnerships (Current partners: https://socnet.bgng.io/partners ) — Become our supplier SocNet — your digital goods & subscription store
    • SocNet is looking for new suppliers! — Snapchat accounts  — Reddit accounts with karma  — LinkedIn accounts with real connections Message us or contact support — let’s discuss terms! We’re also open to other partnership opportunities. Our Online Store Offers: ➡ Accounts: Telegram, Facebook, Reddit, Twitter (X), Instagram, YouTube, TikTok, Discord, VK, LinkedIn, GitHub, Snapchat, Gmail, Emails (Outlook, Firstmail, Rambler, Onet, Gazeta, GMX, Yahoo, Proton, Web.de), Google Voice, Google Ads ➡ Premium Subscriptions: Telegram Premium, Twitter Premium X, YouTube Premium, Spotify Premium, Netflix Premium, Discord Nitro, ChatGPT Plus/PRO, XBOX Game Pass ➡ Additional Services: Telegram Stars, Proxies (IPv4, IPv6, ISP, Mobile), VPN (Outline, WireGuard, etc.), VDS/RDP Servers SMM Panel Services: ➡ Use our SMM Panel to boost Facebook, Instagram, Telegram, Spotify, Soundcloud, YouTube, Reddit, Threads, Kick, Discord, LinkedIn, Likee, VK, Twitch, Kwai, Reddit, website traffic, TikTok, TrustPilot, Apple Music, Tripadvisor, Snapchat, and more. Promo code for store discount: PARTNER8 (8% off) Get $1 trial balance for the SMM Panel: Submit a ticket titled “Get Trial Bonus” via our website (Support) ➡ Go to the SMM Panel (clickable) or contact us through the bot Our Key Products: ➡ Online Store: Click ➡ Telegram Shop Bot: Click ➡ SMM Panel: Click Payments accepted: Bank cards · Crypto · Other popular methods Returning buyers receive extra discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store ➡ Telegram Channel: https://t.me/accsforyou_shop You can also use these contacts to: — Discuss bulk orders — Form partnerships (Current partners: https://socnet.bgng.io/partners ) — Become our supplier SocNet — your digital goods & subscription store
    • SocNet is looking for new suppliers! — Snapchat accounts  — Reddit accounts with karma  — LinkedIn accounts with real connections Message us or contact support — let’s discuss terms! We’re also open to other partnership opportunities. Our Online Store Offers: ➡ Accounts: Telegram, Facebook, Reddit, Twitter (X), Instagram, YouTube, TikTok, Discord, VK, LinkedIn, GitHub, Snapchat, Gmail, Emails (Outlook, Firstmail, Rambler, Onet, Gazeta, GMX, Yahoo, Proton, Web.de), Google Voice, Google Ads ➡ Premium Subscriptions: Telegram Premium, Twitter Premium X, YouTube Premium, Spotify Premium, Netflix Premium, Discord Nitro, ChatGPT Plus/PRO, XBOX Game Pass ➡ Additional Services: Telegram Stars, Proxies (IPv4, IPv6, ISP, Mobile), VPN (Outline, WireGuard, etc.), VDS/RDP Servers SMM Panel Services: ➡ Use our SMM Panel to boost Facebook, Instagram, Telegram, Spotify, Soundcloud, YouTube, Reddit, Threads, Kick, Discord, LinkedIn, Likee, VK, Twitch, Kwai, Reddit, website traffic, TikTok, TrustPilot, Apple Music, Tripadvisor, Snapchat, and more. Promo code for store discount: PARTNER8 (8% off) Get $1 trial balance for the SMM Panel: Submit a ticket titled “Get Trial Bonus” via our website (Support) ➡ Go to the SMM Panel (clickable) or contact us through the bot Our Key Products: ➡ Online Store: Click ➡ Telegram Shop Bot: Click ➡ SMM Panel: Click Payments accepted: Bank cards · Crypto · Other popular methods Returning buyers receive extra discounts and promo codes! Support: ➡ Telegram: https://t.me/solomon_bog ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ Email: solomonbog@socnet.store ➡ Telegram Channel: https://t.me/accsforyou_shop You can also use these contacts to: — Discuss bulk orders — Form partnerships (Current partners: https://socnet.bgng.io/partners ) — Become our supplier SocNet — your digital goods & subscription store
    • The links are down, why do you publish something that you're just going to delete later?
  • Topics

×
×
  • 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