#help-development
1 messages Β· Page 2219 of 1
sure
Wait, loading new chunks wouldnt permanently increase ram usage, right?
Ok, so unloading old one's would clear ram
yeah it should
Aiight, here's the repo. If you don't wanna read through it all, that's fine lol
https://github.com/OGPanda18/BingoPlugin
lol ingore the bonguses
public ArrayList<Material> getItemList(){
itemList.clear();
for(int i = 0; i < itemArray.length; i++){
itemList.add(itemArray[i]);
}
if(nether){
for(int i = 0; i < netherArray.length; i++){
itemList.add(netherArray[i]);
}
}
return itemList;
}
This is a lot of unnecessary read/writes, could really be refactored
public class BingoBoard {
private Player p;
change that to a UUID
Also at any point are you ever removing from plugin.getPlayerBoards()?
otherwise i don't see much that would cause an issue
well itemList doesn't really need to be there at all
why not just use Arrays.toList()
and I'll change the player to uuid, didn't know that necessarily bad
cause I'm lazy and didn't wanna install the Arrays package ngl
its not noticeable but after a lot of players join/leave it becomes deadweight data and gc wont pick it up
Aiight
yeah but nothing else really sticks out to me much
Okay. Thank you so much for your help π π π
nws
Wait wait wait, ONE last thing
Should reloading the server decrease ram usage back to like the base it would be as if I restarted it?
player's name can change, uuid doesnt
say I'm doing a longterm storage of player data, if the player changes their name the next day, they lose all their data
wdym
like an offline server?
I've got no clue about offline servers
i know names can be spoofed
i think uuids would still be more secure
UUIDs can be spoofed, yes
probably use onLoad instead of onEnable
They are just as secure as names
Though to spoof a offline mode UUID you'd need to spoof the name
Since the UUID is generated from the name
Yep
Isn't the UUID tied to the minecraft account?
The purpose of offline mode is to not tie anything to the mc account
how does one make an entity move to a location
a LivingEntity?
if it's an entity that attacks, you can just set their target. Otherwise, or if you only want it to move but not attack anything, use NMS and change their Pathfinder goals
can anyone point me in the right direction for making a multi-world plugin Thanks!
You mean a world management plugin?
yeah
tha basics are extremely easy. with Bukkit.createWorld(WorldCreater) you can create new or load existing worlds. Now you can simply save the name of worlds you have created in a yaml, json, whatever file, or database, and simply load them again on the next startup
tysm!
np
quick IntelliJ question: Everyone knows this annoying "Might be null" warning in IntelliJ. Obviously this can be safely ignored if you have a default config value set. Does anyone know how to ignore the "might be null" warning ONLY for certain methods (ConfigurationSection#getString())?
remove @smoky tinsel tag from that method in the api
wait
there is a guy with that name
funny lol
:)?
@smoky tinsel
no for real, there must be some setting in intellij to exempt that method from inspections
press "More Actions"?
nothing interesting there
im on win 11 and win+shift+s does nothing
imagine using win 11
win 11 good
win 11 is such a downgrade
hmmm then i dont know what is the shortcut for the snipping tool
no drag and drop to taskbar. no right click taskbar for task manager. no changing audio device with a simple right click to taskbar. no proper right click menu in explorer. etc etc etc
install lightshot, press prntscr
well but why
whats wrong with my screenshot
it shows the menu I wanted to show
lol
on the right
there is, in the quick actions menu
what is there?
the right click menu? yeah it requires twice as many clicks now
yes. but I dont need a volume slider. I need to switch between different audio devices
in win 10 it was "right click volume thing" -> you could change it
community survival, does it mean that it is our survival game?
kinda
woah cool
guess I'll have to live with the useless "might be null" warning :<
there
oh true. that must have been added in the last few months
i think intellij is open source right π
lol my list is a bit long
Now that I am thinking, are they using their own software to build their own software?
π«
would be weird if they didnt lol
Does anyone know whether ConcurrentHashMap bricks itself if the hashcodes of the keys change?
I'm gonna look at supporting older versions with my plugin. How annoying is it gonna to be for me to implement player.getWorld().setBlockData() for 1.8->1.18
that method call should not be too complicated given that BlockData existed for a while now
it would break for a HashMap at least
?
i was on win 11 and it worked for me
im so stupid
I pressed ctrl shift s
lol
is there a event for player travel to nether?
World change event
I would check if the new world equals Bukkit.getWorlds().get(1) which is the nether
tysm
how can we give potion effect to spawned entity?
like if someone break a block then random entity spawn then that entity should get a random potion effect
or how can we change that entity damage and hitpoints?
Attributes on a LivingEntity
addPotionEffect() on a LivingEntity
okay...
thanks :)
btw one more thing
when someone break a block then random mob spawn even blocks so will it work?
means will it throw any exception or not?
as long as you spawn the entity sync there shouldnt be any problems
okay.. lemme try it out
Why when I'm adding potion effect to player in OnRespawn event effect doesn't work?
Just doesn't add
delay it for a few ticks maybe, they may not yet have respawned when the code is ran
Okay
no, check the type/environment instead
i think theres a method of the enum
yea
there is
i will use that to get random potion effect
Objects.requireNonNull(event.getPlayer().getLocation().getWorld()).spawnEntity(location, entityType1);
livingEntity.addPotionEffect(PotionEffectType.BLINDNESS);
Can you tell me the best way to call method with delay in my case?
like here first its spawning mob then adding potion
but dunno its showing me error
i tried PotionEffect too
umm wait
its not working still ;-;
?javadoc
Objects.requireNonNull(event.getPlayer().getLocation().getWorld()).spawnEntity(location, entityType);
if(entityType.isAlive()) {
PotionEffectType potionEffectType = PotionEffectType.values()[new Random().nextInt(PotionEffectType.values().length)];
livingEntity.addPotionEffect(livingEntity.getPotionEffect(potionEffectType));
}
i did this thing
let me try
that probably wont do much for you
how can i create a timer from an increasing double? I mean something like this [Green--Red----] the green part represents the progress to full and red the remaining
i would send this thing in the action bar
I would check if the World
World#getDimension == Dimension.NETHER
I tried to create a custom mob but whenever I try to compile to plugin I get this:
java: cannot access net.minecraft.network.chat.TextComponent
bad class file: /C:/Users/ANFFG/.m2/repository/org/spigotmc/spigot/1.18.2-R0.1-SNAPSHOT/spigot-1.18.2-R0.1-SNAPSHOT-remapped-mojang.jar!/net/minecraft/network/chat/TextComponent.class
class file has wrong version 61.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
Is there a player look event? It doesn't look like the player move event fires when one only looks around
it does actually, move event is fired whenever something changes to the player location, this includes yaw and pitch modifications
just check if the player's x,y,z positions are still the same
if they are then the player only looked around
use java 17 or later to compile
ohhhh ty
Hey guys, do you think it's possible with spigot to do some kind of event where you somehow get the stronghold structure and relocate it somewhere else ? π€
I don't know if we can play with structures etc
I assumed so, and thus I only checked wether pitch or yaw have changed, but it just doesn't fire unless I actually move
then just use a runnable that runs every tick
this is my code
https://pastecord.com/xadibafyle.cs
here when ever someone tried to break a block then random mob spawn and get a potion effect(i dunno if potion effect working or not). and if player use this command /easymode or hardmode then it should send a msg in title about difficulty(i have a method but i cant able to call it because of player parameter) and after this it should run other code
i just want to ask that how can i call that sendTitle method?
its all about Player parameter ;-;
Now I get this
java: cannot access java.util.stream.Stream
class file for java.util.stream.Stream not found
public void sendTitle(Player player) {
player.getPlayer().sendTitle("\u00A7e DEMO TEXT", null, 0, 60, 0);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(command.getName().equalsIgnoreCase("easymode")) {
sendTitle();
}
command_name = command.getName();
return true;
}
main code
does any of you guys use paperweight-userdev and know if its possible to set gradle reobfJar task to force delete previous build?
error
that's not how commands work in bukkit
then?
you add command name to plugin.yml
yea ik
then #JavaPlugin.getCommand("commandName").setExecutor(new YourCommand())
YourCommand class implements command executor class
this error just tells you that you have to put a player as argument
onCommand of YourCommand class will always return the same command label, unless its an alias
sendTitle(Bukkit.getPlayer((Player)sender))
You dont need Bukkit.getPlayer()
right
you literally casted sender to player object
you also dont need this stuff
just override the onCommand method
yes, but that way no tab completion would occur normally unless you override tabcomplete method
oh nvm it would occur
but its way cleaner to set command executors
or to use command framework
why are you comparing the command's name?
are you registering this executor to 100 different commands?
well okay
Hello, I'm not a developer but I have a friend who made me a bossbar plugin that allows me to put Placeholders (coordinates, direction, AureliumSkills...).
One thing it can't do is be able to leave that bar always at the top of the screen and no other boss bar come up and take its place. We know it's possible because I used another plugin before that did that, the main boss bar always stays on top even when arriving in front of the enderdragon or if other plugins display it. I couldn't keep it because it wasn't customizable on each world unlike the one he made for me. Does anyone know what to put in place to force this bar all the way up (in fact there are 2 bars possible per world so ideally know what to do so that these 2 bars do not move from the top of the screen) thank you
i am wondering, why not just use Β§ instead of \u00A7
does that not work?
: Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Asynchronous effect add!
xD
whatever suits you i guess
full error would be helpful. Anyway - do not add potion effects asynchronously
the Bukkit API should only be accessed synced
Then how
does the event api work if the annotated method is overridden?
do you have a listener that extends another listener?
Bukkit.getScheduler().runTaskLater(plugin, () -> {
// add potion effect
}, 1L)
i have an EnchantBase class that implements listener with a lot of void methods that are empty inside and you can extend EnchantBase to override the void methods to create your own enchant implementations
if I were to make these methods event handlers and override them in another class, would it work?
without annotating them again in the child class
that's actually a really good question
what about tryitandsee
it could work
im making some boilerplate code and i'd rather not code boilerplate for something that might not work
anyone?
You could ask Paper
annoying how i can't use my test builds without unloading plugin first
i use plugman to reload
to quick test it
that's a time waster too
launch a server
whenever a test build has been compiled
im just too lazy to wait
you could just make that task run sudo rm -rf path/to/jar
Use agencies not Agencies
Apparently something like "rm -rf path/to/jar".execute()
Ah Ye didnt know about that
How can I spawn a entity exactly on the players crosshair?
declaration: package: org.bukkit, interface: World
Not on the termination
use player.getEyeLocation as starting point and direction
huh?
raytraceBlocks queues all blocks on the view vector of the player
oh you mean just right in front of the player?
Yes, exactly 1.5 blocks in front of the player, on the position of their crosshair
Spawn a entity
well just use eye location again
then getDirection on it
and go 1.5 forward
thats it
public class SpigotTest extends JavaPlugin
{
public static SpigotTest Instance;
@Override
public void onEnable()
{
Instance = this;
getLogger().info("Spigot test plugin activated");
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
}
}
Can't call this class and his static fields in other classes
should be good
Trying to call this class in other package
How?
Nothing work
basic vector math
Thank you, very helpful
normalize the vector and then just multiply it by 1.5
then add the location and the vector
to get the new location
spawn there
how can i prevent player from placing item in an inventory except for specific slots? when i cancel the InventoryClickEvent the player is still able to do it with shift or with spamming clicks
Thank you
try using InventoryMoveItemEvent or InventoryInteractEvent
i dont understand how to get the slot where item is going to be placed in InventoryMoveItemEvent
ive noticed that sounds like pigstep or hurt sounds are bound to their loc(obviously)
ambient.basalt_ambient.loop(or so) also gets passed by the playSound() method.
HOWEVER, although its providing a location, it stays centered for the player no matter how far he moves away from the initial loc.
now as for my question: how can i use this behavior to my advantage to play music without relying on note block sounds?
like how is it determined which sounds are centered
increase radius
Ok yeah, that is not even remotely correct
Vector dir = e.getPlayer().getEyeLocation().getDirection();
dir.normalize().multiply(1.5F);
session.get().move(e.getPlayer().getEyeLocation().clone().add(dir), false);
return;```
So where is the mistake
Anyway to get a target entity?
what is session.get().move() ?
Literally just teleports the entity at the yellow particle to the given position
I know sharing ip is not really safe, but is it safe to share ipv4
Why do you think that it is safe to share an ipv4?
And why do you think that ipv4 is not an ip?
ipv4 is not my public ip you can use to conntect to the server
i assume you are talking about private and public ip
ipv4 IS ip (alongside ipv6)
ipv4 is just the way ip adresses are numbered
Hey Guys I have a Timer And I wanna make random time when time under 28. When Time Under 28 .It will pick a random number and fire an event when the timer reaches that second
But private ip addresses (so 127.x.x.x and 192.x.x.x) are usually not really dangerous
I shared 192.... ip
thats fine
can they get the real ip from it?
no
nice
It is the ip address your router assigned to you. It is only valid within your network
you have to do dir = dir.normalize.....
its not gonna change the dir
just return
what is the question there?
k thanks
well i just tried this
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Vector dir = event.getPlayer().getEyeLocation().getDirection();
dir = dir.normalize().multiply(1.5F);
event.getPlayer().getWorld().spawnEntity(event.getPlayer().getEyeLocation().clone().add(dir), EntityType.CHICKEN);
}
and it works
I want to make a random timer. I will Occur an Event at a random time. For example, it will choose a time, do this event. Pick another time and do this.
How can I generate a Random Time? I have already Random method. But I dont know how to generate random time with it
nextInt()
guys don't code plugins, make your own minecraft server, starting at: https://wiki.vg/Protocol#Login_Start
Math#random
thanks
Ok so what are the restrictions for the move event
Because even on monitor, it triggers extremely inconsistently
If I tab my move key, it only triggers sometimes
When I slowly move my camera, it doesn't until I move it a total of like 5 degrees
Can you send code
There is nothing to show for code
It's about the event triggering
Literally just add a printout to a event handler
you can make your own player move event kinda if you just schedule a task for every tick and check every players location
and if it changed trigger your "event"
That sounds inefficient as all hell
ah yes, people, dont drive cars, manufacture them yourselves
how can i make a local variable for each player with a different value?
^^
oh thanks
player objects get stale when they get offline
using player objects without knowing that will cause memory leaking issues if not handled properly
do those values reset when a player leaves?
No
oh
you need to delete values
the player object gets abandoned
if you store the uuid instead you can get the player object back whenever you need
okay thanks
still if player leaves the server, its better to delete any data regarding with him
depends on use case but yeah
So more vector math: I am trying to make a armorstand rotate so that it always faces the player, regardless of each others position, however it always seems to snap to -90 degrees.
So where is the mistake here, assuming that A is the armorstand location and B is the player eye location?`
public static float getYawToLookAt(Vector a, Vector b) {
Vector v = b.clone().subtract(a);
return (float)Math.toDegrees(Math.atan2(v.getZ(), v.getX()));
}```
like for example if you make a manhunt plugin or something and you wanna store who is the hunter then you dont want that information to be lost if someone relogs
?paste
I'm trying to listen for a packet and I'm getting Index parameter is not within [0 - 0)
Here is the code:
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(this,ListenerPriority.NORMAL,PacketType.Play.Server.REL_ENTITY_MOVE) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
packet.getShorts().getField(0);
}
});
The full error message: https://paste.md-5.net/sofuluciwe.apache
Any idea as to why this is happening ?
what version are you on ?
1.8
Oh, where can I find information about packets in 1.8?
I tried decompiling it but I didn't understand anythingπ
Like how did you know that it was bytes?
oh haha I'll look into the link you sent
Thanks !
I've found the source code for this packet, but it has 1 int, 5 bytes and a boolean
How can I check what does each variable stand for?
how do make leaderboard with player:stat list
you'll have to find out how the server uses them
NMS is not documented
thats the fun of nms you sorta have to guess
oh wow ok xD
and no one bothers mapping it because it changes each update
Well if you weren't on a horribly ancient version
you could be using mojang mappings to just guess
but, 1.8 developers deserve the suffering
Are you using mojang mappings ?
in which case, that would be just called Allay
not EntityAllay
Someone has a good vector tutorial?
Yea, check for Allay
that isn't mojang mappings but spigot iirc also uses mojang mappings for the new mappings
Hello, is it easy to implement PermissionsEx API into my plugin?
Welcome to episode seven of this introduction to game development in Unity with C#.
In this episode we discuss vectors in preparation for moving stuff around the game world in episode 08.
If you'd like to support these videos, you can make a recurring monthly donation (cancellable at any time) through Patreon: http://bit.ly/sebPatreon
Or a onc...
this video is good
Ty
just use JMonkeyEngine and get free movement
B)
(jk)
why bother with permissionsex
use luckperms
afaik it's deprecated plugin
lp is dog
Wat
The author of pex even discourages pex from being used
Well at least until it has been re-developed
LuckPerms is pretty much the permission plugin you ought to use as it is quite horizontally scalable with loads of features
I want to use permissionsex but I cant seem to get the dependency in
just gives red errors all over
What do you use? Maven or gradle
maven
Did you add the repo?
Yeah
No clue why it wouldnβt work then 
Might wanna visit the repo url to see what version is available
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ru.tehkode</groupId>
<artifactId>PermissionsEx</artifactId>
<version>1.22</version>
</dependency>
</dependencies>
<repository>
<id>pex-repo</id>
<url>http://pex-repo.aoeu.xyz</url>
</repository>
</project>
Wrong one I believe
^ official
thanks
I was strong hater of luckperms back in 2020's but I once i've tried to look for the luckperms wiki and instantly fell in love with Luckperms plugin
lp = dog permissionsex = OG
Hello guys, I'm trying to get the player by Name even if he's offline.
The only problem is that this returns null everytime... Can you help me please?
public static Player getPlayerByName(String name) {
if(Bukkit.getPlayer(name) != null) {
return Bukkit.getPlayer(name);
} else if(Bukkit.getServer().getOfflinePlayer(name).getPlayer() != null) {
return Bukkit.getServer().getOfflinePlayer(name).getPlayer();
} else return null;
}```
There is NEVER a Player for an OfflinePlayer if they are not Online
Augh, so how can I get his name
If a player is offline, then thereβs no guarantee the name will be present
or check if is valid
Mojang API
^
OfflinePlayer has his name
or usercache.json
If he has played before on your server
Bukkit.getServer().getOfflinePlayer(name).getName()?
use json parser to parse usercache.json and get its name through there if he joined previously, i bet there's an api method for this
Thatβd work
But it might hang the server as itβs blocking
that's quite inefficent I think
Yes. Still check his name != null
But it's checking if it exists
Exists?
way more efficient than blocking your whole main thread just for a name
Yep
By definition there exists an offline player for every uuid
So it will create an offline player no matter what
yes, if you get by name and the returned OfflinePlayer has the same name he has been on your server.
I think if you get a nonexistant OfflinePlayer by name the returned OfflinePlayer object will have a null name.
I explained myself worse than I could, Iβm doing a plug-in where I have to do /agency addemployer Name and I want to add so a dependent. The problem is that I want to make this happen even if they are offline. That's. It.
you are supposed to be adding them by UUID not name
even if he's online?
yes
Your SQL is all setup to use UUID
so by your definition every player should input uuid as an arg lol
And should a player do /agency addemployer hnetgiaetgynjameik-etgy41awegqw-gqegwq4q84-qwegqw451?
no
No
You use teh name to get an OfflinePlayer, then check teh name is valid, and use teh UUID from OfflinePlayer
You take the argument, you invoke getOfflinePlayer(name) (async) and then you invoke OfflinePlayer::getUniqueId
And store the uuid if needed or whatever
Sure! Just a last question, OfflinePlayer#getName returns the correct value even if the player is already online?
yes, unless they don;t exist
Yes
wOW
Why async?
The only occasion where it would not return any string is if the player has never joined the server and you used getOfflinePlayer(uniqueId)
Because getOfflinePlayer(name) might be blocking
^
cool!!! thanks!
elgar should put you among the creators of the plug-in directly for your ahaha help, thanks
So OfflinePlayers can return (If the player exists) player's own UUID and the name?
OfflinePlayer objects will always have uuids accessible
The name might not be if
the other way around nor?
wow! that's really absofantastic
how would it fetch an UUID if the name couldnt be associated with a player
well, getOfflinePlayer(uuid) creates an OfflinePlayer given the uuid and stores it in a weak hm, getOfflinePlayer(name) might make a call to mojang in order get the uuid by name and then it stores it to the hm by key (uuid) (hence why it may also be blocking)
yes, so it depends on the method you are using. there is a potential chance to just have one of the 2 values available
Indeed
@ivory sleet
public static boolean isPlayer(String name) {
return Bukkit.getOfflinePlayer(name).getName() != null;
}```
No that will always return true
in this case you want to check the uuid
wat, so how can I check if the requested player exists or not?
by using OfflinePlayer
An OfflinePlayer exists for every uuid
But if you get it through name, the server will make sure one exists still (by getting the uuid thru mojang conceivably)
and if the player was cracked? He would no longer contact the mojang and would always give invalid
we dont support piracy here
I made a guess as to who can use the plug-in
hi guys
you dont have to. online mode only
i need help plzzz
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Are you telling me that a plug-in like FactionsUUID or similar famous should do favor to this? Iβm asking a simple question, I would find it in cash or similar. There are millions of reasons, the server can be disconnected, offline...
but i cnt do it here
i cant get hashmaps working, when i try to store a value it, the entire server crashes
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
the server can be offline. f.e. in case of bungeecord, but you dont want to support cracked.
plzh help

show some code
logs
etc.
if (!ferro31.main.challange.challange.containsKey(player.getUniqueId())) {
ferro31.main.challange.challange.put(player.getUniqueId(), 0);
player.sendMessage(ferro31.main.challange.challange.get(player.getUniqueId()).toString());
}
That's an heavy values I think ahah
its just integers
hi were can i share my issu
Which version have the sound CHEST_OPEN for open enderchest?
in this channel
so why NOONE CARE ABOUT ME
you haven't asked anything yet
bro what are u on about
more context
we also would need an error
i cant acces the variable in my main class
u see none CARE
if there is a crash, there also is an error
where?
logs
none can help me?
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I mean anyone can give me the list of versions that have that sound for echest open
bro i told my issu 10 time
isnt it just something like ENDER_CHEST...?
Yes. but on 1.8,1.9, Its CHEST_OPEN
do you have a loop somewhere or anything else blocking?
How to translate an OfflinePlayer to an OnlinePlayer? (Player instance)
and I want to know all the version
OfflinePlayer.isOnline()
i believe OfflinePlayer has a #getPlayer method
np
otherwise just use the UUID to get the players instance
thanks!
@hybrid spoke can you help?
yeassh!! It has!
i tried somethign and it now works
I just want to know all versions that have CHEST_OPEN sound
can u help me?
what does this mean ?
oh thats what you mean
well there you would have to look through the Sound enum for the specific version
yes after you spammed it no one really cares
he was in wrong channel
and bombed my dms
How can i add Bukkit to 1.19 to use craftplayer?
Run BuildTools and depend on spigot not spigot-api
I'm coding a plugin that will make a road in the path of a thrown egg
I'm trying to listen to an entity move packet in order to track the blocks the egg has gone through altough I cannot find the right packet for that
What would be the right packet to use? (I'm using ProtocolLib)
new BukkitRunnable() {
@Override
public void run() {
//Code here
}
}.runTaskAsynchronously(PluginInstance());
It will create a new thread right?
will it close auto after doting the task?
yes
How can i get Players Ping in 1.19?
getPing()
Wonβt create a new thread necessarily
As it is using a cached thread pool
Since creating platform threads generally arenβt the cheapest things to do
But you probably donβt need to worry
Will it freeze the main thread if the plugin edits a yml file continuously?
Like in every sec
if you do it on the main thread, yes
if you don't, no
but
why the hell would you have to edit a yaml file every second
umm, I am making a custom chest plugin which save data in yml. so if there are many players and they tried to save items on the chest, it will lag
Yeah do that asynchronously and no issues should be encountered, altho you might wanna use a ReentrantReadWriteLock or an async file channel to make sure everything is thread safe
Perfect thanks lol. I didn't thinked thats so easy with the old craftplayer etc
yeah there's like 20 new api methods in player in 1.19 lol
Whats the reason for saving to yml?
I have added 2 way. in db and yml.
so if anyone choose yml
What data are you saving?
EDIT: getPing was added in 1.17
list of Itemstack
any reason you are not storing the data in teh chest PDC?
If its specific to that chest
So for rendering items in the world?
Could I make a invisible item frame rise a freely positionable armorstand?
Could that work, or will the frame break?
do you want to show a "dropped" item?
No, a static item
you can make an itemframe "fixed" by using ItemFrame#setFixed
When true it's not possible to destroy/move the frame (e.g. by damage, interaction, pistons, or missing supporting blocks), rotate the item or place/remove items.
Excellent
the armor stand should be able to hold the item without need of an item frame..
Yeah, but positioning will be a nightmare
Because, so render the a block at a consistent size, you'd need to have it be a held item rather than the helmet slot
Which introduces all sorts of issues with alignments and offsets to have it stay centered
not true entirely..
Elaborate
you can put an item on a armorstandβs head and it wonβt change the size ?
Blocks will
ohh blocks
Blocks will be rendered differently in the helmet slot
itβll be their item form Β―_(γ)_/Β―
in my past experience itβs the item form of it ..
unless itβs changed since 1.8 i donβt think so
Blocks do not have a "item form"
sad block :<
Yes, but a block model overrides the gui and armorstand display properties differently
weird Β―_(γ)_/Β―
Here is what a block looks like, rendered in the helmet slot
Well, regardless
Next question!
How do I add a second entity as a passenger to a nms entity
And what extra packets will need to be sent to have the client receive the fake entities
Is it possible to create a thread onEnable?
of course, why not?
onLoad?
these are just methods in Java
are you talking about a thread or using the scheduler?
you cant run a task when the plugin isnt enabled yet
so it wouldnt work in onload iirc
you will need to have the plugin enabled to use the scheduler
this gets called in every method of the CraftScheduler
is there a basic guide / quickstart for how to make a library plugin?
that doesnt really help me
could you just answer the question?
not sure what you wanna say
Not really. Do you want a library or a Plugin
and that's it
If a Plugin then you are talking about a PLugin API
you can just make a library and shade it into ya plugin
So, more NMS questions
ArmorStand builder = ArmorStandBuilder.nametagArmorStand(new TextComponent("test"), loc);
ItemFrame frame = EntityType.ITEM_FRAME.create(((CraftWorld)loc.getWorld()).getHandle());
frame.setInvisible(true);
frame.setInvulnerable(true);
frame.setItem(CraftItemStack.asNMSCopy(item), false);
builder.getBukkitEntity().addPassenger(frame.getBukkitEntity());```
I am creating the entity like this
And spawning it like this as a fake entitiy:
PacketUtils.send(p, stand.getAddEntityPacket());
PacketUtils.send(p, new ClientboundSetEntityDataPacket(stand.getId(), stand.getEntityData(), true));
List<Pair<EquipmentSlot, ItemStack>> stacks = Lists.newArrayList();
for(EquipmentSlot s : EquipmentSlot.values())
if(stand.hasItemInSlot(s))
stacks.add(new Pair<>(s, stand.getItemBySlot(s)));
if(!stacks.isEmpty())
PacketUtils.send(p, new ClientboundSetEquipmentPacket(stand.getId(), stacks));
if(!stand.getPassengers().isEmpty())
PacketUtils.send(p, new ClientboundSetPassengersPacket(stand));```
However, the riding entity is not shown, or even present
So, what am I doing wrong?
(The armorstand is present, however)
ok no what i want is a plugin that has an api that can be used by other plugins
if the api is small just make an interface that you implement
how do i set it up so that i can even access that interface in the first place
i'd create a separate project that only has interfaces. your main plugin implements these interfaces. then you can upload the API project to some maven repo
hi,
how to remove attack heart particle ?
Thats just getter methods
Oh, I see
The passengers packet only references entity ids
So I need to send a fake entity of the frame to the player first
can i include the jar file in maven instead? like you can do with worldedit api for example
idk how to do that in maven tho
i used to do it using default java project
yes sure
Jitpack 
:vomit:
how do i add a jar file as maven dependency
it's also slow as hell and uses weird build numbers
not if you make a proper release
and how would it even work with spigot as dependency instead of spigot-api?
not that slow lol, its build numbers are the tags of the publish
idk I rather use nexus
Not if people publish artifacts on Github properly
hm i guess i can google that anyway thanks for the help
you don't
you install it instead
"adding a .jar" is actually what maven is trying to avoid
and why it exists
search "maven install 3rd party jar"
IntelliJ build moment
omggg blogger
OH NO
This would have been the perfect solution
But item frame entities are block grid aligned
Can I bypass this somehow
why dont you just spawn an item
Because, again, it is supposed to be static
no idea what you mean with "static"
not moving
Non-moving
i guess
public static void itemstack moment
you can modify the velocity of a dropped item right
why not let an armorstand hold the item?
The entity renderer of a item entity can't be modified with properties iirc
i havent been reading the convo so idk if thats possible
Asymetrical positioning, which introduces all sorts of issues for rotation and facing
Easier said than done
yep
Besides, my icon system is not really designed to individually move armor stand parts
So, back to the actual question
Can I bypass the snapping to the block grid
Hi! Yesterday I asked for help with my menus, and some good souls tried to help me and I thank them very much, but because of my noob English, I didn't explained properly, so I didn't managed to get the answer that fixs my problem, after A LOT of research, errors, problems, ways, I tried another way, without using a Menu Manager or Menu interface, etc.
The idea behind my problem is that I'm trying to make a class that creates a menu for each 'ID' from my custom config automatically. So I ended with this code: https://paste.md-5.net/onesituwef.java
The code works, but I want to know if this is the correct and optimal way to this. Thanks π₯Ί
Why dont you use UUIDs
public static Player getPlayerByName(String name) {
return Bukkit.getOfflinePlayer(name).getPlayer();
}```
Seems return null, any idea?
the player is not online
player you're looking for has not been on the server
ah wait
nvm
what alex said ^
Bukkit#get-Offline-Player
good question, but where I could use uuids? π
?
There's a method .getPlayer() inside the OfflinePlayer class
yes
you cannot get a player object from offline palyers that are not online
which only returns the player if hes online
which ONLY returns a Player IF the Player is Online
thanks x2 to everyone ahah
How can I check if the returned object (Bukkit.getOfflinePlayer(name).getUniqueID()) is from a valid player? OfflinePlayer class always returns an object.
just call OfflinePlayer#isOnline()
thanks
if he is it will return a uuid, player
This is the code of a custom mob I created
public class DiamondChicken extends Chicken implements CommandExecutor {
public DiamondChicken(Location loc){
super(EntityType.CHICKEN, ((CraftWorld) loc.getBlock()).getHandle());
this.setPos(loc.getX(), loc.getY(), loc.getZ());
this.setCanPickUpLoot(true);
this.setAggressive(true);
this.setCustomNameVisible(true);
this.setCustomName(new TextComponent(ChatColor.GREEN + "Test"));
}
@Override
public void registerGoals(){
this.goalSelector.addGoal(0, new AvoidEntityGoal<>(this, Skeleton.class, 6f, 1d, 1.2d));
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, ServerPlayer.class, 8.0F));
this.goalSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, ServerPlayer.class, true, false));
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players can use that command!");
return true;
}
Player player = (Player) sender;
ServerLevel wrld = ((CraftWorld) player.getWorld()).getHandle();
DiamondChicken entity = new DiamondChicken(player.getLocation());
wrld.tryAddFreshEntityWithPassengers(entity);
return false;
}
}
And this is the error I get when I compile
java: cannot access java.util.stream.Stream
class file for java.util.stream.Stream not foun
Maybe I do even better explaining myself maybe even better from the beginning. Iβm doing a plug-in that allows adding players to an agency. I want to make sure that the "boss" of the agency can fire or hire employees REGARDLESS of whether they are online or not.
Employee are stored as UUID
(And the command usage is: /agency hire/fire [PlayerName]
actually, it seems that you can easily create a maven repo for free using github, so ima try do that instead
Bukkit.getOfflinePlayer(name).getUniqueId()
assuming they have played before so nullcheck that
Is there any way to register my own block? I mean I can do it now like minecraft:my_block but that block exist only on the server side (not client) so player can't see that block and interact with it. I'd like to register my own block where the model is already exiting minecraft block, is it possible?
So, to check if the player exists I need to do .hasPlayerBefore()
i forgot if the getOfflinePlayer is nullable
Player probablyRealPlayer = Bukkit.getOfflinePlayer(name);
UUID probablyUuid = probablyRealPlayer.getUniqueId();
if(!probablyRealPlayer.hasPlayerBefore) {
//DO STUFFS
}```
no?
probably better off checking if the uuid is null or not
ah yes yes hasPlayedBefore
but mye we do not like web requests
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#getOfflinePlayer(java.lang.String)
declaration: package: org.bukkit, class: Bukkit
OfflinePlayer always return an Object
UUID
the thing is that i've looked to the whole sourcecode and i didnt see code for a webrequest anywhere lol
ItemMeta meta = event.getItemDrop().getItemStack().getItemMeta(); meta.setDisplayName("Β§6Β§lTaser Β§eΒ«" + (getCurrentAmmo(event.getItemDrop().getItemStack()) + 1) + "Β»Κ"); event.getItemDrop().getItemStack().setItemMeta(meta);
No errors, but the names doesn't change.
so, can anyone check my code and tells me if its okay? please π
getOfflinePlayer(name) will always return a result. However teh generated UUID will be an offline UUID if the player is invalid. You can compare this to see if the object is valid
what am i doing lol, downloading a dotnet sdk for linux lmao
Are you referring to a comparison in mysql?
How to get the entity that a player is looking, i tried something with rayTraceEntities but canβt be done
no
rayTraceEntities is what you should use
Yeah, i know. But how ?
I am over the moon! I did it!
start is the player head location
direction is direction of player head
maxDistance is how far you want to check
declaration: package: org.bukkit, interface: World
^
it seems to me to be a viable solution in the use of block states. I mean, this will enable a way to make almost fully custom blocks with your own texture (server resources + blockstates)
but like itll just fetch from mojang servers if not
so why do u need to nullcheck that lol
i said nvm after that
use forge
π
no
Hello friends, I have a super hard time wrapping my head around System.currentTimeMillis() can someone explain to me like im 5 how to check if 60s has passed using this?
60000
just to somehow mimic the functionality that u can easily achieve with forge
Is 60 seconds
yep yep
60s is 60000 miliseconds
add 60000 to currentTime and then compare that later
just multiply by 1000
store the System.currentimemillis to some variable and then compare it back after some time with the current system.currenmillis
So let's say u do past = currentMillis
uhhuh
Then now u do timeElapsed = currentMillis - past
if past + 60 * 1000 >= currentMillis
If timeElapsed is more than 60000
ohhh
It's more than 60 seconds
is it based on when the program was first run?
TimeUnit.MILLIS.toSeconds smh
yes
No
its based on your computer
its based on the epoch time
its epoch
π€
This method returns the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC
so how? I tried to register mappings and it works, but without model
Block model = Blocks.REDSTONE_BLOCK;
Block block = Registry.BLOCK.registerMapping(Registry.BLOCK.getId(model),
ResourceKey.create(Registry.BLOCK_REGISTRY, new ResourceLocation("minecraft", "x")),
new Block(BlockBehaviour.Properties.copy(model)), Lifecycle.stable()).value();```
you will have to modify the client in some way though
since it wouldnt know how to render that block
u can probably use resource packs
learn new things every day
but u shouldnt
at that point just use forge mods
whether you can or you should are two different things x)
sure do it if u wanna waste ur time
since u can do that in forge in a few minutes
its one of the most easy shit in forge
I think you can register ur block. I mean I have achieved it with custom entities π
u can use hybrids maybe
custom entities arent actually custom
ur just copying another entity
and modifying it
I mean registration
so you made a whole new entity?
How I can disable create end portal?
so you can do e.g. /summon my:entity π
cancel event
mhm but did you extend any entity
in your code
what event?
extends PathfinderMob
and you gave it a custom texture?
not really, you can set any existing entity model
also isnt that a forge class??
it actually is tho
declaration: package: net.minecraft.world.entity, class: PathfinderMob
You will have to inject your block in to the block registry during load time. Then in every packet replace it with the vanilla block
import net.minecraft.world.entity.PathfinderMob; mojmap
forge mod interperter
The block registry is locked quite early in the loading process you may need to patch the server jar directly
its spelled interpreter but ok
ok
gambling
you mean frozen registry? Or smth else?
Yes
so I already fixed it
The block is registered normally, but the problem is that it doesn't have a model to be displayed to the client. Have I track packets and replace it with my model block or is there any other way to set default model to the vanilla block?
As a result of a server crash, there doesn't quite seem to be enough time to send hundreds of SQL updates to the database in time, which leads to data loss. So during the event of a crash I came up with the idea to store the data to local files instead, which would occur within milliseconds. The local files would then be read and applied to the SQL Database upon the next server startup.
Feedback on this idea would be great!
A server crash halts all code execution, unless you are running your own process. You don;t have time to save to SQL, you will not have time to dump to file
So I'm importing variables from config, then loading listeners, how to reload them? if I reload config it only reloads itself, listeners are registered already with old data, can someone explain it how to make it work?
in the listener you can getHandlers().unregister(this)
What about commands? (setExecutor)
PortalCreateEvent i guess
how can i use like a "text" aspect with in functions?
Example:
public void randomFunction(*Idk what to put here...*){
// Code here
}
or do i just leave it blank?
uhh a String?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
This is really basic Java
yes
alr thx
Dude i forgot chill out lol
nobodys perfect lmao
exactlyyy
forgot π
My point was that your question was a really simple and basic Java question. Not a spigot one. You should at the minimum attempt a google search to find the answer.
Yeah i did and it didnt help
So apparently if you zip a resourcepack directory minecraft won't recognize it but if you zip the CONTENTS which keep in mind both give the same output, minecraft will recognize it. Anyone got ideas how i can achieve the latter programatically?
are you sure your first zip is not including teh root folder?
yeah
not working version
working version
exactly the same contents
contents are identical
very odd indeed
im stumped lol
there has to be some difference for MC to reject it
yeah, can't seem to find anything on stackoverflow
Check the sha1 of both files
yeah good call
Was there a difference
working:
3c4774cf546264b0c5a52241b7345b19aaf941eb
not working:
33f9bf8322306c60fc2e7e9b3a0b80c9422fb1fd
thats sha256 tho
SHA1 is the same anyway
Yeah
don't work π
onDisable() doesn't get executed on a server crash?
simple sha1
of course not. it crashed
i imagine that will affect it but idk
by the looks of it, it doesnt
public static void pack(String sourceDirPath, String zipFilePath){
sourceDirPath = getDataFolder().getAbsolutePath() + "/" + sourceDirPath;
zipFilePath = getDataFolder().getAbsolutePath() + "/" + zipFilePath;
try {
Path p = Files.createFile(Paths.get(zipFilePath));
try (ZipOutputStream zs = new ZipOutputStream(Files.newOutputStream(p))) {
Path pp = Paths.get(sourceDirPath);
Files.walk(pp)
.filter(path -> !Files.isDirectory(path))
.forEach(path -> {
ZipEntry zipEntry = new ZipEntry(pp.relativize(path).toString());
try {
zs.putNextEntry(zipEntry);
Files.copy(path, zs);
zs.closeEntry();
} catch (IOException e) {
System.err.println(e);
}
});
}
}catch (IOException e){
e.printStackTrace();
}
}```
this is my current zipping method
get the same sha if i manually zipped it though
Hiya, hope i didnt intrude anything, i've been trying to setup custom recipes and the issue is that it needs a plugin and i dont want to pass in plugin to every item i want to create, however i need to pass the item as well. Is there anyway to avoid passing the main plugin as a paraemter if i want the create recipe in the same class as the item as i want to avoid this:
Or is this the most efficient way
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
weird, so maybe disable placing the end portal block?
how to access a EnderDragon's attribute modifier?
i should modify it like this ?
and is dragon's default health 200 ?
if theres no setter you'd have to use reflection
@river oracle
this works i googled
π€
why when i spawn the dragon it just stays there with no move
Presumably the health of the dragon is changing the phase from what you set it to
Or for some other reason itβs rejecting your phase change
it worked after i changed
?
So it was the health, makes sense
and why it's bossbar is not showing
i have my bungee config loaded in the default java file (like where all the startup logic happens)
how do i make it so that i can access the config everywhere without loading it in each file?
Pass the object instance around
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
What rank api should I use in my plugin when creating a setRankGUI
Most often "Ranks" are managed by your permission plugin
if your plugin needs to read ranks/permissions then hook vault
How can i make a custom recipe that ignores the Position of some items?
It needs all 4 types of skulls but ignores where they are?
yo is potion effect duration in ticks or seconds?
But then it didn't need to be ordered like on the screen?
You can;t have both order and orderless
So then i need to create 4 recipes
you either need to just accept ALL ingredients, or register a ShapedRecipe for every order