#help-development
1 messages · Page 260 of 1
in java?
maybe a network issue?
change it to the correct type
tf
ah, just like optionals
16
17
optionals have a reason to exist
nullability wraPPER
yeah
just convert the vals to the correct type they should be
or you can just... pass null values
try to use "var" instead of "val", does that work?
optionals are just overhead and don't even look nice
looks like lombokhttps://projectlombok.org/features/val
it's just java tryna be even more verbose just because
var is a thing yes
but imagine that null is an allowed value
@tender shard no difference xd
how would you differentiate between having "null" because it's null, or "null" because it's the actual returned type
not
by throwing exceptions
Optionals do make sense... SOME times
sounds like a data structure problem
true
File -> Repair IDE
i just create my own optional classes whenever i need them
does this help?
wtf xd
mfnalex
can you import this project too?
is it on github?
i wanna know its a network issue or not
yea
that will takes longer that 1 sec anyway, its ok
yeah it's quite big as it seems
great
this is everything the minecraft plugin does:
cause errors
oh and to display chat colors in the editor
but wtf, it still didnt clone the repository yet. how fucking big is it
weird, maybe my intellij is weird, Imma clone it from cli then
yeah in git bash it only took 0.5 seconds
weird
try Repair IDE xd
bro wtf am I completely dumb now?
the particles are flying all over the place wtf
you always were dumb
hm no idea
you gotta set a ton of 0,0,0,0,0
lol what
speed, additional data
they just spray out like a bomb
relx, rely, relz
it's stupid
but you just add a ton of 0,0,0,0,0 params
to your spawnParticle method
and it will work
don't ask me why just accept it
nice code mojang
alex I'll send you a paypal invoice if you doubt me once again
I cloned it but gradle fails to init the shit
fuck 5% laptop battery
maybe some of dependencies are no longer exist?
I'll try with just bash
nice now no particles are getting spawned
lol
the build.gradle is messed up
it needs the Taboverlaycommon-config" dep
is that one on github too?
lemme check
no
Don't you just love it when you download a gradle project and half of the fucking dependencies can't be resolved for whatever fucking reason. I KNOW I DO!
this?
yes
biuld this from source, then try again
haha gradle
people claim "gradle is shorter to write"
meanwhile
mvn install
gradlew publishToMavenLocal
sorry but I can't help it, gradle is just a huge joke
it cannot do anything, cannot even shade dependencies
Hm?
then people claim "yeah just use the shadow plugin that was made by some random github dude"
then I ask "okay and how can I relocate and filter stuff in shadow" and nobody knows
the shadow plugin is a huge joke
Nah it do be fine
Sup?
maybe you can help me with that
because I have no clue
i prefer maven even in big projects
I would like to filter classes, do minimizeJar, AND relocate
but it seems like the shadow plugin gets confused when trying to do all 3 things
I use something called autorelocate in it
can you share an example pls
Well haven’t looked more into filtering it. But https://github.com/JanTuck/EventDebugger/blob/master/build.gradle.kts
And it’s a kotlin buildscript haha
oh yeah would work but it wouldn't filter anything
I need to add the filters, otherwise minimize() reks it up
for the NMS classes
who the heck is kidding me now?
Kotlin 💀
@tender shard Yeah, don’t know off the top of my head and I’m too lazy to look into it at the moment.
my internet in 10 min for downloading a jdk
lol
that sounds like the average gradle user statement
Stop supporting the grade people Alex lol just use maven
nah man someone must be hardcore-kidding me
mflanex that's why I want to come to Germany xd
"Oh yeah, it doesn't work? Well I have no clue on how to fix it. Just live with it. We are not maven, you are expected to have things not working properly. Maybe there's some third party plugin you can use after gradle downloaded itself for the 182th time. good night" lol
l.add(vector);
projectionLocations.add(l);
length += 5;
Bukkit.getLogger().info(l.getX() + ";" + l.getY() + ";" + l.getZ());
``` gives me other output than when I return the object out of projectionLocations WTF
I didn’t say to live with it
I know, I just wanted to complain about gradle
I know it's not your fault lol
public void shoot() {
for(Player player : Bukkit.getOnlinePlayers()) {
for(Location loc : getProjectionPoints(player.getLocation(), new Location(player.getWorld(), 0, -48, 0))) {
Bukkit.getLogger().info(loc.getX() + ";" + loc.getY() + ";" + loc.getZ());
player.spawnParticle(Particle.FLAME, loc, 1, 0, 0, 0, 0);
}
}
}
public List<Location> getProjectionPoints(Location bulletStart, Location targetLocation) {
List<Location> projectionLocations = new ArrayList<Location>();
double distance = bulletStart.distance(targetLocation);
Location l = bulletStart;
Vector vector = targetLocation.toVector().clone().subtract(bulletStart.toVector()).normalize().multiply(5);
double length = 0;
while(length < distance) {
l.add(vector);
projectionLocations.add(l);
length += 5;
Bukkit.getLogger().info(l.getX() + ";" + l.getY() + ";" + l.getZ());
}
return projectionLocations;
}
different logs lol
I relocated like this back in the day https://paste.md-5.net/asogijuluf.bash @tender shard
My wtf
yeah but it breaks when you also add "include" filters and stuff :/
Annoying
indeed it is
anyway, thanks
I will probably just keep telling people to use maven lol
ty for helping me with that
I don’t use it due to not liking the amount of xml in it
yeah pom files can become quite large, but at least it works
I love xml
Devil
Just like I love java it's verbose but clear
I like xml-style 🙂
Ayo apacheee
apache > nginx
I use apache too
nginx is only faster because it cannot do anything
Well, i dislike that too haha. (apache) tho have used it many times before.
(And to write)
but not as annoying as this garbage nonsense happing to my code rn
WHY WOULD THIS EVER RETURN DIFFERENT THINGS?
wait
I mean this
it doesnt return anything
you change the locations in the for loop
public List<Location> getProjectionPoints(Location bulletStart, Location targetLocation) {
List<Location> projectionLocations = new ArrayList<Location>();
double distance = bulletStart.distance(targetLocation);
Location l = bulletStart;
Vector vector = targetLocation.toVector().clone().subtract(bulletStart.toVector()).normalize().multiply(5);
double length = 0;
while(length < distance) {
l.add(vector);
projectionLocations.add(l);
length += 5;
Bukkit.getLogger().info(l.getX() + ";" + l.getY() + ";" + l.getZ());
}
for(Location loc : projectionLocations) Bukkit.getLogger().info(l.getX() + ";" + l.getY() + ";" + l.getZ());
return projectionLocations;
}
sure
lol
So would have vscode :P what is eclipse doing
eclipse is a bad joke
Probably the language level. I know eclipse is capable of it.
bro
Player somePlayer = null;
smoePlayer.setDisplayName("someString");
me using eclipse does not change the fact that my code does not work lol
What's not working
the whole eclipse thing
its returning wrong locations
then you put the wrong locations into the list
as much as I hate eclipse, it's not their fault when you return the wrong stuff
the logging in the first Logger is using the correct ones
the one after the loop isn't
then that's because you change the locations in your loop
You need to do l.clone().add
yeah, add() and stuff changes the actual location
Java doesn’t do a deep copy when you add to a list
So you’re adding the same modified location to the list a bunch of times
^
well but when I just use .clone(), it would still use the normal l for the list
l.add(vector);
list.add(l.clone());
ahhh I understand
That way you aren’t modifying what you added to the list later
Say what now
crack cocaine
What extra if statement?
Ok but that’s not what removeIf does
Lol
removeIf iterates through all the elements in the collection and removes any matching the provided predicate
they should call it removeMatching or removeAll
then removeMatching
true
hey
do u now how to add particles for arrows in 1.8.8 ? i've search but i havent found
Too old! (Click the link to get the exact time)
minecraft 1.8
are u saying that minecraft 1.8 is outdated ? (sory i'm not english i dont understand all very well)
ho
but it's the best for PVP players
and a lot of plugins are in this version
This is just a guess, but you’ll need to create an event that gets the projectile, then start a runnable that gets the location of the projectile and spawns a particle at that location.
ho
yes
i've trail but i've set a while and not a runnable
i need to see because i dont understand runnables very well (i'm starting dev)
but i see wath is it
why ?
@lapis bramble Definitely don’t do a while loop, I learned that the hard way when I first started out. A while loop won’t let the server process anything else until it finishes, meaning the server will freeze.
yes i've see it's make crash the server
scheduling is the same that runnable ?
@lapis bramble What you want is something that runs every tick but let’s the server go off and process other things.
ho ok
@lapis bramble Yeah like Morice said, I have and most of us haven’t or have not in a while, used 1.8, so we can’t give you the exact code
it's not a problem, i used playevent and not setparticle but its same
Yeah
but it will freeze the code no ?
will
ok, so i need to create a sheduler where i set a while loop ?
ho
ho ok
@lapis bramble Hope this helps: https://bukkit.fandom.com/wiki/Scheduler_Programming
ok, thanks
?
@last temple Probably should have looked at that documentation a little more
thanks
LOL
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
and this code is where i want ?
@quaint mantle No LOL
and just wath mean 1L, 1L at the end of the task ?
No, this guy came out of left field.
and L is for ticks ?
L Is long
@quaint mantle @kind hatch Imo, really need to change my profile pic
I need to christmasify mine. :3
@lapis bramble You’ll want an event that detects when the projectile hits a target. You can do an entity damage event and check if it is the projectile, then stop the runnable
Right
Forgot the name
it's a projectil hit event but if i use it i cant set particles
i think
it exist
wath means plugin instance ? what i need to set ?
do you know java?
I'm starting
i set "this" ?
@lapis bramble Here;a a tutorial for that https://www.youtube.com/watch?v=SNZkXWDRNL0
for this instance
?basics
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.
hello?
make it atomic or a one elem array or smth
and use runTaskTimer with a lambda instead
return ++angle ig
dunno what youre doing tho
whats the event for right clicking an item in your hot bar while playing
as if u were to place the item
shit
PlayerInteractEvent
any idea how some of plugins spawn glasses / blocks that only 1 player can see?
packets
Packets
Packets
?nms
S tier tutorial my God
i have a problem : i've see the sheduler have to be a int variable to cancel it. but when i do this , it tell me that it have to be a BukkitTask
Type mismatch: cannot convert from BukkitTask to int
and i can t cancel it if it's a bukkittask
scheduler.runTaskX(plugin task -> /* whatever */ task.cancel()) is a thing
or use the runX methods that return a bukkittask
if you want to do it that way call getTaskID() on bukkittask
declaration: package: org.bukkit.scheduler, interface: BukkitScheduler
Hi, I am currently developing a minigame that has 2 different modes, one if you have downloaded the resource pack and one if not. I store this information in a HashMap, which is lost after a reload. Is it possible for me to "carry" this data over a reload without creating a file or is that not possible?
so youre just saving what players have the resource pack thing?
yep
Pdc maybe
why not using a Set<UUID>?
or ye pdc, but i kinda hate that entries persist even tho the plugin is gone
Okay, then I guess I'll go with pdc.
Set will not work, because I will have more than 2 states later.
public void saveFile(Gson gson, String name, String path, JsonElement element) {
File f = createFile(name, path);
f.getParentFile().mkdirs();
System.out.println(f.getAbsolutePath());
try (Writer writer = new FileWriter(f.getAbsolutePath())) {
gson.toJson(element, writer);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}```
Ok so now my code its working but everytime is save data into the file the old data is override
that will shows only for that player?
Yes
thanks
how do i add chat click with text components do i need the bungee libary
They’ll run into some issues if they try to walk/jump on it and the bounding box of the actual block is different though so be aware of that @sage patio
Yes
use Writer writer = new FileWriter(file,false);
the false means dont override
i think
OK thnx
the player never gonna touch that blocks
do u know the gradle import for it
Then that will work for you
iirc the TextComponent stuff is in normal api
hmm
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
That’s the documentation for it
Is there an event that resembles the GameStartedServerEvent from sponge?
The event guarantees, that:
The internal server is started
It will only be called once
The event will ALWAYS be called
The event will be called directly after the Server has started
So far I've been using a Sync Thread, created in onEnable at the first time it is called (subsequent calls will do nothing). The idea here is, that the Sync Thread will be executed at the start of the first server tick. However if the first tick never finishes (e.g. because the server just hangs indefinitely, but the Server Watchdog doesn't kill the server) and tasks are executed at the end of the tick, then my entire plugin breaks (the idea is to get it to be as reliable as possible). As far as I see nothing in the api guarantees that the thread is executed at the start of a tick.
Also another thing to note is that I'm currently using maven and org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT, because I currently lack a better way to use bukkit. (no non-snapshot seems to be available from spigot's repository).
The WorldInitEvent seems promising, but is still not ideal because I don't know how close or far from the actual internal server start that event is called. (especially when considering other things that implement spigot's api, such as Magma). WorldLoadEvent is also promising, but might be invoked more than once (which I could filter out). Is there any better event that I can use?
I cannot send a player a text component
player#spigot#sendMessage iirc
doesnt exist
Or more plainly player.spigot() should exist
nothing .spigot exists
use spigot api
i am
maven?
gradle
?jd-s
send build.gradle
this is a spigot plugin
send build.gradle
declaration: package: org.bukkit.event.server, class: ServerLoadEvent
'Bukkit'
use spigot api
org.spigotmc:spigot-api
you are using bukkit
^^
fuck why am i here
The event doesn't exist in org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT.
ah fair enough
still the same
1.12 is what, 5 years old?
feels like it. I just want to support a wide variety of severs tho. when was org.bukkit.event.server.ServerLoadEvent introduced?
based on what he said it seems he want to do something like a server manager
guys , how i can decompile a plugin?
Why can't you use the scheduler
What I want to do is simpler. I want to create a plugin that detects when a server freezes.
read the initial post.
If the first tick never executes the server is broken and no one cares about your plugin
if you just need the .class files, you can just change it to a zip, then to a folder and they open it in something like intellij. otherwise i havent got a clue
If the first tick never executes fully, it is my plugin's job to restart the server. Also the first tick might just take ages
Well the option has been given to you. If you want to ignore that and stick 5 years in the past that's up to you
when was org.bukkit.event.server.ServerLoadEvent introduced?
so I can just update to that version.
?stash
ah cool! thanks
August 2018
I would have been grabbing the source jar from the maven repo LUL
Alternatively you can add your own
thanks
sadly not. I'm not even set on a specific server implementation
I want my plugin to work on a wide variety of servers, and explicitly don't want to specify my plugin
Hello guys i have a problem with building my project, well im using remapped mojang and when i run the project it works well but when i want to build the project to my server's plugin folder, it compiles the wrong one. im not really good at working with maven can anyone help please?
make sure you are using the correct jar
where?
if you use special source it exports mutliple jars
i know that
@tender shard which is the right one to use
but where can i select the jar?
they would be in target
how are you building to the plugins folder then
File > Project Structure > Artifacts
does that not give an option to select file]
no i don't see any
you mean the lifecycle things?
press control twice then type mvn clean package
for future builds press the green button top right
doesn't work
do you have a pom
yeah
?paste it
as i said it builds the right one in the target folder
the problem is
well first problem you have is your trying to output into a jar file
well how to set the output direction to my plugins folder?
unless you wait for someone that uses maven to come along the best i can say is do it manually
nvm fixed it
how i can get item in player's hand when he scrolls or presses 1 to 9?
PlayerItemHeldEvent
Hey, I am trying to set ItemMeta of an item inside of runTaskAsynchronously. I noticed that when I do that, it works half of the time so tried to look for another way and found callSyncMethod however it didn't change anything. Any ideas?
?paste code
https://github.com/rusthero/BiomeCompass/blob/main/src/main/java/dev/rusthero/biomecompass/locate/PlayerBiomeLocator.java#L35
https://github.com/rusthero/BiomeCompass/blob/main/src/main/java/dev/rusthero/biomecompass/listeners/MenuClickListener.java#L70
https://github.com/rusthero/BiomeCompass/blob/main/src/main/java/dev/rusthero/biomecompass/items/BiomeCompassItem.java#L77
Sorry for the reformatting, will work on it later
These are my debug messages:
As you see, it works sometimes like (It shows the display name of the Item: old name : new name) Deep Dark -> Sunflower Plains
But sometimes it doesn't change the ItemMeta and I have to call it again
It works like 70% of the time
what do you need it for?
do you wanna unregister your own listeners, or listeners from another plugin?
Ayo wtf is going on here
Oh the injection thing from guice
Forgot about that
Lowkey
my own events for current project I would like to have multiple event listeners instead of one
so I need dynamic registration and unregistration
you can unregister event listeners using the handlerlist iirc
ok just askig because never had done this before
Sorry for asking about obf i know that of you are against it, but is true that Kotlin obfuscated code is more difficult to deobfuscate?
Although this a bit late, but excuse me, what’s wrong with Kody?
Sometimes. The usual jvm deobfuscators and decompiler were not ready for made kotlin. It probably changed in the last dew years, but yah.
WorldBorder border = Bukkit.getServer().createWorldBorder();
border.setCenter(centerLoc);
border.setSize(radius);
border.setWarningDistance(warningDistance);
player.setWorldBorder(border);
Does anyone know why I can't see the border?
How do I check if an InventoryClickEvent occured inside the player's inventory?
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
instanceof PlayerInventory?
Or just check if it's the bottom inventory.
Wouldn't that also return true if you used a chest inventory?
Would it return true inside the survival inventory though?
Are you not looking for that?
Im looking for just the player's base inventory
with their armor and crafting menu
Check if the top inventory is null might be a way @subtle folio
Alright, Where is TopInventory?
What?
I fixed it by adding 5 ticks delay, weird huh. Thanks anyways!
If e.getView().getTopInventory() == null?
Yeah that might work @subtle folio
e.getInventory().getView().getType() == InventoryType.Player
Makes more sense tho
ill tryt it
Most event are made to run before changes are made.
@last temple Yeah I agree he does certain things without explanations. I’m still somewhat starting out (I’ve done plugin development off and on for a few months) and was watching his videos, but what would you recommend instead?
Whose videos?
@rotund ravine Kody Simpson’s
No clue who he is
i saw some of his
Doesn't Work 😦
What does it even return @subtle folio ?
getType() returns an inventoryType
false?
I mean what type does it return
@last temple Yeah I’ve seen some of his. They seem decent.
.equals is for enums !
No
.equals for strings
For non-constants
strings more
i knew that
You use it for lots of things
strings are used most in my use cases
@subtle folio so what did it return?
so i just say strings
Then u need to use more objects
Im restarting and checking
no
its CRAFTING
Is there an issue tracker for spigot builds/ buildtools ?
lol
I see so there is a top inventory
Finding no issue thing here https://hub.spigotmc.org/stash/projects/SPIGOT/repos/buildtools/browse or here https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/browse
arent issues handled on jira
the whole point is i'm asking bc idk
Idk just do something like player.getOpenInventory instanceof PlayerInventory then @subtle folio
is there a good command creation API?
There’s many
Yeah, obviously, the question for what you recommend
Might return crafting tho @subtle folio
nope
I use ACF perosnally
it returns WORKBENCH
Fun
checking if its crafting
might might but nothing else that I can think of returns CRAFTING
Oh true might not idk
Okay, so turns out it's because I was doing it in a Join event
I put it in a PlayerInteractEvent and it works, is this because maybe the chunks haven't loaded yet for the client?
and if so how can I check if they are loaded
delay it a tick or somethign
why
basically it's kind of a general thing where I don't know what event this code is gonna run on
so I'd rather not delay it by a tick in all scenarios
however I just got an idea
nvm
?
I figured it out lol
Hello ^^.
does someone knows why im not getting the item inside of ItemFrame ? (1.19.2)
CraftItemFrame craftItemFrame = new CraftItemFrame(((CraftServer) player.getServer()),new net.minecraft.world.entity.decoration.ItemFrame(EntityType.ITEM_FRAME,level));
craftItemFrame.setItem(CraftItemStack.asCraftCopy(itemStack));
craftItemFrame.teleport(player.getLocation().add(0,1,0));
craftItemFrame.setVisible(true);
craftItemFrame.setInvulnerable(true);
craftItemFrame.setFixed(true);
craftItemFrame.setGravity(false);
craftItemFrame.setPersistent(true);
craftItemFrame.setFacingDirection(BlockFace.NORTH);
ClientboundAddEntityPacket clientboundAddEntityPacket = new ClientboundAddEntityPacket(craftItemFrame.getHandle());
ClientboundSetEntityDataPacket clientboundSetEntityDataPacket =
new ClientboundSetEntityDataPacket(craftItemFrame.getEntityId(),craftItemFrame.getHandle().getEntityData(), true);
((CraftPlayer)player).getHandle().connection.send(clientboundAddEntityPacket);
((CraftPlayer)player).getHandle().connection.send(clientboundSetEntityDataPacket);
player.addPassenger(craftItemFrame);
``` :(
https://wiki.vg/Protocol#Chunk_Data_and_Update_Light
I'm reading this and trying to figure out which field holds the data that determines the blocks ina chunk
is it handle > c > c?
@humble tulip no
d
Oh my bad it’s a lightpacket too
?switchmappings
I was tryna figure it out with protocol lib and IJ debugger
MiniMappingViewer
?paste
How do I set the player's cursor item to air ?
I’m sure you can figure that out by typing mainhand into the javadocs
What would be the best way to check if player has an inventory open? (Weather be a gui, or their own inventory, a chest, ect)
I need to check and see if NOTHING is opened whatsoever
getOpenInventory
I checked that, however in the "InventoryType" enum I didnt see anything that matched something along the lines of "Nothing", the closest I saw is PLAYER, which Im pretty sure also says that if the 2x2 crafting menu is open
Client doesn’t tell the server if player has their own inventory open
beat me to it
Ah okay
If they do not have an inventory window open, it returns their internal crafting view. yeah not sure if this is the PLAYER inventory
in a bukkit runnable, how can I check if a player is currently mining a certain block?
Particles I create seem to "explode" out of their spawnpoint
Instead of just staying still. Is there a way to control particle velocity?
Yeah you can set it to like 0.05 or something and most particles will stay pretty slow and in place
does anyone know how to modify a chunk before it's sent by intercepting packets?
Oh, my bad. It's the extra arg. That's only present when you pass an x/y/z offset though
spawnParticle(Particle.SMOKE, location, 5, 0.25, 0.25, 0.25, 0.05);
Offset is a bit of a misnomer though. It's more of a spread
so a random chance?
Not quite. Just how far out from the location the particle can spawn
e.g. it will spawn anywhere from location.getX() - 0.25 to location.getX() + 0.25
Or something to that effect. It's not that exactly
The 0.05 is really what you care about here. That "extra" is speed, and again 0.05 is fine
Tested it and it works fine, thanks
why east is not working?
its always north, south and west
it seems the calculation is wrong
(yaw % 360 + 360) % 360 is always more than 0
yaw % 360 can be a value from -359 to 359
when you + 360
it makes (yaw%360+360) have a range from 1 to 719
so it'll always be positive
why not just yaw%360?
lemme try
lol
same
public enum Yaw {
NORTH, SOUTH, EAST, WEST;
public static Yaw getYaw(Player player) {
float yaw = player.getLocation().getYaw();
yaw = yaw - 180;
if (yaw > 135 || yaw < -135) {
return Yaw.NORTH;
} else if (yaw < -45) {
return Yaw.EAST;
} else if (yaw > 45) {
return Yaw.WEST;
} else {
return Yaw.SOUTH;
}
}
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer(Main.getInstance(), () -> {
Location location = player.getLocation();
double x = location.getX(), y = location.getY(), z = location.getZ();
switch (Utils.Yaw.getYaw(player)) {
case NORTH:
player.sendMessage("You are looking at north");
player.sendMessage(player.getLocation().getYaw() + "");
break;
case EAST:
player.sendMessage("You are looking at east");
player.sendMessage(player.getLocation().getYaw() + "");
break;
case SOUTH:
player.sendMessage("You are looking at south");
player.sendMessage(player.getLocation().getYaw() + "");
break;
case WEST:
player.sendMessage("You are looking at west");
player.sendMessage(player.getLocation().getYaw() + "");
break;
}
}, 5, 10);
}
yep so yaw is 0 to 360 in spigot but -180 to 180 in client
ow
thanks for help
i'm trying to spawn something like this
like Rust game build system
Yaw is positive or negative dpenending how you turned
It is negative of you turned to the left and positive if you turned to the right
well set the blocks?
However you can always use a positive number with yaw unless you trying to simulate motion
yea
but big problems in here are
trying to find a correct location to send block change to player
then remove it (setting back to air)
Anything greater then 45 but less then 135 is considered east unless you want to start factoring in things like north east and south east
Which i am pretty sure there is cardinal directions for those as well
also north and south
yea
right.getOpenInventory().getType()
Why when I right click a player this always return as "Crafting"
Weather their 2x2 crafitng menu is open or not
Because hotbar exists which is still an open inventory
how do I check if NO TOP inventory is open then
Check the inventory type for hotbar or player inventory i suppose. Dont know related api methods for it
?jd-s
var llllIIlIIlIIlIIllIIlIIllI: String? = null
var llIIlIlIIIllIlIlIlIIlIIll: Long = 0
var llIIIlllIIlllIllllIlIllIl = false
var lllllIllIllIllllIlIllllII = false
Wtf@quaint mantle
Ah yes lets review a plugin but lets not state its obfuscated lol
It's not
That's 1 class
Yeah
Still, if there is a obfuscation in an open source plugin or being able to freely view source. Automatically i assume something shady
just a package that I was attempting to spoof some stuff with a web socket
Its not my code
Thats frosts point
ah
If its an opensource code that has obfuscated coding in it, most likely has a sketchy thing in it
Otherwise why hide that portion of code?
.
I never once said it was yours
Ignore that package
They mean "why hide the code in an opensource github"
"unless something bad was in it"
^
not "why are YOU hiding stuff"
Ah
Emerald to the rescue with translating lol
i have a 60 in engrish 👍
Server is like, no response for 13 seconds terminate everything now
Its part of the heart beat stuff
If after a period of time the server doesnt set some value every so often. The server considers itself stuck or whatever and then just terminates the process
what task
sending some block changes to a player
show your code
yea sorry i was busy 1sec
public static void showFloor(Player player) {
BukkitScheduler scheduler = Bukkit.getScheduler();
ArrayList<Location> blockLocations = new ArrayList<>();
scheduler.runTaskLater(Main.getInstance(), () -> {
Location location = player.getLocation();
double x = location.getX(), y = location.getY(), z = location.getZ();
switch (Utils.Yaw.getYaw(player)) {
case NORTH:
break;
case EAST:
x = x + 7;
y = y + 1;
z = z - 2;
for (int i = 5; i >= 5; i++) {
for (int j = 5; j >= 5; j++) {
Location loc = new Location(player.getWorld(), x, y, z);
if (location.getBlock().getType() == Material.AIR) {
loc.getBlock().setType(Material.STAINED_GLASS);
player.sendBlockChange(loc, Material.STAINED_GLASS, (byte) 5);
blockLocations.add(loc);
}
}
}
break;
case SOUTH:
break;
case WEST:
break;
}
}, 0);
scheduler.runTaskLater(Main.getInstance(), () -> {
for (Location loc : blockLocations) {
player.sendBlockChange(loc, Material.AIR, (byte) 0);
}
blockLocations.clear();
}, 10);
}
in here:
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
BukkitScheduler scheduler = Bukkit.getScheduler();
scheduler.runTaskTimer(Main.getInstance(), () -> {
StructurePlacement.showFloor(event.getPlayer());
}, 10, 10);
}
it has some problems for now i know but crashing server?
i dont see anything tat woudl crash it
?paste
Mmm paper
placing too many blocks at once lagging the server
Does it happen with spigot?
i don't know
i need to do that every 10 tick
Probably should try considering this is spigot discord not paper lol
and i know some plugins does this again with no problems
[06:40:06 ERROR]: Stack:
[06:40:06 ERROR]: net.minecraft.server.v1_12_R1.PacketPlayOutBlockChange.<init>(SourceFile:23)```
1.12
pog
Have to remember your task is also a sync repeating task
lemme try with sending only 1 block to player
yea works with a little lag
So anything that halts the main thread long enough even if it is a task will cause it to panic
But who knows could be a paper issue too
maybe
i'm going to try with spigot too
This loop, you never use i and j for (int i = 5; i >= 5; i++) { for (int j = 5; j >= 5; j++) { Location loc = new Location(player.getWorld(), x, y, z); if (location.getBlock().getType() == Material.AIR) { loc.getBlock().setType(Material.STAINED_GLASS); player.sendBlockChange(loc, Material.STAINED_GLASS, (byte) 5); blockLocations.add(loc); } } }
shit that should be n = 0 yea
you are doing that 25 times on the same block
what are you trying to build?
did you played Rust ever?
the survival game? yes
when you try to build something, if the location be right, the preview is green
if not, the preview will be red
thats what i'm trying to do
for now, its a 5x5 floor
trying to build it where the player is looking?
i will die soon, it is
agreed
one sec let me open my ide. I have some code placing a fake block where teh player is looking
you also need to remove teh blocks you fake place as the player moves his head
yea actually it does, 10 tick after spawned it
its flashing, i have to remove blocks in that way you said
why 10 ticks? that will flash.
y
only remove it when the player moves his head
why is this erroring https://paste.md-5.net/tukefaluxa.java it gives "java.util.HashMap.put(Object, Object)" because "net.picklestring.base.Base.BaseBlocks" is null
?paste
Test this class. When the player equips a stick in their hand it shows a fake glass block where they are looking. you can easily expand that to place a floor.https://paste.md-5.net/ifarefuzap.java
whats the full error
it looks fine to me
one sec
thanks sure
its just a case of changing the Map at line 39 to hold a Set instead of a single Location
and adding all the blocks in getTarget
what is RayTraceResult ?
i'm on 1.12.2 maybe its because of that
yeah thats not in 1.12
you can do the same with vectors
if you want it always 10 blocks from the player use Location loc = player.getEyeLocation(); return loc.add(loc.getDirection().multiply(10));
p.getInventory().getItemInMainHand().setAmount(p.getInventory().getItemInMainHand().getAmount() - 1);
Why does this remove my entire hand?
Even if I have 5 items it just deletes it
show your full code
?paste
unless your event is being called many times over i dont see why it would do that
are you sure it'd deleting them all and it's just your inventory is not updating?
see if it's invisible in your hand
oh wait i know why
its 2 hours i'm trying to spawn a fucking 5x5 blocks but i can't
whats wrong with me
did you use teh code I gave you?
then just start x -2 to x + 2 and z - 2 to z + 2
you get teh center location then use +- 2
your code you never change the location
you loop i and j and never use them
oh you are incrementing x and z seperately
that would nto work
you are incrementing x 25 times
its 8 am, i didn't sleep from last night
even i can't speak english correctly
don;t alter x and z in your loops, instead add to x and z i and j
and change the end to x + i, y, z + j);
ow
remove your x = x + 1 and z lines
night 🙂
Please resend the image about player inventory slots, i cannot find it
Do you guys recommend to saving data from yaml file to RAM/variable (on onEnable method) and use that or its better to access file every time?
I mean like this:chests = this.getConfig().getStringList("locking.chests");
and use this variable in code or just access .yml file every time
Anyone know any librarys I could use to create custom enchantments in 1.19+
the config gets cached to memory anyway
ok, so I can access directly .yaml file like Main.getConfig().getString("some path");? What about custom .yaml files?
anything that uses the default config system will cache
If I will use some file with this DataManager will that cache data? https://paste.md-5.net/nisajaduqa.java
as long as you use FileConfiguration
So its waste saving data to variable on plugin load, right? So its better to access .yaml file with ex. Main.getConfig().getString("some path");, right?
If yes, Im wasting system resources in my plugins xD Thanks.
No it’s fine @trim lake
What of the question? 😄 sorry I dont getit
Which ones?
I don't get it wdym with that answer.
I mean this.
Idk what is fine or just what do you mean
Configs can't change during runtime (as far as I know) so there's no need to keep getting a config value from the config. Saving it to a (final?) variable would make more sense to me. That said, unless you're reading that value thousands of times, it really doesn't matter much in performance or resources
They can, but you'll notice soon enough when it does and when it does not
The confugs privided by the bukkit API do Not Change when the underlying file Changes that is
More exactly, the are ready once into memory and that is it
i was wondering if spigot has a method getNearbyEntities i was using paper then decided to use spigot and it says its not a thing
of the location class
It’s in the world class
Saving data to some variable sounds unnecessary if they are already in memory. Maybe I'm not understanding something correctly.
gotchu thanks
It depends on how you use it really, both are viable and neither is "bad". In the end it's your own choice
but if you made some reload command they will get changed in memory, right?
Hmm, Im thinking about performance what would be better (maybe there is nothing more to be worried about 🤔)
Performance wise it will be insignificant unless you use it a real ton. (say a 100X100X100 for loop)
For me, seems pointless to save data to some variable if they are already in some variable on memory. So I if will create some variable where I will save some data in onEnable method Im saving value twice, right?
that´s the way Im thinking about it.
This is how I've done it before, not quite a variable, but more a helper method for config values https://github.com/KevinDaGame/DailyLeaderboards/blob/main/src/main/java/com/github/kevindagame/PluginConfig.java
I don't like interfacing directly with the config reader because I feel that passing a string is open to mistakes, so I made a wrapper/helper class around it
Maybe for config like this, will make sense to make variables: ```options:
watering-multiplier: 1.15
fertilisation-multiplier: 1.3
water-bucket-max-usages: 4
plating-time: 1.5
fertilizer:
basic:
material: COCOA_BEANS
# customModelData: 2810401```
Bcs, the values will not be changed at all. They are same for everyone. So in this case I should save data to variable and not needed to access .yml file for every right click (check if player is clicking with fertilizer). So its not bad to save to variable in this case I guess?
This is config for plugin witch allows player to watter and fertilize crops.
code looks like this: https://paste.md-5.net/fifumuweqi.cs
on line 36 is variable used, witch get data with onEnable method
So in case like this is better to use variables? or just make more sense to use them?
It's really just preference. Saving this data will take up (much) less than a kilobyte of memory, so don't worry about performance
If you think that it will make your code clearer, then do it
One of my friends told me is not necessary to save data to variable, bcs they are already in variable. Just another guy told me, I will losse CPU bcs I will every time access that file (sounds like blueshit). That's why I'm asking here. Thanks for advice.
Probably most used is saving to variable from config in onEnable method I guess, right?
You gotta Programm it in then though
config is an in memory map, no need to store in separate variables
there is no file access unless you load or save
something like this should be enough mby? ```public void reloadConfig() {
if (this.configFile == null)
this.configFile = new File(this.plugin.getDataFolder(), name);
this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
InputStream defaultStream = this.plugin.getResource(name);
if (defaultStream != null) {
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
this.dataConfig.setDefaults(defaultConfig);
}
}```
soo looks like it doesn't rly matter if I will save to variables or not as Kevin point.
your own configs not the default plugin one?
Hey, in 1.8 i wanted to summon an armor stand that is set to invisble via metada, because it will also be invulnerable. DO you guys know how to use meta data to do so ?
I've senn that the invisible tag is linked to Index: 0, Type: Byte, Bit Mask 0x20 but idk how to apply this to an ArmorStand
1.8 👽
IMO you probably could just make a loadConfig method that you reuse in onEnable and the reload command
But I believe that's the gist of it
Really the best workflow is make it work with sorta neat code and if it's too slow, then look into speeding things up
isnt that same if I use FileConfiguration?
do you have a need to use your own config files?
plugin has it's own config methods
Yes, I do. I need save data about player (ex. player XP) and some block (if chest is locked, is crop is wattered...).
I guess for this is better to make separate file.
do I this wrong or client bug? Is on 1.12.2, create an door with the name ACACIA_DOOR_ITEM (old version seams to not use ACACIA_DOOR). I set right data also ofc (it should not show the item at all then).
when place it it turn to right item. Only item some not get invalid texture is oak door.
where can i find the structure of the nbt tags of an item
<player>.dat files are used by servers to store the state of individual players. The format is also used within level.dat files to store the state of the singleplayer player, which overrides any <player>.dat files with the same name as the singleplayer player. These files are in NBT format.
ayy thansk
Someone has an idea of how i can check if mob is nerf by spigot ?
I made a stick to capture mob but i dont want that player can capture mob spawned by a spawner
I made that but its currently not working:
if(main.getUtil().checkCustomItem(it, "§2Mob Collector") && !it.getItemMeta().hasLore()) {
if(e.getEntity() instanceof LivingEntity) {
LivingEntity lve = (LivingEntity) e.getEntity();
if(lve.hasAI()) {
ItemStack its = it.clone();
its.setAmount(1);
p.getInventory().getItemInMainHand().setAmount(p.getInventory().getItemInMainHand().getAmount()-1);
p.getWorld().dropItem(e.getEntity().getLocation(), main.getUtil().addCustomLoreToItem(its, "§2Mob Collector", ("§a"+e.getEntityType().toString())));
}
else p.sendMessage(ChatColor.DARK_RED+"You cannot capture this mob !");
}
}
Mob is nerf?
Aka has no ai i think
A simple way would be to write to it's PDC a value if it spawns from a spawner and then check when they try to capture it
PDC ?
if it doesn't have AI isnt there a .hasAI method?
yeah
maybe they use an ancient version for dem pvp skillz
recently I got a commission for a 1.8 plugin
then I banned them
what a stupid question
no but I know someone who's the best coder for 1.4.6 plugins
@LeGuernic
damn shit he was banned
people still touch that shit lol
this leguernic dude claimed to be "well known in the spigot 1.4.6 scene" lmao
I think he's still on my server though
let's see
damn no
he also left my server or got banned, idk
lmao my supporters also remember him
Probably because he's the only user using 1.4.6
that makes sense yeah
Lol
@onyx fjord explain yourself
yeah
kacper
explain yourself
but do not use the words "firefox" or "gpl" or "foss"
public static void Circle(float x, float y, float z, float radius) {
for (double i=0; i<360; i+=10) {
float x_ = (float)Math.cos(Math.toRadians(i));
float z_ = (float)Math.sin(Math.toRadians(i));
PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(EnumParticle.BLOCK_DUST,true, x+radius*x_, y, z+radius*z_, 0, 0, 0, 0, 1);
for(Player online : Bukkit.getOnlinePlayers()) {
((CraftPlayer)online).getHandle().playerConnection.sendPacket(packet);
}
}
}
Hey, this command makes my game crash, with an UnpooledHeapByteBuff(ridx:38, widx:38, cap: 38) error IG
and a java.lang.ArrayIndexOutOfBoundsException: 0 error in the console
Is it because i'm sending too much packet ?
But 36 looks fair :/
what version? why are you not using mojang mappings 😢
I'm using the hasAI but its not working (idk why)
And im on 1.19.2
What should i use ? I'm using spigot 1.8.8 :')
There has literally never ever been a reason to do this
The other commands doesn't work
Player.spawnParticle
not in 1.8
iirc in 1.8 you actually need packets
Uh yes?
hm I just checked the javadocs for player in 1.8 and there's no spawnParticle method
how do u get the javadoc for minecraft 1.8 ?
Like in particular
Tysm
the official source is to run buildtools though
you haven't heard of buildtools?
where did you get your spigot .jar from
lol
to get javadocs for 1.8.8:
java -jar BuildTools.jar --rev 1.8.8 --generate-docs
Error: Unable to access jarfile BuildTools.jar
?bt