#help-development
1 messages · Page 1473 of 1
as the item spawn event is called for any form of items being spawned I do not think it is very possible
but why not use the drop event ?
Yeah that one
Didn't work
doubtful
what about ItemSpawnEvent#getItem#getThrower
Assuming there is one
EntityDropItemEvent or PlayerDropItemEvent
But that’s what the other event is for
I'm trying to limit the amount of items that can be spawned/dropped in a radius of getNearbyEntities basically
hm, let me see
there's no getItem
getEntity my bad
damn it I just can't get this effect right
that returns an UUID 🤔
Correct
yup, so just use PlayerDropItemEvent instead.
But that doesn't include if someone breaks a chest with the items inside, right?
Or just turn the activation range for items way down and then not worry about it
Bukkit.getPlayer(ItemSpawnEvent#getEntity#getThrower) maybe
I don’t think the drops of chests will have a thrower anyway
BlockDropItemEvent may work for that, maybe
Nope. It worked when I threw an item, not if the chest broke
null check everything xd
Then I assume I can just message every player near it
This works fine xd
oops, wrong scope, but otherwise works, spamming everytime a player drops something otherwise
not that safe but yeah
yea
Rip any items over 60
Yea 😳
will create a Map that saves location and item and have a task to try to respawn the Item work? xd
A player managed to spawn in more than 2100 item drops. TPS dropped to 8-9
They weren't trying to crash the server, just farming their farms, but way too much to have no protection against it at all xd
Doubt you can solve that in spigot.yml or paper.yml, if you can please let me know
just listen to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/ItemSpawnEvent.html and check nearby items before allowing it to spawn
tuff?
At least I'm sending them a message xd
perhaps have it check for junk items that automation could produce and only allow x number of those on the floor
sand, dirt, cobble, cacti etc
Combine them into a shulker box
Actually that would be pretty cool if it didn’t give people a free shulker box
or just remove x number of junk items. Its not like they are valuable
I guess you could make a plugin that combines items into a shulker box and then removed the box on pickup
That could be fun
So long as you tag it so you only remove YOUR boxes
There seems to be a total miscalculation of how many entities there actually are as well... (The numbers are the amount of dropped items nearby)
1 stack is essentially one item...
When a chest breaks, don't they stack up?
Or is it only after a while?
Not immediately iirc
Oof
if there's 1 stacked items on the ground, does that count as 1 item or?
Yea
They probably stack on the next tick
how can I get the NBT tag of a player? I want to do something like this
((CraftEntity) player).getHandle.getTag()
someone?
getHandle is a method
yea
so probably
((CraftPlayer)player).getHandle().getTag()
fixed that but there is no getTag()
Idk might be called something else
Inventing methods I see
?
Uh look for a method declared in EntityPlayer which returns NBTCompound probably
What tag are you trying to get?
I want to add a tag
then use the Spigot PDC API
uhh how can I get the API?
declaration: package: org.bukkit.persistence, interface: PersistentDataHolder
why don't put the file in the value?
I know I asked yesterday, but found no solution:
AccessController.doPrivileged(new PrivilegedAction<VarHandle>()
{
public VarHandle run()
{
try
{
MODIFIERS = MethodHandles.privateLookupIn(Field.class, MethodHandles.lookup()).findVarHandle(Field.class, "modifiers", int.class);
return MODIFIERS;
}
catch(NoSuchFieldException | IllegalAccessException e)
{
e.printStackTrace();
return null;
}
}
});
Requires me to start the server with --add-opens java.base/java.lang.reflect=ALL-UNNAMED, is there a way to auto start it with that or something else? Somebody told me also that a security manager prevents me
plugin.getDataFolder = /plugins/<plugin name>
im trying to make my plugin disable itself with this.getServer().getPluginManager().disablePlugin(this);
but it continues running after it disabled itself and throws an IllegalPluginAccessException
any ideas?
Send stacktrace
is it just me or is #checkFinite() really odd?
i mean how do i stop it from running on after its disabled
it just throws an exception if a component isn't finite? why isn't it a boolean?
im want to disable the plugin if something has gone very wrong
I have a Problem, I try making a balloon with a falling Block and a bat, but for some reason, i can't get them to spawn. I'll send the Gists for the 2 relevant methods in a Second
I know for a fact that both the create() and startBalloonTask() Method are getting called
Send the code snippet where you do it
@ivory sleet
Yeah
Hi
Hi @paper viper
No we’re enemies obv
Yeah obv
Else we wouldn’t greet each other
But how’s mml going pulse
ok carry on
good
someone decided to give a server
anyways imma stop
What was the catch of the server then?
nothing
PluginCommand myCommandCommand = getCommand("mycommand");
if (!(myCommandCommand == null)) {
myCommandCommand.setExecutor(myCommandClass);
myCommandCommand.setTabCompleter(myCommandClass);
} else {
System.out.println("[MyPlugin] An error occurred when trying to register a command.");
this.getServer().getPluginManager().disablePlugin(this);
}
Why did he decide to that then
?paste entire method
its my onenable
Put return under disablePlugin(this)
you could download it at runtime into your plugins folder
or have it in your jar resources
which one
Yeah pulse will help you cya folks
What's a good way for generating structures?
ic
declaration: package: org.bukkit.plugin.java, class: JavaPlugin
This should get a resource in your resources folder
Yes
in your jar file
You can't do it in the src folder
you just cant do that
You mean the resources folder?
it must be in resources
/src/main/resources
Show me what you have and I'll have a play
Ok I will send the class
Your src/main/resources is standalone
you dont add package names to it
you just directly add your files
to src/main/resources
and it will appear in the root directory of your jar
Oh
show a screenshot
just want to make sure
any ideas?
The reflection class: https://paste.md-5.net/vehocoqexo.cs, The test class: https://paste.md-5.net/mileqihofo.java, the statements to check:
Class<?> clazz = Reflection.getClass("me.tvhee.tvheeapi.core.test.AClass");
System.out.println(clazz); //Works
Reflection.setStaticField("me.tvhee.tvheeapi.core.test.AClass", "stringField", "anything"); //Error
System.out.println((String) Reflection.getStaticField("me.tvhee.tvheeapi.core.test.AClass", "stringField").getObject());
System.out.println((String) Reflection.invokeStaticMethod("me.tvhee.tvheeapi.core.test.AClass", "aMethod", "TEST").getObject());
Reflection reflection = Reflection.newInstance("me.tvhee.tvheeapi.core.test.AClass", "TEST4");
System.out.println((String) reflection.invokeMethod("stringMethod", "test1", "test2").getObject());
reflection.setField("st", "aStringFieldTest");
System.out.println((String) reflection.getField("st").getObject());
Not using Maven?
um, java 16?
uhh
well if you arent using maven or gradle
you have to put the file on the outside of your folder
like where your plugin.yml is located
JavaPlugin#getResource
for the string?
if you pass in that string, it would locate to a folder named songs
and that file
yes
Well, let me tell you this actually
The File class is designed for paths that are external to the jar file
the issue is, your file is inside the actual jar file
so you can't actually create a file object from it, sadly
bruh
Sussy baka
i think ElgarL or that long name told me this
this should work right?
you crate the file somewhere
i think it will
Mayhaps.
EntityDamageByEntityEvent
java -DIReallyKnowWhatIAmDoingISwear -jar /Users/admin/Desktop/sveta_temp/Amogh/Minecraft/Plugins/Server/1.16.5/server/server.jar
how do i use that with --noguii
how do I delete item from player's cursor
java -DIReallyKnowWhatIAmDoingISwear -jar /Users/admin/Desktop/sveta_temp/Amogh/Minecraft/Plugins/Server/1.16.5/server/server.jar -nogui
yes
thanks
player touch event
and by touch u mean like by getting close?
how do i delete an item from player's hand
that checks
cursor*
what item
get the item in hand and set it to null
what needed
dont ask to ask
player.getItemOnCursor()
try {
InputStream inputStream = instance.getResource("spigot/config.yml");
OutputStream outStream = new FileOutputStream(getFile());
byte[] buffer = new byte[inputStream.available()];
inputStream.read(buffer);
outStream.write(buffer);
} catch (IOException exception) {
instance.log("&r &cError: &fWhile creating &cconfig &fan error ocurred!");
exception.printStackTrace();
instance.getPluginManager().disablePlugin(instance);
}
try using this
in hashmap?
why
what are the hashmap values
you certainly aren't making a hashmap with a bunch of song classes
you're most likely making a map with a bunch of song objects
or are you actually putting Class<Song> objects in it
bruh this still doesnt work
and it doesnt even give error
yeah those are song objects, not song classes
try debugging
ohhh
i see
your trying to compare two metas
you should get displaynames from the metas and compare them to each others @oak mica
ok
idk but i think metas have something like durability and they wont be same and stuff
How do I delete an item from player's cursor
using displaynames to identify items is error prone and old fashioned
persistentdatacontainer
thx
is the getcursor deprecated?
setcursor is deprecated because of client desync buggy stuff iirc
setCursor(ItemStack stack)
Deprecated.
oh they removed it a while ago i think
not seeing a deprecation note here
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
see the docs
map.put
it does, read the docs
I said nvm
what is a song object
what constructors does it have?
yes but what constructors does it have
i and pulsebeat told u need to save the getresource to file
for that just use saveResource
then yes you need to save it to a file and then pass the file to that method
which means you want to use saveresource, which extracts a resource and writes it to a file
new BukkitRunnable() {
double delay = 2.6;
@Override
public void run() {
delay = (delay - 0.1);```
delay is 2.5555555559 and blabla, how i make only btween two numbers
or ig you could getresource and write it down manually but that's unnecessary
getresource is a method
saveresource is also a method
you know how to use a method right
then what's the problem
have you considered, i don't know, reading the docs
the plugin's data folder
in plugins
server/plugins/myplugin
getDataFolder()
My IDE is too old, it doesn;t support preview features for 16
?jd
package index
really should look at the javadocs
Why not using IntelliJ?
google is helpful as well
because not everyone likes intelliJ @maiden briar
Because I like Eclipse
Ah
I use netbeans 🙂
Ok then no problem, then I'll have to wait
did you read the docs
I'll run an update, but Eclipse usually kills itself when you do that
I can remember at "TheSourceCode" discord, "@maiden briar, why are you not using IntelliJ ? Eclipse is bad, etc"
#help-development message can some1 help me with it ?
declaration: package: org.bukkit.plugin.java, class: JavaPlugin
by learning java
Same
like u want it to be like 2 or 2.5
you clearly have zero clue of what you are doing
2.5, 2.4, 2.3 and etc
hi
and if is 0.1 end runnable
if (var <= 0.1) cancel()
doesnt work
show code
{ }
could u try debugging it?
how
why dont you check in just one condition?
just add System.out.println(1); to everyone but keep increasing the number
like this
ok
idk
Your code is not designed to run without minecraft 😦
I went to test yoru code in a standalone project but it fails as you have too bound with spigot
doesnt that cause problems
Yes (for ElgarL)
final Material type = item.getType();
if (type == null || type == Material.AIR || type == Material.CAVE_AIR) return;
``` @oak mica
CAVE_AIR is material ? 🤔
yeah i think bcz u have the != in there
!= null and when the item you are using does not exist in your hand it will execute this condition
this send
use == bro
yeah bcz you are checking if the item ISNT (!=) null and if the item ISNT (!=) null then it cancels (return) everything
.
the == means if the value equals value
and use isSimiliar to compare itemstack as i already told you
#help-development message how to solve this
runned your code and it runned fine for me
who
double delay = 2.6;
delay = (delay - 0.1);
System.out.println(delay);
Output: 2.5
continue removing
until the result is 0.1
no i mean it works
it was for @minor garnet sry
ok
any idea?
maybe your teleporting 1 y below
from what I can gather, you're trying to teleport a player 25 blocks straight ahead of where they're looking. Why not just check if the block they're gonna end up on is a solid block, and if so use something (SUCH AS) World#getHighestBlockAt(x,z)
(assuming thats the behaviour you want)
is NoteblockAPI installed on your server
yeah
you're importing classes from it, right?
do you include it in your plugin then?
wait why?? its a separate plugin isnt it?
how do I set the slot that the player clicks to be an ItemStack
Inventory#setItem
you need the plugin on your server unless you shade it
Guys how set player group in luckperms api i have this code:
api.getUserManager().loadUser(player.getUniqueId()).get().setPrimaryGroup("vip"); api.getUserManager().saveUser(Objects.requireNonNull(api.getUserManager().getUser(player.getUniqueId())));
or getRawSlot or
Is the plugin still in your build path
Using the correct location?
(Did you move the plugin jar to the plugins folder or copy it)
Design Question: I'm running multiple instances of a minigame on one spigot server, and each GameInstance has a GameState which is an Enum (GameState.STARTING, GameState.INGAME, etc). Where should I handle the tick logic for each state? Currently I have the logic inside the enum, but I feel like that's stupid because enums are supposed to be constant but I have Map's inside of them for each GameInstance. I don't know what to do. Any suggestions?
i would make some GameHandler class and handle it from there
I have a issue related to starter pack
https://www.spigotmc.org/resources/starterkit-1-8-1-13-2.49445/
and im not able to create a starter kit
I get an error too
- not related to development (in this channel we help u with your own code and plugin)
- you should contact author
but show the error
maybe i could help u
probably sending some message
Is it possible to add something to the an list in config.yml through a command?
Is this an answer to me?
If it can't be resolved then it can't be on your build path or its pointing a wrong/nonexistent file
yw
Exactly. Check the location of the reference. Try readding it and see if that fixes the problem
ok
what ?
this should work right?
for better checks, use
if(item.isSimiliar(ItemManager.TPsword)){
// your codes
}
ok
or
if(!item.isSimiliar(ItemManager.TPsword)) return;
I was thinking more along the lines of ```java
Location desiredLocation = /* some loc */;
if (!Material.AIR.equals(desiredLocation.getBlock().getType())) {
desiredLocation.setBlockY(desiredLocation.getWorld().getHighestBlockAt(desiredLocation.getX(), desiredLocation.getZ())+1);
}
p.teleport(desiredLocation);
WorldGuard? anyway #help-server
huh
I had a problem... nothing to worry about.😂
Heyo, I made a custom entity with NMS (custom silverfish), at the moment it walks on the ground, can I specify another Y? (I already tried to change the Y on the onTick method but it doesn't seem to work with custom pathfinders)
why I get ignored so hard😥
A silverfish can not fly
Gotta constantly set their velocity or teleport them. Or put it on an invis armorstand with no gravity.
Please tell me why it doesn't work? Writes that it is not defined for the NamespacedKey type.
NamespacedKey.fromString(key);
return key;
}
lol
that method returns the string you pass in
return new NamespacedKey(plugin, key);
litter! Forgot to remake it. I want fromString to return.
NamespacedKey doesnt have a static fromString method does it..?
There is no fromString method in NamespacedKey
fromString
@Nullable
public static @Nullable NamespacedKey fromString(@NotNull
@NotNull String key)
Get a NamespacedKey from the supplied string. The default namespace will be Minecraft's (i.e. minecraft(String)).
Parameters:
key - the key to convert to a NamespacedKey
Returns:
the created NamespacedKey. null if invalid
See Also:
fromString(String, Plugin)
https://papermc.io/javadocs/paper/1.16/org/bukkit/NamespacedKey.html#fromString(java.lang.String)
Not Spigot
thats PaperSpigot
It also doen;t just take a string
wait what-
Yeah, I don;t see that method either
It is in the documentation!
im gonna run buildtools and see if that method exists when i get a new jar
Its in the docs, its not in the jar though
Its definitely in the code, but it does not show up in my IDE
strange
I've never seen that before
netiher have i tbf
How else can you get enchantments by name?
can i get the first OnlinePlayer from the Collection with this code?:
Collection<Player> player1 = (Collection<Player>) Bukkit.getOnlinePlayers().toArray()[1];
oh,nm, its there, it was added in 1.16.5 I was still on 1.16.4
im also on .4 lol
or what is the best way to do so?
No, if there is on one online, or teh only play is dead there will be no [0] and definitely not an [1]
and just fyi you don't need to do toArray() when getOnlinePlayers already returns an array
Collection<? extends Player> players = plugin.getServer().getOnlinePlayers();
Player p = Iterables.getFirst(players, null);
if (p == null) return;```
return NamespacedKey.minecraft(key);
}
As I understand it, this method now gives me a NamespacedKey.
What exactly are you trying to do?
@eternal oxide and how can i get the location of this first player because its no player? can i convert this?
is ?tag something?
I need to synchronize enchantments in a file.
So you are trying to get all Enchantments that are registered on the server?
or just their names?
So that I can restore them to the subject.
- I need to save them to the database.
Is there some kind of api or how can i do something like updating config from other versions without having to recreate?
getConfig().options().copyDefaults(true)
i didnt meant that
i have a file config.yml, messages.yml and stuff and i want to when i add some sections to it i want it to update
Like copy the new sections to your config.yml?
yea smth like that
Without recreating
but with comments
i've see plugins that starts from 1.13 and has support from 1.8 to 1.16, how they do that? Native version: 1.12/1.13
dont believe you can copy comments, only the header
smth with inputstream and stuff u can
i mean appending it to the end of the file maybe, but once you save that file then you're gonna lose the comments if you use Bukkit's FileConfiguration#save
I got a map. Then I need to restore.
check the config if a key of your new section exists, then use FileWriter to append the new default values
something like that
if you are saving and loading items, they are serializable
It's more convenient for me through the text. The database must be synchronized.
and how can i get the second and third?
You learn Java
your about to get violated for that
No
You don;t know how many are in the Collection
yes obviously i check for null
no
but i know it i have a switch statement for that
there will be no null values in the collection
no, this is not an array
🥲
okay thx
Skull guy wat u tryna do
I'll give you a hint, you can google the rest. java Iterator itr = players.iterator(); while (itr.hasNext()) {... }
Raw types 😬
I did say I'd give him a clue, not write it all
hi, i am just asking to be sure, to reach summon-item it should be like this right?
generators.emerald.summon-item
hey guys, is there a way to get a list of all mob entities? i'd like to spawn a random mob
or do i have to manually get all entities and put them in a list before randomizing it
There is no log nor sysout in that code
you are logging an object
somewhere in code that calls
what is the init() method?
or the updateState method
find the log/sysout line
somewhere in your update you are logging an object
how can I create a scoreboard in 1.16.5 with packets?
no]
You understand what a logger is?
Somewhere you are using the logger or calling System.out
yeah you're just a noob
there we go, finally
is there an event to change a mob? for example if i spawn a zombie it changes to a chicken
you can't change a mob
you can replace it is all
what does that mean?
once the zombie spawns it replaces it with a chicken?
no
understood
how about an event that changes a mob's damage? to make the player flying after every hit
events don't do what you think they do
there is a way to change a mob's damage yes, but it doesn't involve events
events are things that are called when stuff happens; when a mob spawns, a block is broken, a player joins, so on
ok my apologies, still learning
i guess i meant functions since I'm learning the functionality/calls of the spigot api
in java we call functions methods, but yeah, methods
here are the javadocs for zombie
here we can see that it extends Attributable
attributable has a method that lets you get a specific attribute of an entity
it takes an Attribute and returns an AttributeInstance
this is great thank you
attributeinstance then lets you modify the values
f.e by setting the base value
or by adding a new attribute modifier
the first thing you want to learn is how to navigate javadocs
Hi folks, where can I find the list of available keybinds?
for what
In the basic example, there is a keybind (key.jump). I want the keybinds for attack/destroy, use item/place block and swap item with offhand
Thank you!
Is there a way to extend or use methods/attributes in other entities?
For example can I have a chicken entity inherit creeper methods to make it explode?
not automatically no, you'd have to program that behaviour yourself
Hmm yeah I wouldn’t want to see the TNT though. Not sure if that will
you can just set an explosion
Ah right on
By the TNT or just a random explosion?
Pass in teh chicken entity https://hub.spigotmc.org/javadocs/spigot/org/bukkit/World.html#createExplosion(org.bukkit.Location,float,boolean,boolean,org.bukkit.entity.Entity)>
declaration: package: org.bukkit, interface: World
Now I’m thinking if there’s an explosion method that we can do
Ohh very nice
there is a search box in the top right corner of the javadocs
Create explosion 👀
again, the first thing you want to learn is how to navigate javadocs
searching and being able to find stuff is part of that
you can't rely on elgar linking you the relevant methods forever
wrap the code in the runnable in a try/catch
Everyone learns differently
everything that is in the run method
2 methods?
does update fun?
then one of your if statements is failing
actually, its probably itemsList is empty
wouldnt that also possibly mean itemsList.length is 0
itemsList[n] instanceof BetterCraftArmour
this is probably the fault point
where are you obtaining the contents of itemsList?
the only way NEITHER of them can run is if there are no items
sysout the length
of itemList
dude
if you won;t listen we can;t help you
ok, good luck with that then
so colour me surprised. my telling you to add a try/catch would have shown you that
Exceptions in anonymous runnables do not get shown in console
They don’t?
are you sure about that
Yep
exceptions in lambdas sure do
I've come across it before
I threw a RuntimeException in an anonymous Runnable and it showed stacktrace just fine.
odd
are you maybe confusing it with exceptions in static initializers
Maybe it’s cause the runnable was executed in another thread pool with an unset uncaught exception handler or smtng
thast possible
nope
you never set it
Hi! me again haha.. i'm using getDisplayName() to save an itemstack meta name to config but it doesn't make it readable when it has colors. It still works but is there a way to get &k instead of ยง4ยงk 😄
String displayName = inv.getItemInMainHand().getItemMeta().getDisplayName();
what does the :: mean?
similar to the # it sometimes notes that the method is non static
String#replace(String, String)
String#replace('§','$')
String::replace('§','$')
the :: notations comes from the method reference notation introduced in java 8
How would i deal with a chatpacket like this. json {"extra":[{"color":"dark_green","text":"Wilderness "}," ",{"color":"dark_gray","text":"["},{"color":"gray","text":"Member"},{"color":"dark_gray","text":"] "},"MangoOnTop",": hello"],"text":""} Im using ```py
def handle_chat(chat_packet):
chat_raw= str(chat_packet)
text = message(chat_packet)
if debug is True:
print(chat_packet.json_data)
print(text)
if text == '':
print(text)
else:
print(text)
from_minecraft.put(text)
``` and get Wilderness [Member] when i should get Wilderness [Member] MangoOnTop: hello
thanks!
I am trying to cancel the default drops for some custom entities so I can replace them with other items
when the entities are spawned I set a string value in their persistent data containers but the value does not persist, as evidenced by debugging my EntityDeathEvent handler
I am not sure why this is the case, or if it is related to how I am spawning the entities
this is the function that attempts to spawn entities and sets the persistent data: https://hatebin.com/diuranwbij
other attributes of the entity that are set before spawning appear to work fine, but the persistent data does not.
hi
My fawe plugin (1.12.2) is having problems
(log:)
I don't have much idea of programming
Ok quick question
I have a functional “snowball launcher”, it shoots snowballs and everything
How would I go about making the snowballs do Damage?
well heres the thing
there is technally, but then it applies to all snowballs
i just want snowballs shot from my cannon to do damage
oh you are right
there is
listen to whatever event is fired when projectiles hit shit
apply a metadata value or a pdc tag to the snowballw when fired
and check for that in the event
and then use the methods on Damageable
and I was scrolled like 30 lines up
ty
is there a good way to store data on a player? like maybe tags
yes, the persistent data container
player implements persistentdataholder
if you don't want them to persist over restarts, use metadata or something
ok
inv.getItem(slotsMap.get(equipSlot)) == create()
looks dubious
are you sure == does what you think it does
a == b returns true if and only if a is b
a equals b will also return true if a is the same as b
for example two Integer objects each representing the value 3 will return false for ==
because they are two objects
Projectile snowball = p.launchProjectile(Snowball.class);
snowball.setCustomName("snowballLauncherBall");
but they will return true for equals, as they are the same
this is how i name the projectile yes?
that is, represent 3
inv.getItem always returns a new ItemStack object
because the returned itemstack is a clone of the actual itemstack
so the object you get will never be == to anything you pull from elsewhere
don't name the projectile
use a pdc tag or metadata
did you actually read the page
sorry, i'm "click happy" I'll look through more in depth
it is somewhat similar to a Map
but takes 3 parameters instead of 2
a Map takes a Key and a Value
Hello, how can i set EntityArmorStand as EntitySlime passanger? i tried with armorStand.startRiding(slime); and slime.passengers.add(armorStand); but it doesnt work :/ Should i send any mount packets? (if i set EntityArmorStand or EntitySlime as player's passanger - works)
the pdc takes a Key, a Type, and a Value
and unlike Map, where Key can be anything, PDC only allows you to use NamespacedKey as key
throw some stouts at it
system.out
Is there a way to get all users that have joined a server without registering them when they join?
in everywhere
I need to do arg > string > uuid (both online and has played)
Bukkit.getOfflinePlayers()
only works for the uuid though
can't do string to offlineplayer(string)
as it's deprecated
you can
read the deprecation note
it's not recommended as the default way of getting a player as you should design your shit to look players up by uuid rather than name
lemme play around with it
but you still can use it and it does work
that said it can fire a blocking network request to mojang, so you shouldn't do it on the main thread
ye, essentially need to do string > player > uuid so only really running it when the query is requested
it's all async so we good
@wraith rapids so this would work right?
well, not just yet, but...
yes that should attempt to find an offlineplayer matching the given name
what is the null error
the full error
is there a way to make passive entities (cows, sheep, chickens, pigs) run away from a player?
BetterCraftArmour.playerEquipped(BetterCraftArmour.java:117) ~[?:?]
what is this line
surely not
stout accepts null values
it does not throw a npe if it's given null
give me the actual class
@wraith rapids im sorry, i've read this site 10 times over and i still dont understand it
So i need a namespacekey for a PersistentDataConatiner correct?
myes
ItemStack itemStack = ...;
NamespacedKey key = new NamespacedKey(pluginInstance, "our-custom-key");
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.DOUBLE, Math.PI);
itemStack.setItemMeta(itemMeta);
why on the 4th line does he set it to pi
does it just have to be pi
idk he is an idiot
this is not the same version of the class as what you're running
don't listen to that author, he is trash
69.420 for example
i see
it's just the data you want to store
that seems too dope to put into the PDC
(key, type, data)
so thats the damage value I want to make
you could record the damage the snowball should cause in the pdc, yeah
create a namespacedkey like yourplugin:custom-damage or whatever
use the DOUBLE type
and then write a double
ok
the code that threw the exception and the code that you're showing aren't the same
the only case where line 117 would throw a NPE is if the static field 'out' of System is null
which I don't expect to be the case
doublecheck and triplecheck
something is fucked somewhere
or actually, did you include the full error?
it would make sense if you only posted a part of the error
i don't think you did
i'm 90% sure there's a Caused by: block following the stack trace you sent
ItemStack itemStack = ItemStack(Material.SNOWBALL);
NamespacedKey key = new NamespacedKey((Plugin) this, "customDamage");
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.getPersistentDataContainer().set(key, PersistentDataType.DOUBLE, 3.0);
itemStack.setItemMeta(itemMeta);
like this?
restart the server, rebuild the project, and try again
and send me the entire server log
the fact that you have to cast this to a Plugin seems wrong
you need your plugin main instance there
can one create javadocs with github pages?
oh
the 'this' in onEnable
that means that you need to somehow obtain the instance of your main class in there
for example by passing it down in a constructor
for async on my database function can I use ```java
Thread newThread = new Thread() -> {
...
}
newThread.start();
o.O
or is there another way to do it
the most common way would be a completable future
which is then executed on an executor
Is using "Bukkit.createInventory" often optimized?
or should I keep those inventories
ah wait, is there no custom model data equivalent for blocks?
like if I want to give a new custom model into the game, it has to replace a block?
blocks are just a few tightly packed bits in a block palette in a chunk
there is no room for extra data like model ids or anything
so it has to replace a block in the game, for each model? :(
its so unfortunate they cant even toss in a few bytes for a custom model data
the exception to this is a tile entity, which is a totally separate thing from blocks and has more in common with a regular entity than a regular block
a more apt name might be voxel entity
yeah but then I'm just better off placing an armor stand with an item on it's head
since its the same thing
there are some blocks like mushroom blocks and note blocks that have a large number of block states that you could use a resourcepack to apply custom textures to
but no, aside from maybe fucking with tile entities, there is no way to add anything new
everything you do involves replacing something that exists
since block states and all of their combinations are pre-baked
minecraft should introduce an block that specially occupies 4 bytes or smth as a custom model block :[
it'd have to be a tile entity with the way how things currently work
currently, a block is just a few bits in a block palette
basically, a palette maps a number to each material type that exists in the chunk
and then the chunk contains those numbers
🤔 so every block with a custom state is a tile entity?
I think they might not even be too far off that.They also added I think minecraft:marker which is an entity that doesn't tick at all
like a door for example has facing states, waterlogged, all of that
since most chunks only contain a few kinds of block types, the resulting numbers are only a few bits in size
no, that is not a tile entity
but it has additional state
which is tracked separately
a door for example has a handful of state fields
then yeah why cant they add what I said and just track is separately
whether it's open, which side the hinges are on, whether it's the top or bottom block
because all states need to be pre-baked
do you know how the current block states are implemented dlg?
wdym banana
how its stored in the block registry, and how its sent to the client
for example, a note block has a few thousand different states
or was that a few hundred
i don't remember
and what the difference between a tile entity is or not
thousands? lol
heres the block palette for 1.15
and you can maybe get a better idea of how they're stored dlg
that looks like my old end-2019 shitcode
oh tf
basically, every possible combination of each attribute is precomputed and assigned a number
I see, I thought they would store a few bytes for the block id then afew for the state
the only difference that tile entities have is that they also get an additional NBTTagCompound to store in the mca files
but thats really it
but if its precomputed then having any extra data thats not locked is impossible
yea
block state can only hold different combinations of predefined data
block data can hold arbitrary data in the form of nbt
you can add extra block states to the block palette if you want, but they need to have the existing id of a vanilla blockstate otherwise they dont appear on the client
annoyingly enough, bukkit calls block state blockdata, and block data blockstate
lmao
might just add a block type that contains block state that only references a single integer
yeah, that seems like a relatively sensible approach
which is mapped on the client side to the respective model
using tile entities for it would have a bit too much overhead i'd wager
it would be fine if the server sent the client the list of blockstates and their ids
Yeah you wouldn't want them ticked by default
so that the server could add additional numbers
i mean, the additional numbers would just be loaded from the resourcepack
so say I wanted to replace snare with a note of 24 in predicates, is that even possible?
https://minecraft.fandom.com/wiki/Block_states#Note_Block
and different states
it'd limit you to only having 2^32 different custom block states
I don't think mojang would actually implement a registry sync for the available block types banana
but the same limit is in place with the model ids for items
well theres always a limit
maybe not, but otherwise it means that the registry is hardcoded for every version and subversion 😳
usually its an integer
it'd be more feasible to hardcode the client to treat a specific range of block states as things to be loaded from the resourcepack if present
and then assign that range to a specific block
I mean, a fully dynamic approach seems problematic because the server would also have to send assets for it else a missing resource pack might explode
and at that point you are in mod land
nah
no, the resource pack doesnt have to be synced
it would just show a missing texture if it wasn't in the pack
oh yay we are in garrys mod hell
perhaps there could be a NewBlockState packet, that has the new block state id, then another id representing a state already in the game, which would be the texture & model if a resource pack doesnt override it?
It definitely would be yes xD
just work that they are probably not going to ever focus on
a single block with custom state seems easier
like, same with custom model data
like, we're already kind of doing the whole "hardcode the client to treat a specific range of blockstates to be loaded from the resourcepack" thing
we just don't have a dedicated block for it
though the registry would practically have to be locked on world generation, since if u start replacing and adding block states it'll cause problems with already added blocks
so we're using noteblocks and mushroom blocks
NNY
idrk what to call you but
so say I wanted to replace snare with a note of 24 in predicates, is that even possible?
"https://minecraft.fandom.com/wiki/Block_states#Note_Block"
is that possible with a resource pack predicate?
having a disposable range of a few thousand states that wouldn't be used in vanilla normally would pretty much solve the whole issue
yes yes you can do whatever
yes dlg
tbf a single blockwith custom "model" blockstate might still have its issues regarding hitboxs
yeah they could just whitelist 0 to like x and then every minecraft block would start from there :(
depends on how thorough the support is
i don't think we can change block models currently, even for specific block states
you can replace any state in the list i sent with 1 custom block model
that'd have to be possible for it to work
actually no, that wouldn't even be an issue
there are already blocks that change hitbox based on blockstate
yeah there are
e.g stairs
but idk if resourcepacks support modifying them
at present, anyway
i know for sure we can change the texture of a blockstate, not so sure bout the model
i'm not really a resourcepack guy
I don't think they can right now 😭
but, since items already support custom models, it shouldn't be too difficult to implement for blockstates either
imagine if minecraft was open source
imagine how many trash version of minecraft would be around
xD
ngl, the deobf maps are good enough imo
also depending on a modified client seems like a big hurdle for servers
why does it create the config file name as Main?
instead of the name of the jar
and when i try to enable it with pm
i don't know, let me get my crystal ball
🔮 the crystal ball says... you're doing something wrong
i can't tell if you did something wrong
because i haven't seen a single line of code
i sent the pom
pom is not code
getServer().getConsoleSender().sendMessage
don't use this for logging
the config file should be called config.yml
yes thats not the problem
then what is the problem
the file containing the config file is
sorry to bother again, but this time i want to see if a player has an item with a custom name (Grey name, "Ammo Box"), i have
if(p.getInventory().containsAtLeast(new ItemStack(Material.CHEST), 1)){
Which just finds if they have a chest, how do i check the chest's name?
that is controlled by the value in plugin.yml
your plugin's name
don't check against name
write a tag in the persistent data container of the itemstack
to mark it as an ammo box
then check for that
relying on item names is old fashioned, performs poorly, and is error prone
an item's pdc is accessible through the ItemMeta
ok
create a namespacedkey along the lines of yourplugin:item-type of type PersistentDataType.STRING
and then save the item type, f.e "ammo_box" on the pdc
pdc.set(key, PersistentDataType.STRING, "ammo_box")
then you can check whether an item is an ammo box by doing pdc.get(key, PersistentDataType.STRING) and comparing to "ammo_box"
also could you tell me why whenever i make a change in the config file it resets to the default?
is it because of the config.options().copyDefaults(true); in the AddDefaults ?
this.saveDefaultConfig();
new AddDefaults().add();
saveConfig();
define change
thats on the onEnable
like i set
test: true
and if the default is false it goes back to false
defaults are already read from your bundled config.yml
just call saveDefaultConfig and nothing else on startup and you're fine
but do i add this after the defaults? config.options().copyDefaults(true);
cuz now theres nothing on the config file
this.saveDefaultConfig();```
if you make changes you save teh config not the default
BRO how the fuck does microsoft store use more cpu than google XD
it's probably fucking electron
everything is electron these days
i'm sure windows 10 will be rewritten on electron eventually
pisscord is trash
taskmanager when it starts up it uses 10% cpu
oh shit it just used 25% now for like 2 seconds
XD
bro i dont get it
main:
https://paste.md-5.net/rupozecopa.java
addDefaults:
https://paste.md-5.net/bequmoniba.java
if i do it like this the config file is empty when i start the plugin even tho i have the this.saveDefaultConfig
and to fix this i have to add
config.options().copyDefaults(true);
wich adds the data to the config file but doesnt let me edit it
doesnt the saveDefaultConfig save the raw data to the config file? so if i add the defaults the saveDefaultConfig should add all of that data to the config file
now the weird part is, the data is there and i can work with it inside the server, but it doesnt show
dont u use save config for that?
saveconfig saves the in-memory config object that you may have modified
savedefaultconfig extracts and saves the config.yml file that is in your jar
which is why the former kills comments and the latter doesn't; the latter doesn't actually touch any config parsing shit anywhere
it just copies a file
savedefault only copies the jar config and saves to file if there is no file there alread
it's functionally equivalent to saveResource("config.yml", false)
yea but theres no config, but still it doesnt show anything
but if i do something it adds it
savedefaultconfig and config.save are two different things
have u set the defaults up in the config.yml file in ur plugin
so anything i add as a default doesnt show