Tryskell Posted January 5, 2019 Share Posted January 5, 2019 (edited) findAny() can't be used as a counterpart of Rnd. It only means it doesn't guarantee any order based on your Stream. You can - or can't - retrieve exactly the same order. But most likely, it will produce exactly the same content. Meaning you will never see some of your maps. In a non-parallel operation, it will most likely return the first element in the Stream but there is no guarantee for this. You have to Rnd.get(list). Edited January 5, 2019 by Tryskell Quote Link to comment Share on other sites More sharing options...
SweeTs Posted January 5, 2019 Share Posted January 5, 2019 Yep, just did some tests and it's returning first element. Yet, it can do the trick, BUT first you have to use shuffle. Quote Link to comment Share on other sites More sharing options...
Tryskell Posted January 5, 2019 Share Posted January 5, 2019 34 minutes ago, SweeTs said: Yep, just did some tests and it's returning first element. Yet, it can do the trick, BUT first you have to use shuffle. Less costy to pick a random element than to shuffle a whole container. And your point is to pick a single element, not the whole list, so shuffling the whole list is pointless. Quote Link to comment Share on other sites More sharing options...
SweeTs Posted January 5, 2019 Share Posted January 5, 2019 @Tryskell, as always speaks well. Old school while for the win or as @melron suggested, start from 1 and ++. Quote Link to comment Share on other sites More sharing options...
Elfo Posted January 5, 2019 Share Posted January 5, 2019 (edited) a Edited October 1, 2021 by Elfocrash Quote Link to comment Share on other sites More sharing options...
xdem Posted January 5, 2019 Share Posted January 5, 2019 2 hours ago, Kara` said: Didn't know we need also that check. RandomZone selectedZone = ZoneManager.getInstance().getAllZones(RandomZone.class).stream().filter(s -> s.getId() != getCurrentZone().getId()).findAny().orElse(null); In null you can add to return the same zone if no other exist. I write it in notepad++ so i cannot know if syntax is ok did you just imply that you wrote this code right out of your mind in a simple text editor? What kind of psychotic autistic lair attention whore bitch can someone be, really Quote Link to comment Share on other sites More sharing options...
xdem Posted January 5, 2019 Share Posted January 5, 2019 (edited) for randomness I would go with a jackpot-like random generator pool, feel free to use my code https://pastebin.com/SZq07PZy your jackpot weight should be an inversion of current zone hits Edited January 5, 2019 by xdem Quote Link to comment Share on other sites More sharing options...
Kara Posted January 5, 2019 Share Posted January 5, 2019 Trash code as always posted by xxdem. The attention whore came as always. Quote Link to comment Share on other sites More sharing options...
Gezis Posted March 31, 2019 Share Posted March 31, 2019 (edited) Hello MXC members, maybe anyone try this zone changer? I try but I can't change zones from ZoneManager.xml If I change loc's not move me to other zone or maybe only can use arena type? anyone know how to fix? Also only Cuboid can use? Because i try make NPoly and get error to console. Help to me pls. Edited March 31, 2019 by Gezis Quote Link to comment Share on other sites More sharing options...
StinkyMadness Posted April 1, 2019 Author Share Posted April 1, 2019 5 hours ago, Gezis said: ... Code is working fine and with zone type RandomZone not with Arena Also ofc you can use NPoly, the diff is coded on aCis 377 if you have older version or newest you have to adapt parts of code. Quote Link to comment Share on other sites More sharing options...
Gezis Posted April 1, 2019 Share Posted April 1, 2019 Yes code working to me, but I say about random zone with other locs :) maybe my fault with xml idk. But I chancge only from "CuboId" to "NPoly" Quote Link to comment Share on other sites More sharing options...
StinkyMadness Posted April 1, 2019 Author Share Posted April 1, 2019 (edited) 50 minutes ago, Gezis said: Yes code working to me, but I say about random zone with other locs :) maybe my fault with xml idk. But I chancge only from "CuboId" to "NPoly" Cuboid required : 2 node locations. NPoly required : 3+ node locations. //Edit Here is one good tutorial from @SweeTs Tutorial Link Edited April 1, 2019 by StinkyMadness Quote Link to comment Share on other sites More sharing options...
Gezis Posted April 1, 2019 Share Posted April 1, 2019 Yes my bad, working with NPoly, but not move to next zone, with default zones (Arena) move. My zones: <?xml version="1.0" encoding="UTF-8"?> <list> <!-- Random Zones --> <zone type="RandomZone" shape="NPoly" minZ="9080" maxZ="11080"><!-- gludin_pvp --> <stat name="id" val="1"/> <stat name="name" val="Gludin Arena"/> <stat name="time" val="120"/><!-- time in seconds --> <stat name="locs" val="114264,16280,10080;115009,15114,10080"/> <node X="115736" Y="16152" /> <node X="116056" Y="16872" /> <node X="114856" Y="17768" /> <node X="114083" Y="17376" /> <node X="113140" Y="14874" /> <node X="114264" Y="15650" /> <spawn X="114264" Y="16280" Z="10080" /> </zone> <zone type="RandomZone" shape="NPoly" minZ="9080" maxZ="11080"><!-- gludin_pvp --> <stat name="id" val="2"/> <stat name="name" val="Arena"/> <stat name="time" val="120"/><!-- time in seconds --> <stat name="locs" val="114264,16280,10080;115009,15114,10080"/> <node X="115736" Y="16152" /> <node X="116056" Y="16872" /> <node X="114856" Y="17768" /> <node X="114083" Y="17376" /> <node X="113140" Y="14874" /> <node X="114264" Y="15650" /> <spawn X="114264" Y="16280" Z="10080" /> </zone> </list> Quote Link to comment Share on other sites More sharing options...
StinkyMadness Posted April 1, 2019 Author Share Posted April 1, 2019 (edited) 43 minutes ago, Gezis said: .... Nice zone... its around the TOP of the Sky take a look on you minZ maxZ.... also aCis have //check_zone if there not appear "random zone" then your nodes are wrong... but on current XML the minZ maxZ looks TOTAL to much... If you are not inside zone how you will be teleport ? Edited April 1, 2019 by StinkyMadness Quote Link to comment Share on other sites More sharing options...
Gezis Posted April 1, 2019 Share Posted April 1, 2019 I make zone with creat zone modification. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.