#help-development
1 messages · Page 1794 of 1
Oracle Cloud
legit?
so this is better than having an actual host?
you can seeming allocate 6gigs of ram for the cloud server. is that good?
i think its always running so it very well could be better
for a smal server, ye
so if its for friends its good
if you know how to use it and just need it for a small group of friends/for testing yeah it's good enough
6-8 plugins plus 2 mods, will it work without lag?
quote from the post "we're going to create a server with up to 4 CPU cores and 24 GB of RAM! That’s more than enough resources to host a game with 20+ friends with excellent performance (and still have enough leftover to create another server for something else). "
thats good
Packets
packets
oh wow
Anyone here familiar with Citizens traits?
go on denizen discord
Traits are fairly simple
Show code
But i got a empty constructor
do i need to loop through all players to set a prefix for a specific player?
i'm using scoreboards
@Override
public String onPlaceholderRequest(Player player, @NotNull String params) {
if(player == null) {
return "";
}
if (params.equals("cold")) {
return PlayerHeight.getCold();
//other class
public double cold;
public PlayerHeight(double coldp){
cold = coldp;
}
public static String getCold() {
PlayerHeight cold1 = new PlayerHeight(0);
String coldFormatted = "";
DecimalFormat coldFormated = new DecimalFormat("#");
coldFormatted = coldFormated.format(cold1);
return coldFormatted;
}```
Hey! how can i solve this error?
https://media.discordapp.net/attachments/551613805176815655/914541021713555456/unknown.png
PlayerHeight != number
Whatever your PlayerHeight object is, you need to get it as a number somehow
yes
what?
choose better names
oh
but is a double
Well, no, it's a PlayerHeight object lol
Yes but you're doing this
public static String getCold() {
PlayerHeight cold1 = new PlayerHeight(0);
String coldFormatted = "";
DecimalFormat coldFormated = new DecimalFormat("#");
coldFormatted = coldFormated.format(cold1);
return coldFormatted;
}```
coldFormated.format(PlayerHeight)
well yes
So you should be doing coldFormated.format(cold1.getValue())
or however you get that 0 that you passed into that cold1 object
Or just pass 0 because it looks constant, but again, I don't know what that object is
Either way, you can't DecimalFormat an Object. It has to be a Number
PlayerHeight is not a Number lol
i'm trying to do a instance of public double cold;
So if it's a public value, coldFormated.format(cold1.cold)
oooh
Get that double from your object somehow because that is what you want to format
coldFormated.format(new PlayerHeight(0)); = error
coldFormated.format("Test"); = error
coldFormated.format(0.0); = properly formatted value
if i use config.options().copyDefaults(true); in onEnable does it just rewrite the config to the same as in config.yml file in the src, so it makes it useless to edit the config ?
@worldly ingotbut now, (before i had cold with static) the value isn't increasing with the method i have
how woul it have to be then?
idu
Hi, I am in need of a simple solution that removes all player inventories that are in a specific world.
I need this to stop using an inventory management plugin from like 2012 for a creative world. I want to move creative to a seperate server on bungee but if I down-right remove the plugin, all players that were in the creative world will have those creative items in survival when they log in. Any suggestions?
Anyone know what the gradle thing for MVdWPlaceholder API is?
how do i check whether EntityDamageEvent is an instanceof EntityDamageByEntityEvent
can i use the "instaceof"
yes
you kind of answered your own question
and then you can cast
it is deprecated
?
It isnt used anymore
Past what version?
Also like the entire plugin or for Gradle?
Entire plugin. Like, everyone uses PAPI now
Not the server I'm dev for. .-.
i'm making a /setline command that sets the line number to whatever u choose, how do i get the block the player is facing
wtf
Ikr.
well
- try to communicate with server admin
- if first didnt work, clone mvdw placeholders sources, build it, and publish to local maven repo
and the use it
...
even tho he made a post agout it
i think buildtools?
or jenkins
How I can disable movement? Ig I should cancel some event?
yes, you can cancel PlayerMoveEvent
or set player speed to 0
alright ty
imo the 2 option is cooler
yes, btw isnt that deprecated?
it isnt
just wondered if it was replaced with attribute, like similar methods
how can I convert exp levels in exp bottles?
manya, help me pls
You do some math
i dont know the values I have to work with
Google it
I just googled "xp bottles minecraft" and it gave me the info that you need
you cant convert exactly. every thrown exp bottle gives you 3-11 points randomly
declaration: package: org.bukkit.event.entity, class: ExpBottleEvent
make it have a pdc
then check if the exp bottle has that pdc
then setExperience
to maybe 10
so u can convert them easily
:D
this is best way iirc
smart
i'm trying to add a potion effect inside a lambda statement when a certain packet is sent, but whenever the player sends that packet is kicked and this pops up in the console: java.lang.IllegalStateException: Asynchronous effect add!
no stacktrace
It’s async
It is
it is
You need to runTask to sync back to the main thread
aight i guess i can just put it inside a runtask
kk thanks
actually should i put all my code in a runtask
there are multiple api interactions
Running sync in async 🤠 🥶
inside your maven-shade-plugin's <executions><configuration>
Ik this more of a java question but is there a way to write the thing below in a single line
if (function(str) == true) {
}
}```
Why not 
you cant
:(
I mean you can but it’d look very ugly
I mean, you can just use streams no ?
depends on what is in the conditional then
Well, concerning that it is just a function call in the example you should be able to
thats exactly what i was thinking of, just wasnt sure
im trying to cancel a event but is not cancelling, look at this
Block listener https://paste.md-5.net/keyucuruto.java
Main file: https://paste.md-5.net/usoyumawan.java
i'm not getting any type of error, even the ide shows is correct, but when i try to break a block, it breaks and not cancel the event
- you dont name variables like that, learn Java Conventions
why do you never use ur enter button
ayo chill everyones learning 🙂
what?
anyway why the event is not registering or why is not working? i see all right
@fast onyx are you able to run this in a debug?
show us ur main class
^ but not sure if u need to debug for such a simple thing
nope
yep on enable
yes obv
Its good troubleshooting practice, helps illustrate walking through the runtime and get to the point where you don't "need to debug for such a simple thing"
Show us ur main
also dont access config on run time
bro
what
dont create ur config
like that
and why is ur main a listener
just listen for EntityDamageByEntityEvent
what
you don't need to
you don't have any events in the main class
does the main class implements listener ?
and is the event in main class ?
replace the listener with new ClassName()
no i need to listen for both ;)
then register that class, not the main one
the hubris in the room could hold up a building
and rename ur main class to LobbyTools
dont make methods for simple things like this
its good practice when the code is kinda huge and it makes the code messed up
still not registering the events
did u try that?
the file u send me?
show me ur config yml
Yes
i tried, yes
- are there any errors in ur block listener after u changed ur main class code
no..
show me ur config yml
Config:
block-place: false
block-break: false
Messages:
cannot-place-blocks: "&aSorry! You can't place blocks here"
cannot-break-blocks: "&cSorry! You can't break blocks here"
bro
its not if(config.getBoolean(PlaceIsEnabled, false)) {
its if(config.getBoolean(PlaceIsEnabled){
}
i want to check if the place is enabled
YES
so if its on false then cancel the event (?)
i think the second argument is the default
yes
what?
@fast onyx omg
u mixed ur logic up
ur basically saying
" if block-place is true and the player doesnt have permission then stop the event "
do if(!config.getBoolean(PlaceIsEnabled) {
no?
dont say no to me
if block place is false and player doesnt have permission then cancel event
chill
thats not what ur doing
lol
don't help then lol
dude chill
@fast onyx try this
public class Block implements Listener {
private final lobbytools plugin;
public Block(lobbytools plugin) {
this.plugin = plugin;
}
@EventHandler
public void onBlockPlace(final BlockPlaceEvent event) {
FileConfiguration config = plugin.getConfig();
final Player p = event.getPlayer();
String CannotPlaceBlocks = "Messages.cannot-place-blocks";
String PlaceIsEnabled = "Config.block-place";
if(!config.getBoolean(PlaceIsEnabled, false)) {
if(!p.hasPermission("lobbytools.admin")) {
event.setCancelled(true);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString(CannotPlaceBlocks)));
}
}
}
@EventHandler
public void onBlockBreak(final BlockBreakEvent event) {
FileConfiguration config = plugin.getConfig();
final Player p = event.getPlayer();
String CannotBreakBlocks = "Messages.cannot-break-blocks";
String BreakIsEnabled = "Config.block-break";
if(!config.getBoolean(BreakIsEnabled, false)) {
if(!p.hasPermission("lobbytools.admin")) {
event.setCancelled(true);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString(CannotBreakBlocks)));
}
}
}
}
it only gets executed if the value hasnt been set
@grim ice is right
is not the same?
add ! before config.getBoolean()
what did i do wrong
the second argument is DEFAULT
"I don't want to help you"
.....
"But i'll stay here and berate you"
istill not working with your code
im talking with bakbuki
lol
lol
so that means
that if the value is not set
it will be false as default
and if the value is set..
my bad
...
ur right
i told you lol
no
ah yes
Isn't this getting away from the core issue which was that the event wasn't registering? Or am I missing something with this block you guys are talking about?
then why is it not working?
caye is trolling prob
he knows nothing about java and hes insisting that hes right
I DONT KNOW that is why im here ASKING FOR HELP but you're saying things with NO SENSE?
I mean I genuinely thought the main you sent earlier would've resolved the issue
it will, this guy just doesnt want to listen lol
Imean he said he tried it 🤷♂️
if(config.getBoolean(titleIsEnabled, false)) {
i've another if statement on another plugin, that works perfectly if the config is set to false
lol
?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.
thats the way to solve ur thing
I TRIED
show me the code u tried.
the code u sent me
(PlaceIsEnable)
i told me that
the whole thing
Honestly @fast onyx, I myself am not a master Java guy, but when I run into issues like these I abstract portions of the runtime out and add one block of code in at a time to try and diagnose. Thats IF you aren't just going through a debugger.
@tawdry schooner hes just trollib prob
try adding ! before config.getBoolean()
JESUS CHRIST
IM NOT EVEN CHRISTIAN
AND IM CALLING JESUS
DO WHAT I TOLD YOU
troll or no troll hes got you wound up like a ball of yarn
YOU GIVED ME WRONG CODE LOL
okay hes definitely trolling
1s
THIS FUCKING SHIT
Caye, no one wants to help you if you dont stop acting like this. Everyone here is trying to help you out lf there own time so show some respect @fast onyx
caye
ok anyone feel like helping with my issue now? 🙂
check the "!"
check your code
ill just ignore this guy hes trolling
check it
Make a thread (:
@ivory sleet maybe stop him, hes trolling
no problem 👍
MY GOD
Guys stop debating this non sense
hes clearly trolling
your code: if(!config.getBoolean(PlaceIsEnabled) {
correct code:
if(!config.getBoolean(PlaceIsEnabled)) {
you're wrong
so stop talking
my god
that doesn't matter, your code is wrong, just stop.
I ALREADY HAVE IT FIXED
Both stop
Want to understand the feasibility of using database connectors for things like permission nodes. I recognize other plugins do this, but if I wanted to implement a similar system for my own plugin manager, are there things that should be considered before starting development on such a system?
?kick @fast onyx stop
the correct code is the exact same as my code
Done. That felt good.
now please
Permission state management via DB connectors
no
is not
my bad
you forgot )
🤦
ur ide should tell u that?
ur telling me my code is wrong becuz i forgot a )
im using discord to write
whatever, stop this
if you can even make a correct code then don't help, the conversation ends here, i'll still asking here and you won't reply me again for avoid problems 👍
what event for playerhitting
EntityDamageByEntity i think
i just wondered whether there was a player event for that
is an instance of player
seems like not :(
double message? 🤔
guess i cant help
sorry
if(!config.getBoolean(PlaceIsEnabled)) {
if(!p.hasPermission("lobbytools.admin")) {
event.setCancelled(true);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', config.getString(CannotPlaceBlocks)));
}
}
i told you to stop replys about my problems
just ignore me
.
its literally the same
thanks
no is not,
i even checked diffchecker
ignore him btw
hes telling me im wrong becuz i forgot a )
and you're telling me the same because i forgot an ! (?)
intellij will fix it for ya automatically btw
Caye is intellectually rolling us all
hes so egoistic even though his code is shitter
ok
Yes
cuz u didnt forget
u just dont know it
ANYWAYS
i told you to stop
joe biden
so stop
! gives a whole different meaning to the statement ...
?kick @grim ice stop
Done. That felt good.
🔨
Mmm, let me check my main
God
1s
is your pfp golang
yep
what happened to your space formatting
there isn't the right channel to talk
no, its his own tos
No, i didn't
yes im aware i was writing message on general
oh ive seen many like this
How would you parse an int from an argument without using try catch?
I heard you shouldnt use Error-Throwing for validating simple user-input
1.) There isn't the right channel to talk
2.) I don't care about your non-constructive opinions about my plugins, they are made for my friend server so they're very simple but i decided to publish them for boring
3.) There isn't the right channel to talk.
is the plugin paid
no
there isn't the right channel to talk just cut it out, go dm and criticize me all you want that i won't care anything
xd
Just wondering for some more background, you said parse and integer, what is the arguement's type you are parsing the integer from?
I have a dumb idea for it
dont mind it im just saying ot
it is not
o first time i see u here
and add it to a new string
There isn't the right channel to talk, again
just stop talking here for non development topics
args are typically String
i just replied to someones message chill dude
then convert the string to an integer
so ur trying to check if an argument is parsable or smth
Cool! so if you know for a fact an index of your command is expected to be an integer, you could type cast that arg to an integer type
ofc i can use parseint and try catch
but i heard its not good using error throwing for user input
i don't speak here but here i'm
I mean Ints::tryParse returns Integer which can be null on mal-input
u can type cast from string to int? what?
but you should try catch that type cast I would think. I can't imagine why it wouldnt be good to do that..
doesnt it throw an error on wrong input?
No
oh my bad my Python is showing... sorry
xD
But yes try catch is a little bit expensive but throwing errors are most expensive, even so are they still negligible in regards to performance, if you’re not using it as some sort of regular control flow.
5x the runtime, 1/5 the RAM 😎
stop playing moderator
i cant find Ints::tryParse
is there a better way or at least some best practice approach people use generally?
I mean if statements?
Iteration
It’s from guava
oh
Which happens to be shaded into spigot
Pretty much
no idea what shading means
but i assume its a dependency sort of?
It means the library classes are contained inside the spigot jar
so included dependency
So basically they’re provided for you at runtime thus you can just add them to your compile time classpath.
regex i think
alright, will use that to validate the number then
dont forget that regex isnt fast
trycatch is even slower only if the exception is caught
did you just ran unit tests
@ember estuary when the try catch doesnt handle an exception
so like
content of try wont throw NFE
it will be faster
than the regex
I would prefer using a try catch
regex ugly
Probably a dumb question, but unless this is a giant plugin doesnt this nuance between try catch and regex basically mean nothing? How much is it really saving you..?
Just use try catch lol
yeah
that little performance difference
wont do much
trycatch would be the main option
It’s the essence of negligibility
I mean if we were talking like a hypixel server that is doing a custom plugin yea it'd be a big deal i'd concede but all us in here probably aren't dealing with crazy scale
I use my own implementation of Integer#parseInt that returns OptionalInt and it's empty if the string is invalid
I believe Integer::parseInt can be a bit slow since it supports all bases, so yeah hypixel probably uses their own variant.
Yuh sometimes
🥲
public static boolean isParsable(String str) {
int startIndex = 0;
char[] chars = str.toCharArray();
if(chars[0] == '-') startIndex = 1;
for(int i = startIndex; i < chars.length; i++) {
char c = chars[i];
if(!(c >= '0' && c <= '9')) return false;
}
return true;
}
``` if you care about speed that much
whats wrong? no regex overhead
yeah
true yeah
i suggested this but i said its a joke
had this in mind too
and its actually good? dayum
i mean, why should it be bad?
because most of my ideas are bad
What about doubles/floats
Thanks you so much
#getEntity() instead of #getPlayer() right?
mhm
uhm you Just add if(char == '.')?
Shh, no logic allowed here
just count the dots
xD
using a boolean or something, that goes true after the first dot. second dot -> return false
also numbers shouldnt start with zero, like 023 or 0001
Oh fr
public static void dropItem(ItemStack item, Location loc) {
Bukkit.getScheduler().scheduleSyncDelayedTask(ViperUHC.getInstance(), () -> loc.getWorld().dropItemNaturally(loc, item), 1);
}```
Why doesn't dropItem or dropItemNaturally work
Yes this is being ran, I've put debug messages.
No the itemstack is not Air
Yes the location is valid
there are no exceptions
@EventHandler
public void onMove(PlayerMoveEvent e) {
e.getPlayer().getWorld().dropItem(e.getPlayer().getLocation(), new ItemStack(Material.GOLDEN_APPLE, 2));
}``` This also doesn't work
Yes it's registered
"Who asked"
Im trying to change the command of a plugin to something different, not change the function just like what you type to get the function can someone help ❤️
???
On what version you are
1.8
Try iterating over the players inventory
It's not relevant to me if it works on the newer versions, I need to be able to do it on this versino lmao
Why would I iterate over the players inventory? Or are you referring to someone elses question
do npcs have inventories
That's what I thought lmao
reject legacy smh
Legacy is still the superior version of minecraft
I've thought about that, but there's gotta be a proper way of doing it
Name it dinnerbone
But its not
https://bstats.org/global/bukkit#
What am I doing wrong using GridPane https://imgur.com/Jidq9Ci
burger is 0,3 and fries is 1,3 although thinking should I use vbox as root for this
If you can't help and your suggestion is try a different version, why say anything at all lmao
Because we don't support 1.8
Isnt 1.8 here at all, so instead of completely ignoring you i try to, maybe, change your mind?
If that was an option, I would be on a newer version. But I'm on an older version for a reason.
ok
Probably for a bad reason lol
sure
is this possible to do?
Nope
Armor stands can only be rotated horizontally
However
I believe you can get a lying down effect with two armor stands positioned correctly
The base will always be on the ground though
with two of these, if positioned right and set to invisible, you might be able to get the effect you're looking for
but it'll take some bullshit
i dont imagine it will ever look that convincing
Armor will render even when invisible
well define invisible
are you using the invisibility effect?
if so, yeah
if you're using packet fuckery, then no
i were thinking making a invisible player with visible wings
for what effect?
invisible entities with armor still show their armor
and this is what it looks like
just give the entity a elytra on the chest slot and the effect, it should create the effect you're looking for
https://www.spigotmc.org/wiki/itemstack-serialization/ this page talks about the itemstack serialization that bukkit uses but what are the methods used to generate these in the first place?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
I know itemstack has serialization and deserialization methods but those go to maps, is there a quicker way to json/yml or any other text format?
Just creates a map with <String, Object> and yaml takes those.
the map itself isn't directly serializable right? I was having issues with that
maybe I'm being dumb but it seems like something is missing between the step of having a map and the step of having a viable configuration string
Can be used by both yaml and json. But you might have some issues cause some objects don't always function as a json string.
so which method is getting used to turn the map into a json format?
ultimately I need to get this into a string format
You have to format it to json your self. Just like yaml.
so I can dump it into sqlite
What is ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion(); in the current NMS? Since it's all letters I can't tell.
((CraftPlayer) player).getHandle().b.a.k;
Thx! :D
np
It's returns a IChatBaseComponent
1.18 or 1.17?
1.17
Thats a Channel
Anectotally, I have been sued (successfully, twice) by a company who bought the first company, to whom I sublicenced open source contributions I made. The seller did not tell the buyer, and they litigated against me, after the fact, privately. They were arguing that they'd bought a closed source product with no rights reserved by third parties whatsoever. I courteoulsy hinted them to my open source repositories and told them their assumption was wrong, they went to court and had me take my open source repository down and pay hefty fines. Not something you want, be careful.
dude wrote open source software and added as dependency for his company
and he got sued for using company's property
after company got bought by another company
LOL
Basically he payed fines for his own software which was open source before it was added
remove the k.
That returns a NetworkManager
Which u have to get the version from
I recommend you use the mapped NMS
I just don't know which letter returns the protocol
I tried. Can u explain how it works?
I'm using Maven
Where I worked, the company specifically prohibited using open source software in our own products, especially if it was GPL.
https://paste.md-5.net/icucotulij.xml
Put first part as your dependency then add the second part as a plugin
Then you're done
Use BukkitObjectOutputStream
Do u need 1.17-R0.1?
Or can u use 1.17.1-R0.1 to
1.17.1 works too
I'm not finding NetworkManager.getVersion()... What version were you using this in?
How do I add a fake player to a scoreboard?
When looking for it on google/spigot I couldn't find anything for 1.17.1 that wouldn't return errors.
This is my code for the fake player creation.
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
final PacketContainer packet2 = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
packet2.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER); // action
WrappedGameProfile gameProfile = new WrappedGameProfile(UUID.randomUUID(), "Steve");
PlayerInfoData playerInfoData = new PlayerInfoData(gameProfile, 1, EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), WrappedChatComponent.fromText("Steve"));
packet2.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
This is the function I use to add a player to a scoreboard
private PacketContainer getScoreboardPacket(String team, String entryToAdd, int mode) {
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
packet.getStrings().write(0, team);
packet.getIntegers().write(0, mode);
((Collection<String>) packet.getSpecificModifier(Collection.class).read(0)).add(entryToAdd);
return packet;
}
When tested on a regular player it works fine. But when I use it on the fake player called "Steve" it does nothing
try {
protocolManager.sendServerPacket((Player) sender, packet2);
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) sender, getScoreboardPacket("a", "Steve", 3));
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) sender, getScoreboardPacket("b", ((Player) sender).getName(), 3));
} catch (Exception e) {
e.printStackTrace();
}
Anyone knows why this is occurring?
PROTOCOLLIB FOR SCOREBOARDS???????
'getScoreboardPacket'
I'm just using to add a fake player to a scoreboard
which you can do with the api.....
How?
literally as normal
Cannot resolve org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT
Did you run BuildTools
He wants the mapped version
So I would use team.addEntry?
Do I need to put the spigot jar somewhere and/or rename it?
You need to rum BuildTools
I just did
yeah I got it down now
Do I need to put the jar somewhere?
@royal vale what version were you able to run NetworkManager.getVersion()?
I converted it to a map, cast the map to hashmap, converted the hasmap to a string
the did the same thing backwards, works great
No version
Just old nms code with I got from somewhere
You need the --remapped flag
But eh thats a lots of unecessary effort isnt it? Just open bukkit obejcr output stream, write an itemstack object and save the byte array in db?
((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion()
I didn't find NetworkManager.getVersion() in any version 1.8.8 and up. So either I'm missing something or that field/method isn't in networkmanager anymore.
It's the remapped version
I just don't have it myself yet
I know. I didn't find any methods or fields that correspond to that object.
Doing it rn
What do I do with the output jar
i get this error when trying to build my code:
Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default) on project com.santapexie.santa_koth: Error creating shaded jar: D:\Documents\Coding\Plugins\TestingServerKoth\plugins (Access is denied)
Yeah it's still not adding it to the fake player with:
final PacketContainer packet2 = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
packet2.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER); // action
WrappedGameProfile gameProfile = new WrappedGameProfile(UUID.randomUUID(), "Steve");
PlayerInfoData playerInfoData = new PlayerInfoData(gameProfile, 1, EnumWrappers.NativeGameMode.fromBukkit(GameMode.CREATIVE), WrappedChatComponent.fromText("Steve"));
packet2.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
Team team = scoreboard.getTeam("a");
team.setPrefix("§c§lA ");
Team team2 = scoreboard.getTeam("b");
team2.setPrefix("§b§lB ");
team2.addEntry(sender.getName());
try {
protocolManager.sendServerPacket((Player) sender, packet2);
team.addEntry("Steve");
} catch (Exception e) {
e.printStackTrace();
}
does maven have access to the directory
and is the server running as youre trying to build?
no
how can i check
no clue actually
those are just the only things i could think of being an Access issue
Nvm it worked @chrome beacon. Thx!
is it to do with my pom.xml?
https://www.toptal.com/developers/hastebin/fetumireli.xml
@chrome beacon this is weird. Spigot is remapped, but there's no playerConnection in the handler
It's Mojang mapped
nvm
I think it's just connection
After that I still can't find my way
There's no network manager
I asked before and it was a whole thing about use spigot, use spigot-api, use spigot remapped etc... Well I've been trying for the passed few days and none of these methods are allowing me to use bukkit methods... can't even use JavaPlugin
Anyone been able to get 1.18 to build right?
What are you trying to do?
Okay so what are you trying to do?
Yes
^
Neither worked for me. Tried using maven to.
Missing tons of libs and other api methods to.
Show us the POM
Ah yep that would do it
;/
This works with gradle compileOnly group: 'org.spigotmc', name: 'spigot', version: '1.18-pre5-R0.1-SNAPSHOT'
but you've already been told what the solution is, depend on all 30 jars/libraries
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-pre8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18-pre8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
``` With this one I lose all the "nms" classes even some craftbukkit classes like `CraftWorld` and such.
Use remapped
Using remapped I can't even access JavaPlugin
it does actually
Oh?
he should have CraftWorld, idk what his issue is there
but I'm not even sure I believe he's using maven :p
yes
Nice
Get the player's protocol version
well it wasn't extra effort because i was using the same serialization system that I am using for the rest of the object, but it suddenly became a lot more effort when I just realized it's not working
Players only have one protocol version, the current one
tbf I can make my project look like that and not strictly speaking be using maven lol
can I point out the irony in that itemStack.serialize() is not serializable ?
yeah, but not java serializable
Cause java seriakizable sucks
word
but still
ObjectSerializer.toString((HashMap<String, Object>) itemStack.serialize());
failing makes my cri every tim
well
guess i have to use the other thing
BukkitObjectOutputStream right
seriakizable
it's called serializable because it will make a serial killer out of you when you actually try to implement it into your project
any guide to get started on making jars working with bungee & spigot with the same jar?
how can u make a command so it does /game start or /game stop and it auto shows it when u press tab like most commands usually?
ngl multiple attachemnts per discord message is starting to feel like a bad idea
ye
I already said what the issue was read above xD
unyone?
Implement TabCompleter
alright
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
List<String> commandSuggestions = new ArrayList<>();
return commandSuggestions;
}
where do i do that
in your command executor class
took 6h:30min because I spent 5 hours hitting my head against the walls trying to get apis to do it for me
and implement TabCompleter
?
so i can do /game <thing>
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().equalsIgnoreCase("<command>")) {
if(args.length == 0)
sender.sendMessage("Command ran with no sub commands.");
if(args.length > 1) {
if(args[0].equalsIgnoreCase("<subcommand>")) {
// code here
}
}
return true;
}
return false;
}
do i need to do anything extra in the plugin.yml?
commands lol
no
ok
I made a little lib to help with commands
that does exactly those things, but easier
Whats wrong with wanting things done faster?
iirc javas stream api is the furthest thing from fast
The overhead isn't that bad
faster then looping with a for loop.
No it isn't
already tested
doing this didnt send me the msg:
if(command.getName().equalsIgnoreCase("koth")) {
if(args.length == 0)
sender.sendMessage("Command ran with no sub commands.");
if(args.length > 1) {
if(args[0].equalsIgnoreCase("start")) {
sender.sendMessage("Command ran with no start commands.");
}
}
return true;
}
this sounds wrong on too many levels
Go test it yourself. Just display the time in ns it takes to run through the loops.
will try later, not at pc rn
They used to be slower, now I find a lot of mixed info online
I guess Java has improved things
So aside from the code used... does anyone know why the imports aren't working for certain things?
Generally the Java Streams API is slower, but it obviously depends on what you're looping over.
Again... I've already done my testing. Its faster then a for loop in the case above. Do your own testing.
when i do ```java
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(command.getName().equalsIgnoreCase("koth")) {
if(args.length == 0) {
sender.sendMessage("Command ran with no sub commands.");
}
if(args[0].equalsIgnoreCase("start")) {
sender.sendMessage("Command ran with no start commands.");
}
return true;
}
return true;
}
``` and run /koth it says an internal error has occured
I know how Java works. What I said is correct, but as I stated, it heavily depends on what you're looping over. Java 8 streams are generally slower for simple loops because of the amount of time that's required for stream initialization and value transmitting. Various benchmarks seem to suggest that streams are slower than loops for most tests. Though not catastrophically slower, and in some cases, parallel streams can give a useful speed up
Then show the error from console
but when i do this:
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(command.getName().equalsIgnoreCase("koth")) {
if(args.length == 0) {
sender.sendMessage("Command ran with no sub commands.");
}
if(args.length > 1) {
if(args[0].equalsIgnoreCase("start")) {
sender.sendMessage("Command ran with no start commands.");
}
}
return true;
}
return true;
}
``` `/koth` works but `/koth start` doesnt
sry yh didnt see that
Listen. Quit trying to drag this out... just do your own testing get your own results and adjust accordingly. My code isn't the question that was being asked. Spigots broken jar system for 1.18 was the issue I was inquiring about.
It's fine now, lul
I wasn't referencing any of your code in specific, just a general note of Java's stream performance. Not trying to drag this out or anything, just trying to help others gain some more knowledge :).
Hey, is Bukkit.getPluginManager().callEvent() waiting the execution of all listeners ?
For exemple, is the condition evaluated after the execution of listeners (so I can knew if the event was cacelled) :
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { ... }```
Yes
Ok thx ❤️
oh yeah when they first introduced them they were pretty meh in performance
i could just be carrying that idea into new java thinking they haven't touched them for reasons beyond my /own/ comprehension rn
i think theres a bossbar api for it
ye
I've measured the difference between the two via actual benchmarking and streams are much slower.
search for boss in javadocs
foreach is literally a single method call, instantiation, and loop.
fk I need more ram, 1.18 is a pig
Streams are faster in only two situations:
i personally only use streams for either
- method references (cause they look concise)
- parallel streams
- Parallel (although parallel streams can hang your computer if not used correctly)
- Lazy evaluation
Streams are slower but they're not abysmal
Someone I know ran a proper benchmark of them
I'd take a small ms delay for readability any day
It makes a difference if you use a lot in your program.
~20% slower than loops
That's not negligible imo.
It's not
Yeah its not
And readability isn't improved by that much for it to be worth it.
Method references
But it's not terrible either
Streams are fine if your code isn't super performance critical
They can really clean up your code too yeah
Exactly
Readability
Difference is that's not a stream.
I absolutely love streams, they're not perfect but they can save a lot of effort
I use streams for tab completions for my commands
same
I personally prefer declarative operations.
I enjoy the idea of having good performance
Redempt do you know uncle bob
No
Ah
Ok sorry your tab completions will be 20% slower
hes just a guy thats super good at talking about good code craftsmanship
I am sure it will really impact the server dramatically
I don't use brigadier
I use my own
But commands and tab completions have never been an issue sync
Yeah of course
And if they are then you probably have bigger things to worry about
idk, just a random thought lol. But his videos really helped me create good code
need some help with Particles, might be an easy thing -- tried googling didnt really lead me anywhere... how do i get coloured Particle.NOTE particles?
Any resources to learn how to make an enchantment book that would work in an anvil
get the stored enchantments from the itemmeta
it's not the same as enchanting the book
Huh
cast the itemmeta to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/EnchantmentStorageMeta.html
declaration: package: org.bukkit.inventory.meta, interface: EnchantmentStorageMeta
put a check if meta is instanceof too
or just make a giant try{ and catch{ 😎
bump?
how can i support hex colour code things thats like
&#fb0e0eJ&#f6300du&#f2520bs&#ed740at&#e89708D&#e3b907o&#dfdb05o&#dafd04m
?
i can only do it if theres a & infront of them all
it spells "JustDoom" (discord name)
so a single one is
&#fb0e0e
Minimessage or iridium colors
Good apis
ill have a look, thanks
amigos
The way im doing this enchant it just is an enchanted book with some data stored in nbt, and then it checks for it in an event. I was able to make it work with a crafting table just don't know how to with an anvil.
looks like just note / 24 sets the colour
i forgot how it works
ohhh
so i should use Random#nextInt(24) for random rainbow
you can probably only use those 12 colours
- 24 colours
or between them whatever scale
perfect
you';d have to check client ode
How can I fix this? https://imgur.com/XHnMZP2 using GridPane ```
Button btnBurger = new Button("Burger");
root.add(btnBurger, 0, 3);
Button btnFries = new Button("Fries");
root.add(btnFries, 0, 4);
Button btnSoda = new Button("Soda");
root.add(btnSoda, 1, 4);
just opened my plugin after not touching for abt a month.. lolwtf?
org.gradle.internal.resolve.ArtifactNotFoundException: Could not find spigot-api-1.17.1-R0.1-SNAPSHOT.jar
https://paste.md-5.net/motujocefo.cs this is my build.gradle
can you play a sound at a location instead of playing it to a player?
i think i might actually need U for this @sullen marlin .. dont mean to ping but if its a repository issue thats out of my control
declaration: package: org.bukkit, interface: World
looks like they exist too.. not sure why my gradle cant grab the latest
Yeah i got that issue too before... im not sure why i received it
i just upgraded my gradle wrapper
to 7.3
and it seemed to fix it
i restarted intellij with invalidated caches too and it just went nah too
ill try updating gradle
Yeah
Actually?
sorry for ping md
😂
thanks for everything