#help-development
1 messages · Page 2160 of 1
xd
hi, tell me how to put a player a personal spawn point?
code that will be equivalent to the /spawnpoint command
who would have thought that the method name contains a bed...
i havent got a great understanding of lambda, but is it a quick foreach? or for every value in collection also supplying variable
not really
so instead of looping through a list and sending it as a normal for loop i could do
messageList.forEach(message -> p.sendMessage(message));
oh
a lambda is used in the case of foreach
but that isn’t it’s only purpose
you can think of it as an interface with only one method, but just shorter syntax
in the case of the foreach in collections, the method is just being called for every value in the collection, with each value being a different argument
it is still a loop, just because you use lambda doesn't mean it changes how the code is executed, instead it changes how it looks and in some cases to be more compact
have to sometimes be careful when using lambda's as while it can make the code shorter, it does hide away some of that verbosity to understand what is really going on with the code.
okay
I personally don't use lambda's as I don't like them
yeah but it makes it look fancy
nice
and when i get the data back, it is empty
get better theme
I remember reading that lambda code is also slower then just normal loops
is olddata null
this isn't true as lambda
still executes normal code stuff
it is just hidden away out of view
opinions on lombok
is it possible to change the spawing rate of a specific mob
Thats also what I thought, I think it just depends if it generates the same bytecode as if you were to write it normally
I assume oldData is a list of blockdata? and why are you doing iterator.next
where is that from tho
if you want to decrease it, remove mobs with a certain chance on spawn
if you wanna increase I guess you have to double spawn mobs with a certain chance?
isnt there an event for spawning
CreatureSpawnEvent
can you call that
suppose i get list of all the zombies and put a chace of 50% to spawn a new zombie there?will it work?
what do you meant a list?
not increased spawn chances
you just listen to the CreatureSpawnEvent
ok
and then you could with a 50% chance spawn another one
you would have to make it not be able to spawn another one on the extra zombie spawn tho
ok
does someone know how to inject new items to the item list that the vanilla /give command is using?
i would probably just make my own command for that
you can override vanilla commands
iknow
and i did before
but i dont wanna rewrite the give command
i mean, it seems like less work to do that than inject into the /give command
that would probably require lots of nms and shouldn’t really be done in the first place
if you’re making custom items, you should make custom commands to get them as well
Pretty sure give pulls from the item registry
Those are frozen soo gl Injecting anything
And even then that might cause other issues
yea
where can i find that field?
injecting directly into registries seems more like modding, not plugin making
it’s much more complicated than just one field
i’m just telling you straight up, it’ll be way easier to just make your own command than to inject custom items into nms registries
it doesn't generate the same byte code
however, the JVM will still execute things in native code the same way
for some things in regards to lambda
occasionally it will do it differently
how can i delete every document from a collection?
okay i guess im stupid but why does this return 0.0 instead of 0.33
int a = 3;
int b = 9;
double c = a / b;
Bukkit.broadcastMessage("c: " + Double.toString(c));
i thought a double is a 64 bit value
as if this is being hit by the diminishing accuracy lmao
The result of the division is an int
just used it for this
Inventory inv = Bukkit.createInventory(null, 9 * ((debugMenuList.size() > 0) ? (int)Math.ceil((double) debugMenuList.size() / 9) : 1), ChatColor.GREEN + "ItemControl Debug Menu");
so the debug item list increments its size by itself
when i inject new items into the list xD
!good
lombok attempts to be kotlin in java
is it worth learning kotlin and how does it run on mc
Not having Lombok in your project
That’s the best feature of it pretty much, I’ve had terrible experiences with lombok fyi lol
i would recommend learning it yeah
it’s just java but less boilerplate and more qol really
Kotlin compiles to java virtual machine compatible bytecode
Thus it can run on the jvm
yeah
it seems to be working quite well a getter for me ¯_(ツ)_/¯
tho you need to either shade or define the kotlin std as a lib
Oh yeah ^ that’s a good point
whats the pros/cons from java
@Getter is nice until you realize it’s not
the only thing I really appreciated about lombok was @Delegate
I do appreciate the Builder one but it’s also a bit too much, yeah delegate is fine
what about @hoary knollThrows
yeah, but even that is pretty buggy
Sneaky throws are evil
lmao
I mean it all is pretty buggy
Don’t sneaky throw unless you got seriously good reasons to sneaky throw
✌️
looks like i'll be using a normal getter from now
Is it possible to get a UUID from a online player?
yep
Entity::getUniqueId
player.getUUID()
hmm... my IDE says no this function.
is it possible to add a plugin to a cracked server that doesnt allow cracked players except for a select few user names? so like the whole server is premium but only a few cracked players can join
getUUID does not exist
Yes because it’s named getUniqueId
use getUniqueId like conclure linked
Maybe just don’t use a cracked server 
I mean, would not mean anything ? you can change the username to anything anyway
because, ya know, cracked
I mean I am sure you can code that up
will you get help from a lot of people doing so ?
probably not
alright thank you
what procedure/connection does cracked miss out? just askin
is the UUID got from getUniqueId is a UUID from mojang database?
ok
but that should be a given
Basically no talki talk to mojang
I have to save an object to an mysql db which contains a list of players. What is the best way to do that?
What event get's triggered if a player shots a crossbow?
ProjectileLaunchEvent I believe
ty
that one is for sure, not sure if there is a more specific one
But do you know how I can get the item it was shot from?
does it only contain a list of players?
or does it contain more?
It contains other strings but i can save them easily
can you show what the object layout looks like?
private ArrayList<UUID> players;
private GuildColor color;
private GuildColor tagColor;
private String name;
private String tag;
private UUID head;
private GuildMetadata guildMetadata;
I have a couple things, whats the best way to loop through a list of some sort without having to use list.size() - 1 as the limiter. srcond thing is whats the best way to replace placeholders (not placeholderapi) within my plugin if i have multiple placeholders
get the shooter of the projectile and then get the inventory, from there its easy
yes ik but how can I get the shooter with this event?
Projectile has a getShooter() method
Ok thanks
is there any way to remove the lore content of the bundle? the slots and storage count
what is guildmetadata?
IIRC, no as the item slots are something unaccounted for in the api. You’re more than welcome to try all of the ItemFlags and see if it removes it. However bundles have been untouched for a while.
They were never complete in the first place either.
@patent horizon
create table players (
playerUUID varchar(36) primary key,
playerName varchar(48),
playerhead varchar(255)
);
create table guild (
guildUUID varchar(36) primary key,
playerUUID varchar(36) not null,
guildName varchar(48),
guildTag varchar(4),
guildColor char(10),
guildMeta blob,
constraint fk_guildUUID_playerUUID foreign key (playerUUID) references players(playerUUID)
);
that is how I would create the DB
UUIDs only need a varchar of 36 right? Isn’t 64 just extra?
64 if you include the dashes
or it could be 36 I don't remember
doesn't matter as long as you just make it large enough to hold the UUID 😛
True. I think the UUIDs are 32 chars long and 36 with the dashes.
what is returned if a is true? return a ? "Yes" : "No";?
Yes is returned.
thanks
question for a texture pack, if file which the texture pack linked changes its contents. Do i need to change the SHA1 as well?
yes
Yes. If the pack changes then you will have to rehash.
as for player.setResourcePack(texturepack, hash)
which hash should i be sending?
the new one?
The hash of the pack?
yeah
Take your pack, hash it and use that hash.
thanks
then would this update the server properties as well?
no
No, you would have to update that yourself.
so if i don't update it, everytime they join. it would automatically download it agian even if it was similar
what counts really is just the verification of the hash
if you don't update it, it won't download again
as in i don't update either the resource pack or the sha1
i see, does spigot load server properties into memory? or does it retrieve it from the file everytime it is needed
cause if in memory i need to use spigot api to update it
if you don't update the sha1 in the server.properties or send it to the client, the client will not download the pack again.
sha1 doesn't change for the pack unless you update something in the pack
gotcha
how about this one?
I think it’s loaded into memory.
mh alright, ima look into javadocs then
thanks for replying my barrage of questions!
can't seem to find the java docs for editing the server.properties in spigot
iirc its nms stuff
I have a couple things, whats the best way to loop through a list of some sort without having to use list.size() - 1 as the limiter. srcond thing is whats the best way to replace placeholders (not placeholderapi) within my plugin if i have multiple placeholders
you can't alter the properties via the API
ah i see
then you would have to reload the properties after editing the real file?
yes
aint shapeless recipes working with RecipeChoice.ExactChoice as material?
tried to do it but it worked with any and all
if(e.getMessage().equalsIgnoreCase("//calc") || e.getMessage().equalsIgnoreCase("//calculate")) {
e.setCancelled(true);
}
}``` why does it not work?
do you have a eventhandler annotation and is it registered?
Do u see this message?
?
i added code that sent a message after the event was cancelled and i removed it
it did send
Well comething else is probably uncancelling it
Set the priority to something higher
Like highest or monitor
i wanna store a list of custom enchants (strings) in the persistent data of an item, but it doesn't look like persistendata supports string arrays. what's the next best alternative?
Use mfnalex’s library
im not looking to add a library
is TAG_CONTAINER_ARRAY like a map?
I highly recommend using a library, it contains also itemstack serialization and a bunch of other stuff you should use
But if you don’t, use a normal string and split every entry with a \n character
actually that library doesnt look too bad
How do I generate a completely flat world with a custom floor?
worldcreator?
is there an example
kinda
it's basically a PDC itself
oh hi alex
like a nested PDC 😄
hello :3
how would i shade your lib in gradle
hm I don't really know but I guess you simply set it to "compileOnly" and then run the "shadowJar" goal or however it's called
I never use gradle myself
ah alr
https://stackoverflow.com/questions/34343640/how-to-shade-a-transitive-dependency-in-gradle this seems to be everything you need
anyone ?
here's how oraxen does it: they simply set it to "compileOnly" and add the "relocate" thing to the "shadowJar" thingy: https://github.com/oraxen/Oraxen/blob/master/build.gradle
is there not a plugin jar for your lib?
no it has to be shaded
ah
it's not a standalone plugin
snazzy ;-;
making it a plugin would be annoying, people would have to install it 
yeah I always hate it myself when I download some plugin that "requires eco and vaut and mythiblib and whatever and protocllib and this and that" lol
oh xD
what about the second? do you have ap ersonal preference
String#replace or replaceAll ig
i have most of those things already installed
then i would have to use .replace() like 4 times, but if thast the only way then ok
he said not papi
just do String.replace?
i thought implementation was for shading though
replaceAll is for regex stuff
oh yeah maybe you're right
as said I really have no idea about grade
I use maven all the time
shadow will shade dependencies marked as implementation yea
but you need to define the plugin
as said, just copy the needed parts from oraxen's buid.gradle lol
then simpy replace "CustomBlockData" with "MorePersistentDataTypes" and it shoud work then I guess lol
yikes not using kotlin gradle dsl?
I mean, converting between the two is pretty easy
i need a plugin for shading dont i
IntelliJ even does it if you copy Maven dependency into a build.gradle lol
no
ugh
No, it's stupid lol
gradle cannot do java on its own either
you also define a plugin for it
that is kind of the point
well maven needs a plugin too but after all it's a plugin made by apache themselves lol, not some random github person
I mean I wouln't call them random 😅
he does look like a friendly dude lol
xD but yea the plugin is the absolute industry standard
It's still a bit silly, it's like if Spigot needed a plugin for events.
yeah lol
imve hit roadblock
i got the shadowJar plugin installed, just not sure why shadowJar isnt working
doesn't look like there's anything in oraxen's gradle build that i've missed for it to work
how can i get radius around aplayer
?
what does the error message say?
get radius? whut?
did you add the shadow plugin?
yes
cant
i am creating a algorithm to spawn my special mobs around player so i want to get a radius of 20 blocks around player to spawn them randomly
im working on a server with a few other devs with a bit too much ocd
then simply add a random offset to the location of the player?
RIP
can you paste your whole build.gradle
RIp my intellij became nothing but a black bar
it became a coffee shop
and in the other window, all menus are empty lol
that theme omfg
why doesn't thatcode work?
because you sent none
public static Portal getPortalByLocation(Block b) {
for(Portal p : CreatePortal.validPortals) {
if(p.getBlocks().contains(b)) {
return p;
}
}
return null;
}
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
I haven't finished
When I add the NoAI:1b tag when I summon an entity via command it uses the setNoAI() method?
Or is there any other mechanics?
treat this discord like stackoverflow
no. it simply adds the "NoAI" tag to the entity. No part of Spigot API is involved at all
when I use this code inside an event it doesn't find the Portal object:
thats just a method for the spigot api... minecraft doesnt use the spigot api in game
@EventHandler
public void onGlobalPlayerMove(PlayerMoveEvent e) {
Portal portal = Portal.getPortalByLocation(Objects.requireNonNull(e.getTo()).getBlock());
System.out.println("portalcek");
if(portal == null) return;
System.out.println("passed portal check");
portal.triggerTeleport(e.getPlayer());
}
you should look into nms and code obfuscations if youre interested in those kinds of questions
it basically goes nms -> craftbukkit -> spigot
afk 3 hours, waiting for gradle to download its wrapper
the easier way of doing this is to just define a worldguard region where the portal is
yeh me
ok, so in that case setNoAI method should works the same as noAI tag? I mean i have my custom entity, and summoning it with the tag works, but setting it via method nope.
yes
your build.gradle always throws errors for me in the second line lol
second line?
looks like smth built into kotlin
cus the origin class is called BuiltInPluginIDExtensions.kt
any way to get RecipeChoice.ExactChoice workablefor shapeless recipes?
no
well you can use workarounds like listening to the CraftItemPrepareEvent or however it's called
i guess i can be happy it works for smelting already xD
yeah the crafting API is a bit weird :<
yeah md_5 was probably drunk when he wrote this part
or it's a vanilla limitation, idk lol
How can i get the player from the InventoryMoveItemEvent?
there is no player in that event
i just wonder like why exactly not shapeless xD
InventoryMoveItemEvent is for things like hoppers moving items between themselves
have u ever installed kotlin?
i suppose i can not create anvil recipes xD
sure,. isn't that part of intellij anyway?
yeh
well I didn't update my kotlin plugin but it's definitely installed
ok, so how can i detect if a player get's something from a chest.
InventoryClickEvent and InventoryDragEvent
thanks, works now
why i cant send images
bruh
anyways i cant change versions from any other then 1.12-R0.1-SNAPSHOT it shows me to click the 1.12 but when i try 1.8 it dosent wanna work it just stays red
?verify
?verification
hm
well you need to get verified
then just create an account
bruh
it only takes like 1 minute
guess you gotta use ascii art then
Dependency 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT' not found
did you declare the correct repository?
nvm
why i can set the string into it but i cant get it back?
thanks
?paste
why are PDC values having an extra 'b' letter at the end after loading them from a player file?
Huh???
they don't
they do
but they are not identical
to the directly from memory version
when i get a custom item and logoff logon / compare it to one generated from memory
how are you even reading them? I guess you're using NBTAPI or something instead of PDC?
i use pdc
what's your code to store items?
I thought you were storing a whole itemstack
what no i modify an itemstack like this
yeah anyway, just ?paste your code
public class DiamondDust
{
protected static ItemWrapper item = null;
static
{
ItemStack is = new ItemStack(Material.EMERALD, 1);
ItemMeta meta = is.getItemMeta();
meta.setDisplayName(ChatColor.RESET + "Diamond Dust");
meta.setCustomModelData(2);
is.setItemMeta(meta);
item = new ItemWrapper(is, "diamond_dust");
item.setItemTag("version", "1");
item.setSmithable(Access.FALSE);
}
public static void register(main plugin)
{
DebugMenuCommand.debugMenuList.add(item.getItemStack());
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(plugin, "recipe_diamond_dust"), item.getItemStack());
recipe.shape("AAA", "AAA", "AAA");
recipe.setIngredient('A', new RecipeChoice.ExactChoice(new ItemStack(Material.COAL_BLOCK)));
Bukkit.addRecipe(recipe);
}
public static ItemWrapper getItemWrapper()
{
return item;
}
public static ItemStack getItemStack()
{
return item.getItemStack();
}
}
the itemwrapper is just a QoL wrapper to add pdc values
and read pdc values
If i made a better alternative to a plugin, can i post that my plugin is better than the other plugin?
thats a subjective opinion
So no?
you can post anything on spigot that doesn't violate the rules on that website
so just read the spigotmc rules
Ah ok will do
@tender shard how can it be that one and the same item is no longer identical after login
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
with the one i store in memory
idk, print out both items and check what's different
24.05 19:10:06 [Server] Async Chat Thread - #13/INFO [Admin]TheTimeee: OLD ORB
24.05 19:10:08 [Server] Server thread/INFO Key: version
24.05 19:10:08 [Server] Server thread/INFO Namespace: itemcontrol
24.05 19:10:08 [Server] Server thread/INFO Key: smithable
24.05 19:10:08 [Server] Server thread/INFO Namespace: itemcontrol
24.05 19:10:08 [Server] Server thread/INFO Key: item_type
24.05 19:10:08 [Server] Server thread/INFO Namespace: itemcontrol
24.05 19:10:08 [Server] Server thread/INFO Full Item Meta: UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"light_purple","text":"Everburning Orb"}],"text":""}, lore=[{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"white","text":"Requires Titanium Mantle."}],"text":""}, {"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"white","text":"Can be combined to Burning Blade."}],"text":""}], custom-model-data=10002, PublicBukkitValues={itemcontrol:item_type=everburning_orb, itemcontrol:version=1, itemcontrol:smithable=0b}}
24.05 19:10:15 [Server] Async Chat Thread - #13/INFO [Admin]TheTimeee: NEW ORB
24.05 19:10:20 [Server] Server thread/INFO Key: version
24.05 19:10:20 [Server] Server thread/INFO Namespace: itemcontrol
24.05 19:10:20 [Server] Server thread/INFO Key: smithable
24.05 19:10:20 [Server] Server thread/INFO Namespace: itemcontrol
24.05 19:10:20 [Server] Server thread/INFO Key: item_type
24.05 19:10:20 [Server] Server thread/INFO Namespace: itemcontrol
24.05 19:10:20 [Server] Server thread/INFO Full Item Meta: UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name={"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"light_purple","text":"Everburning Orb"}],"text":""}, lore=[{"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"white","text":"Requires Titanium Mantle."}],"text":""}, {"extra":[{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"color":"white","text":"Can be combined to Burning Blade."}],"text":""}], custom-model-data=10002, PublicBukkitValues={itemcontrol:item_type=everburning_orb, itemcontrol:version=1, itemcontrol:smithable=false}}
not a prob
ive output the whole content to the console
how are you comparing the items
public static void register(main plugin)
{
DebugMenuCommand.debugMenuList.add(item.getItemStack());
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(plugin, "recipe_diamond_dust"), item.getItemStack());
recipe.shape("AAA", "AAA", "AAA");
recipe.setIngredient('A', new RecipeChoice.ExactChoice(new ItemStack(Material.COAL_BLOCK)));
Bukkit.addRecipe(recipe);
}
i dont compare them at runtime
i compare them with the recipe choice
bumping this issue bc it will be a thorn in my side unless i just dont try to support the 3 types im having issues with
wait why does "smitable" say false? what PDC type do you use
its my own wrapper
i can show u
public boolean setSmithable(Access access)
{
switch (access)
{
case TRUE:
this.setItemTag("smithable", "true");
return true;
case FALSE:
this.setItemTag("smithable", "false");
return true;
case SIMILAR:
this.setItemTag("smithable", "similar");
return true;
default:
return false;
}
}
public Access isSmithable()
{
switch (this.getItemTag("smithable"))
{
case "true":
return Access.TRUE;
case "false":
return Access.FALSE;
case "similar":
return Access.SIMILAR;
case "":
return Access.TRUE;
default:
return Access.TRUE;
}
}
IIRC yes
public boolean setItemTag(String key, String value)
{
if (this.is != null)
{
if (this.is.hasItemMeta())
{
ItemMeta meta = this.is.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(main.getPlugin(main.class), key), PersistentDataType.STRING, value);
this.is.setItemMeta(meta);
return true;
}
}
return false;
}
public String getItemTag(String key)
{
if (this.is != null)
{
if (this.is.hasItemMeta())
{
PersistentDataContainer pdc = this.is.getItemMeta().getPersistentDataContainer();
NamespacedKey nKey = new NamespacedKey(main.getPlugin(main.class), key);
if (pdc.has(nKey, PersistentDataType.STRING))
{
return pdc.get(nKey, PersistentDataType.STRING);
}
}
}
return "";
}
you should use a byte instead of a string to store stuff like "true/false"
why
the code to parse NBT tags is a bit weird
i need to store things like the type as string though
to get which custom item it is
you can easily do that but you get in trouble if you want to store "true" or "false" directly as string iirc
still
pain
why do the 2 items differ
I am not sure. better just print out the type and see for yourself. sometimes what I say is just wrong lol
alex could i ask you a thing?
oh now i see it
yeah no i was sysouting it bc i was trying to see why my types were mismatched in the first place
just ask
so ur right that it is turning them into <Object>
@tender shard wtf why does PDC change my values at will?
it doesn't, it's the code that "parses" the stored NBT values
yes I once opened an issue about this on jira
ok ty at least now i know how to fix it
how does your lib for data type work? i understand it serializes to byte but i'll like to make a serialization for my own classes so i'll love if you can tell me how does it work
although this is stupid
so the vanilla serializer when i logoff
is janking my items?
xD
you can simply implement PersistentDataType<T,Z>
if ive got that right
just take a look at my lib for example, e.g. at the ItemStack datatype
it is a spigot flaw with the "true" string becomes a byte issue
a failure in implementation
there is an open issue about it but like
not a lot of people run into it because they just use the proper types
and It also only happens using the spigot yaml thing
which like
using that for item storage is kind of meh anyway
yaml does seem to get a bit... Quirky... afterhours
Yeah i opened a simolar issue half a year ago or sth
That was about it failing when parsing strings that look like json
Yeah spigot should add that too
there is a PR that nearly does that
If i only knew how to properly add pull requests to spigot lol
yeah I don't see problems with "stealing" code when the license allows it, because well that's what the license is for
but you would have to recognise it
which is something I don't think spigot wants ?
like, they would have to include an MIT licence for the changes
paper uses MIT? didnt know that
changed datatypes working now beyond relog-ins ty
some authors just decide to publish under MIT
actually most of the time I give a shit about the license lol
btw i doubt there are "correct" data types in PDC actually
because in the end everything is just a wrapper for String
xD
all fun n games til somebody publishes their code under The Unlicense
yea i mean like u give a byte array but its actually stored as string
same with ints
etc
seems like quite a problem
the api just typecasts the string for u
I mean not enough of a problem for someone to PR a solution apperantly
well like ive said changed datatypes working now
maybe it should Name some Bitches Then
nice
xd
cause the data doesnt get janked no more
NBT also sounds like it comes from transgender term
what
could be exploited though if someone uses it to store player-entered strings 😈
no binary transgender fenderbender
also i need a ticket for the fact that Shapeless recipes dont work with ExactChoices which makes no sense to me
yes, that's probably the only true meaning of NBT
Well an exploit with this would be hard
go to jira and open an issue then
Just a bug
well
i mean lets be honest i can just use a shaped recipe as dummy until the shapeless thing gets fixed eventually
or fix it yourself and submit a PR 😛
Hi! I'm registering my custom entity type with armorstand model. I want now to create all properties that has an armorstand and currently everything works, but nor setSmall. I created all needed dataaccessors and I set it to small like normal armorstand, but doesnt work. Importaint info is that the Mob uses the same dataaccessor (15) and the same bit mask (1) to disable AI, so i overrided the isNoAi mothod that returns always false, but Idk why setsmall doesn't work :/
private static final EntityDataAccessor<Byte> DATA_CLIENT_FLAGS = EntityDataSerializers.BYTE.createAccessor(15);
@Override
public void setSmall(boolean small) { // TODO fix
this.entityData.set(DATA_CLIENT_FLAGS, this.setBit(this.entityData.get(DATA_CLIENT_FLAGS), 1, small));
}``` Other properties uses that dataaccessor (15) too, and works good.
its just less convenient
if you expected a string and instead got a byte/bool, it could cause some issues probably
unless getString sort of just implicitly casts it as well
be me, expect a Byte[], get a fuckin Object[]
well but the plugin author is responsible to simply tell spigot about the correct data type
and then it'll work fine
in actuality i could probably just manually cast the items in the array to byte but
Yea you are not getting a byte you just get nothing
hhhh
So the item won’t work
the only problems I ever encountered is when a YAML is parsed, but that's more like a bug in the YAML<>PDC code and not in PDC itself I guess
mine issue is with normal yaml config stuff not items 😔
Hey I need help because I am getting an error with an example for a dependency I am using for TOML.
The code:
@SuppressWarnings("ResultOfMethodCallIgnored")
public Toml loadConfig() {
if(!getDataFolder().exists()) {
getDataFolder().mkdirs(); // Creating the directory as it may not exist
}
File file = new File(getDataFolder(), "config.toml"); // Assign a variable to the file
if(!file.exists()) {
try {
Files.copy(getResource("config.toml"), file.toPath()); // Copy the file out of our jar into our plugins Data Folder
} catch (IOException ex) {
ex.printStackTrace();
}
}
return new Toml(
new Toml().read(getResource("config.toml"))) // We'll use our internal file as default to prevent errors
.read(file); // Reads the file from the Data Folder of our plugin
}
Error:
Cannot resolve method 'copy(InputStream, Path)'
still cant remember half the time if its called a persistentdatacontainer or a personaldatacontainer
persistent
what java version do you use?
16
or wait, it's part of Files.copy right? then maybe your apache commons is simply too old to support this method
now i know to call it a personaldatacontainer so people will get mad
👀
i like this
every itemstack has it's own personaldatacontainer
honestly i wouldnt doubt that theres an NIO method to do it instead of apache
So what do I do about that?
is there any way i could manually change the time it takes before the fish bubbles appear while fishing
well at least in spigot 1.18 this should work fine
When trying to pass something like the instance of your plugin into another class what's the better practice?
- Creating a private static variable in the main and then making a public static method to get it
- Create an argument in the classes constructor and pass it thru there
Thats what I am using
It should be #2 right?
what's the import you used for the Files class?
some people argue that the second option is better
import com.google.common.io.Files;
other people however say the first option is better because it's easier to use etc
I feel like the dependency injection method is probably the best imo
It's more annoying but I feel like it's better
in the end both are fine and you have to decide for yourself. I wrote a tiny blog post about it and from an "architectural" standpoint I agree that using a constructor to pass it is better, but I don't want to do thiy myself everytime so I simply use a static getInstance() method
Can you link?
one sec
I'd love to read it
it's really nothing interesting, I just wrote it for people who don't know about those two methods anyway yet
so there's nothing you'd be learning from it but I'll send it anyway 😄
😄
?di lol
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
people keep saying "static getters are bad because it violates OOP stuff" and similar things but imho that's bullshit
I mean it's true but there's also nothing wrong in violating rules sometimes because well if doing something differently is easier and doesn't have any disadvantages, then there's no reason to stick to this rule in this specific case
yeah I've seen this before, I was just trying to get mfnalex's opinion
public static void registerUniqueRecipesTempFix(main plugin, String name, ItemStack precursor1, ItemStack precursor2, ItemStack result)
{
ShapedRecipe recipe = new ShapedRecipe(new NamespacedKey(plugin, "recipe_" + name + "_0"), result);
recipe.shape("ABC", "CCC", "CCC");
recipe.setIngredient('A', new RecipeChoice.ExactChoice(precursor1));
recipe.setIngredient('B', new RecipeChoice.ExactChoice(precursor2));
recipe.setIngredient('C', new RecipeChoice.ExactChoice(new ItemStack(Material.AIR)));
Bukkit.addRecipe(recipe);
recipe = new ShapedRecipe(new NamespacedKey(plugin, "recipe_" + name + "_1"), result);
recipe.shape("ABC", "CCC", "CCC");
recipe.setIngredient('A', new RecipeChoice.ExactChoice(precursor2));
recipe.setIngredient('B', new RecipeChoice.ExactChoice(precursor1));
recipe.setIngredient('C', new RecipeChoice.ExactChoice(new ItemStack(Material.AIR)));
Bukkit.addRecipe(recipe);
recipe = new ShapedRecipe(new NamespacedKey(plugin, "recipe_" + name + "_2"), result);
recipe.shape("ABC", "CCC", "CCC");
recipe.setIngredient('A', new RecipeChoice.ExactChoice(precursor1));
recipe.setIngredient('B', new RecipeChoice.ExactChoice(StarDust.getItemStack()));
recipe.setIngredient('C', new RecipeChoice.ExactChoice(new ItemStack(Material.AIR)));
Bukkit.addRecipe(recipe);
recipe = new ShapedRecipe(new NamespacedKey(plugin, "recipe_" + name + "_3"), result);
recipe.shape("ABC", "CCC", "CCC");
recipe.setIngredient('A', new RecipeChoice.ExactChoice(precursor2));
recipe.setIngredient('B', new RecipeChoice.ExactChoice(StarDust.getItemStack()));
recipe.setIngredient('C', new RecipeChoice.ExactChoice(new ItemStack(Material.AIR)));
Bukkit.addRecipe(recipe);
}
```behold my solution to fix the shapeless recipe until md_5 fixes shapeless recipes lol
thats so disgusting
TL;DR my opinion is this
Choose one of the methods mentioned above. If you ask what’s better: in terms of OOP, Method #2 is cleaner. Some people might argue that this doesn’t matter, and that Method #1 is more comfortable. Both statements are true, so choose whatever you like.
Yeah I saw it
FUK conventions, do what makes u happy
for example I started out with passing the instance in the constructor and I got tired of doing this. If I pass it to any class anyway, why not just use a static getter in the first place. The real question should be "why do you even need your main instance everywhere? you shouldn't be needing it in most cases"
I mean
for most spigot plugins going with the DI wont be of any help unless you might scale your project to other platforms
Ig if you start testing, then using DI will help
indeed
I mean, for example to get something from the persistent data container (not what I'm using it for but just an example)
yeah of course. I just wanted to say "if you need your main class instance in EVERY class you wrote, then you're doing something wrong". Of course you SOMETIMES need the main instance sometimes
Yes someone should do a PR to rename it
quick refactor
and breaking about a lot of plugins
"This build of spigot breaks all plugins that wrongly refer to the PersonalDataContainer by the old, wrong name, that was never intended to be used. It doesn't add any functionality beyond this. Have fun everyone updating your plugins"
You're telling me I shouldn't import my main into every class and store it?!
yes lol. if you need your main instance in every other class, you probably have a problem in "thinking in objects"
It was sarcasm
forks Spigot, calls it Spigot-Personal, only change is PersistentDataContainer -> PersonalDataContainer
well you wouldn't believe how many people don't understand why OOP is so awesome and they write huge weird classes every day
I would 100% not use it but I still support this
making fields public make me happy
:)
x(
I'm a TA for my Uni's computer science department. Trust me I know
ye Bukkit.commandMap.get(uuid) would be great
why the heck
I don't understand this error
never seen it before
also everyone pls be happy, I'm using darkmode in intellij again
🙌
i guess if Console calls super()
hm well it doesn't though
dracula > all other themes
darcula*
no problem u heaven
It's not
theres like an identical theme called dracula but the intellij version is called darcula
look in ur preferences
included version is darcula
anyway deep ocean is also quite nice and comfortable to code with
@ancient plank is comfy to code with
ugh
I just installed it and the font is huge
hm weird
github lookin ah
I simply entered that name in the intellij plugins window and used the default thing that it installed
its perfect for me
some languages look good in it
rust
yeah that looks fine
I just googled the "class loading deadlock" warning and it says this:
12
The deadlock can only occur if you have 2 threads and one starts to load User and one starts to load NonRegisteredUser. There are synchronizations in place that will cause a deadlock, but then it requires separate threads. If the loading happens in a single thread, there is no deadlock as the thread owns both locks.
Hence the might in the message. However deadlocks usually do tend to require a specific environment, so there's nothing weird about that.
Guess I'm fine then
also where's my money lebowski?
hmm
give me a few more days ill probably be able to change it again
oki no problem. we all do mistakes from time to time. except for me, everything I do is always correct and 100% perfect etc
this chat xd
Hi! I'm registering my custom entity type with armorstand model. I want now to create all properties that has an armorstand and currently everything works, but nor setSmall. I created all needed dataaccessors and I set it to small like normal armorstand, but doesnt work. Importaint info is that the Mob uses the same dataaccessor (15) and the same bit mask (1) to disable AI, so i overrided the isNoAi mothod that returns always false, but Idk why setsmall doesn't work :/
private static final EntityDataAccessor<Byte> DATA_CLIENT_FLAGS = EntityDataSerializers.BYTE.createAccessor(15);
@Override
public void setSmall(boolean small) { // TODO fix
this.entityData.set(DATA_CLIENT_FLAGS, this.setBit(this.entityData.get(DATA_CLIENT_FLAGS), 1, small));
}``` Other properties uses that dataaccessor (15) too, and works good.
ASM is BSD-3-clause?! damn..
i once installed this whole thing aaaaa
MIT is pretty pogchamp but recently ive been gravitating towards Apache-2.0
hello everyone
in VSCode how to show the description of a method?
i sow somebody get the description of the methods if he hover to a method like getName() but in my VSCode it's just giving me the Import Path.
make sure u have the Java extension pack downloaded and/or read the docs instead
not using vsc would be a good start
?jd-s
How to create an npc protocollib?
Vsc is fine
If you use the jqva extension pack otherwise its no better than a notepad
Provides as many features as you need
mwoaa
help
im using BukkitObjectOutputStream and BukkitObjectInputStream
the EOFException
like
it deserializes the location
but it cant deserilize the string
here is me creating the streams
this is executed right after the creation of the inputstream
and it works fine
and next, a location is deserialized and also works
but the next string doesnt
?paste
yeah eof is usually when you read the wrong thing
out.writeUTF(infos.get(0).getWorld());
for (BlockDataInfo info : infos) {
out.writeObject(info.location());
out.writeUTF(info.data().getAsString());
}
here
write an int that tells the length of infos
and then read that int where you loop that many times
the writing works fine
Why the heck the shity mongo doesnt detect enum types?
nah thats not the issue
and the first string (infos.get(0).getWorld()) and the first location works fine too
the issue is that the format is inconsistent
String 1 - the world name
Location 1 - first location
String 2 - first string referent to the first location <--- error here```
Why you still using PMC when you have redis or ws?
//write
writeInt(infos.size())
for (var info : infos) {
writeObject(info)
}
//read
var size = readInt(info.size())
for (int i = 0; i < size; i++) {
info.add(readObject())
}
basically
i will try that
talking to the proxy
why are you reading it as UTF?
because it is a string
Hey so for some reason I cannot build my project with Maven because its saying that a dependency I am using doesn't exist or something.
Dependency section of my pom.xml
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.moandjiezana.toml</groupId>
<artifactId>toml4j</artifactId>
<version>0.7.2</version>
<scope>shade</scope>
</dependency>
</dependencies>
Error:
package com.moandjiezana.toml does not exist
just means that package don't exist maybe you aren't importing the repo 
or your have the dependency set up wrong
only real 2 issues you could have
Well it was working and stuff in my code because it auto suggested importing classes and what not
How are you packaging the jar
^ oh true thats important
Is there a delay for using OfflinePlayer? Just wondering as I'm creating player skulls and I don't want lagging while opening an inventory
checked docs but there wasn't really explanation ont here
if you use UUIDs, definitely no. Getting them by name opens a blocking web request IIRC
^^
ok thanks I only need to use UUIDs anyways
player name cringe 
then you're fine. I do it like that too and at least noone ever complained lol
player skulls are a pain
why blocking, if https are suppoused to be done async...
I'm shooting myself in the leg here
erm well because that's how it works. If you do stuff like "OfflinePlayer player = new OfflinePlayer("mfnalex")" then obviously you need this player NOW
Sorry but i dont really know much about spigot
so the plugin author themselves would have to make this run async
^
I thought they have all offline uuid pre-catched
So then you dont have troubles with blocking
what if you want a player thats never joined your server
you can ALWAYS create an offline player object by UUID with no delay but as said, if you get them by name, the server has to check "to what UUID does this name belong"
?
uhm
I think you misunderstood something
thats just not true verano
I was told every http request = async, so then you dont block the main thread
^
not how it's automatically done
for example ikevoodo's plugin did update checks every 5 minutes, blocking the main thread for like half a year lol
Atleast that what does okiHttp
most of the time you would want to request HTTP info on a different thread
so you don't block your main program
That what i said
😂
Isnt the same
you can do this with offline player idk what your even asking at this point
yeah but one has to care about that oneself. it's not like creating a HttpUrlConnection and then using it will automatically make everything async on its own. that's what I tried to say :3
http requests has no inherent notion of asynchronous dispatching
also OkHttp is weird
thats up to the developer
Sorry for being annoying, but why the heck http url connection?
You have better things!!!!
Http url connection its like comparing a ferrari with a fitito
which ones?
I always use HttpUrlConnections, there's nothing wrong with using them
Also with my friends we are experimenting shity problems, because we use custom reponse code
of course you have an object, which is the HttpUrlConnection
So while he send a code not provided by default, the f**d exceptions its trown
I explain wrong, you dont have any http response, request, etc
What do you think mfalex?
of course you have. it returns an InputStreamReader
And sorry for being really ass pain
this is how I do HTTP requests, never had any problems https://github.com/JEFF-Media-GbR/Spigot-UpdateChecker/blob/2971114ada3db91071a4f03ed9d656c0750b538c/src/main/java/com/jeff_media/updatechecker/UpdateChecker.java#L266
Yeah its the oddy way, luckperms doesnt use that
public class PlayerJoinListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent Event){
System.out.println("plr join");
Player P = Event.getPlayer();
Inventory Inv = P.getInventory();
ItemStack Settings = new ItemStack(Material.COMPARATOR,1);
ItemMeta SettingsMeta = Settings.getItemMeta();
SettingsMeta.setDisplayName(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Settings");
ArrayList<String> lore = new ArrayList<String>();
Settings.setItemMeta(SettingsMeta);
Inv.setItem(9, (ItemStack) SettingsMeta);
}
}
i'm trying to give a player an item when they join but it isn't working can anyone help me
?isnt-working
?not-working
does it print "plr join" when a palyer joins?
it's ?notworking
no
Hi! I'm registering my custom entity type with armorstand model. I want now to create all properties that has an armorstand and currently everything works, but nor setSmall. I created all needed dataaccessors and I set it to small like normal armorstand, but doesnt work. Importaint info is that the Mob uses the same dataaccessor (15) and the same bit mask (1) to disable AI, so i overrided the isNoAi mothod that returns always false, but Idk why setsmall doesn't work :/
private static final EntityDataAccessor<Byte> DATA_CLIENT_FLAGS = EntityDataSerializers.BYTE.createAccessor(15);
@Override
public void setSmall(boolean small) { // TODO fix
this.entityData.set(DATA_CLIENT_FLAGS, this.setBit(this.entityData.get(DATA_CLIENT_FLAGS), 1, small));
}``` Other properties uses that dataaccessor (15) too, and works good.
Maybe you didnt register the listener
did you actually register your event listener?
public final class CallousPvP extends JavaPlugin {
@Override
public void onEnable() {
getServer().broadcastMessage("callous pvp started");
getServer().getPluginManager().registerEvents(new PlayerJoinListener(), this);
}
}
did you check whether that line appears in the console? I'm not talking about the ingame chat
I suggest to open a forums post, I doubt that many people can you help you with this here
it might be a pebble thing but i don't see anything plugin related in the console
cuz im using pebble host for the server
is your plugin loading properly
does your plugin appear when you do /plugins ?
yes
in green?
yes
then I guess you're not using the proper .jar or something because the code should at least always print "plr joined" when some joins if you don't get any errors
you can add tags to entities or sth like that
do i use the snapshot jar or the original jar
whichever one is newer I guess lol
yes you can use Entity#addScoreboardTag("somestring") and then check in EntityDamageByEntityEvent if the damager has this tag, and if yes, cancel the event
oh wait
a better way would be to use Entity#setMetadata
then you don't need scoreboard tags
that's what I actually meant
how do I make it so parameter names stick when I deploy my API with maven
wait nvm I'ma just look this up
lmfao
they should do that automatically
odd they aren't for some reason i'm getting arg0 arg1 etc
hm then show your pom
Obviously it doesn't work, you're giving an itemmeta, not an itemstack
And you cast your itemmeta as an itemstack for no reason
?paste
it doesn't even print the sout message though so the problem seems to before that
no it isn't
pebblehost is stupid
i think AyUniz is right
that looks fine to me. maybe I was wrong on the "it works automatically" and you need to upload the sources .jar too
google "maven attach deploy sources" or sth
yea idk why i didn't just look it up lol
although tbh I thought that parameter names will be kept even without attaching sources
attaching sources unfortunately is very tedious if you have a multiple-module pom
why the hell any java http library support custom reponse codes?
but you don't use modules so just attach the sources and then you're fine
they all support that
the response code is just an int
why would any library NOT support it
i use custom response codes all the time
I dont know
Its explote
Explote in the way of causing an exception
And we endup with the cause of it where the custom reponse codes
I suggest to simply use a HttpUrlConnection and catch the IOException that it might throw
it worked
That what we do
But its really harcoded
And we dont like harcoding with my friend
Bu t in fact thanks
hardcode what?
Stupid question but PlayerHeads have skull meta correct?
in the inventory, yes. in the world, no
do you know of anyway to set the player head to something independent of a skin a player has. I have a method, but either I'm misunderstanding how it works or it nolonger works
I always use this to, for example, let players use custom base64 textures for "in-world" skulls. It's a bit outdated (because meanwhile we have the PlayerProfile class or sth like that) but still works fine on everything that's 1.13+: https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/SkullUtils.java
PlayerProfile was added in 1.18.2 or 1.18.1 and it's basically just a wrapper for the NMS "GameProfile" class
so actually using a PlayerProfile does the same thing
e.g. check out line 48. you have to create a new GameProfile with a random UUID, then you can set it's textures field to some base64 value and then just use the Skull class to set the owning player
?paste
oh you use URLs directly
idk I just found it tbh
I wouldn't do that. for example on mcskins or what's it called, you can simply copy paste the base64 directly
I was looking for something that used skin urls but this won't work
one second I'll send a link
scroll down to the second lowest field ("value")
its just a base64 string that translates directly to the json string that contains the url
{"textures":{"SKIN":{"url":"http://textures.minecraft.net/texture/7f21052d18a1ed6e7073384830e7b285310a7dc0a80b36431db654d3e3dae8d0"}}}
you can directly use this base64 encoded string in a new GameProfile
and yeah that's how I always do it. since admins are used to use base64 strings for textures anyway
so ive currently got his code but it doesnt cancel the task and just continues on
Heres the Event class : https://paste.helpch.at/awodorupof.java
Command Class: https://paste.helpch.at/ikugomehex.java
Is it common practice to make my spigot plugin have a bungee counterpart to talk to other servers?
depends on the kind of plugin I guess
most plugins don't need anything like that
It's one that'll allow chatting across servers but it also has some gui stuff
I also need to knownif the player received the message
well if it's a "cross-server-chat" then obviously you want to create a bungee plugin lol
So i guess this is a valid usecase to have both a spigot and bungee plugin?
just use the plugin message channel to send messages to the other servers
yeah
you definitely need a spigot plugin for the gui and stuff
the chat itself could easily be bungee-only
unless you also want to allow it to run on normal spigot servers
Yep i do
btw you can create a .jar file that runs on both spigot and bungee. simply create a plugin.yml that has points to your spigot main class and also a bungee.yml that points to your bungee main class. then you can use the same .jar on both spigot and bungee
Ik
oh ok
Bungee.yml and plugin.yml
Haha thanks tho
thank you I got it working :)
also you should probably decide whether you want to use stuff like redis or if you only rely on spigot plugin messaging. if you go the plugin messaging way than you can always only send messages to servers who have any online players, which might be bad if you also want console to be able to read the chat messages, even if noone is online on tha tserver
Nah it's a chat plugin in this case so empty servers don't matyer
Well not solely chat but idc abt empty servers
well as said, sometimes admins read the chat from console. but I probably wouldn't care about that too lol
after all the admin could still just open the bungee console instead
np :3

Who would be chatting on an empty server?
no that's not what I meant
imagine you have lobby, survival and skyblock
Ye
the admin looks at the skyblock console while noone is online there
now someone chats on the survival server, which normally would be broadcasted to the skyblock server too
but the admin who only looks at the skyblock console cannot see the message now
that's what I meant
Creating logs as well
yes
?pdc
What exactly you mean by metadata?
no
only have entities have "metadata"
pdc is similar to metadata
and even better
but ItemStacks do NOT have metadata
no idea
nah
that versions is like 100 years old
you have to use NBT tags on 1.12
why are you using 1.12 since you have no pvp gripe with it
either with NMS or use a library like NBTAPI
If I was you, I'd first think about why I do 1.12 plugins in 2022 and then after that I'd just use NBTAPI
1.12
atleast with 1.8 they can argue something but 1.12 I don't get
many servers stopped upgrading after 1.12 because 1.13 broke so many old plugins
1.13 have some major nms changes?
1.13 got rid of all the numeric item IDs
Has major api changes as well
ohhh yea

