#help-development
1 messages · Page 1415 of 1
have an array of consumers
what is a consumer
could be for each slot, or for item id or something
variable that executes code
Consumer<int> myconsumer = (i) -> {
System.out.println(i);
}```
takes a lambda expression
doesn't have to be an int, can be any generic
so is guiObject an item in the gui?
yup
public GuiObject(Material material, int amount, Gui gui, Consumer<InventoryClickEvent> consumer) {
this.setType(material);
this.setAmount(amount);
this.owningGui = gui;
this.consumer = consumer;
}
GuiObject obj = new GuiObject(x, x, x, (event) -> {
//do stuff
});
Gui object is just ambiguous, could be the holder, could be the item
then when you want to actually call it
call consumer.accept(event)
on your listener
but you would have to figure which object is being clicked
i mean you could
but you would have to do the same if statements in all of them
which is the same as having just one
Is it possible to create a packet and send it to a player with a shield blocking to simulate the shield getting hit by an axe?
I want to force players to lower their shields
how would i create a new instance of an InventoryClickEvent
you dont
new InventoryClickEvent(args)
you are just passing it to the consumer when it gets called
but you can do that to check if it's cancelled
by another plugin
before you do something yourself
dangerous territory though
show your code
Tried that and it sets the cooldown correctly and you see the items cooldown in your hotbar but doesn’t lower the shield
So it defeats the purpose of the cooldown because you can just continue to hold down right click
Shields also have a unique cooldown animation
Which doesn’t work when you set it that way that just doesn’t allow u to block
Whereas a normal shield cooldown drops the shield down and then slowly comes back up
There has to be some sort of way to spoof hitting the players shield with a packet
Is there an easy way to check if an entity is in render distance of a player
you can listen for the Settings packet and get render distance from that, then just do a sqrt function. That's the best method ic an think of really
I guess a better question is, is there a reasonable and performant way to check if an entity is close the the player or should I just be sending my packet for all entities in the world
there is the getEntitiesInRadius (or whatever the method is called), can just iterate over that
I'd assume a few math calcs would be more performant than iterating over every entity in the world
Does that method have to check all entities in world anyway
Or does it do it by chunk
Good question, I'm not actually sure on that
would have to look at source
I'd assume it would just get neighbouring chunks and check
can i check the DisplayName in the PlayerInteractEvent to check if the block clicked is a custom skull?
@EventHandler
public void onClick(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();
if (e.getClickedInventory() == owningGui.getInventory()) {
if (e.getCurrentItem() == null) {
return;
}
if (e.getCurrentItem().isSimilar(this)) {
consumer.accept(e);
e.setCancelled(true);
}
}
}```
why isnt this working
it just does nothing
and doesnt cancel
this is a class that extends itemstack
You aren’t supposed to extend itemstack
@young knoll true
Or most API classes
Why extend ItemStack
You shouldn’t compare inventories with == use InventoryHolder (discouraged) or InventoryView
So what? Then it works lol
no
its this part
if (e.getCurrentItem().isSimilar(this)) {
consumer.accept(e);
e.setCancelled(true);
}```
no
Yeah idk send ur entire class lach also how do u register it
i did this thing so i dont have to use material
oh okay
equals and isSimilar do completely different things
?paste
Or well they’re not exactly the same
this is 1.8 api
Can you stop implementing the api interfaces lmao
1.8 xD
ItemStack and MetadataValue wth
metadatable has to be implemented so i can add metadata yea
Wat
itemstack doesnt have setmetadata
That doesn’t mean you should implement the api interface
Unless it’s explicitly mentioned don’t because it most likely will lead to unwanted bi effects
setmetadata works fine
i just wanna know why the listener isnt getting to that point
it sysouts "yes"
does the event get called at all
Maybe cuz you extend ItemStack dummy
how would that affect anything
Idk check the CraftItemStack isSimilar and the normal ItemStack ones
Maybe it disallows your extension of it
maybe its cuz im running a 1.8 plugin on a 1.16 server
That too isn’t a great idea
But for the fifth time dont extend api classes and interfaces unless mentioned jesus dude
ofc it exists
oh there is a nms dependancy;-;
oh
also make sure to run BuildTools and build 1.12.2
i did
IChatBaseComponent cannot be resolved to a type
hello hazim
o/
NMS = Non modified source or in the case of mc it meants net.minecraft.server
net.minecraft.server
I am just stating what it means, shouldn't be hard to check if its still present 😛
need to target the server jar instead of the api
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
<type>jar</type>
<scope>provided</scope>
</dependency>``` isnt this how
wot
do you have the server jar installed in your local maven repo @coral sparrow ?
no
that would be why then, install it to the local maven repo and it should pick it up 🙂
normally buildtools would do it for you
1.8 buildtools would?
any of them
imma install it again
run java -jar BuildTools.jar --rev 1.12
if you want 1.8 spigot then you need to change that
I meant in the pom
<version>1.12.2-R0.1-SNAPSHOT</version> this is what you showed you had, this means 1.12 spigot version, not 1.8
so <version>1.8.8-R0.1-SNAPSHOT</version>?
looks right
will have to research the revision number
not sure if it was only r0.1
or if there was a r0.2
ig there is r0.1 but no idea abt r0,2
anyways after fixing all that, and buildtools installs 1.8 to the maven repo
you should be able to compile
if buildtools still doesn't move it to the maven repo, I can show you how to manually do it
np
player.sendTitle("e", "e", 1, 20, 1); btw does this works
sure
is using nms better
how can i make a communication between spigot and bungeecord without plugin messages bcz i want to communicate even if players arent on server
throw some sockets at it
@quaint mantle basically what is being stated is have your plugins communicate directly with each other 😉
okay
Okay, so i followed this tutorial https://www.spigotmc.org/threads/small-socket-tutorial.211527/, but i have problem i have a command /serverstatus (that gets cpu ram and other things) and i want to make when console or player writes the /serverstatus command to make the bungee to make the spigot send the message through socket.
Code: https://github.com/pavlyi1/test
event.setCancelled(true);
}
}```
How do i allow them to use only some commands such as /msg /r
show the full event
ok
ty for help but.. I think you done it in a wrong way lol
u cant /msg or /r but u can use other commands xD
is that in PlayerMoveEvent?
PlayerCommandPreprocessEvent
yes
yw
does the code mean
you cant use msg and r
but u can with other msg
@quaint mantle
First you need to get the message and split them to arguments
and make an array that contains the allowed commands that they can process
after that check the array if contains args[0]
this means that if the command isnt msg or r then it will be disabled
does this actually work?
try msg without /
The code, because by all accounts it should not
u talking abt me?
yup
nvm, you are using pretty interesting logic
ikr
If I remember PlayerCommandPreprocessEvent works even if the player didn't process the comamnd
wdym
Beware of the commands.yml and command aliases
I dont even use that
i use some command aliases btw
uh nvm
heh
small question, currently im able to get "tickets" when player is online , someone knows a way to return all players "online & offline ? public static List<Player> convert(ArrayList<String> list) { return list.stream().map(Bukkit::getPlayer).filter(Objects::nonNull).collect(Collectors.toList()); } https://pastebin.com/0FEwbpBe
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.
how can i send a player a Title in Spigot in 1.16.5?
#getPlayer and #getOfflinePlayer never return null iirc
for them, everything is a player
getPlayer() returns null if the player isn't online.
how can i send a player a Title in Spigot in 1.16.5?
@quiet ice
Player.sendTitle()
but i cant just put the string in right?
Follow the variables provided
can you send me a example with the text: hello world?
player.sendTitle("hello world") wont work i guess
package index
package index
declaration: package: org.bukkit.entity, interface: Player
use the second one not the deprecated one
why when i click inside an anvil inventory the method getClickedInventory.getType return CRAFTING inventory and not anvil ?
i would try getView instead
in creative it return CREATIVE and in survival it return CRAFTING
very weird
getView is better for this
yep but look my message
it never return ANVIL
even with getView
thats weird
testing it now
haha funny of course i reload it
or stop the server and start it idk
and i put my computer in rice ?
what is the best time for fade out and fad in for a title?
Default likely, it's documented
okay
But you can always test for yourself with some try and error
yes i see
it makes sense when you see the code
so what's the problem ? i'm trying to uderstand
...
it would just be easier if you investigated the NMS code involved with it 😉
I works just fine for me
[10:36:08] [Server thread/INFO]: View: ANVIL```
your doing it on InventoryClickEvent ?
System.out.println("Type: " + event.getClickedInventory().getType().name());
System.out.println("View: " + event.getView().getType().name());```
.name() hmmm
how can i remove all particles using /kill or smth like that?
that's the only difference between us
@EventHandler
public void InventoryClick(InventoryClickEvent event) {```
on 1.16 my full method ```java
@EventHandler
public void InventoryClick(InventoryClickEvent event) {
if (event.getClickedInventory() == null) return;
HumanEntity whoClicked = event.getWhoClicked();
SlotType type = event.getSlotType();
whoClicked.sendMessage("Click - Top = " + event.getClickedInventory().equals(gui) + " : Type = " + type.name());
System.out.println("Type: " + event.getClickedInventory().getType().name());
System.out.println("View: " + event.getView().getType().name());
}```
works perfectly
i can't understand what i'm doing wrong
What spigot are you using?
let me just build current. There was an update yesterday
i've copy past your code
Silly question, but you are definitely clicking in an Anvil?
i open an anvil and click in it yep
I was in creative. I'll test in survival
okay i'm updating right now so
What does /version say
heuu 9 version behind sry
Yep, shows ANVIL in both creative and survival
i'm using maven did i need to change something in it to update it inside intellij ? or just run the build tool ?
You need to run BT to get the latest build for your test server
Hi, I would like help with ProtocolLib. I am trying to send a fake advancement, to show the popup on the top-right corner. But the packet is a little bit complicated 😅
Someone can help me please 😄
couldn't you just use t he api?
declaration: package: org.bukkit.advancement, interface: AdvancementProgress
Is there anyway someone could help me? I'm trying to edit the code for a plugin I have and I'm terribly new and don't know what I need to even do that. I'm not trying to redistribute it afterwards or anything shady.
U can decompile using online software, read the plugins terms before doing it
what are you trying to do?
Well the plugin itself is a gui. which has already been made and preset with things. the config that i can edit from my ftp doesn't let me do anything but change the placeholder items on the gui menu itself. I'm trying to make it so when you click the items in it, it not only runs the command it currently does, but also a second command which I need. Which can't be done from the config
Right, do you have the source code?
And that's where you lost me lol. I don't even know that. I have the file version of the jar file
😫
There is a way around it without modifying the plugin at all
and what would that be?
curiosity peaks
add a plugin I wrote called PermTrigger. That allows you to define a set of command to run when a player is given a specific permission.
then you just configure your GUI to assign a permission to trigger all the commands
is this normal that the PrepareAnvilEvent is fired infinit times until there's item inside it ?
It's not giving them permissions tho. It's running commands for them. I'm trying to make it so when it runs that first command for them, the console will run a command at the same time for something else
if you assign a timed permission it can even be removed after you are finished
Hey, I need help with ProtocolLib, I am listening to the Block Change Packet and want to get the type of the block before it was changed, using the packetwrapper i could only get the type of the new, changed block
Ummmmm, idk tbh. i thought it was when there was a valid input
Using permissions you can run any number of commands you want
Click GUI, it runs a single command to add a permission
by adding that permission it triggers teh command sequence
i'm making a custom anvil recipe but when i set result it trigger the event infinit times which repair my item infinit times
iirc you can only get the new block from the packet, because it is telling the client that it needs to change a block to that
and 3 trigger by move inside the anvil inventory
I am trying to make it so that only arrows drop but they still dont drop and no item drops
`@EventHandler
public void onpDropItem(PlayerDropItemEvent e){
// Player p = e.getPlayer();
if(e.getItemDrop().getItemStack().getType() != Material.ARROW) {
e.setCancelled(true);
}
}`
okay that makes sense i guess, do you have any idea how i could get the old block without using spigots events?
Seems odd, why would you want to avoid Spigot events?
i would say they are better cause the packets get kinda spammed
Who is doing the dropping? is the listener registered?
well i have an area where all placed/broken blocks should be reset, i just thought there would be a better way than listening to all of spigots block and bucket events
it is because no items drop
i would use spigot events over protocollib packets
Are you throwing items down and they don't drop?
alright thank you
is it possible to redirect a player to another server (e.g. to hypixel.net) when he enters a command?
no
replace != to == because you are saying that if not equal to arrow don't dorp
and only arrow drops
i want only arrows to drop
no, that is correct, right? he wants the arrow to drop
only arrows
okay
but nothing drops
?
nothing at all?
arrows should drop but nothing drops
Have you registered the listener
thank you
check other events
`@EventHandler
public void onItemSpawn(ItemSpawnEvent e) {
if(e.getEntityType() != EntityType.ARROW) {
e.setCancelled(true);
}
}`
the same for this 1 as well
no items spawn
not even arrows
that is not what you think
an EntityType.ARROW is the entity that gets fired from a bow
declaration: package: org.bukkit.entity, enum: EntityType
You would need this https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/EntityType.html#DROPPED_ITEM
declaration: package: org.bukkit.entity, enum: EntityType
how can i keep client socket keep alive and connected and not make it disconnect? https://paste.md-5.net/gixuwitozi.cs
are you running this code sync?
yes
your ServerSocketThread?
yes i am
you are locking up yoru server
no i am not it works
while (true) {
you are literally running that constantly and never stopping
It never exits so the server can do nothing else
And?
You can't run sync code in a permanent loop and not crash the server.
im like having command "/serverstatus" where i wanna get like cpu usage ram free/max/used and i use socket
How are you starting your runnable?
public void startServer() throws IOException {
serverSocket = new ServerSocket(instance.getConfigHandler().SERVER_PORT);
serverThread = new Thread(new ServerSocketThread(serverSocket));
serverThread.start();
}
That's a shit tutorial
and i am a newbie with sockets
So you are wrong, its not sync
bcz i need to use something that will work even without players online bcz console too
That is a terrible tutorial
Yea
and what should i use
Read like the last post in it it has a link to an official java 1 if I recall
Yes
okaay
`@EventHandler
public void onItemSpawn(ItemSpawnEvent e) {
if(e.getEntityType() != EntityType.DROPPED_ITEM.ARROW) {
e.setCancelled(true);
}
}`
doesnt appear to work
ah fixed, just tried this out: if(e.getEntity().getItemStack().getType() != Material.ARROW) {
thanks
👍
how can i wait 3 seconds in my java code?
Thread.sleep(3000);
hum guys, quick question. Does anyone know how the packet https://wiki.vg/Protocol#Entity_Metadata works? What I mean is what it does? Does it tell the client to refresh the GameProfile of the entity?
well yea
do you know concurrency?
For some reason im still not executing the command kit ```java
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (!SolarKitPvP.hasKit.contains(p)) {
if (SolarKitPvP.noKit.contains(p) && (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && e.getItem().equals(Material.NETHER_STAR)) {
if (!e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "Kit Selector")) {
return;
}
p.performCommand("kit");
}
}
}```
or just do
TimeUnit.SECONDS.sleep(3);
.
try debugging if you can reach the code
in that case i would runtasklater in the scheduler
Entities don’t have a gameprofile
Depending on the entities, different indexes will change the visual appearences for entities
Thats it
Like at index 0, a byte value of 0x20 will make them invisible
Do you know what the packet is used for?
I just told you
ok. What i want to do is create an npc with a skin.
EntityMetadata is not the right packet
Hu
I modified the gameprofile
and added the property textures
with the value of the texture
is it enough?
I told you what you need to do
There are places for the gameprofile in the player info packet
ok, when i send the packet with the gameprofile nothing happens
the player appears
without the skin
how can i lock a location so i created a Location of a player and added 33 blocks to the x, the Location is different for everyone but i want to lock it
Which packet are you using
PlayerInfo
Is the texture signed?
no
I believe it needs to be
public void openConnection() {
try {
this.connection = DriverManager.getConnection("jdbc:mysql://" + this.address + ":" + this.port + "/" + this.database + "?autoReconnect=true", this.username, this.password);
this.loaded = true;
Prison.getInstance().getLogger().info("[Database] Connection to the database was successful.");
} catch (SQLException ex) {
this.loaded = false;
Prison.getInstance().getLogger().info("[Database] Could not establish a connection to a database... Shutting down");
Prison.getInstance().getLogger().info("[Database] Reason=" + ex.getMessage());
Bukkit.getPluginManager().disablePlugin(Prison.getInstance());
Bukkit.getServer().shutdown();
}
}
why is this not connecting? all my info is 100000000000% correct im using it on another plugin and it works but not here
ye
cos the server shuts downm
do you have error?
the server shutting down and it saying it cant connect
send the error message
could you try ex.printStackTrace instead?
Prison.getInstance().getLogger().info("[Database] Could not establish a connection to a database... Shutting down");
Prison.getInstance().getLogger().info("[Database] Reason=" + ex.getMessage());
wdym
🤦♀️
I cant remember
.
Load the right classes
sure
Yea an exception would probably help lol
okay
https://pastebin.com/CzBuvZz4 here is how i did it
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.
fixed it
ig npe
Its probably ideal to not silence errors
User of your plugin “hey my server wont start”
Plugin gives no info
ig
?PASTE
How would i serialize a collection of byte arrays to byte array?
toArray()
What do you think the best way to listen for when a villager levels up? Just listen for VillagerAcquireTradeEvent and compare the villager's exp to the traded recipe's exp?
yes, you asked "a collection of byte arrays to byte array"
If you want it all in a single array you will have to packetize it. with a size byte preceding each section.
Though you might want to put this information before everything else for easy jumping without having to read a few bytes before jumping to the right position.
But I would advise against such principles for anything that is stored in memory, unless memory becomes a concern
yes
okay
pointless unless you are using different priorities
oh okay
listen
He means two event listeners that are identical, just different method names
I disagree, it may be easier to compartmentalize
what is this? xD
Or you may have a sequence of implicit else and dont want to rewrite the whole thing with if/else
Kind of, however you'd then be looking to two seperate classes
This is probably why i write different listeners in same class usually
your config is null
This code doesnt work doesnt even print anything ```java
@EventHandler
public void onInteract(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (!SolarKitPvP.hasKit.contains(p)) {
if (SolarKitPvP.noKit.contains(p) && (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) && e.getItem().equals(Material.NETHER_STAR)) {
System.out.println("Stage 1");
if (e.getItem().getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "Kit Selector")) {
System.out.println("Stage 2");
p.performCommand("kit");
return;
}
}
}
}```
did you register the event?
Yea its registtereed
add a Stage 0 after if (!SolarKitPvP.hasKit.contains(p)) {
it prints
Hello everyone !
I'm trying to do a plugin which will be usable for any version.
There are certain classes that I will have to do several times depending on the version of the game
I run into a problem: For version 1.13 and above, I have to put "api-version: 1.13" in the plugin.yml file ...
If I do that, my plugin is no longer compatible with 1.8 ...
How can I solve this problem please?
are you right clicking a block with a nether star in hand?
if so e.getItem().equals(Material.NETHER_STAR) should be e.getItem().getType() == Material.NETHER_STAR
yea was about to say lol
I saw your modification, what's the difference between
e.getItem().getType() == Material.NETHER_STAR
and
e.getItem().getType().equals(Material.NETHER_STAR)
please ?
== is for comparing primities, enums and other Singletons
Well if you look at what .equals does
(In an enum specifically)
It just does this == that
it does teh same however == is null safe
there is no practical difference
So no different, but you should use ==
but the convention is to use ==
Okay thank you !
enums should never be null anyway
multi-module project
each module would depend against a particular version of nms or api or whatever you're writing against
Thank you
and each module would implement functionality as defined in the contract of your internal api
and you'd load the correct module in depending on the server environment
Mh I see I see ...
I'm looking how it works and I guess I have to learn to use Maven so :/
myes
WELL !
Let's go so.
Thank you 🙂
Whats the simplest way to add an item to a dispenser, but override an item thats already inside the dispenser (the dispenser may be full)
if you don;t care about its contents, always add to slot 0
use addItem(ItemStack) and check its return value
I expect its iteration, which I am doing now, was just curious if there was a cleaner method
can you help me ? at net.minecraft.server.v1_16_R3.WorldGenFeatureFlower.b(SourceFile:33)
it returns a HashMap of anything that did not fit in the Inventory
thanks
this is a bit of a weird question but is javafx still worth working with in 2021?
@void flume Swoa are there more lines of errors?
and if not what's a good replacement for it
Show the full error and a descrition of what you are doing
oh cool, didnt know you could comment on messages
?paste
package index
@quaint mantle yes
😦
paste the whole thing @void flume
what are you trying to do
nothing
You are modifying the list you are iterating over whilst iterating
that sounds fancy so I agree
use an iterator
sucks to use streams i guess
um, this is happening in a chunk gen world populator?
oh Mohist 😦
@void flume You may get help in #help-server but as this is a Mohist server, good luck
Known server brands: Spigot, Mohist ?
spigot
I'd suggest you remove Chunky and see if it still ahppens
okay
chunky is just a pregenerator plugin though
yep, its teh only plugin I see in there that has any effect on chunks
by effect, you mean loading them?
perhaps he had a chunk gen running
players do that too
point is that chunky just tells the server to generate stuff, if the server blows up on that, there's something wrong somewhere and just removing chunky only hides the issue
?paste
Location: 447,773 is the chunk that threw the error
Since when has MC/Spigot chunk generation been threaded?
i built two containers in my minecraft map on the server and this event asks if a player clicks on a red or a green glas pane. If they click on the green they will be teleported 33 blocks + on the x and if they click the red - 33. everything works but the player can click multiple times on the red/ green pane wich means they can teleport as long as they want, i want that they only can click the red if they are on the side of the green pane. Here is the code of the Event: https://paste.md-5.net/exuyedixax.cs
the language is german btw 😄
1.14
I Missed that
yea chunk gen and lighting has its own thread
You'd have to check the players location before allowing them to move
Every time I see Objects.requireNonNull a small part in me dies
X/Y/Z coordinates, bottom right point, top left point, then check if player loc is between those with quicc mafs
reqnonnull doesn't make your code work better or make it more robust or make it able to handle nulls
because it still causes an NPE, it just stops showing the warning that there can be one in IntelliJ
it just makes it blow up more reliably when encountering nulls
which makes issues easier to diagnose
it's not a solution, it's a failsafe
Yeah, a failsafe is not why most are using it though. Its a false idea it will prevent an npe
most people use it just to hide ide warnings yeah
public static void connection(String s, boolean b) {
try {
if (!b && !connection.isClosed()) {
connection.close(); return;
}
String url = "jdbc:sqlite:" + s + ".db";
connection = DriverManager.getConnection(url);
stmt = connection.createStatement();
} catch(SQLException e) {
e.printStackTrace(); return;
}
}``` why is dont creating a file ?
oooh, haven't been back here for a while, time to see what noobs that don't know java have managed to do
SQLException: No suitable driver found for jdbc:sqlite:plugins\GroundLoot/database.db
kek
you don't usually need to create the file, because already create the file
you need to install mysql
no thanks
im using sqlite :p
install sqlite then
i don't think so
Check Class.forName("org.sqlite.JDBC")
but I had done a test on other versions, after I changed the version that started giving this error
the paste site exists so I don't need to download 30 million message.txt's from 4000 people sending them daily
well exist that class
you dont need install it
you can just .. read ?
i dont know if if the author who sent the message only can see
so i dont know why he need download it =/
depending on size it can be too wide/long to read easily in discord
?paste
https://paste.md-5.net/ideqabogix.cs why is this always else?
I'd suggest you look at that logic and simplify it if(!(someone.getLocation().getX() > -211))
if not greater than -211. So in other words if less than -211
yes less than -211 is for example -212
what is the current players x coord?
and line 3 no need to cast
i need to...
no its already a Collection<Player>
its easier to just for(Player someone : Bukkit.getOnlinePlayers()) {
But IJ is wrong if it says you have to cast
that code will teleport anyone who's x is less than -211
Hello spigt! I was removing all the mob AI and adding AI. Other AIs work, but 'PathfinderGoalNearestAttackableTarget' did not work. Do you know why? The other AI worked fine. my code:
@Override
public void initPathfinder() {
this.targetSelector.a(0, new PathfinderGoalNearestAttackableTarget<EntityHuman>
(this, EntityHuman.class, true));
this.goalSelector.a(1, new PathfinderGoalAvoidTarget<EntityGolem>(this, EntityGolem.class, 15, 1.0D, 1.0D));
}
Working part:
this.goalSelector.a(1, new PathfinderGoalAvoidTarget<EntityGolem>(this, EntityGolem.class, 15, 1.0D, 1.0D));
Not working part:
(this, EntityHuman.class, true));``` (It doesn't attack player)
@eternal oxide right
I have this little funktion witch should update the money value in a table, but it returns "null", can someone help me? (the name i use exist in the database)
public void insertgetter(String name, int betrag){ try { PreparedStatement ps = MainSQL.getConnection().prepareStatement("UPDATE money_survival1 SET money=? WHERE name="); ps.setInt(1, betrag); ps.setString(2, name); ps.executeUpdate(); } catch (SQLException e) { System.err.println(e); } }
because you need to put it in targetSelector, not goalSelector.
goal = movement, target = attacking
elaborate "returns "null""
ok, thanks
thanks, but ```
@Override
public void initPathfinder() {
this.targetSelector.a(0, new PathfinderGoalNearestAttackableTarget<EntityHuman>
(this, EntityHuman.class, true));
this.goalSelector.a(0, new PathfinderGoalAvoidTarget<EntityGolem>(this, EntityGolem.class, 15, 1.0D, 1.0D));
}
also, entitypig not working
and EntityCow
is it possible to get an array with online and offline players in the same Player obj ? still having problems to get offline players
you're the cutest creature I've seen in a minute
is it possible to make a spider go up the wall faster?
why not
You can’t have an offline player in a player object, so no
Offline will include online you just have to if (offline.isOnline()) player = offline.getPlayer()
What exactly are you trying to do? as getting offline and online players is quite simple
Hem guys, have anyone an idea why when i send the playerinfo packet with a skin property the skin isn't always applied?
lmao why
cute lizard
im not sure if that can work with what i need. i query database to get all uuid's " report system" i get all uuids to array, then put the uuid's into player object to puth them on an item "Paper" and loop it. since Player = online it only shows online players tickets would like to get all tickets online and offline ``` for (Player value : convert(list)) {
PreparedStatement statement = DatabaseSetup.getConnection()
.prepareStatement("SELECT * FROM " + DatabaseSetup.Reporttable + " WHERE UUID=?");
statement.setString(1, value.getUniqueId().toString());
ResultSet rst = statement.executeQuery();
if (rst.next()) {
String report = rst.getString("REPORT");
String reporter = rst.getString("REPORTING");
Player reportingP = Gat.plugin.getServer().getPlayer(reporter);
ItemStack ticket = new ItemStack(Material.PAPER, 1);
ItemMeta meta = ticket.getItemMeta();
assert meta != null;
meta.setDisplayName(value.getName());
ArrayList<String> lore = new ArrayList<>();
assert reportingP != null;
lore.add(ChatColor.DARK_AQUA + "Submitted by: " + ChatColor.AQUA + reportingP.getName());
lore.add(ChatColor.DARK_AQUA + "Reported: " + ChatColor.AQUA + value.getName());
lore.add(ChatColor.DARK_AQUA + "Reason: " + ChatColor.AQUA + report);
meta.setLore(lore);
ticket.setItemMeta(meta);
inventory.addItem(ticket);
}
}
}
}```
"Value" is the array list with online and offline players
If you are getting the UUID as a String, no that will not work. You have to convert it to a UUID first
UUID.fromString(String)
and you should Gat.plugin.getServer().getOfflinePlayer(UUID.fromString(reporter))
dang i totally missed that, got lost on my own code actually xd
just note that an OfflinePlayer will never be null.
If they are not truly a player they will have a null name
yea ive noticed that a while back thanks !
share main class ?
k
https://paste.md-5.net/sanahayuqe.java I made this in like 5 minutes
so dont judge me
o
?paste
https://paste.md-5.net/oqaviposur.java
When in the hashmap after /ds create, on message event doesnt work
uh
the problem is fixed but for some reason it does not do it
Hey guys, getting net.md_5.bungee.util.QuietException: Unexpected packet received during server login process! 0d0100 Anyone got an idea? Trying to work with JoinGame packet on bungeecord
debug. ad sysout in your code to see where its failing.
ok
lastly if you are in teh BlockFormEvent and you are setting a type you have to cancel teh event
if you don;t cancel the event your changes will be overwritten
o
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
pog
now time to make it in minecraft
it gets stuck at
if(event.getBlock().getType() == Material.COBBLESTONE) { doe sum reason
Am I missing smth?
what's the event?
@EventHandler
public void generation(BlockFormEvent event){
it does not give errors
it just does not go thru the if statement
even when its cobblestone
Use BlockSpreadEvent to catch blocks that actually spread and don't just "randomly" form.
sysout the type
ight
You made cobblestone spread correct?
also sysout in the top of the event to be certain you are in the correct event.
?
im just trying to check if the cobblestone is generated by water contact
ah I see now
oh uh
it seems like type is lava?
how can I check if its cobblestone
so like the voidgenerator plugin?
its not always going to be lava
it is
[18:09:31 INFO]: LAVA
[18:10:00 INFO]: Event triggered
[18:10:00 INFO]: LAVA
[18:11:04 INFO]: Event triggered
[18:11:04 INFO]: LAVA
[18:11:05 INFO]: Event triggered
[18:11:05 INFO]: LAVA
[18:11:07 INFO]: Event triggered
[18:11:07 INFO]: LAVA
[18:11:08 INFO]: Event triggered
[18:11:08 INFO]: LAVA
[18:11:10 INFO]: Event triggered
[18:11:10 INFO]: LAVA``` tried sum
How can you replicate a piece of armour breaking through code? As far as I can tell, setting the damage/durability to 0 or lower doesn't actually break it (also to cause the sound of it breaking)
no like uh when a cobblestone generator generates a cobblestone
delete it and play break sound effect
ah, no easier way?
its not rly hard
it's only like 2 lines but ig what you mean it seems wrong
So uh how can I check if the generated block is cobbleston
Are you actually creating any cobblestone?
im using a cobblestone generator for this
then check getNewState instead of getBlock
oh lol
now since its cancelled it always generates 1 type
Best free sevrer hosting
that would be your random method failing
this is what I have ```java
public boolean getChance(int minimalChance) {
Random random = new Random();
return random.nextInt(999) + 1 >= minimalChance;
}
}
so 1-1000
yeah
what minimal chance are you passing?
1, 5, 30, 100, 500
so yoru first call is getChance(1). That has a 999 chance of being greater
yes
it going to pass almost every time
so every time its called you are going to replace it with a diamond ore
Yeah but I dont want that
you actually want it reversed? so 1 in 1000 chance to spawn diamond ore?
Yeah
then reverse your >= to <=
o ok
you shoudl also have it fall through and make cobble as it is possible for all of yoru tests to fail
I do
I only cancel it if the test is met
ok
how do I get the display name or somenoe?
if (cmd.getName().equalsIgnoreCase("afk")) {
Bukkit.broadcast(p.getDisplayName() + "is AFK!")
}
ah wait nvm
can someone familiar with java abstraction tell me if I got the implementation of this abstraction correctly? just at a conceptual level, don't worry too much about the literal logic of the code
https://paste.md-5.net/keqotofuga.java
does anyone have any idea why when I send a playerinfopacket with inside an entity with a skin to a target player if the target is still joining it spawns the npc without rendering the skin?
Does your MajorPower implement listener?
oh you sub classed
Is this thing this.getConfig().options().copyDefaults(true); gonna force the config to have the default value?
yep
though I was rereading it and I might be able to get away with implementing the listener as a subclass of the abstracted class instead
i wanna log what armor a player is wearing in a config
@glossy scroll
i’m not sure. I dont do a lot of stuff with player skins. Probably best to look at other code
thanks anyway
does anyone know how to write textures for skulls and use those skulls ?
I have a method that transform the texture to skull
public static ItemStack createSkull(String texture, String displayName, String... loreArray) {
{
ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
if (url.isEmpty()) {
return head;
}
SkullMeta headMeta = (SkullMeta) head.getItemMeta();
headMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
List<String> loreList = new ArrayList<>();
for (String lore : loreArray) {
loreList.add(ChatColor.translateAlternateColorCodes('&', lore));
}
headMeta.setLore(loreList);
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", url));
try {
Field profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, profile);
} catch (IllegalArgumentException | NoSuchFieldException | SecurityException
| IllegalAccessException ignored) {
}
head.setItemMeta(headMeta);
return head;
}
}
@quaint mantle ^^
ty, but that's not wat I exactly wanted, I wanted to create a code that write's textures
Any minecraft reach presents plugin for server
so you want to get textures from the skull?
get a texture from a skull and edit that texture
the reflection sent kinda tells u how you'd do that
let me do the method to how to get them
you want the idea?
yes?
How I can translate spigot slots to NMS slots?
what how will reflection tell me how to do that
instead of Field#set use Field#get and cast
tbh I thought u knew wat algorithm they are using to write the texture (I assume hashing but I m dumb)
wdym ?
How I can set Item in inventory use this numbers slots?
oh recar the base 64?
isn't it just PlayerInventory ?
lol its fine recar 🙂
but how I use playerInventory.getItem or setItem
minecraft use this slots ;/
but I have slots with nms
and Idk how convert this
intresting idea but I think isn't perfect metod
I have slots with read packet
Just do what i said, there is no better option.
Roflmao
I think there is a method for that in spigot
No one’s hindering you from using it if one exists
tfw you turn down someone's suggestion because you don't think it's good but you can't think of anything better
I think I will use it although I would prefer something NMS
hy ray
not everyday i hear "prefer nms" 😄
have fun
wait till he's been programming a while and a few versions are relased.
Lmao
if it's possible api can do it
api is always
a better solution than nms
He wants to use nms or spigot it’s immensely unclear
nms just complicates everything more
and along with that this server iirc won't provide a lot of nms support but idk
how can I make varuables that carry over restart
Ik I can make a yaml but dunno how to do it
do you mean a restart or a reload?
restart
how
uh I do not know what PDC mean and I sure dont have a db
a value so ppl can toggle autopickup
a boolean for every player
or just a arraylist ig
then store it in teh players PDC. It saves with the player
idk how to use it
Not rly I just started
get that all written and working, then ask about storing a boolean in the PDC
Ok
Why is the DisplayName not set?
player.setDisplayName(ChatColour.RED+player.getName());
what makes you think its not set?
is white
what plugin are you using to modify chat?
my plugins : Plugins (17): ArmorStandEditor*, ArmorStandTools, BKCommonLib, Citizens, Essentials, (WorldEdit)FastAsyncWorldEdit, HeadDatabase*, HolographicDisplays, LagMonitor, LuckPerms, Multiverse-Core, PacketWrapper*, PlaceholderAPI, PlugMan, ProtocolLib, Vault, WorldGuard
Nothing that affects chat
I mean the player name above the head is just white
thats not affected by setDisplayName
What then changes the head name
Is there a thing to give the blocks mined form
like if its stone and the player does not have silk touch
Via code or plugin
with code
How do you execute a command when you click a player with a material
player interact event?
oh
Is there a thing to give the blocks mined form
like if its stone and the player does not have silk touch
i was gonna type a solution but elgar got this 😎
someone can help me with skript ?
where did elgar go 😭
what help ya need just ask
You use the Scoreboard system
ok
if block is stone:
give 10 tokens to player
on mine:
if block is coal ore:
give 10 tokens to player
```bye the first one it only works on cobblestone and not on stone and the second one doesnt work at all i dont get the toekns
You handle that yourself. you see what block was broken then get the ItemStack to give to the player.
right
?
if player hold pickaxe with silktouch ?
``on mine:
if block is stone
give 10 tokens to player
on mine:
if block is coal ore:
give 10 tokens to player
whoops
if block is stone
if player hold a diamondpickaxe with silktouch
give 10 tokens to player
on mine:
if block is coal ore:
give 10 tokens to player
``` like that
Check the item that was used and check its Enchants for SILK_TOUCH
...
Skript ahahah
i was just thinking abt this lol
I'm not touching Skript with JanTucks