#help-development
1 messages · Page 1401 of 1
Nah you can do that
there are many ways of doing tab completions
kk
You just won't have the start of an argument, so you just show all options
with the way how the args array is populated I don't see how that's possible to do
can i send my code here
Or like
you can't discriminate between "writing arg 0" and "finished writing arg 0"
because it ignores spaces
Hello, I want to create an invisible armor stand but it seem that setVisible(false) method doesn't work. Do you know if that is a bug plz ? I'm using spigot 1.16.5
but is it?
?paste
enable or disable
it might be different for the tab executor, but the command executor doesn't have empty strings "" popping up in the args i don't think
/kill -> args = []
/kill_ -> args = []
/kill_n -> args = ["n"]
/kill_n_ -> args = ["n"]
/kill_n_i -> args = ["n","i"]
iirc it goes like this, could be wrong though
i am pretty sure it is populated with something, as my conditional for args.length == 1 is satisfied when just typing /q
Yeah same with the code I showed
args[] is String array not char
but the code i sent u doesnt work with autocompleting just by not giving the first letter of args[1]
it only autocompletes if i do /fm (letter)
version?
1.16.5
is it legal to upload a resource that is not strictly yours (i.e. a dead plugin that you decompiled, fixed and updated)?
not quite sure.. this works just fine for me (no letters given)
depends on the license
can you show me the code you used
you would have to see the license of the original plugin
It depends on if its really dead and the source licensing
unless they've licensed it under "do whatever the fuck you want" or similar, you can't modify and upload it even if the author is dead
that said
nobody will care
and you will be doing the world a service
MIT hopefully
just do it anonymously
Not updated in 6 months is not necessarily dead.
not updated since 2017 and it has no licensing
No licencing means, no you can;t modify and upload it
Defaults to ARR iirc
so only modify and use it personally?
Yes
not even that really
Nah you can use anything for personal use
@unreal quartz can you show me the code you used for your autocomplete?
Licenses get involved for when its commercial use or distributed
Only in teh form its released in. Not modify
elgar by the way
But i must say that im not giving legal advice
where did that ico5 for towny go
hang on a second
it used to be on the palmergames homepage
but somebody has put it through a redesign
kk, thx
and now I can't find shit on it
Its on github now
legacy sounds scary
It just had some Towny specific bits added while I was gone. When I came back I updated it to run stand alone again.
so i've been tinkering around with the multithreading and i think about arrays.
Imagine i read primitive array index in first thread and set index of array from another. I don't care if its visible to the other thread or not, but im thinking about if the second thread would pass the new value from index from the cache to RAM. How long does cache hold the value? Is there a probability that cache wouldnt pass the set value to the future threads?
"good luck" basically
using the normal TabExecutor, this works just fine
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (args.length == 1) {
return Arrays.asList("never", "gonna", "give", "you", "up");
}
}
what is your version?
mkay
Hi guys, I would like start using brigadier but I don't know what should I use as command source. Any suggesstions?
interesting
If so, how can Bukkit.getOnlinePlayers() be safe to read async, when its not volatile field, and can update anytime when the player leaves?
commodore is a great start
its not really safe
basically this ^^
it work 🙂 thx
well its not like commodore substitutes brigadier or vice versa empee
the worst that's going to happen is just that the data is out of date
@unreal quartz yeah i got it fixed I watched a tutorial from 2014 before and added a dumb if statement
is it really a thing? 😆
which makes people think it's safe
to check if args[0] is not equal to ""
because it doesn't explode
Commodore is a wrapper around brigadier
its mapped brigadier from NMS
Thanks!
commodore complements brig
ah wow
commodore is nice
sick names
Don't do that. just provide the options for that arg. You don;t do the narrowing down, The client does that as you type
what dovidas, I mean what does it lack of
Thanks everyone
gotchu
brigadier gives me pimples
I don't believe the client does that on its own
Hence StringUtils.copyPartialMatches
what is the default chatbox width in pixels
i've changed mine to something and i don't want to reset to defaults to figure out
type support if i remember correctly. It has primitive types, but as always if you're gonna use such a library, you wanna remove boilerplate of yours
some thread on hypickle says 320 pixels
yea, but i don't see any support for typed colors
atleast i've never saw how to implement it
I just use normal color codes and it works fine
im trying to make a /spawn thing, but i want to wait 5 seconds but i dont want to block the plugin from working while those 5 seconds pass, how would i do this?
rreeeee why is it a fucking slider
Scheduler
have you tried asking politely
it looks to be going by increments of 4
oof
It works fine, but it needs some polishing to be used, at least for me. It could be the best command api if it would implement more utility classes. Its lightweight
i made my gui scale huge
i can barely see the buttons
managed to set it now
sliders are cancer
well in some cases lightweightness is good
but eh
i prefer more than less
its a preference
In all fairness it's not really like a command api, I see it as just adding those messages above chat when typing commands
yup total agreement
PR
like they have ability to do, its not that hard to implement, even license for brigadier have been changed
yeah yeah fr
dev has no licensing, hasnt been active on the forums since 2020 and also after finding their disc they havent posted since 2019
f
republish it and license it under a fake name
then use that with your real name/real identity
if it leads to legal action the fake sockpuppet goes in jail but you'll be fine
Would you even get jail time
not really, nobody cares anyway, and nobody is going to pursue legal action either
unless you become big like hypickle and somebody does craftbukkits to you
ik null.equals() doesnt work but equals(null) will not throw an exception or yes?
why even ask that
Just do == null
^
a.equals(null) will never return true
Faction playerFac = plugin.getData().getFaction(player);
for(Faction f : plugin.getData().getFactions()){
if(f.hasClaim()){
if(f.getClaim().containsLocation(event)){
if(f.equals(playerFac)) return true;
return false;
}
}
}
return true;
}
Objects.equals(null,null) might work
playerFac may be null
f.equals(playerFac)
ok ty
im trying to make a /spawn thing, but i want to wait 5 seconds but i dont want to block the plugin from working while those 5 seconds pass, how would i do this?
Runnable
or bukkitrunnable
or if you're a gigachad, an async thread that sleeps for 5 seconds
alt forums account? I thought that was against the rules and gets them both deleted lol
lmao says the alt king himself
When I say runnable I usually mean bukkit runnable
that's the whole reason you're making an alt
how many alts do you have now NNYa?
large IQ moment
discord apparently does some fancy alt detection shit, will have to muster the effort to get disposable phone numbers to verify those 2 at some point
can i check if a runnable is equal to null aka is not currently running
I had no issues with getting alt disc accounts. it doesnt like things such as minutemail but legit gmails work
talking about bukkitrunnable
that's not how anything works
yeah the detection is pretty difficult to trip, you need to be really blatant
which message was for me?
but a few days ago when I was cycling through like 8 accounts in the span of 20ish seconds, the two last ones got locked
oof
but yeah, you need to be really blatant about it
hmmm 8 accounts on the same IP
does anyone know how to remove an entity if an entity is spawnning
entity.remove
Hello, setVisible work on armor stand on 1.16.5 version please ?
did you try it
Yes, my armor stand is created
?paste
are you sure you're calling ArmorStand::setVisible and not LivingEntity::setInvisible
show
yep, i've cast my entity
and i call setVisibile
His base plate is disable
he got a custom name
but it still visible
:>
show update name
I've try to call setVisible each time when i'm using teleport on the armor stand, but it's doesn't work
Do you have any idea ? :p @glass sparrow
spawn it invisible
consoooomer
must CONSOOOOM
can't reproduce with either a consumer setup or the used setup
yea i got no idea i cant reproduce
what are you, an eunuch
what the fuck
a rather public revelation
NO
It OK. We won't judge
i can reproduce guys i swear
we'll see about that
uh oh
is there a way to check whether or not a horse has a lead on it or not
the javadoc search box is a handy tool
i didnt think it would be under isLeashed i was looking for soemthing with 'lead' my bad
but ty ❤️
i'm recreating clientside inventory actions inside serverside
it works
but im using async netty channel handler
and im worried that by setting items in async
would break the server
i set the items via main thread using NMS dedicated server object .executeSync() method
it works
How can i do this plz ?
but now im thinking about iterating the items in async
mmm
world.spawn(location, ArmorStand.class, a -> {
a.setVisible(false);
});
and it seems there's no guarantees that the thread cache would flush
the callback method allows you to mutate the entity before it is added to the world afaik
I linked the spawn method you need to use. Either use aConsumer or Lambda
since list is not atomic
does FileConfiguration#set override configuration?
Lynx got you
heck even Bukkit.getOnlinePlayers() is not technically safe
just ignore potential data races and go for it
Ok i'm a fucking retard, I'm really sorry for the stupid question. I'm using setVisible(true) on other method of my code
99% of the API is not safe. Most reads will be ok but no guarantees
🤡
Thanks all for your help and sorry :p
well that would work for iteration but still there's no guarantees that the thread cache would flush
guys, i am trying to store inventories into the config, tho when setting up the "isOnline" it destroys the inventory https://paste.md-5.net/koyokiyilu.java like it removes it from the config, if i remove the 2 instructions (set and save) contents do not disappear, how can i fix this?
Why are you bothering to flag as online or offline?
using bukkit config api to save player data 👀
Bukkit#getPlayerExact does the same
just check if there is a player currently online 😂
not like this is cross server
In Java, threads doesn't cache any object or variable, they just have a reference to an instance of an object. does this mean if i access arraylist from another thread it stores the arraylist reference or the whole primitive array reference with it
java doesn't cache anything no
if it stores only the list reference that's why its updating it
so JVM only give opportunity for CPU to store reference to the object from another thread
threads operate on memory
memory may be locally cached by the processor
two threads may run on two different processors which may have cached different values for what the threads consider to be the same memory
and what if the cache is never flushed or flushed very slowly
doesn't that make the code unsafe?
unless there are memory barriers or the like that ensure that you're not operating on stale data, yes
locks, synchronization and whatnot are ways to make this happen
as for how they make it happen, it depends
if you ask someone to explain what locks and synchronization does under the hood, the best you will get is an overly simplified explanation of there being a cache and stuff being read past that cache from the main memory
which is not what really happens
what really happens is an impl detail that changes from processor to processor
what are your suggesting if i cant edit the code NMS or replace the list with atomic one
i'm not sure
synchronisation is also not an option
since those lists are used both by NMS and internally by bukkit
what is this list
ArrayList
List of NMS ItemStacks
of an inventory?
i vaguely remember someone saying that inventories themselves are thread safe to some extent
not sure if they were talking about bukkit inventories or the underlying nms ones
🤔
eh fuck it
im gonna sync
setting of the items
but leave iteration
in async
There should be only the small chance
idk..
why are you iterating anyway
are you like trying to figure out where shift clicked stacks are getting sent
yes actually
Is this an inventory you create yourself or some game inventory?
i don't think so
pretty sure the client and the server just compute it both without telling one another what the result is
NNYa you're missing the shit storm in #general
it seems server handles the placement due to security measures
general doesn't exist
i guess i could take a look
i knew redempt was an anarcho libcuck
because there's no data between client and server regarding clicked slots apart from dragging "paint" mode
that's why its threadsafe
it uses copyonwritearraylist
inside NMS
Bukkit.getServer().getOnlinePlayers() is totally thread safe.
Nice to know
Hey
Does anybody know
Why some particles act very weird
example end rod particles
when you spawn them with code, they get thrusted around like explosion
And could I fix that some how?
particles have offsets
check your offset values
you need to specify the velocity properly
yea i've saw it
how can i do that?
what
its basically cauldron
oh
but on fabric
god
lmao people are gonna run out of names one day
its a fabric mod that loads bukkit plugins
just particle.setvelocity?
maybe
i mean, cool, but eh
particles are kind of fucked
theres no method for that
working with them is cancer and I never remember which button does what
it doesn't help that the param names aren't specified in the api either
need to always look them up from the fucking javadocs
How can i check those
when you spawn particles
particle api is awful to work with
i don't think it's entirely bukkit's fault
pretty sure it's like a protocol limitation from mojang why they're so trash
but i think someone should eventually write a decent wrapper api for them
because god
what about effectlib
i've saw this lib thrown around quite alot
for particle effects
never heard or used it
dovidas how can I specify them tho?
Is it something like
dustoptions?
where I spawn the particle and fill extra params
oh yeah
my bad
i've just realised
how fucked up api really is
Options which can be applied to redstone dust particles
~ DustOptions
Redstone (dust)
iirc
#World.spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ)
you need to spawn particles 1 at a time if you want to set the velocity manually? i think
the first 3 doubles are the place where it's spawned
the int is the number of particles to spawn
if count is 1, the last 3 doubles specify the velocity
whats the best offset x y z
why is particle isn't class type
if count is > 1, the particles spawn randomly in a box specified by the last 3 doubles
iirc that's how it works
set the last 3 doubles to 0.0
the issue is the underlying mojang shit impl of it
they don't actually have specific parameters for stuff like velocity and offset
they reuse the same parameters
Bukkit.getWorld(worldName).spawnParticle(particle, location, 1, 0.0, 0.0, 0.0);
what is offset in one context is velocity in another
and the api builds off of that so the api is shit too
Should I do stand.getEntityId() == head.getEntityId() or stand.equals(head)? Which is better/faster?
Both are ArmorStand's
what
it depends how entityid is implemented
both are implementable methods by the class
there's no way you can tell which is faster by not digging in to the code
hm
i don't remember if the bukkit entities implement equals properly
i know == won't work here because both are bukkit wrappers
get the UUID of both entities and .equals
isn't entityid primitive data type?
it would, I meant == on the entities themselves
that said I really don't like the entity id concept at all so I just kind of refuse to touch that value
it'd probably work
try booting up jdgui
or intellij
and decompile the class
to see which gets the type faster
doesn't matter anyway
are entity id's unique?
you won't be doing it so often as for it to actually make any difference
yes
per world per entity type?
but there are only 2^31 of them
ok whats the different between it and the UUID?
so it's possible that there might be some collisions
the entity id is only valid for the lifetime of that entity object
the next time it's loaded in, it will have a different id
UUID is univerally unique
and will always be the same
server would die with more than 2^31 lolol
entityid is unique since its probably integer counter just like container ids are calculated
with 2^31 loaded at the same time yes
Oh true
but servers have literally thousands of mobs instantiated per second constantly
Okay good to know, I'll use the former comparison
so it's entirely possible that the counter will overrun eventually
which is why I don't like it
granted the whole fucking server will explode if that happens
open 2^31 unique chests at the same time
but that doesn't mean I like it
and the server will crash due to integer overflow and enormous chunk lag
Does anyonw know how to cancel the entity spawn event
event.setCancelled(true)
what
i want to canel the event if the entity is an villiager
have you added @EventHandler annotation to it?
yes
is it getting called
have you tried debugging it by sending messages to yourself or the console
its working almost there are so many villagers
what
after i start my server but i want to spawn just one
👀
- I want to spawn a villager after that im checking if the type of the entity is a villager if it is true i want to cancel it
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() == EntityType.VILLAGER) {
event.setCancelled(true);
event.getLocation().spawnEntity(//bla bla i dont remember look at javdocs);
}
}
this is all i can offer to you
this is the highest iq server
Excuse me, when I teleport an Entity with teleport method, I need to relog on the serveur to see the new location of the entity. Do you know why plz ?
is it riding something
server and client sync issues i guess
have you tried entering new dimension inside the server
that's what I thought, there is no way out nms to fix that ?
and going back
no
Ok
yes it's working
F3 something
the problem is that i want to just the villager one time
is the awnser
World world = Bukkit.getServer().getWorld("world");
Location finalEntityLocation = new Location(world, 66 + .1111111f, 66, -125);
Entity newEntity = world.spawnEntity(finalEntityLocation, EntityType.VILLAGER);
newEntity.setCustomName("TEST");
entitySpawnEvent.setCancelled(true);
It's possible to fix automatically that (and not reload player loaded chunk ?)
that's literally what i've made
oh
nvm
put this inside the main method
and implement the listener
which cancels
.
the villager type spawning
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() == EntityType.VILLAGER) {
event.setCancelled(true);
}
}
see my code
@Override
public void onEnable() {
World world = Bukkit.getServer().getWorld("world");
Location entityLoc = new Location(world, 66 + .1111111f, 66, -125);
Entity newEntity = world.spawnEntity(entityLoc, EntityType.VILLAGER);
newEntity.setCustomName("TEST");
}
this would ensure that villager spawns everytime the plugin starts
although you need to kill it
if you would reload this with plugin manager
i need it on entityspawn
and above the code for handling villager spawns
why
you said it you need it when server starts
place 1 villager
i want to make an randomizespawn plugin
good luck
Not to be rude or anything, but if there's plugin that's suitable for you why not use it
instead of making bootleg version of it
to have the fun of fixing bugs
if this is your first plugin, try doing something simpler instead
no it is not my first plugin
coding is more fun than games and that’s a fact
link the entire class in a pastebin or something
yea ^^
and describe thoroughly and verbosely what is going wrong
don't monkey slam the keyboard
its hard for people who are from foreign countries to speak english here
i do understand it
but
im a foreigner myself
most people are
working with complicated chat based layouts is cancer
having to left justify 20 million fucking elements per row is cancer
i'm writing a chat based interface for a stonk market
i want it to be nice and tidy and have columns for shit like price and quantity and total offer and the seller/buyer name
and i also want it to be adjustable for different chat widths
so literally everything needs to stretch and contract and squeeze and bounce
u use git or smtng? or do u just code w/o vc
i use git when i feel like it
yeah github or smtng else?
usually not because the intellij integration for git keeps spamming git subprocesses every 0.5 milliseconds if the project is imported into git
and it taxes my system resources
oh yeah you cant disable that?
fair enough, anyways whats ur name on gh? the same as discord or confidential?
do i look like a guy who uses a single account
good point, I mean like a main account rather
i have a couple of accounts for paper and one for an org for my serbur
i don't have any public projects on any of them though
i think i have an untouched slimefun fork on one of them
ah well lets call it a day then
i might write an optimization guide or something eventually
that'll probably be on github
so at least you have something to look forward to
lmk when ur finish 😮
Someone should make a skin farm API (like mineskin)
using education edition teacher accounts
they allow java edition to render 4K resolution skins
with full transparency support
someone made some sort of a plugin for it but I think you still had to upload the skins manually
yea there's transparent heads plugin
but its not for skins like SkinsRestorer
well
some python magic with selenium or magicsoup libraries would do for this
is it possible to raytrace through entities but not blocks
brilliant
any way to cancel bow being drawn back? setCooldown works, but about 80% of the time
can some help with some code help
maybe
e.getPlayer().getWorld().spawnEntity(l, EntityType.PRIMED_TNT); for some reason the 1 is a error
what is the error
i'm trying to spawn 1 PRIMED_TNT but it's not working
what is the error
so I have an item called the midas ingot, and I want to incorporate that into the recipe for my custom midas sword item, how do I do that?
create a recipe with an ExactChoice
ayyy skyblock player
ExactChoice takes an ItemStack rather than just a Material
make a hyp that crashes a server
what?
nvm
1 cannot be resolved to a variable
you have no 1 in the code you posted
it doesn't want a number
it wants the location
you aren't spawning 1 PRIMED_TNT
you are spawning a PRIMED_TNT at l
L
how do I use exact choice? I cant find a good article
new RecipeChoice.ExactChoice() or something, I don't quite remember
new RecipeChoice.ExactChoice(ItemStack)
yes
k
gonna test it real quick
theres an error, something about null itemstack
heres my code
ItemStack material = new ItemStack(ItemManager.midas_ingot);
ItemStack item = new ItemStack(Material.GOLDEN_SWORD, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Midas Blade");
List<String> lore = new ArrayList<>();
lore.add("§6this blade originally belonged to");
lore.add("§6king Midas and can turn mobs to gold");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK,1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
midas_blade = item;
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("midas_blade"), item);
sr.shape(" G ", " G ", " S ");
sr.setIngredient('G', new RecipeChoice.ExactChoice(material));
sr.setIngredient('S', Material.STICK);
Bukkit.getServer().addRecipe(sr);
}```
paste the actual error
hold on lemme get it again
the error is always the most useful part of an issue
it shows what happened, where, and usually why
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122) ~[patched_1.16.5.jar:git-Paper-580]
at org.bukkit.inventory.RecipeChoice$ExactChoice.<init>(RecipeChoice.java:171) ~[patched_1.16.5.jar:git-Paper-580]
at org.bukkit.inventory.RecipeChoice$ExactChoice.<init>(RecipeChoice.java:160) ~[patched_1.16.5.jar:git-Paper-580]
at com.profmonkey07.moreswords.items.ItemManager.createMidas_Blade(ItemManager.java:60) ~[?:?]
at com.profmonkey07.moreswords.items.ItemManager.init(ItemManager.java:27) ~[?:?]
at com.profmonkey07.moreswords.MoreSwords.onEnable(MoreSwords.java:14) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-580]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-580]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-580]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-580]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-580]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:580) ~[patched_1.16.5.jar:git-Paper-580]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:280) ~[patched_1.16.5.jar:git-Paper-580]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1055) ~[patched_1.16.5.jar:git-Paper-580]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-580]
at java.lang.Thread.run(Thread.java:834) [?:?]
[16:03:50 INFO]: [MoreSwords] Disabling MoreSwords v1.0
what is on line 60 of the code you pasted
sr.setIngredient('G', new RecipeChoice.ExactChoice(midas_ingot));
are you sure midas_ingot is not null
it kinda looks null
but the itemstack is outside the void
the variable looks like it's null
private static void createMidas_Blade(){
ItemStack item = new ItemStack(Material.GOLDEN_SWORD, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Midas Blade");
List<String> lore = new ArrayList<>();
lore.add("§6this blade originally belonged to");
lore.add("§6king Midas and can turn mobs to gold");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK,1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
midas_blade = item;
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("midas_blade"), item);
sr.shape(" G ", " G ", " S ");
sr.setIngredient('G', new RecipeChoice.ExactChoice(midas_ingot));
sr.setIngredient('S', Material.STICK);
Bukkit.getServer().addRecipe(sr);
}
public static ItemStack wither_sword;
public static ItemStack midas_blade;
public static ItemStack ice_sword;
public static ItemStack obsidian_sword;
public static ItemStack lifesteal_sword;
public static ItemStack midas_ingot;
public static void init(){
createWither_Sword();
createMidas_Blade();
createIce_Sword();
createObsidian_Sword();
createLifeSteal_Sword();
createMidas_Ingot();
}```
ItemStack item = new ItemStack(Material.GOLD_INGOT, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Midas Ingot");
List<String> lore = new ArrayList<>();
lore.add("§6used to craft midas blade");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK,1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
midas_ingot = item;
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("midas_ingot"), item);
sr.shape("GGG", "GGG", "GGG");
sr.setIngredient('B', Material.GOLD_INGOT);
Bukkit.getServer().addRecipe(sr);
}```
k
print what?
the value of midas ingot
wym value?
hhhh
srry complete beginner here
system.out.println(midas_ingot)
print it at the beginning?
immediately before this line
sr.setIngredient('G', new RecipeChoice.ExactChoice(midas_ingot));
k
you were right
but I cant figure out why its null
I did everything to make it
ItemStack item = new ItemStack(Material.GOLD_INGOT, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Midas Ingot");
List<String> lore = new ArrayList<>();
lore.add("§6used to craft midas blade");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK,1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
midas_ingot = item;
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("midas_ingot"), item);
sr.shape("GGG", "GGG", "GGG");
sr.setIngredient('B', Material.GOLD_INGOT);
Bukkit.getServer().addRecipe(sr);
}```
oops
you are calling create midas ingot after you are calling your other code
heres the actual code for it ```private static void createMidas_Ingot(){
ItemStack item = new ItemStack(Material.GOLD_INGOT, 1);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName("§6Midas Ingot");
List<String> lore = new ArrayList<>();
lore.add("§6used to craft midas blade");
meta.setLore(lore);
meta.addEnchant(Enchantment.LUCK,1, true);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
item.setItemMeta(meta);
midas_ingot = item;
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("midas_ingot"), item);
sr.shape("GGG", "GGG", "GGG");
sr.setIngredient('G', Material.GOLD_BLOCK);
Bukkit.getServer().addRecipe(sr);
}```
it's going to be null until create midas ingot makes it not null
but I have create midas ingot
yes. but you're calling it too late
wow, Im dumb
you call create midas blade before you call create midas ingot
just realized that lmao
How should I get a level from an XP amount?
i remember the xp related math being super cancer
I couldn't find a method, so I thought to rearrange the equations in the wiki
The equations to get total XP given the level. Rearranged them to get the level
// 0-16: -3 + sqrt(9 + xp)
// 17-31: 8.1 + 0.1*sqrt(-7839 + 40*xp)
// 32+: 18.35 + 0.03142696*sqrt(-158362 + 225*xp)
public int getLevel(int xp) {
if (xp <= 352) {
return (int) (-3 + sqrt(9 + xp));
} else if (xp <= 1507) {
return (int) (8.1 + 0.1*sqrt(-7839 + 40*xp));
} else {
return (int) (18.35 + 0.03142696*sqrt(-158362 + 225*xp));
}
}
Not sure if this would...work
Well you can test it pretty easily
It seems alright, but I'm insecure about it somehow
Relatable
Test it on a bunch of values
Like 1 less than a level up
And 1 more
To make sure it's correct
Make sure to get each case, like those where it's over 352 and then again over 1507
plug it into mockbukkit and write a test 👀
Oh look who's back
i don't think mockbukkit does xp though
I'm pretty sure I understood correctly. I'm insecure about the ranges. The wiki says "0-16", "17-31", and "32+", but does that mean [0, 16], (16, 31], (31, inf)?
test it on a server, call the set xp methods on a player and see what the get level methods say
or cuntpaste the math from nms
But seriously though, I don't know if there's some convention I'm missing here, but
Does 0-16, 17-31 mean [0, 16] (16, 31] or [0, 17] (17, 31]
I'm sure I'm just being a dumbass here somehow
unless the wiki explicitly says inclusive or exclusive, who knows
but, based on how the ranges are 0-16 and 17-31, I would guess they are all inclusive
since otherwise there would be a gap between 16 and 17
0 (exclusive) - 16 (exclusive) would mean values 1 through 15
you probably start at level 0 yes
it probably just doesn't render as level 0
the number is probably absent
There's no 0, but it's before 1 shows up
Honestly, due to the nature of how levels work, I'd say inclusive ranges make sense. Since even level 16.00001 would theoretically be level 16
And level 16.9.. is still level 16
if we want to bring decimals into it, it would have to be 0 (inclusive) - 17 (exclusive)
Actually, hold on. The wiki says the first equation applies to levels 0-16, but 352 XP is level 16 on the dot
just copy it from nms
the wiki fucking sucks
they don't know anything about anything
One time I tried making an arrow calculated with the gravity equation, but couldn't. All I was missing was a meters/second velocity to plug in, but didn't think of how to get it. I turned to the source, and I wish I hadn't
Entirely obfuscated
iirc it just adds some number of downwards velocity every tick and then multiplies the vector by 0.99 something for the slowdown
i don't remember which order it was in
Nah, nah, I wanted a perfect trajectory at a 45 degree launch angle given a desired landing distance at the same Y level
The equation yielded meters/second, but "launch force" had no conversion to that, which was my dead end
you're spawning an entity and then listening to it spawning and then spawning an entity and then listening to it spawning and then spawning an entity and then listening to it spawning and then spawning an entity and then listening to it spawning
I want to change entities with villager for example but a lot of villagers spawns in the specific location and an error appears
how can i fix it?
don't recurse infinitely
what xD
What could be the best fix for this problem
when I interact with an entity, the event is called 4 times. I will be able to modify it, but I wanted to know if there was a simple way, known, to change that
public void onPacketReceiving(PacketEvent event){
if(event.getPacketType() == PacketType.Play.Client.USE_ENTITY){
TODO...
....
launch force is in blocks per tick
which is meters/second times 20
20 meters/s = 1 blocks/tick
basically everything in minecraft is in blocks/tick
the velocity of an entity is just the vector that is added to its position every tick
DMed you the attempt
No images here
But, that's the direction I was going with that
keep in mind though that real life gravity and minecraft velocity don't work quite the same
minecraft gravity works by adding a fixed downward velocity every tick
but the velocity is then also slowed down to a factor of 0.94 or something
which means that items that go faster sideways accelerate slower downwards
since the total blocks/tick slowdown is based on the actual velocity of the object
say the factor is 0.9
and the object is going 100 blocks sideways per tick
after the slowdown it only goes 90 blocks sideways
the added 0.0 something that goes downward gets lost in that reduction
Hey, have you taken calculus?
Interesting
Anyone know of the non-deprecated way of putting colors on a map? All of the MapPalette colors are deprecated but there's no reference to what I should use as an alternative
i remember there being a way
it was somewhat obvious
i don't remember what it is though
I don't think anyone ever drafted an alternative
It was something I had wanted to do but never got around to completing
there's drawText and drawImage ?
Yeah but I'm not trying to draw an image or text, just want to set pixels on the map. I know I can use the deprecated colors but I'm trying to avoid that
just make a quick BufferedImage that you fill with a white rectangle from 00 to 128, 128
allows you to draw text on it pretty easily too
is there an other easy way to store players uuid doing it this way errors on "UUID to long " setPlayerToReport(Bukkit.getPlayer(UUID.fromString(e.getCurrentItem().getItemMeta().getLore().toString())));
e.getCurrentItem().getItemMeta().getLore().toString() obviously thats gonna be too long for a UUID lol
@quaint mantle you can use the item's PersistentDataContainer to store the UUID
idk never used items to store data before
list.toString returns sth like "String: [element 1, element 2]"
use the persistent data container
^
ill check on that thanks 🙂
since when is EntityDeathEvent not called for players
seems like one of those things that probably should be called but most people don't expect it to be called
@EventHandler
public void onCurse(AsyncPlayerChatEvent e) {
Player p = e.getPlayer();
List curse = Main.getInstance().getConfig().getStringList("banned-words");
if (e.getMessage().equalsIgnoreCase(curse)) {
e.setCancelled(true);
p.sendMessage(Main.getInstance().getConfig().getString("curse-message"));
p.kickPlayer("Please do not curse in chat!");
}
}
I cant wrap the getStringList() with String.valueOf() so that doesn't work im trying to create an anticurse thing where when someone says one of the words in the "banned-words" part of the config the message is deleted my error is with the variable im having trouble with getting the string list
List curse
should be parametrized
List<String> curse
then what you can do is use List#contains
and you can replicate equalsIgnoreCase by making the message and curse word list lowercase
oh ok thx
use a set
list contains is slower and set represents the intent of what you're trying to do better
and don't get it from the config every time, precompute it on startup or something
.getStringList("curse-words").stream().map(String::toLowerCase).collect(Collectors.toSet());
fuck you
why
Everytime I restart the server, the map's custom MapRenderers are removed and I have to reapply them, is there a way to have them persist across restarts?
i doubt it
the server would need to be given a way to obtain the renderers when the items/entities are loaded in at random
Streams are great if you don't care about sacrificing a bit of performance for cleaner code
In cases where performance isn't critical they're 👌
ight think i just finished rewriting my whole plugin who want the before after
everything must absolutely use imperative for loops and be like 30 times the lines and characters than the stream counterpart
List<String> curse = Main.getInstance().getConfig().getStringList("banned-words").stream().map(String::toLowerCase).collect(Collectors.toSet());;
I do that it says it requires List <String> but I provided Set <String> sorry if this is stupid on me i haven't learned that much of streams
Change it to Set<String>
ah ok
It's a better data structure for your needs
Depending on how you check that is
If you iterate, use a list
If you call contains on the container, use a set
https://github.com/ViperCobra/OldHCF https://github.com/ViperCobra/HCFPlus rate the transformation?
oh my god
sorry
its so big...
it says it requers a string
that's what she said
boom
It says it requires a string in the if (e.getMessage().equalsIgnoreCase(**curse**)) { e.setCancelled(true);
curse is a set
yes and it says it requers a string
it meaning
if (e.getMessage().equalsIgnoreCase(curse)) {e.setCancelled(true); }
what you want to do is see if the message has a word in it that is contained in the curse set
what you are doing now is seeing if the message is equal to the entire set
that will yield nothing
is my code good enough for premium now
probably not
or, well, i don't know
spigot's requirements are kind of loose iirc
i sent my whole project a few msgs up
premium shouldnt really be a goal i think
Hi, previously I saw that I can add my own configurations by putting getConfig().addDefault("perms", "blabla.blabla"); I wanted to know if it is correct what I am putting if in the case it is ok as it could be with a StringList.
define 'I can add my own configurations'
You can use a List<String>, yes
you generally don't add configuration options by adding defaults
defaults will not be visible in the config.yml and the end user won't know of the option's existence
I actually have no idea what those do, I just say some mention of them in the source
a config default is a value that is used when the end user has not defined any value for a config option
List<String> list = new ArrayList<>();
list.add("asdasdsd");
list.add("asdasdsd2");
list.add("asdasds3");
getConfig().addDefault("perms", list);```
Like this?
to add a config option, you want to create a config.yml in your resources directory, and write the option in there
and then access it as normal
Huh, I always use the get overloads that take a second argument for a default
That’s useful
Yes, that's what I wish
so there's no need to use it, either
anything you write in config.yml is automagically a default value
What if the config file just doesn’t have the entry
then there is no default for it and it'll be null
Maybe I should just not be lazy and make a config updater
Would be nice if spigot updated to the newer SnakeYaml that supports comments
So is what I just sent okay?
configurate is alright but might be a bit oop purist for the average guy
:v?
no, that is not how you add a config option
again, open up your config.yml in your IDE and just add it there
okay 😔
perms:
- "a"
- "b"
- "c"
that will then be the default value and the config.yml that is copied from your jar when you call saveDefaultConfig or whatever that method is will contain it
If I know how it is
But what I want to get to is NOT to add it to the config, only with code
I don’t see a reason not to have the defaults visible to the user
then you can't use comments in your config
nah
saveconfig does
savedefaultconfig just cuntpastes your bundled config.yml
so it keeps comments
or am i talking about loaddefaultconfig
how do i see how many posts i have
Might be that one
i don't remember the methods, haven't used bukkit config api in ages
Don't worry, it won't be an uploaded plugin or anything like that, I was just wondering how to use it xd
pretty sure i meet all the premium requirements but its still greyed out
really hungry for that jew gold huh
uys
iirc you have to have at least one not premium resource before you can open a premium resource
As it stands the current requirements are:
8 week old account
80 posts + 20 positive ratings
3 free resources
Two-step verification enabled
ah two step
that is what im missing
so does anybody test the plugin when you upload it or they just read the code? could use a free testing service lmaoo
ok i wasnt actually gonna do that
if not it would be scamming right
they at least pretend to look at it
though, considering some premium resources, it's kind of doubtful whether they do
Kinda dumb question- I see that a lot of people put final in their variables, and I understand what it does. Is there any other reason for people doing this? I get that it basically "locks" the variable, but is there anything else I am missing?
for variables, it doesn't "matter"
the compiler will basically always be able to infer whether or not that variable is effectively final
kk, thanks
but
that doesn't mean there is no reason not to use it
there are certain things that need final/effectively final variables
such as lambdas
in such cases you definitely should declare them final
to specify your intent
"this must be final"
some people also say that making literally everything final makes compiling faster but that sounds pretty dubious
lmao ok, thanks
Is there a packet to force players to unload a resourcepack?
or use a new one directly (by unloading the old resourcepack and loading the new resourcepack)
Because the set resourcepack url method for the Player class for some reason sends a packet to the client to load the resourcepack existing
but not a new one
do I need to provide a hash?
If you don’t have a hash and the client already has one downloaded it will use that
if the hash is different it will redownload the resourcepack iirc
Even if it did it’s compiling it’s really not that hard to wait a little bit. I wouldn’t sacrifice readability for performance anyways.
Code quality > functionality > performance
performance > everything else
Netbeans likes to tell you to make every variable that can be final final
how would you guys go about syncing two inventories between servers?
im just thinking send an update to redownload the inv each time an update is made to it
but eh
depends
String winMessage = plugin.getConfig().getString("win-message");
winMessage.replaceAll("%outcome%", String.valueOf(outcome));
winMessage.replaceAll("%wonamount%", String.valueOf(wonamount));
String looseMessage = plugin.getConfig().getString("loose-message");
looseMessage.replaceAll("%outcome%", String.valueOf(outcome));
looseMessage.replaceAll("%lostamount%", String.valueOf(gambledAmount));
why is this not replacing?
You aren't setting the string just replacing.
String winMessage = plugin.getConfig().getString("win-message");
winMessage = winMessage.replaceAll("%outcome%", String.valueOf(outcome));
winMessage = winMessage.replaceAll("%wonamount%", String.valueOf(wonamount));
not really
It tells you it returns a string...
oh