#help-development
1 messages · Page 2051 of 1
i wanna do something dumb with it
nO PLEASE DONT
How much would you ask for a multi version cuboid library and docoumented?
i beg you
how about like
ugh I am trying to optimize a plugin and it doesn't store the Inventory anywhere
it only stores the names
Could y'all move to #general?
ill mlg it
yeah sorry
and what does that mean?
and if i dont fail then ill hyper max a set of leaf armor
#general kekw
Well first you'd have to find the immutable implementation, probably something like java.util.Collections$ImmutableList, which you would access via Class.forName, then reflectively access the field via getDeclaredField, and acquire its value via the immutable instance.
Seems like you'll have to do that then.
Comparing by name isn't wise since inventories have default names based on their type, e.g. InventoryType.CHEST = "Chest"
so you basically cant modify the underlying collection grr
on a not cheaty way
Yeah that's the point
You shouldn't be able to mutate an immutable collection
Makes sense that you'd have to do it reflectively
Between Guava and Java's?
ye
Guava's ImmutableList is not a view
It stores values itself instead of delegating calls to an underlying collection
but whats a view i dont understand that
We just explained it :p
so a view is a delegation which blocks modification?
Don’t InventoryViews store an inventory and a list of players accessing the inventory?
They store the top and bottom inventories
The top inventory being the one a player is accessing, and the bottom inventory the inventory of the player
No
Makes sense
There's an interesting implementation detail
In CraftBukkit, the "active container" and player container are separate fields
The active container is the inventory the player is viewing
While the player container is their inventory
So, the player opening their own inventory does not create an InventoryView
Because it's not handled the same as something like a chest GUI
Unlike Collections.unmodifiableList(java.util.List), which is a view of a separate collection that can still change, an instance of ImmutableList contains its own private data and will never change. ImmutableList is convenient for public static final lists ("constant lists") and also lets you easily make a "defensive copy" of a list provided to your class by a caller.
ahe when changing that java.util.List, the actual collection you want to protect isnt altered?
With unmodifiableList, get and forEach and such will return values from the underlying list, but methods like add, remove, and set will throw an UnsupportedOperationException
Guava does the same, just without an underlying list
I haven't looked at Guava's immutable implementation but I'll check it out eventually, probs
I would like to know why so that I obtain a greater understanding
ah the unmodifiableList changes when changing the undlerlying list
im starting to understand
short durability = p.getInventory().getItemInHand().getType().getMaxDurability();
if (!(p.getInventory().getItemInHand().getDurability() == -durability)) {
p.getInventory().getItemInHand().setDurability((short) -(durability));
Zenon.getInstance().getConnection().createStatement().executeUpdate("UPDATE ZenonPVP SET points=points-"+price+" WHERE uuid=\"" + p.getUniqueId() + "\" ");
p.sendMessage(format("&e-"+price+" points"));
} else {
p.sendMessage(format("&3You are already at max durability"));
}``` The statement still gets executed even though the durability does not equal max durability?
whats better using string format or .replace()
please assign that short to something
it looks horrifying
is there a way to remove Symbol from banner patern lore?
should look like this but without "Símbolo"
I know its probably a very stupid question for most of you but
how do I call a function that is on another class
like I have a Gui Function that returns a gui and I want
to access it from a different class and using the information that is already there
Class.function()?
Races is the class so I try to do
private static Races races;
and then call races like this
p.openInventory(races.GuiCreator(p));
(p is player)
||wheres the code block : (||
yes
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
so I do private Races races;?
yes
?naming should be add
Standard Java Naming Conventions:
Packages: Names should be in lowercase. ...
Classes: Names should be in Pascal Case. ...
Interfaces: Names should be in Pascal Case. ...
Methods: Names should be in camelCase. ...
Variables: Names should be in camelCase. ...
Constants: Names should be in uppercase.
yes
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
Manager manager = new Manager(this);
}
}
public class Manager {
private final MyPlugin plugin;
public Manager(MyPlugin plugin) { this.plugin = plugin; }
}```
thats the best thing
instead of a static getter
?naming-conventions
there might be situations where you need one but try to avoid it
well
it doesnt matter
in most cases
not really imo
still dont understand :((
then learn java
is it possible to extract chunk X and Y from ChunkData?
Actually I’d say not but it’s better for sure
Radius = 10
And i didnt move from the location (Im inside the radius)
So im definitly giving up
i have a troll command with 3 cases and i want that you can choose the case with tab how can i do it
let your command class extends TabCompleter
then override the abstract method
check for the args length and the content
thats not how to learn
I mean I gave you working code 3 times now
The paste urls are down
They dont load on my google
I was going to say
And how check if player location, is inside the 2 locations?
wha-
Using the contains
Wouldnt that math lag the sever when having lot of claims with large radius?
No it won't lag
And call it on MoveEvent?
Computers are fast machines
No? This is the most efficient method
fast to a degree you will never imagine
Allright i will try
No need for more than 2
Well if you want a circle that's different
addition takes 1 to 2 cpu cycles
circles in mc
But you can inflate a 1x1
I need the to calculate 2 corners from 1 location and 1 radius
That what i need, ge tthe red points based on a radius
btw @sterile token
Idk why its so diffcult
whats ur pc cpu ghz
Its not for my pc
just tell me
Its public plugin
Yes just tell me
My pc has ryzen 5 3600, 32gb of ram
damn 32 gigs ram
But you know all the points
eitherwya
i wish i could afford that
I don't understand
And what about the radius?
I want you to define how many block will protect around the protection block
gaming computers usually have 4 ghz
the distance between min points and max points / 2
That's easy divide the distance between x1 and x2 by 2
Mike i dont understand sorry
(those cycles are per second btw)
IM too confused
can i clear potion effects with getActivePotionEffects.clear()?
computers are way too fast
I want to people be able to set how many blocks around (literally a radius) will protect, knowing the center of the protection (where its placed the protection block)
Idk why i cannot do that
Such a simplier thing and im so dumb
Using inflate
You can inflate from a point. You can do other math to find the center
Does it support from 1.8x to lastest sipgot version?
the world's fastest cpu can perform around 6 billion add operations in 1 second
a fact i think
Wouldnt apply using world edit cuboid?
My big problem is that i dont know how to calculate the 2 corners knowing a center location and a radius
Your code didnt work
I test and still aying false
you forgot to say "fun fact: "
When i was inside the location
zacken how much do you ask for coding yourself that thing?
Because im stressed
To test everything and nothing works
No unless you use the wrong one by accident
is it still bad if its in a different module?
I will start from 0 again using this base that you told me it was correct
public class RadiusCuboid implements Cuboid<Vector> {
private final Vector first;
private final Vector second;
public RadiusCuboid(Vector location, Integer radius) {
this.first = new Vector(location.getX() - radius, location.getY() + radius, location.getZ() + radius);
this.second = new Vector(location.getX() + radius, location.getY() - radius, location.getZ() - radius);
}
public boolean contains(Vector location) {
return null;
}
@Override
public Vector getFirstPoint() { return this.first; }
@Override
public Vector getSecondPoint() { return this.second;}
}```
The operators or what?
I don't get why you don't just use a simpler implementation
Nevermind
I dont understand when you said negative values
So my whole class its wrong?
I ill start from there
on contains method?
Or the constructor?
You never told me that before
Or i never seen that
So i have to cahnge operators or what?
but i dont understand
I ill post my question on stackoverflow
Maybe they can help me
In which vector? first or second?
why you have 2 values?
Im probably confuse because never worked with 3d models
Why is Gradle failing to load changes now? It didn't have problems before:
plugins {
id 'java'
}
group 'com.macintoshfan'
version '2.0.1'
repositories {
mavenCentral()
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
implementation 'org.jetbrains:annotations:23.0.0'
}
test {
useJUnitPlatform()
}
Has the link changed for 1.18.2?
Nothings changed. Check your logs
Could not find spigot-api-1.18.2-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT:20220316.085735-20).
Searched in the following locations:
https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.2-R0.1-SNAPSHOT/spigot-api-1.18.2-R0.1-20220316.085735-20.jar
It did work before, but does not now.
Allright, i will watch a video to understand how works 3d graphs using x, y, z
I rember on high-school just orking with x and y*
it feels sort of weird how invariably the largest classes I have exist because they just have hundreds of lines of strings
like over 500 lines of strings of me just defining what is in the default arena
I just tried 1.18.1, and it worked just fine. Why not 1.18.2?
how do I add worldedit 7.2.10 to dependencies?
pom.xml
How to use it?
<repository>
<id>sk89q-snapshots</id>
<url>http://maven.sk89q.com/artifactory/repo</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.10-SNAPSHOT</version>
</dependency>
not worked
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Ah ty :)
say it drops for 30 seconds straight it will destroy itself and drop its item
if you wanted to make it exist longer, u can just keep setting the time it existed to 0.
Cannot resolve org.hamcrest:hamcrest-core:1.1
Clean up the broken artifacts data and reload the project.
im pretty sure setPersistent will not help you. and it will still destroy the block
dont u have Entity#setTicksLived?
u could try setting that to 0 every X amount of time
im not aware of one. and already heard lots of people complaining about this
there should indeed be a better way. but i think there is not.
Something like this you where saying?
public List<Block> getBlocks(Location pos1, Location pos2) {
World world = pos1.getWorld();
List<Block> blocks = new ArrayList<>();
int x1 = pos1.getBlockX(), y1 = pos1.getBlockY(), z1 = pos1.getBlockZ();
int x2 = pos2.getBlockX(), y2 = pos2.getBlockY(), z2 = pos2.getBlockZ();
int lowestX = Math.min(x1, x2);
int lowestY = Math.min(y1, y2);
int lowestZ = Math.min(z1, z2);
int highestX = lowestX == x1 ? x2 : x1;
int highestY = lowestX == y1 ? y2 : y1;
int highestZ = lowestX == z1 ? z2 : z1;
for(int x = lowestX; x <= highestX; x++)
for(int y = lowestY; x <= highestY; y++)
for(int z = lowestZ; x <= highestZ; z++)
blocks.add(world.getBlockAt(x, y, z));
return blocks;
}```
And sorry for being so asshole and annoying
Its taken from spigotmc thread, just to ask you if its similar
I know that i dont have to loop
u could use an armorstand
So what i can do? I just wanna finish this, and stop fucking on the discord
what do you want to achieve in the end?
maybe i can help
Oh allright really thanks
Let me do a diagram
On block place, i keep the block location (x, y, z) into a list.
I having problems to calculate the Pos1 and Pos2 knowing 1 location and radius.
Let say the blue part its the protection block, based on that cordinates and a radius i want to calculate the 2 corners
My goal, to people be able to change how much blocks around (a radius literally) will be protected by the protection block
add radius to the x and z?
so that includes Y axis?
I think yes, because the protection will be 3D, top, botton, right and left
So let say, you put the protection block on coords: x=0, y=0 and z=0 and radius 5, the x, y, z should protect 5 blocks around
is there a way to get every Attribute avaible for an entity?
without actually having an entity
okay, give me a few minutes okay, gonna test some stuff
Oh really thanks
declaration: package: org.bukkit.attribute, enum: Attribute
you mean this?
yeah
i would like to have a way to store in something like a list, all the attributes avaible for an entity, without having the entities
but that doesn't explain how to do that
Attribute class doesn't have a .isAvaibleFor(EntityType type)
hmm
yeah
without manually add the attributes that i know are avaible for that type of entity
Again I solved this lol. You create a container at a position and then inflate it by x amount and voila
I don't think theres a way to do that automatically. Sounds like something you have to do by hand
i guess there isn't a way to do that
yeah, i though that too but still wondered if someone knew a way
thanks anyway :=)
Allright le me know if you need something
hat should be voila?
My code I wrote has an inflate. You just need to set the initial to 1x1 block aka the center then you can inflate it by x y z and you've got a x by y by z square with an origin of your original position
cant u just +5 for each coordinate
I have done of the positon +5 and the other -5
didnt see this. yes this is perfect
So i dont kno why still saying im not inside the claim, when im inside
Use the code he provided. Its your best bet.
Allright
Create the bounding box with both points of your block
then inflate it by the radius
then ur good
`Mike this would be like this (https://paste.md-5.net/zoxelecoqi.java):
Location loc = player.getLocation();
int raidus = 10;
CustomBoundingBox cuboid = new CustomBoundingBox(loc.getX() + radius, loc.getY() + radius, loc.getZ() + radius, loc.getX() - radius, loc.getY() - radius, loc.getZ() - radius);
cuboid.inflate(radius, radius, radius);`
LIke that so?
no
So?
Im confused
No dont use the + radius
ur already adding the radius
Just put the initial coords of it
Oh allright
Location loc = player.getLocation();
int raidus = 10;
CustomBoundingBox cuboid = new CustomBoundingBox(loc.getX(), loc.getY(), loc.getZ(), loc.getX(), loc.getY(), loc.getZ());
cuboid.inflate(radius, radius, radius);
My issue is that i dont know the 2 corners
you dont need them
I jsut kno the center coord
do you specifically need the two corners?
How do I use p.setStatistic();
once you inflate it just call the isInside method
use CustomBoundingBox#isInside
Because so them the player couldnt break around
Yea you dont need it specifically
The isInside will return true if they try to break inside of the box
so u just cancel the break then
also you should probably use getBlockX(), getBlockY(), etc in this case
Allright and the constructor will be liek the one i send?
But changing getX, getY and getZ, for getBlockX, etc?
yes
it would be the location of the center block
yea you also need to pass in the location of your center block indeed
not the player
Location loc = (your center block).getLocation();
So will be:
Location loc = block.getLocation();
int raidus = 10;
CustomBoundingBox cuboid = new CustomBoundingBox(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
cuboid.inflate(radius, radius, radius);
but, block.getLocation. will be the block the player has broken no?
uhhhh
not the center block perce
Well you can make a constructor that assigns x1 and x2 to the center block
Wait because i have to use for 2 things
ok so initially to create the box you need the center block. When you check if its inside you want to use the block that the player is trying to break
1- Create the cuboid when player place the protection
2- Check the cuboid when player break, move, etc
So im confuse again
I was unconfused but i get again
yea nvm haha
I want the next:
- On block place, if it his claim allow him to place blocks, if not doesnt allow him
- On block place, if claim doesnt exists create the cuboid
- On block break, if claim exists doesnt allow him
But im confused again
whats there to be confused about xd
if ur not gonna help then stop commenting zack, he obviously doesnt understand
So for creating the claim just do:
CustomBoundingBox cuboid = new CustomBoundingBox(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
So?
and you telling him you already told him isnt doing anything
I know you explain but im so dumb that i cannot do it
anyone? i cant find a solution in google
yes
Yeah
and tell us how it would look like
oh ok
Theres just too many people talking i think and its confusing him
Black = protection block (1 location)
Blue = the amount of blocks
So if in this case the radius will be 3, protecting 3 blocks around the black one
Do i have explained? That what i mean with radius Hex, Kero
// In the listener for block break/place
Block b = ??? //The block breaked or placed
Location loc = b.getLocation();
if (cuboid.isInside(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())
{
// Also check if they own it, however you want to do that
// If the block is inside the cuboid and they dont own the cuboid cancel the event
event.setCancelled(true);
}
Yeah i know
thats it then 🤔
So my claim object, will contains just a single location?
Maybe in your claim object. Have it store the bounding box itself
Oh yeah its better
I was trying to put some snippet into my project for resetting pitch, but when I put it in the "PacketPlayOutPosition" was red, and I'm not sure if I'm supposed to import some library or what
private void resetPitch(Player player) {
PacketPlayOutPosition posPacket = new PacketPlayOutPosition(0,0,0,0,45, Set.of(PacketPlayOutPosition.EnumPlayerTeleportFlags.a, PacketPlayOutPosition.EnumPlayerTeleportFlags.b, PacketPlayOutPosition.EnumPlayerTeleportFlags.c, PacketPlayOutPosition.EnumPlayerTeleportFlags.d), 1, true);
((CraftPlayer) player).getHandle().b.sendPacket(posPacket);
}```
does anyone know a minecraft bedrock api, to fetch player info such as skins? something like crafatar.com but for bedrock
Did you use the remapped jar?
?paste
it might also help you to use this instead, i edited it a little bit to fit your needs more. https://paste.md-5.net/zuhuleqili.java
Oh allright really thanks
Really thanks to everybody, Epic, Kero, 2hex, zacken and mike for being helpful
ah yes that does seem better for him. now he has to figure out how to use that one now tho :huh:
omg my emoji didnt work
are external emojis blocked lol
yea
darn
unless you are a booster :D
What remapped jar?
first off, what spigot version are you using
1.18.1-R0.1-SNAPSHOT
Ok
as of 1.17 NMS is different
read this post for info (the second message)
isnt rr a win win
if ure gonna do it u prob need money
if u win u get money
if u lose ur suffering ends
arent gambling plugins not allowed on spigot anyways
pretty sure i read that somewhere
i could be mistaken tho
they are, just not premium
oh okay gotcha
should i make a russian roulette plugin
premium gambling plugins that existed before that rule however are allowed to stay
lets all make it together
and let us make the death visualized as realistic as possible
and a lose ends with a 1/2h ban
that would be sick but lotta work
im not into selling things
but not sure what type of youtuber would do that on their channel
either public or nothing
lol
ye
and make custom messages
ur character talks without you talking
e.g
"Dear god, be with me..." click
Player 1: Uhh.. Can I go back home.. I don't wanna continue..
Player 3: I'm definitely dying this one..
Player 2: If I win this, I'll pay off every debt on me.
hm, nah. would be funnier if it comes from the players itself
Player 5: I will leave this alive, hopefully
nothing forced
stuff like this
would be more dramatic if its forced
if its from the players it would be prob
or like messages which spoil the outcome
"I have a bad feeling about this.."
and like
the revolver
a huge one
is held by a npc wearing a costume
handing it to the next person
oh and premium features like a rocket launcher
oh and messages shouldnt be randomized
the personalities should
each personality has its own messages
so it wont be like this:
Player 1: I will win this and get this money, I will pay off my debts!
Player 1: Oh god I'm sorry please let me out, I have children I beg you
2Hex
Yes
Yes
how do i get the shaded reobfuscated jar with paperweight userdev
its giving me a classnotfound with the dev-all version, i assume the dev versions are not reobfuscated?
make your build dependon reobfjar and then it's just your normal output jar
ight ill try
still getting
java.lang.NoClassDefFoundError: net/minecraft/server/level/ServerPlayer
but i need to shade another module with it
what jar are you trying
building with paperweight (build task) generates
*.jar // no shading
*-dev.jar // idfk
*-dev-all.jar // shading
i need shading
but theres no *-all.jar
really?
show your build.gradle
it's not dev-all
What is "VarInt" on the wiki.vg/protocol page?
Man i wish i knew x86 assembly like a god
there aren't many tutorials or sources referencing assembly
I like varints.
so it's just int ?
Yes, it's essentially just a different way to encode int.
I mean, byte-wise they're pretty different, but if you're using ProtocolLib then you'll likely just write/read ints.
In most cases, at least.
so if I'm trying to get the EntityId of a packet that I'm listening to (the field is VarInt), what would I do?
Read a var int? :D
There are some situations where varints actually waste an extra byte, but that's negligible for how much they save.
this is the packet
What in the name of god is this
assembly
I know it's x86 but
for loop
which one would it be here?
getIntegers(), probably
Also
One important thing about ProtocolLib!
Assembly, the most human readable language ever made
The index of the values in a packet is relative to the fields of the NMS packet.
any reason why they're not relative to the wiki.vg website?
Because I think ProtocolLib uses reflection to instantiate a packet
That way avoiding issues with versioning
I think they are?
Wiki.vg documents the protocol, the actual implementation by Minecraft might be different
So, each packet is represented by it's own class in NMS.
You basically need to check the fields
for example
I mean, they are in order on wiki.vg and I think they're kinda the same order on the ProtocolLib as well since anyways they're using streams and the order matters
int i0;
int i1;
IBaseComponent c0; // or whatever the class is
would be
getIntegers()
.write(0, /* int here */)
.write(1, /* int here */);
getChatComponents()
.write(0, /* component here */);
Also yes those indices are correct
Yes, but I'm talking about the class fields, the implementation by Minecraft might have different fields in different orders
Also don't use PacketWrapper it's out-of-date.
In the end it all gets sent / read in the correct order, but some packet classes might not store certain or different fields
it could, yeah, but you always have reflection and javap which is very useful as well :p
What exactly am I supposed to supply as an object for in the parameter if I just want to get the object from index 0?
You don't wanna use getField
😐
You wanna use read
I see
That returns the actual value
getField returns the instance of java.lang.reflect.Field that represents that value
can someone of you remind me does low endian mean that its starts from the right or the left (binary value)
little endian whatever
Little-Endian means the smaller value's on the end
Big-Endian means the bigger value's on the end
so which is normal to human writing
did I get that backwards
yea
Yeah
Supposedly Big-Endian is more common in some areas.
Like uhh
I think networking?
Java is big endian
Yeah okay so a lot of networking stuff is Big-Endian
But Little-Endian is more common for architectures
DH and DL are the High and Low halves of the DX register. or EDX or in 32 bit registers, does this mean if i acess DL 8 bit register i get the least significant byte out of the EDX register
suppose its little endian
private void registerEntitySpawnPacket(){
Games.getInstance().getProtocolManager().addPacketListener(
new PacketAdapter(Games.getInstance(), ListenerPriority.NORMAL,
PacketType.Play.Server.NAMED_ENTITY_SPAWN) {
@Override
public void onPacketSending(PacketEvent event) {
// Item packets (id: 0x29)
Player player = event.getPlayer();
if(!isDisguised(player)) return;
if(getDisguise(player) == null) return;
System.out.println("pass1");
if (event.getPacketType() ==
PacketType.Play.Server.NAMED_ENTITY_SPAWN &&
(getDisguise(player).getDisguiseEntity().getEntityId() == event.getPacket().getIntegers().read(0))) {
System.out.println("pass2");
event.setCancelled(true);
}
}
});
}
Am I doing the wrong packet here?
Named Entity Spawn is the spawn packet for players, depends on your use case if that's the right packet
yeah no I was doing the wrong one
do you mind if I add you as a future reference? 😀
👍
People tend to just message me out of the blue with questions bc... idk, I guess I seem smart :p
Stop tooting your own horn 
I mean when you can answer protocollib questions confidently that's when you know... 😆
I can answer questions about much more than ProtocolLib lol
I just delve into the depths of unsafe and internal shit
Seeming friendly seems like the most likely reason why people usually approaches to ask :p
Well yeah but usually learning protocollib is towards the end of the bucket
I personally don't find myself to be a friendly person.
You could've just replied to my question with a snarky attitude and told me to look it up or something
At least is not like the: "did you even learn java before coming to ask here?? lol get good before joining to the spigot community"
Sometimes I'm like that
Well
Not the latter half
But more so the "Do you even know Java?"
Usually when someone is so bad that they honestly need a ?learnjava
It was just a lil joke :D
You will repent for your sins. 🔪
I mean what
Making disguises for your plugin is so time consuming 😩 💀
sometimes I point the specific part of java they need to learn to answer their question and some other times I ignore when they're just simply too bad kek
Fair enough
A vast majority of questions can be answered with either learn java or read the docs
that doesn't help people who have actually tried doing both of those and just need some minor assistance in the right direction
or pointing which part of the docs or java stuff they need to be looking for
I guess every people's different
Most people who come here haven't done either so it still applies as a general do a before b philosophy
Hey, could someone help me with setting up these flags for a relative teleport using PacketWrapper?
WrapperPlayServerPosition relativeTeleport = new WrapperPlayServerPosition();
relativeTeleport.setX(0);
relativeTeleport.setY(0);
relativeTeleport.setZ(0);
relativeTeleport.setPitch(10);
relativeTeleport.setYaw(0);
Set<WrapperPlayServerPosition.PlayerTeleportFlag> set = new HashSet<WrapperPlayServerPosition.PlayerTeleportFlag>();
set.add(WrapperPlayServerPosition.PlayerTeleportFlag.X);
set.add(WrapperPlayServerPosition.PlayerTeleportFlag.Y);
set.add(WrapperPlayServerPosition.PlayerTeleportFlag.Z);
set.add(WrapperPlayServerPosition.PlayerTeleportFlag.X_ROT);
set.add(WrapperPlayServerPosition.PlayerTeleportFlag.Y_ROT);
relativeTeleport.setFlags(set);
relativeTeleport.sendPacket(player);``` this code is probably really stupid looking but I honestly have no clue how I'm supposed to format it
Don't use PacketWrapper
It's outdated.
At least, I believe so, since some packet wrappers don't seem to make sense.
Well I don't know of any other simple methods so I'm just going with this
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
i love when this happens
Why are you teleporting using packets rather than via the API?
The API doesn't support relative teleportation + API is not thread safe
Relative as in between dimensions?
relative as in the minecraft cmd "/teleport Player ~ ~1 ~"
pretty sure u can just calculate a relative location
You can make it relative with just a little work?
It's not the same, relative keeps the player's velocity and only adds to their current location
Sending a teleport packet wont change the players position on the server though
im not sure how the sever would respond to that actually
maybe by just placing you back
Store velocity before teleporting them?
Then just add to their location?
Probably correct the position as soon as the client responds with their (now wrong) coordinates
yea, thats what i thought
yeah.. packets are not the way to go here
Well the thing is I want the server to update the client's pitch and yaw by a certain amount and it needs to be smooth
You understand that entity teleport does the same stuff
it lags you back
Sending a packet instead of using the API isn't some magic bullet
It works with minecraft cmds, so I thought there would be some way to do it in the code
it's usually worse
there is... you can't just type +1 in the code but you can do
(PSEUDOCODE BTW)
Player.setLocation(player.getX()+1,player.getY(), player.getZ())
which is like
the same thing
uh
have the vanish plugin unregister them from the tab completion list?
because it's either that or you manually recreate /ping and /msg
lol
.
I mean that doesnt prevent you from typing their names in
just tab completing them
filter for first arg?
yea PlayerCommandPreProccess or somethn
yep
Well he wants it for every command haha
Thats for incoming commands, not incoming tab requests iirc
hes not talking about tab requests at all
Huh, I misunderstood this then
What do you hope to accomplish by doing this anyways?
why is it so bad if they type their names in
this tbh
so what 🤔
You could do something like giving admins the ability to block all incoming dm's or teleport requests or something specific like that. To be honest I dont think youre going to find what youre looking for
You can really hide them from every command
I think what you're trying to do is unrealistic
i guess you would need to make the player appear offline to the server
im pretty sure SuperVanish does this
and supervanish is open source
could look into that
Even when checking the player's velocity and setting it back after the teleport it's not a seamless transition. Like you can tell you've been teleported. I've been trying to change the pitch of the player for a recoil system, which means that I can't take the pitch and yaw of the player and then teleport them up a bit since that'll create a yucky lagback feeling that doesn't happen when you use relative.
quote from supervanish Hides invisible players in the list of logged in players in the serverlist (configurable)
If your plugin controls the command you could simply check if the player in the arguments is vanished, but if you don't control them youre kinda screwed
i think u want that.
Yea it doesnt do anything else other than that basically
just like silent chest and other syuff
Hold on so let me get this straight
hmmm sounds like a difficult problem
you want to make it so they cant type in any commands at all with a vanished player as a target?
Wouldnt that just let the user know that theyre online and vanished
"oh i cant use this command on this player... they must be vanished"
"This player is offline"
you'd just have to redo every command manually
or do packet magic to just drop the command if it contains those names
- Listen to the preprocess event and write a handler for every possible command (rip)
- Make the commands yourself and check if the player is vanished
Dont see any other possibilities
I have run into a problem
Zak sounds like you should make your own vanish plugin
and integrate it with your custom commands
so I'm listening to the packet for spawning entities, but in that listener I'm checking if the entity id of the packet spawn is equal to the entity id of the player's disguise which isn't spawned yet according to that packet
Do you have a standard command class that you inherit for your custom commands?
if not youre gonna have to edit them all manually
yea @quaint mantle i think the only way is to make the commands yourself and support it.
or use packet magic
thats lame tho
Some command libs like Aikars check for vanished players automatically which is pretty nice
He means filter out the commands that include the players names that are vanished
Which basically you can just use the command pre process event for
Yea
okay but there's this thing called .split(" ")
so just make a bunch of cases
No
you're not getting an easy fix
That’s so fucking stupid
stop being an ass if you don't have any better solutions
How do you make a bunch of cases for an infinite amount of commands
I already gave a solution
Inject code into every plugin changing their commands 😂
It’s actually way better buddy
He can rework his network of custom commands
To integrate with his custom vanish plugin
All solutions will suck to implement
That’s a win win in my book
which one
this is the truth 🙏
In the long run doing what I suggested is the cleanest way to implement it
No need for packets
W H I C H one
At all
wow no packets so cool
My guy do you know how to read 😂
BRO
B R O
I count 2
there is definitely not
you just don't know how to count
thats indeed the cleanest way.
You don’t know how to read
This is chaos
Yes because one person gets butthurt and can’t read English
I'm not the one who started insulting other people for perfectly valid solutions
but okay bud
Anyways, good luck on your issue. However you decide to fix it @quaint mantle
indeed though, good luck Zak
I’m far from upset but thanks
it sucks that there aren't any easy solves but that's just part of coding :P
If you say so ^^
I did say so
bump
🥓
we need a little more info, what ru tryna do.
I'm creating disguises for my plugin and I'm trying to cancel the entity spawn packet for whoever owns the disguise
does this disguise plugin disguise you as any entity or somethn?
yes
so why are you trying to cancel an entity spawn packet. i dont rlly understand.
so that the entity doesn't get in the way of the player and they don't see it or aren't able to interact with it at all
so just spawn it for everyone else
I was previously just sending the entity destroy packet upon creation, but changing worlds & things of that nature resulted in it not being a viable option
So how am I supposed to compare entity ids if the entity isn't created yet, disallowing me to even compare it anywhere else
What if you add a delay to the id check?
might not be the most reliable solution tho, idk
that would be the equivalent to waiting 1 tick then cancelling the event
wouldn't work
That's true
private void registerEntitySpawnPacket(){
Games.getInstance().getProtocolManager().addPacketListener(
new PacketAdapter(Games.getInstance(), ListenerPriority.NORMAL,
PacketType.Play.Server.SPAWN_ENTITY_LIVING) {
@Override
public void onPacketSending(PacketEvent event) {
Player player = event.getPlayer();
if(!isDisguised(player)) return;
if(getDisguise(player) == null) return;
System.out.println("pass1");
if (event.getPacketType() ==
PacketType.Play.Server.SPAWN_ENTITY_LIVING &&
(getDisguise(player).getDisguiseEntity().getEntityId() == event.getPacket().getIntegers().read(0))) {
System.out.println("pass2");
event.setCancelled(true);
}
}
});
}
Here's the current code
it passes the 1st one and throws errors beyond that for reasons that I described
isnt there a way to spawn it for everybody except the player who is disguised?
I havent messed with entities for a while i forget
wait yea cant you just send the spawn packet to everyone but the player 🤔 or am i missing something
watching a tutorial that uses TasksBukkit as a type but when i write it in nothing is found. has it been deprecated? i'm confused.
ok i was going to use that but in the tutorial the guy uses bukkittasks too so i got more confused
👍
anyone got any ideas why skeletons won't aggro during daytime?
or even night time I am extending their follow distance but they're just sort of chilling
got any code to show?
this is out of the box mc ai as far as I can tell
public void run() {
if (Bukkit.getWorld("world").getGameTime() >= 14000
&& Bukkit.getWorld("world").getGameTime() < 24000) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"title @a actionbar It turns night.");
System.out.println("Alerted players of nighttime");
}
if (Bukkit.getWorld("world").getGameTime() < 14000
&& Bukkit.getWorld("world").getGameTime() >= 0) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"title @a actionbar It turns day.");
System.out.println("Alerted players of daytime");
}
System.out.println("checked time");
}
hmm
are you in god mode or something 😂
it prints "checked time" whenever the task runs but doesn't sout the "Alerted players of ..."
if anyone knows how i'm misusing the getGameTime or getWorld let me know
game time isnt what you think it is
nope when you get relatively close they do aggro, and sometimes they aggro from a bit farther but in general it seems like they are just ignoring the follow distance
game time is the time since world generation i believe
also when you hit them they also aggro
or mayeb im mistaken
oh shit
No... I'm spawning a real entity and listening to the packet, then trying to cancel it for just that player who "owns" that npc
you're probably right
hence why it's MUCH bigger than either of those two conditions i have in the if statements
ok
documentation doesn't say that 😭
how should i go about getting the actual game time
cuz this is confusing me
trying getTime()
sounds right
Well the docs says getTime is relative so I assume that's correct
ty taco man
ok perfect
it works
thanks
just um, the title command doesn't work
i still dk how to properly send minecraft commands apparently
Oh
because i didn't add quotes maybe?
o
sendTitle()?
sweet
ok yeah i find time and time again that i don't need to use minecraft commands
gotta break habits ig
sorry for drowning your problem in text
okay and just so im clear, how come you cant destroy it after? was there issues?
Issues arose when a player changed worlds
since I can't exactly predict when they're completely loaded in the world
Unless I'm missing something 😏
can you elaborate specifically
- spawn mob and send destroy packet for player
- Everything works
- Player is teleported to another world
- mob shows up again as it's spawning in the world
ohhh okay i get it now
hmmm
cant you destroy it every time it spawns tho or?
you have to wait for the player to load in tho...
That's what I'm trying to detect...
yea
And yes
seems like quite the pickle
Does it have to be a real entity for a specific reason?
because I'm doing real things to it and there's pretty much no reason to modify every single thing that I'm already doing with the bukkit api if I should be able to do it fine
hmm i see
just tryna think of every possible thing haha. im not extremely familiar with disguise stuff hopefully somebody else has some pointers
you're fine it's better than nothing
I'm trying to make a custom entity much like a traditional custom item. basically i want a unique mob (that can really just be any mob) but has special properties (like max health) and can be identified as the new custom entity. How do i make this kind of entity in spigot?
ok nvm found a good resource
all i really wanted was just a datatype for entity that was comparable to itemstack
this doesnt create a new instance everytime the event is fired right?
public class BeltManager {
JsonObject belts = new JsonObject();
would belts reset?
no?
its created whenever BeltManager is initialized
and it belongs to that instance
i think i understand now thanks
When i want to set the packet meta in protocollib, do I have to sat arrays as json-strings?
The click manager is created once and for all whenever enabled
the belt manager also
it will only be destroyed and recreated when you reload the plugin or you choose to unregister the listener
I have a custom event that extends InventoryClickEvent. Now I want to listen to an InventoryClickEvent and call my custom event in some cases. Is it better to use the same HandlerList as the event I'm extending, or a custom one?
If I use a custom one, I explicitly have to listen to ChangedItemMoveEvent. Listening to InventoryClickEvent is not sufficient (that's bad)
If I use the original event's one, I have to check if the event is instanceof my custom event in my own listener, and then return (not bad but also ugly)
My event: https://paste.jeff-media.com/?0e14f17435854f1e#GphoEqUvkpcebPivHc5MNF4BbWPMetMeD2A9ezcwd4a8
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
why is it again implementing interface
i mean, why would you want to create a custom event if you want to listen to InventoryClickEvent anyways?
because I added "extends InventoryClickEvent" later and simply forgot to remove the interface
I sometimes also want to listen only to the custom event 😄
does Bukkit.getScheduler().cancelTask() apply to tasks that are scheduled to be run in x seconds? or only ones that are actively running right then?
future ones too ofc
actually its even the opposite
if your task is currently running, it still finishes to execute
it will simply stop future tasks from getting started
ah I see, I think my issues is that I was checking currentlyRunning instead of isQueued
so if it was queued but not running yet it wasn't being cancelled
hew how do i create a potion itemstack? new Potion is deprecated
i mean idk whats wrong with deprecated stuff because its worked before
so i would go with the first way. i guess thats what you want to achieve with a custom event
new ItemStack(Material.POTION) ?
lol well, according to the docs it means "the name of this modifier."
Yeah it's just an identifier
So passing in the stringified attribute type is enough?
E
G
AttributeModifier(Attribute.GENERIC_ARMOR.toString(), 69.0, AttributeModifier.Operation.ADD_NUMBER)
How can I use different java in git bash ?
I mean more like a name that describes the attribute modifier
How do I convert a bungie component to a vanilla chat component?
toLegacyText()
you should use your own name instead of just reusing the attribute's name
I think it's supposed to be used like this:
if you want to create an armor that makes you walk twice as fast, and the armor is called "Fast Shoes" I'd call the modifier "fastshoes" or sth
Is it ok to use the config as a database or should I implement some sort of database?
without the _? Like fastshoes instead of fast_shoes?
Is there a debug info send event? (eg. whenever a mob sents a pathfinding data with DebugPackets#sendPathFindingPacket)
I don't think that it matters
i mean, i would not use the config for data storage. but rather create a specific file for that. or use a database. but it really depends on your storage needs
if you want the admin to actually edit the data, it may go into the config. otherwise it belongs into a separate file or database
what amount of data do you store?
for small things I'd use json or sqlite, otherwise a proper db like postgres, mysql, etc
you could even use YAML if you want it to be easily editable and don't have megabytes of data
or save in bytes :D
its the fastest. but also uneditable for someone without knowledge
I'm just storing player settings for my plugin and their in-game balance
Is my api-version the version I put in my plugin.yml or is it the version of the spigot library on the pom.xml file?
um they should be the same i think
you need to set your api-version to the version ur compiling against
Are you sure?
is it better to store information like this in a flatfile or in a players PDC, I am using PDC for basic info of a player as I thought accessing and writing to a file would be slower?
It sounds like it would slower, yeah
That returns a json formatted string, I mean a nms component
for little things this is fine, like 1 or 2 values. but when it exceeds this i would go for a file
yea
lets gooo
Hey why does this take 3 doubles instead of a Bounding Box
its a radius
not an area, its a radius around the entity
having some trouble parsing and serializing json to an actual object, lemme send the json and dataclass
did you design the gun!
i wish you would tho
that be so neat
me neither
xD
bad deal
i cant model either
{
"id": "SUSSY_SHANK",
"name": "&c&lSussy Stabber",
"material": "DIAMOND_HORSE_ARMOR",
"enchants": [
{
"id": "KNOCKBACK",
"level": 6500
}
],
"lore": [
"&c sus amogus"
],
"unbreakable": true
}```I am able to parse this, but the code isn't that great. How would I go on about making a custom Serializer with kotlinx's json plugin?
dont mind the name
are u using Gson?
Question, why does this: new ComponentBuilder("■■■■■■■■").color(ChatColor.of("#f800f8")).append(new ComponentBuilder("■■■■■■■■").color(ChatColor.of("#000000")).create()[0]).create()[0]
result in this:
It should be a more or less solid line in two colours
And is this instead
Make sure your plugin is compiled with UFT-8
It is
It very clearly does
But invalid characters aside, why is the colour formatting wrong?
One half should be pink, the other black
i have this to cololize hex strings
idk if thats just translates the hex things or also the text
for (Player player : Bukkit.getOnlinePlayers()) {
player.doSomeThing();
}
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
Player p = player.getPlayer();
p.doTheSameThing();
}
Is this the right way to do something for all online and offline players?
or should I work with a db?
Second one won't work very well
You can't get the player object of an offline player
Is that not the way or is it just not possible?
It will throw an error
Is there a way to do that with OfflinePlayer?
or is Bukkit.getPlayer(uuid) the way?
I want to delete a resource I uploaded to the spigot website, is the only way to do it is reporting myself?
yes
How do I get the player object to work with PDC if they are offline?
You restore a backup?
Is there a way I could improve this code? It basically takes a file path arg and reads it and passes it to parseItemData which returns an ItemStack
How i can do tablist like this? https://imgur.com/a/6QJ2f14 is there any API for that? (1.8)
?paste Please
what is the metrics site for plugins called again
bstats
Here is my issue, I'm looking to get the value of BlockBreakEvent#isDropItems() that is set by another plugin that has the event priority of HIGH
Here is the specific line of code of the said plugin, setting the value to false: https://github.com/MrButtersDEV/AutoPickup/blob/06f4fdeb3e5088104b8583d10903314d9ce378e3/src/main/java/us/thezircon/play/autopickup/listeners/BlockBreakEventListener.java#L165 (I'm certainly confident this plugin is calling this method)
We have our own BlockBreakEvent, with an EventPriority of HIGHEST. Also tried this with MONITOR and no matter what the return value of BlockBreakEvent#isDropItems() will always return true would anyone happen to have any theories as to why this could be happening? I havent seen this happen before with any plugins ive worked on
oh yeah thanks
?
Make sure you don't have any other plugin changing that and that the server is up to date
yo im trying to add a plugin to bstats, but it says that the plugin was already added. when i go to "My Page" and look at the plugin list though, its not there
Server is up to date, only plugins are the one im working on, the auto pickup plugin and essentialsX
