#help-development
1 messages · Page 1610 of 1
i read all w3school thing about java
its not enough apparently
they didnt even have constructors did they
1s imma check
Well you always keep learning
well i hope i can learn the basic stuff at once so i dont get screamed at here everyday for not knowing java
https://0bin.net/paste/FhdkRJt5#mchwLCG+ytgoggNSR9QlwXuN05g7Y7dp8VbjhTRlj4a
LOG:
[20:24:42 INFO]: Checked if the sender is a commandblock
[20:24:42 INFO]: checked if the command is /attractie
[20:24:42 INFO]: whatever line 25 does
It seems like it stops at line 27.
the temp at level 27 is greyed out. dont know if that could be it, idk it is since its just a translator.
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
I have a Discord bot running on Bungeecord but I want to listen for the player entering certain areas on one of the servers. I know there's a way for Bungeecord to send messages to Spigot and recieve feedback, but I don't want to spam requests asking for each players' location constantly. Is it possible for Spigot to instead send Bungeecord a message and I can use a PlayerMoveEvent to do all the processing on that side before messaging Bungeecord? Or can Bungeecord intercept the packets to find the player's location from them? All I can think of is using a file or database that Bungeecord listens to which Spigot writes to whenever it needs to send a message but that sounds messy
Yeah look up plugin messaging channels
I was looking at a few pages on that but as far as I can tell, it's only one-way
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
https://0bin.net/paste/FhdkRJt5#mchwLCG+ytgoggNSR9QlwXuN05g7Y7dp8VbjhTRlj4a
LOG:
[20:24:42 INFO]: Checked if the sender is a commandblock
[20:24:42 INFO]: checked if the command is /attractie
[20:24:42 INFO]: whatever line 25 does
It seems like it stops at line 27.
the temp at level 27 is greyed out. dont know if that could be it, idk it is since its just a translator.
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
Whats in your command block
/attractie argument1 argument2
It depends since their all over the theme park.
Are you supplying all the arguments in the command block? You need 6 of them.
No, some only use the first 3 some only the first 4 etc
You have to supply 6, you're not checking for the argument length.
It works like this : /attraction warpname attractionname.
Or replace "args[1] + args[2] + args[3] + args[4] +args[5]" in the TextComponent with temp
Considering you're not even using temp. I imagine that's what it's supposed to be for.
Ah okay. It was first supposed to be used for a broadcasts message since I based it off a broadcast plug-in tutorial. But I can try that!
i added the method but when trying to call it I get this error:
Cannot make a static reference to the non-static method teleportBypassed(Player, Location) from the type CommandTuto
with the code
CommandTuto.teleportBypassed(player, one)
so i tried doing
new CommandTuto().teleportBypassed(player, one);
outputs no error but doesnt't work in game
I recommend learning some Java basics before starting with Spigot
Inventory#addItem adds the item to the first empty slot that it finds?
javascript has nothing to do with java
borat
InventoryDragEvent responds when clicking items in an inventory too?
only when you place down an item into a slot
oh ok
This is probably a really basic question but which library would you guys recommend for JSON storage? I tried Jackson but found I couldn't save an ArrayList of my User objects despite following multiple examples to the dot. I've tried GSON before but had troubles with it, although that might just be because I was unexperienced at the time. Any recommendations?
you can use Gson
oh
well still, its really easy
i can help
np
https://gyazo.com/0a4d718bb96a19cd70120169aa56e56c
why is this not working to create a new player in the playerdata.yml file
Moshi
Simplejson 
public float y = 0;
public void update() {
Bukkit.broadcastMessage("value :" + y);
}```
the value return me 0.0;
```java
GunManagement.recoil.values().removeIf(value -> value.y < 0);
}
}``` but is removing if is 0 why ?
Cuz that floating point might have lost some precision
use double
i need float..
why?
nms
you can cast it back to float

@EventHandler
public void click(PlayerInteractEvent e) {
Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, () -> {
ResultSet resultSet = //SQL QUERY
if (resultSet.next()) {
//do something
e.setCancelled(true);
}
});
}```
as e.setCancel (true) is in runTaskAsynchronously not working
how I can fix this
running db queries on the interact event 
setCancelled doesn't work because the event is already over
you are scheduling a task
the task will run later
the task will be run sometime in the future, and the event, by that time, will have already finished
yea this I know but idk how fix this
by not trying to do db queries in the interact event
but maybe you have idea how I can fix this
That's how you fix it, don't query inside the interact event.
so i get a clicked item in a inventory
and i want to replace it
do i need to #setItem(item-slot,replacement-Item) ?
Yup
and do i need to update the inventory or something?
im a bad dev, im not sure exactly what the problem is, but im trying to launch players, and my code isnt working
ive checked around a few areas, and it shows the same thing
@EventHandler
public void OnBlockBreak(BlockBreakEvent event) {
int min = 1;
int max = 5;
Player player = event.getPlayer();
World world = player.getWorld();
Location location = player.getLocation();
location.add(0, 1, 0);
player.teleport(location);
player.setVelocity(new Vector((int) Math.floor(Math.random() * (max - min + 1) + min), (int) Math.floor(Math.random() * (max - min + 1) + min), (int) Math.floor(Math.random() * (max - min + 1) + min)));
}
any errors?
nope
just doesnt send the player anywhere
trying to make it launch a player when they break something as a challenge for me and my friends
does it teleport them?
nope
Is the listener registered
thats what i tried adding, in case they needed previous velocity in order to change it
yep
try doing player.teleport(location.add(0, 1, 0));
theres one more thing ill try in a bit, if you have any ideas though, id like to try them first
i forget whether location is mutable
ill try
oh nvm
What does DragonBattle#respawnCrystals do?
Hey there! I need some help with an error. I am working on a furniture system using itemframes to hold an items and optionally armorstands for seats.
This worked pretty well until I refactored by code, and I don't understand why it broke
This is my error
It only occurs when I place a furniture with a seat (so with an itemframe AND an armorstand)
Is there a way to "auto complete" a command for player from an event? (ex: interaction event types for the player a predefined text in the chat ready for him to press enter to send it)?
What event is fired when you punch an ender crystal?
I have a Discord bot running on Bungeecord but I want to listen for the player entering certain areas on one of the servers. I know there's a way for Bungeecord to send messages to Spigot and recieve feedback, but I don't want to spam requests asking for each players' location constantly. Is it possible for Spigot to instead send Bungeecord a message and I can use a PlayerMoveEvent to do all the processing on that side before messaging Bungeecord? Or can Bungeecord intercept the packets to find the player's location from them? All I can think of is using a file or database that Bungeecord listens to which Spigot writes to whenever it needs to send a message but that sounds messy
both having the server push updates to bungee and having bungee intercept the move packets are possible
but the former is probably the easier to implement
Ah awesome! I have no idea how intercepting packets is done in Bungee or how to work with them, though, so do you know of a good tutorial or wiki page for this?
i'd go with the pushing updates from the backend to the proxy rather than doing that
Oh wait former not latter, sorry I misunderstood
there are bukkit tutorials for sending the plugin messages i'm sure
Someone on another server just found me a good thread about it so I think I understand how to do that now. Thanks!
anyone know how to kill all entities that are dropped on the ground through a plugin?
like the way /e kill@e[type=item] does
why do you want to do that
you aren't making another bootleg clearlag are you
borat send me a spgiot sql tutorial
easy one
implying one exists
dumbified one
i don't know any tbh
ping elgar and ask him to spoonfeed you
o:
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Gotta love how all the examples are sync
what does it mean when my resting heart rate is 200
thats why im not using that tutorial
i dont trust
ehmmmm
that doesn't seem healthy
it means that u are in serious trouble
call 911 now
lul
it uses a connection pool and prepared statements
it looks 'fine' at a glance
and does mention that you probably want to do the queries asynchronously
That wiki is actually decent
And it also redirects to some async shit if you want that iirc
no i made a stupid minigame for me and my friends, and i give them items when they respawn, and the items eventually start piling up and lagging
im not getting clearlagg lol
i feel bad for doing this, i just want to know what would make this not so laggy
lol
@EventHandler
public void onHit(EntityDamageEvent event) {
int min1 = 1;
int max1 = 5;
Player player1 = (Player) event.getEntity();
Location location = player1.getLocation();
location.add(0, 1, 0);
player1.teleport(location);
player1.setVelocity(new Vector((int) Math.floor(Math.random() * (max1 - min1 + 1) + min1), (int) Math.floor(Math.random() * (max1 - min1 + 1) + min1), (int) Math.floor(Math.random() * (max1 - min1 + 1) + min1)));
}
}
I've gotten all the way to the point where I need to deserialize it. Serializing it works just fine but deserialization is kicking my butt lol
For some reason when I'm deserializing this ArrayList of my sign objects, it's erroring saying com.google.gson.JsonSyntaxException: duplicate key: null despite my json being seemingly perfectly fine:
[
{
"uuid": "f5ee70fb-aeec-41d6-8cf2-219f51d1bbc7",
"lines": {
"jp": [ "", "", "", "" ],
"en": [ "", "1", "", "" ],
"de": [ "", "", "", "" ],
"es": [ "", "2", "", "" ]
},
"loc": {
"world": "a491aaa7-6aff-42e4-856f-7c67b1343ce6",
"x": 100016.0,
"y": 5.0,
"z": 99992.0,
"yaw": 0.0,
"pitch": 0.0
}
}
]
This json was made by gson.toJson() so I'm not sure why it's having trouble reading it. I don't think it's anything to do with my deserializer because even if I change it still has the same error.
The thing is too that it says the error is on the line ArrayList<LangSign> signs = gson.fromJson(reader, new TypeToken<ArrayList<LangSign>>(){}.getType()); and not in any of my deserializers
I tried connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc)); which I found on the forums, but it removes the skins
Put it in the wrong function 🤦♂️
Oop
And it still shows them in tab
I fixed the issue, seems I had changed the way it was serialized and forgot to update the file and for some reason it was saying that, not sure why but it works now so
One question I do have is why I need to specify a deserializer for my class but not a serializer.
GSON serialized my class just fine without a serializer but when I wanted to deserialize it it errored with a different error
gson serializes it reflectively
This is annoying
How do I remove NPCs from tab?
Everything I've found about it on the forums does something like removing the skin
Or is from 1.8 nms
anyone know why i can only use integers in playSound?
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 1, 1.5); has a red line under it in IntelliJ
not under the player.playSound doe
and the semi colon
send ss
to the person that just said something, i have you blocked so don't bother msging on this topic
(i'm floofsy btw)
isnt this the asshole who rejected everyone's help like 3 weeks ago
This is so annoying
Has anyone used NMS with NPCs before?
I'm trying to remove them from tab, but the NPCs are Steve and Alex when they're removed from tab
KEKW
This should make it clear:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#playSound(org.bukkit.Location,org.bukkit.Sound,float,float)
declaration: package: org.bukkit.entity, interface: Player
Hey does anyone know the maven repo for com.sk89q.worldedit.bukkit.selections.Selection ? I added worldedit-bukkit in my pom.xml, it fixed all import beside this one
You can just call runTaskLater with incremented time
Usually you want other approaches to distributed computing in spigot:
https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
But you can also just call runTaskLater with incrementiing time
So a tab plugin should hide them?
Really depends on the tab plugin and if its tailored for citizens.
There is a trick with packets to make them not show in the tab list. But in most cases its just easier to let them be shown for 1 tick.
^ quick note; TAB is open source so you don't have to pay for it
Thats basically it. Filling the tablist with filler profiles.
it would help the dev though
Back then i made a nice API for myself so i can dynamically change every column/row in a tab list ^^
How does Citizens do NPCs and keep them from showing up in tab if you basically can't do it with NMS?
Might be packets
There are several packets that get sent when a player joins. You can instantiate a Player entity without it being added to the tab list. This requires a separate packet.
Okay, that I can work with
Wait. Player Info has to be sent before spawn player can be sent or the client doesnt spawn the player 
Maybe a second player info packet is sent right after the first one while containing this property:
player info -> add
spawn player
player info -> remove
Not sure if the client accepts them in one tick
Wouldn't be surprised, these are the same people that decided the client should handle flight while on a server
Sorry for interrupting, but is there anything i need to use specifically to store data in spigot?
like would a .txt file be fine or should i go for a .yml file? also do I need a specific additional library for interacting with .yml files?
You got a full programming language at your disposal. Do whatever you fancy.
Write your own binary file structure. Save stuff in txt, yml, json or png 😄
Use databases like mysql or mongodb. Its all up to you.
alr tysm!
Ah btw spigot has a lot of support for yml files. So if you want to use their configuration api then its yml.
ah ok
would i need any other libraries or can i just read yml similarly to txt files wait nvm i just saw config library ill check that out
Heck how do i get an instance of WorldServer in 1.17 ? Any quick hint?
There are also lots of examples with her save, load, and other functions for making a class for your own config
Ah nvm got it.
Spawned NPCs without them showing in the tab list
private void spawnNPC(final Location location) {
final MinecraftServer minecraftServer = ((CraftServer) this.getServer()).getServer();
final WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
final GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Bob");
final EntityPlayer entityPlayer = new EntityPlayer(minecraftServer, worldServer, gameProfile);
entityPlayer.setLocation(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw());
final PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.a, entityPlayer);
final PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
final PacketPlayOutPlayerInfo playerInfoPacketHide = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.e, entityPlayer);
Bukkit.getOnlinePlayers().forEach(player -> {
final PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
connection.sendPacket(playerInfoPacket);
connection.sendPacket(spawnPacket);
connection.sendPacket(playerInfoPacketHide);
});
}
off the rip???
^^
foit me 
Yes 2 spaces. i want more code on my screen. i would be fine with 4 spaces but if you use tabs then im out.
nobody uses tabs anymore
I would really like to update my lib to 1.17 but im just not satisfied with the whole mapping approach. And writing code with the obf jar (like above) is just too much of a hustle.
All i need is ProtocolLib because i have no idea how to properly inject my own packet handler into netty. So i just wrote to the dev of plib and asked him if
he could make it run in a mapped environment XD
This way i can just run my server with the moj mapped jar and also dev with it.
Are .a and .e 1.17 things?
Yeah. Those are the ADD and REMOVE enum entries.
1.17 go brr
private final @Getter String legacyName;
private @Getter final String legacyName;

