#help-development
1 messages ยท Page 2152 of 1
pretty sure console even has higher permission than op
well
you can do System.exit(0) and god is gone
CraftConsoleCommandSender extends ServerCommandSender
and that still has a "permissions map"
orrrrr /stop
so I wouldn't trust the ConsoleSender to ALWAYS have all perms
ah i just stopped checking for console permissions cuz i assumed it had all permissions
it's definitely possible to remove permissions from the console sender
why would you ๐คท
idk, I just wanted to say that ConsoleCommandSender does NOT override hasPermission to always return true
I assume that it still uses the default permissions as defined in plugin.yml
so I guess if you set a permission to default to "false" in plugin.yml, I guess that the console sender does not have this permission
hmm
I'll just try it out quickly
Why can't I cast this to a Bed?
does Bed implements BlockData?
iirc u need to remove getData() ?
or how its called
yeah, use getBlock().getBlockData()
it's not
commands:
test:
description: Some command
permission: some.permission.name
permissions:
some.permission.name:
default: false
the console by default only has permissions that are either "default: true" or "default: op"
if a permission is "default: false", then console won't have it either
oh
Still doesn't like this
.getBlockData() doesn't exist
Using 1.8.8 api if it matters
ugh...
anyone who uses acf?
you have to mention that you use a 8 year old version
me
of course that matters
Not my server, not my decisions
yeah but you have to mention that anyway
I would upgrade if it were me
Sorry for the noobie question.
I am getting an error = https://pastebin.com/3KeS1eDH
Can anyone help me out I would appreciate it.
but yea
1.8 uses a totally different way for "blockdata"
having an omnipotent god is cringe
im trying to make a method
@Default
public void onSetHome(KingdomsPlayer player, String[] args) {}```
instead of (Player player, String[] args) and im wondering how it could get a kingdomsplayer object
you are casting a blockdata to endportalframe that isn't instance of EndPortalFrame
i guess i need commandcontext
I see, one second. it's a bit complicated but not that complicated
let me check, I am using something similar in one of my plugins
How do I change the server resource pack via code.
the server doesn't have any resource pack. you can however of course send a resource pack URl to a player
set it in the server.properties file? or where its located
Player#sendResourcePack or sth like that
:o
Should i just handle sending the reosurce pack stuff myself and have no server resource pack specified in the server.properties file
okay i think thats what I plan to do...
Can I share with you the Main/Summon class and you can help me out? is it possible? sorry for that question
https://github.com/aikar/commands/wiki/Command-Contexts
Yes, you need a custom CommandContext. Basically you just take in "c" from the context, then return your custom class object from that
you can paste it here:
?paste
@tardy delta let me know if you need more help but I think the github link should explain it good enough :3
๐
looks good to me. between line 25 and 26, print out the clicked block, e.g.
System.out.println(e.getClickedBlock());
then see what the output is
monkelemphii
getServer().getPluginManager().registerEvents(new Summon(this), this);
new Summon(this);
?
in main
haven't checked the main but that shouldn't do anything bad except that it's totally useless
useless is bad >:(((
oh wait
in what line did the error occur
only now do I see that you also cast random blockdata to endportalframe in lines 57 to 60
you get an error in line 60
im wondering what BukkitCommandExecutionContext#popFirstArgs is doin
Whys that
because the block at loc4 is something else then END_PORTAL_FRAME
In my plugin I want to create a plain, flat start world: On the internet, I figured that you need to edit the server.properties file and set "level-type" to flat. However, if I do so, it isnt working... Any tipps?๐
Bukkit.createWorld
or do you want to change the "default" world?
setting "level-type" to flat will work
it works fine on localhost server
unless there already is an existing world
idk what is going on
yeah it should be my default world.
@latent pelican changing the "level-type" in server.properties will only change anything if there isn't already any generated world
@tender shard i think its something like this, i might test it out tomorrow
stop server, delete the world folder, start it again. now you should get a flat world
is userMap a Map<UUID,KingdomPlayer> ?
its supposed to be that ye, didnt create it yet
okay then yes, that should work fine
oh wait
no
you are trying to make KingdomPlayer be the commandsender right?
that won't work. the context is only for the given parameters
ye
your ACF method should still take a normal CommandSender
:o
and inside that, get your KingdomPlayer
the first parameter in ACF will ALWAYS be either ConsoleCommandSender or Player (or just CommandSender to allow both)
I couldn't fix it
be a gigachad, use bukkit commands
is it possible to do something liek onBlablabla(Player player, KingdomsPlayer kp, String[] args)?
How should the command syntax look like?
void onSetHome(Player player, KingdomsPlayer kp, String[] args)
public void onBlabla(Player player, String[] args) {
KingdomsPlayer kp = userMap.get(player.getUniqueId());
}
no I meant the syntax for players
like /message <receivingPlayer> <message...>
yeah just do what I sent
the first parameter will be Player
a bukkit player
now just turn it into a KingdomsPlayer on your own
manual? it's one line
ACF works with the builtin command senders
it won't mess with those
it can transform the arguments into your custom classes, but not the commandsender itself
e.g. if you do something like this:
/home myFirstHome
it can turn the String "myFirstHome" into a "KingdomsHome" object
but it will never do that for the sender itself
just create a method ```public KingdomgsPlayer fromPlayer(Player player) { userMap.get(player.getUniqueId()); \
btw I suggest to use compueIfAbsent instead of get()
mye doesnt matter too much
does acf support parsing custom types
yes
you mean to turn a "string parameter" into a custom object?
like u use custom object as a param
is that what the registerContext is doin?
yes
What do you mean by that? Just deleting the server in minecraft or the whole folder in my explorer?
So 3 folder right?
depends on which world you want to remove
@tardy delta @buoyant viper here's an example that works like this:
Players can enter /test someString
The commandExecutor receives a MyCustomObject instance, which is generated from the "someString" thing.
In your main class:
PaperCommandManager acf = new PaperCommandManager(this);
acf.getCommandContexts().registerContext(MyCustomObject.class, context -> {
return new MyCustomObject(context.getFirstArg());
});
The command executor:
public class MyCommand extends BaseCommand {
@Default
public void onCommand(CommandSender sender, MyCustomObject parameter) {
// Do something
}
}
The MyCustomObject class:
public class MyCustomObject {
final String myValue;
public MyCustomObject(final String myValue) {
this.myValue = myValue;
}
}
I fixed it, thanks for your help.
:o
important: in this case, the MyCustomObject thing is always created from the first argument
if you want to change that, you can ofc also get the full args[] in the "context" lambda
basically, a "context" in ACF returns an object that consists of
- the commandsender
- the full arguments that were entered
- and more information
ah i get it
you can use the context flags to also get the correct parameter if your commands have different parameters and the desired object isn't e.g. always the first parameter
it's a bit complicated at first but once you get it, it makes everything so much easier. so yeah just let me know if you have a specific example and I'll try to explain it again in detail
btw for ACF questions I recommend joining their discord. for some reason, most people here have no idea about ACF
everytime I ask a question here, noone answers ๐
ACF is awesome but unfortunately the documentation is shit. it's so powerful but so badly documented >.<
Ew
then you have to parse and translate everything yourself >.<
samee lol
my biggest plugin uses a mixture lol
If (args.length) hahahahahahah
No
bukkit commands for commands that already existed 3 years ago, and ACF for all commands that came after that
and I would never go back to bukkit commands
I am just too lazy to "translate" the old logic to ACF
adele is busy preparing her birthday
acf is nice but Im not a fan of annots which it bases itself of so ye
Lamp also uses annotations
ye I havent touched lamp
Why do you not like annotations tho
even spigot uses annotations. although not for commands
but the "provide custom objects as parameters" we were talking about does not require ANY annotation
yeye
like annotations are pretty bad when it comes to proper abstraction, ofc a cli implementation is a lower level module type, so one could argue for that proper abstraction might not be that integral
manual parsing goes brr
ACF is really nice. onCommand2 is using ACF, onCommand is the bukkit way:
@Default
public void onCommand2(Player player, AngelChest angelChest) {
// Do stuff
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
// send error
}
int angelChestId = Integer.parseInt(args[0]);
AngelChest angelChest = angelChests.get(angelChestId);
if(angelChest == null) {
// send error
}
// Do stuff
return true;
}
i simply dont like reflections
i used to do it manually too
obviously in ACF you have to tell it once how to turn a string into an "AngelChest" object but you only have to do it once and do not worry about all the error messages everytime etc
I mean I still write argument parsers for my arguments but yeah get watchu mean alex
actually angelchest is my only plugin that doesn't heavily rely on ACF lol
so it was a bad example
but anyway
there was a time, instead of sending messages and blablabla to a player, i just returned a CommandResult in my onCommand method
scary
I do the same thing in my discord bot
public void handleCommand(@NotNull CommandSender sender, @Nullable Message message, @NotNull String... args) {
if(args.length==0) return;
String commandName = args[0].toLowerCase(Locale.ROOT);
Command command = commandMap.get(commandName);
if(command == null) {
CommandSender.CONSOLE.message("Unknown command: \"" + Command.withPrefix(CommandSender.CONSOLE, commandName) + "\". Enter \"" + Command.withPrefix(CommandSender.CONSOLE, "help") + "\" for a list of available commands.");
return;
}
if(!sender.hasPermission(command.getPermission())) {
sender.message("You do not have the required permission (" + command.getPermission() + ") to run this command.");
return;
}
CommandResult result = command.execute(sender, message, Utils.shiftArray(args));
if(result == CommandResult.WRONG_USAGE) {
sender.message("Usage: " + commandName + " " + command.getUsage());
return;
} else if(result == CommandResult.NOT_FROM_CONSOLE) {
sender.message("You cannot run this command from console.");
return;
}
Logger.info(sender + " executed command: " + String.join(" ",args));
}
public enum CommandResult {
OK, NOT_FOUND, WRONG_USAGE, NO_PERMISSION, NOT_FROM_CONSOLE;
whoops
that's longer than I thought
I just made a command system where I dont need to do checks for arguments cause fuck arguments
we should create a library called "TerribleCommands" that works like this:
- Player enters /sethome
- A conversation starts where the plugin says "Please now enter the first parameter"
- Player enters a name in chat
- Plugin asks "Do you want to enter an additional parameter?"
- Player enters "no"
- Plugin replies "Error: Your home was set successfully."
yes
its also case sensitive of course
if you type No rather than no you must restart
I updated #6
it shouldn't be THAT terrible
it should only be over complicated
So setting the type to "BED_BLOCK" allows me to cast it to a Bed, but it removes the actual block...
"please enter the base64 encoded name of your home"
check how the block is called in 1.8
in 1.13+ it's simply "BED"
The problem is both BED_BLOCK and BED exist in this version
IIRC in 1.8 there's two blocks for the head of the bed and the tail of the bed
BED is probably the inventory bed
It probably is
while BED_BLOCK needs to be set twice for both the head and the end, with different data
idk anything about 1.8, I started in 1.13 when all this bullshit was changed to proper API ๐
1.8 is so tedious to work with
but for beds it's similar in 1.13+ too: you have to set the head block and the tail block. if you only set one, you only have half a bed and it will break once there's a blockupdate or similar
How do I get a pack hash?
do i have to have it saved
i can't just generate it
ugh
how do I get the hash
a hash of what?
of a resource pack?
sha1sum <resourcepackfilename>
whats that, CLI?
yeah
ok
I am sure there's also websites where you can upload your file and it will tell you the hash
ty, I guess
nice using that!!!
not that I hate CLI but that I have to get server owner to use it
SHA1 online hash file checksum function
thank you!
๐
any minecraft work in general is a chore tbh
not really
Hello friends, can anyone help me decipher this error?
Let "src" not be null. Done.
haha yes, but what does that actually mean
wait oops forgot the implements Serializable nvm
Show your SerializePlayerWrapper.java file
How does Hypixel get to avoid authentication server issues
its currently working with the auth servers down
Man, why are the 1.12 kids the most toxic kids?
Probably because they're using 1.12
because they aren't using 1.8, the best version 
1.12 most toxic? Then 1.8 is most entitled 
idk after like 5 years working with the client, its tedious @dusk flicker @torn shuttle
yee
As far as I am aware, they cache players and the auth sessions somehow
I could be 110% wrong, but thats my understanding
most likely not
I've been at it for 5 years as well, it's not that bad
I'm doing Unity and even some web dev right now and it's the good old meme of if you wish to make a pie from nothing you must first create the universe
server-side
hmm
webdev is still fun for me for now, not as monotonous as mcdev yet
even when i have to do it from scratch
if you want to make a hunger games plugin in minecraft you can rig up some code in under a week to get something pretty decent going, if you want to make a hunger games game in Unity, or any engine (or god forbid with - no engine) you better start making the models, rigging animations, checking your topology, create the map assets, script the movement, record your various soundtracks, create the UI and also at some point you have to create or implement netcode, lobby systems, dedicated servers or p2p solutions (so basically use steam as the middleman)...
and then you can start worrying about the gameplay lol
Yeah then the bugs start rolling in 
the bugs start comin n they dont stop comin n they dont stop comin n
if you want to talk tedious I'm doing webdev right now and this is the most bored I've felt all year
making a single page webapp with just html css and js makes you wish for nuclear winter
are u a framewoker or vanilla kinda guy
and I would rather go become a goat farmer than actually finish learning angular
I would honestly start with vue or react.
Angular is gonna make you commit unliving real quick.
I'm just using the vanilla tools
I am not going to learn these fancy frameworks for this project
I hate webdev, the less I do it the happier I am
tru
Same. Ive tried force learning it each other month now and i could never get past
the basic building blocks. Its just so boring...
I did the classic mistake of trying to fix how shit of an experience web dev is by trying fancier tools of web dev
it lead nowhere and it's one of the few times in my life I gave up on something
ill get the url just wait
which tbf I am doing the thing I gave up on a couple of years right now so I guess ultimately I didn't really give up on the project, just on using angular for it
The most complicated web application ive written was actually done in Java with vaadin XD
now I'm not even using jquery, either it gets done with js or it gets done with js but it takes me a bit longer
ok now i got it
besides webdev frameworks are basically just fashion statements with the speed at which they seem to come into and out of popularity
I built a simple app with 10 different JavaScript frameworks... Learn the pros and cons of each JS framework before building your next app https://github.com/fireship-io/10-javascript-frameworks
#javascript #webdev #top10
๐ Resources
Full Courses https://fireship.io/courses/
Performance Benchmarks https://github.com/krausest/js-framework-benc...
talk abt frameworks coming n going
Ill just wait until web assembly is more adapted and then write websites in Kotlin or something
hope you're not waiting standing up then
https://magmaguy.com/webapp2/webapp.html gaze upon my prototype and despair
just use kotlinjs ๐
the only thing I used for it was bootstrap because I'm not a masochist either
is it supposed to be .yml.txt
nah, part of why it's a prototype rn
mine worked
๐
FF
@lost matrix chrome?
Hell no. Not gonna throw any more data at google than i already have to.
ill try it on pc later
k then I don't know, it seemed to be generating as yml as well but tbf I wrote the code for generating the file extension after 23 hours of straight work
is it sad that i can recognize firefox from the download popup
it doesn't even matter that much because ultimately it would be better if it gave you a zipped file with everything in the appropriate directories, it's a tool for mass creation
the main things I still have to do are the zip distribution and the nested editing
well, and adding all of the fields for the other file types but that's just me mindlessly filling in the already created templates
Why wont this work? Am I setting it wrong? Once again, 1.8.8 API.
Question... If I have a YamlFile in class 1 and another yamlfile in class 2 but they both are refrenced to the same place, and come from the same place... If i write something to the file from class 1, and another thing from class 2 and then saved the both, will class 2 overwrite what class one wrote or they both get written down since it is the same object refrence?
Does it use the same instance of yamlconfiguration?
Yes
Are you setting and saving different things
So YamlFile file1 and YamlFile file2 come from the same location
point to the same refrence
I dont understand why you call it file1 and file2 then
if I set "Name" to John in file 1 and "Age" to 22 in file 2. Will both of those values be saved or only age since it was saved second>?
It is just a way to explain it brother.
Each class i am working with has a different YamlFile but some can repeat that's why I'm asking if they both come from the same place, what I make to file 1 happens to file 2?
If it's the same instance of yamlconfiguration it'll save both
If you create 2 different instances I'm not sure what ll happen
Can you show your code?
Are all of the data u have in those auto complete fields hardcoded
Lets say there is a list with a bunch of files saved. in class 1 I need a file that is the same file that class 2 needs. I get it from that list. So YamlFile file1 comes from that list and YamlFile file2 also comes from that list it is the same exact instance of the file. What I'm asking is that if I modify the file from class 1 class 2 also has those modifications on its file instance
Yup
Two different objects but same refrence
Huh?
that keeps track of the changes right?:
Thought it's the same object
If you load 2 configs of tje same file, changes to one do not show in the other
However if you load one config and share it between multiple classes
Changes are shared
YamlFile file1 = Tools.getFileLoaded("java4life");
YamlFile file2 = Tools.getFileLoaded("java4life");
``` Modificatios to file1 also happen to file2 since the value Tools.getFileLoaded returns the same exact object it returned to file1
?
If getFileLoaded returns it from a map that caches loaded files then yeah
2 referemces to the same object
No problem
yes, I created a greasemonkey script that downloads spigot api enums in a js array-friendly format so I just have to click the dl button and copy paste it into the webapp
that way I don't have to do any of the work and I also don't have to scrape the api page which would not really be cool of me to do
Aight, I think your web app is suitable in node
Since it mostly deals with io and files
I would rather not make the app at all than make it in node
Kindw tedious but node does the job too
yeah I have no intention of using node unless I really have no option
ultimately this works just fine with vanilla js
it's barely 300 lines of code
Fair, my plugin wiki is just vanilla js too as of now with fetching data from a cloudflare worker that returns a json of the items, lore, recipe
I like how we're using the exact same bootstrap button
btn btn-primary
is this even the same blue?
Yeah its using bootstrap
jesus you'd think one of us was looking at the other's webpage while making it
yeah I mean it's the default primary action button
Mine uses modals
Button then pops up modals
I made it 2 days ago since I exported all of the items in a json file
I was using cards but then I stripped the card code out at some point and ended up remaking it in my own implementation
anyone know why this error happens
i havent boot up my server to test my plugin in a while now so it may be outdated
Great, been using bootstrap for my IT course with php, made our lives easier
bootstrap is great for quick formatting, especially if you're more of a developer and less of an artist
alright I need to get back to writing this
Goodluck ๐
no help? sadge
google the error
Check if the jar name is correct and/or the path to the jar file.
it worked before
nothing shouldve changed
could u tell me how i can check i installed the server months agop
Just open the start file with nodepad and check if the names are the same as the jar file in server folder.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Also please use #help-server for further questions.
i did nobody there ๐ญ
All needed info is on that spigot page I've send ๐
ok ty
Trying to open a inv with 9 slot and got
java.lang.IllegalArgumentException: Invalid inventory size; expected 9 or less
Trying to open with 18 slot and got
java.lang.IllegalArgumentException: Invalid inventory size; expected 18 or less
Trying to open with 27 slot and got
java.lang.IllegalArgumentException: Invalid inventory size; expected 27 or less
Can you show the code?
Its just openinv(inv)
Its a custom ec plugin. so when I try to open ec. I got error
but same code was working 2 weeks ago
users started reporting me then I found this
Which line though
[08:50:24 ERROR]: Could not pass event PlayerInteractEvent to EnderPlus v1.6
java.lang.IllegalArgumentException: Invalid inventory size; expected 9 or less
at org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventory.setContents(CraftInventory.java:85) ~[patched_1.17.1.jar:git-Airplane-"74774a0"]
at me.rrs.Util.Util.inv(Util.java:21) ~[EnderPlus.jar:?]
at me.rrs.Listener.OpenEnderchest.onPlayerInteract(OpenEnderchest.java:27) ~[EnderPlus.jar:?]
??
Im wondering if the size being passed in by RRS is too small for the contents being added
The inv methoud should ideall take the number of rows
yeah
And then multiply by 9
so from what I am betting RRS
is the contents of that players enderchest, however you are storing it (where you showed earlier) is larger than what they have permission for
so I can remove the if player is op things?
Lol
Yeah
yes, just flip your checks around basically
start at 6, then 5, then 4, etc
Btw you can create a for loop for that
loop?
btw still getting same error
for (i=6, i>0,i--)
umm
alright That will be grate ig. but I will still get error .-.
Yeah let's solve the issue first
java.lang.IllegalArgumentException: Invalid inventory size; expected 18 or less
with enderplus.lvl.2 perm
okay
wait @humble tulip I can't print inv size as there is no inv
I mean inv didn't created
java.lang.IllegalArgumentException: Invalid inventory size; expected 18 or less
so it just cancel
Print int size and print Echest.get(player).size
Print it as soon as the method is called
Did it throw an error there?
??
Echest.get(player).size
oh
Me?
nvm
Noooo
That's the map size
Echest.get(Player.getName).size
Or .length if it's an array
Before you even test it send the code so I'll make sure it's the correct thing you're printing
idk whats wrong/write, now inv is opening after adding this line .-.
but
problem is
java.lang.NullPointerException: Cannot read the array length because the return value of "java.util.HashMap.get(Object)" is null
do you think its java problem?? before I tested it with java 8. and now using 17
Nope
Not java
The size of the echest inventory contents was larger than the inventory you created
That was the problem
Is your code on github?
it was but it magically fixed when I print that line .-.
That line couldn't have possible fixed it
Okay what happens if a player had an inv of 4 rows and then got downgraded to 1 row
When you load the data tjere are 36 items
But then when you set contents to 1 row you're trying to set the other 27 items that can't fit in an inventory with 9 spaces
If you add an extra - null to your config file it'll break it once more
umm. but all empty slot is null. so it shouldn't fill
I mean null == no item
so that shouldn't search for an item
but
I tested that before
it just remove items from data.yml(where it save hashmap) on inv close
if slot downgraded
if (Echest.containsKey(player.getName())){
int echestSize = Echest.get(player.getName()).length;
EnderPlus.getInstance().getLogger().info("Number of enderchest contents: " + echestSize);
EnderPlus.getInstance().getLogger().info("Trying to open enderchest of size: " + size);
EnderPlus.getInstance().getLogger().info("Will fail? " + (echestSize > size));
inventory.setContents(Echest.get(player.getName()));
}
try putting that
.-.
yap. but how to fix it .-.
this plugin is too far gone
wait
lots of issues
oh nah. that was inventory.setContents(Echest.get(player.getName())); problem
its not a problem with setContents
its a problem with how you handle data
if (Echest.containsKey(player.getName())){
ItemStack[] echestContents = Echest.get(player.getName());
for (int i = 0; i < size || i < echestContents.length; i++) {
inventory.setItem(i, echestContents[i]);
}
}
that should solve your problem
but i do recommend you recode your plugin
Also, never use player name for data, always uuid
there is times where you have to use player name
however, in general yes use UUID where possible
I always have a database table mapping uuid to player name and update it every time the player logs in on asycplayerpreloginevent
nvm
I am using a NPCClickEvent to get which player clicked and which npc got clicked (using the CitizensAPI) but the event isnt firing
I have registered it as well
can it be because I am implementing the Bukkit Listener and not something else
nvm fixed, I was using the wrong event, I shouldve used NPCRightClickEvent
NbtCompound signNbt = NbtFactory.ofCompound("ExtraAttributes");
signNbt.put("id", "minecraft:sign");
signNbt.put("x", pos.getX());
signNbt.put("y", pos.getY());
signNbt.put("z", pos.getZ());
signNbt.put("Text1", "{\"text\":\"" + line1 + "\"}");
signNbt.put("Text2", "{\"text\":\"" + line2 + "\"}");
signNbt.put("Text3", "{\"text\":\"" + line3 + "\"}");
signNbt.put("Text4", "{\"text\":\"" + line4 + "\"}");
shouldn't the Text1, Text2 .. work ?
id, x, y, z, do.
what duration should i pass if I want the effect to be permanent (in a PotionEffect)
Integer.MAX_VALUE
I get the duration through the config, so what should I put in the config?
2147483647
9999 will do it, if I remember correctly
Depends on how you give it to the player and what the effect is for
but this is a good way to do it.
i give it using the add potion effect method
Yeah, but how do you give it to him, when he executes a command or ?
when he clicks an NPC
Hmmm, I'd say maybe use Integer.MAX_VALUE
But how can I know that value from the config
I am importing what the user wants to do on click from the config
okay so i think some progress
getConfig().getInt(duration); //The duration should be the path where you store the potion duration in the configs of the player, and also instead of getConfig, maybe use FileConfiguration to get the player config file and go off of there.```
yea i do that
Does this make any sense to you?
Is it possible to check if an item is an armor, and if it is, where it?
rn when the player click, the plugin gives them haste but it dissapears after 1 millisecond
Maybe try checking the itemstack of it ?
Or just use instanceof
instandof what?
ItemArmor
I mean I guess I can check for every possible armor but that wouldn't be that efficient
#ItemArmor
Oh I didn't know this was a thing, thank you!
No worries, hope it helps.
Hello all Spigot experts, please tell me how to do it right
f.add("title", (c /*yaml-similar config*/, path) -> {
TitlePart part = switch (c.getString(path+".type", /*comment*/"TITLE or SUBTITLE or TIMES")) {
case "SUBTITLE" -> TitlePart.SUBTITLE;
case "TIMES" -> TitlePart.TIMES;
default -> TitlePart.TITLE;
};
return new Script() {
final String msg = c.getString(path+".title");//not null
@Override
public void run(Player p, /*and other*/) {
p.sendTitlePart(part, msg);// <- there's a mistake here
}
};
});
the error itself
java.lang.ClassCastException:
class java.lang.String cannot be cast to class net.kyori.adventure.text.Component
(java.lang.String is in module java.base of loader 'bootstrap';
net.kyori.adventure.text.Component is in unnamed module of loader 'app')
at org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer.sendTitlePart(CraftPlayer.java:2333)
Give it a component instead of a string
Please tell me the exact name of the class.
Component
this is the interface ...
Thank you, I think that's enough for me to figure it out
Did it work for you ?
Solved, the way i was reading the config was wrong, i was using the wrong path
I ended up manually checking it since I'm making a Bedwars minigame and it doesn't have a lot of armor types
The class you spoke of wasn't recognized and I didn't find it in the SpigotAPI
can I color 1 message in different colors?
(player see something like this &6 Hello &cWorld)
Looks like I 'm really blind .. Okay, I'll look for more.
Text Serializers
Or MiniMessage
Sorry i couldnt help
i'm currently having a KingdomsPlayer class which stores a AtomicReference<PlayerData>, should i just throw all data in there or should i make it more structured?
Also, i think its craftbukkit not spigot
'im for example saving a list of homes, cooldowns, the kingdom
Spigot is built on CraftBukkit. Everything in it is in Spigot
That's ok, thanks for trying haha
as far as I understand, without connecting external dependencies, I will not be able to paint the text as my heart desires, am I right?
however, the development environment does not see MiniMessage
despite the fact that the paper fork with all its classes is in dependencies
1.17
any good tutorial how to work with h2 databases
whats the best way to deal with CraftBukkit versions? Do I just have to make an if else statement for each version I want to support?
I found a suspicious similarity of work
player.sendTitlePart(Component);
player.spigot().sendMessage(Component);
I know for sure that sendMessage(BaseComponent[])
allows you to send a message in multiple colors
if I put in Title ,,BaseComponent[],, (Component will be empty), it will work?
Is there a possibility to change the spigot-api code? I want to route the Bukkit#getOfflinePlayer method to my own service or something like that
build your Spigot from sources.
the spigot-api does not provide any implementation
and if you change the spigot code itself, your plugin will not run on other people's servers
I forgot, they were closed. Use paper patches
it's just for my server
Only recompilation. You can use Paper or manually replace the necessary classes in your jar package.
it's not. just download BuildTools and run it
now you have the complete source code for spigot
If you want to a modification you modify spigot-jar right?
why does everyone suddenly ask this question?
since yesterday there were a shit ton of people who suddenly want to modify the server software
which imho is a very bad idea
Because i have seen many time spigot jar and i didnt find any impl flrmthe te api
spigot.jar IS the implementation
That's why MiniMessage is missing. It was added in 1.18.2
whut?!
Paper 1.18.2
in paper or in spigot?
I thought minimessage was part of paper since like... a long time ago
I've already done it via BaseComponent-s
Alright
minimessage is very flawed imho but still 100 times better than spigot's weird "components"
The same MM as far as I understand is just an add-on over the components, am I right?
is there any way to tell if a called event had an actual impact in the game? like if i call an entity damage event is there a way to distinguish between an actual damaging event or just a called event
without comparing hp before and after a tick
Also which the impl of player?
CraftPlayer ?
Ohh ok
How can I update/change the inventory name? (Preferably without NMS)
setTitle()?
i guess the title can only be defined when the inventory is made
is it a custom inventory
I only know such a crutch as, copy the content to a new (renamed) inventory.
pretty certain the name is part of the open menu packet
e.g. you cannot mutate it without reopening the inventory
I was doing so, But closing and opening the inventory cause the cursor to reset to center ๐ฆ
And the update happens every 4 tick ๐คท
So the cursor will be stuck ๐
Bukkit#createInventory ๐คท
He wants to change the name so that he doesn't have to create a new inventory
without opening a new inventory i doubt that will be possible
Let me clear it, Title is like this Confirm (10s) and it will count down and after that it will enable the confirm slot
I know there must be a way as I saw it in several servers ๐คท
is it impractical for you to open new inventories with the same contents
Update is frequent ๐คท and as I said opening new ones cause the cursor reset...
are you closing the inventory before opening? i feel like that might cause the cursor reset
I am so masochistic that I keep all non-changeable menus in RAM as a finite set of packages..
but i dont know for sure
Can you reopen another inventory while another one is open ๐ค
dont see why not
I made the API last year... But I think not closing the last one was causing issues
doesnt hurt to try i think lol
I don't know tbh
AFAIK it's a "standalone" system
but I don't really know
please tell me where are the vanilla commands? (in which package)
Yes, use packets.
Can you hint the packet name ๐
Packets always confuse me...
Use -1
If you see the value is negative set it to max
Aight
hi when i type somthing i get a white line over it like ------
Idk what I did wrong... But it doesn't work...
this is wrong try it https://paste.md-5.net/uvexecageg.js
Is it an alright idea to have a class such as ItemRegistry be used to store static ItemStack objects?
Sure, so long as you understand that ItemStacks are mutable so things like ItemRegistry.MY_ITEM.setAmount(5) would change it
You could make a series of static getters to make sure they aren't mutable
Probably the best option in that case
it would be so cursed
imagine a
public static ItemStack MY_ITEM() {
return MyClass.MY_ITEM.clone();
}
private static final ItemStack ITEM = // whatever
public static ItemStack getItem() {
return ITEM.clone();
}
public static boolean isItem(ItemStack itemStack) {
return ITEM.isSimilar(itemStack);
}```
That's generally what I would do
is it safe to add an event listener to a class constructor? or would this cause a lot of problems when you have a lot of class instances?
I'd avoid registration of listeners in constructors
I know some people prefer doing that but it's just... not great...
(1) Loose object construction
(2) Not clear that it's being registered
(3) Prone to mistakes if multiple instances are created
oh ok
Though to answer your question about whether or not it's safe: yes it's safe
Just unclear
how would i listen for a left-click at an entity?
Use a listener
Np
i know that i need to use listeners but what event should i use its my question
I need help storing custom enchants on a pickaxe, and I don't want to do that in a .yml file, what would be a smarter option to do to have something like this?
use the PersistentDataContainer
declaration: package: org.bukkit.event.player, class: PlayerInteractEntityEvent
Possibly this?
this only triggers on right-click
You want on punch?
yes
EntityDamageEvent
Oh okay, could I save like jackHammerLevel variable, and load that value in the ItemMeta ?
yes
u can make custom persistent data types
make like a class that stores all the info u need
yes try using the mfnalex's lib for data types
Hey, how can I cancel the throwing of a snowball and give it back in the Inventory with the onPlayerInteract event? Is it even possible?
PlayerInteractEvent @karmic hull
Okay, another question, would it cause lag if I got the persistent data every time someone broke a block ?
you can cancel the throwing
oh, yes I meant that
if you cancel the event it should just not do anything
tried it with event.setCancelled(true); already
no difference
nope pdc is very light
as my experience
try it with the projectileLaunchEvent
Okay, thanks alot man!
np
There I can remove the entity, but I also want it to get back into the players inventory
you can get the entity which launched the projectile, right?
EntityType.SNOWBALL
did you figure this out yet?
@midnight shore would you store the economy in PDC ?
Such as /balance /tokens etc..
it depends on whether you wanna get the balance of a player when they aren't online aswell imo
Oh so it only loads a data when a player's online ?
you cant get the PDC of an offline player as far as I know unless you store it in a file
oh sorry, needed to go away for a short period. My problem is that if I cancel the ProjectileLaunchEvent nothing happens, I would need to manually give the player the item back and remove the entity. Same with the PlayerInteractEvent. Should this be the case?
nah use a database or yml
depends what u have access to
If you don't have access to MySQL, you always have access to SQLite
if the cancelling does not work as you want it to you have to give back the item to the player and remove the launched projectile... not sure about what cancelling the ProjectileLaunchEvent actually does
I'm using MySQL
use that for your economy then
YAML can be abused as storage tho :3
okay, is there an easy way to get the item that was thrown + the inventory slot?
hold on, checking the event real quick
well for one you can get the launched projectile with the getEntity() method. From there you can get the ProjectileSource with getShooter(), check whether thats a player and do whatever in the inventory there.
For some reason, I have items in my GUI inventory but I can not see them on my client ๐ค
How do I update a minecraft plugin that is 1.16.5 to 1.18.2?
Thanks a lot! But is there an easy way to get the item directly as an ItemStack? You only get an entity, right?
have you tested whether it already works on 1.18.2?
as long as you dont have nms it should be fine
yeah you get the Projectile, but you only want to listen for Snowballs, right?
It doesn't work on 1.18.2
do you have nms?
What doesn't work ?
Do you have any error ?
while this may be true, it only works for small things. Once you go beyond small stuff you start to see hinderances
it was meant as a half joke but yeah
Any ideas for designing protocols?
protocol for what exactly?
Communication one
yes lets just keep it broad
you designing a protocol level like TCP or something? Or you talking about software protocols
Im thinking to design a protocol using a backend as base
I think looks more similar to "SMS" or "SMTP"
All protocols need a backend
but are you looking for something like Minecraft's protocol where it's basically TCP on crack or something a little more specific?
minecraft's protocol operates on a very simple ideal, where you just have a packetid and you let both sides decypher info based on that id
there are some slightly more complex byte structures that indicate the type of data the following byte segment has, like nbt
where you have a byte saying wheter it is a long, an nbt tag etc and then you just parse it based on that byte
Like I think using hashmaps is the only way so like how mcuh overhead is there
Depending how much data, its size, many others things you are catching
Yeah i was a protocol similar, which allow sending/receiving data (my server working as a router), which allow multiple people doing their communication. Defining custom packets
or smth else i should use instead of a hashmap
so you are looking to create an application layer protocol
those are easy to create for the most part
What does this crash-report mean? https://paste.md-5.net/erenutezub.apache
the hard part is keeping the packets/data to small sizes for what you are creating as well as avoiding duplication
Yeah, my main goal is an api with a protocol allowing to send and receive custom packets
So i dont know from where to start, so i was looking if i can find any ideas for doing the protocol layer design
Where you declared or asserted in your code that something can't be null
that something is returning null either because it is or you made it null
but you asserted it isn't suppose to be
partial or image shots of code isn't helpful
and what I said also applies to api methods too
where it was asserted to not be null, but you made it null anyways
Generally speaking
if you wanna reduce memory usage, then operations may scale worse
Soo a hashmap it is?
just look at some other protocol ๐
lol. sure
Im just not quite sure about the overhead that comes with java has maps so its kinda scary
how much data do you intend to be manipulating at any given time?
or read already benchmarked results
I'm making a denylist so the data/per is really not that big
then you really have no concerns over overhead of any kind of object you decide to use
I'm wondering how a server implementation works in java. If inwere to create my own would i have a thread for each socket connection and have a main thread with a concurrentcollection where i store "packets" to be processed?
Ya but when the amount reaches 10s of thousands I'm just not quite sure
The most convenient optimization would be for you to define the scale factor for your hashmap lol.
you don't need to worry until you reach somewhere in the millions
Alr
if you had a thread for each connection you would run out of memory to allocate new threads.
very fast
yeah youd usually opt in for a thread pool
Doesn't wating for data from a socket block the thread?
it could, depends how you have it setup
Network cards have buffers
as long as you don't make it wait too long you could have a non-blocking thread
I mean both netty and java nio can help you with the entire concurrency design
Never looked into any of those
It's just something i think about sometimes
I'll have a look into it
well you should also research what network hardware is capable of too ๐
netty is the library that MC uses for its network implementation
nio is the java package in java that is for concurrency
Btw for runnables that need to run sync from an async task, does it just add the runnable to a concurrentset and call runnable.run on the next tick?
No i mean how does it work internally
an asynchronous task that executes a synchronous task will cause the asynchronous task to wait on that sync one every time it is called
Oh yes sure 1sec
Been working with other threads alot recently and concurrency is mind boggling
Haven't run into issues yet but i feel like I'll cause a deadlock eventually
synchronous and asynchronous tasks do not directly relate to threads
myeah
always smart to read up on stuff like optimistic concurrency design
Can i read 1 variable from 2 threads at the same time safely?
it isn't easy to cause a deadlock yourself
well I guess it is if you really know how
but for the most part, Java won't let you easily do that ๐
Yeah i mean on someone else's server since it happens randomly
it doesn't just happen randomly lol
if you need the variable to be the same between two threads or a method to be thread safe use the synchronized keyword in java
So even setting and reading on multiple tjreads is thread safe
Java objects are sync right?
yes
What does the * mean after a plugin name in /pl?
wouldnt make sense otherwise, they would have to use futures
it depends on what you are doing. You can end up with a CME(Concurrent Modification Error)
Ok thought so
if you try to do things say on an array that adds and removes in one operation
Which is why i get data async and set it sync
wat
no
objects have no notion of sync/async
I know modifying a list while iterating throws that
they said collections at first
methods do tho
they edited it
yes because you are reading and writing in one operation
there was 'collections' before
that response was from "collections"
So collections are part of java objects, and are sync?
I mean adding or removing and then reading
what happens in that scenario is that what was read in the list, may not be in the list anymore
the methods a collection offers may support it
dunno how objects would be async
How will i be reading and writing in one operation from different threads though? I can understand if the read and write occurs at the same time but it'll be different operations
noobie question..
How do I add radius using e.getPlayer().playSound
if you have 2 threads that are doing it, its not 2 operations per-say one after the other. Its 2 operations at the exact same time or nearly
thus the reading could happen before the write
which is not the ideal scenario in most cases
or you could get 2 write operations that add and remove a variable in the same position
Ok so modifying non tjread safe collections from one thread only is the way to go
if the remove was suppose to happen first before the add
you could get the add happening before the removing ๐
Volume specifies it
now if you use the synchronized keyword though on methods, any threads accessing that method will need to wait for that method to complete before getting their turn. This a cheap way in making something non-thread safe into something thread safe. But have to be careful in doing it this way as you could potentially take performance hit doing so.
Yeah for starters using synchronized will suffice, but as you develop you must learn how to operate atomically and learn about Javaโs framework concerning multithreading
Let's say i have a dataholderobject that is only modified sync, can i load the data into it on asyncprelogin since it's on a different thread but when I'm ready to read and modify, it'll be done on one thread only
You mean to players in a radius?
minion in principle
async or sync doesn't necessarily mean threading. You can have an asynchronous task done on the same thread as the main thread
^
it doesn't necessarily get its own thread to execute in
iterate through the players you can get from getNearbyEntities() and play the sound for each one?
Wait really?
async means code does not run linearly to its expressive declaration
my bad wrong line
Thats the line:
e.getPlayer().playSound(loc5, Sound.EVENT_RAID_HORN, 25.0F, 1F);
btw
think of asynchronous as meaning the work is spread out over multiple ticks instead of trying to do it in a single one
Get all the players in thenradius and play thebsound for them
And yeah
Huh.. So when i save data async, it's possible that it's on the main thread?
yes
Sync - code runs linearly (by reading the order you put your statements in, you can predict the order the code will execute)
Async - code does not run linearly thus you cannot predict in what order the code is going to run despite knowing the order of how the code was declared
Concurrent - two operations run seemingly at the same time, but not really
Parallel - two operations can run exactly at the same time, usually when you have multiple processors
Sorry for ping, but whats better Stream or ParallelStream()?
depends
So why is it reccommend to save data async if it's possible tjat it runs on the main thread?
Wouldn't that be blocking
Mmm so like after the parsing of the hashmap, I just resize them to the minimum? ( I didnt jsut see this I just finished the trie so this is related istg)
not really
When saving data into database or using rest api, if you dont use async can block the main thread or atleast you lost resources
On what
more like, when the backing array is full, how big it should be resized to
because it doesn't try to do everything in an async task in the amount of time the game loop lasts. Which in the case of MC is 50ms. If your task is going to take longer, it will spread it out over time to accomplish the task
Yeah so the minimum?
since its not going to be mutated any further
so it will slice up your task, and add other tasks in there too in the loop
uh sure lol.
and then keep processing those small slices until its done
Ohhh so it runs until it reaches 50 ms in 1 tick and then schedules for another tick if it doesn't finish them all
yes, except it won't try fitting your task in that full 50ms
am i missin the obvious
you might have a fraction get done in one tick
then it might skip doing your task for 1-2 ticks
then come back and do 2 of your tasks etc
How would it run half my runnable though?
but the point being, your task is just broken up over time to fit in with everything else going on
Or does it?
in Java its by convention not possible unless you throw some error inside the runnable or use Thread.interrupt()
So if my async runnable takes 3 seconds and it haooens to be run on the main thread, it will lag?
pretty much
Wtf
Yes because you are overloading the main thread with tasks never completed
That i did not know
So should i use my own threads then if i have really heavy reading/writing to do?
