#help-development
1 messages ยท Page 1628 of 1
is this what you wanted
I'm no dog here
no you're Illusion
;)
Cringe.
yeah
Yeah like, I know very well how clients and servers communicate
But not relating to Minecraft, and I've been scared to try it
Just like I haven't wanted to try NMS. Is NMS mapped well?
Not really
Shoot
ProtocolLib is a fancy wrapper for NMS packet stuff
I see NMS as just like
Decompile
and see what does what
Is there a lot of obfuscated shit?
everything
Man
Just use that maven / gradle plugin that md_5 made
that kinda remaps the jars
and the code
"Oh, an arrow's velocity? Sure man it's just f_17239182776482631_"
BRUH
and some very specific numbers
Yeah I'd imagine there's magic numbers all over the place
for no reason
There must be some
Also the most common NMS things are documented
You know the quake fast inverse square?
Yeah I've seen it
Magic number
It's some floating point hack
Yeah it's very well done
bump
The magic number is there to make sure the error margin is only 1%
Ever since I saw it, I've respected magic numbers a bit more
I swear I thought I replied to this
Plugins use invisible armorstands / entities to add multiple lines
Unless you're talking about entity metadata packets where each player sees a different name
Not sure what you're trying to do here
"Society if NMS was mapped as well as Forge"
pretty sure forge is just some nms refactoring without the lawsuits
problem with NMS is intellectual property
What lawsuits could there even be?
DMCA
It's custom deobfuscation
You're joking, right?
"It just happens to be similar enough to our real code"
Like come on man
Oh, for real?
It comes to a point where you can't tell if it's original with some slight name changes or if it's the distributed one with custom deobf
The code is not seriously obfuscated, all of the fields and methods are just renamed to a single letter
It's like the most basic proguard obfuscation
Yeah, like, just making sure the names of stuff isn't a bunch of numbers
But not "real" deobf
it's never a bunch of numbers
Isn't it?
it's always just a, b
a single letter
Except the bukkit / spigot / whatever patches have nice names too
I feel like I remember functions in Forge that weren't mapped named something like...fuckin f_18938_ or something
Is there a way to do something like java Bukkit.getOfflinePlayers().forEach
That's literally it
for(OfflinePlayer player : Bukkit.getOfflinePlayers())
updated it
ah ok
It's actually an array
is it?
I prefer the traditional for loop
In that case yeah nvm
but if you really want to use streams
Arrays.stream
Yes
Ah, @SafeVarargs
I need to read what that does again
Something about generic heap pollution, it was weird
it just suppresses some compiler warning
Yes, because it's dangerous
and makes sure the compiler doesn't get anxiety from all these objects ๐
It was an array in 1.7
That method was removed. It's a Collection<? extends Player>
OfflinePlayers is an array
Oh, offline players
OnlinePlayers is a collection
Wildcards aren't returned
Or well, if you do...I just wanna talk
Sure they do. And when you write an API like Bukkit, ? extends Player is the correct type over just Player
I want to support 1.17 in my plugin. Is this possible? I was told 1.17 made ALOT of changes and it's
a) not possible
b) a massive pain
is this true?
Not really
not as bad as 1.12 -> 1.13
This is a plugin that uses alot of nms
just do that fancy stuff with the nms where you have a package for each version
does Bukkit.getOfflinePlayers() only get offline players?
Middle click on it and it will tell you
but, yes it does
Interface the NMS changes across versions, and load the correct implementation on startup
Since Player extends OfflinePlayer and the docs aren't really clear about it being offline specific so we assume it's all
It does send all players
It sends every player that has ever joined the server
At least as far as the server's player data is concerned
thats why I used it for player data LMFAO
Uhuh
If this guy is doing getOfflinePlayer for some name check I swear
LOL
na it's for other stuff
let's hope
Because when you return a Collection<? extends Player> you're denoting that it returns some implementation of Player. It's an upper bound generic. That method should, when implemented, return a list of objects that implement Player. As far as Bukkit is concerned, that could be either a GlowPlayer or a CraftPlayer. Also, as an added benefit, they're almost treated like read-only arrays. They're not, but they can be treated as one because one cannot do Bukkit.getOnlinePlayers().add(new Player() { /* and then implementing all the methods */ });. It will throw a compile error
I can tell choco likes writing essays
Then it makes sense, alright
I wanna make a prison server. Never made one only played them ALOT
Since it's an upper bound, it's a producer Collection, so I assumed it was unmodifiable @worldly ingot
to not confuse the new devs just make it return some immutable Collection<Player>
Here's a good explanation of it, https://stackoverflow.com/questions/18382694/returning-collection-extends-type-vs-collectiontype
The only reason I thought it'd made sense is if different types are being handled under the hood, and that's just what was the case
every time I see a \o/ I think of a shocked face
Right. iirc there's a List<CraftPlayer> in implementation
Ah
ImmutableList
Heya Choco ๐
ye this
so I just see choco with half a face here
Which can just be directly returned after being made immutable
Ye
I'm actually really bad about using ? extends X whenever I should definitely be using it for returned generic types
But the thing I don't really get is, like. Why can't you just handle a List<Player> under the hood, and then return that? It's a Collection<Player>, and the compiler wouldn't complain because you're giving it the same compile time type
So it wouldn't care about the runtime type, still
Right?
Could theoretically, sure. But why would you?
because spigot is all about confusing new devs
Because it makes more sense, imo
What if you want to refer to that List<CraftPlayer> under the hood and need implementation methods
You then have to iterate and cast each to CraftPlayer
If that's truly the reason, sure, fine. But generally you wouldn't do this
If you want to follow good API design patterns, you should ๐
Instead of returning Collection<? extends Player>, returning List<Player> actually helps because the developer can be certain there's some order
Although it doesn't imply immutability
? extends Player and just Player are pretty much interchangeable when returned
When you're using the API it doesn't matter
Yeah but new devs don't know that choco
I don't see why returning a List would be better than a Collection
They should ;p They're still shown a Player
They'll get c o n f u s e d
You shouldn't care, you just want "a bunch of players"
just make everything return Object
Funny joke
Nah, screw you and your prison server. I've been spammed by a bot account like 10 times to JOIN FREE PRISON SERVER TODAY CLAIM FREE LIMITED TIME VIP RANK GRAND OPENING
LMFAO
Account name Mijaa?
5 minutes later
LAUNCHING IN 10 MINUTES JOIN NOW FREE ADMIN RANK
Michael this time
I've been asked to work for some of them
I see
haha
But I've had random accounts
Work as what
dev
I see
Weren't you that guy that I had a private lesson with
I don't even get contacted by those losers
this was a long time ago
ehh
hello guys!
I like to fuck with obvious bot accounts when they friend add me
I finally finished up my command system to a degree. Its a platform agnostic command framework which uses annotations to describe the command and that can be used to auto generate completions, atm it does not support brigadier but its really nice with spigot rn. Every platform needs an implementation though and spigot is the only one WITH an implementation but yeah it is good
I'm like "Hmmmm, your account was created on XXX XXX XXX, you're a bot account lmao"
they never reply to me ๐ฆ
I think I've gotten some that are real people, doing it manually
People who don't know how to self bot, I guess
Unless you're doing the annotation stuff to modify the bytecode, It's not the best for performance
I tend to stay away from annotations because of performance
i don't know exactly how to do that..
i'm trying to get just the slot from inventory crafting, but when i click on slot 1 in main inventory it's sending the message, but it should work just with crafting inventory slot
I really would...prefer to avoid reflection, in such a case
Just because you can doesn't mean you should
Annotations are actually fine for performance the main problem is when you are parsing/querying them at runtime it becomes a problem
^
This
Except annotations are pretty much made to have reflections attached to them
Yeah
When i need a command i end up reading annotations and making something called CompiledCommand which kinda stores all the command meta/the methods and access and makes sure everything is safe and properly parsed/created
You need to use reflection to find annotated things, if I understand correctly
Too much work
So i convert the annotation to something more standard
And just, no
I'd rather just some random command system I made like 2 years ago
Where I can just use an identifier system and a wildcard that gets passed as arg
Fair, i wanted to do it though since i want my plugin to work on fabric AND spigot. And fabric has a very different system than spigot (brigadier)
So i used annotations which are read and turned into brigadier commands
You're trying to do some template metaprogramming type shit and I want nothing to do with it
LMAO
^ me
Thats fine it works nice for my plugin personally, ill show a little example (also java template metaprogramming aint shit when you compare it to C++)
It was a joke
You can't tmp in Java though. Just, I'd really go about trying this somehow differently
I wish C# had enums that weren't just static identifier bullcrap
java's enums are pretty much classes
I've done barely anything in c# apart from some stuff in unity and all I remember from that is Time * Time.DeltaTime or smth like that
While C# has no params
Like, look, let me get this straight. You want to make a command system that provides the Command implementations with information and properties through their annotations?
So this is happening https://imgur.com/lLTMF8r and I understand this is not passing through ```java
if (kills > 0 && maxKills > kills) {
maxKills2 = kills;
maxKillsPlayer2 = playerName;
}
Hey, Illusion, you have a gray pfp, right? Do you, or is my client fucking up rn
if (location.getLocations().contains(blockLocation)) {
if (p.getLocation().distance(blockLocation) < 2.2)
p.getInventory().addItem(new ItemStack(Material.IRON_INGOT));
}``` how do I get the distance of all of the locations in the location array?
it's light gray on chat, dark gray when you click
Uhuh, thought it was broken
Looks like you have no pfp
best paired with an invisible name and blank text
What is location here
public class location {
private static ArrayList<Location> locations = new ArrayList<>();
public static void addLocation(Location loc) {
Generators.getInstance().getConfig().set("locations." + loc.getX() + loc.getY() + loc.getZ(), loc);
Generators.getInstance().saveDefaultConfig();
locations.add(loc);
}
public static ArrayList<Location> getLocations() {
return locations;
}
}
No
yo what the
what is you put discord on light mode?
then would you see it
it turns white
try it
it's only 1:20AM
ru trying to burn my eyes?
mm gotta love uh
lmfao
Boutta DM you something
With that thing people complain about to use List<?> list = new ArrayList<>() instead of ArrayList<?> list = ...
Why is nothing showing up https://imgur.com/lLTMF8r when the second if statement is true? ```java
int maxKills = 0;
int maxKills2 = 0;
int maxKills3 = 0;
String maxKillsPlayer1 = "";
String maxKillsPlayer2 = "";
String maxKillsPlayer3 = "";
for (OfflinePlayer p : Bukkit.getOfflinePlayers()) {
for (String playerName : core.getConfig().getConfigurationSection(p.getUniqueId().toString()).getKeys(false)) {
int kills = core.getConfig().getInt(p.getUniqueId() + ".kills");
playerName = core.getConfig().getString(p.getUniqueId() + ".name");
if (kills > maxKills) {
maxKills = kills;
maxKillsPlayer1 = playerName;
}
if (kills > 0 && maxKills > kills) {
maxKills2 = kills;
maxKillsPlayer2 = playerName;
}
}
}
and singleton config
do you update the text?
Do you debug it?
oh god my eyes
yes
it just doesnโt feel like it
I can see that
I squinted
this is DISGUSTING
discord light mode doesnโt look that bad, but it burns your eyes.
I cant see shit on it
And blocked
lol
Hello !
I have a simple question about FileConfiguration...
I need to make runtime configurable, and I would like to use this layout:
beginning: 11:05
ending: 11:10
Won't the two points be a problem?
Thank you for reading ๐
yeah... green theme is better
well maxKills prints out two values ```java
00:27:14 INFO: 1
almost puked
yo wtf
you're printing before and after
That is inhuman
so yeah your updating is wrong
is this a joke or do you actually use it?
@echo basalt ```java
@Command(aliases = {"link"})
public class CommandLink {
private final DiscordLink plugin;
public CommandLink(DiscordLink plugin) {
this.plugin = plugin;
}
@Default
private void link(CommandSender sender) {
sender.sendMessage(plugin.getLocale().getElement("link.example").set("player", sender.getName()).info());
}
@Command(aliases = {"subcommand"})
private void subcommand(CommandSender sender, @Choice({"tea", "coffee"}) String drink) {
sender.sendMessage("You like " + drink);
}
}
this is the command, also beware @Command does have stuff for permissions too, here is it being used
https://i.kawaii.sh/5AyQBM5.mp4
its a cool concept i think anyway
so yeah it does kind of checking to make sure args are valid and automatically parses it. CommandSender is not bukkit commandsender its my own, this whole thing is not platform specific and has adapters
So spigot has a command implementation for this (and has an EventBus implementation since i made my own too)
๐ more of a very specific use case though so most wont need it and its bloat but i like for my stuff since i also support fabric
after
daily
cursed
I have green spots when I get up
Itโs the worst theme I have seen
me?
i can overpass that max distance?
You'd have to teleport the entities
ok, thanks ;D
No worries
nah jk i use this theme '
what plugin did you make? link?
Does anyone know any reasons this might be happening?
a entity with multiple names? I think one entity can have only one name. What are you trying to do?
don't worry I figured out what I wanted to do
hmm, actually wait, am i adding the commands correctly in the yml?
commands:
listlocations:
description: shows a list of all signs that can be teleported to and their coordinates
removelocation:
description: removes a warp location by name from command arguments
Fairly certain yml needs two spaces
Also did you register it in the main class (be honest, everyone forgets ๐ )
i did register it, but let me try to double space and see if that fixes it
Just do
List<UUID> entries = new ArrayList<>(kills.entrySet());
Or if you need a map use Map<UUID, Integer> instead
What's wrong with what i have?
Idk it looks weird
If it works it doesn't rly matter
But that's just not how i would do it
whatever floats ur boat tho ยฏ\_(ใ)_/ยฏ
it still isn't working and i'm clueless as to why ๐
Is there a way to make floating blocks that move freely so i can make animations with them that are life size (when i do it with an armor stand they are smaller)
How would I find the event for when a cow is milked?
I searched the java doc and there isn't anything for just cow milked
if theres really no event you can get the right click of the player interact event and see if they right clicked a cow
holding a bucket
Oh PlayerInteractAtEntityEvent use that
t
@EventHandler
public void cowMilk(PlayerInteractEntityEvent e){
Player p = e.getPlayer();
if (e.getRightClicked() instanceof Cow && p.getItemInHand().getType().equals(Material.BUCKET)) {
//Logic Goes Here
}
}
smth like that
whats the difference between PlayerInteractAtEntityEvent and PlayerInteractEntityEvent
@rancid snow From the docs
PlayerInteractAtEntityEvent: Represents an event that is called when a player right clicks an entity that also contains the location where the entity was clicked.
PlayerInteractEntityEvent: Represents an event that is called when a player right clicks an entity.
And the PlayerInteractEntityEvent is a superclass of the PlayerInteractAtEntityEvent class
getItemInHand is deprecated
Use PlayerInventory#getItemInMainHand()
alr
Sorry for giving you a deprecated function it isn't deprecated in 1.8 and i mainly use that .w.
np dw
could it be because im using entries.get(i).getKey()
How do I make a message component?
I'm using player.sendMessage(); but i don't understand how to make the component
Player#sendMessage(); just takes a string AFAIK
Just put a string in it it should work
I looped through the location but now I have a problem where for each generator I have placed down, I get 1 iron ingot so if I have 5 generators I get 5/t and I want 1/t for each one ```java
public void run() {
for(Location l : location.getLocations()) {
if (distanceBetween(p.getLocation(), l) <= 2.2) {
p.getInventory().addItem(new ItemStack(Material.IRON_INGOT));
}
}
}
}, 0, REWARD_TICK_DELAY);```
switch (args[0].toLowerCase()) {
case "iron":
p.getTargetBlock((Set<Material>) null, 3).setType(Material.IRON_ORE);
blockLocation = (p.getTargetBlock((Set<Material>) null, 3).getLocation());
location.addLocation(blockLocation);
if (location.getLocations() != null)
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Generator Placed at " + blockLocation.getBlockX() + ", " + blockLocation.getBlockY() + ", " + blockLocation.getBlockZ()));
Generators.getInstance().getConfig().set("locations", location.getLocations());
Generators.getInstance().saveConfig();
}``` command
put the gens in a map maybe?
player.sendMessage("You just milked a cow!") should work
Have you tried a normal string?
like what i provided earlier
I don't want a normal string, I'm looking for colors
with colors?
If you're just trying to send a message with color, use ChatColor.translateAlternateColorCodes('&', message), with the Components you can send those by using player.spigot().sendMessage()
like you said using components is deprecated?
Different numbers means different gens, I need to give the player 1 item each gen
i need a way to make things unbreakable
yeah, but .sendMessage is deprecated
is there is aplugin u know of
I'm trying to find something that's not deprecated
Don't forget the .spigot()
I didn't.
Player#sendMessage(String) is deprecated??
tried what
okay
bump
so this functon
player.sendMessage("")
is deprecated?
because i just got the latest
version of spigot
and its working completely fine
because i promise you
.spigot().sendMessage is deprecated
whoever told me that
.
why didnt u jus try this
the first time
:l
If my IntelliJ would behave I would help more ๐
anyway
It has decided to not find my own classes
next person
WHY
THATS WHAT I WANT TO DO
then you can use the very helpful
@SupressWarnings
if you arent going to use
what your supposed to
What version of Spigot are you using? @rancid snow
why care about depercation
also yeah
i just tested
and none of those
functions are deprecated
scroll down, it's the baseComponent[]
as described there
If you want to use something thats apparently deprecated when there are other options that work perfectly fine
just supress it
tf are yall doing
Your end goal is to send a colored message to a player, right?
Cause you don't need components for that.
idk someone is refusing to use strings for something that would work perfectly fine with one
player.sendMessage(ChatColor.translateAlternateColorCodes('&', myColorString));
and complaining because the thing they want to use is deprecated
This ^, I mentioned it earlier.
theres no need to use that
fucking why
Then just leave
how is that confusing
Because that's how I want to do it
tell us why you need to use a component
then
fucking leave
and deal
with the deprecatin
why do I have to explain myself
ok?
it's literally there in the code
so we can assure you leave with the best code possible
Because we're telling you the correct way to do it. So when you want to do it some way else, you should have a good explanation of doing so.
when you set a wolf to angry does that go away after a set amount of time?
use paper api if you want components
if all the players leave
you can just use adventure
and shade that in
leave a range?
ok I used this
gj
yes
Use a HashMap
the game
Like UUID to Integer?
Yeah
He means that the UUID is a key that you can use to get the value thats an integer
i think
^
yea
Yeah use a HashMap
But what's wrong with what im doing?
Uhh, well doing entries.get(i).getKey() will just return a single UUID at the entry at index i
OHHH
my brother
explained this to me a while ago
so with HashMaps it only has like one layer
but a list then a set has 2
What im trying to do is have a top 10 leaderboard
Anyway HashMap is basically a list of entrysets
Is the Integer the placement?
shouldnt your integers be the key then
Just use a List<UUID> and use the index as the placement
Yeah so what I was trying to do is just store the entries
but I guess ima do what you said
awesome, thanks
If I use that then I can't sort them using java Collections#sort
Well add them in order
TreeMap, integer key
no
They should, if you're sorting by them
how come>
Use a TreeMap, keyed by the integer, sort it, reverse it, and get the first 10 values
Because if you key by the integer and use a TreeMap, it'll be a natural order
Just one operation to sort it and then reverse it
hm
Natural order for ints is least to greatest, so that'll get ya the worst player to the best player
Then you just wanna reverse that to go from best player to worst, and the first 10 items of that state is a nice and neat top 10
Will have to do some research on treemaps never used it before
It's very simple, basically a Map implementation that has ordering and sorting capabilities
Which is exactly what you want
You have a mapping of "scores" and player UUIDs, and you're sorting by scores
so should then should I be doing public Integer[] still?
Question, if I want preform a sync only method at some point through an async event should I just schedule a scheduler.runtask inside of the async event?
I didn't read the whole convo, what are you doing with an Integer[]
well before I was using their uuid
Are all of these in one object?
As in, does one object have name, UUID, and kills?
Or is the name and UUID separate from the kills?
same object
6e103091-1f23-4818-904c-d8df7211ebda:
name: wengengengengeng
deaths: 2
kills: 8
deserialize?
Well, not exactly what I meant. You have access to the configuration object in the place you're ordering the leaderboard, correct?
yea
Alright, so getting all the keys in the level you just posted will get you all the UUIDs. Now what you probably can do here is get all the configuration sections here
As in, get all the "player" objects, can you do that?
Yeah not to hard ```jav
core.getConfig().getInt(p.getUniqueId() + ".kills");
Well, no
What did you mean then?
I mean get all the ConfigurationSections of the UUIDs on top
Like a collection of them all
These would represent "player" objects
Yeah?
I'm not sure if I understand what you're trying to say
So, you know how there's a getConfigurationSection(String)?
you mean getConfig().getString()?
Actually, hold on. I have a better idea
You wouldn't mind doing this on Bukkit.getOfflinePlayers() would you?
And if they're not there, default to 0 kills?
That's what I was doing before
I mean that sounds fine honestly. Are you using the sorted list right away after making it?
Or, will you
I haven't even made the method..
Okay, so look. You could get the OfflinePlayers, right? And then copy the collection
And then sort it by their kills in the config
so sort the kills in the config file itself?
Well, no, in your code
The config is where we get how many kills they have
So you can do Bukkit.getOfflinePlayers() and then pass that to new ArrayList<>(offlinePlayers); to make a copy of it
Which you can then sort, but for now just make a copy, and tell me
so just copy the players UUID into the collection
No, not UUID
Because you need the name later
So use the OfflinePlayer, trust me. Just make a copy of the offline player list first
Collection<OfflinePlayer> players = List.of(Bukkit.getOfflinePlayer());
How can i get the midpoint of 2 locations
Math
val avgLocation = Location(armorStand.world,loc1.x+loc2.x/2,loc1.y+loc2.y/2,loc1.z+loc2.z/2) this isnt working
and im pretty dum
Well that's because you're not organizing your orders of operations properly
Divison comes before addition, my friend
Nope
ok
Use that snippet I gave, it's like that
pemdas ๐
Well, yeah, literally
Also
WHY ARE YOU ADDING LMAO
Is it addition? I totally forgot
isnt avg (x+y)/2
ok
yeah that worked pog
btw what is List suppose to represent?
List.of is a static method that just copies what you give it
And gives you a List that is the copy
Im on jdk 1.8
I see
In that case, do Arrays.asList(Bukkit.getOfflinePlayers())
Then once you have this copy
wait doesn't asList return a list? and your using it in a collections
What
wait let me try something
It's polymorphism
Yeah no instance(s) of type variable(s) T exist so that List<T> conforms to Collections
how can I enchant items with a higher level enchant than 5?
how do i get distance between loactions
You'll want to do
offlinePlayers.sort(comparingInt(p -> config.getInt(p.getUniqueId() + ".kills")).reversed())
something like this
Add the static import for comparingInt
player.getScoreboard().resetScores(resetMyScore);
How can I use this to reset the score starting with the specified character?
What is your name...pyuagotto?
๐คท
players.stream().sorted(Comparator.comparingInt(p -> core.getConfig().getInt(p.getUniqueId() + ".kills")).reversed());
You could do ((OfflinePlayer) p).getUniqueId()
Because for some reason it sees it as an Object
yes, that it very strange
so everything gets sorted now?
Well, now the list copy should be an ordered Collection from OfflinePlayer with the most kills to the one with the least kills
Does Collection have a thing to only select top 10 or do I have to make something myself for that
Stream it, and limit 10
oh I see
Hello im not very good at math so basically i have 3 points (the red green and blue wool) and i want to get a parabola so i can make somethign that travels smoothly that passes through those 3 points i also have a function to get a quadratic equation from 3 points but im wondering what the heck im supposed to pass as the points since this is 3d
well this is my method ```java
public Collection<OfflinePlayer> getTopKills(int maxTop) {
Collection<OfflinePlayer> players = Arrays.asList(Bukkit.getOfflinePlayers());
players.stream().sorted(Comparator.comparingInt(p -> core.getConfig().getInt(((OfflinePlayer)p).getUniqueId() + ".kills")).reversed());
players.stream().limit(maxTop);
return players;
}
Stream.of(Bukkit.getOfflinePlayers())
.sorted(comparingInt(p -> getConfig().getInt(((OfflinePlayer) p).getUniqueId() + ".kills")).reversed())
.limit(10)
.collect(toList());
This would be more succinct
What
Is it a ClassCastException
Lmaoooo
Dude
That's funny
You're putting the OfflinePlayers there
Not the players' names
Use their getName()
You're literally putting them as Strings
So, somehow, you're passing the entire objects directly
well I do have getTopKills in a string
in the stream?
You're literally printing the Collection of them
yea
Somewhere
No, bro
Lmfao
Like, you're putting the result of the collection in a string?
Yeah that's why
It's doing toString() on the Collection, and it becomes that
So you're gonna want to extract these values yourself by iteration
What format do you want here, exactly?
Format for what?
For the leaderboard
I did a boolean here but like that https://imgur.com/Nxrs4JE
Ahhhhh, shit
wsup?
So like you want the kills listed there also. We did it wrong then
Cuz like right now you're not storing the kills, ya know
And you need them later too, so
I am actually not sure what I was thinking in the end
But hey, it's not so bad. The original idea with the TreeMap is actually what you want
Now let's see. You'll want to make a TreeMap<Integer, OfflinePlayer>. And iterate through the OfflinePlayers
And for each one, put it in the TreeMap like
map.put(config.getInt(player.getUniqueId() + ".kills"), player)
so do I still need the method I made?
Nope, this has to change now. You could make the method return a Map<Integer, OfflinePlayer> though
Is it?
Yes
Should he sort it after the iteration instead
If 2 players have the same number of kills it will drop one
Ah, that is indeed a scenario
You don't need random access, right? Only iteration?
He wants a top 10 order of integers to players
is there anyway i can fit a parabola to three points in minecraft so i can have something like ana rmor stand move smoothly through them
Why
You can sort on kill count
Which by the way doesn't need to be stored in config
It's a statistic you can get from the player directly
getStatistic or something I think?
He's storing it himself though, you don't know that he's depending on the overall kill count in the world
anyone have any ideas or pointers for me because im struggling with google>
Like plugin ideas for learning?
no for this
No, the 3D parabola
Ah
so uh
Thing is, Redempt, he wants to sort by OfflinePlayer kill counts he's stored, and also have access to the kill counts after the sorting is done
So a Set doesn't sound right, but a Map does
Huh
You can totally use a TreeSet for that
And don't do OfflinePlayer
That's a bad idea for another reason
Why? He's using the built top 10 of them right after it's built, and just taking their name with their kills
Yes
nope you could say an animatyion of some sort
That's easy to do with a TreeSet
@raw coral I don't think it would be easy to make a parabola but it shouldn't be hard to approximate one by slicing up a sine wave
No, I'm asking why it would be bad to use OfflinePlayer then
Ah

Because if a player logs off and logs back on again
im just in 8th grade im about to take geometry
Then you get a new Player instance
Doesn't matter
ie: no idea what a sine wave is
It's better to use UUID
Well generally, but he wants the player's name
Yes so you fetch the offline player by UUID
Exactly
thats what i did for ma leaderboard
The map approach would work with an OfflinePlayer if not for the int collision
You'd want something like this
So what's the plan
Would you just get all the UUIDs of offline players just to fetch the offline players again with them after
Set<UUID> leaderboard = new TreeSet<>(Comparator.comparingInt(id -> -config.getInt(id + ".kills")));```
Easy
So do i just have to do something sketchy for smooth travel being pretty early in my math learnings
Then to get the top 10
Why are you negating
leaderboard.stream().sequential().limit(10).collect(Collectors.toList())```
Because otherwise it sorts in ascending order
You want descending order, highest to lowest
I know
But then he needs the kills after. Would you just fetch from the config again?
Well yeah I know it's a cache
Just repeating myself makes me uncomfortable
I use Comparator#reversed here
when you say that are you just saying that its pretty efficient to call from config so its not a big deal
I mean yeah but that's a bunch of characters instead of just 1 lol
alr well i guess drawing a 3d parabola is too complicated for me so ill just get averages of points
hey hey
ola
this is a question that will lead to way more questions i assume
whats up
If you want to approximate a parabola
You can lerp between the 3 points as a start
however, what are some of the best ways of detecting Flight on an anti-cheat
NOT ASKING FOR CODE
And then smooth it into something like a parabola
By moving points by the square root of their distance to the center
Ok all my knowledge with lerp is it stands for interpolate
so what does the function return
Lerp just gets a value along a line
ah
oh my
Yeah lerp would be a straight line
Same as if it were 1 dimesional basically, just applying all operations to 3d locations instead of 1d
e.e ive never used this before can i get an example?
hey, need a little help..
i have 3 worlds (for here lets just say test, test_nether, and test_end) and i want to link the nether/end portals between them..
currently i have, but this doesn't work
public void onPlayerPortal(PlayerPortalEvent e) {
World fromWorld = e.getFrom().getWorld();
switch (e.getCause()) {
case NETHER_PORTAL:
switch (fromWorld.getEnvironment()) {
case NORMAL:
e.getTo().setWorld(Bukkit.getWorld("test_nether"));
break;
case NETHER:
Location newTo = e.getFrom().multiply(8.0D);
newTo.setWorld(Bukkit.getWorld("test"));
e.setTo(newTo);
break;
default:
}
case END_PORTAL:
e.getTo().setWorld(Bukkit.getWorld("test_end"));
break;
}
@unkempt ore So what's the plan?
scroll up redempt explained it pretty well
hm I see
I might just store the kills in a db
Will be much simpler to add it to leaderboard
oh wait just clicked so basically i do it to x y and z ?
Yes, then you could do SELECT name, kills FROM leaderboard ORDER BY kills DESC LIMIT 10;
sounds easier
But if you only need to store top 10 then TreeSet is your best friend
If it helps, I have a SQL helper
Never really worked with TreeSet
It's just a sorted set
๐คท
how do i set the amount of online players in the ServerListPingEvent
not to fake the playercount
well yeah to fake it but just to remove people who are vanished from it
https://github.com/Redempt/RedLib/wiki/SQLHelper
Here's docs on my SQL helper if you're interested
k
Ok so i got the lerp to work but can u explain what you were saying about square root?
Ok so you currently have it as linear
yup
Look at the graph of y=sqrtx from 0 to 1
like want me to pull it up on desmos?
Sure
alr
You can sqrt the number you plug into lerp
val armorStand4 = SkyblockHolograms.createFloatingBlock(armorStand.location.lerp(armorStand3.location,0.2), ItemStack(Material.STONE))
so 0.2?
how do i set the amount of online players in the ServerListPingEvent
man i was so close
yo, im having a bit of an issue, but im sure its pretty simple to solve
what
ServerListPingEvent#setMaxPlayers()
what i want to set/30
well i saw the Iterator for it
and was wondering how that one even works?
declaration: package: org.bukkit.event.server, class: ServerListPingEvent
well there isnt a setter for it
so no idea
basically, is there a way i can check if an argument in a command is null so it doesnt give me an error after running an if statement on an unentered/null argument?
you need to use args.length
to determine
thats the only null safe way
args[0].length == 0?
would that work?
no
if(args.length==1)
then args[0] exists
args.lengt == 2
means args[0] and args[1] exist
would that only account for the first argument?
ok so, args is multiple strings, right?
and so checking the .length is checking how many strings are there
an argument?
depends
how many
args
do you want
in your command
thats what you should length check for
also dude i asked you this yesterday
ahh, i see!
do you know java
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
does anyone?
because it really would help you to get some foundationm
ยฏ_(ใ)_/ยฏ
lmao
I assumed it was the lengh of a certain argument in characters
i defenitely dont know math
ahhh, thats String#length()
idk why they're so similar
i imagine .size() would've been more appropriate for collections of strings
ok, that makes more sense
that probably is a thing i just cbb to check
LOL
also, i'm just starting to learn java, going from c#, ps, and batch lmao
C# is basically Java just switched some cases
I'm a few weeks in
ik, like .tostring is the same
almost*
anyway i just spent the last 3 hours to make a failed parabola because the person that was helping me had to sleep
Looks pog :0
nice
idk what they meant by this
you call that failed?
its 2 straight lines
meh
Redempt went to sleep already!?
lines are cool ..

apparently
would you by chance know what he meant?
worked like a charm
i was just tryna make a smite command, but if the user didnt enter a player, it sent an error
Lol
i'm really just making a simple plugin for my server
and im trying to copy skyblock, a very large game
Hypixel SkyBlock?
Ah
๐ฌ thats big
Oo thatโs a nice motive to say the least (:
dude i only have fot and strong/young drag ;-;
how come?
if i told you id have to kill you 
Prince are you adding dungeons also? O.o
๐
idkkk
go ahead