Ew
How about you annotate like everyone else?
Above the field... like a sane person
@Override
public @NotNull String getCommandForPlayers() {
@Override
@NotNull
public String getCommandForPlayers() {
With the second you would have more space for argument annotations ^^
But the first one looks good
how difficult it is to make a plugin like this one?
https://dev.curseforge.com/projects/enchantcontrol
2013, yikes
Looks like it will involve reflections
When you start Fabric with your Forge mods
But the skins
Block is an interface. Be more specific pls.
I almost just want to just make my itemshop a command then have it get run by a Citizens NPC on right click at this point
Citizens is utter trash
It would at least do what I want
You mean a block variable? Because that depends not on the class but the state. Is it final?
Then you can just redeclare the variable. Doesnt matter if its a Block or a Server or a SpaceShip variable.
You can redeclare a String or a Player variable...
You can redeclare all non final variables. Doesnt matter whats in them.
Onto things that are actually possible with what I already have, I have a config and I want to get the first key under categories in it so I can access everything in it, what should I use to do that?
itemshop:
mainsize: 27
stuff:
categories:
blocks:
stuff:
weapons:
stuff:
The path would be itemshop.categories.blocks
But if the user was able to change it?
I guess a more foolproof way to do it would to use numbers instead of names like that
Nah
Then how can I get the first thing there?
ConfigurationSection section = configuration.getConfigurationSection("itemshop.categories");
Set<String> categories = section.getKeys(false);
for (String category : categories) {
}
But I don't want look through the categories because that I want separate GUIs for every category
Wait
final ConfigurationSection section = configuration.getConfigurationSection("itemshop.categories");
final Set<String> categories = section.getKeys(false);
for (final String category : categories) {
ConfigurationSection stuffSection = section.getConfigurationSection(category + ".stuff");
}
I might be brain dead from trying to figure out the NPC tab stuff
I can't wrap my head around how that would work with separate inventories rn lol
Do you want to have one Inventory for each entry under "categories"?
So in your example: One inv "blocks" with the content being "blocks.stuff" and one inv "weapons" with the contents being "weapons.stuff"?
public Map<String, Inventory> loadInventories(final YamlConfiguration configuration) {
final Map<String, Inventory> inventoryMap = new HashMap<>();
final int inventorySize = configuration.getInt("itemshop.mainsize");
final ConfigurationSection categorySection = configuration.getConfigurationSection("itemshop.categories");
if (categorySection == null) {
return inventoryMap;
}
final Set<String> categories = categorySection.getKeys(false);
for (final String category : categories) {
final String inventoryName = categorySection.getString(category + ".name");
final List<String> content = categorySection.getStringList(category + ".stuff");
final List<Material> materials = new ArrayList<>();
for (final String entry : content) {
materials.add(Material.getMaterial(entry));
}
final Inventory inventory;
if (inventoryName == null) {
inventory = Bukkit.createInventory(null, inventorySize);
} else {
inventory = Bukkit.createInventory(null, inventorySize, inventoryName);
}
for (final Material material : materials) {
inventory.addItem(new ItemStack(material));
}
inventoryMap.put(category, inventory);
}
return inventoryMap;
}
This will load a Map<String, Inventory> out of the following structure:
itemshop:
mainsize: 27
stuff:
categories:
blocks:
name: "Block stuff"
stuff:
- STONE
- IRON_ORE
weapons:
name: "Weapon stuff"
stuff:
- DIAMOND_SWORD
- IRON_AXE
Where the key is the category.
So blocks and weapons in this example
Ohh
I'm going to finish the shop tomorrow, I'm afraid I'm going to screw something obvious up rn lol
still need help w/ this
This should make it very clear:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#playSound(org.bukkit.Location,org.bukkit.Sound,float,float)
declaration: package: org.bukkit.entity, interface: Player
it does not
there's nothing about different pitches in there, just how to use the pitch
Take a good look at the argument types
yeah so it's float
What types qualify for usage in float variables?
numbers
No
wait it's integers?
Thats one
is float just a type of integer
Nope
then it's a type of number
Yes
ok so why isn't it working
But not all numbers are the same
what do you mean
Because you are not providing a float
1.5 is a float
No
how so
That is one of the first things you learn normally...
float x = 0.15F;
double y = 0.15D;
double z = 0.15;
short a = 100;
int b = 100;
long c = 100L;
Floats are 32 bit numbers. Same goes for ints.
Doubles and Longs are 64 bit numbers.
You can put a 32 bit number in a 64 bit field but not vice versa because 64 is too big to fit into a 32 bit field.
In java if you dont append an F to your floating point number then it defaults to being a double.
i understood none of that
but what i did understand is that i have to put an F after it
Thats at least something...
Learn. Java.
be. gone.
Why do you try to code plugins without basic Java knowledge
simple: it's fun this way
Your never going to get anywhere without learning the basics of Java first
of course i will
Well don't waste people's time for simple Java questions if you aren't willing to learn the essentials
there are many ways of learning, i'm not gonna stop asking because you disagree with one
now if you're gonna be mean again, d o n ' t
Ok please at the very least watch a beginner tutorial video on YouTube before you continue, I am not asking you to take an entire java course but please, for your sake and everyone else's just watch a couple vidoes.
i have
I think I'll make a forums post tomorrow and see if anyone can help with the NPC in tab issue
Uhm.
With keeping skins
Just removing the NPC gets rid of the skin
Every forums post I've seen is either some obscure thing that hasn't existed since 1.8 or removing them, which doesn't work with 1.16 or something
Doesnt seem possible then. I dont see any other way...
Other than filling the tab list with placeholders
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/block/Action.html
how does this work in a condition
Its an enum so you just get the current action and check it against an entry with ==
hmm intellij bullied me for using that earlier
Maybe ProtocolLib has something
What are you trying to do Elephant?
Action action = event.getAction();
if(action == Action.LEFT_CLICK_AIR) {
event.getPlayer().sendMessage("You left clicked air.");
}
I managed to make NPCs so whatever you're doing is probably possible.
If you cant do it with normal packets then you wont be able to do it with ProtocolLib
Hiding NPC names in tab plus what smile said
Removing them from the tab list without removing their skin
getAction isn't a thing
In what event
EntityInteractEvent
i'm using action to check when an entity steps on a pressure plate
There is no action involved in this event
@shadow gazelle put PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, <npc entity>) in a runTaskLater.
Mine has it set to run 15 ticks after
my bad i was looking at the PlayerInteractEvent.
Minecraft has some arbitrary rule where they have to be in tab for a little before you can remove them
So the client caches the GameProfile after N ticks?
Ohhh
is there any way i can check if an entity steps on a certain block or pressure plate
The brains of Mojang devs
It just has something to do with how Player entities work
Sure. EntityInteractEvent#getBlock()
They HAVE to be in tab when they're spawned, that's why even on Hypixel you can see them in tab for a second before they're removed.
If you remove it immediately everything goes wrong 😂
I tried like two seconds and it still yeeted their skins
I just removed them and thought it was fine.
Hm, mine is on 1.16.4 so something could've changed in 1.17 I suppose
But i usually fill my tab list with entries so they are never visible anyways
How are you spawning it
Just made a quick mock up for elephant earlier.
private void spawnNPC(final Location location) {
final MinecraftServer minecraftServer = ((CraftServer) this.getServer()).getServer();
final WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();
final GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Bob");
final EntityPlayer entityPlayer = new EntityPlayer(minecraftServer, worldServer, gameProfile);
entityPlayer.setLocation(location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw());
final PacketPlayOutPlayerInfo playerInfoPacket = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.a, entityPlayer);
final PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
final PacketPlayOutPlayerInfo playerInfoPacketHide = new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.e, entityPlayer);
Bukkit.getOnlinePlayers().forEach(player -> {
final PlayerConnection connection = ((CraftPlayer) player).getHandle().b;
connection.sendPacket(playerInfoPacket);
connection.sendPacket(spawnPacket);
connection.sendPacket(playerInfoPacketHide); // Ill try delaying this
});
}
That's pretty much what I had
You're not even setting the skin 🤔
I request the skin properties from Mojang and apply them to the GameProfile
Me too
And when the server stops/starts they're pulled from a yml
then loadNPC runs and set the skin and whatever
then sends packets with another function
How are you setting the skin
Wait does the skin work if you don't remove them from tab
It does work
It pulls the texture and signature from Mojang then loadNPC/createNPC gets it and sets it in the GameProfile properties
Yeah if it works before you remove them from tab that should be fine
Lemme convert mine to 1.17 and see if it still works
I'm using 1.16
It was right after the NPC packets were and it was spawned
I gtg, I'll tell you if it works or not tmr
Okay.
Also not sure if this makes much a difference, but I spawn the entity & then send the playerInfoPacket
I actually listen for PacketPlayOutNamedEntitySpawn, check if the ID is an NPC, and then send the InfoPackets
I listen for the spawn packet because if you leave the range of the NPC, and it despawns, you have to manually re-spawn it when they're close enough
So I just let the server manage that for me and then do the tab stuff whenever the client gets sent an NPC
Yeah it's just some weird quirk with Player entities ¯_(ツ)_/¯
Wont happen to me because i usually just fill the tab list with profiles and mirror real players in when they join.
Well yeah that's one way to do it I guess LOL
Ofc i wont name them "index x" but have some icons etc in there XD
Those textures are cool
Thx 😄
:D
Also gonna ping @shadow gazelle for this so you can see it when you come back, delay should fix your issue.
You can actually do some really cool stuff when you are able to generate the resourcepack with a plugin and hook into that
:/
Doesn't Bedrock just natively support custom models and such?
Idk but it has quite a bit of data driven models. Especially custom textured entities.
Not sure, all I know is that when you go onto a Bedrock server they do things Java couldn't even dream of
All i want is:
Adding custom mob models
Adding more blocks
Adding new gui schemes
Then we'll be able to do everything that forge does.
Yeah adding Items/Blocks with custom Textues and Models would be absolutely amazing
Well, without the help of a resource pack I mean
Being able to send the client all the information about a custom item
Just send it to them when they connect
But thats basically what resourcepacks do...
Then just switch to Fabric or Forge
You can force a user to accept a resourcepack
Just wish it was more seamless
Yeah
The loading screen for resource packs is so intrusive
its cause there are like 5 year old kids prolly and mojang doesnt want any sketchy stuff
that they want to see
but yea i personally dislike how you have to go through the menu and options too
its a hassle
Don't you have to accept the resource pack like everytime too
even like sending custom sounds is a pain in the ass
no
you can set it to auto
Yeah but the user has to do that
well yea
Such a pain
ofc
Those occupy most of the resourcepacks size...
And isn't it per-server?
Yeah its crazy
are OGG's more compressed than mp3?
texture and sound streaming would be nice to have
in terms of storage
If you set it on one server it'll be set the same for any new servers you add after that iirc
Ah
You can make them pretty small. But the quality sometimes suffers too much.
yeah
Or another stupid thing Mojang did
They do seem to be good at that
OGG provides super well tho actually with low kilobits per second
in fact the quality actually seems to better than mp3 for lower kilobits
Still feels like a lot
@lost matrix are you just manually setting IntelliJ as an activity in Discord activity settings?
Updated it
There you go

