#help-development
1 messages ยท Page 2201 of 1
then go to #help-server
sure, np
but as said you should rather compare the squared distance
because getting the square root is a bit expensive
how does java sqrt numbers? using newton raphson?
idk, it's a natice functino
also for the living entity checking, how would i go about that? also idk if the original entity is living, as this is entity damage by entity and the entity might die
entity instanceof LivingEntity
o
what entities are not living? zombies and stuff?
arrows
items
public static HashMap<Location, Material> map = new HashMap<>();
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) {
Block oBlock = e.getBlockReplacedState().getBlock();
ItemStack blocks = new ItemStack(Material.SANDSTONE, 64);
e.getPlayer().getInventory().setItem(4, blocks);
map.put(e.getBlock().getLocation(), e.getBlock().getType());
BukkitTask runnable = new BukkitRunnable() {
@Override
public void run() {
e.getPlayer().sendMessage(oBlock.getType().name());
Block blockPos = e.getBlock();
blockPos.setType(oBlock.getType());
map.remove(e.getBlock().getLocation(), e.getBlock().getType());
}
}.runTaskLater(LobbySystem.getInstance(), 40);
}```
Is there a way to get the block which was replaced with the block I place in my event? Atm oBlock ist the block I place, not the old one :/
zombies are living. basically everything that has a "health" is living
ah i get it
event.getBlock?
that is the placed block, I need the old block (for example grass)
mhm comparing locations goes brr
try getBlockReplacedState
although wait no
I already use that
that's also wrong
Anyone know why I get an error at line 51 when putting in an ItemStack that isn't an item in an inventory?
hm then no idea
what is the error you're getting?
NullPointerException
does the BlockBreakEvent gets called when I place a block?
uhh obviously not
a newly created item will not have any itemmeta
no, that would be quite counter productive
So shouldn't the second return get called?
the playerjoinevent also doesnt get called when a player quits ๐
do you have any other solutions for this?
oh yeah mb. send the full stacktrace or we can all just guess
seems like getBlockReplacedState is supp to work
but they already use that
uk #hasItemMeta() exists
yea ik, but in my case its just the blockstate of the placed block
imo it should lmfao
the "replaced block" is the block which was there BEFORE the block was placed
also here are the line numbers
let us call every event on EVERYTHING that happens
they want to get the blockdata of the block that is about to be placed
excellent idea!
gosh
so uhm, any solutions?
I want to get the block that was there before I placed the block
Anyone knows if a setting for maximum paricle render distance exists?
do u want the block that is replaced, eg if you place a dirt block in air, do u want air or do u want data abt the dirt block or air?
for example if I place a block in a grass the block is grass yk?
save it somewhere on blockBreakEvent, and then get it on BlockPlaceEvent
i want to get air in your example
ohh well use the blockstate
dont get the block from the blockstate
yea, the blockstate afaik is the one that was there before
let's just call it all the time
new Thread(() -> {
while (true) {
Bukkit.getPluginManager().callEvent(new PlayerJoinEvent(Bukkit.getOnlinePlayers().stream().findAny().get(),"lol u joind lol"));
}
}).start();
the block is always up to data, blockstate is a snapshot of what was there
GOSH
uhm lol
that doesnt even work
I think it might actually
you can't use such "default" events
can I use BlockState#getType()?
yep, that's exactly what u need
they error out instantly when you enable the server
nah that dont work
ill try, ty
that cannot work. Event is an abstract class and doesn't have any HandlerList assigned
sad fair enough
if you want to listen to all events, you have to do some tiny reflection magic
i tried to use BucketEvent before, imo kinda sad it doesnt work
I was a bit surprised that I got the little eventhandler icon from my ide
it requires the use of 20 event handlers in some places
lol
or maybe just 2... who knows
when I replace a grass it places a dead bush, how can I fix this?
that icon
ye if any1 is actually interested. https://www.spigotmc.org/threads/listening-to-all-events-listing-all-events.337466/
I think it's some kind of custom annotation thing
huh?
*annotation
1sec, ill send you a screenshot
I thought it was saying that it's implemented in eventhandler
"Go to event declaration"
before and after
dont talk to me if you dont run on the spigot virtual machine
I think there is smth wrong with the bytes
what mc version?
nice watch
its outdated, 1.8.8 so I wont get support ik but it would be nice if you could help me anyways ^^
thank you ๐
so... you want to get the block that was broken, and later get it when you place a new block on it?
1.8 is half as old as you lol
true xd
holy fuck
wait a sec why are u setting the block back to grass?
cant u just cancel the event?
god, time flies so fast
no, I want to blace a block which is getting removed after 40 ticks and does not change anything in the world yk?
please
ahh
https://howoldisminecraft188.today/ never mind it exists
Too old! (Click the link to get the exact time)
I want to get the broken block and set it after the 40 ticks again
2 more years and its the half of my age lol
well u can use data from the blockstate to set the correct data back to the block
okay, ill try
dang there's probably an official list somewhere
I hate having to type this all the time ```xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
can't intellij add the executions part automatically?
should I use MaterialData or bytes?
noone ever adds the shade plugin without declaring a goal and a phase
true
i forgot lol, just try materialdata, then bytes
okay, so how can I set the MaterialData again? lol
I only can find the method to set the bytes
would this work?
public class PactCommand implements CommandExecutor, Listener {
like can i implement 2 things like this
wdym?
yes, I think so
i'd say so
when registering, just make sure do not initialize it 2 times
so just call this method after setting the type?
uhm
im confused
idk what you mean
if I dont set the type the block wont get replaced?
np
do I have to understand this? xd
yea
lie! a blockstate is like a huge bowl of crack cocaine
why am i getting this error java.lang.NullPointerException: Cannot invoke "org.bukkit.configuration.ConfigurationSection.getInt(String)" because "sec" is null from String title = e.getView().getTitle(); String[] words = title.split("-"); String name = words[1].replace(" ", ""); Bukkit.broadcastMessage(name); ConfigurationSection sec = fc.getConfigurationSection(name); im trying to get all the text after "-" and get a config section with that text but its saying sec is null, yes 100% the configuration section exists
e.getBlockReplacedState() gives you what the block was before it was placed
because as it says "sec" is null
that doesnt help me though
yes
when u use BlockState#update, it basically sets the block back to the blockstate
well if something is null, you cannot call methods on it. because it's simply not there. and that's why you get this error
ohh, that makes sense
so since the blockstate is from before the block was plasced, it basically rolls it back
thank you soooo much!
yes and im asking WHY i get this error read what i said i dont think i should be getting this error
you get this error because you call "getInt(String)" on sec although sec is null. You should instead check if "sec" is null and if yes, do not call any methods on it
there is no section with the name of whatever name variable is
and I told you why you get this error
like three times already now
ArmorStand armorStand = loc.getWorld().spawn(loc, ArmorStand.class);
armorStand.setCustomName(Utils.formatString(colour + damage + suffix));
armorStand.setCustomNameVisible(true);
armorStand.setGravity(false);
armorStand.setVisible(false);
armorStand.setSmall(true);
armorStand.setBasePlate(false);
armorStand.setInvulnerable(true);
armorStand.setSilent(true);
armorStand.setMarker(true);
armorStand.setRemoveWhenFarAway(true);````
i have this code to spawn a damage indicaotr, but for a split second the armor stand is visibke how can i fix that
there is though this is my config test: dem: 1 and when i broadcast name i get "test"
you are very unhelpful
finding my messages helpful requires a basic understanding of how java works, I guess most people here can agree with me on that
well, for some reason the configsection is null, most likely cuz it doent exist
if i were him, i wouldn't even try helping you
there is literally nothing to help, you cant do smth on smth that doesnt exist which is also known as null
telling me its null doesnt help me at all i have eyes and i can see it says "null"
try do debug
if someone said the way your regex is is wrong that would help
see if the section exsits or something
fwe things
- are you loading the config?
- is it updated on runtime? if so are you reloading it?
- are you sure it exists and ur accessing it the right way
- yes
- what
- yes
send your complete config.yml and pls also tell me what's the name you're using for the configuratinosection when you try to get it
2: are you updating your config while the server is running, without restarting/reloading the server
is there a way to make arrows not disappear after hitting a target? Also for removing the imunity frames for arrows but not for melee
yeah? im using fc.save(f); if thats what you mean
meanwhile could someone look at this? i should probably ask this after their thing is over but
dem: 1``` "test"
is that the content of the config.yml included in your plugin, or did you also actually save that file in the plugino's datafolder? because IIRC you cannot get configurationsections from the default config but maybe I'm also confusing things
i create the config section after the plugin is loaded there is nothing in the file when the server loads
I'm pretty sure there's a way of creating an entity object, then spawning it, but I can't remember how
soo that might be the issue
you're not loading it properly
YamlConfiguration fc = new YamlConfiguration();
try {
fc.load(f);
} catch (IOException | InvalidConfigurationException ex) {
throw new RuntimeException(ex);
}```
Ya you're loadfing the empty file
instead of doing "getConfigurationSection()", do this for debugging
Object result = myConfig().get("test");
if(result == null) {
System.out.println("result is null");
} else {
System.out.println("Class: " + result.getClass().getName());
System.out.println("toString: " + result);
}
it has nothing in it
? im trying to get the configuration for it so i can use fc.getString(etc);
P.P
im talking to u
oh
in that case
you're loading the empty file
its literally empty
and ur not updating it with the new contents
pls
Yeah there is test: demo 1 in the file on the hard drive
not the memory of your plugin
you need to load it again after you change it
toString: MemorySection[path='test', root='YamlConfiguration']
oh then you int is simply not set
can you clear an NbtTagCompound?
if you do stuff like
getInt("my-int") and the config doesn't include "my-int" then it'll fail because of auto unboxing
Who could help me?
thats not the issue though its saying its null
well if it isnt there.... its null
in your first error, it clearly told you that "sec" is null. now the debug statements show that it's actually indeed a MemorySection. try to replace get with getConfigurationSection again and see if it's still "not-null"
- just tried it with
sec.set("test", "d")and im getting the same error
so im not getting anything
sec is test config section
hey Guys I'm setting player Inventory's content to config. but Its setting empty slots too. Ant Its making ItemStack null. How can I set just ItemStacks
inventory#getContents()
if u set a path to a string, it's no longer a config section
well you kinda need the null itemstacks to keep the original slots of items, don't you?
I have already done it. Its setting null slots too
ye
getContents should only return the not null values if im not mistaken
/wait so whats ur issue
no, getContents returns an array like this
[firstItem,null,null,anotherItem,null, ...]
let me send ss
it's always fixed length no matter if the inv is full or not
so you basically want to remove null elements from an array?
if so just use Arrays.stream().filter(Objects::notNull).toArray(new ItemStack[0]);
Don't know how to set network ID of my thing so it's not shown as a pig to clients ๐ค Only example I can find means redoing it entirely in a way I don't get
this is more like how you should do it if you wanted to load a file from the resources folder
https://github.com/FourteenBrush/xKingdoms/blob/b2ff9d794c6cca07335dff93254e9c8deda49d81/src/main/java/me/fourteendoggo/xkingdoms/utils/Lang.java#L13
hey does anyone know if org.bukkit.block.Bed exists in 1.8.8 ? It doesnt work on my end... there's probably smth else i could use
i dont want the material bed i want the block bed
isnt there BED_BLOCK ?
yeah
just... continue if the item is null..?
like when iterating over it
just continue if the item is null
i'd rather save the slot number too but i forgot how to do so
But it will always null, wont it ?
I guess I spawned a bit too many particles xd
Okay Let me try something different Thanks Guys
that must have been a LOT of particles
how many ram do you give it lol
or just 200mbs of ram
is that even enough to start it? ๐
Ye
32gb but I think I only allocated 1gb
well
default vm memory is 250mb iirc
you can start minecraft with it
it was Mob_Appearance particle I guess the game doesn't like it several hundred times every second
are you sure? my mc takes like 600mb just be being open in the main menu
Please tell me how to implement deletion from the database, I tried this way, but I got an error?
public boolean exists(UUID uuid, int type_implant){
try {
PreparedStatement ps = im.SQL.getConnection().prepareStatement("SELECT * FROM implants WHERE UUID=? AND ID_OF_IMPLANT=?");
ps.setString(1,uuid.toString());
ps.setString(2, String.valueOf(type_implant));
ResultSet result = ps.executeQuery();
if(result.next()){
return true;
}
return false;
}catch (SQLException e){
e.printStackTrace();
}
return false;
}
This is error:
[22:55:47] [Server thread/WARN]: java.sql.SQLException: Can not issue executeUpdate() or executeLargeUpdate() for SELECTs
What happened to org.apache.commons.lang.Validate? It does not work anymore on 1.19, but did last on 1.18.2?
playerdata has locations of players where they have left right?
close your stuff please
RIP this is not good. use a try-with-resource block instead pls
i have a /warp command is it possible for me to somehow teleport the person to that location where they have left THAT world
well SELECT != delete
what's the correct way of loading a custom world created via worldcreator?
Guys Its Good ItemBuilder ?
I can't find any methods to load one, and after a restart Bukkit#getWorld returns null
thats not a builder
Can't I use it?
of course you can
it will work ye but maybe you want to overload it with an amount for the itemstack
oh yes..
I dont know how.. Actually I also tried something like that first time.
oh thanks
a builder class is usually a class that holds all the required information to create the finished thing, so in your case material, name, amount etc. and then you can turn it into the actual result using .build() or .bake() or however you decide to call that method
I'm always only thinking in crack cocaine 
Thank you Guys ๐
Sorry, I sent the wrong code. Here is the correct code, but it still doesn't work. Now it doesn't even throw an error.
public void removeImplant(UUID uuid, int id_of_implant){
try {
PreparedStatement ps2 = this.im.SQL.getConnection().prepareStatement("DELETE * FROM implants WHERE UUID="+uuid+" AND ID_OF_IMPLANT="+id_of_implant);
return;
}catch (SQLException e){
e.printStackTrace();
}
}
then you probably do not have any entry where UUID = uuid and ID_OF_IMPLANT = id_of_implant
ugh
I cant type today
use a try with resources
try (Connection conn = getConnection(); PreparedStatement ps =
conn.prepareStatement(sql)) {
// your stuff
}```
that will basically call #close on it after the code block finished
try to use SELECT first and see if you actually find any matching results
?paste
very simple primitive example https://paste.md-5.net/uyazubepuc.java
?potato croquet
potato croquet huh
thanks ๐
AbstractItemStackBuilderFactory implements AbstractBuilderFactory<Factory<ItemStack>>
oh yessss dude
so fancy
im legit so pleased with this new way of player input i now got
ip.rightBlockClick().orTimeout(10, TimeUnit.SECONDS).whenComplete((secondary, throwable2) ->
{
if (throwable2 != null) {
Common.tell(player, "Error: " + throwable2.getMessage());
return;
}
displayTo(player);
updateMenu(true);
});
i can now take player interactions as input easilly
What happened to org.apache.commons.lang.Validate? It does not work anymore on 1.19, but did last on 1.18.2?
are you using maven?
I am using gradle
ah idk gradle sorry
because IIRC you need spigot instead of spigot-api for those libs
perfect! np
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/profile/PlayerTextures.html
Is it possible to actually insert a base64 texture? Otherwise, this seems to be kinda useless to me
declaration: package: org.bukkit.profile, interface: PlayerTextures
no. you have to provide an URL
Guys When I set ItemStacks of Items on GUI. Its doesnt setting. but When I set it on Command Class Its setting. Can't I set these Items on another class?
which you can do by simply decoding the base64 string and then throwing into the URL constructor
well a base64 texture is an encoded url so
Oh wait, for real
I try use this code but it doesn't work
public void removeImplant(UUID uuid, int id_of_implant){
try {
PreparedStatement ps2 = this.im.SQL.getConnection().prepareStatement("DELETE * FROM implants WHERE UUID="+uuid+" AND ID_OF_IMPLANT="+id_of_implant);
return;
}catch (SQLException e){
e.printStackTrace();
}
}
oh wait no not exactly
I always thought it contains the texture itself and not only the url
the base64 look slike this
{"textures":"https://..."} IIRC
I wouldn't worry to use the playerprofile class but instead do it like always
How can I get if it was a specific arrow which hitted?
Entitydeathevent
But when I try to check whether this object is in the database, then it is. Code to check:
public boolean exists(UUID uuid, int type_implant){
try {
PreparedStatement ps = im.SQL.getConnection().prepareStatement("SELECT * FROM implants WHERE UUID=? AND ID_OF_IMPLANT=?");
ps.setString(1,uuid.toString());
ps.setString(2, String.valueOf(type_implant));
ResultSet result = ps.executeQuery();
if(result.next()){
return true;
}
return false;
}catch (SQLException e){
e.printStackTrace();
}
return false;
}
u never even execute the statement
The reason why skulls would cause lag in the past was because the server would look fetch for the uuid given by the username, and not the texture itself? While the player later has to fetch the texture again? This sounds like a horrible implementation...
lol true
I do it in another file
how the fuck would you get a local var in a another file
Bro What does it do?
it creates ItemMeta
lol sorry
sometimes I'm just here to annoy people
yes lol
and you put this. on every varibles but Why didnt you put this on amount?
this
public void removeImplant(UUID uuid, int id_of_implant){
try {
if(exists(uuid, id_of_implant)){
PreparedStatement ps2 = this.im.SQL.getConnection().prepareStatement("DELETE * FROM implants WHERE UUID="+uuid+" AND ID_OF_IMPLANT="+id_of_implant);
}
return;
}catch (SQLException e){
e.printStackTrace();
}
}
I mean why didnt you use this.amount in there
This is error:
java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
Oh Okay thanks
you are still never eexecuting this.
if(exists(uuid, id_of_implant))
though it is odd getting an SqlException without executing anything
you are just creating an prepared statement, abusing it by not using the features it provides to actually prepare statements, and then never execute it
oh he does call exists
๐คก
but wtf does "exists" do?
prolly this
no they are never executing it. they create the PreparedStatement called ps2 and that's all they do
Then how should i do this?
then they wait for it to get GCed
execute it xD
yeah lol
What is executeUpdate?
that's the method you should use to execute the deletion
and you should also use ? in your preparedstatement instead of "hard pasting" the UUID etc
because otherwise using a preparedstatement in the first place makes no sense
Okay, when i use this code, i have an error
public void removeImplant(UUID uuid, int id_of_implant){
try {
if(exists(uuid, id_of_implant)){
PreparedStatement ps2 = this.im.SQL.getConnection().prepareStatement("DELETE * FROM implants WHERE UUID="+uuid+" AND ID_OF_IMPLANT="+id_of_implant);
ps2.executeUpdate();
}
return;
}catch (SQLException e){
e.printStackTrace();
}
}
you are never closing the stuff either
for weird reasons I don't currently have access to your computer and so I cannot find out what the error says, so it would be very helpful if you could send it here
lmfao
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '* FROM implants WHERE UUID=6d9d3fea-d7d7-34a1-bd62-117d724b982b AND ID_OF_IMP...' at line 1
you should really just properly use the prepared statements instead
and you might wanna format it properly yea
just use prepared statements and it will automatically escape the UUID
WHERE UUID=?
ye just using prepared statements and try with resources and everythings fixed
yes hikaricp is nice
is there a good tutorial for a custom item with an interact anywhere
can you try to rephrase that? ๐
all i find googling is infinite threads of people asking and getting no response
sure go ahead
senc code
send code
trying to make an item to spawn my custom minecart (like a normal minecart item)
basically this enum and the connectionprovider class in the same package
https://github.com/FourteenBrush/xKingdoms/blob/master/src/main/java/me/fourteendoggo/xkingdoms/database/StorageType.java
This code:
public void removeImplant(UUID uuid, int id_of_implant){
try {
if(exists(uuid, id_of_implant)){
PreparedStatement ps2 = this.im.SQL.getConnection().prepareStatement("DELETE * FROM implants WHERE UUID=? AND ID_OF_IMPLANT=?");
ps2.setString(1,uuid.toString());
ps2.setString(2, String.valueOf(id_of_implant));
ps2.executeUpdate();
}
return;
}catch (SQLException e){
e.printStackTrace();
}
}
This error:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '* FROM implants WHERE UUID='6d9d3fea-d7d7-34a1-bd62-117d724b982b' AND ID_OF_I...' at line 1
literally cannot find a tutorial on anything to do with items just a load of threads of uselessness
you can simply listen to PlayerInteractEvent, check if the action is RIGHT_CLICK_BLOCK and then booom squirt out your custom cart into the face of the fucking user who decided to use your item lol
if i have a section called "kits" and i want to change the name to "inventory" instead, how would i do that?
isnt the syntax "DELETE FROM ... WHERE"?
you could identify your custom item by a PDC tag
yes
DELETE * FROm makes no sense
thast the problem then, i always make the same mistake lol
the * in SELECT to tell people about what columns to select
i dont get how to
- make a custom item
- differentiate it from the normal
- listen for action
- spawn it at location of the action
theres no tutorial for the basic parts (like making the item)
is the problem
like thats helpful but i dont even know how to make the item to add the listener to yk
i dont know why i cant find it
you can create a new itemStack with any existing material. lets say you reuse the existing Minecart item. then you can apply a custom PDC tag on it's itemmeta, like
"myplugin:is_my_custom_item:true". Then in the interact event simply check if the used item has this tag. if yes, spawn your custom minecart and cancel the event, if no, do not do anything
I'm fucking do that, thanks to everyone for putting up with me and my stupid questions
I guess it wasn't me who did it, but you)
In the EntityDeathEvent how can i detect if the entity was killed by a specific arrow?
how do you define a specific arrow?
check if the killer is an arrow
the arrow's shooter a player i guess
and idk what makes your arrow specific, pdc tag?
Why are you setting the player as killer without knowing if that's true?
I have an specific arrow with itemstack, how can I check if the Killer is that?
?pdc
Okay, I'll try that thanks!
ye you cant get the itemstack from it
^^
why creating a new bar each time
should i put the bar outside of the for loop?
Any easy way to check if a block is a rail (any type) in Spigot API (not nms thats easy but not applicable)
Tags are pog
i see Rail exists in api but dont see how to compare/equal it with the block data
thats nms isnt it
is there a Tags.RAIL?
ye RAILS
huh
Tag*
Tag.raiwels
welp yeah turns out i was using exactly that in another place but via NMS as BlockTags
Lol
when in doubt check tag
check if Tag.RAILS.isTagged(material)
wicked thats super easy thanks
would this be an appropriate place to ask about an issue I'm having with making web pull requests to github (in java)
Yeah we can help with that
?paste
https://paste.md-5.net/likutukoze.cs
this successfully creates the new branch, uploads the files and commits, but a pull request is not created (and the rest (deleting old branch and merging pull request) isn't completed)
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "com.fasterxml.jackson.databind.JsonNode.asText()" because the return value of "com.fasterxml.jackson.databind.JsonNode.get(String)" is null
at me.hapily.downloadfromgithub.PullRequest.getPullNumber(GitHubUtil.java:229)
at me.hapily.downloadfromgithub.PullRequest.execute(GitHubUtil.java:116)
at me.hapily.downloadfromgithub.DownloadFromGithub.main(DownloadFromGithub.java:29)
that's the error
the thing is null
^
ah its more complicated than that
Line numbers don't match so I guess you're trying to read a string from a json that doesn't exist
I can send the whole class
229 is the asText() method
yes and I'm wondering how there's nothing when I'm providing the required values
and the expected response contains number
Are you reading the response right
Print pullRequestResponse and see what that value is
Is there a way to deny the collection of a slot when a double click occurs? I want to have the double click act as normal but disallow collecting from this one singular slot.
kinda what I want ? https://gyazo.com/d6be7205cfd21017b42f891717d40bc5'
yes but if i cancel the event the double click doesnt happen at all
i still want it to work normally, but just not collect from a defined slot
Looks like you have something to work with now
well
this api's example was with only one file
as you can probably tell
Do you think making all those commits could be making it slower?
woah that is a massive difference in speed (I tested with only one file provided for the new branch)
okay I need to figure out how to commit all of these files at once
eventlistener -> https://paste.md-5.net/olisahusam.cs
onenable in main class -> https://paste.md-5.net/opasuvivuk.cpp
Is this right for making a spawner item? Think i've got it
you should never convert strings using ==
unfamiliar with java so whats the better way
if(someString.equals("whatever")) { ...
thanks :) ill change it
and before you get the pdc value, first check if it actually exists
never >:(
so basically do sth like this before getting the string from the pdc
if(pdc.has(plugin.railKey, PersistentDataType.String)) {
actually checking if the tag exists should be enough
you dont actually need the content
is it ok to do that like
if(pdc.has(plugin.railKey, PersistentDataType.String) && pdc.get(plugin.railKey, PersistentDataType.STRING).equals("isRailcart:true")) {
in java
well i guess thats pointless to ask now but still good to know
as said, if you use "isRailcart:true" as value all the time anyway, you don't have to check it. just check if the "plugin.railKey" tag exists at all
yeah
Rn there are 208 individual commits (1 for each file)
thanks for all ur help ๐ should be more than enough to do the rest off as a basis
np ๐
alex you got a post for nbt tags?
I only got a post telling you not to ever use NBT but go for PDC right away ๐
i cant use pdc i dont think
that's a pity. but no I neither a post about NBT, nor have I ever used it myself lol
if i set an nbt tag on an itemstack it wont be stackable with its others right?
oh nvm
you can do the same with PDC
why
mmmm
because it's useless to use any NMS methods if the API allows the same thing in a better way
if i set pdc on an itemstack it wont stack with its others of the same type?
yep
bet
just add a random number or sth
I always use the current time as milliseconds to make items unstackable
but I guess a random integer will be good enough too lol
alex bro youre like 4/4 for fixing my issues rn
problem was that im making this custom crafting gui and players were able to double click and grab the item out the menu but i didnt wanna cancel the double click cause then the normal double click functionality wouldnt work
brroooooo its alexx 2.000
Im alex too
what is 4/4 lol
Like you are 100%
4 issues 4 solutions
oh you mean like a perfect 5 out of 7
idk if its actually 4 but
Yeah he means that u are perfect
ceo of math
And u alays help him
bro fuck that glowing
are you reflecting it?
i was tryna use nms
To se it glow?
wym
Are you setting an item glow?
glowing
Hey everyone, I got a strange bug using 1.18.2 latest build of spigot, let me explain
I'm looping through the player inventory and serializing it. I had no issue on 1.17, but on 1.18 only <= 1.17 items get serialized
for (int i = 0; i < inv.getSize(); i++) {
ItemStack it = inv.getItem(i);
if (it == null || it.getType() == Material.AIR)
continue;
Bukkit.getLogger().info(it.getType().toString());
dataOutput.writeByte(i);
dataOutput.writeUTF(serializeItemStack(it));
}```
where inv, is the player's inventory
it should log as info all items, but the issue is, it doesn't log 1.18 items. So is this an actual spigot bug I found ?
@EventHandler
public void onZombieKill(EntityDeathEvent e){
int shouldDrop = rand.nextInt(11);
Player player = Bukkit.getPlayer("Thunderins");
player.sendMessage(String.valueOf(shouldDrop));
if(e.getEntity().toString().equalsIgnoreCase("ZOMBIE")&&(e.getEntity().getCustomName().toString().e("[COMMON] Poison Zombie"))&& shouldDrop == 10) {
e.getDrops().add(poisonPowderItem);
}
}```
so even though shouldDrop is 10, the mob never drops the poisonPowder
@tame sky I don't think thats a spigot bug? not sure, Can you check all the materials and see if there are 1.18 materials?
it's not logging the 1.18 ones
like the turtle hat
yeah can u log all materials and see if the turtle hat is there
Is EntityDamageByEntityEvent called by tnt damaging a player? I assume it should, but also it kind of feels like it might not?
What is the best way to teleport armorstand nametag above the players head? I mean packet teleport (and no passengers). Doing it with bukkit runnable with 0 delay and 0 peroid is good way?
definitely a spigot bug
look at this
are the other things true?
drop the items manually
I doubt its a spigot error, I think that would be a very common thing that would be happening to a lot of people and definitly wouldve been found already, can you check materials and see if the 1.18 materials are there
yes the API contains the Material
what does it log for the item? or is it not stored in the inventory at all
nothing stored
does the size include the item
yes definitely a bug i should report x)
you should not be using e.getEntity().toString().equalsIgnoreCase("ZOMBIE")
use e.getEntity() instanceof Zombie
I completely removed that bit since it's poison ZOMBIE
That's useful to know, how can I do it
idk- i don't think its a spigot problem... 1.18.2 isnt a very new version and getting all inventory items is a pretty common thing I feel like they would've found it already right?
World#dropItemNaturally(...)
mhh figured it out
stucked for 3h, issue was the api-version i did not set
ahhhhh
looks like plugin.yml library loading is broken on 1.19
yep
I also wonder why the heck it only allows maven central
that makes is totally useless for me :<
would be cool if you could specify repos
probably should report it being broken lol
the third party repo becomes a bit of a meh thingy because then your plugins can download pretty much whatever
it can do that anyway
I mean it's not like one couldnt just create any httpurlconnection and download stuff from any place
no no like
I define my dep ehh
apache commons
but also have another repo
now that repo could just throw in apache commons but fucked
plugin.yml could simply look like this
- repo:groupid:artifactid:version
I presume it could yea
right now it's just annoying that one can only use central :<
should I report this on the JIRA?
yeah I don't see any
lmao wtf is a goat horn
goats drop it, I think you can play it?
wait library loading was fixed, I just didn't get the latest build
What bungeecord messaging channel subchannel do you need to use to make the bungeecord server run a command
just in-case you're curious it's because the pull request was being created on a nonexistent branch
Is there an easy way to add multiple file contents to a single commit through the github api?
private String createFile(File file) throws IOException, InterruptedException {
//var fileToAdd = getResourceFile("new_file.txt");
var fileToAdd = getFile(file);
var encodedContent = java.util.Base64.getEncoder().encodeToString(Objects.requireNonNull(fileToAdd).getBytes());
var createMap = Map.of(
"message", "New file added",
"content", encodedContent,
"branch", "new-branch");
var requestBody = objectMapper.writeValueAsString(createMap);
String modifiedFilePath = file.getPath().replaceAll("\\\\", "/");
modifiedFilePath = modifiedFilePath.replaceAll("C:/", "");
return this.put("/contents/" + modifiedFilePath, requestBody);
}
that's what the content is looking like rn
hey gamers, is there a way to change the actual name's color aswell with scoreboard teams?
yes it's whatever's after the prefix
odd
Team.setacolor
but it makes the name &f automatically
lessgo minion carry
I guess the team color was the same here
Wait I'm not 100% sure if that'll work
declaration: package: org.bukkit.scoreboard, interface: Team
The javadocs documented that poorly
Sets the color of the team.
This only sets the team outline, other occurrences of colors such as in names are handled by prefixes / suffixes.
such as in names
Oh well
Good to know it works
yeah lmfao
bonk
Whatvare u tryna do lol
I dont mean for this
In general
Why is ur plugin committing to github
wouldn't it be like, 5 times easier to just call the git cli
there must be a million wrappers for it
it's so you can easily upload your stuff from a test sever to your production server & vice-versa
Shouldn't there be a better solution than github for that?
and collaborate with others on github
So the server folder is on gh?
I suppose you could put it that way
that's the goal anyways
rn I'm just testing it with one of my repos
๐ฉ
I mean, the only benefit you get from it is configuration no ?
jar files seems pretty useless in a git repo
also what do you mean "upload your stuff from a test server to production"
that sounds like a very straight forward CI usecase
or well CD
?
Like, if your point is "I want to quickly get plugin changes onto a test server"
and manage that through git
instead of someone manually compiling the code and pushing it
then build a CI/CD pipeline to do that for you
Are you building the plugin with your build tool ?
sorry to interrupt
they would need to do this
Well that is why you write a CICD pipeline
that automatically compiles it for you, pushes it onto your test server
that's not the goal
Then I must have misunderstood your goal here
well i have a .schematic file in my resources folder, i can't make the file appear when the plugin loads
any1 can help-me plz
again, how are you compiling your plugin
people could use it as a server template (if they're making a network or smth) and build off of that as well
on this one hosting service it's extremely difficult to do something like that
it's just a pain
what
you cannot push the spigot jar you get from build tools to a public github repository
Ah.
everything I have right now (testing on a regular java project) works as intended, my only issue is that each file commits individually, making it extremely slow
and that was only with 208 files from one of my other repos
what would be the best way of implementing config for a list of materials?
You answered your own question
i meant like the format
like how do i store materials in config
bruh ive been stuck in cloudflare for the past 10 minutes skfjdsklfjlkj
just redirecting back and forth lol
between spigotmc.org cloudflare and the one with a query string
like minecraft format?
materials
And get the name as a string from cinfig and use material.valueof
but how would i convert that to a Material
Material.matchMaterial
Works for me
Is there a way to forcefully load a world?
does this break the world record of worst internet without lag switch
Without players in it? For what purposeโฆ
for loading npc's ๐
Ah
bc in onEnable
[01:46:47 INFO]: ?5?lRigel created
[01:46:47 ERROR]: Error occurred while enabling Tazpvp v1 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.World.spawnEntity(org.bukkit.Location, org.bukkit.entity.EntityType)" because the return value of "org.bukkit.Location.getWorld()" is null
at net.tazpvp.tazpvp.Utils.NPCS.NpcUtils.spawn(NpcUtils.java:14) ~[tazpvp-1.jar:?]
at net.tazpvp.tazpvp.Tazpvp.onEnable(Tazpvp.java:143) ~[tazpvp-1.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:541) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugin(CraftServer.java:560) ~[paper-1.18.2.jar:git-Paper-372]
at org.bukkit.craftbukkit.v1_18_R2.CraftServer.enablePlugins(CraftServer.java:474) ~[paper-1.18.2.jar:git-Paper-372]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:664) ~[paper-1.18.2.jar:git-Paper-372]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:431) ~[paper-1.18.2.jar:git-Paper-372]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:316) ~[paper-1.18.2.jar:git-Paper-372]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.18.2.jar:git-Paper-372]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.18.2.jar:git-Paper-372]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
[01:46:47 INFO]: [Taz] Disabling Tazpvp v1```
i believe its caused by the world not being loaded in
Ah I just realised Iโm Really late for something but there is a guide on spigot for loading chunks in other worlds
i just got a random really loud xp noise in my headphones and it scared the shit out of me
okay okay lmfao
https://paste.md-5.net/kutiticobi.coffeescript my error, my code: ```java
new WorldCreator("ban").createWorld();
for (Villagers vil : Villagers.values()) {
NpcUtils.spawn(vil);
}```
why not ยฏ_(ใ)_/ยฏ
i made that once
ban world
to send naughty people
didnt use npcs tho
nop
so i just do new ArrayList and then add them?
Does ur plugin enable before world loads?
i think thats the issue
is there a way I can no do do?
new BukkitRunnable() {
@Override
public void run() {
for (Villagers vil : Villagers.values()) {
NpcUtils.spawn(vil);
}
}
}.runTaskLater(this, 20L * 5);```
I do
bruh cloudflare flashes the "i am human" button for half a second how am i supposed to click it
its like spigot isnt loading the world at all until I join into it
its a nether world btw
if that means anything
Can i see ur spawn method?
for the npc's?
Yh
?paste
Ok and where do u get those villagers from villager.values from?
SHOP(ChatColor.GOLD + "" + ChatColor.BOLD + "Maxim", Villager.Profession.FARMER, Villager.Type.SAVANNA, 1, 1, new Location(Bukkit.getWorld("arena"), -7, 101, 8, -135, 0)),
MENU(ChatColor.RED + "" + ChatColor.BOLD + "Lorenzo", Villager.Profession.CLERIC, Villager.Type.JUNGLE, 3, 1, new Location(Bukkit.getWorld("arena"), 8, 101, 8, 135, 0)),
MINER(ChatColor.YELLOW + "" + ChatColor.BOLD + "Caesar", Villager.Profession.WEAPONSMITH, Villager.Type.JUNGLE, 2, 1, new Location(Bukkit.getWorld("arena"), -1.2, 96, 176.3, -154, 0)),
SHARDS(ChatColor.AQUA + "" + ChatColor.BOLD + "Bub", Villager.Profession.MASON, Villager.Type.SNOW, 5, 1, new Location(Bukkit.getWorld("arena"), 18.5, 80, 103.5, -90, 0)),
REBIRTH(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Rigel", Villager.Profession.FLETCHER, Villager.Type.SWAMP, 6, 1, new Location(Bukkit.getWorld("arena"), -9, 101, -12, -45, 0)),
REBIRTH2(ChatColor.DARK_PURPLE + "" + ChatColor.BOLD + "Rigel", Villager.Profession.FLETCHER, Villager.Type.SWAMP, 6, 1, new Location(Bukkit.getWorld("ban"), -1.5, 78, 11, -180, 0)),
BOW(ChatColor.GREEN + "" + ChatColor.BOLD + "Hrank", Villager.Profession.FLETCHER, Villager.Type.PLAINS, 8, 1, new Location(Bukkit.getWorld("arena"), 29.5, 97, 109, 0, 0));
enum power
Is arena loaded?
?
only the ban world ones
Is ban loaded?
no i dont think so
is there a onWorldLoad event?
declaration: package: org.bukkit.event.world, class: WorldLoadEvent
oh heyy
I have an organization question for you guys. When you're working on a complex system/plugin, how often do you step back and "refactor" your code?
yes.
Whenever I have a bug and am too lazy to fix it
i reorganize my entiere plugin
nice. good answer :D
well. i feel like that was eventually going to happen regardless
finally finished migrating the shit from my list to the default config, went from 29 lines to 207
lol
and thats not even all of the materials
Wait why are u doing this?
Also u could've just used config.set and saveConfig to do it automatically
I hope u didn't write all those in
Did write them in?
Or u used config.set
who cares
How will u know if u missed 1
ยฏ_(ใ)_/ยฏ
any way to make this less of a trapezoid lol
nested for loops
Depends on what the loop does, but you could maybe use named for loops.
this is starting to look like a worldgen plugin
k
how do i check if a block is a container? block instanceof container doesnt seem to work
and by container i mean tile entity
TileState?
nope doesnt work either
oh tilestate did work im just dumb
i had to use getState()
Quite new here to Java and such but I wanted to ask since I noticed there is a BlockDamageAbortEvent. Is there a simple way to know how long a player has been damaging a block or a way to know when the block damaging stops within the initial BlockDamageEvent?
Or like a link between the two events, like an ID or something haha, I feel like I'm asking this so poorly
My first idea is to keep track of the cord of the block they started to break and if the stop event is called and the cord of that block are the same then I can move on from there
So I guess I'm asking now if there is a better method than this.
That might be the best approach.
Question, when trying to create a new world on 1.19 with the world builder, I am getting the following error:
at org.bukkit.craftbukkit.v1_19_R1.util.RandomSourceWrapper$RandomWrapper.setSeed(RandomSourceWrapper.java:75) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3508-Spigot-fa893f0-50ef122]
at java.util.Random.<init>(Random.java:146) ~[?:?]
at java.util.Random.<init>(Random.java:109) ~[?:?]
at org.bukkit.craftbukkit.v1_19_R1.util.RandomSourceWrapper$RandomWrapper.<init>(RandomSourceWrapper.java:69) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3508-Spigot-fa893f0-50ef122]
at org.bukkit.craftbukkit.v1_19_R1.generator.CustomChunkGenerator.lambda$0(CustomChunkGenerator.java:251) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3508-Spigot-fa893f0-50ef122]
at org.bukkit.craftbukkit.v1_19_R1.generator.CustomChunkGenerator.lambda$1(CustomChunkGenerator.java:256) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3508-Spigot-fa893f0-50ef122]```
How can I avoid that?
Someone else was having this issue in #help-server might be a spigot bug report it
I'm not sure what you expect from something released not too long ago
also its not even the preferred version yet
Looks like the CustomWorldGenerator fails to retrieve a seeded random when generating the surface
Yeah, nothing against the spigot devs, itโs impressive how fast they got it out
https://www.spigotmc.org/threads/spigot-bungeecord-1-19.559742/ refer to this post on how to report bugs never done it before so ๐คทโโ๏ธ
I was just gonna look into it and fix it in my fork, but I thought I would report it here
seems to be other world gen issues
Report it in Jira for anything to be done otherwise there was no point to talk about it at all
I saw spigot jira but thought discord was more of a casual place to ask
I wasnโt feeling like making a whole report
Iโll do it tomorrow
yea figures if you weren't sure yet, but I suggest actually going and making one
https://hub.spigotmc.org/jira/projects/SPIGOT/issues/SPIGOT-7044?filter=allopenissues&orderby=created+DESC%2C+priority+ASC%2C+updated+DESC looks like a similar report is already made
Nice, well I will be waiting for it to be fixed then I guess.
Would be a waste of my time to do it myself when itโs already been reported and is gonna be fixed
yea I actually just went on jira to check
Yeah, I was just saying that I was gonna fix it myself but since itโs been reported thereโs no point
has something changed with the addPassenger function with the 1.19 update, it doesnt seem to work anymore, if so, whats the work around?
I figured it out
what I don't get is why extend Random, then back a Random and provide no other functionality o.o
ah ok RandomSource is apache commons ig
https://hub.spigotmc.org/stash/projects/SPIGOT this is the stash, but idk if anyone can PR it
I don't think you can tbh so I'm not quite sure how you'd go about that lol I'm stupid
facing a "problem" right now where it takes like 2-4ms to create a gui and all the items for it since i need to do lore line replacements etc
Reason i consider it a problem is if there's a server with say 100 players and other plugins, if the gui is opened alot which it possibly may be, it can increase tick times to even > 50ms. Now I dont have aserver with 100 players to test on so the best i can do is try to find the best solution. Previously, my solution was to preload the gui for each player on join which i didnt really like so now, which lead to my current solution.
Do you think i should be worried abt the 2ms per tick or not. I can still make optimizations such as cacheing the gui once it's created so i dont need to recreate it for the player if they open it again.
or i can just ignore it for now and if it becomes an issue, start caching
more potential for "future updates" that way
how different is the GUI for each player?
I possible solution to be cache the common aspects and change the required portions on open
it's a storage gui
ahhhh
like private vaults
the gui items have lore and whatnot based on page number
so i have to create them when i create the page
well a common tactic would to be cache on open and then remove the players vault from the cache after say 5 minutes
that could definitly help
yeah i was thinking that
also are you serializing item stacks? or just formatting them into a database/yml
serializing to byte[] and throwing in a db
ok yea thats probably the fastest that will get
that's not the problem, all that's being done async anyways
on bigger servers a caching system as I mentioned above and as you were thinking could be helpful
i'm caching data properly, what i wanna know is if i should cache the Inventory objects
๐ฅ๐ฉ๏ธSUPER ๐ฉ๏ธ ASYNC ๐ฉ๏ธ PLAYER VAULTS ๐ฉ๏ธ 1.19 SUPPORT ๐ฉ๏ธ๐ฅ
lol
hmm that I'm not sure i'd personally just cache the inventory objects, but I'm not the best example as I have little java and programming experience
i was creating them and caching before but that felt off to do
no that'd get too big too fast
swallow the initial delay and cache for frequent openers
the perfect middle ground would be just to keep what they use most
so i can keep 5 invs cached at a time
if a new one is opened, oldest is thrown away
if you wanted you could cache using a
Map<UUID, ItemStack[][]>
yea :)
i'm def not doing that
well wouldn't you be caching multiple player vaults for one player
you'd need a way to properly index the different vaults
if you wanted you could also run the cache async so you can include more lightning bolts and ASYNC in your plugin name
dont wanna mess with bukkit objects async
personally i Like to flex that all of my plugins only use the main thread
so many plugins use the main thread for io it pisses me off
and they get more downloads than me too
i need to name my plugins better
๐ฎโ๐จ I use main thread for IO
I see a problem its not clicky enough
like nothing makes me want to click it
the lack of ASYNC
and obnoxious emojis
how can i use nsm package i want to download for 1.19
same way you do for 1.18

