#help-archived
1 messages ยท Page 48 of 1
what does your startup script look like then
can i dm u wwith ss?
is the horse jump bar client side or can i manipulate it?
Hello, I have a question pertaining about a certain plugin on the Minehut server, Plugin is called "Prism" and is not working although it shows green when I try to see if it's installed but for some reason the commands will not work?
use core protect
could i get some help please? https://pastebin.com/ywJLaPes
by the way i would recommend not buying plugins from Demeng his staff team is toxic and they are banning lots of costumers that need help.
your plugin config is corrupted
the "Example:" is wrong tabbed
wdym
prism is no longer maintained as far as I am aware
Run your config through http://www.yamllint.com/
there is one space to much at line 29 I think
uhm could you send the new config?
Well then, have fun!
ty ๐
Hi, I changed the values to lose less food but I'm still losing as much, any idea?
`hunger:
walk-exhaustion: 0.1
sprint-exhaustion: 0.1
combat-exhaustion: 0.1
regen-exhaustion: 0.1`
i think 0.1 is too much
Hi, I changed the values to lose less food but I'm still losing as much, any idea?
`hunger: walk-exhaustion: 0.1 sprint-exhaustion: 0.1 combat-exhaustion: 0.1 regen-exhaustion: 0.1`
@frigid ember could you give us a little more information
I want to make sure that on my server, we slowly lose the food (in all possible situations). However, in this case, I am losing food much too quickly.
if u want to not lose food at all set to 0
where have you set that and please send the complete file
@frigid ember read correctly my message please.
hey, no need to be pissed i just offered something, in case you are a PvP server
๐ค
@vale slate I do, as shown in the screenshot. The same variable that got the issue was used multiple times before that.
does someone know how to make a citizens npc damageable ?
Yeah, give me a minute
@vale slate https://paste.md-5.net/durebukecu.java
It's erroring on line 61
@quasi seal i think /npc gamemode survival
With the api I mean
@ripe niche I recommend you take a look at implicit else.
?? how i regen my skyblock island every 5m (auto)
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
@visual walrus do you have any idea ?
but someone can help me?
You have a very nested lambda structure
its save my server
@ripe niche
@ripe token They will get to you when they can.
@ripe niche It would help your code in general.
Not really. It reduces cognitive complexity and you save lines.
@vale slate Nature of my plugin calls for such unfortunately.
Found it by decompilation, it's the GameModeTrait
Lambdas have some features you need to be aware of
They are not working exactly like for loops
I'm used to C# coding, and I remember Java being different when it comes to lambdas, I'm sure there's something I missed.
Well I need to define all your methods to recreate the error, could take a second
It's 5 am, I need to be heading to bed. Thanks for the help anyway, tonight.
I could give you the source tomorrow, if you're up to still help me by then. It's open source anyway
kk
gn
?? how i regen my skyblock island every 5m (auto)
@ripe token Are you looking for a plugin or about to create one?
@ripe token Are you looking for a plugin or about to create one?
@vale slate i thimk he dont mean any of these 2
he asks like how to do it
Then he/she should be a little more precise
true
anyone know hhow to make a .structure file for 1.15.2
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
to which one? @ripe token
regen my skyblock island auto
no console errors
every 10m
just it quits
once i initiate that class, the function im calling exists
no console error
idk why
I'm looking at it trooper
It's often a problem, bc NMS has no logging system
e.getPlayer().sendMessage("preee");
e.getPlayer().sendMessage("is null: " + (e.getPacket() == null));
WrappedPacketPlayInUseEntity packet = new WrappedPacketPlayInUseEntity(e.getPacket());
e.getPlayer().sendMessage("post");```
thats my code
@versed forge have you tride using a transformer
no idk what that is @hollow thorn
It'll take some time, as i need to look what exactly this package does on the client side
i cant find the structure format
@frigid ember what are you trying to do with playInPackets?
dw found out my dev my it
do you mean .schem
listen
i want to access the entity in PacketPlayInUseEntity
for example
and support 1.8 -> 1.15
the version part works
no console logs
or errors
so its hard
to know whats wrong
WrappedPacketPlayInUseEntity packet = new missing a ;
?
nms jokes
oh sorry i got onfused by the newline
also the is null doesnt show
e.getPlayer().sendMessage("preee");
e.getPlayer().sendMessage("is null: " + (e.getPacket() == null));
WrappedPacketPlayInUseEntity packet = new WrappedPacketPlayInUseEntity(e.getPacket());
e.getPlayer().sendMessage("post");```
@frigid ember "is null: " doesnt seem to show in chat
thats old pic
oh
im not gonna make a new one
How do you catch the packets?
its not the listening part
i said
fi i remove the packet variable
it works fine
and "post" is called
????
its no syntax error kid
and what is in the WrappedPacket, because this is not a NMS class
ik
i made it
??
its no syntax error
Wrapped.... is the class
the function i sent u
is inside
that class
mabye try sending the class
you sent me a If else line
because obviously it hangs up in the constructor
no
it doesnt
i said fuc it
i sorta figured out myself and it wasnt cause of constructor
those classees i imported dont exist
i need a new class wrapper
ยฏ_(ใ)_/ยฏ
Hey, I need someone to explain to me PersistentData
I'm trying to make a unique identifier for items with special effects
and was told I should use PersistentData
this is what I have so far
I'm doing this to check
However, it doesn't seem to be working
I don't think I understand PersistenData or the NameSpaceKey
I've looked for a tutorial on it, or documentation explaining how it works
but I've struggled to find anything
also, is this static abuse? I couldn't seem to get any results without using static
Any help would be appreciated ๐
md, a buyer's account was stolen from him by one of his staff
would he be able to get it back?
Only if he owns the email used to register it
oh yeah he does
i redirected him to tmp-support
he showed me paypal transaction and all that
@fleet crane I'm in the same society as you
Hello, do you know any plugins to fast sell items in gui?
@fleet crane ahh, so I need to create a new key for each item. That makes sense
my name keeps changin
yo boys
i need some advice
do you think the mine academy course is worth purchasing ?
what is the mine academy course
its a course for development
link?
im debating whether or not to purchase this
Do you already know java
nah dont do that
even less reason to do this
dont learn from that
are u crazy
lmao
there are good enough or same level tutorials on yt
for free
idk, it seems to have all scattered resources into one
yt tutorials are also shit mostly
I don't usually recommend that course
It's open source
and i went and played wow
The spigotmc wiki explains everything you need to know to get started and there are many free java courses
Spigot's wikis, Oracle's documentation. Really, lots of free resources that will do you significantly better
^
these courses are very nice and highly recommendable, in particular the first and the last one
i dont think i need more java knowledge tbh
I've heard good things from Codecademy as well, though never used any courses myself
Those are syntax sugar and you don't really need them until you get into more advanced things
it's something you certainly should tackle, but it's not part of the very basics
i know the very basics
i say sololearn.com
sololearn is meh
hyperskill is good for all people as they give you actual projects
Does anyone know what this means?
do i have to practice algorithmic logic to get better with making plugins ?
oh hecc that dark mode
but it's not???
Mmmm the error says otherwise
do i have to practice algorithmic logic to get better with making plugins ?
Just follow a course
You don't have to view all the dry stuff separately
Once you start building stuff it'll come automatically
That key should be created on the spot, not conditionally on method call
It should be constant. private static final NamespacedKey GOD_BOOTS ... etc ...
Don't ask me. You have it private already lol
Yes
*private
event handler in same class
but if I make it in the method
and make it private
then it won't be accessible by the event handler?
Yea, it wouldn't be a field. Just instantiate that field inline. No reason to do it in the method call. It's constant
By the point your playermoveevent was called, you have not yet called getItem("GodBoots")
(not to mention creating an ItemStack every time PlayerMoveEvent is called isn't the best idea)
That IS should be constant as well
o/
I've created some HolographicDisplay placeholders, however they don't seem to get updated on my holograms until I do /hd reload. Any ideas?
Server: creates 1000 ItemStacks every 2 seconds
(not to mention creating an ItemStack every time PlayerMoveEvent is called isn't the best idea)
That IS should be constant as well
the gc is bored it's fine
Yea. Lazy bastard. Just leaves all its garbage right until the very end. Put that guy to work!
@subtle blade so if I create an item in a method, should I just run that method in onEnable()?
therefore it's created when the plugin is started
and then after than, I can just reference the item using method().item
Ideally you'd create an in-line constant for it as well using an ItemBuilder. There are some utility classes on the forums to help build items
could I have a link?
There are plenty. You can pick among them. Do a Google search for site:spigotmc.org item builder and you'll find a few
ok ty ๐
I'm just curious, since I havent worked with Spigot API for a few years
I have one of my own as well but don't think it's on the forums. In a few of my projects on GitHub you're welcome to use. Up to you
๐
does the PersistentDataContainer still retain the data (aka store it in the world map or w/e) after server restarts etc
Noted, thanks
I'm really confused on how to use persistent data tbh
I was told I could use it as a unique item identifier
You could
Yep. That's fine
and have been trying to figure it out for a week lmao
There's other ways you could approach it too
haven't found much documentation
It's mostly newer but there was a guide on it iirc
but seems like that would be best if you want that data to remain "persistent".
I was originally trying to use custom nbt tags
cause that's something you can do with vanilla command blocks
so I assumed that you could use spigot to give an item a custom nbt tag
which you could then look for
but apparently you can't
You can. PersistentDataHolder does exactly that
are they the same thing?
It just wraps all that NBT under a Bukkit namespace
wfhwoguwguwegwe
Seems like they are the same thing, just one is an API
You could do /give @p diamond_sword{"Bukkit":{"myplugin:key":4}} and persistent data could be fetched using get(new NamespacedKey(plugin, "key"), PersistentDataType.INTEGER)
(I think that's the format, something close to that if not)
right..
PersistentDataContainer just doesn't allow you to interact with vanilla NBT because that should all be encompassed by ItemMeta
Sounds great to me if you dont have to deal with manually storing the data
why do you need the integer on the end though?
Probably an index of reference
isn't enough to just have the plugin name and key?
To tell it what type it should return
You could probably call PersistentDataType.STRING and it would return "4"
You could probably call PersistentDataType.STRING and it would return "4"
walk?
Is there a way to get ahold of Spigot 1.16 snapshot versions?
No
alrighty thanks
why would I?
you obviously know what you are talking about, and I was just asking politely to see if there was, but fair enough. Understandable
keep up the good work :P
You typically get people who are like, there has to be SOME way for us to get the 1.16 snapshot versions!
But I NEED it!
XD, I was mainly wanting to test it with my plugins and my server to see how it runs etc but its done when its done i suppose :)
It's more than likely that a majority of your plugins will work fine so long as they're using the API, not some hackery to support like... 8 versions in one
great, glad to hear. Thanks for your assistance!
o/
I always appreciate help if it is given, i dont get these whiney kids going on. Its not like moaning will get it anywhere
tis only polite
true
Hi, does Player#getKiller take in account Arrows? So if I shoot a player, will this return me or null as the killer was Arrow?
or Tridents and other Player launchable entities...
i have a problem about the comand blocks being activated, i set it true in server properties and put it at the bottom of the list, but it keeps going up the list once i reload the server and still dont work.
@median hill try actually stopping the server, try to open the config after the server has been stopped and set it, then start the server...
@sacred wave i will try thank you
Hey i have a list of minecraft usernames i need to sort alphabetically
with numbers first any ideas?
= Arrays.asList("Aman", "Kajal",
"Joyita", "Das");
System.out.println("Before sorting:");
stringList.forEach(System.out::println);
stringList.sort(Comparator.naturalOrder());
System.out.println("\nAfter sorting:");
stringList.forEach(System.out::println); ``` something along this way I guess
Comparator.naturalOrder() is redundant when using the util method, but yeah that's the same thing
public List<String> sort(List<String> usernames) {
usernames.sort(Comparator.naturalOrder());
}```
o:
Your method does not need to return anything
as List's sort modifies the list itself...
ohh so it doesnt produce a new list ?
nope
ok cool now heres the thing
you need a new list?
im making a friends list. friends are stores as uuids, im getting the player names from the uuids in a database. then im sorting the names alphabetically and then adding them to an open gui. on issue is to create the player heads in the gui i need to include the uuid for each name somehow
example?
Bukkit.getOfflinePlayer(uuid)?
what if fetching a player off uuid who never joined the server
Wouldn't that be the same problem
bukkit.getofflienplayer is to get a player on that individual server
if players are friends
and one never joined the server their friend is on
and their friend tries bukkit.getoffline
that wont work
guess ill do a <username, uuid> map
Map<int, Map<username, uuid>>
Bukkit.getOfflinePlayer is to get a player on that individual server
Wrong
so how does it work?
It makes an api request if the player is not online
but isnt that rate limited?
Yes
so then thats not a smart idea
public static List<Map<String, UUID>> getFriends(){
return null;
}```
im thinking something like this
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
return Objects.equals(player(), user.player());
}
does this look sound for a player wrapper class
How do you want to get the player head otherwise
player() is weakreference of player's get method
You sure? You got the same problem there
ill code and then you review brb
public static List<Map<String, UUID>> getFriends() {
return null;
}```
Wow if that isn't relatable, I don't know what is
just wait watch my magic
You're so unimportant it doesn't even bother to allocate a list for your friends
return Collections.emptyList()
throw new Exception("Yup, still empty");
public Player player() {
return player.get();
}
java bean syntax OUT. record syntax IN
no more getPlayer
now it's just player() OOOOOH
it feels so nice
wait... how do you do setters with this syntax? overloads? LOL
fascinating
Hi, does Player#getKiller take in account Arrows? So if I shoot a player, will this return me or null as the killer was Arrow?
@sacred wave Ok, in case anyone wondered, it is actually pretty smart, getKiller is returned even if Player was pushed to lava by some other player... awesome!
@granite cedar using SQL?
is getKiller in the bukkit api?
public List<HashMap<String, UUID>> getFriends(aPlayer ap){
Map<String, UUID> map1 = new HashMap<String, UUID>();
List<String> names = new ArrayList<String>();
for(UUID uuid : ap.getFriends()) {
String name = SQLUtils.getString("Players", "UUID", uuid.toString(), "name");
map1.put(name, uuid);
names.add(name);
}
names = sort(names);
List<HashMap<String, UUID>> fin = new ArrayList<HashMap<String, UUID>>();
for(String name : names) {
??
}
return fin;
}
public List<String> sort(List<String> usernames) {
usernames.sort(Comparator.naturalOrder());
return usernames;
}```
@granite cedar you're storing player friends in a MySQL database, then just pull the UUIDs when the player logs in and store their friends list in their player class
confused by the arrow
Yes it does, Fr33, and yes it should take arrows into account, Dawon
@dusky herald already do that
It's the same value that determines whether the death message includes "by <player>"
Your sort method is redundant
i.e. "<killed> was shot by <player>"
Just use Collections.sort
@subtle blade awesome, thanks, I just tried it just to be sure, that will simplify my code a lot!
Why do you return a list of hashmaps, don
but does it work at on damage event? ๐ค
I need this return list for when i produce the friends in a gui
No because damage events are fired before death
the map will provide the itemstack create method with the uuid and name
@runic wadi He should be a pro, and just call it Player ๐
There you can getDamager(), and in PlayerDeathEvent you have PlayerDeathEvent#getKiller()
just kidding
- HashMap is not the type for that. You want to make a class that contains UUID and name
- Creating the player head requires an OfflinePlayer anyway. Why don't you just use that directly
@subtle blade actually there is not getKiller in PlayerDeathEvent... I need to get it via getEntity...
I am releasing a question:
Why would I not want to use a global static variable for something like a list of channels or regions that exists for the entire runtime?
Oh there isn't. Strange. Well, Entity#getKiller() would work at least
but that is easy enough, so not a problem at all...
@runic wadi idk, why wouldn't you?
you get who last damaged the player from entity damage event when you check if health is < 0
@runic wadi There's no problem with making a global static variable, it's just frowned upon because sometimes people use them too extensively, or when they really dont need to.
if its a projectile you get the shooter and check if player
The reason you should make it private and have a getter is incase you want to modify functionality
By having a public static field
You cannot control or change the return
I mean I could make it a field of a channel or region manager singleton, but it's still accessed statically
whereas if you want to change functionality down the line with a getter you can
Don, I know that, I was just wondering if the getKiller is not a simpler solution and it is and it covers even more cases, so ... ๐
if you know it's not going to change then it's not that bad to do it
oh getKiller is under LivingEntity... not a Player...
but it's just easier to have a getter if you might need to change it down the line
makes sense I guess..
well I could have a static getter instead
it's still backed by a private static field
is it for a singleton object?
That doesn't make much of a difference
I just don't see the reason to use a singleton
why is a singleton containing a list better than a class containing a static list
incase you want to return a different list based on something later
you can control what a getter returns
Global state shouldn't be mutable, that's all
you can't control what a public field returns
can I show ItemStack on hover event without touching NMS?
yes
private static List<String> shrimps = new ArrayList<>();
public static List<String> shrimps() {
return shrimps;
}
this gives me control of what is returned
hello i have plugin to ban player on bungecoord how to remove form tab sugestion /ban for normal player ?
yeah, because in there you could return new ArrayList(); instead if you really wanted
@trail zephyr
look into https://www.spigotmc.org/wiki/the-chat-component-api/ (or kyori text / minimessage or something)
That doesn't really give you control
it isn't a singleton because it's not your own object
you can still create more list instances
@dusty topaz I don't understand, it doesn't say anything about showing item in chat
@prisma basin Find a plugin that hides plugins. PluginHider or something like that.
oh yeah, it's a global list, i'm not talking about creating my own list implementation or other object
yeah, so it's not a singleton, it's just a publicly accessible field
@dusty topaz it just points to JavaDoc. I know about HoverEvent.Action.SHOW_ITEM, but this require JSON representation of item which is accessible only via NMS.
Iam asking for NMS-free way
didn't see myself plugging minimessage but pretty sure it makes it really easy to show item
@radiant pollen but this is bungecord plugin i can't find tab completer bolker for 1.15 ๐ฆ
but you shouldn't need to use NMS with chat component api, so i'm not sure what you're looking at
Chat-component API indeed offers a way to show item in chat, but it does not accept ItemStack, it accepts only JSON representation
hello i have plugin to ban player on bungecoord how to remove form tab sugestion /ban for normal player ?
Yeah I guess I will have to :/ thank you
those libs are preferred by most to chat component api
(text is at least, minimessage just interfaces with text from strings)
all anti tab plugins have one thing in common they don't work on 1.15
is it posdsible to sort the keys of this?
Map<String, temp> friends = new HashMap<String, temp>();
use TreeMap?
i basically have the player name and their object in that map
need to sort the names by alphabet
Again why do you use a map
If you have a list of names, String is comparable
And why do you not use OfflinePlayer
So you can literally Collections.sort(stringList);
This would be so much easier
And it will order alphabetically
i need to sort a list of names yes
but i also have a player object attached to each name
So do Collections.sort(list);
Collections.sort(myMap.keySet());
might need to make the keyset a list instance first
but you get the idea
heres what i ttempted, what do you think?
Map<String, temp> friends = new HashMap<String, temp>();
List<String> friendsNames = new ArrayList<String>();
for(UUID uuid : ap.getFriends()) {
temp temp = new temp(uuid);
friends.put(temp.getName(), temp);
friendsNames.add(temp.getName());
}
friendsNames.sort(Comparator.naturalOrder());
List<temp> fin = new ArrayList<temp>();
for(String name : friendsNames) {
fin.add(friends.get(name));
}
return fin;
}```
You can just do Collections.sort(firendsNames);
does anyone know a placeholder for kills and deaths??
and just return friendsNames
List<temp> fin = new ArrayList<temp>();
for(String name : friendsNames) {
fin.add(friends.get(name));
}
%kills% %deasths%
its returning the list of temp objects in alphabetical order is it not?
Damn MiniMessage cannot show items in hover events
@sacred wave
it is returning the exact same thing
you're looping through list a, adding to list b
that means lista.equals(listb);
why did you call the class temp..
@trail zephyr I guess he hasn't added that functionality yet - it's a new api
@granite cedar ?
because im not saving the objects anywhere
if I am adding players to a list when they log in (PlayerJoinEvent) and iterating that list asynchronously (virtue of the async chat event), do I have to use https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/CopyOnWriteArrayList.html
should be able to just do with text anyway
no
if you're just going to ignore what I say don ยฏ_(ใ)_/ยฏ
This is important
i just need to get the friends list in alphebatical order
Because most of what you're doing now is probably redundant
Creating the player heads usually requires an OfflinePlayer
nvm i'm not modifying it async
OfflinePlayers contain name and uuid
i know of a way to do it without that through my database
with my database
@fading frost you can create a skull with just a name
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) SkullType.PLAYER.ordinal());
SkullMeta skullMeta = (SkullMeta) skull.getItemMeta();
skullMeta.setOwner(playerName);
that... gets an offline player internally, I bet
thats deprecated
you might be right
How else would it get the texture
@granite cedar An identity set would probably be better in your case.
querying mojangs api
see, that's my point
mojangs api has limits which is why i use my own database for heads
Wrong tag.
example please @rigid nacelle
@runic wadi ^
public boolean setOwner(String name) {
if (name != null && name.length() > 16) {
return false;
} else {
if (name == null) {
this.profile = null;
} else {
this.profile = new GameProfile((UUID)null, name);
}
return true;
}
}
a what
this is 1.8 api code however
and what does the GameProfile constructor do
the placeholder %kills% and %deaths% doesnt work
yeah, i'm not seeing where it is setting the texture property either ...
I know this works, since I use it but now I'm confused as to if it is querying the api or just offline players
either way, in my case the offlineplayer will always be present so doesn't affect me too much ๐
oh I see
@rigid nacelle I simplified my question, I'm actually wrapping the player object so identity comparison wouldn't work
public List<temp> getFriendsObjectsInAlphabeticalOrder(aPlayer ap){
Map<String, temp> friends = new HashMap<String, temp>();//for
List<String> friendsNames = new ArrayList<String>();
for(UUID uuid : ap.getFriends()) {
temp temp = new temp(uuid);
friends.put(temp.getName(), temp);
friendsNames.add(temp.getName());
}
friendsNames.sort(Comparator.naturalOrder());
//now that the names are sorted we still need to return the List<temp> ordered by temps names in alphabateical order
}```
it's a User containing a weak reference to a Player
explain please
colorize that shit
temp is the basic player object which contains data to show in the friend gui
@granite cedar I would listen to other guys here, your code looks far too complicated than it has to be...
@dusty topaz thats what i did but apparently im wrong
it is a very inefficient way to do things
public List<temp> getFriendsObjectsInAlphabeticalOrder(aPlayer ap){
Map<String, temp> friends = new HashMap<String, temp>();//for
List<String> friendsNames = new ArrayList<String>();
for(UUID uuid : ap.getFriends()) {
temp temp = new temp(uuid);
friends.put(temp.getName(), temp);
friendsNames.add(temp.getName());
}
friendsNames.sort(Comparator.naturalOrder());
//now that the names are sorted we still need to return the List<temp> ordered by temps names in alphabateical order
List<temp> fin = new ArrayList<temp>();
for(String name : friendsNames) {
fin.add(friends.get(name));
}
return fin;
}
```
so this is ok after all?
ugly. but sure
well how can i simplify/optimize it?
i dont even know where i went wrong
well think what there could be inefficient
you're creating three different collections
and adding to all of them
im a self taught dev
... so are most of us
what is wrong with TreeMap, again? ๐
And is it a problem?
you don't need a map at all
@runic wadi IIRC, the spigot api comes with Guava so you should be able to just use Sets.newIdentityHashSet(), if not Collections.newSetFromMap(new IdentityHashMap<>().
And is it a problem?
@sacred wave yes, it's spaghetti
temp temp = new temp(uuid);
friends.put(temp.getName(), temp);
where exactly does the name come from
why do you make all of this so complicated
public class temp {
private String name;
private UUID uuid;
private String serverID;
public temp(UUID uuid) {
//fectehs data from sql
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public UUID getUuid() {
return uuid;
}
public void setUuid(UUID uuid) {
this.uuid = uuid;
}
public String getServerID() {
return serverID;
}
public void setServerID(String serverID) {
this.serverID = serverID;
}
}```
Uh oh
I guess, but when you try to get the item by the name, it will speed thing up, or am I wrong?
please call it something else than temp
no, all of this is way too complicated and confusing
why does the name matter its just a temp player object
yeah, why does name matter, lets just call everything A, B, C, D
you return it
But anyway, you could just make a list of those objects, populate it and sort that
idk what it is with maps and intermediate lists
yeah, why does name matter, lets just call everything A, B, C, D
@dusty topaz Self-obfuscation. smart :p
completely redundant, all of it
it's sane convention
https://hastebin.com/udojizehub.bash anyone know how to fix?
you call variables temp sometimes because they're actually temporary
although that's not a good name in general
@fading frost so If I search for the Item I want by name with e.g. stream, it will be done quicker or at least in a same time as through hashing in a hashmap?
no its cause i dont want anyone understanding my code if it gets leaked
are you serious
.-.
use an obfuscator then lol
@fading frost so If I search for the Item I want by name with e.g. stream, it will be done quicker or at least in a same time as through hashing in a hashmap?
@sacred wave this is about returning a friends list sorted by name
dunno what you're talking about
obfuscators make it a lot harder than calling your player class temp lol
and just use jnic
true will probably use one when i finally publish my network
screwing up your naming in the source code intentionally is just a bad idea
yeah, let's talk about that again in a year
if only you have source
when more spaghetti is involved
this is just a non-argument
whats is alternative to PlayerCommandPreprocessEvent in bungecord?
@fading frost well firstly I was talking about Don's case, but then from what you were writing I got a feeling that using model of Map<String, Item> where string is part of the Item class is not worth it, so I am asking...
Your case seems different
If you want to access your item by name, this is useful
Don otoh just wants to display all of them in the list order
Map<String, guiPlayer> friends = new HashMap<String, guiPlayer>();```
again. why map
@fading frost hard to tell, I have something like this: private Map<TeamColor, Team> teams = new HashMap<>(); and of course I have Team#getTeamColor...
just make a list of guiPlayer and sort that
because when getting the temp its not cached
what
how
whats is alternative to PlayerCommandPreprocessEvent in bungecord?
how would i sort a list of temps by name?
Arrays.sort(string list)
List<Friend> friends = new ArrayList<>();
for (...) {
// populate the list
}
friends.sort(Comparator.comparing(Friend::getName));
return friends;
simple
then arrays.sort(array, objectcomparator)
public List<guiPlayer> getFriendsObjectsInAlphabeticalOrder(aPlayer ap){
List<guiPlayer> friends = new ArrayList<guiPlayer>();
for(UUID uuid : ap.getFriends()) {
friends.add(new guiPlayer(uuid));
}
friends.sort(Comparator.comparing(friends::getName()));
return friends;
}```
idk how this comparing method is supposed to use parameter???
why don't you implement comparable? ๐ค
bruh i dont even know what that is
why would you
custom object why not
guiPlayer doesn't have an obvious natural order imo
how do i fix this? .comparing(friends::getName()));
You might want to sort it by something else somewhere else
bruh
method reference
Comparator.comparing(new Function<guiPlayer, String> {
@Override
public String apply(guiPlayer player) {
return player.getName();
}
});
```shortcut for this
or this Comparator.comparing((player) -> player.getName())
what is the -> do
ok ill watch /read some tutorials on it and brb thanks
i read -> as 'then do'
how do i make a server?
Even better, Player::getName
that didnt work
yes it does
You just didn't copy correctly
and don't understand what it is
as mentioned already
i dont even know lol
I doubt it
se-13
nobody uses java 7 accidentally anymore
https://www.spigotmc.org/resources/pluginhider-pluginhiderplus-hide-your-plugins-anti-tab-complete-all-message-replace.51583/ why this is don't work for bungecord command?
@fading frost well I had to ask...
ok so this method here will sort guiPlayer objects by their names alphabeticallty yes?public List<guiPlayer> getFriendsObjectsInAlphabeticalOrder(aPlayer ap){ List<guiPlayer> friends = new ArrayList<guiPlayer>(); for(UUID uuid : ap.getFriends()) { friends.add(new guiPlayer(uuid)); } friends.sort(Comparator.comparing(guiPlayer::getName)); return friends; }
https://www.spigotmc.org/resources/pluginhider-pluginhiderplus-hide-your-plugins-anti-tab-complete-all-message-replace.51583/ why this is don't work for bungecord command?
yes
and its better than this? public List<guiPlayer> getFriendsObjectsInAlphabeticalOrder1(aPlayer ap){ Map<String, guiPlayer> friends = new HashMap<String, guiPlayer>();//for List<String> friendsNames = new ArrayList<String>(); for(UUID uuid : ap.getFriends()) { guiPlayer temp = new guiPlayer(uuid); friends.put(temp.getName(), temp); friendsNames.add(temp.getName()); } friendsNames.sort(Comparator.naturalOrder()); //now that the names are sorted we still need to return the List<temp> ordered by temps names in alphabateical order List<guiPlayer> fin = new ArrayList<guiPlayer>(); for(String name : friendsNames) { fin.add(friends.get(name)); } return fin; }
https://www.spigotmc.org/resources/pluginhider-pluginhiderplus-hide-your-plugins-anti-tab-complete-all-message-replace.51583/ why this is don't work for bungecord command?
wanna send it again
@frigid ember why?
no, you should hide things people don't need to see.
@prisma basin you probably have the plugin configured incorrectly.
then block a player from running /ban in command pre process event @prisma basin
lol you actually thought to hide the command but not actually block it code wise
AdvancedBan how to configure it to remove tab sugestion
@frigid ember this is bungecord
@granite cedar bungecord don't have pre process event
command pre process still blocks bungee commands
when on a spigot server
i think *
public void onPlayerCommand(PlayerCommandPreprocessEvent e)
{
onTabComplete();
if(e.getPlayer().hasPermission("admin"))
{
return;
}
work only on bukkit command
yes
no player is going to be connected to your bungee server only your spigot servers, no?
but i need to remove this form /<tab>
public void onPlayerCommand(PlayerCommandPreprocessEvent e)
{
onTabComplete();
if(e.getPlayer().hasPermission("admin"))
{
return;
}
and when its cancelled print your own version of /tab
don't work
with the commands you want
i want to whitelist tab sugestion
I would probably find it easier to just nab the tab complete packet for this purpose, but that might be above your level though to make XD
public void onPlayerCommand(PlayerCommandPreprocessEvent e)
{
onTabComplete();
if(e.getPlayer().hasPermission("admin"))
{
return;
}
String[] cmds = e.getMessage().split(" ");
List<String> allowcmds = getConfig().getStringList("dozwoloneKomendy");
for(int i = 0;i<=allowcmds.size()-1;i++)
{
if(cmds[0].equalsIgnoreCase("/"+allowcmds.get(i)))
{
return;
}
}
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&',"&cNie ma takiej komendy /pomoc"));
e.setCancelled(true);
}
this is full code
my eyes ๐ญ
lol
onTabCOmplete()
Use ```code``` next time plz
get ProtocolLib, use it to kill the tab complete packet ๐
code @Override
public void onPacketReceiving(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
PacketContainer packetContainer = event.getPacket();
String msg = ((String)packetContainer.getSpecificModifier(String.class).read(0)).toLowerCase();
if (msg.startsWith("/")) {
PacketContainer pack = new PacketContainer(PacketType.Play.Server.TAB_COMPLETE);
pack.getStringArrays().write(0, messages);
try {
protocolManager.sendServerPacket(event.getPlayer(), pack);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
});
@prisma basin is this for commands list or argument list
commands
Use PlayerSendCommandEvent
wants to stop commands from appearing in tab complete
Or something similar
And use event.getCommands().clear or whatever you intend to do
but wants to implement a whitelist as well for commands that are allowed
Yea
or blacklist which ever way you want to look at it
if it were me though, I would just find it easier to kill the packet then to just check what players input all the time
i do it and all spogot command has removead but bunegcord command not
Didnt work for me
you need to kill the packet that goes out, not the one incoming
I know
@keen compass how
@prisma basin have you tried my suggestion?
if you don't know how @prisma basin I would probably not recommend messing with packets
i don't usung packets can you get me exaple
use Martoph's suggestion
Cc2, try what i recommended
@wanton delta i try you sugestion its work to spigot command not bungecord command
in case you feel like messing with packets anyways, https://wiki.vg for most of the data references in regards to packets
Then you need to add your bungee commands to a permission group
I have packet filtering at the firewall level anyways, so most of the time I don't really need to code some things XD
this is make if player execute command server send to player you don't have permission and dont remove command from tab sugestion
@wanton delta
Where are you from
Thats ok. If you spoke spanish i could help a little bit better
@keen compass if i kill tab completer packet how to make tab completer whitelist
@fading frost still here?
I'm afraid so
lol any way to optimize this?
context?
i get all the temps from sql before starting the loop
then use the loop to add player heads to the gui
for (int i = 0; i < 54; i++) { ?
but if i do that how will i loop through the guiPlayers?
you would intercept the packet, read which commands it contains. If it contains commands that you don't want sent. Re-create the packet without that command in it and send it again @prisma basin
oh I see, well at the very least, please use i < 54, far more readable.... than !(i >= 54)
that is gist of how it is done with packets
its the list of a players friends
wat. There's a PlayerCommandSendEvent
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerCommandSendEvent.html
No need for packets if you just want to remove commands from tab completion
Ah you're on Bungee
@granite cedar yeah use a regular for loop as dawon said
I didn't say it was the best way, just if I didn't want to make a plugin for the bungee server or mc servers, I would just do the packet way because I already do packet filtering at the firewall level anyways XD
but if i use that as he said how will i also loop through the players friends?
it's a list isn't it
that has random access
List#get(int)
Or an iterator if you prefer that
ohh ok
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, new PacketType[]{PacketType.Play.Client.TAB_COMPLETE}) {
@Override
public void onPacketReceiving(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
PacketContainer packetContainer = event.getPacket();
String msg = ((String)packetContainer.getSpecificModifier(String.class).read(0)).toLowerCase();
if (msg.startsWith("/")) {
PacketContainer pack = new PacketContainer(PacketType.Play.Server.TAB_COMPLETE);
pack.getStringArrays().write(0, messages);
try {
protocolManager.sendServerPacket(event.getPlayer(), pack);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
});```
why don't work
you are going to want the one from the server and not the one from the client
we don't care what the client sends, we care what the server responds with ๐
@keen compass please give me exaple ๐
I don't have an example on hand to give.
https://wiki.vg has most of the data you will need in packets and how they must be structured or what data has to be present and what data doesn't need to be
for (int i = 1; i < 54; i++) {
//inv add item
}```
this will add 53 items starting from the second slot yes?
Yes
please explain the parameters
https://wiki.vg/ this is too hard for mee
already told you it would be
hence why I didn't recommend it as the way for you to do it, just pointing out that it is another way of doing it.
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.HIGHEST, new PacketType[]{PacketType.Play.Client.TAB_COMPLETE}) {
@Override
public void onPacketSending(PacketEvent event) {
if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
PacketContainer packetContainer = event.getPacket();
String msg = ((String)packetContainer.getSpecificModifier(String.class).read(0)).toLowerCase();
if (msg.startsWith("/")) {
PacketContainer pack = new PacketContainer(PacketType.Play.Server.TAB_COMPLETE);
pack.getStringArrays().write(0, messages);
try {
protocolManager.sendServerPacket(event.getPlayer(), pack);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
});
} ```
sorry
Please paste online and send link lol
there we go, looks better
https://wiki.vg/Protocol#Tab-Complete_.28clientbound.29
the / is never sent just fyi
how to fix it
the array contains a list of commands or strings that gets sent to the client depending on what the client asked for, also you need to listen for the incoming packet for tab complete because what you need from it is the transaction ID. If the transaction ID from the server going to the client does not match the client rejects it as well.
this is too hard ๐ pleasr repair my code ๐ฑ ๐ญ
relevant packet structure that the server gets
Yes, messing with packets can be difficult, with enough practice though it will be easy once you learn how the protocol for MC works ๐
@fading frost public static List<guiPlayer> getTempsInOnlineOrder(aPlayer ap, List<UUID> uuids){ List<guiPlayer> online = new ArrayList<guiPlayer>(); List<guiPlayer> offline = new ArrayList<guiPlayer>(); for(UUID uuid : uuids) { guiPlayer guiPlayer = new guiPlayer(uuid); if(guiPlayer.isOnline()) { online.add(guiPlayer); }else { offline.add(guiPlayer); } } online.addAll(offline); return online; } thoughts? good?
what is the point of the two lists
ah
Just use OfflinePlayer @granite cedar that player object has a method to check if their online, and you can cast OfflinePlayer to Player
@keen compass if i remove (msg.startsWith("/")) this is work ?
why are you so obsessed with offline player lol
I'd rather compose a comparator that sorts by both the name **and **whether they're online or not
I am not obsessed with offline player o.O
in fact that is first time I have suggested anything to you @granite cedar o.o
i would do that but if a player is looking for a certain friend
it will be a pain to look through an unlimited size friends list
so alphabetical for the friend gui i think is a necessity
but for showing party/clan members i want to show in order by online status and not alphabetical
so perhaps you have an idea to optimize the code i put above
my suggestion doesn't change the outcome of your current method
it's just a more concise and (imo) better way
also by standard java naming conventions your guiPlayer class should be named GuiPlayer
(I'd name it Friend, btw)
ok well i wouldnt mind if its like that for party/clan
thats actually better
how would i do that
You can compose as many comparators as you want
I don't know what your DB structure looks like, but your code can be optimized if you knew more about sql XD
and the gui player is used for more than players its used globally for all sorts of gui displaying
What's the first thing you sort by
online status first
and then alpha betical
well actually
idk
cause id want offline and online to be in alphabetical order while the online players show first
that's doable
thinking how
Comparator.comparing(GuiPlayer::isOnline).reversed().thenComparing(GuiPlayer::getName).thenComparing(...)...
id say orderign alphabetically, then ordering by online status, then ordering the online players alphabetically, and then th eoffline alphsbatically and then adding all offline tothe online
MySQL can order your data for you just fyi
@keen compass PacketType.Play.Client.TAB_COMPLETE is for /command <tab> whats packet is for /<tab> ??
that packet is for both
And you shouldn't put the database logic in your GuiPlayer class
why not
ohh i run them async with hikari in a seperate core plugin
i just use the api i made for it in guiplayer class
@keen compass if i /<tab> no error and don't have all command
select name from user ORDER BY name;
example of how you can use the query to sort your data.
that is for Ascending order, descending order
select name from user ORDER BY name desc;
DB queries should be ran from another thread
Doesn't really have to do with that, the point is that it clusters the logic of a simple data class
i need to get their uuids as well though
@keen compass how to clear it pack.getStringArrays()
get the array, iterate or loop through the array for anything that contains the commands you don't want. Remove them from the array, re-create the packet plug modify array into that packet. Send packet
mate i just figured this out. its better to have in the friends list both the online players irst yes but alphabetically and then the offline players alphabetically XD
you should be storing UUID's and not their names anyways
public static List<guiPlayer> getTempsInOnlineOrderAlphabetically(aPlayer ap, List<UUID> uuids){
List<guiPlayer> online = new ArrayList<guiPlayer>();
List<guiPlayer> offline = new ArrayList<guiPlayer>();
for(UUID uuid : uuids) {
guiPlayer guiPlayer = new guiPlayer(uuid);
if(guiPlayer.isOnline()) {
online.add(guiPlayer);
}else {
offline.add(guiPlayer);
}
}
online.sort(Comparator.comparing(guiPlayer::getName));
offline.sort(Comparator.comparing(guiPlayer::getName));
online.addAll(offline);
return online;
}```
looking good right?
no
no need for the sorting if MySQL will do it for you
^
this will show the online players first alphabeetically and then the offline players alphabetically
i store player data in json
strigns
also you are adding all the offline to the online list
why...
why do you store players as json
Decent people