Hey, if i wanted to do something like minehut what would be the best way to store server data?
Docker
With file system mounts
Wait minehut is this thing where you can just get a server for free right?
Yeah you can get a server for free and pay to upgrade it
Ah. They probably use some sort of container framework
What plugin channel should I use for sending messages from Spigot/Paper/Tuinity to BungeeCord/Waterfall? When Googing, I see several places saying you have to use "Bungeecord", others saying "Bungeecord:main", others saying "bungeecord:main" and others saying to use a custom one, and I don't really understand what it means ngl. I tried a custom one but got an error saying it must contain a colon so not sure if I just put ":main" after that too, or if I go with the Bungeecord one, or if there's a different one I need to use if using a fork of Bungeecord or something
For custom channels you use namespace:key
Something like "my:channel" should be enough.
So it doesn't really matter, as long as there's a colon?
God damn it it's gotta be lowercase too lol
Ok, you have to register it too, but I can only find how to register it for BungeeCord and listening on Spigot for some reason. How do I register a channel to send on with the Spigot end?
hey im bad at math im sorry for asking this
how do i check if a number would be divisible by 10
im overthinking it
im just trying to check to see when i can actually give the player some money when they level up exp
okay
thank you
sorry
i thought it was something like that, to make sure it equaled 0
LOL
idk
i just overthink math a ton
How would I get all the chunks between 2 locations (basically like inside a region)
the chunks?
i know how to see if blocks are within certain points
idk about chunks but i can send you the boolean for stuff
the boolean i use atleast, that works
i need all of the chunks that are inside of the of the area
ahhh
as i then need to go through them to look for certain types of blocks (As ChunkSnapshots so i can run it async)
I've got my code to not give errors but the proxy doesn't seem to be receiving Spigot's messages. My proxy is receiving messages intended for other plugins but I'm printing the tag and definitely none of them are the ones my plugin is sending. Here's the code for the plugin installed on the Spigot server. Any ideas why it's not working? https://paste.helpch.at/ruwabihedo.java
- Get minimum x,z coords and bitshift each one by 4 to the right to get the minimum chunk coordinates
- Do the same for the maximum x,z
- Nested for loop to iterate over each chunk and add it to a 2D array of size chunkXMax-chunkXMin,chunkZMax-chunkZMin
so i think i get steps 1 & 2
it would look smth like this
int minX = minLoc.getBlockX() >> 4;
int maxX = maxLoc.getBlockX() >> 4;
int minZ = minLoc.getBlockZ() >> 4;
int maxZ = minLoc.getBlockZ() >> 4;
wt would the loop look like
i get the idea of it for going through locations (like each block in an area) but not a full chunk
Bitshift by 4 is the same as dividing by 16. It is unecessary optimization and doesn't help much
would it be like
for (int x = minX; x < maxX; x++) {
for (int z = minZ; x < maxZ; z++) {
// i have a chunk
}
}
Yes
right yeah i think that makes sense
Also z++ on the second line
No worries
Nope, dividing produces incorrect results for negative numbers
It rounds towards zero
Whereas bitshifting truncates
It's dumb but yea
Yup looks right
Then array[x-minX][z-minZ] = getChunkSnapshot(x,z);
He might not be doing a world generator
Actually the loop is not right, it should be <=
ah right, just added that
?
The array is just to efficiently store and access the chunk snapshots
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
ChunkSnapshot snapshot = i.getWorld().getChunkAt(x, z).getChunkSnapshot();
}
}
thats what im doing
i dont need to store them
just need to process them then move on
tysm for all the help btw
sure thing :)
Ah cool
which is why im getting the chunksnapshots
Yea that's good
yea thought that would b the best way
I think using streams would make it faster than a normal loop over each block
Since they can easily do it parallel
hmm yeah possibly. i dont have much experience w/ streams so what would that kinda look like
It's really simple
oh oof- i really need to look into them
Though the ChunkSnapshot doesn't seem to give you access to the full array of blocks hmm
It's probably possible to use streams anyway to call getBlockType(x,y,z) in parallel
Streams are parallel automatically
No?
You just need to make sort of a converter so that the stream knows how to iterate (or ig spliterate?) over a chunk snapshot
Thought they are
Only parallel streams are parallel
Oh and streams are slightly slower but make for cleaner code
Doesn't java figure it out by itself
Like if I do someArray.stream().xyz() it would do it in parallel
No that will be done sync
How would I do it parallel then
It will do things parallel if you tell it to be a parallel stream
ik .forEach() is done in parallel since it causes errors if you're not careful
So I thought same would be for .stream()
@ionic reef regarding how to make a stream from a ChunkSnapshot, this thread might be helpful https://stackoverflow.com/questions/63377723/create-a-stream-that-is-based-on-a-custom-generator-iterator-method
As for parallel streams Olivo knows better
It's not. I assume you're talking about an ConcurrentModification error which is caused by the stream reading the same data you're writing to
Nah I had problems with something like someList.forEach(someHashSet::put)
For more info about streams read https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html
Ofc that's kind of a useless example but the point is the stream didn't read from the place it writes
So .forEach didnt work where a normal for loop did
Doesn't that imply it is parallel
At least in modern versions of java
The .forEach uses the collections Iterator to simply go through all values
Then it should be equivalent to a for loop and not cause errors where a for loop doesn't
But, at least in Java 16, that wasn't the case
also another question, for when im looping through the x, y & z (am going to do that just for now until i have time to properly learn how to use strings). Should I be doing x << 4 to convert it back to a normal coordinate which I can then input into snapshot.getBlockData(x,y,z);
Nah not quite, you lose those bits. Plus I think you need it in local space so you gotta bitmask it
x & 0b1111
Though actually nah
In your case you don't need to bit mask cause you're not gonna be using the same coords
Your x and z variables are chunk coords
You need another triple loop for local coords
Still not solved this if anybody has any ideas
right, how would i get the local coords
as rn i dont think i have any clear way of getting them for the specific chunk
They're just in range 0-15 or, for Y, 0-255 (keep the Y min/max as a variable since world height can be higher in 1.17+)
But there is a problem
Since you want to only loop the blocks between your 2 corners
It's easier to handle if you store the snapshots in an array
Show your code on the bungee
Hmm right, how would I store them
Then after generating the array you exit the double loop for chunks and start a triple loop for x,y,z between your global min/max corners.
use a 2D array
new ChunkSnapshot[maxChunkX-minChunkX][maxChunkZ-minChunkZ];
Oh i think I see where you’re heading with this, 0 idea how I’d execute it but I think I get the idea
If you scroll up I gave the code to store the snapshots in the array
So like, with all the snapshots in a list, you then loop through all of the local cords, between the min and max variables from much earlier, get the corresponding chunk snapshot and then I have the x y &z to check it?
Nah they wouldn't be in a list
. This is the storing right?
Yes
oh right yeah array
Sorry, it's just this https://paste.helpch.at/itijizalip.cs. Pretty much only the first 3 lines are important for now. This event gets called often but the tag shows it's from other plugins
So when you go through the block coordinates you can just bitshift the x,z and subtract the minimum chunk coordinate to get the position in the array that the chunk snapshot is in
e.g. if your minimum chunk X is 100 and the block's coordinate is 1624 then your chunk snapshot's x index will be 101-100 = 1
So it's at array[1][?]
And then the local coordinate is x & 0b1111
Which would be 8
That is extremely over my head Rn xD
whats the topic
If it’s not too much to ask could you write out some code/pseudo code with comments or smth
Counting blocks in a volume
I'm on phone rn but I'll try
So you know how to populate the chunk array?
I don’t want to get spoon fed code but I think if I have some finished code/semi-finished code I can try to understand it
Storing the ChunkSnapshots
Kinda, but not really
You could do it without
But it's easier and more readable and pretty much just as efficient to store in an array and then count blocks
for what do you want to safe the ChunkSnapshot? to keep it in cache?
So we can do the block coordinate loop outside of the chunk loop
You could get the chunk and count all the blocks but it's more complicated to figure out the start and x local coords
Say if your volume starts halfway through a chunk
And intersects 3*3 chunks
It's easier if you do the block loop after getting all chunks rather than figuring out where in a chunk to start and end at
Since you can do:
- Loop through chunk coordinates and populate snapshot array
- Loop through all coordinates in the volume and count blocks using the snapshots
And where are you registering the channel
Rather than
Loop through chunk coordinates
--Get appropriate snapshot
--Figure out where the volume starts/ends in the chunk's local coordinates
--Loop through all coordinates in said sub-volume
I tried getProxy().registerChannel("stockblockjda.node"); in the onEnable() but it made no difference. afaik you only have to register the channel in Bungee if you're sending to that channel, not for listening to it, both because I can't find any method for registering a channel to listen to and because I'm receiving plugin messages from other plugins despite no registering them so why would I need to register my own
Make sure that's not a . in the actual code
Oh sorry I meant a colon, I typed it manually on Discord
I used a colon in my actual code
@ionic reef pseudocode is:
figure out min/max chunk coords
declare chunk array of size [maxChunkX-minChunkX+1][maxChunkZ-minChunkZ+1]
//chunks loop (double for loop)
for each chunk coordinate between min and max X/Z inclusive:
chunks[chunkX-minX][chunkZ-minZ] = getChunkSnapshot();
//blocks loop (triple for loop)
for each block coordinate in your volume:
chunkX = x >> 4
chunkZ = z >> 4
localX = x & 0b1111
localZ = z & 0b1111
blockType = chunks[chunkX-minX][chunkZ-minZ].getBlockType(localX, y, localZ)
//do your counting logic here
Hmm right
Let me know if you don't understand parts of it
The first bit I don’t quite understand (defining array & size of it and also what the chunkX-minX (& z) are
But everything after the // triple for loop i think understand
So yeah pretty much all of the first part I dont quite get (sorry!) but everything after the // triple loop I think I’m good with
Well the reason for the array size is that if you have chunks between x=100 and x=103, your array would only need to be big enough to fit chunk 100,101,102 and 103. I actually made a mistake in the pseudocode, the size for both dimensions should be 1 more than max-min
so chunks[0] corresponds to chunk x=100 and chunks[3] corresponds to chunk x=103
I fixed the pseudocode now
Then the reason you do chunks[chunkX-minX] is because at the first chunk (chunkX=100) you would be doing chunks[100-100] = chunks[0]
And at the last chunk (chunkX=103) you'd be doing chunks[103-100] = chunks[3]
Right, and chunkX is the x variable in my for loops which gets the chunk snapshots right?
Yea
I also fixed an error in the bottom loop
Since it also needs to account for the array being "shifted" by the minimum coordinates
Oh right ty
Idk if it makes any more sense now
That does yeah
Nice :D
Am still a tincy bit confused on actually making the array
As I looked up 2D arrays and it seemed a bit odd
Have you used arrays before
Arrays yeah, not 2D tho
If an array is like a list of things then a 2d array is a grid of things
To make it you just do the same thing as a 1D array but add another []
Oh right that makes sense
So for a 3x4 array you'd do ChunkSnapshot[][] chunks = new ChunkSnapshot[3][4]
Wt is the maxChunkX variable tho, is that the bit-shifted boundingBox.getMaxLocation().getBlockX() that I did earlier
Yep
Give it a go
U cool if I friend you in case I have any issues tomorrow?
Yea sure
Awesome, tysm man, I’ve learned a heap today haha
This kinda thing it outside of the usual plugins I make
Glad I could help :)
:D
How can you get EntityArmorStand object using their id?
It's a client side entity or nms.
When the entity is spawned, they will have a unique id, and I already have the ID, and I just need to get the EntityArmorStand object from the id.
Bukkit.getEntity and then cast it?
It's not uuid
What is it
int
its from nms
even if its use UUID, I can't get the entity using Bukkit.getEntity
because the server doesn't even know if the entity exist on the server
Can you store the references
Sure I can, but I want it to support multiple versions, so I can't really do that.
If it's a client side entity it doesn't persist between restarts right
Or even between the client relogging or unloading chunks
Actually that's what I'm doing right now.
Yeah it doesn't persist, and I don't need it to be persist.
anyone has ideas for a plugin
Btw I'm on train internet so apologies in advance
Where do the version problems come into play
I'm just gonna store the reference for now I guess.
What spawned the entity?
packets
Then it only exists on the client and the ID is only known to the client and the code that spawned it.
If you restart the server it has no way of reobtaining the entity
even from an ID, it simply does not exist on the server
that's not what I want to do, I don't need the entity to be persist.
InventoryCloseEvent triggers only if the player closes the inventory?
So I spawned armor stand with packets, and I got the EntityArmorStand object, and you can get the id from that, and right now I want to get the EntityArmorStand using that id.
I don;t believe you can. As you manually created the AS and spawned it for the client using packets it doesn't really exist on the server. Its just a fake object
Why do you want to reobtain it
Alright then, I'm just gonna store the reference.
To show the armor stand to the player that just joined the server.
If an entity exists on the server with a location it will be automatically spawned for the player when they come in rang of that chunk. Your Entity never actually exists on the server so can't be obtained by its ID. Its fake.
Then just keep a reference yea
You have to keep an Object reference for the AS, or recreate it after a reload
Can;t be done with just an ID as it doesn;t exist in teh server Entity list
I thought I can make it simple, you know creating 1 class for every version instead 1 class each version.
I'm just gonna keep the reference, thanks anyways.
All I had to do is copy the class and just change the import xd
Can you wear helmet client side? so it doesn't take the helmet slot, just a visual display.
How advanced
An actually good player shop plugin with a nice GUI
Nah physical
Anything you find fitting that a player can place in the world and if you right click it a (multi-page) gui showing all configured trades shows up
The owner can set up trades and stock the shop through a virtual inventory
thats used way too much except the fitting thing
thats basiscally a normal /shop plugin lol
Idk all I experienced was shitty sign shops
Though I didn't play on survival servers for a while
And occasionally an auctionhouse which generally doesn't support item trades only economy
eh
A good shop plugin imo would be:
You right click a villager and see a chest inventory with all the trades, and a sidebar for page traversal and owner options.
Owner options would be:
-Open trade configuration gui
-Open stock inventory
-Open vault inventory (where the payments go)
All inventories should be multipage to allow for easy bulk selling/buying. Optionally have different tiers of shop with different amounts of max pages to not allow for cheap and compact infinite storage
or something what doesn't exist that often
yeah thats the point
i need a good idea
how experienced are you?
just give me an idea
if it's not in my level
ill try to figure it out
doing stuff only at my level will slow me down
Hey! my method is causing big lag. here is my timing: https://timings.spigotmc.org/?url=osomudodun and here is my #1 lag code
Level::onFarm
https://pastebin.com/raw/MKerwg27
how can I solve this lag
(without removing that method)
} catch(ClassCastException exception) {} <- Dont do this
oh
toto try catch is considered among the more expensive things
But to be honest it should not cause too much lag.
What does Level.giveEXP(player, "farming", 10); do?
But also chances are you’re casting something erroneously
How to detect what direction the player is moving in Playermoveevent?
https://pastebin.com/raw/JsA8pqJP here are you go!
Oh so you’re messing with IO also?
🥲
One way would be to record their location between two different points of time and then determine the direction
Get a vector that points from the Location "from" to the location "to"
Although iirc there’s a function which says their direction or maybe it was velocity
explain
Better cache it toto, and saves on plugin disable and load on startup
😂
Maybe the velocity vector that conclure described is better.
Do you want a BlockFace or a Vector?
why do i need vector , i think i only need magnitude
So you want the distance the player has travelled over some time or no?
Magnitude of what? What are you trying to do?
magnitude of the vector that starts are the starting position and ends at the end position
Btw to your lag problem: Dont ever do IO stuff on the main thread. No writing in files and not DB access.
?xy
Asking about your attempted solution rather than your actual problem
Tell us what you are trying to do pls
err , I got 0 clue XD
trying to figure out the direction of the players movement, in relation to it's crosshair
public void initTime(ProxiedPlayer player){
long initialTimeMinutes = (System.currentTimeMillis() / 3600000);
timePlayer.put(player, initialTimeMinutes);
player.sendMessage(new TextComponent(convertSecondsToHMmSs(System.currentTimeMillis())));
player.sendMessage(new TextComponent(String.valueOf(System.currentTimeMillis())));
ScheduledTask task = plugin.getProxy().getScheduler().schedule(plugin, () -> repeatTime(player), 1, 1, TimeUnit.MINUTES);
tasks.put(player, task);
}
public void repeatTime(ProxiedPlayer player){
long timeRepeatMinutes = (System.currentTimeMillis() / 3600000);
double bd = timeRepeatMinutes - timePlayer.get(player); //timePlayer is a hashmap which contains another currentTimeMillis from a previous method
plugin.getDb().setTime(player, bd);
player.sendMessage(new TextComponent(Double.toString(bd)));
player.sendMessage(new TextComponent(String.valueOf(System.currentTimeMillis())));
timePlayer.put(player, timeRepeatMinutes);
}
How am I going to attempt it if I got no clue how to do it
You can get the velocity of a player with getVelocity() and get his crosshair direction with .getEyeLocation().getDirection()
You can then get the angle between those two vectors
Anyone knows why printing bd gives me 0.0 and not 0.016?
alr
Is looping all players ~100 players and sending them Tablist effect the performance in BungeeCord?
I mean everything in bungeecord happens more or less async
Since iirc there’s really no main thread there
Which means probably fine
160 players currently
what cpu
what is the
from Hetzner
is it exlusively for the bungeecord
No, i share 8 servers with it
lmao
wtf
?
i thought you meant that bungee was using that
8 servers is quite a few tho
eh
that seems normal
Trying to make an armor stand rides player, but it only works on the first time, when I tried to make the armor stand rides the second time on the player, it's just won't ride. I'm using nms, and the method that I use is EntityArmorStand#startRiding
WHAT IS the tzz sound effect made by the guardians called
Use velocity.
can someone explain how does the VillagerReplenishTradeEvent work?
When I tried to test and trade with villagers it prints nothing
I use FlameCord
I'm just trying to know if the cause is looping around 150 players
ok? velocity is still better
if you want to use less cpu, velocity is the way to go
hey
how do i use pitch..etc in e.getPlayer().playSound
what do iset the volume and pitch to
yep
you meant config file? and what is main thread(sorry for my small brain) and what is db access?
oh no
Some basics:
Your RAM is much much faster than your hard drive.
This means if you read/write something from/to your hard drive (a File for example), it takes a very long time.
Your code stops the entire server. As long as you dont exceed 50ms it is not noticable.
But reading a File blocks the server for a long time and produces lag.
Yes. But you should also check for air because a players hand will be an ItemStack of type AIR
nah i am making a filler for a gui
Wow... you can get a full ryzen root server with 64Gigs of ram and all 16 cores (not v) for 10€ less
really?? thats cheap
And iirc this runs on an Epyc which is less than ideal for something like minecraft.
So im pretty sure you cant run >30 - 40 concurrent users on one server with this.
60 euros monthly omg
anyone knows a way i can make a feature have charges
like an item can only be used 5 times
then u have to wait an amount of seconds for it to recharge
store the player witth the int value of used times
thanks you! so I should save to map, and when player leave save map to file right?
@summer scroll so try debuging checking the passanger of the player
with what, it's client sided entity
client side
send me your method
what is the method you remove an armor stand?
@Override
public void destroyArmorStand(Player player) {
if(!armorStandMap.containsKey(player)) return;
System.out.println("Destroying backpack for " + player.getName());
NMSBackpack nmsBackpack = armorStandMap.remove(player);
sendPacket(new PacketPlayOutEntityDestroy(nmsBackpack.getArmorStand().getId()), null);
}
packetplayoutentitydestroy does not necessarily destroy the entity, it just makes other players see the invisible entity
yes
but it's still there, it just makes it invisible to other players, so the second time you add the passenger, the entity is still mounted on you
try .killEntity
yeah it works, thanks so much
?paste
does this looks good for a homes command?
https://paste.md-5.net/ecolemenuc.cs
Looks fine
Check with Block#getBlockData instead.
if (Tag.CROPS.isTagged(block.getType()))
i want to make a random tp plugin, and since the world will be regenerated every day, i want to pre-calculate pseudo random places when starting the server, a few, 10 or 20 idk, and then generate those chunks, before a player needs it, so it takes as little as possible to tp the player
how can i do that? generate a chunk. and after generating it, what would be the most efficient way to know which is the highest block? just a for loop in y? or maybe there is a "safespawn" of "safetp" method in the spigot api giving it a region or something, something that minecraft uses maybe
Random X/Z then get highest block and test for a two block high space.
getting a block from a certain location will automatically generate that chunk?
yes
then its easier than i thought, thanks
what? where?
oh i thought you meant less than 10€ lol and i was like wut
i want to store this into the config file
Map<String, Map<String, Map<String, Double>>> stuff = new HashMap<>();
but this doesnt work
getConfig().set(stuff);
it says MemorySection cannot be applied to that thing
i want something like this
key1:
subkey1:
subsubkey1: 1.0
subsubkey2: 2.0
subsubkey3: 3.0
subkey2:
subsubkey1: 1.0
subsubkey2: 2.0
subsubkey3: 3.0
key2:
...
show the actual error
wait im stupid, i forgot to send the name of the new section to set
ups
why cant it just say 'missing argument'
Help
how do i check how many items of an itemstack does a player have in their inv
and send that int to the player
either #getAmount or if you wanna receive every stack you probably have to loop over the contents
how though
having an int
looping over the contents
verify if its exactly THAT itemstack
add the #getAmount on top of that int
hey
was wondering if its possible to make it so i can have a subdomain like pickles. insert rest here. then when i join it it takes me to a server kinda like minehut does it but like with one ip
how can i print all the entries of a file, this goes brr
What theme are you using ?
don't use § use the ChatColor enum
one dark vivid italic
So like hub.servername.net for example? And that will take you to hub
yeah and like olivo.severname.net taking you to your server
I would take a look at how the bungee does it
Oh and you will have to setup SRV records and stuff
wym look how bungee does it? Will i have to make my own fork of bungee for this?
if i use getKeys(false) will that return the homes?
ow wait i need to get all the homes below the uuid
I know this is java basics and this is not the place to ask this, but how do you put players inside hashmaps?
like "test" is a one
map.add(player)
that isnt helpful
.put(player, value)
how to create the hashmaps though
HashMap<Player, List<Player>> list = new HashMap<>();
?
wait
HashMap<Player, Player> list = new HashMap<>();
list.put(e.getPlayer(), e.getPlayer());
is this fine
ik it shouldnt be namedl ist
list
just ignore the name
just use .put(key, value) where value is a list
yeah
is this a reply to what i asked
Map<UUID, Set<UUID>> playerMap = new HashMap<>();
hey but how can i get the second level of a configurationsection?
use this ^^
okay
but
how do i put
the player
playerMap.put(player.getUUID, new HashSet<>));
thanks
Is there a way i can access the player in the hashmap from another class / method
make getters / setters
okay
can i get a block and read it (not modify it) and generate that chunk from another thread?
are u sure? i saw people saying that as long as you dont modify the world, there is no problem with using threads
aaa
but i dont want it to get corrupted or something, but idk if minecraft generates the chunk in the main thread anyway, or it would be generated in the new thread or something, idk
im confusion
anyone knows how do i pass a player object from a method to another method
?learnjava
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.
how do you get the items dropped with the BlockBreakEvent
it wont corrupt it will just error
do you mean like this:
public void method1(Player player) {
method2(player)
}
public void method2(Player player){
player.kill()
}
yeah kinda of
event.getBlock().getDrops()
tysm
but that would just throw an error
right
why would that throw an error?
will this remove all lines from the homes?
private void removeHome(Player p, String name) {
if (hasHome(p, name)) {
for (String s : homesFile.getConfigurationSection("homes." + p.getUniqueId() + "." + name).getKeys(true)) {
homesFile.set(s, null);
Utils.message(p, "§aRemoved " + name);
}
} else {
Utils.message(p, new String[] {"§cHome not found!", "§cYou can use /home list to see all your homes"});
}
}
just set the root key to null
so change the true to false?
what? I never said anythign about true nor false
nvm
if you want to remove all entries under "homes.uuid" you set that root to null
no need to do each individually
public static int getAmount(Player rightClicked) {
ItemStack regular = new ItemStack(Material.REDSTONE);
if (regular == null)
return 0;
int amount = 0;
for (int i = 0; i < 36; i++) {
ItemStack slot = rightClicked.getInventory().getItem(i);
if (slot == null || !slot.isSimilar(regular))
continue;
amount += slot.getAmount();
}
return amount;
}
//and in another method:
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColor.GREEN + "Taser Charges left: " + getAmount(clicked)));```
u think that will work?
what will config.getInt() return if the path doesnt exist?
nullpointer
really
why couldnt it just return Integer instead of int, so it can return just null
?paste
How can i leave the marked slots empty?
I tried to set the marked slots to null and air with .setitem(0, null), But if I use .additem it will still take slot 0.
mentioning Regular() will return the ItemStack, right
You’ll need to use setItem for everything
^
anyways can some1 answer my question
its a java question so i bet most ppl know the answer help pls
Yes
you mean Yes to that?
Yes
YOOO POG
I won’t comment on the poor naming