#help-development
1 messages ยท Page 2203 of 1
I know that I need to send a packate with metadata, but I don't fully understand how to do it, and Google does not have anything specific about this for version 1.18
You won't have setGravity() but a(), b() or c() and simillar
Version is 1.18
I recommend using mappings so you don't have to use unmapped method names lile that
@EventHandler
public void onThunderSword(EntityDamageByEntityEvent e) {
ItemStack thunderSword = CustomItems.createThunderSword();
if(!(e.getDamager() instanceof Player)) return;
Player player = (Player) e.getDamager();
player.sendMessage("event triggerer is player");
if(player.getInventory().getItemInMainHand().equals(thunderSword)) {
player.sendMessage("you can strike!");
e.getEntity().getWorld().strikeLightning(e.getEntity().getLocation());
}
}```
how come this if statement never fires?
Well is it the same item
it should be ahaha, my main hand is the thunderSword itemstack
why is getCommand(String) null
You forgot to define the command in your plugin.yml
Try isSimillar instead of equals
i did tho
Check for typos
nope still wont.. hmm
add a cooldown with a map and timestamp
setDeaths is missing
I guess you'll have to debug that then or use another method of identifying your item, such as a NBT tag with PDC
?pdc
yep thanks
Does anyone know why setting the custom name of a client side Armorstand does not work in 1.19? (Image of what it looks like rn: https://media.discordapp.net/attachments/913885553206911048/984534762796494929/2022-06-09_17.04.24.png?width=1618&height=910) Here's the code:
https://github.com/ItzAmirreza/EzChestShop/commit/93db4b2c6ab67ff979e1ba663adf276fd4a6cf8b#diff-60bfd18c1821478405010df230167f57501b181b187f99da24c9a6ec040597feR76
The Code works perfectly fine in 1.18 and below:
https://github.com/ItzAmirreza/EzChestShop/blob/main/craftbukkit_1_18_R2/src/main/java/me/deadlight/ezchestshop/Utils/v1_18_R2.java#L76
I haven't remapped it yet due to time limitations, so here are links to the NMS mappings (replace 1.19 with 1.18 if you wanna check for previous versions):
https://nms.screamingsandals.org/1.19/net/minecraft/network/chat/Component.html
https://nms.screamingsandals.org/1.19/net/minecraft/world/entity/decoration/ArmorStand.html
Thanks!
i got it to work via lore but PDC seems very interesting, if you can, could you give me a brief overview of how it works or an example because that post is confusing the hell out of me
hey guys, any idea why my multiple jumps plugin is not working? https://paste.md-5.net/tolabelibe.java
Another Minecart question - there's an extremely strange segment in AbstractMinecart fn MoveAlongTrack that makes zero sense to me; https://paste.md-5.net/havakilaye.cpp
It seems to make X & Z coords 50% bigger if it's moving along an axis and set position of Cart to there
On a corner it works out to put it in a different place on the rail (Which still seems strange because there's no check for direction)
(From testing it rewritten in Python with Minecart coord at 100.5, 100.5 (middle of block) and Rail coord at 100,100)
Can someone help me work out what this part actually does because I'm at a loss all day
The only way it makes any sense to me would be if Java does not use BIDMAS but I'm pretty sure it actually does?
for some reason none of my commands are doing anything
im running all these commands and nothing happens and i don't get a error
are they registered in plugin.yml
e on accident
Why are you checking if An empty set contains a player?
who creates a command named "setLives" XD
please tell me you use ignoreCase
and if so it's even weirder that the L is uppercase
best i can do is to cast the string to its sha-1 hash and compare it
can you set the velocity of an AOE cloud? I am but it seems to have no effect on the entity
how do i make this return the sub commands so they auto complete
like that
but commandname
u gotta make the class implement tabcompleter
and implement that
honestly, tho bukkit command system is horrible, use something like afc or lamp
I guess you want a map for subcommand lookup
ive never used an addon like that
maybe i should
u really should
return it where
u gotta reutrn a list<string>
not list<subcommand>
can i see what ur subcommand class looks like?
Strange segment in AbstractMinecart fn MoveAlongTrack that makes zero sense to me; https://paste.md-5.net/havakilaye.cpp
It seems to make X & Z coords 50% bigger if it's moving along an axis and set position of Cart to there
On a corner it works out to put it in a different place on the rail (Which still seems strange because there's no check for direction)
(From testing it rewritten in Python with Minecart coord at 100.5, 100.5 (middle of block) and Rail coord at 100,100)
Can someone help me work out what this part actually does because I'm at a loss all day
The only way it makes any sense to me would be if Java does not use BIDMAS
u can do subcommands.stream().map(SubCommand::getName).collect(Collectors.toList());
just trying it. You are amazing
it does keep completing forever but thats not a huge deal
how can i pass this through to the sub command
guys Idk if I'm dumb or what but I have a
HashMap<UUID, UUID>``` and this listener ```java
public void onSelectedPlayerLeft(PlayerQuitEvent e) {
UUID target = e.getPlayer().getUniqueId();
Iterator<UUID> iterator = plugin.trollManager.cachedTrollPlayers().keySet().iterator();
while (iterator.hasNext()) {
if (plugin.trollManager.cachedTrollPlayers().get(iterator.next()).equals(target)) {
Player troller = Bukkit.getPlayer(iterator.next());
plugin.guiManager.openPlayerSelectGui(troller);
}
}
}``` why does this stop after it finds the first match?
There is a command for that in vanilla iirc
Attribute
public static void addRecipeThunderSword() {
ItemStack thunderDustItem = CustomItems.createThunderDust();
ItemStack thunderSwordItem = CustomItems.createThunderSword();
ItemStack magicDustItem = CustomItems.createMagicDust();
ShapedRecipe sr = new ShapedRecipe(NamespacedKey.minecraft("thunderswordcraft"), thunderSwordItem);
sr.shape("DGD", // Dust, Glass, Dust
"GMG", // Glass, Sword, Glass
"DGD");// Dust, Glass, Dust
sr.setIngredient('D', new RecipeChoice.ExactChoice(thunderDustItem));
sr.setIngredient('G', Material.WHITE_STAINED_GLASS);
sr.setIngredient('S', new RecipeChoice.ExactChoice(magicDustItem));
Bukkit.getServer().addRecipe(sr);
}```
java.lang.IllegalArgumentException: Symbol does not appear in the shape:83
whats wrong with my recipe?
Don't see An S
oh wait whattt, im blind mb lmao
Read stacktraces
FurnaceRecipe fr = new FurnaceRecipe(NamespacedKey.minecraft("magicpowderfurnace"), magicPowder, new RecipeChoice.ExactChoice(poisonPowderItem), 1.0f, 40);
now i have a list of items that can be inputs for the furnace but how do i get that list as the input?
ignore this i fixed it
it calls iterator.next() 2 times
you could use a foreach
or just store iterator.next() in a variable but both methods are effectively the same
Anyone know why my IDE is not recognizing the Player#openAnvil(loc, b) method?
Bro I need the index of the outset x the index how do I do that with offset
ty, I ended up using this and it works now
public void onSelectedPlayerLeft(PlayerQuitEvent e) {
UUID target = e.getPlayer().getUniqueId();
plugin.trollManager.cachedTrollPlayers().keySet().stream().forEach(uuid -> {
if(plugin.trollManager.cachedTrollPlayers().get(uuid).equals(target)) {
plugin.guiManager.openPlayerSelectGui(Bukkit.getPlayer(uuid));
}
});
}```
gg
Kinda funny it took me an hour
to figure this out
I really didn't see the error with the iterator thing
even tried a for loop
whats the simplest way to raycast into the direction the player is looking and getting
- the block face that was hit
- the entity that was hit
i tried using BlockIterator but it just returns a Block object
Hello, could someone help me with something?
I am making a plugin in which I need to check if the user has a permission, but this permission is based on a "list" so to speak, which would be in the config.yml divided by groups, something like:
default:
- "text"
vip:
- "text vip"
admin:
- "text admin```
but what happens is that I want more groups to be added in the config.yml and with this a new permission would be created, example
- testpermission.default
- testpermission.vip
- testpermission.admin
Make getters lol
ur using the wrong constructor
put subcommands.add(new SubCOmmand) in the constructor that takes the plugin as an arg and remove the constructor with no args
getters for what?
of a particle?
?
of what
setting the velocity of the entity called "AreaEffectCloud"
how do you set an entities velocity
would be even more to write
nvm
However I just saw that I'm getting a ConcurrentModificationException now on this one
eventhough it does work
youre probably adding or removing from a list while iterating
tbh i cant find if the aoe cloud is an EntityInsentient
but id suppose just as u can call setOp on an OfflinePlayer but it will fail
this may also apply to other api parts
what does this have to do with setting the velocity of an entity
setVelocity is a method from the Entity interface
oohh
Iterators are there to avoid this. alternatively you can copy the collection over which you want to loop, then instead loop over the copy and then remove the stuff only from the original collection.
alex can you check sumtin for me
Is there an easy way to make player tab show player display names???
my entity has gone back to turning into a regular minecart on unload/reload DESPITE being a registered entity.. was fixed for a while but noo
i do know that it doesn't do this if i don't super the minecart entity type (but instead its own) - but then clients see it as a pig
so it seems like the better fix is to make clients see it as a minecart while the server doesn't
anyone know how i set the network ID of custom entity to appear as something else instead
does PostLoginEvent from bungeecord only run when the player logs into the network? and wont' trigger as players switch servers?
how to delay ServerConnectEvent?
wdym delay
?scheduling
thats bukkit api
ServerConnectEvent is bungeecord
you could force players, on swithcing servers, to use some command you made to switch servers
and delay that
what is the dependency for actionbarapi
because i added the jar file into my project but i get this
package com.connorlinfoot.actionbarapi does not exist
Hello, I am getting kicked from server when I try to send entityEquipment packet. When entityId is armor stand it works but when it is same player: https://cdn.discordapp.com/attachments/984344319643246632/984549369401475192/unknown.png
public class EntityEquipmentPacket extends AbstractPacket {
private final ItemStack helmet;
public EntityEquipmentPacket(int entityID, ItemStack helmet) {
super(entityID, PacketType.Play.Server.ENTITY_EQUIPMENT);
this.helmet = helmet;
}
@Override
public @NotNull
AbstractPacket load() {
packetContainer.getIntegers().write(0, entityID);
packetContainer.getSlotStackPairLists().write(0, Collections.singletonList(new Pair<>(EnumWrappers.ItemSlot.HEAD, helmet)));
return this;
}
}
AbstractPacket class just does some very simple setup so it shoudnt matter.
Any idea what I am doing wrong?
whats the difference between getServer().sendData and getServer().getInfo().sendData
oh you know what i don't even care nm
I can't connect them
They just joined the network
and they are connecting* to that serer.
server*
I want to delay the event so I can load their data before they join
the under server has to have the data already loaded on Redis by the time they join the server.
what is the sing sound effect when you hit someone with a bow?
First one sends data if there's a player online and doesn't if there's none. Sending data to serverinfo will send data if a player is online but will queue the data to be sent when a player joins if no player is currently on
so uhh any ideas?
How can I force a player's compass target to spin as if not in the overworld? Setting the location's world doesn't work and just points to the same coords in the current world
when using ServerConnectedEvent, using event.getPlayer().getServer().sendData returns a null server
is there a way to get a non-null server
when I do event.getPlayer().sendData, it doesn't send for some reason so i'm trying this but its notw orking
Which location are you altering
Another player's location, if the second player is in the nether and the first is in the overworld, the first's compass points to the players nether coords but in the overworld
Hi ! I have a problem with my code. When I want get item.getItemMeta().getDisplayName() in my PlayerItemConsumeEvent I get the good name but when I did this condition if (item.getItemMeta().getDisplayName() == ChatColor.GOLD + "โ "+ ChatColor.YELLOW + "Ramens" + ChatColor.GOLD +" โ") { p.sendMessage("Vrai"); } else { p.sendMessage("Faux"); } And i Ate the item this say me "Faux" (false). But in check it's the same name
p.sendMessage(item.getItemMeta().getDisplayName());```
Someone have idea ?
PDC ?
Persistent data container
?pdc
thx
if you want 1.7 to 1.19 support*
NBT API for outdated versions
doesn't matter
it is so useful, and not very difficult to learn
it works on newer too
Looks like one got made - https://github.com/SpigotMC/BungeeCord/issues/3327
It's not been documented anywhere, but BungeeCord 1.19 has an API breakage - it's not possible to use the chat passthrough .chat() feature.
Does matter. Don't need it
I use 1.8 version
?nbt API
they might use 1.7 if they're stupid very legacy players or 1.19 if they enjoy the new terrain.
at least 1.12, some servers are using
May I see code?
and PDC didn't exist back then (on the bukkit api)
you cant please everybody
Well if you're forced to use an outdated version then you'll need to use NBT API
๐ legacy versions
there was an NBT api?
well.
why did that get taken out
Yeah, older versions lack a lot of QoL and features modern versions have
i think pdc replaced it. pdc is great to use. nice api
it can't
NBT is the base of minecraft..
NBTAPI adds access to NBT.
PDC also adds access to nbt (as far as I know)
@Override
public void run() {
if (Plugin.isRunning() && Plugin.target != null) {
// for (ItemStack compass : Plugin.compasses) {
//
CompassMeta compassMeta = (CompassMeta) compass.getItemMeta();
// Location targetLocation = Plugin.target.getLocation();
// compassMeta.setLodestone(targetLocation);
// Bukkit.getLogger().info("Location: " + targetLocation.toString());
// compass.setItemMeta(compassMeta);
// }
for (Player player : Plugin.hunters) {
Location location = Plugin.target.getLocation();
if (location.getWorld() == player.getWorld()) {
player.setCompassTarget(location);
} else {
// player.setCompassTarget(null);
player.setCompassTarget(player.getLocation());
}
}
}
}
}.runTaskTimer(Plugin.getPlugin(Plugin.class), 1l, 1l);```
lmao why'd it format it like that
oh, could be. i have no clue so take my comments with a grain of salt. :)
?paste use pastebin
that wont work
I assume you could just get a random location relative to the player if you want it to spin
You'd have to do sth like JavaPlugin.getPlugin(YourMainPluginClass.class)
(not Plugin)
i guess the separation of vanilla nbt and having PDC for plugins is nice..
it works fine, its a snippet
https://paste.md-5.net/sikolorati.java cleaned up version
yeah
lol nvm then
its what i name the main class for all my plugins
yeah its nice decoupling
tho unlikely mojang would ever switch from their current nbt system
soo i have a fun question for u guys, i have a registered custom entity and i'm making item to spawn it
it passes itself to the superclass in it's constructor
however i have no idea what i need to pass to it in the spawn item (in place of EntityType.MINECART) and/or do in the loc argument constructor to super this
So, I have a PostLoginEvent listener, and I connect the player on the event itself, and so I have a ServerConnectEvent, so the question is, how can I delay the Event? I have to delay it to load the data to redis so the server under the bungeecord has the data.
[Bungeecord btw] <- not new but maybe someone doesn't know.
Try doing player.setCompassTarget(player.getLocation().add(Math.random(2), 0, 0)); or similar instead
another fun reason for PDC is to make sure people don't think they are going to edit item meta stuff with it.
maybe ServerConnectedEvent?
its a different event from Connect
existing item meta right? you can add data with it, but can't modify an item's existing data.
ServerConnectEvent is called when a connection is going to be made.
ServerConnectedEvent is after the connection has started.
if it's connected already, it's terrible..
because I cannot load it fast enough
why?
if the player is already connected, you can just use the data you sent to the server to now do whatever you need?
yea, minecraft nbt values cannot be mutated with it
why do you need the data specifically at that time
that's interesting, but also makes a bit of sense. you could goof up minecraft pretty bad if your not careful huh?
because I'm making a server where the servers can be offline and online at different times
the servers have to have the data already loaded at the time that the connection IS BEING DONE, it's not after.
because after, the server did not find the data, already threw 50 NPE's and life's not good.
Then do it on the main thread so it delays it?
or LNG instead of LG
How.
Is there a reason for doing it on bungee and not the server itself?
Oh boy aren't you the person who s trying to pair online and offline players?
Yes.
because it's way more effective.
Are you loading data from the DB to redis on bungee so that the backend server can access only redis?
Why "Plugin" with cappital letters its hurts my eyes*
yea you definitely do not want plugins manually editing minecraft nbt values
C# Will hurt your eyes more..
three lines later you have a server error with no trace of a plugin mutating anything
mad burn
Im trying to make a clickable message, and if clicked run a method, this is the code I have rn, any ideas?
player.sendMessage("Confirmation message.",
"Do you want to confirm?");
TextComponent message = new TextComponent ("Yes");
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/command"));```
I know i used to develop windows dektop apps
it doesn't matter????????
the point is simple
how to delay ServerConnectEvent
it doesn't matter how why, what, or anything else.
By running your code in the event? Unless the event is async
Do you have experience with redis? Do you know about any lib working over Redis for sending/receiving packages of data?
What do you mean by packages of data?
If the event is async your solution is quite simple. Write yourself a fork.
Like doesn WebSocket, you define a packet
Well is ServerConnectEvent ASYNC?
No clue I'm asking you?
And then you send and receive data via that packet
I suppose you can use Gson to serialize/deserialize classes and just send them as json
you didn't know
isn't that kinda how the Log4J vulnerability orked
well how would I know..
but not with gson
Gson#from(String, Class) => Object
Gson#toJson(Class) => String
or use a lib Like Jackson
Put a thread.sleep there? Idfk you're the one complaining that you can't pause it or whatever or asking how to
I'm not complaining I'm asking how. And I really don't know, because Bungee is multi-thread (well uses multiple of them)
so I'm confused on how I should do things
The reason I asked the initial question was because I think you have a flawed design/approach to the problem @vestal dome
?jd
yes, and you get aggresive when we try to find out why
What's the best way to save data (like inventories and stuff) to files?
yes
but like
many of the player connection related events are synchronous to the connection
like with in spigot AsyncPlayerPreLoginEvent, the player cannot login until the event is handled
I don't understand the urgency
I apologize..
but its still asynchronous in relation to the server thread
I do get this but I just got stuck because I need an event that is called on a player connecting to the server to change the information of the player and stuff...
hello, i run PostLoginEvent to run this code:
e.getPlayer().sendData("BungeeCord", out.toByteArray());
like im sending data to the server, but it's not working. any way to send packs on the moment the player joins? i want it to run only when th eplayer logs in and not when it switches servers
or well, in relation to other processes happening
when the post login fires the player connection has yet not been fully established iirc
i added this bit
ProxyServer.getInstance().getScheduler().schedule(Main.getInstance(),
() -> {
e.getPlayer().sendData("BungeeCord", out.toByteArray());
Main.getInstance().getLogger().info("SecondStar received connected event from: " + e.getPlayer().getDisplayName() + ", sending pack...");
},
1,
TimeUnit.SECONDS
);
so that it waits a second
uh?
iirc?
if I remember correctly
yeah liek conclure might be wrong
Conclure is genius
so it might also be that he might not be on the server yet
which is why im waiting a second
it appears to be that is also what Bungee Resource Packs do
well if I call a connect event on PostLoginEvent it should take over the priority right??
you have to remember bungee is a proxy
like sure the player does connect to the proxy, but that does not inherently imply the player is suddenly connected to backend as well
is there an event for like the first time the player is logged in and connects to a "backend"
yes but then check if it was initial
huh
yeah
wdym check if it was initial
check with sth like ProxiedPlayer::getServer == null
might be you wanna use the pending connection instead
but you get the point
so it will be null before its not fully established the connection? and when it switches a server, it will still contain the old server its on and not be set null while its connecting?
basically
if I remember bungeecord correctly thats how it works
or if im just mixing this shit up with velocity
altho their designs are to some extent identical
i do want to use velocity one day but my server doesn't really need either or
im fine with either as long as they work
yeye
does having entities with large amounts of PDC data have any negative effects for the server?
by large amounts i mean like 10-15 different "attributes"
probably not
didn't work, gonna try e.getPlayer().getServer().getInfo().sendData("BungeeCord", out.toByteArray()); instead
k, im probably being more conscious of the server's performance than i need to, but my plugin seems "heavier" than some others. i could be wrong though. thanks for the answer though
you could try spark to get to see what your plugin does
just put it on the server and run the profiler for CPU profiling. also has a way to check the heap summary
Got two kind of complex questions about custom entities:
- I have it registered - In my item spawn I need to pass it's entity type to the constructor but when I try to get it from the registry I get a type mismatch, not really sure how I get it from the registry (it's summonable so I'm trying to work back from that but not finding anything useful)
- Because it is it's own type, clients see it as a pig - How do I give network ID of a Minecart
wow. that seems helpful for every plugin developer regardless of the plugin size. thanks!
well ok. so i did find one metric
that plugin alone is 3.4 MB, and my plugin is 98K
lol
its not meant to be included in your plugin
just as a plugin itself. i got that.
i think, i've only used it on my server
i was just comparing file sizes, and was surprised
ยฏ_(ใ)_/ยฏ
huh. i guess its just my computer. the profiler says the server is fine.
I mean, your PDC lives in memory
and needs to be loaded from file
that is about it
but as with any in-memory storage solution, if you trash it with giant data sets that is on you
every get a good idea for your plugin and have absolutely zero idea of how to approach it at all?
i do!!! :)
Well time to start researching
:) my issue is more of a plugin architecture problem, but some research won't hurt
What're you trying to do?
trying to make a plugin inspired by Tinkers' Construct, but with a few interesting twists in how upgrading the tools works
right now im trying to implement a fuel system for the upgrades, and ive got most of it. just missing one small piece.
https://pastebin.com/ePprMPVN does anyone know why I would be getting a class not found error here? I'm just messing with nms and I'm curious why It works when I statically access the class,but if i instantiate the class I get a class def not found error its quite odd
No! ๐คฃ
No!
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Here
i dont know why i found that so funny! i watched it 5 minutes ago and im still laughing ๐คฃ
are you trying to prevent people from placing on dirt?
No this is like an addon to oraxen
Like conditions
This custom block can be only placed on thos block
And only this block
But somehow
Its reversed
declaration: package: org.bukkit.event.block, class: BlockPlaceEvent
that else if is the problem. i agree with hyper
oh wait, the else if actually happens... i didn't look enough
if (preventType == event.getBlockPlaced().getType() && placedOnType == event.getBlockAgainst().getType()) {
event.setCancelled(true);
player.dostuff
}
it will
that looks good to me. lol, the confidence is great
well. i just realized my idea isn't thought out enough... oops
#notcreepy
๐
๐ ๐
.๐.
.๐.
anyone know if papi has 1.19 builds, so i can test?
doesnt seem so
sad
Hey guys, im trying to open an inventory (specifically by a method), when a specific message in chat is clicked, anyone know how to do that?
some recent activity. not dead!
TextComponent message = new TextComponent ("Yes");
message.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/command"));``` how would I be able to implement that here?
can I replace the run command?
wut?
?jd-bc
??
oh ok sorry
Hey, I have a plugin that I created that I would like to separate into two different plugins as it would make more sense to do so. I'm currently using a relational database to store player settings, but was wondering if I could get some advice on how to proceed. Should I use the same database for both plugins? Or should I use separate databases? Or is there something better to do that I am unaware of (something like accessing my database class from the new plugin)? Thanks!!
1.18
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
?jd
ohhh bungeecord chat is separate
?jd-bcc
dummy
fuck u too babes
โค๏ธ
dont you dare
but it would be "mod abuse" ๐
mod is a abbreviation for moderation
my knucles are infinitely strong
if (material.equals(Material.DIRT)) return;
that line is ignored
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
i punched a dent into my dresser
material == Material.DIRT
not .equals
What?
enum variants are constants
Same thing
no
you must obide by what i say
kidding
but its frowned upon to call .equals on constants, like enum variants
that line isnt ignored
also
do what i said
why are you listening to PlayerInteractEvent
^
@normal isle instead of using the event specifically designed for things like this, you cheat your way into it
L
1
2
2
3
gave you the answer
ignore my mentally challenged friend
fuck you
โค๏ธ
โค๏ธ
no the frick you didnt
Just making sure, inventoryclickevent and inventroydragevent is enough to stop ALL inv modification?
inventoryinteractevent can substitute both of those
declaration: package: org.bukkit.event.inventory, class: InventoryInteractEvent
if inv == myinv { setcancelled }
that's abstract is it still called?
Nope
so i have to listen to both
both of these
Yep
i do tho?
No it doesnโt have static getHandlerList method for one
im gonna check something
Itโs basically gonna end up exploding like if you were to listen to Event or PlayerEvent etc
Ye
https://pastebin.com/ePprMPVN does anyone know why I would be getting a class not found error here? I'm just messing with nms and I'm curious why It works when I statically access the class,but if i instantiate the class I get a class def not found error its quite odd
my only bet, and I dont have a ton of experience with the new mappings, is you are using the mojang mappings and not converting back to the spigot mappings
yep as you said that would be the issue I was moving projects for testing and I just figured out I'm not recompiling with the spigot mappings
thank you I like instantly realized I forgot the second you said something lol
lol
Hello everyone i'll continue the thing that he started with it but more comfy haha. So i wanted to created a mechanic that will e.g prevent players from placing dirt on other type of blocks then only one that i speciefie e.g Stone
i literally gave him the answer
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
public class CanBePlacedOn implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void OnPlaceBlock(BlockPlaceEvent event) {
Block block = event.getBlock();
Material material = block.getType();
Player player = event.getPlayer();
if (preventType == event.getBlockPlaced().getType() && placedOnType == event.getBlockAgainst().getType()) {
event.setCancelled(true);
player.dostuff
}
}
}
declaration: package: org.bukkit.event.block, class: BlockPlaceEvent
sry afai
please tell me you are not using pseudocode and trying to compile it.
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
oh they fucking are
what? no it's inside my custom plugin for addons to oraxen
braincells are gone im going to bed
goodnight
i compiled it with maven and create it in IntelliJ
wdym bro
its for plugin not mod first of all
second of all your answer have red light because there isn't a thing like preventType
because inferring things isnt a thing anymore
ah anyway i don't want to lose your time my friend
thank you any way for a few good tips
it's to hard for newbie like me so i'll just pay for some advanced developer that will make work it for me haha
have a good night mate
pay?
ye
dm me
๐
LMAO
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward i don't quite understand this
here is the response
short len = in.readShort();
byte[] msgbytes = new byte[len];
in.readFully(msgbytes);
DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes));
String somedata = msgin.readUTF(); // Read the data in the same way you wrote it
short somenumber = msgin.readShort();```
that the example gives us
is the subChannel going to be Forward or the subchannel you specified
is there a good way to format the lore text? kind of like iomanip if you're familiar with c++?
Is the location where an experience bottle breaks stored after the bottle breaks?
more specifically a setw equivalent
Nevermind
might be a beginner question but doesn cancelling the PlayerInteractEvent cancel block placement as well?
There's a BlockPlaceEvent
anyone used the Forward bungee plugin messaging subchannel that can tell me whats going on
do i need to make a class for every command i want to make?
ive already got the event stuff done but
No
There are lots of options to make commands cleaner
so its basically mocking me lol
Show code and plugin.yml
alr
instanceof?
There's nothing that depends on the sender being a player here
in case the command is sent from the console
But why would that even be a problem
It's not like you need to do any player specific actions to the sender like damage or teleport them
true
Literally all you do is send a message
is there a tutorial video for this
ive tried like 3 different ways just now and it still does the same thing
fixed it with
CommandHandler commands = new CommandHandler();
getCommand("discord").setExecutor(commands);
in the main class
Im having an issue comparing locations.
[23:11:27] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=40.5,y=70.0,z=322.5,pitch=0.0,yaw=0.0}
[23:11:27] [Server thread/INFO]: Location{world=CraftWorld{name=world},x=40.5,y=70.0,z=322.5,pitch=0.0,yaw=0.0}```(2 different entries) and I have an if statment to check if they are the same, and it does not go through, any ideas?
are you using ==
you should use .equals
oohhhhh ok tysm
same memory location
on strings that may have unintended side effects
im pretty sure utf-8 and utf-16 strings wont work together on ==
my bad
Can I get ItemFrame object from an ItemStack?
I'm guessing not since it's an entity.
How can I query this in 1.19 since this has been removed?
import net.minecraft.server.MinecraftServer;
MinecraftServer.getServer().recentTps
Step 1. Don't
wat
I am sure there's another way to get tps
Average it yourself via the scheduler if you have to
Don't use nms
couldn't you just run the calculations yourself
don't understand why you would need nms there
from a google search looks like you can do it with a scheduler as redempt said
is it possible to remove the zombie pathfinding ability in nms?
Disable ai?
is it a known issue that boats riding players don't update their position for the client that the boat is riding?
other players on the server see things as they are, but the player with the boat on their head sees the boat where it was, and then the boat teleports to them when they eject the boat.
i'm going to check jira now, but wnted to ask here also.
only the path finding of players
you can clear their pathfinder goals, or just remove the goal you don't want them to have
this.targetSelector.removeGoal( new NearestAttackableTargetGoal(this, Player.class, true)); i tried this but it still hits player
don't remove a new thing ever, i think that's your problem
you should get the goal from it's list of goals, then remove the one you want to remove from there.
the code you sent i'm pretty sure will just create a new instance of a NearestAttackableTargetGoal, and since it wasn't in the goal list, when you tell the game to remove it nothing of note happens
ok
No, encoding does not matter there. As long as the Strings are in the String Pool (e.g. are interned) == will work as intended - that being said the String Pool is modified UTF-8 iirc
public class runner extends Villager {
public runner(Location location){
super(((CraftWorld)location.getWorld()).getHandle());
}
}```I am getting an error in the super line but i did the same for my other class and it does not have that error
Cannot resolve method 'super(net.minecraft.server.level.ServerLevel)'this is the error
what package is Villager in?
import net.minecraft.world.entity.npc.Villager;
EntityVillager's constructor takes EntityTypes<? extends EntityVillager> in addition to a world
(and optionally a VillagerType as a 3rd arg)
if (!TntTag.games.isEmpty()){
for (Game game : TntTag.games){```
but I still get error: `` generated an exception
java.util.ConcurrentModificationException: null
at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1013) ~[?:?]
at java.util.ArrayList$Itr.next(ArrayList.java:967) ~[?:?]``
the extend Villager was entityvillager but when i added the remapping it got changed
ya that's fine, same class afaik
super(EntityType.VILLAGER,((CraftWorld)location.getWorld()).getHandle()); is this correct?
i think so
https://www.spigotmc.org/threads/protocollib-entityequipment-packet-error.559981/ Can anyone help me with this?
i was googling around and it looks like this is happenning with boats:
https://www.spigotmc.org/threads/spigot-1-9-player-setpassenger-help.130324/
PacketPlayOutMount isn't being sent to the player that the boat mounts.
im going to play with it more, and if this seems to be what's going on i'll make a jira bug
(also need to run buildtools again, just remembered i didn't do that yet today)
((CraftWorld) player.getWorld()).getHandle().addFreshEntity(new NewMob(player.getLocation()), CreatureSpawnEvent.SpawnReason.DEFAULT);This is the code to summon a custom zombie created , but how can i use it to summon Passivemobs
if i were you i'd make functions to modify the ai instead of extending the entities.
makes things a lot simpler, you can use API to spawn in whatever and then use functions to modify it's ai after. i did it for one of my minigame plugins and it works great, also makes it so you don't need to extend a bunch of entities, just make functions that use EntityInsentient, or whatever the mappings call it
also makes it so you can just make your own pathfinder goals and stuff, and just kinda inject them in.
named my utility class BrainSlug as a futurama reference lol
nice idea even tho somethings went above my head
my code is old and i haven't had time to convert my projects to use the mappings, so it's still full of obfuscated method names and reflection and stuff.
but if the code was cleaner i'd send it over or submit it to see if they'd add it to the api or something.
bump
Can someone tell why chat preview always returns Type to preview in grey color?
I tried with ProtocolLib event nothing happened (seems not called)
World.rayTraceEntities and World.rayTraceBlocks, or World.rayTrace, using Player.getLocation and Location.getDirection
is it possible to make an item have enchantments but disable the enchantment glint?
cool didnt know that
It is possible, but would require using ProtocolLib or NMS
how would i do it using protocollib?
package fr.program.pranction.commands;
import fr.program.pranction.Pranction;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class MuteCMD implements CommandExecutor {
Pranction plugin;
public MuteCMD(Pranction plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("mute")) {
if (sender instanceof Player){
Player plr = (Player) sender;
Player target = Bukkit.getPlayer(args[0]);
if (!plugin.getConfig().contains("players." + target.getUniqueId())) {
plugin.getConfig().set("players." + target.getUniqueId() + ".name", target.getDisplayName());
plugin.getConfig().set("players." + target.getUniqueId() + ".banned", "false");
plugin.getConfig().set("players." + target.getUniqueId() + ".reason_ban", "N/A");
plugin.getConfig().set("players." + target.getUniqueId() + ".time_ban", 0);
plugin.getConfig().set("players." + target.getUniqueId() + ".muted", "true");
plugin.saveConfig();
}
if (plugin.getConfig().get("players." + target.getUniqueId() + ".muted") == "true") {
plr.sendMessage("[" + ChatColor.BOLD + ChatColor.LIGHT_PURPLE + "Pranction" + ChatColor.RESET + ChatColor.WHITE + "] Le joueur a deja ete reduit au silence !");
return false;
} else {
plugin.getConfig().set("players." + target.getUniqueId() + ".muted", "true");
plugin.saveConfig();
}
StringBuilder reason_mute = new StringBuilder();
String[] nargs = args;
nargs[0] = null;
for (String part : nargs) {
if (part != null || part != "null" || part != "NULL"){
reason_mute.append(part).append(" ");
}
}
Bukkit.broadcastMessage("[" + ChatColor.BOLD + ChatColor.LIGHT_PURPLE + "Pranction" + ChatColor.RESET + ChatColor.WHITE + "] Le joueur " + target.getDisplayName() + " a ete sanctionne par un moderateur pour : " + reason_mute);
return true;
}
}
return false;
}
}
``` Hello why I am still getting the case "null"? (It's about the loop `for`).
the metheod remove on what?
Anyone know if a 1x4 matrix can have an identity or is it only when rows and columns are the same?
I wonder what the point is of thread-locking palette interactions
Won't the identity be the 4x4 identity matrix?
oh yeah you're right lol
In particular, why it is thread locked now
you can have a 1x4 multiplication matrix
Wdym?
someone can help me with my plugin? but need it general 1 because i need to do a share screen
Can you screenshare there tho? Thought no one had permission
Guess a youtube video or some screenshots are possible options then
No matter I fixed it
You need to compare strings with .equals, you cant do != or ==
someone know why it not spawn slime?
you are not calling the method anywhere
You did not call your function @quaint mantle.
package fr.program.pranction.events;
import fr.program.pranction.Pranction;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class PlayerChated {
public static void init(AsyncPlayerChatEvent event, Pranction plugin) {
Player player = event.getPlayer();
if (plugin.getConfig().getString("players." + player.getUniqueId() + ".muted") == "true") {
player.sendMessage("[" + ChatColor.BOLD + ChatColor.LIGHT_PURPLE + "Pranction" + ChatColor.RESET + ChatColor.WHITE + "] Vous n'avez pas la permission de parler dans le chat publique !");
event.setCancelled(true);
}
}
}
``` Why once I reloaded the server, I can speak and .muted is true?
@dense falcon always compare strings using a.equals(b)
otherwise it wont work
also it might load it as a boolean instead
also
tf is that structure
thats not how events work
It is.
public class PlayerChattedListener implements Listener {
private final Pranction plugin;
public PlayerChattedListener(Pranction plugin) {
this.plugin = plugin;
}
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
// your code
}
}
then register thatr
@dense falcon
๐คฆโโ๏ธ
and compare using stringA.equals("true")
instead of ==
that wont work sometimes
I didn't do it like that and my way is very good for information, it's exactly the same thing except that I have something to sort out. Then, I ask something about the reload not about the events.
And ok.
shouldn't you be using getBoolean instead anyway
yeah
when are you calling that function
why are you using get string to get a boolean
this is confusing as fuck
@EventHandler
public void PlayerChat(AsyncPlayerChatEvent event) {
PlayerChated.init(event, plugin);
}
you don't need == true
or just if(getBoolean)
xd
lmfao
Alr.
I remember back in the day when I did if(boolean == true) lmao
I don't think I have ever done that
ive probably done that by accident a few times
Fixed, and now?
sometimes it helps tho visualizing stuff
yeah
when youre thinking in terms of a condition or comparison you sometimes write == true
or i do
at least
yeah
true
Yeah it works, thanks guys.
np
idk what you're doing but that method saves your config from your plugin resources/config.yml to your plugins/your_plugin/config.yml
or is that saveconfig
Hello can anyone help me I have a server of spigot but after i updated the server to 1.19 it always shows (incomplete sets of tags received from the server) but my friends can join but I cant
I have created a custom villager using nms but i am unalbe to summon it on command while on the other hand i am able to summon zombie
with 1.19 my npcโs (entityplayers) donโt work anymore. they need a new argument. โprofilepublickeyโ what is this exactly? i canโt find anything on the internet.
could someone help me?
ping me if you can help me
?paste
[14:43:47 ERROR]: Error occurred while enabling DiscordUtils v3.0.1 (Is it up to date?)
java.lang.NoClassDefFoundError: net/dv8tion/jda/api/entities/UserSnowflake
Why does this happen?
pom.xml: https://paste.md-5.net/abogatezay.xml
Maven or gradle?
Maven
what can cause villagers to not get scared by a zombie
The pom Looks okay, albeit I would Not shade log4j
Are you Sure that you are building the maven artifact via mvn package or similar?
I build it using IntelliJ
IntelliJ artifacts builder
I have created a custom villager using NMS but i am not able to spawn it I ma using `else if(args[0].equalsIgnoreCase("Villager")){
((CraftWorld) player.getWorld()).getHandle().addFreshEntity(new runner(player.getLocation()));
}`
I've sent u a photo in DMs
how does Enchantment#canEnchantItem() work? i'm getting true with diamond sword and quick charge 3
some enchants only work on some tools
What exactly did you do?
for example sharpness only works on swords and axes
quick charge i think is how long the charge resets when u hit someone
the new combat system charge thing
And Well 1.13+ is Not my area of expertise
wait
no
isnt quick charge a crossbow enchant?
oh wait nvm
thats his question
I would think so too
#canEnchantItem is basically a Switch on enum on the material
Iirc
Yeah, but that is a Switch on enum then
oh yeah nevermind it only worked because i was in creative
Ah lol
ig creative allows you to put any enchantment on an item using an anvil
no
u canonly do that using give command
It does
i just disabled my plugin and it lets me put protection on a sword
that has to be new
Been Like that since forever I think
At least since 1.7.4
I never knew it to be different
i guess i just never tried it
i was worried my plugin somehow did that. on survival mode, the prepare anvil event is not fired at all with incompatible enchants, but on creative it's fired and Enchantment#canEnchantItem() accepts the incompatible enchantment
i guess it just allows anything in creative
yeah could be
but maybe the docs should indicate whether creative mode affects Enchantment#canEnchantItem()
But how does spigot know that the Player is in Creative?
it has viewers on the inventory
but even then, how does the enchantment or canEnchantItem know the player
what does the method pass in as argument?
ItemStack
theres no way to tell what the itemstack's inventory from that object right?
i dont think so
maybe decompile the sharpness class
or the enum
not even an enum actually just the Enchantment class
Is there an actual way to change / add to server code with spigot?
wdym
theres tutorials online
I mean with a plugin :P
no then
no mixins?
what are u trying to achieve
add more events
Nope no mixins
you can create your own events
You can fork
what happens if you call an abstract method in the constructor of an abstract class? does it call the overridden method in the child class?
Yes
these rely on existing events
thanks
enchanted books have no getEnchantments?? (I mean it's empty map)
ngl i'd love to see mixins in spigot's api but it aint happening :c
Mixins does not really fit into spigot due to the amount of api thatโd probably break
but i see why its not possible
Nah
The enchantments are stored under a different nbt key
ok i'll check, thanks
yeah I guess..
for a private server it would be awesome to have mixins
Indeed
actually a custom jar is not a bad idea
it's getstoredenchantments or similar
yes but isnt fabric slower?
wait
actually yea, you could run a fabric server without any client side mod
frick fabric is actually a good idea
the line it is pointing to :
you are calling that method at the same time from another thread
i'm pretty sure fabric has a lot of optimizations but not as many as spigot for multiplayer or public server hosting
or Update is modifying getShips
well I need to execute that every tick
theres a lot of server side mods for fabric
it just moves blocks
i'm talking about internals, not mods or community made stuff
so its in repeatable task:
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, Repeateble::everyTick, 1, 20);
if you wanna workaround the issue just clone getShips and use that in the enhanced for
what's getShips? A list?
ArrayList
pretty weird name for a non method
for a field yes a very weird method
Bukkit#runTask() return an int (id) right?
but he called a method Update with capital U so im not suprised
bro didn't understand what's a getter
i used Unity
and the method there was with uppercase U
soo its fixed in me
ah
ik whats getter
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.
C# and java are not the same
I dont know why people think that as they learned C# they now how java Work
I dont want to modify the original variable
public ArrayList<Ship> getShips(){ return ships; }
I agree to the random person that said learn java
or modify only when i want to
That why are getter
Getter are done to access a class or a field
anyways do something like for(Ship ship : new ArrayList<>(getShips) {
public variables only make sense for static final things like Collections.EMPTY_LIST
Why?
make the return type a List
not an arraylist
sure thx
and even then a getter is better to get a list of the correct generic type
so he doesn't get the concurrent modification exception
Ohh ok
i'm 99% sure he's getting it because a method changes the list inside the for loop
can you access a non static field without an instance of the class through reflections?
no, that makes no sense
instance fields are always bound to an instance
Who knows why it writes this to me whenever I try to write the command speed? And the command is already registered
yea makes sense
check console
it means theres an error
having the stacktrace and the code would help
sort of what it says
why the heck are you checking the command's name?
thats what the tutorials teach you on youtube
check the stacktrace in the console
but you really only need to do it if u have multiple commands handled in 1 method
it must be a very shitty tutorial then tbh
they are
yea i remember watching the same tutorial
coded red
years ago
yep
why don't you look at the console and read the actual stacktrace?
i kinda have the feeling coded red just googles stuff and copy-pastes it in his tutorials
sometimes
^ it should be pretty straightforward what the issue is
.
wait
yeah it must be between -1 and 1
i wonder why they check if it's below 0 before checking if it's below -1
indeed, bro didn't even read the console ๐
why does this code bring me a little pain inside
ยฏ_(ใ)_/ยฏ
show the actual error
it's not the whole stackltrace
not the stack trace
there's a caused by part
?paste the full stack trace instead of screenshotting it
a lot of spigot's code contains massive if-else chains
String highLow = value > 1 ? "high" : value < -1 ? "low" : "";
if(!highLow.isEmpty())
throw new IllegalArgumentException(value + " is too " + highLow);
stil ugly
that's pretty stupid imho lol
just remove the < 0.0f check
so is checking for positive values
i just started
as we already said 3 times, 50 is too high because the max value is 1
https://paste.md-5.net/reruzixeyo.rb this is a nice 350+ line method in CraftRegionAccessor i discovered while creating entities without spawning them
the docs also explain that it must be between -1 and 1
it even tells you the exception thrown
ok thanks
you can give me some advice to learn spigot API ot to learn to make plugin with spigot API?
- learn java
- docs
- more advanced, read spigot's internals to understand better how does some stuff work
I just noticed that PlayerChatEvent is deprecated so how would I know if someone types in chat?
AsyncPlayerChatEvent
ok
are divisions by exponents of 2 automatically optimized to bit shifts by the jvm or javac compiler? for example, instead of down a / 2 it will be a >> 1 or a / 8 = a >> 3
with integers
but how I will be more advanced
?
pratice makes perfect
And if I do not understand the docs?
back to step one
but it not go step by step
step one was learning java
