#help-development
1 messages · Page 740 of 1
Ive also set the Plugin to print the running services, in which i only get the Metrics and Permission
ClientboundPlayerInfoUpdatePacket
as seen here
Yeah looks like rubbish to me. No idea, i dont use external libraries.
In this case the structure should look like this?
serverPlayer.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, this));
Do you have a plugin installed which implements the Economy interface and provides it?
Does that not come shipped with the default?
No Vault is just an empty communication pipeline for plugins. You need a plugin which actually implements the Economy interface.
You could also create your own Economy. Its only a few lines. The biggest part is storing and loading the data.
You need a collection for ServerPlayers. For example List.of(this)
Ah i see, i dont usually use libraries, i write the stuff myself, so im not that good at it xD
Thanks anyways 😄
As well as an EnumSet<Action> instead of a single action
Perhaps you have a clear example?
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
List<ServerPlayer> players = List.of(this);
ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, players);
serverPlayer.connection.send(packet);

ignore the dumbness of this but is my brain correct in saying to see if its been like 20 min since an instant, i do thatInstant + 20 min is after now instant
You mean.... Instant?
yeah
Yeah an Instant is a point in time. So if you look at it after 20min then it will be 20min in the past.
If you add 20 min then it will be in the present. If you create a new Instant and add 20 min then it will be in the future.
@remote swallow For some reason, the advancement registers, but it doesn't display the toast. When I set "announce_to_chat" to true, I get that message, but setting "show_toast" to true results in nothing.
so this should™️ go into the if 20 min has passed since last give
knowing how to register itis about the limit of my knowledge, if anything i recon its probably another change either something to record that came with 1.20.2
You want to doe something if the Instant inside the Map is 20 min old, right?
yeah
Caffeine perhaps
idk if caffiene is worth it here because there isnt really much data being handled
That could be one approach
if(lastGiven.isBefore(Instant.now().minus(20, ChronoUnit.MINUTES))) {
}
Or you can use Duration for this. Its maybe more clear to read:
Duration duration = Duration.between(lastGiven, Instant.now());
if(duration.compareTo(Duration.ofMinutes(20)) >= 0) {
}
i completely forgot about duration
The comparator of Duration is maybe a bit weird to read. I often fall back to millis because of that.
nothing on its time senitive and shouldnt cause bugs if its late a minute or so
Duration duration = Duration.between(lastGiven, Instant.now());
long durationMillis = duration.toMillis();
long twentyMinutesInMillis = Duration.ofMinutes(20).toMillis();
if(durationMillis >= twentyMinutesInMillis) {
}
this is definitely better
It only updates its entries when the Map is accessed unless you tick it manually with a ExecutorService
In this case, what should the structure of the team that will spawn the NPC look like?
I dont know what that means, you absolute catfish
How does a team spawn an NPC?
How do I transform a block display to rotate around the y axis but pivot the translation at the center of the block?
I currenty have this, but I can't seem to get the right rotation matrix to get the translation to account for the rotation offset
display.setInterpolationDelay(0);
display.setInterpolationDuration(tickInterval);
display.setTransformation(new Transformation(
translation,
new AxisAngle4f(angle, 0, 1, 0),
display.getTransformation().getScale(),
new AxisAngle4f()
));
No not really
public class TestCMD implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
Player player = (Player) commandSender;
GameProfile gameprofile = new GameProfile(UUID.randomUUID(), "test");
gameprofile.getProperties().put(
"textures",
new Property(
"textures",
"%value%",
"%signature%"
)
);
new NPC(player.getLocation(), gameprofile);
return true;
}
LuckPerms has a data structure that revokes entries lazily
But caffeine can do it eagerly if you ask it to
On a Caffeine cache? Im almost certain that entires are only updated on access unless you specify an Executor in the builder.
who can how to make ai cover?
Cover of what?
Idk if it always (as in by default) update eagerly or lazily, but I know you can configure it to your likings at least (:
if you say music you are a troll
i have song and voice model, i need make song cover using ai
Anyway smile the reason iirc they do it eagerly is because of RemovalListeners
since those need to be accurately invoked when an entry should be removed
I think you need to translate because a quaternion rotation always rotates around the origin (0, 0, 0)
So Translate | Rotate | Translate back.
When using two Quaternions this gets a bit more tricky.
I would suggest HuggingFace. Thats where i get my base models for training.
https://huggingface.co/Lykon/DreamShaper
This one will probably be the best match for your case
But getting a diffusion pipeline going will take quite a bit of learning.
The translation isn't changed by the rotation though, so even after rotating the translation values will be the same, meaning when I translate back after rotating it'd just take me back point 0, and what I want is for it to take me back to the translation point
I've already done it, no more needed
I suggest to directly use a Matrix4f and set it with Display#setTransformationMatrix, since there you can use methods such as Matrix4f#rotateAround which makes it way easier to do what you want.
you need to call display.rotatorPhotosynthesis(x,y,z,g,b,4,false) as well
Is there a way to stop the server from loading certain player's nbt data?
guys, who can make for me plugin..? but.. i only have $8
ok, maybe 10-12$, i not checked
I can.
i need big plugin, are you serious?
Matrix4f transformationMatrix = new Matrix4f();
transformationMatrix.set(new float[]{
1f, 0f, 0f, 0f,
0f, 1f, 0f, 0f,
0f, 0f, 1f, 0f,
0f, 0f, 0f, 1f
});
transformationMatrix.translate(new Vector3f(0.5f, 0.5f, 0.5f));
transformationMatrix.rotate(new AxisAngle4f(angle, 0, 1, 0));
transformationMatrix.translate(new Vector3f(-0.5f, -0.5f, -0.5f));
display.setTransformationMatrix(transformationMatrix);
angle += 0.15f;
i came to a rather strange observation
splash potions of instant damage do magic damage right
thats normal
lingering potions of instant damage do entity attack damage
lol
That is rather odd
avg nms moment
How would I go about translating the display once again?
if (pivotRotations) {
final Vector3f translation = transformation.getTranslation();
final Vector3f scale = transformation.getScale();
// Apply rotations
Quaternionf rotation = new Quaternionf();
transformation.getLeftRotation().mul(transformation.getRightRotation(), rotation);
Matrix4f transformationMatrix = new Matrix4f();
transformationMatrix.translate(scale.x / 2, scale.y / 2, scale.z / 2);
transformationMatrix.rotate(rotation);
transformationMatrix.translate(-scale.x / 2, -scale.y / 2, -scale.z / 2);
transformationMatrix.translate(translation);
// Set transformation
this.entity.setTransformationMatrix(transformationMatrix);
return;
}
This seems to mess up the rotation pivot once again
The rotation seems to work fine until I make the final translation
Translation on this matrix equals a translation of the origin. Any reason you dont want to just teleport the entity?
Or do you need an actual translation, away form the entities actual location?
I need an actual translation to achieve smooth movement across this line https://images-ext-2.discordapp.net/external/31rzNRDrxUbgUrYihhEzV7CLrTX_euxmZib0hGlvlf4/https/i.imgur.com/g86aNZw.mp4
hmm
I want to make the block rotate around its axis (which I've achieved thanks to your matrix solution) but I also need to keep the original translation because it's needed in the interpolations made when the block follows the parabola
So then you need two matrices. First one is Translate | Rotate | Translate (For a rotation with the shifted origin)
The second one defines a Translation over x, y, z where rotation and scale are identity values
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
After that you compose the matrices. Just mutliply them together.
Ah and one more thing for the translation. I made a mistake for the pivot point.
first translate to -px -py -pz instead. And then with positive values back ofc.
Wait...
Nvm, just try composing of the matrices first
Compare different mappings with this website: https://mappings.cephx.dev
I actually tried that but it made the translation exacerbate the rotation by a bunch
if (pivotRotations) {
final Vector3f translation = transformation.getTranslation();
final Vector3f scale = transformation.getScale();
final Matrix4f translationMatrix = new Matrix4f();
translationMatrix.m03(translation.x);
translationMatrix.m13(translation.y);
translationMatrix.m23(translation.z);
// Apply rotations
Quaternionf rotation = new Quaternionf();
transformation.getLeftRotation().mul(transformation.getRightRotation(), rotation);
Matrix4f transformationMatrix = new Matrix4f();
transformationMatrix.translate(scale.x / 2, scale.y / 2, scale.z / 2);
transformationMatrix.rotate(rotation);
transformationMatrix.translate(-scale.x / 2, -scale.y / 2, -scale.z / 2);
transformationMatrix.mul(translationMatrix);
// Set transformation
this.entity.setTransformationMatrix(transformationMatrix);
return;
}
PS: Show the final result. Looks interesting.
m03 is on the bottom right, no?
isnt it m30 m31 m32
it's row-column
Thats garbage notation. X comes first.
i need this commands for my plugin:
- Useful commands (which I can write in more detail)
- A system of currencies and ranks (ranks can be upgraded for currency and receive goodies for this, such as prefixes or increased income at work)
- Works system
- System of cases for currency
- Donation privilege system
- Authorization and protection system against bots
- Regions system
- Chat filter system
How many years do you think it will take to write such a plugin?
max like 6 to a year probably
https://i.imgur.com/0QKLIcl.mp4 this is meant to be the final product. I initially did it with block displays riding an armorstand and setting their location rotation, but I had an issue with players who were using Lunar Client and Sodium specifically where the block displays would flicker between the real translations and their origin
much easier to use plugins that already exist
i don't like this
This is my code it's the same one I sent is it still making an 8x8 claim, if not show me your code?
Why using Chunks? They are intensive operations, arent them?
Alright then lets apply each operation using a full composition
t being our translation
p being our pivot point
| 1 0 0 tx | | 1 0 0 px | | R1 R2 R3 0 | | 1 0 0 -px |
| 0 1 0 ty | | 0 1 0 py | | R4 R5 R6 0 | | 1 0 0 -px |
| 0 0 1 tz | x | 0 0 1 pz | x | R7 R8 R9 0 | x | 0 0 1 -pz |
| 0 0 0 1 | | 0 0 0 1 | | 0 0 0 1 | | 0 0 0 1 |
The main problem is finding the RX values because you would need to apply the Rodrigues rotation and
i dont remember how to calculate it. You need some sort of skewing for that...
Try to simply rotate the identity matrix instead of calculating the R values.
do you guys math
I use the chunks because calculating them for 16x16 was like 8x8 and it's the same thing, I think it's the api plugin
If you are experienced you can do it in 3 to 6 months
Make sure to clear the GP folder and remove all claims that exist in the world.
You should also check if the result is valid and print that out. It has a boolean for that iirc.
I prefer giving them a claim item to select what they want. And if what they select is bigger from a limit tell them, etc. For me is better than rather work with Chunks, where you load them and then do many things
then for me it's about 69 years
So something like this?
if (pivotRotations) {
final Vector3f translation = transformation.getTranslation();
final Vector3f scale = transformation.getScale();
final Matrix4f translationMatrix = new Matrix4f();
translationMatrix.m03(translation.x);
translationMatrix.m13(translation.y);
translationMatrix.m23(translation.z);
final Matrix4f pivot = new Matrix4f().translate(scale.x / 2, scale.y / 2, scale.z / 2);
final Matrix4f pivotN = new Matrix4f().translate(-scale.x / 2, -scale.y / 2, -scale.z / 2);
// Apply rotations
Quaternionf rotation = new Quaternionf();
transformation.getLeftRotation().mul(transformation.getRightRotation(), rotation);
Matrix4f rotationMatrix = new Matrix4f().rotate(rotation);
Matrix4f transformationMatrix = translationMatrix.mul(pivot);
transformationMatrix.mul(rotationMatrix);
transformationMatrix.mul(pivotN);
// Set transformation
this.entity.setTransformationMatrix(transformationMatrix);
return;
}
i don't want this
what you want? Could you detail more
Getting the matrices independently then just generating the product of all 4?
na, what are you going to do it? For personal usage or selling it
when you do /claim that claim in 16x16
Hi Do you know a way to get the texture of an element in url png or byte (I'm not talking about the unfold texture but the visual one)
for my mc server
oh right, well the most difficult thing i seen and which havent done is the protection part
Month if slowly done
Just use ImageIO
URL url = new URL(imageUrl);
BufferedImage bufferedImage = ImageIO.read(url);
But something to tell u, if yo get frustrated you wont do it. Have to do it little by little
you can develop it for me? i can pay u 30$
Not worth tbh
30 USD would be something that can be done in half an hour. There isn't much that can be done in that time.
I don't have the URL, I'm looking to create one
for example I have an itemstack and I want to obtain a visual of this item in image
I dont understand what this is supposed to do...
The server doesnt know about textures. Only the client has this information. And they can use whatever resourcepack they want.
Then you'd need to find the locations of the vanilla textures
???
Or just use a resourcepack which is simpler
Software engineering is expensive.
i know, but where can I get more money? I'm only 14 years old, I can't work anywhere
lol
Then take the chance and do it yourself.
At 14 yrs old you can learn anything in pretty much an instant. Only issue is that you have next to no experience to build upon, but that is why you shouldn't delegate anything to other people
in theory I can make simple custom plugins for $4-6. but no one needs them
~ Uh that is not what I meant
He means that you can start little by little coding it urself
He shouldnt be native speaker, he should be using translator and they translate what ever
I meantion me as none english native speaker they translate waht ever
Your corrections make less and less sense by each correction
Is this a general question or a commission inquiry
well same question haha
I mean he asked how much time will take him to do that
?services It probably is a commision
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
we dont know!
Considering the other responses, it is.
Well i dont know what you mean
But what i suggest him is doing it little by little. Because at age you can fully start learning pretty well and you can be really indepdent if you start now
I wish I had learned non-coding stuff at that age 🙁
So since there's two rotations both on left and right I can multiply the left times the right and then set the destination to 'rotation', which is the second parameter of the #mul method
Why? I started programming when I was 7-8 years old in C, imagine that. I would have to be the one to say it
Being able to mod everything to smitherines and back is nice and all, but I'd really like to do the other stuff necessary for gamedev. Oh well, good thing I still have a lot of free time (a bit too much for my tastes).
imo learning programming at such young age is not worth it
That was my first approach to programming and it was because electronics runs in my family. And microcontrollers are fundamental in electronics.
anyway probably most things you know now you learned from when you are teenager
yeah, what i fully manage now are things from around 3-4y ago as yo have said. Tennager things
mate got some traumas for the rest of his days
That's why I hate languages that are not strongly typed. Looking at it this way, there you have the main reason why I hate languages that are not strongly typed.
i fully support you
new BukkitRunnable(){public void run(){boolets=10;}}.runTaskLater(plugin, 20*2);
why is this not working
im new to making plugins
what exactly isn't working ? You never declared boolets variable
How to implement a proper equals() for finding my custom menus via my Menu Obj?
the plugin part is red
does anyone know why this only spawns non-living entities such as a minecart and item frame, etc?
List<EntityType> entities = Stream.of(EntityType.values()).filter(entityType -> entityType != EntityType.PLAYER && entityType.isAlive()).collect(Collectors.toList());
int randIndex = ThreadLocalRandom.current().nextInt(0, entities.size());
return entities.get(randIndex);
i can send the whole code
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
have you ever made variable called plugin ?
no this is exactly what i dont know how to do
?paste
Can you send code so we can see the context
plugin variable is instance of your main class (the one extending JavaPlugin) you have to pass it somehow
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
public class listener implements Listener {
// Declare boolets as an instance variable
private int boolets = 10;
@EventHandler
public void onPlayerIntercat(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (item != null && item.getType() == Material.NETHERITE_HOE && item.getItemMeta().getDisplayName().equals(ChatColor.RED + "maw")) {
if (boolets == 0) {
player.sendMessage("i need more boolets");
new BukkitRunnable(){public void run(){boolets=10;}}.runTaskLater(plugin, 20*2);
player.sendMessage("reloadau si ja nimas izbire");
}
if (boolets != 0) {
Arrow arrow = player.launchProjectile(Arrow.class);
arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
//arrow.setVisibleByDefault(false);
arrow.setVelocity(player.getLocation().getDirection().multiply(60));
}
decrementBoolets();
player.sendMessage(String.valueOf(boolets));
event.setCancelled(true);
}
}
private void decrementBoolets() {
if (boolets > 0) {
boolets--;
}
}
?conventions
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
look at those two links, second one is explaining how you can pass your plugin instance
ok
What do you thin kabout this equal method? I will use it for finding my custom menus
oh sorry for anwering i just realize. Discord is going to the fuck
i mean its ok 
Because i till dont know better way to find the menus
idk context, but that is more or less classic equals impl
I just know i have to find them via == but not sure tho
Because i was told InventoryHolder is the worst option
What about using a Map<String, Menu> where key is a unique name
why you dont just compare inventories with == if those are mc inventories
yes they mc inventories, right will directly use that. Thanks
That what i was asking which was better hehe
what if the first if statement obj is null
yeah there i mad a mistake i fixed it
didnt we tell you earlier to just use == xD
oh Steaf nice yoo see you again
Yeah i remember it, but didnt know a good aproach for implementing it
/shrug Just use equals
epic ¯_(ツ)_/¯ fail
I know that it is gone, but I couldn't be bothered to insert it myself
Back in the old days we had it easier
Hold on, that isn't valid english, is it? Whatever.
what is gone
hey guys i have a quick question. So I have a datapack generated nether that I want to import into my server to replace the current nether with. I took the DIM-1 folder and put it into the world folder but for some reason it did not work
anyone able to explain to me how I would do this?
are you just using spigot?
paper
?whereami
ya but yall know your shit so im sure you can give me a hand
Paper has own support
also, #help-server would be a better place to ask
yer devs for crying out loud
Paper 💀
well idk
paper uses separate folders for nether and end
Probably need to just put the datapack into the datapacks folder and let the nether folder generate a new version, like delete it
but yeah, datapack != spigot
that too
public class listener implements Listener {
// Declare boolets as an instance variable
int boolets = 13;
private final Guna plugin;
public listener (Guna plugin){
this.plugin = plugin;
}
@EventHandler
public void onPlayerIntercat(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (item != null && item.getType() == Material.NETHERITE_HOE && item.getItemMeta().getDisplayName().equals(ChatColor.RED + "maw")) {
if (boolets == 0) {
player.sendMessage("i need more boolets");
new BukkitRunnable(){public void run(){boolets=13;player.sendMessage("reloadau si ja nimas izbire");}}.runTaskLater(plugin, 20*2);
}
if (boolets != 0) {
Arrow arrow = player.launchProjectile(Arrow.class);
arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
//arrow.setVisibleByDefault(false);
arrow.setVelocity(player.getLocation().getDirection().multiply(60));
}
decrementBoolets(); // Call the method to decrement boolets
player.sendMessage(String.valueOf(boolets));
event.setCancelled(true);
}
}
private void decrementBoolets() {
if (boolets > 0) {
boolets--;
}
}
}
how do i make it so players arent using the same boolets var
What, each player has their own booklets variable?
yes
map, pdc
^
Something to add, always use the modifiers and also constants (bullets in this casa) are defined as final
ok thanks
They are small modifications which make code more cleaner and learning new things isnt bad
@illusion_dev you have to put the folder into the world_nether folder, not the world folder
How i can get ItemStack Fished??
why can't I change DragonBattle.getBossBar().setTitle("X Guardian");
hello, I'm trying to add a player to a scoreboard team, tho Team#addPlayer and every other player-related method is deprecated and doesn't seem to work / doesn't add me to the team
how do I do that?
How i can get ItemStack Fished??
nvm, it does work
nevermind, when I run /team list <teamname> nobody gets shown + prefix & colour don't work
Does anybody know any library that makes working with a relational database easier? Like switching between sync and async and so on
no need to over poste it, must be patient as everyone else here
translate it via deepl
Google your question before asking it:
https://www.google.com/
?jd-s
You are so patiently and gentle man
?
i wish i could be you haha
yoo have to much patient to help. I mean because he post the same thing liek 2 times, like asking fast help i ma quen
oh yeah i seen i, i was going to dm you to see you if were okay
I remmeber you used to be all day giving some hands on this channel
how to i stop block break progress reseting like save it
Via database or flatfile depending your requirements
I assume you saving them via some sort of Map right?
for example when mining coal I want to progress of it to stay if i stop mining it
oh right, you want to create a plugin which limit how many coal blocks you can mine? Atleast in the example you had given
I want to perform some action if the player breaks a block, what do I need to do for this?
a listener for block break event
no for example lets say i am breaking a coal block and i broke it half of the way and stopped mining it would say as half broken
?eventapi
oh okay i catch what you need
Im not sure how to do that
@sterile token check dm
He wants to tell player like percentage of block break. So if they start mining and stop, tell the player how much is left - Thats what i have understand please confirm it @modern spade
yeah it saves the state
the eventapi link was for the other guy
We talking about the same guy haha- The one who asked what to use was Easygamer
Well im not sure how to do what he wants could you Epic try to explain him
no verano , the eventapi link was for @lofty badge
i just didnt know the command so it got sent after
oh sorry man, i confuse it my bad
You would have to use BlockBreakEvent, get the block and then get the damage from the event
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
double blockHealth = 100; // would have to check how to obtain it
int currentHealth = (int) (blockHealth - event.getDamage());
player.sendMessage("Block state " + ((currentHealth / blockHealth) * 100) + "%");
}```
ty
isn't the max block damage just 7
i dont know, just an example written using cellphone
Does anyone know why the advancement toast would not be showing up? The chat message shows up if the variable is set to true, but the toast does not.
https://paste.md-5.net/bosoyubapa.js
https://paste.md-5.net/anigabogip.json (Advancement in json format)
iirc you had to unregister and re-register it with bukkit unsafe
.
.
apologies if I have pinged
UnsupportedOperationException due to ImmutableMap being used. Is there a workaround?
https://paste.md-5.net/welobefiku.css
something something what if you replace the map
How would I replace it? Reflection?
ye
Reflect on what class? The NMS one or is there a bukkit class that I can work with?
the one that's causing the exception
Changing the map doesn't seem to do anything either. Chat message still shows up though.
https://paste.md-5.net/ohobukinam.cs
Field was public, so it didn't need reflection. :p
is anyone really good at using interactiveboard?
idk why i bought it if there's only 1 plugin tutorial on it
but please any help would be appreciated!
HOWTO: Removing a player's auras
I've made my own version, for plugin configuration help check #help-server
?
you need API help or help configuring the plugin
lmfao wtf am I seeing
Perfectly safe - nothing to worry about
(Though protip: Use Unsafe#allocateInstance next time)
Meh, the amount of performance I gain from doing that is much less than the time I need to spend to figure out in which order I need to call it again
when was this about performance again?
Is it parent.isAssignableFrom(child) or child.isAssignableFrom(parent)? I keep forgetting, so I wouldn't risk going that route and forgetting it.
Obviously, passing Class<T> instances is a flawed design anyways.
haven't had that problem in years
Hello, I wanted to know if the player's head could be obtained with the skin he has.
If so, how do I do it?
Does somebody know how I can make commands disappear from the tab complete, if a player doesnt have the permission to use/see them?
I mean it is probably parent.isAssignableFrom(child) but I never want to risk it.
yes, give me second
So AbstractMap.class.isAssignableFrom(HashMap.class) yields false? See, that is why I am afraid of using that method call.
ok
Imma ask here this time. I am trying to set a command's permission message. The issue is that it will just give me "unknown or incomplete command" even though I registered the message
you can cast the meta to a skullmeta and set the owning player
sounds like a you problem ngl
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) playerHead.getItemMeta();
OfflinePlayer player = Bukkit.getOfflinePlayer(playerName);
if (player.hasPlayedBefore()) {
meta.setOwningPlayer(player);
} else {
meta.setOwner(playerName);
}
playerHead.setItemMeta(meta);
return playerHead;
}
}```
This should probably work
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
like i said, i haven{t had that problem in ages
Does somebody know how I can make commands disappear from the tab complete, if a player doesnt have the permission to use/see them?
But that doesn't make much sense anyways.
HashMap x = new HashMap();
AbstractMap y = x;
works. Hence, AbstractMap should be assignable from HashMap?
if by parent you mean superclass then yes
It does by default
if you just use #setPermission on your Command
Of course, parent is superclass.
Any ideas?
thanks :)
Sure thing ;)
Nothing?
okay lol
wdym by commnds permission message?
You can call #setPermissionMessage on a Command
Which should define the failure message you get
Of course I could plug in my awesome ClassWrapperPool that bypasses this issue by implementing a isImplementingInterface() (https://github.com/Starloader-project/Micromixin/blob/main/micromixin-transformer/src/main/java/de/geolykt/micromixin/supertypes/ClassWrapperPool.java#L95) but uh, we'd be going of course at that point.
:WeirdChamp:
couldnt you just check player#hasPermission("blabla") else { message
in the commands you want it to be like that?
Well yes but then it won't hide the command and so on
And the API thing should just work
Though I wonder if using an instanceof on an Unsafe#allocateInstance is much worse performance-wise than straight-up using isAsssignableFrom
wait, why cant u hide it if you do it like that
Given that evidently the only difference of note is the performance impact as Unsafe#allocateInstance doesn't run the constructor.
And perhaps JPMS
Idk why but it does lol
I do not understand why setPermissionMessage is implemented even though it seems to not work
geol are you sure you mean isAssignableFrom and not just isInstance (iirc the name)
isAssignableFrom for sure exists. isInstance would be new to me
cuz Class#isAssignableFrom checks the class relation, while Class#isInstance is just iirc a glorified instanceof
Does that work with loading mixins into spigot?
I am basically asking how much slower it would be to run unsafe.allocateInstance(clazz) instanceof MyClass versus MyClass.class.isAssignableFrom(clazz)
Well I got inspired by particularly bad code
Which uses Class#newInstance instead
This project mentions that it's a reimpl with the reason listed that mixins badly support usecases that are not "intended"
I can say for sure allocateInstance is faster than newInstance
So does this micromixin contain a loader for spigot or sth?
But then you could prob identify the type of the instance by a switch or Map<Class,V> where u pass the class
Micromixin was written for Starloader. Support for spigot cannot be done without agents or transformations regardless as you'd somehow need to hook into the classloader before classes are loaded.
Yes I know part 2
Damn sad I almost had some hope that someone wrote some Agent for that
However Starloader's classloading architecture is very similar to bukkit's classloading so as a fork of cb/bukkit it would work.
I am not talking about forking
I am talking about dynamic agents reloading classes to apply mixins
So basically no fork or startup args or anything, just a plugin lifting the work
/hotswapping
Given that I haven't encountered that problem while modding galimulator I haven't looked at it.
Hm sad
I have been thinking and asking about that stuff for 2 years now
I know it's possible but I know I would not be able to do it lol
You'd need startup args
No
Dynamic Java Agent
You inject your agent at runtime
Which reloads/hotswaps classes
When using agents it is actually better to use the spongeian implementation than the micromixin impl as latter was explicitly coded for classloader-based systems.
Deprecated and will be disabled in the future
So the only two areas where micromixin shines at is Java 6 (perhaps even Java 5 since people requested that in the past) and classloader-first architectures
Theres a fix for it already
Yeah, but it won't last forever
The project is called "unfixer" lmao
So ig it's possible if you to limit yourself to old versions
Afaik it is over prety soon with all these workarounds
but alas I should go to bed urgently
Link?
@lost matrix aw sucks 😔 Im hacking my way through it right now, but I thought to ask here in case I missed an API that could do that
Well that's some real unsafe stuff
Also won't work on all systems
Wdym unsafe lll
If it works it works
Using native code to forcibly inject a startup argument isn't supported
And if something goes wrong you can crash the entire jvm
It's just hacky
Is there a way to set the block loot in code
something like
table.put(Material.Cobblestone, new ItemStack(Material.Dirt)); 1.12.2
Can someone help me on how to properly implement permissions into plugin.yml or link a tutorial?
I'd recommend using a datapack
i dont think they are avalible for 1.12.2
you should have specified that you're on 1.12.2
Otherwise we'll assume you're on the latest version
mb
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
where would i start looking?
Loot table class probably
That's where I'd start
Alternativly look at where the loot table is used
it depends what you are trying to accomplish. If you are trying to change what is dropped when a block is broken with random drops, then the loot table may be ideal
otherwise just use the drop method of blocks
make new class
nah the world will be like a bukkit world
it's basically a wrapper
imo
so it might have stuff like
in that case I would probably make it an inner class
nooonie i thought u were smart
in theory but not even the bukkit api has it setup like that
that is to spawn an entity
it's a command
yes but no
easily because the api lets you listen for commands already and you just only need to check the world someone is in
unless you also want to support console stuff
then it may be a bit more involved
but do remember, just because myself and others may say different things
it is your plugin after all 😉
bruh
ok but here
let's say
the Location spawn object needs to be passed around everywhere
cause player death
out of bounds
etc
I would rather dependency inject the entire world with all the data
than just a single object
well it should be the other way around
also the world object should mostly be static unless there is time it will be removed?
I mean there's no guarentee the world 100% stays loaded
that is why I added the question mark
smae
you shouldn't be avoiding static, rather learning how to use it properly
it does have its advantages
if you think so, as I said it is your plugin so whatever you decide goes and really it is you who has to work on it. So not everything has to be about efficiency or best ideals, but also easy for you to maintain lol
but this project is perfect for you to learn how to use statics though
bro
@wet breach why would I use static for this
cause ik my server gonna be VERY popular ima need
multiple game worlds
there is just some rules to follow with statics. One of the primary ones is, if the object is never going to go away it is ok to use a static for it.
there is other rules, but they are dependent on the scenario
yeah i understand that
idk u might be right
actually now that I think of it
you just have to learn to not use a bunch of statics is all 😛
but some occasional ones are fine
i just avoid static when it comes to abstraction
but then you have stuff like enums which are static
so if you want to use an enum, then you can't avoid the staticness XD
Enums are great and so is static
The reaction of someone who doesn't know how to use enums and static
Anyone know why i'm getting this problem when compiling with intelij and Maven? [ERROR] Malformed \uxxxx encoding.
I have checked my POM xml extensively, and it SHOULD work
May something be corrupted?
making it abstract doesn't prevent the use of static
where statics don't do good is in dynamic scenarios usually
wdym dynamic
seems for whatever reason the file encoding is messed up
only way I dealt with file encoding issues reliably is to delete the file and remake it, or use some option to ignore encodings
like loops and the sorts
they usually don't do good in those situations lol
because they are static and don't change, where as in a loop you are wanting change usually. It just depends on what it is that is static really
do u have Brachydactylous
what if i just make this class static
bruh
@wet breach
ok so i might just get rid of this whole class
but if I want to set the gamerules
idek atp
are you smart
depends
since setting up game rules is only done once, I probably wouldn't make it static
Excuse my ignorance. How do I get started with making PRs for Spigot? I'm trying to achieve this. Seems like there's no method for this.
Asks how to get the items from the player's inventory?
declaration: package: org.bukkit.entity, interface: HumanEntity
you could just get all the effects and then remove them and re-add the one you want
the reason it removes all of them is because the remove method takes a type and doesn't distinguish between multiple of the same types
but if you want to start doing PR's with spigot you are welcome to
probably should start with the CLA
?CLA
?cla
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
epic fail
Nice, still good to know where I can start. Thanks!
Do you mean getting the effects from by getActivePotionEffects? This will also return multiple same types?
so
make it a class?
an object that does everything
it returns a collection
so it should do so
The warning for add is saying that lore() may return null. however the code above that should assert that it can never be null. is there something I'm missing or should I ignore it
I think it's cause it's annotated with Nullable
And u have to use a requirenonnull or directly check if it's not null something like that
not sure how this ensures its not null. Empty lore is null. Regardless, the add method has no clue about your prior code and the warning derives from the api as your IDE reads it and just lets you know the api states that it is possible for there to be no lore AKA null
Because it should be whether there's an array list there or not. An empty array list is not a null list
while true, an empty lore is null
I don't get it
Thanks!
You should probably be best with changing your structure. Instead of adding lore like that. You should add lore using parameters. Not sure whether it is lore() or setLore().
You can also do itemMeta.lore() == null instead in the if checks, iirc. That should negate the warning from IDE.
ended up doing this
public ItemBuilder withLore(@NotNull String... text) {
Objects.requireNonNull(text);
itemMeta.lore(Arrays.stream(text).map(miniMessage::deserialize).toList());
return this;
}
will still look fine
Is there a way to play a chest opening animation using the API? (I'm currently updating a plugin which used packets)
declaration: package: org.bukkit.block, interface: Lidded
Thank you!
you're welcome
Hi, I am in need of assistance please. I'm making a plugin where it changes mob attributes on spawn, and when I try spawning them in game, they don't. It makes the sound of them spawning in, just doesn't actually spawn them. I am trying to update this plugin, as I started working on it during 1.19.3, and it was working fine in that version. The version I'm trying this in is 1.20.1 on a 1.20 client w/ fabric mods (if that somehow matters). Here's an example case for Creepers:
Please let me know if any other details are needed, as I am relatively new to plugin coding.
Update: No mobs are spawning at all.
Is there any error logs at all?
No errors are thrown in console for some reason
I'll check my logs
Nope
If it helps, I'm running Paper.
Just something to check, but have you registered the Listener?
Also other events work like players joining
Yes I checked 500 times lol
Try to log something in the method, and check if its even running.
Okay lemme see
try to log the entityType as well
I added this now let's see
Okay for some reason it is now logging and also spawning mobs correctly
I love java
Thanks for the help I guess lol
Why is the 1st parameter (String name) a string instead of an Attribute
probably to make it easier to read
doesn't really matter on the order of the parameters
im pretty sure the name doesnt matter, its something for you to decide
no like why am I specifying an attribute, and then inside of the attributemodifier basically specifying the attribute again just in string form
How does dependencies via maven and bukkit even work I'm so confused
Does bukkit load all the projects into like one jar during runtime
like theoretically
a jar with a bunch if modules
Idk the analogy for ot
It
Y'know how each plugin has its own classloader
P sure that's involved
Basically it scans the yml file, downloads the deps into a cache folder and loads them accordingly
No way.
Spigot does download deps from original jar?
@echo basalt so if I depend on something like luck perms how does that all work
and honestly what even happens when I depend in a regular maven project now that I think of it
like does it, during compilation, it compiles the dependency in the project
https://textures.minecraft.net/texture/e4d49bae95c790c3b1ff5b2f01052a714d6185481d5b1c85930b3f99d2321674 is this not a valid skin url?
that's an option for maven central dependencies if you don't want them to be in your own jar
ok there's no URL error when using this
base ItemBuilder
https://paste.md-5.net/muhadadeqi.java
skullitembuilder (one I'm having trouble using)
https://paste.md-5.net/igonibucoh.java
usage
private final ItemBuilder.Item SETTINGS_HEAD = new SkullItemBuilder(
"https://textures.minecraft.net/texture/e4d49bae95c790c3b1ff5b2f01052a714d6185481d5b1c85930b3f99d2321674")
.named("Settings") // TODO color
.build();
Update the offline player constructor works just not the skin url constructor
Talking about the maven libraries feature
Hey i am installing BuildTools with java 8 and selecting 1.8.8
sadly something weird happens here, can someone explain this?
the error says sh: 0: cannot open /usr/bin/mvn/bin/mvn: No such file the path should be /usr/bin/mvn
Is there a way to check if the player is in combat? Like a sort of combat log API already existing?
I believe that isn’t directly exposed in spigot
aw man
You can track combat with attack events
well it isnt rly a feature in spigot nor minecraft itself
would have to rely entirely on some api
It should be in mc
there isn't really a way of telling whether someone is in combat or not, I mean you can define your own restrictions on what being in combat means
There is
The game needs to know how you were killed to show the appropriate death message
Including player & entity combat
dude
death message has nothing to do with whether a player is in combat or not
its just how they died
Well you obviously haven’t read far enough
I’m not…
there is literally no such thing as being in combat
I can solemnly swear there is a combat tracker in NMS right now
show me
so how does knowing my ass dropped in the void help in knowing wether i am in combat
If you can wait about 12 hours for me to finish work and wind down that would be bless
To further prove my point, combat tracking is also essential in the entity AI subsystem
So yes it is “tracked”
How far, that isn’t known to me right now
no it isnt you goof
you are straight up lying
the ai system just caches targets and entities during runtime
has nothing to do with combat
and has never been
there is something called a targetSelector and a goalSelector, these two have a set of goals that constantly tick to check where the entity may move and what the entity may target
nothing to do with combat
stop coping
Sorry what exactly does this have to do with combat tracking
I will take a look again later
I am almost certain combat is tracked
it doesn't matter when you take a look
everything you've said to this point is wrong
its okay to be wrong
Well I sincerely apologies for my lack of expertise
And your due unprofessionalism in resolving disputes
: )
There is a combat tracker in nms
Though it's only used for death messages as far as I'm aware
^
Yeah the one for death messages is a thing I suppose
Just managed to try. Doesn't seem like the method retrieves lower level potion effects.
Is there any other potion effects getter than I'm currently missing out on?
I told you yesterday that spigot is missing an api for that.
Best you can do is tinker with the EntityPotionEffectEvent
Soo, I'm trying to get to know PersistentDataHolder / PersistentDataContainer...
Now, I want to implement a key-system where you can just click on the iron door with the key in your hand and the door will open.
I kinda don't know how to start tho since I have absolutely no idea about PDH. I tried the guide but I kinda failed. I don't quite get how I will be comparing the data when clicking the door.
Oh right, I also want to store all the already used keys just so there's no duplicate keys created. (which is very unlikely, regarding every key has a 16 letter alphanumeric code, but anyway)
Doesnt this only track player combat?
Only for direct kills (last hits)
Code is written so it can work with all living entities
Haven't checked where the combat tracker is used
Alr just checked it tracks any damage
and it's source
Normal Blocks like Doors dont have a PDC. You would need to save the Data in the Chunk instead.
The API from alex lets you store PDCs for every Block by outsourcing the data to a chunk.
oh- damn
i'll look into that
thanks
when is a chunk deleted?
When an admin goes into the world folder and removed region files
oh
well that's nice then
that's really nice actually, damn
also since i only started with maven a couple of weeks/months ago, can u explain the relocation thing on the github-page for the api?
But chunks get regularly unloaded* If thats what you are asking
In short: Relocation fixes the problem of other plugins shading the same library as yourself
nono, i just read in the readme for the api, that upon chunks being deleted no more data remains
Because it changes the classpath of the loaded classes. Meaning you will use your version of the lib
while others use theirs.
okay... so does the package need to exist orrrrrr
You mean from the custom blockd data api?
yea
this:
* When the chunk where the block is inside gets deleted, there will be no leftover information
Yeah this just means that if you delete a world, no data is left behind.
Imagine if you would save the data in a Database. Then you would have to clear out the DB when a world is deleted.
ahhhh that's pretty cool then
Also: Materials are the items inside your inventory, did i understand that correctly?
And blocks are, well, blocks
Apologies. Someone else said it was retrieveable, so I tried my luck. Thank you though.
Material is a property. An item in your hand is an ItemStack and a block in the world is a Block.
Both have a type property, meaning they have a certain Material type. But neither a Block nor
and ItemStack can be completely defined by just their Material. They have a lot of extra data besides that.
i see, thank you
And I'm guessing upon placing the ItemStack (if placable), like a door, the meta is copied to the block?
or rather to the chunk with the CustomBlockData api?
As normal Blocks dont have any way of storing data, the PDC is not copied upon placement.
You need to track this using your own Listener. Writing some nice little code 😄
okayyyy this is a bit more than expected, but sounds doable
Should be a listener and like 5 lines of code. Def doable.
How would I get the ProtocolLib serialiser for a VillagerData metadata type?
is it just an int[]?
Show some code pls
I don't have any code right now
I'd like to send a packet to change a Villager's type and profession
I've been able to do similar things purely through WrappedDataValues before, but is it possible here?
damn, guess i'm overthinking lmao
I need to update the type and profession
normally there'd be a built in serialiser for a compound type but there doesn't seem to be one for VillagerData
Does the villager data get sent via the metadata packet? Let me check the protocol...
yes
that's what I've been talking about
right, lol serializing. i've been trying to do this with inventories but i can't get shit to work, well that's a topic for a different time though, lol
Have you tried getting a serializer for WrappedVillagerData
not sure how I'd do that, that seems to be for a data watcher
That would be my first approach:
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
packet.getIntegers().write(0, this.someFakeId);
List<WrappedDataValue> dataValues = new ArrayList<>();
WrappedDataWatcher.Serializer villagerSerializer = WrappedDataWatcher.Registry.get(WrappedVillagerData.class);
WrappedVillagerData villagerData = WrappedVillagerData.fromValues(Type.DESERT, Profession.ARMORER, 3);
WrappedDataValue serializableVillagerData = new WrappedDataValue(18, villagerSerializer, villagerData);
dataValues.add(serializableVillagerData);
packet.getDataValueCollectionModifier().write(0, dataValues);
Ah, you can also try
WrappedDataWatcher.Serializer villagerSerializer = WrappedDataWatcher.Registry.get(WrappedVillagerData.getNmsClass());
instead of
WrappedDataWatcher.Serializer villagerSerializer = WrappedDataWatcher.Registry.get(WrappedVillagerData.class);
Ah ok
thanks for the help
protocollib looks so ugly
better than using nms lol
eh, i'm more happy with nms
Last time I used protocol lib, I didn't want to use nms, but I still had to use nms classes
I greatly prefer nms. But it breaks every version, so...
plib has access for nms classes. You dont need them
For what?
It was the armor equip packet, I needed to set the armor to nothing for everybody else if some conditions match and it wouldn't let me do stuff like getItemStack(0) or whatever it was, so I had to use the getModifiers or whatever it was (I don't remember, haven't done this stuff in ages) which required me to pass nms classes
plib couldve made their public api way better
PacketContainer#getItemSlots() returns an StructureModifier<EnumWrappers.ItemSlot>
You can 100% do this without nms
But it returned null
you need to do getSlotStackPairLists
Yeah this one
now it's giving me a NullPointerException when I try to initialise the WrappedVillagerData
WrappedVillagerData villagerData = WrappedVillagerData.fromValues(
WrappedVillagerData.Type.valueOf(villagerType.toString()),
WrappedVillagerData.Profession.valueOf(profession.toString()),
1
);
```(both those `WrappedVillagerData` enums are correct, I checked their values)
I'lll try that now
yeah still get the error
everything but the WrappedVillagerData initialiser's commented out
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:907) ~[guava-31.1-jre.jar:?]
at com.comphenix.protocol.reflect.accessors.MethodHandleHelper.getFieldAccessor(MethodHandleHelper.java:83) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.reflect.accessors.Accessors.getFieldAccessor(Accessors.java:84) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.wrappers.EnumWrappers$FauxEnumConverter.getGeneric(EnumWrappers.java:957) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.wrappers.EnumWrappers$FauxEnumConverter.getGeneric(EnumWrappers.java:938) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.wrappers.WrappedVillagerData.fromValues(WrappedVillagerData.java:53) ~[ProtocolLib.jar:?]
This looks like an internal error from plib
yep
Are you using 5.1.0?
How do I fix the problem with the PlayerInteractEvent being fired twice when there is no item in their hand?
huh I've got 5.0.0 in my pom
?interactevent
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
yeah newest version and newest dependency, still getting it
No matter if i have an item in my hand?
If you also have 5.1.0 installed on your server then its time to open a github issue
yes
Perfect
The cooldown doesn't work
public class xrayEvents implements Listener {
TheLogger plugin;
private final HashMap<UUID, Integer> lista = new HashMap<>();
private HashMap<UUID, Long> cooldowns;
public xrayEvents(TheLogger plugin) { this.plugin = plugin; }
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
//int current = lista.remove(p.getUniqueId());
lista.merge(p.getUniqueId(), 1, Integer::sum);
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
this.cooldowns = new HashMap<>();
Player p = event.getPlayer();
Block b = event.getBlock();
Material material = b.getType();
if(material.equals(Material.DIAMOND_ORE)){
Integer blocchi = lista.get(p.getUniqueId());
if(!this.cooldowns.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldowns.get(p.getUniqueId()) < 10000) {
this.cooldowns.put(p.getUniqueId(), System.currentTimeMillis());
if (blocchi <= 6) {
lista.put(p.getUniqueId(), lista.get(p.getUniqueId()) + 1);
} else {
for (UUID uuid : plugin.xraylog_list) {
Player staff = Bukkit.getPlayer(uuid);
staff.sendMessage("attention! " + p.getName() + " use xray");
lista.put(p.getUniqueId(), 1);
cooldowns.remove(p.getUniqueId());
}
}
}
}
}
}
ehm ok?
Why do you merge the player into the map when he joins?
This will cause the value to shoot up when a player connects several times
pretty bold to assume someone is using xray if they break >= 6 blocks of diamond within the span of 500 seconds too
Just add him
lista.put(p.getUniqueId(), 0);
Idk why but It doesn't work
in console spam: lista is null
cooldowns is null. lista isnt.
i try lista.put before insert the cooldown
First I try without cooldown, and then I add it
And here is the problem.
Every time a player breaks a block you delete the old map and create an empty one.
no, I have only one, I send it
show ur event registration
@Override
public void onEnable() {
// Plugin startup logic
System.out.println(ChatColor.BOLD + "[TheLogger]" + ChatColor.GREEN + ChatColor.BOLD + "Enable!");
//Commands
getCommand("log").setExecutor(new logGroups(this));
//Drop
getServer().getPluginManager().registerEvents(new dropEvents(this), this);
//Kill
getServer().getPluginManager().registerEvents(new killEvents(this), this);
//xray
getServer().getPluginManager().registerEvents(new xrayEvents(this), this);
this.saveDefaultConfig();
config = this.getConfig();
}
right thats fine
I already try to make the cooldown without this but it doenst' woek
I remove it now
but It still not work
private final Map<UUID, Long> cooldowns = new HashMap<>();
And then remove the map creation out of your listener.
If you create an empty map every time, anyone breaks any block, then you dont
have to wonder why your code doesnt work. You just delete all your data constantly.
because cooldowns is null ;d
the cooldown doesn't change, you have to make it work
Sys currenttimemilis - cooldowns.get uuid >= 1500
do stuff
how many seconds are 1500?
doesn't work
but if the server is laggy, you might wanna consider a sync task
now the plugin doesn't send the message
the server isn't laggy
it's definitely something wrong with the code still
do some prints
it's a good learning advice, you'll end up understanding how debugging works
I already know how debugs works
thank
but if I'm writing here it's because I didn't found help on forum discusses or google
when i pass a string to a C api via the jni, can and if so should i explicitly null terminate the string or does jni handle it for me?
If you cant figure this out you either lack serious java fundamental knowledge or. In fact do not know how to debug
I know how to use the debug, I already try it. I only need an hand with the cooldown
and it's useless for you to tell me that I have to learn java or tell me other things that have nothing to do with the help on the cooldown. Or even worse I would say that insults can be avoided. I'm here to learn and have fun, I just asked for help.
Sigh well can you post your up to date class?
yeah, im pretty sure jni handle that
TheLogger plugin;
private final HashMap<UUID, Integer> lista = new HashMap<>();
private final Map<UUID, Long> cooldowns = new HashMap<>();
public xrayEvents(TheLogger plugin) { this.plugin = plugin; }
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
//int current = lista.remove(p.getUniqueId());
lista.merge(p.getUniqueId(), 1, Integer::sum);
}
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player p = event.getPlayer();
Block b = event.getBlock();
Material material = b.getType();
if(material.equals(Material.DIAMOND_ORE)){
Integer blocchi = lista.get(p.getUniqueId());
if(!cooldowns.containsKey(p.getUniqueId()) || System.currentTimeMillis() - cooldowns.get(p.getUniqueId()) <= 10000) {
cooldowns.put(p.getUniqueId(), System.currentTimeMillis());
if (blocchi <= 6) {
lista.put(p.getUniqueId(), lista.get(p.getUniqueId()) + 1);
} else {
for (UUID uuid : plugin.xraylog_list) {
Player staff = Bukkit.getPlayer(uuid);
staff.sendMessage("Attention " + p.getName() + " use xray");
lista.put(p.getUniqueId(), 1);
cooldowns.remove(p.getUniqueId());
}
}
}
}
}
}```
but on some places i read that we should not assume lol
In the general case this means one should never assume JNI returned strings are null terminated, not even UTF-8 strings.
xD yea its rather contradicting answers
Hi, what's the best way to prevent placing an Item into the Offhand? I already have a handler that cancels the PlayerSwapHandItemsEvent but it seems like there is no easy way to do it in the inventory
InventoryInteractEvent
debugging with java plugins is more difficult though because we dont have the ide to go through the lines one by one with breakpoints and all the fancy tools like heap profilers
So I really have to go through different clicktypes and check if the offhand slot was part of it?
wouldn't you just do
if (slot == offhand)
dont();
its not easy
because theres lots of different events
pickup, swap, drag, placing
well pickup only when an item already is in the offhand
still
🤷♀️ gotta catch em all
also
u cant just say inventory this event
Alright thx guys and one other question does TextColor not work in gui names and only NamedTextColor s?
u first gotta check if its actually a player inv
not an anvil chest or whatever
cause theyre all inventories
not every inventory has an offhand item tho
Ill check for the slot
Dont recommended stuff that wont work
everyone should be on at least Java 11 now
8 is not a good version to use these days
I'd also never recommend Oracle, but thats personal due to their attempt to copyright an API.
sorry got caught up, anyway
your cooldown check should be if(!cooldowns.containsKey(p.getUniqueId()) || Systen.currentTimeMillis() - cooldowns.get(p.getUniqueId()) >= 10000)
and your cooldowns.put should replace your cooldowns.remove
Im on 17 xD
I want to get a start area in a world i generate? What is the best/most efficient method to do this? Should I create a structure file and somehow load it?
it depends on teh size of your start area
a couple of chunks, yeah create a Structure
ok
And how would I load it do I like have to spawn a structure block and use it to place the structure or are there better ways?
no, you can save it and it will create an nbt file for you. Include that in yoru jar
then load/place as you need
With Spigot StructureManager?
yes
Perfect I think that didnt exist last time I tried this a few years back 🙂
what I put in the long cooldowns?
the same as ur doing rn
@lost matrix created an issue in the plib repo, will see how it turns out
If I set the QuitMessage to null, do I get no message or an empty message? (I can‘t test rn and it‘s bothering me lmao)
No message
Perfect, as I expected. Thank you
can you obtain the server time in ticks without relying on the overworld?
ye thats why im asking
Well, just start counting away from server start and when stopping (or reloading) save it, after "boot up" load from config and continue counting and so on. And by the seconds going by you can see the server time (not really good when implemented later on tho)
maybe
different problem
why does this dependency break jetbrains @NotNull
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230227</version>
<scope>shaded</scope>
</dependency>```
Better question: Why do you use org.json in the first place?
cuz of this java.lang.NoClassDefFoundError: org/json/JSONObject
spigot.org says json is included
its not or im using the wrong import
Any reason why you dont want to use Gson?
And spigot comes with json simple iirc
also its not giving me the option to go for GSON
aaand my annotations package is still broken
There you go. Remove your dependency and import json-simple.
What are you doing in the first place. Gson is the better lib for most things you would want to do with json.
hello, i'm trying to make an api like this:
// PluginAPI
public class MyClass {
void doSomething();
}
and I would like to use MyClass#doSomething in my main plugin:
// PluginMain
public class Class {
void something() {
PluginAPI.doSomething()
}
}
how do I do that?
do i still need to shade something? it builds but im not sure now if it will work for spigot
needs to be public methods too to be accessible from outside
Compile your API using mvn install and then add it to your main plugins pom.xml
yeah ofc im on mobile so forgot that
What are you writing that needs json?
i'll try that later
ActionBars
found some code by brunobelloni1 and am using that
and its saying classNotFound on the JSON again
wait
not the json
on IChatBaseComponent
bleh why is this not in the API
Because thats nms
oh this is interesting. does getServerVersion only return the major version?
.v1_20_R1. is what its trying to access but im on a 1.20.1 server
And not even actual nms. Thats an old spigot mapping class name
you can get the nms version from the craftbukkit package
but paper are planning to remove that
?whereami
so you have to convert getServerVersion to nms ver if you want paper compat
Explain to me what version you are on, and why you need json for that.
not really
cuz actionBars are apparantly NMS, and the only piece of code i found so far parses JSON for that
action bars are available in the api
What version?
player.spigot().sendMessage
latest stable
aint that chat
There's an option for action bar too
ActionBars are an api feature since 1.9 i believe
declaration: package: org.bukkit.entity, interface: Player, class: Spigot
i see
ChatMessageType
does that work on paper? I'm using spigot with the hope that everyting on spigot works on paper
yeah
system chat message
Hi im back and still dont know how to solve my issue, if someone has too much time i would really aprreciate if he could explain to me how to properly do a mute plugin 🙂
the advancement type messages probably
store the mute, if their muted cancel the asnyc chat event
ye i did that but im too dump to make it, i can still write although being muted
ah that makes sense. Is there a way to clear the actionBar text?
i want to display this for a specific time
you arent cancelling the event then
well the event isnt even called i dunno why
Show some coderino
Did you register the listener my boi
is ur listener registered
yes
i think to
Bukkit.getPluginManager().registerEvents(new PlayerListener(),this);
Did you add the EventHandler annotation
public class PlayerListener implements Listener {
@EventHandler
public void onSpeak(AsyncPlayerChatEvent e) throws ParseException {
e.getPlayer().sendMessage("Test works");
if(!MuteUtils.muteCheck(e.getPlayer())) {
e.getPlayer().sendMessage("is false");
}
if(!DataConfiguration.INSTANCE.getData().contains("Data." + e.getPlayer().getUniqueId())) return;
e.setCancelled(MuteUtils.muteCheck(e.getPlayer()));
}
}```
i doubt it will take it with the throws parse exception
i had it with highest priority before but it didnt change much, its not even showing "test works" when i send something in chat
use try catch
Alright, your listener is registered and should send the "Test works" message.
If it doesnt then your plugin probably crashed on startup. Look in your log real quick.
also dont set cancelled the result of mute check
bc that will uncancel a cancelled an event
muteCheck needs it tho
so if(MuteUtils.muteCheck(e.getPlayer()) == true} set event cancellled
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.
what api?
spigot-api
ye that wasnt code that was how i would code it
oh just send nothing yea that should work
if(MuteUtils.muteCheck(e.getPlayer()) {
event.setCancelled(true);
}
Do you get the "Test works" message?
was the actionbar always this high above the hotbar?
no
im pretty sure it was
try catch what is throwing the error and remove the throws ParseException
but i need the parse because of this
Then send us your onEnable method. And also: Check your log when the server starts. Make sure the plugin is enabled without exceptions.
