#help-development
1 messages · Page 2212 of 1
It just takes too much time when you use spigot mappings you just need a tool for help...
You'll have to deal with stuff like that when you're on old versions
You can always update
1.16.3 definitey doesn't have --remapped, just checked
or tell the server owner to update
this
yeah im thinking about this since aswm is also not supporting 1.16 anymore...
they just have to stop staying on older versions when 1.8 pvp version is not an important option
I wonder just how painful it would be to make a library that detects when other plugins use nms or mca to modify blocks...
How would one even go about that? Is it even possible? How resource demanding would it be.
proxy into the NMS classes, lol good luck
Load Mixins and inject in to the methods
That's a good idea, although still seems like a lot of work
Probably only worthwhile if we aren't the only project prospectively using it.
If we made such a library, think any other plugins might have a use for it?
If it can be a library I'd say do it
Would it be sustainable though? Making libraries is one thing, but maintaining them is another.
We already have needed to make two libraries to get our stuff to work, but they are sufficiently general that they are likely to be self sustaining
(i.e. other projects depend on them, and they are now large enough that people will keep them up to date via prs)
Not sure if this is sufficiently general to be of use for other projects
Someone has done this before https://github.com/LXGaming/BukkitBootstrap
😮
I tried something like this
But when my dropped any item, console gives a error
What error
Oh
Sorry
Well somethings null on ManHunt line 41
Oh
Right
@EventHandler
public void getReady(PlayerInteractEvent e){
if(e.getPlayer().getWorld().getName().equals("world")) {
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED+"hazırsın mı");
item.setItemMeta(meta);
if (e.getItem().getItemMeta().equals(meta))
e.getPlayer().sendMessage(ChatColor.RED + "bu sadece bir test ve galiba doğru çalışıyor");
}
}
```
41: if (e.getItem().getItemMeta().equals(meta))
getItem or getItemmeta is null
But which :/
You should null check them both
Both of them seems correct..
void getReady hmm
@EventHandler
public void getReady(PlayerInteractEvent e){
if(e.getPlayer().getWorld().getName().equals("world")) {
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED+"hazırsın mı");
item.setItemMeta(meta);
if(meta == null){
do something
}```
Are you talking about like this?
What does it matter :/
dont think you should give the player something on every interact lol
?
What is this now?
whats what
if I right click or left click or interact with anything in hte world you will get an item
your logic is flawed
What if I add an else?
it doesn't matter what you do
if they are in hte world world
they will get an item
Yep
I'm wanting this
Vehicle Move Event -> https://paste.md-5.net/liguhazadu.cpp
Relevant AbstractMinecart -> https://paste.md-5.net/puvuyodeso.cs
Was hoping to bypass the hardcoded 2block-per-tick momentum cap by applying it to the entity
But it seems no matter what I give to the entity it doesn't change what gets applied to the cart the next tick.
Seems like player entity movement resets itself between this tick and the next - I need it to persist so it's given to the Minecart early next tick at that point in AbstractMinecart.moveAlongTrack - Waiting one tick using the scheduler to set it early does not work either :/
1 min
I have a idea
oh ok
@EventHandler
public void ChangeWorld(PlayerChangedWorldEvent e){
if (e.getPlayer().getWorld().getName().equals("world")){
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED+"hazırsın mı");
item.setItemMeta(meta);
e.getPlayer().getInventory().setItem(3, item);
}
}
@EventHandler
public void getReady(PlayerInteractEvent e){
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED+"hazırsın mı");
item.setItemMeta(meta);
if (e.getItem().isSimilar(item))
e.getPlayer().sendMessage(ChatColor.RED + "bu sadece bir test ve galiba doğru çalışıyor");
}```
How is this?
use ```java
@EventHandler
public void ChangeWorld(PlayerChangedWorldEvent e){
if (e.getPlayer().getWorld().getName().equals("world")){
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED+"hazırsın mı");
item.setItemMeta(meta);
e.getPlayer().getInventory().setItem(3, item);
}
}
@EventHandler
public void getReady(PlayerInteractEvent e){
ItemStack item = new ItemStack(Material.REDSTONE_BLOCK);
ItemMeta meta = item.getItemMeta();
meta.setDisplayName(ChatColor.RED+"hazırsın mı");
item.setItemMeta(meta);
if (e.getPlayer().getInventory().getItemInMainHand().equals(item)){
e.getPlayer().sendMessage(ChatColor.RED + "bu sadece bir test ve galiba doğru çalışıyor");
}
```
instead e.getItem()use e.getPlayer().getInventory().getItemInMainHand()
also please make a function for creating the item if you’re going to reuse it in multiple places
do you have an error or what
what is he even tryin to do
I don't know
don't ask questions he can't answer himself
this.setDeltaMovement(Vec3.ZERO);
this.tick();
if (this.isPassenger()) {
this.getVehicle().positionRider(this);
}
}```
So I found the issue - Entities riding get their movement reset every tick
Is there any way to avoid this? Like override rideTick fn? Or set it again after this but before this.tick kind of thing
Was hoping not to have to use NMS stuff but I guess I need to to force this off
me?
@Override
protected void addBehaviourGoals() {
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, false));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Pig.class, true));
}```It is suppose to make zombie not to fight players and make zombie attack pig but the pig part does not work
So my issue; I'm trying to set DeltaMovementTick of an entity in a VehicleMoveEvent so it begins the next tick with that movement
However it's reset by Entity.moveTick() to Zero at the beginning of every tick
If I use scheduler to do it one tick later, it's too late
Anyone know how I could set movement AFTER the reset but before anything else without NMS ideally... Kind of a mess
Or just some kind of workaround, yk - It's to bypass a momentum cap in Minecarts - Without NMS it's theoretically possible to give 10x velocity to player and it'll be added to the cart AFTER the momentum cap - but the reset of player movement on a new tick when in a vehicle makes it not work
why is Player
playSound(Location location, String sound, float volume, float pitch) not chaning the volume?
not beyond 1.0
i would make a repeating task which changes the volume to see if it actually works :)
Can anyone Help me? ;/
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
is it possible to add knockback on hand using java?
anyone got ideas for weird tick stuff? need it to happen at a certain point in the tick kinda and im not sure thats doable
when a line in a config doesnt exist is it a empty string or a null object?
null
thx 🙂
what error, more sure?
gud job
thank

im sorry to have summoned you
@Override
protected void addBehaviourGoals() {
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, false));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Pig.class, true));
}```
It is suppose to make zombie not to fight players and make zombie attack pig but the pig part does not work
no problem, im here to help you out.
😌 🙏🙏
when i write a player uuid in a config there is a expression because of the !! at the beginning of the uuid...
Why does this disables explosions completely and not only block damage ?
@EventHandler
public void onBlockBoom(BlockExplodeEvent event) {
if(!event.getBlock().getWorld().getName().equals("spawn")) return;
event.blockList().clear();
event.setCancelled(true);
}
@EventHandler
public void onEntityBoom(EntityExplodeEvent event) {
if(!event.getEntity().getWorld().getName().equals("spawn")) return;
event.blockList().clear();
event.setCancelled(true);
}```
okay thx 🙂
is there a blockdamage event?
How can i add knockback on Hands
you can edit the attribute
because you cancel the event
omg yes i'm so dumb
When registering custom item recipes with NamespacedKey, is there a point to keeping a reference to that key? I'm having a few different varieties of my custom item for different Material types, and im wondering if it would be easier to identify which version it is by just having a PersistentData string of the material, rather than checking each possible key?
in game?
I know I just copy pasted the cancel then forgot about it
yah
sure? a NamespacedKey is just a normal object, you can keep / store it whereever you want
can you say me how? :/
btw take a look at MaterialChoices if you have "variants" of your recipes
I guess my question is more about efficiency or best practices then. Would you as a dev prefer to be checking these keys or checking a string? Ohh also going to look into that material choices now
do you want to increase forever for every play?
let me check what I meant
Umm i wanna do it in Plugin
okay I meant the groups. for example, oak_boat, birch_boat, ... all appear as one "group" in the crafting recipe book. you can do the same by setting the same "group" to all your "similar" recipes
ShapedRecipe#setGroup
woahhhh
I'm def gonna do that, awesome feature ty
well, actually it might not be applicable in this case
MaterialChoice is for stuff like barrels or chests - it takes oak plank, birch pank, ... (and you can even mix them) but it all results in the same item
since the dif varieties are gonna have different strengths
so not exactly "variants"
ok so you can create a function which gets the list of al online players and then you can loopthrough the list and set the attribute to high knockback
good info ty alex, you helped me about a year ago as well 😉
I think it was on forge modding though
np 🙂 erm tbh I cant remember lol
yeah haha I just recognize the name 😉 was a trivial thing in the end haha
i wanna do it in a command 🙂
um what is a plugin instance? i feel a bit dumb
i'm trying to make a bukkit runnable
ok
then you can create a command and get the sender wait i sec i will send you an example code
a reference to your main class
if you're in the class that extends JavaPlugin, than it's "this"
Ah i see, ty
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(sender instanceof Player){
Player player = (Player) sender;
player.getAttribute(Attribute.GENERIC_ATTACK_KNOCKBACK).setBaseValue(<Your number>);
}
return true;
}```Its untested but it should set teh knockback to the number you want
@Override
protected void addBehaviourGoals() {
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal(this, Player.class, false));
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal(this, Pig.class, true));
}```
It is suppose to make zombie not to fight players and make zombie attack pig but the pig part does not work
wait so i tried putting this and HeavyWeapons in the spot but it's still giving me an error, what am i doing wrong?
You need to pass an instance of your plugin
(your main class)
?di You can use di for this
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
"this" in this context is your listener
question i’m using saber factions as my main factions part but how does f top even work? cause i placed spawners in my claim and my f top didn’t go up is this because i need a separate plugin for that and if so can someone suggest the one i need or is it something instead saber i need to turn on if so where cause i could t see it
you basically have two methods: a static getter, or passing your main instance into the other classes when you need it. I explained both methods as short as possible here: https://blog.jeff-media.com/getting-your-main-classes-instance-in-another-class/
#help-server or ask the author of that plugin
i'll take a look at that, thank you
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
can i send a player a message when he contacts a block the first time in the playerMoveEvent?
lets not contact blocks lol
you would have to store a collection of all blocks he has walked on lol
i mean the player contacted the block in a way XD
my brain is already thinking bout optimisations lol
lOl
i assume that means that the player walked on the block
yes
store the locations
and then?
if there were tuples in java i'd just store the x y z
dunno what you even trying to achieve
I have created a nms class with custom entity and u have overrided the addbehaviur goal but i am unable to make zombie passive towards players
little bit expensive storing all the locations
where is that in the obfuscated version?
just if the player walks on the block the event is triggered everytime the player walks on the block but i want it to only be on the first walking action on the block @tardy delta
yk?
you could store a collecctions of blocks and check if it contains the block the player is walking on lol
hashset with 2k elements lets goo
well lets get the reason tho
lmao
That's why u use hashset
to achieve what you are trying to get
Quick lookups
no duplicate elemnts lmao
the thing is i am working on a jump and run plugin wich should send the player a message when he first reached a checkpoint
bruh
LOL
like parcour thing?
ye
just store the waypoints things
that i did
instead of all blocks they walked on
then just.. store a boolean or something
to check if the player walked on it already
yes i thought of this too ill try it
sounds like xy problem
Yep lmao
x)
and then conclure comes in
or you dont even have to store boolean
classic
run and jump plugin
hmm youre right
I have made zombie a neutral mob so now it no longer attack anyone but how can i make it passive
(r instanceof Rectangle(ColoredPoint(Point p, Color c), ColoredPoint lr)) java 19 pog?
my brain is too tired to think
so i have a runnable set up that gives the player a mining fatigue every 5 seconds whenever they have a wooden axe in their hand.
the thing is, i want to cancel this runnable whenever they switch something in their hand
how do i do this? idk how i would implement another listener in this if statement
what does that do lol
Record deconstruction/matching
Oh lol
i'd just gave them the effect for a very long time when they switch to an axe and remove it when they switch to smth else
no runnable
hmm that is a better way, i guess i was just overthinking the possible ways of losing the effect without having to switch items, thank you!
public NewWarden(Location location) {
super(((CraftWorld) location.getWorld()).getHandle());
}```why it gives error even it works fine for aombie
what error
'Warden(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.monster.Monster>, net.minecraft.world.level.Level)' in 'net.minecraft.world.entity.monster.warden.Warden' cannot be applied to '(net.minecraft.server.level.ServerLevel)'
it needs an entitytype and level thro the constcutor ii gues
super(EntityType.WARDEN((CraftWorld) location.getWorld()).getHandle()); like this?
hm
what class are you extending
warden
but when should i change this boolean to true?
Use a set instead
this mob is so new that there are no threads about it
?paste the full error trace
its just 2 line error
in which way?
Warden(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.monster.Monster>, net.minecraft.world.level.Level)' in 'net.minecraft.world.entity.monster.warden.Warden' cannot be applied to '(net.minecraft.server.level.ServerLevel)'
the error is in ide not in consolee
?paste yoru class and I'll take a look
?
just add the uuid to the set when it steps over it...
that sok, its mainly so I have the same imports etc
and if they step over it again, check if its in the set
?paste
would you save it as a uuid or as a string?
as uuid
why string?
idk because there is no unique id in org.bukkit or i just cant find it
or is it UUID from java.util?
um
why is it that whenever i switch to something other than a wooden axe i get the effect? shouldn't it be the other way around? i tried != and it worked vice versa
Warden requires more args in its constructor.
There is non for a single arg
like i give myself a wooden axe and i switch to it to my mainhand but i don't get anything, when i switch to something else i get the effect
i mean it works if i just flip it around but i kinda wanna know why it's backwards
Cuz the slot didn't chage yet when the event it called
That's why u can cancel it cuz events tend to be called before the thing happens
how can i get to know the args
ohhhhh i see
just hover over the method (depends on your ide) but i think you should learn a bit general stuff before doing this
i know but it in super it does not show the sub argument
U can do player.getInventory.getItem(event.getNewSlot)
To get the new item
odd thing is there doesn;t seem to be an EntityType.WARDEN
And vice versa
wait what
i got it, thank you so much!
there is
net.minecraft.world.entity.EntityType I see nothing for WARDEN
Yes, but theres no EntityType
I shoudl be, else there would be no net.minecraft.world.entity.monster.warden.Warden
let me clean my project as I did just update it from 1.18
when i typeEntitytype it recommends warden
help pls
I don;t get that option. However yoru constructor shoudl be super(EntityType.WARDEN, ((CraftWorld) location.getWorld()).getHandle());
Super wierd. its missing from mine
I'll run BT again. I havn't run it in a few days
oh
pov:When you are so pro at programming you help others without even being able to run teh code
lol
Btw i just remembered that on the next day of 1.19 release i was not able to use warden but today i was able to maybe this type og glich happened with you
odd, still not showing up for me
hmm
how do i get rid of this error?
let helditem not be null
i did but it still throws that error which i dont' understand
well how do i check if it's null
if heldItem==null
?java
yeah that's what i did, lemme try again perhaps i screwed something up the first time lol
ye i'll test once more i deleted the line assuming that wasn't the solution before haha
it would be like this, right?
Ye
it works now! i have an idea on what i did wrong the first time, you kinda pointed that out indirectly. tysm again!
nah i think i did if (heldItem.getType == null) before
which is kinda obvious isn't gonna work now that i think of it haha
Ah ye
Hey, I have a list of ItemStack and I want to get the itemStack with the highly amount, how can I do that?
through java streams
wdym by highly amount
ItemStack#setAmount(int amount);
np, he means get the itemstack with the highest amount value
🤷♂️ no clue can be different based off the conditions he wants
Collection<ItemStack> listOrWhatever = ...;
ItemStack highest = null;
for(ItemStack item : listOrWhatever)
if(highest == null || item.getAmount() > highest.getAmount())
highest = item;
you'll need to add items together (duplicate entries wont work)
hope there's a better way through java streams, isn't there?
Thanks that's what I needed
java streams add overhead
Which is why I avoid them
for loops look fine 🤷♂️ no reason to use streams
oh, maybe, don't know a much about them, just used to use stream syntax in Kt
¯_(ツ)_/¯
is it possible to get an entity by its entity id?
I only recommend streams when they turn a 200 line for loop into like 10 lines
What is wrong with this? when i manually put the material type in runnable setType it works
I think paper has an api for that, but you're likely gonna need to loop through worlds
Anyone know how I could be getting Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug! for a plugin that should be compiling to 1.19 via Gradle? Trying to check if the players holding a stick and it keeps giving me LEGACY_STICK and it's kinda annoying
ok
block type after a tick might be different
api-version: 1.19 on plugin.yml
I've saved that before
Already done
Any clue if it can change in OnPlayerInteract? And if so, when?
you saved the block reference, but not the type
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Bukkit.getLogger().info("interact");
Player player = event.getPlayer();
Bukkit.getLogger().info(player.getInventory().getItemInMainHand().getData().getItemType().name()); // < Gives "LEGACY_STICK"
if(!player.getInventory().getItemInMainHand().getData().getItemType().equals(Material.STICK)) return; // < Doesnt' pass here
Bukkit.getLogger().info("it's a stick");
Entity chicken = player.getWorld().spawnEntity(player.getLocation(), EntityType.CHICKEN);
chicken.setVelocity(player.getEyeLocation().toVector().multiply(8));
Bukkit.getLogger().info("chickeeennn");
}```
pain
ItemStack item = event.getItem();
if(item == null)
return;
Material type = item.getType();
if(type != STICK)
return;
issa stick
yea fine now with material, thanks
heeeelp
oh yeha this issue
issa pain in the ass
You gotta send an Entity Metadata packet containing all the skin layers
Was somehow unaware getItem was a thing :/ Thanks lmfao
1 | 2 | 4 | 8 | 10 | 20 | 40 | 80 for all the skin layers
or Byte.MAX_VALUE for short
I tried to create separated inventories using this way, i think it works, somehow, but what can I do to open using a command
that's my idea:
Inventory[] itemsMenuGui;
public ItemsMenu() {
itemsMenuGui = new Inventory[0];
createItemsMenu();
}
public void createItemsMenu() {
itemsListConfig = new ItemsListConfigFile(plugin);
Objects.requireNonNull(itemsListConfig.getItemsListConfig().getConfigurationSection("Inventories")).getKeys(false).forEach(ID -> {
String menuName = itemsListConfig.getItemsListConfig().getString("Inventories." + ID + ".menu_name");
itemsMenuGui[Integer.parseInt(ID)] = Bukkit.createInventory(null, 36, "§8§oEditing " + menuName + " menu...");
});
}
public void openInventory(Player player, int ID) {
player.openInventory(itemsMenuGui[ID]);
}
command class:
itemsMenu = new ItemsMenu();
itemsMenu.openInventory(player, Integer.parseInt(args[0]));
sorry for my bad english
?
if somehow I could give the size for Inventory[] itemsMenuGui; as the numbers of the inventories in my config like Inventory[] itemsMenuGui = new Inventory[inventories_list];
you can start by understanding it's a bitmask
so you gotta add the bits together
instead of setting them 15 times
& is a bit AND
| is a bit OR
you want the OR
A bitmask is just a set of 8 booleans represented as bits on a byte
11110000 can both mean a number, but you can also look at the bits and say that there are 4 values set to TRUE, and 4 set to FALSE
so it will look like this?
Yah
same error
What version?
1.17.1
alr
What's line 65
why expression expected
in the 1st version, it was the 1st set
nvm
?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.
i know
that is not how you cast 🧐
it sometimes takes a second
very close though
new ArrayList<>((List<Integer>) PlayerData.get().getList(...))
I KNOW
Ok
stop the making fun
can somebody help me, please? 🥺
I am not able to understand your question
how can i give effects to mobs in nms cuz there is no addPotionEffect
^^
if(sender instanceof Player){
Player player = (Player) sender;
player.openInventory(player, Integer.parseInt(args[0]))
}
so why it dont work? it looks like this now
when i shift click on this in my inventory plugin runes this 4 times player.sendMessage(Utils.getColorizedConfig("messages.crafting"));
but it wont work if the size%9!=0
call registerObject before calling set
honestly calling set is for replacing objects
How would one clear unlocked recipes from a player? (to essential remove use of the recipe book)
ok, no errors now but still no cape
are you sending the packet
of course
pretty sure it's stored in the player nbt
gotcha. thanks for the pointer
1: i send the PlayerInfo packet
2: i send the EntitySpawn packet (addEntity)
3: i send the metadata packet
4: send the PlayerInfo packet with REMOVE
hey does anyone know how I can place a bed in 1.8.8? I've tried the regular stuff I found googling the issue but nothing seems to work
I got 2 locations I would want the bed to be at
not supported
with a bit of hackery everything is possible
uhhh great question
exactly
thats not what i meant...
1.8.8
Yeah. I've been spending so many hours trying to find a way to get this done
yall got any idea?
haven't touched 1.8 in months
Again, not what i meant. but whatever
nah not wtv explain i'm in the trenches over here
if I have a method that takes in parameters like public <T> T myMethod(Something<T>, T) and i have Something<?>, what should the second parameter be?
In theory it would be object, but it is likely that there is no valid type given that ? is a wildcard
can you try to help me plz im lost
yeah that's the issue and obviously i can't cast to ?
I'd recommend casting it to Something (no types), at which point T would be the upper bound (usually Object)
huh odd
Well then, go with the completely nuclear option: Manually cast it to the upper bound
can I safely cast PlayerStatistic<?> to PlayerStatistic<Object>?
Depends on what ? can be
For example if you have PlayerStatistic defined as public class PlayerStatistic<T extends Number>, then you'd need to cast it to Number
But javac will complain about unchecked casts either way
public class PlayerStatistic<T> {
private final Class<T> clazz;
private final String name;
public PlayerStatistic(Class<T> clazz, String name) {
this.clazz = clazz;
this.name = name;
}
public Class<T> getValueType() {
return clazz;
}
public String getName() {
return name;
}
}
``` this is the entire class
Oh, then it is Object
i should've not designed player statistics like this
its pretty awful to deal with
but i cba to make a field for each statistic and update my serializer methods each time i need to add a new statistic
that's actually crazy... the fact that I can't place a bed in my server even though i got the 2 locations needed.
how tf can it be that hard to get an API properly done
Multi-block blocks are a complicated thing, regardless of how the API is
@echo basalt helppp
yeah but the API doesn't support beds. only beds
its crazy
🤔
Probably BlockStates vs BlockData
hey how would i create a completable future for a player on their login?
😤
Whatever, they are stupid either given that they are using 1.8.8
i'd like to create a message that the plugin can send to the player once they login, like an announcement or something if they miss it
its so annoying
It makes sense however
i remember there was some sort of orientation api
that i used
for a while
what do you mean?
simply send the message on the PlayerJoinEvent?
i need it now
that gives loads of useful blockstate methods for multiblock and block facing stuff
Only that there are 3 or 4 orientation APIs
Yeah, probs
i'm pretty sure the client is ready to receive messages when the playerjoinevent is called
it's not like that, it's sort of like a queued message from when they were offline, and not sending on join
I don't see why y'all say 1.8 doesn't support beds
beds were definitely in 1.8
aaaa
you would need to store every message sent then
so you want to send each chat message that has been sent while the player was offline to the player when they join back?
what do completable futures have to do with that
yeah something like that but not all of them
when the player is online, then send it?
im not really sure
you need to log somewhere the message and the time it was sent at
how do i place it with my locations though
then when a player joins check when they left last time and send all the messages that have been sent after the last logout
i thought theres was a whole blockstate thing to go through
alr
Block head = ...;
Block foot = ...;
Bed headBed = new Bed(head.getFace(foot)); // you might need to reverse this
headBed.setHeadOfBed(true);
Bed footBed = new Bed(foot.getFace(head)); // you might need to reverse this
footBed.setHeadOfBed(false);
head.getState().setData(headBed);
head.getState().update();
foot.getState().setData(footBed);
foot.getState().update();
pain in the ass but it's just what happens with multiblock
do I have to shutdown thread pools when my plugin is disabled or are they automatically shutdown if there are no more references to them?
As long as they aren't static, they should be garbage collected
Make sure the threads are set as daemon threads for that extra safety
i'm aware that gc is a thing, but i'm not sure whether it could cause memory leaks, like if you don't close streams
uhh
if i have to shut them down myself, can I make sure that all the tasks have ended before my plugin disables?
honestly running threads might cause memo leaks
i saw there's shutdownNow but i remember last time i used it, it just deadlocked my server
I'd put them all on a completablefuture and join it
mm deadlocks
messing with threads in general can cause so many deadlocks
awaitTermination*
how do i check if a term in config is in a players name?
head.getState().setData(headBed);
gives: java.lang.IllegalArgumentException: Provided data is not of type org.bukkit.material.MaterialData, found org.bukkit.material.Bed in the console
Is there a way to change treasure chests loot tables?
Chest#setLootTable is a thing
i'm pretty sure there's an api for loot tables but i'm not sure how it works
It is a good practice to shut em down
But assume your pool is configured with a daemon thread factory then you’re basically good to go in conjunction with a shutdown
You can then await termination for like 20 seconds perhaps?
whats the best way of getting a random online player
How does differentiate between chests in dungeon and let's say in the end city?
sounds good, i don't think mongo will ever take longer than 20 seconds to finish saving player data
unless my wifi goes out 😛
But yes ExecutorService kinda sucks as it’s basically unstructured concurrency at its core
end city loot has elytras and enchanted stuff
other stuff has other loot
also all the loot might be configurable via datapack not sure
it's all keyed
check org.bukkit.loot.LootTables
do you know any other options i could use? right now i'm using Executors.newFixedThreadPool(2);
hello i nead help whit exelentcrates cant find itf for 5 days
hey when taking something randomly from a collection/list, how do i do that easily? without having to use Random.nextInt(0 or 1, colection)
Not exactly
because i remember prevoiulsy i had to do collection.size() - 1 for some reason
You just have to deal with it, I mean executor services work fine
But for instance we have no control over parent and child tasks
being able to unit certain futures etc
You can use join
But that becomes unstructured
private <T> T getRandomElement(List<T> list) {
int size = list.size();
if(size == 0)
return null;
if(size == 1)
return list.get(0);
Random random = ThreadLocalRandom.current();
return list.get(random.nextInt(size));
}
thank you so much lmao
hm aight, just asking because my experience with concurrency and threads can be summarized with Bukkit.getScheduler().runTaskAsync(...)
Yes if you’re not creating something scalable the Bukkit scheduler’s async methods will suffice
i kinda like how what i coded turned out tho
Ye
what changed in 1.18 to completely lock up servers whenever I try to load any world
Completely lock up?
https://paste.md-5.net/tifumosila.java this is my registry class that handles the async stuff too
crap deadlocks for 15 seconds and stops trying
What about with collections btw? I know you can convert a collection to a list but how could i modify that to suit collections
I haven’t experienced that
since collections dont allow you to select with an index
turn that to an array
i think apache commons can do that but idk how it manages
alr
Is that what locks it?
best way to do that lol
toArray
That’s fucking odd let me try that rq, I assume load is invoked on some other thread?
RandomGenerator.getRandomElement(new ArrayList<>(BukkitUtils.getOnlinePlayers()));
you pain me
lmao
toArray converts to Object[] for some reason
random.nextInt is generally not inclusive
so nextInt(5, 10) will return a number between [5,6,7,8,9]
the +1 makes the 10 belong
so doesnt that mean that the getRandomElement will return something between the start value and the second to last value?
imillusion it works perfectly fine for me
and random upper values are exclusive
rly odd
hella weird
could be something about the mca file
that issue has been plaguing me for like 2 months now
yeah, I used paper weight mojmapped server thingy
conclure i did what you told me but the server seems to deadlock and awaitTermination returns false
I only have a 1.17 mca file for now
but i'm unsure about why that's the case
let me see
?paste
How would one display values on the tab list for each player?
Hello guys, I got a problem, this event is called twice. I didn't registered it twice I'm sure. Can you help me?
https://paste.md-5.net/dozepuzofu.cs
you mean make per-player tablists?
packets
PlayerInteractEvent is called twice, one for each hand
player interact events are called once per hand
Look at line 5
so check the event hand and return if the hand is the offhand
uhhh
No just like display a number for everyone, like equal to just vanilla commands
ik the code quality is so bad i'll fix it
amogus
tablists or sidebars
tablist
I can't tell if spigot is just weird today or if I'm too sleep deprived to figure out a fix
yes the code is kinda unreadable ngl
that's the same for me
seen the wildest stuff
any idea for a fix?
i didn't know you could use commands to modify the tablist
you can display a scoreboard on the tablist
put a broadcast above the hand check and put another one below
bro
look at my code
ln 14
it is called twice
i am trying to help you debug the issue
if the event is registered twice, a broadcast above the hand check will be sent 4 times
it is sent 2 times
wait you mean the score of a scoreboard near a player's name?
yesss
anyways the method should be setDisplaySlot from the Objective interface
sent the printLn 3 times before and 2 later
I’ll need to be debugged too soon
oK kill05
i debuggegged
the event is called 3 times
Ok, but then how do I add a score to a player?
what's the name of the "click" sound
it's usually used when a player selects an item from a GUI
oh wait this sounds better
but i just found the sound
it was BLOCK_DISPENSER_DISPENSE
what should getOwner return???
UUID.fromString() or similar
Thank You so much
np
@ivory sleet try this schem
Cannot resolve symbol 'PacketPlayOutSpawnEntityLiving' why am i getting this error is there a certain repo i need to add or somethifn?
What version are you using
add spigot instead of spigot-api
1.18
.2
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>``` ```Unresolved dependency: 'org.spigotmc:spigot:jar:1.18.2-R0.1-SNAPSHOT'```
?bt Run BuildTools
i need to install it for it to work?
Yes
how can i fix this error *** The version you have requested to build requires Java versions between [Java 17, Java 18], but you are using Java 16 i need to use java 16 soooo and i cant download an older version of btools because the link is just a download
Why do you need Java 16?
1.18 plugin java 16 server
public void savePlayerSync(UUID uuid) {
MongoHandler.getCollection(Collection.PLAYERDATA)
.replaceOne(getFilter(uuid), getPlayerDocument(uuid), new ReplaceOptions().upsert(true));
}
private Document getFilter(UUID uuid) {
return new Document("_id", uuid.toString());
}
private Document getPlayerDocument(UUID uuid) {
CosmicPlayer cosmicPlayer = getPlayer(uuid);
if(cosmicPlayer == null) {
throw new CosmicException("There is no player to save with uuid " + uuid + ".");
}
Document document = new Document("_id", uuid.toString());
for(PlayerStatistic<?> statistic : PlayerStatistics.getStatistics()) {
document.append(statistic.getName(), cosmicPlayer.getStatistic(statistic));
}
return document;
}
``` hey, for some reason the `savePlayerSync` method seems to block the thread it's executed in for an indefinite amount of time, i've added a debug message above and below the call to the method and in 10 minutes only the first message was sent
are you using the mongo streams driver
or the regular one
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.12.11</version>
</dependency>
this is my maven import
am I supposed to use another one?
use the mongo streams driver it can run async safely
it should also stop the blocking
granted you take full use of the features provided
good rule of thumb don't run DB calls main thread its going to end up blocking if the requests don't take long
yes
you will need to change your code up for the rest of the project, but it should help if you implement it correctly
i'm aware, this is the method that was invoking savePlayerSync
public CompletableFuture<Void> saveAll() {
CompletableFuture<Void> completableFuture = new CompletableFuture<>();
threadPool.submit(() -> {
for(UUID key : cosmicPlayerMap.keySet()) {
Bukkit.broadcastMessage("next!");
savePlayerSync(key);
Bukkit.broadcastMessage("done next!");
}
Bukkit.broadcastMessage("completed!");
completableFuture.complete(null);
});
return completableFuture;
}
there is also a mongo async driver, but its deprecated in favor of the reactive streams driver
why use a db?
to store information. Its the standard and proper way to do it
yaml files is ok for smaller things
how different is the syntax compared to the driver i am using now?
but you always want the scalable option at the disposal
it's a private plugin for a server im working on
so why not use a db which is a better option compared to yml files
I don't remember exactly I just remember it being different make sure you read the docs Mongo has amazing docs
you could also alternatively implement async yourself
do you think that I should learn how to use dbs?
yes learn SQL variety or Mongo
if you want to sure
i mean i kinda was, if you check the method i sent above
no pain no carrots, I'll do it
if that's what you meant
the issue is not that the method makes the thread stop a bit, it completely freezes it
it's been 20 minutes now and it still didn't run once
am i supose to put buildtools in my project to be able to use packets orrr? the spigot link doesnt really say and i jsut ran it and it started creating folders
No just run it somewhere
no build it with mojang mappings as stated in every announcement post after 1.18 than depend properly with maven or gradle
i did and i still cant use <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency> same error
what does that means? strictfp
is it possible to play a sound for one player that doesnt have a location using packages?
so a sound that "always stays in the center"
regardless of actual positioning
play it at the cloned player position maybe?
i guess the sound follows if you play it at the players loc
I believe it has to have a position
i mean it does make sense esp for the 3D sound effects
however it doesnt for playback music
hm?
pls help, nautilus is fired two times https://paste.md-5.net/ezesawixeh.cs
Olivo i belive in u
both hands?
look at line 7
how can I get a static field with reflections?
for(Field field : getClass().getDeclaredFields()) {
if(field.getType() == String.class) {
field.setAccessible(true);
System.out.println(field.getName());
try {
String value = Colors.parseColor(langConfig.getString(field.getName()));
field.set(this, value);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}```
because these events tend to fire multiple times
delta time it for the player to not fire twice within like 1sec
the same player
bruhhh that's not normal
so i need to do a runTaskLater and remove the player from the array after 1 sec
kydoky
this does not answer my question
you copy pasted something that's barely related to my question
can. id probably just remove them on disconnect
I remember using reflection to do this, accessing string names, I thought it might be useful in some way excuse me...
well but yea
i deltatime it using the items cooldown
however i use rightclick abilities bound to items which u dont so yea id suggest to use a backend list
what is event for drinking milk
PlayerMorningCookieEvent
ty
no sorry ahah
xd
we need md5 for that
mwah
report
ladies
if i put null
will it set it to nothing
i realize this is a localhost link
EntityArmorStand stand = new EntityArmorStand(s);``` why am i getting this error ```Cannot resolve constructor 'EntityArmorStand(WorldServer)'```
because
youre obviously
as the error tells u
instantiate it incorrectly
wrong parameters
hey timinator
i found it on a post
thanks, it works!! (The countdown)
hehe np 😛
and when i hover over it it says the paramater is a world
world or worldserver
what
ohg
says world but when i put the world there instead i get Cannot resolve constructor 'EntityArmorStand(World)'
what parameter does it require?
says world
u can look every class interface etc from the bukkit/spigot api up online btw. there u can see all possible constructors and their overloads
spigot already has a class for armor stands, do you really need packets?
yeah i need only 1 person to be able to see it
Try (CraftWorld)
Cannot resolve constructor 'EntityArmorStand(CraftWorld)' EntityArmorStand stand = new EntityArmorStand((CraftWorld) p.getWorld()); if thats what you ment?
.getHandle()
its already has (CraftWorld)
OHH
EntityArmorStand stand = new EntityArmorStand(s);```
wait I got it it needs a nms world variable.
(net.minecraft.server.v1_8_R3.World)((CraftWorld)b.getWorld()).getHandle()
replace import with wtv verison you're using
why are you doing all that
u want 1 player to see the armorstand?
player.getWorld()..
hey, can somebody help me with this question
and pass that as param
what.,,,
Other player's would be able to see it in that world 🙂
how could I use the same inventory across all my classes, like, for example Inventory 1 is created in my class ItemsMenu from my config file:
public class ItemsMenu {
public ItemsListConfigFile itemsListConfig;
private final Map<Integer, Inventory> itemsMenuGui = new HashMap<>();
public ItemsMenu() {
createItemsMenu();
}
public void createItemsMenu() {
itemsListConfig = new ItemsListConfigFile(plugin);
Objects.requireNonNull(itemsListConfig.getItemsListConfig().getConfigurationSection("Inventories")).getKeys(false).forEach(ID -> {
String menuName = itemsListConfig.getItemsListConfig().getString("Inventories." + ID + ".menu_name");
itemsMenuGui.put(Integer.parseInt(ID), Bukkit.createInventory(null, 36, "§8§oEditing " + menuName + " menu..."));
});
}
public void openInventory(Player player, int ID) {
player.openInventory(getInventory(ID));
}
}
then i wanna open this same inventory it with a command
itemsMenu = new ItemsMenu();
itemsMenu.openInventory(player, Integer.parseInt(args[0]));
then i wanna get exactly the same inventory in another class,
so i did this:
@EventHandler
public void checkInventory(InventoryOpenEvent event) {
itemsMenu = new ItemsMenu();
Map<Integer, Inventory> inventoryList = itemsMenu.getInventoryList();
Inventory openedInventory = event.getInventory();
if (inventoryList.containsValue(openedInventory)) {
itemsMenuGui = openedInventory;
}
}
but the problem is with itemsMenu = new ItemsMenu(); wich creates a "new inventory" for every class
So, what i have to do to create a single inventory for all my classes, like a static one, but without using static keyword? 🥺
I hope I have explained what I meant, my english is not the best 😅
the package sending part is his problem. world is world🙂
EntityArmorStand stand = new EntityArmorStand((CraftWorld) p.getWorld());``` im getting a load of errors from the (net.m) thing ```Cannot resolve symbol 'v1'``````Not a statemen``` ```Cannot resolve symbol 'R0'``` ```Cannot resolve symbol 'SNAPSHOT'```
o h
Cannot resolve symbol 'v1_18_2'
EntityArmorStand stand = new EntityArmorStand(s);```
first off, if you want the SAME inventory you need to
A: keep it referenced
and
B: dont use a new instance.
type out world and do the net.minecraft.world.level
well... that's the problem, i have no idea how to do that
first off u could make it static
Maps 😛
Cannot resolve symbol 'v1_18_2' same error
or
send code
EntityArmorStand stand = new EntityArmorStand(s);```
the better alternative
Did you follow this @quartz basalt
yes
keep it referenced although the problem is
net.minecraft.world.level.World
try tahat
Alright it won't be called EntityArmorStand
hmm
that inventories get "deleted" when the viewer count goes to 0
wdym jsut on its own or in the ( )
as long as someone is viewing that inventory for example itll never get deleted from memory
in the ()
but thats not the solution here
Also using v1_18_2 won't work
Ntdi gave you some outdated info
im running outdated software 😛
what do you actually want to use this for?
player backpack?
or what is it
The class should just be called ArmorStand or smth like that.
what class for what
EntityArmorStand isn't named that
oh
hm?
trading post
creative menu
interface
im working on a giveall plugin
so players can take stuff out of that inventory?
where u can create menus with items
wich later can be give to all online players
so interfaces?
/giveall gui 1/2/3/4
thats the only one other then the regular entity armorstand
everyone can get 1 set
not exactly, i mean somehow yes, but they cannot open the menu, they just recieve the item from the menu
directly in their invetories
only the admin can open the menu to add items
okay so
im not gonna do ur homework
but
id suggest you read into serialization
instead of keeping it in memory at all times
id keep it serialized on the harddrive
and instantiate it from the harddrive when needed
once ur done with that, theres a bukkit wrapper that you need to use to serialize bukkit objects
I'm not at my PC so I can't check what everything is. When using NMS you should be experienced enough to take a look around Mojang code yourself
So dig around a bit and see if you find what you need. If you decide to google it, keep in mind it's usually version specific code.
oh and ofcourse if u wanna hand out the items to the players
create an instance for everyone each
so everyone can receive their set instead of grabbing from the same inv pool
laughs in pathfindergoals
?
can i like post my code here and ask for a code review
I have something that works but its got duplicate code and idk how to clean it
just gimme a sec gonna finish up some feature
okay, thank u, i will try
basically theres a reason why inventories get removed from memory. so instead of forcing them to stay there id just store them to the harddrive while not needed activly
and reload them into mem when needed
if u want them to be persistent
once serialized theres like thousands of ways to store them
okay, thanksss
np 😛 thank me when its working
this is submenu for a GUI created with InventoryFramework
the main problem is the duplicate code, i'm repeating the same thing for both Color and Style
alright
I have a ColorSelector enum and a StyleSelector enum
two methods which are almost identical
hey does anyone know how to cash data, for example only save the data the the db when the player leaves or the server is shut down. looking to make a small eco plugin
you should probably be saving the data to a database right away
instead of cache
if the server is shut down unexpectedly (for example a power outage), all the data is lost
saving the balance of a player to the database when the balance is constantly changing will cause mass lag
thats why i dont want to do it
i'm sure it'll barely make a dent in performance. but if you want to go that route, just store an array in the plugin or part of the plugin
where each element stores information about a player and their balance
i cant save data multiple times a min with 100+ players
when there bal is changing from mining etc
it won't cause lag, unless you have 10000 of players on mysql
how much is "multiple"?
chances are you'll be fine
PlayerQuitEvent, @override onDisable
like stated before, unexpected shutdowns will cause data loss but tbh
crashes always will
I've had a server 8 years ago with 200-300 players with mysql
ok ty
anyways bump for later
if you feel like mysql is not enough, go for mongoDB
ye thats what im using
ty tho
give the guy time to read lol
yeah ik no rush lmao
package me.screescree.SuperiorSteed.superiorhorse.horseeditor.submenus;
there's too many private static classes
private static Mask MASK = new Mask(
"1111111",
"0000000",
"0111110"
);
make it final
final the enum variables
for (ColorSelector colorSelector : values()) {
i would not iterate everytime over the values of an enum. even if its small its more efficient to use a internal hashmap
remove the getByName methods, they will probably not work
that's just the enums
sheesh thanks
uh btw i dont think you can use final enums
also i would not use the ordinal() method of enum
and for iterating over all the values of the enum, what's an alternative?
why
event on campfire lighting?
its not really an item index. also the order can change. easily misunderstandable as well
also getByName actually does work
yeah i know its not an item index, but it serves as an item index in OutlinePane because thats just the way it functions
but i guess your right its confusing
but what can I do about the duplicate code?
since it seems to be the exact same code you can just inline it into a method and use that
what do you mean inline it into a method
for the enum duplicate code i would probably go generic with a Selector superclass
cut the code off
put it in a function
call the function twice
checkColor checkStyle could be one function
enums cant do inheritance though
i tried doing that at first
do you really explicit need an enum
well not really
i guess ill find a way to turn it into a class
generics is a good idea
thanks
@echo basalt
i just wanted to say that
i just spent hours on this
some minutes making this:
to see that the problem
was this motherfocker here
lol
the false seems to reset the tags after they get sent or something