#development
1 messages · Page 135 of 1
i don't found the error i just use another method
if (item_meta.getDisplayName().equals("§6Core Chest")) {
Player player = (Player) e.getWhoClicked();
Inventory inventory = Bukkit.createInventory(null,
plugin.core_upgrade.getConfig().getInt(player_clan_name + ".chest_upgrade.level") * 9
, "§6Core Chest");
UUID player_uuid = e.getWhoClicked().getUniqueId();
Clan player_clan = plugin.get_simple_clans().getClanManager().getClanByPlayerUniqueId(player_uuid);
clan_inventory.put(player_clan, inventory);
FileConfiguration core_upgrade_file = plugin.core_upgrade.getConfig();
if(core_upgrade_file.contains(player_clan_name + ".chest_upgrade.content")) {
Set<String> inventory_content_list = Objects.requireNonNull(core_upgrade_file.getConfigurationSection(
player_clan_name + ".chest_upgrade.content")).getKeys(true);
for (String path : inventory_content_list) {
clan_inventory.get(player_clan).setItem(Integer.parseInt(path), core_upgrade_file.getItemStack(player_clan_name + ".chest_upgrade.content." + path));
}
}
player.openInventory(clan_inventory.get(player_clan));
}
}
@EventHandler
public void on_inventory_close(InventoryCloseEvent e){
if(!e.getView().getTitle().equalsIgnoreCase("§6Core Chest")) {return;}
FileConfiguration core_upgrade_file = plugin.core_upgrade.getConfig();
String player_clan_name = Objects.requireNonNull(function.get_player_clan(e.getPlayer().getName()).getClan()).getName();
int slot = 0;
for(ItemStack item : e.getInventory().getContents()) {
core_upgrade_file.set(player_clan_name + ".chest_upgrade.content."+slot, item);
slot++;
}
plugin.core_upgrade.saveConfig();
}
here the code if anyone need
i just do a another section for every item
i use get kkey with a condiguartion section
can you put java after the 3 ` its not much but might make this more readable
also one thing I have to recommend is naming conventions. everything here is just named with_this_naming_whatever and it makes it even harder for us to keep track of stuff.
also I hope you're aware Objects.requireNonNull would just throw if the argument is null. it doesn't get out silently
anyways these are just observations not related to your problem I had to make. currently debugging something on my own so someone else might be able to help with more stuff.
intelij mae a error if i don't use it
?
well clearly something in here can be null function.get_player_clan(e.getPlayer().getName()).getClan(). so you should instead check if that is null before. java if (whatever == null) // do something since its null
okay thx
{ /* ... */ }
what?
u forgot brackets
not exactly?
u forgot
I think you are mistaking
stop trolling
This is perfectly valid```java
if (whatever == null) something.do();
I think you should stop trolling or move to #off-topic ...
you're just spamming this channel for no reason
@wraith scarab is that your exact code? it makes no sense.
As I don't think Objects.requireNonNull() returns a getName() which your code java String player_clan_name = Objects.requireNonNull(function.get_player_clan(e.getPlayer().getName()).getClan()).getName();
Shows it should.
it returns T
It's also basically pointless in that context
it will basically return what you give it
if its not null
so it is valid. its just useless for the most part
so I'm assuming this function.get_player_clan(e.getPlayer().getName()).getClan() returns a Clan or whatever which has a name
I see, I usually never touch it so that'd make sense
Thought possibly the IDE had a error, or the user doesn't like the red alerts to be shown.
well its not even red. its yellow by default. at least in intellij.
Question, So im making custom enchants, and i figured instead of creating each enchant I could make one class and load them from config. So i have a CustomEnchant.java class like so: https://paste.helpch.at/sateqowofu.java
and then I have a CustomEnchantManager.java which will handle all of the enchant loading and such, but my question is can i create a new instance of CustomEnchant.java each time to create a new enchantment?
Like;
CustomEnchant test1 = new CustomEnchant(0, "Test1", 3, 1, EnchantmentTarget.ARMOR);
CustomEnchant test2 = new CustomEnchant(0, "Test2", 2, 1, EnchantmentTarget.WEAPON);
CustomEnchant test3 = new CustomEnchant(0, "Test3", 4, 1, EnchantmentTarget.ARMOR_HEAD);```
Hi, I'm working w Vault and want to do something when balance or permission primary group is changed, is possible to do this using Vault API? 🤔
you can create an wrapper for vault and register it with a higher priority, look at "vault events"
im using protocolLib and i have this issue and i dont know how to fix it
[14:21:45 ERROR]: Could not pass event PlayerJoinEvent to Zombies v1.0
com.comphenix.protocol.reflect.FieldAccessException: Field index out of bounds. (Index: 1, Size: 1)
at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:373) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:349) ~[ProtocolLib.jar:?]
at me.TahaCheji.utils.Nametag.<init>(Nametag.java:23) ~[MafanaZombies.jar:?]
at me.TahaCheji.events.PlayerJoin.onJoin(PlayerJoin.java:36) ~[MafanaZombies.jar:?]```
the code is this
this.packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
String name = UUID.randomUUID().toString().replace("-", "").substring(0, 12);
this.packet.getIntegers().write(1, 0);
this.packet.getStrings().write(0, name);
this.packet.getChatComponents().write(0, WrappedChatComponent.fromText(player.toString()));
this.packet.getSpecificModifier(Collection.class).write(0, Collections.singletonList(player.getName()));
}
public Nametag setPrefix(String prefix) {
this.packet.getChatComponents().write(1, WrappedChatComponent.fromText(ChatColor.translateAlternateColorCodes('&', prefix) + " "));
return this;
}```
I guess you meant getIntegers().write(0, 0);@craggy zealot
let me try that
Are you trying to create a team?
fake team
for nametags and tab names
com.comphenix.protocol.reflect.FieldAccessException: No field with type net.minecraft.network.chat.IChatBaseComponent exists in class PacketPlayOutScoreboardTeam.
at com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:369) ~[ProtocolLib.jar:?]
at com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:349) ~[ProtocolLib.jar:?]
at me.TahaCheji.utils.Nametag.<init>(Nametag.java:24) ~[MafanaZombies.jar:?]```
this.packet.getChatComponents().write(0, WrappedChatComponent.fromText(player.toString()));
What version are you on?
you want me to use that?
that's the documentation for packets, but your packet should have a ChatBaseComponent field, hmm
try getBytes().write(0, (byte) 0); for Mode create team
where does it create the team
the packet has a Mode field, and each value represents an action
0 to create a team, 1 to delete it, etc.
this is what the index is for
index 0 to set the team display name, index 1 to set its prefix and index 2 to set its suffix
same thing applies for all fields
in your case, index 0 for byes is the Mode field, and you set it to 0 (getBytes(0, 0)) to use the Mode create team
Anyone have an idea how to fix my issue?
I made a discord way back when. Signed out to make a second went to log back in. It was an old forgotten email
Now I'm forced to make a new one. And want to re link my same ps4 account to my current email
I'm not sure if I can re link without knowing the old account info. And bc of privacy I cant even get the email address to go through the recovery options to reset the password. Much less remember the email or that password
what
@finite monolith uh you should contact discord support, this is a Minecraft and programming help server
?not-discord
Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.
I want to prevent an item from being burned. I have this code, but it does not work.
@EventHandler
public void onItemIncinerate(EntityCombustEvent event) {
if(event.getEntity() instanceof Item)
event.setCancelled(true);
}
@EventHandler
public void onItemIncinerate(EntityDamageEvent event) {
if ((event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK
|| event.getCause() == DamageCause.LAVA) && event.getEntity() instanceof Item)
event.setCancelled(true);
}```
The events are registered.
try walking over where the item was. I know when I last tried this, the item would just become invisible but I could still pick it up and it would show back.
Need to know:
The loadPlayer function calls every time when somebody joins.
Code:
https://haste.jazzkuh.com/acamehasuw.java
Problem:
Now he make's every time somebody join's a new row in the table, but i want that everyone person have 1 row, not more
how did you create the table?
you probably want the uuid column to be the primary key (or was it unique? i'm not particularly well-versed with sql)
Thats in my main class.
Its the uuid of the player. So primary key
Is there a way to make an item immune to lava just like netherite items? I currently just replace the current item with a new one, but the item is super twitchy.
Cancelling the event should should be enough
even if it is, the majority of players use optifine
I guess, but then I can blame that if don't manage to fix it lol
there is a field you can change in the item type so it's as natural as netherite but, that won't be in the client data and the client will still de-render it
No point in changing it then. Guess I'll keep it as I have it now. Thanks though
One more thing, does anyone know the default values for the pick up sound?
I can't for the life of me find them
I'm trying to tweak pitch and volume but it just sounds weird
1, 1?
Nope, I've tried 1,1 0,0 and the other obv ones. But all seems odd
0.2F, (this.random.nextFloat() - this.random.nextFloat()) * 1.4F + 2.0F
fixed volume, random (high) pitch
https://paste.helpch.at/cihocumata.shell
So im making a configureable custom enchants. Each enchant has a type and an effect. Basically the type is the condition for it to run. So for example the BOW type requires a player to shoot a player. I have this part handled inside an EntityDamageByEntityEvent which i do some shit to get down to where a player shoots a player. Thats beyond the point. I also have a Effect which is what happens when said condition is filled. The effects are what i sent above ^. So say this enchant has a type or BOW and an effect or MESSAGE:You have been shot! or the enchant has the same type, but the effect HEAL. Basically i need to differentiate between all of the types, so should i create a long ass if statement inside a function? So like a function runEvent(String s) which takes in MESSAGE:You have been shot! and if some substring ordeal == MESSAGE send a message? Or is there a better way Not sure if this makes any sense so feel free to ask questions lmao.
Please ping me abt to gts will reply in morning.
okay im still having issues with packets and name changing
anyone know another api?
idk if you used it yet but https://github.com/retrooper/packetevents/tree/2.0
no like a name changer api?
why do you want to change names?
and what do you want to change them to
i fixed that i just used teams does anyone know how to orgnize a list?
i have a list of rounds that i wanna go from 0 to 1 to 3 to ect...
and there added into a list randomly they all have a id of 1 or 0 or 3 or 2
and i wanna go from smallest to biggest this is what i already have but it doesnt work
if (i == Main.getRounds().get(i).getRound()) {
rounds.add(Main.getRounds().get(i));
Main.getRounds().get(i).setGame(this);
}```
like im trying to sort them from highest to lowest
Collections.sort
Anyone have any other ideas?
you could just use an already existent action library and just add your own actions to it.
Gian has one, Frosty has one, there's quite a few out there. https://github.com/GiansCode/ActionUtil or you could just make your own.
Ah, I didnt think abt that thank you 🙂
Guys im making an RPG like and I'm a newbie tbh, so as player levels he gets also more health, do you think theres a way to do this without the main healthbar or can I use it? Im scared of the scaling of health at high levels at a certain point, how would you handle that?
public class WildBoar extends EntityPig {
public WildBoar(Location loc) {
super(EntityTypes.PIG, ((CraftWorld) loc.getWorld()).getHandle());
this.setPosition(loc.getX(), loc.getY(), loc.getZ());
this.setHealth(20.0f);
this.setCustomName(new ChatComponentText(ChatColor.YELLOW + "Wild Boar"));
this.setCustomNameVisible(true);
}
@Override
public void initPathfinder() {
this.targetSelector.a(0, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
this.targetSelector.a(1, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false));
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true));
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityTurtle.class, 10, true, false, EntityTurtle.bo));
this.getAttributeMap().b().add(new AttributeModifiable(GenericAttributes.ATTACK_DAMAGE, (a) -> a.setValue(1.0)));
this.getAttributeMap().b().add(new AttributeModifiable(GenericAttributes.FOLLOW_RANGE, (a) -> a.setValue(1.0)));
}
}``` what am i doing wrong? the pig stands still and doesnt do anything
it doesnt have numbers in the class it has numbers
Make the team class implement Comparable
Try giving them a permanent health boost effect?
You can't set the health to anything above 20 iirc so you just do that with effects
im so confused with this
like this is a round
public RoundOne() {
super("Round 1", 1, new MobSpawn(new Testombe(), 3), new MobSpawn(new Testeliten(), 1));
}
@Override
public boolean whileIn() {
System.out.println(2);
return true;
}
}```
and this is the gameround class i need to use the int round to go from 0 to 1 to 2 to 3 to 4
public abstract class GameRound {
private final String message;
private Zombies game;
private final int round;
private int amountOfMobsNeeded;
private List<Entity> mobKilled = new ArrayList<>();
public List<MobSpawn> mobsToSpawn = new ArrayList<>();
public GameRound(String message, int round, MobSpawn... mobSpawns) {
this.message = message;
this.round = round;
this.mobsToSpawn = Arrays.asList(mobSpawns);
}```
Yeah I think I'll make a system like hypixel that creates a custom bar that handles the damage and the main bar stays there doing nothing
Give the player the 'health_boost' effect permanent
You can change the amount of hearts
Yeah but at somepoint when people will get 10k health how do I scale it for people with 100 health?
Its better to make a custom healthbar
Yes
Idk why but this seems not to work, Do I do something wrong?
player.getAddress().toString(),
ChatColor.BOLD + "" + ChatColor.RED + "You got banned too many times!\n" + "You got banned PERMANENTLY!",
null,
null);```
I see that my ip is the same but the port changes, is that the issue? Or it's only because im in local? Do I have to substring it to take only before the port? Or maybe it takes also the / before the ip?
What doesn't work?
Check this first
Honestly if your players are going up to 10k health then you want to rethink your rpg design choices
You probably don’t want them to get more than 20 or 30 hearts, anything above will just be too broken
If you want to have stronger enemies, you give your players better gear that protects them from it, don’t increase their health any more
Can't you change the scaling? So that the amount of hearts is always the same buts each hearts hp value is different per player?
It wont be a pvp server so there arent all those issues, its more a pve ambient like world of warcraft, so dungeons and stuff with level scaling
Yeah that's cool and all, but you don't need overly inflated values
No idea.
declaration: package: org.bukkit.entity, interface: Player
Hey,
Im trying to make a Particle Gun that shoots particles but idk how to calculate the Direction and stuff to spawn the Particles
this is what ive got so far:
@EventHandler
public void onShoot(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
Player p = event.getPlayer();
if (p.getItemInHand().getType() == Material.NETHERITE_HOE) {
Vector direction = p.getEyeLocation().getDirection();
Particle.DustOptions options = new Particle.DustOptions(Color.GRAY, 1);
p.spawnParticle(Particle.REDSTONE, p.getEyeLocation(), 50, 0,0,0, options);
}
}
}
uh sooo I store gens in a json file where the keys are like: world::XCoord::YCoord::ZCoord and then a base64 serialized string which is the gen.
But somehow, recently I found out that it is breaking some gens and turning them into normal blocks but the weirder part is that it has a pattern.
This also only happens when the json file has a big size.
Let me know if you need anything that might be helpful, either info or classes, etc.
Is there a way to fork a repository without forking it?
I still need to pull upstream changes occasionally, but github doesn't let you private forks
If you have access to a private repository and the owner permits forking, you can fork the repository to your personal account or any organization on GitHub Team where you have repository creation permissions. You cannot fork a private repository to an organization using GitHub Free. For more information, see "GitHub's products."
you misunderstood smh
he wants to fork a repo then make that fork be private
wait what? you don't need pro to create private repos?
Hm, strange, I thought you need pro. Thats nice then
just download the code and push it to another repo
oh wait but you want to do pull request
thats a problem
pull upstream changes, not make pull requests
^
but yeah that's pretty much it, clone locally and push to private repo
my bad
They are limited (I think you can have a maximum of 4 private collaborators)
how do I get the target block the player is looking at?
(like any distance)
._.
sorry
@NotNull
Block getTargetBlock(@Nullable Set transparent, int maxDistance)```
Gets the block that the living entity has targeted.
This method considers all blocks as 1x1x1 in size. To take exact block collision shapes into account, see getTargetBlockExact(int, FluidCollisionMode).
transparent - Set containing all transparent block Materials (set to null for only air)
maxDistance - this is the maximum distance to scan (may be limited by server by at least 100 blocks, no less)
block that the living entity has targeted
I am trying to make a plugin that allows players to have custom pickaxe enchants, one of those will be able to break 5x5 layer of blocks with the pickaxe and I want it to be compatible with the AutoSell plugin, I am using this method to break the blocks but it's not working sadly with the auto sell. Any help with it?
if (block.getType() == Material.BEDROCK) return;
ItemStack[] items = block.getDrops(item).toArray(ItemStack[]::new);
HashMap<Integer, ItemStack> restItems = player.getInventory().addItem(items);
block.setType(Material.AIR);
for (ItemStack itemStack : restItems.values()){
player.getWorld().dropItem(player.getLocation(), itemStack);
}
}```
autosell only listens to the BlockBreakEvent. so if there's no event fired for those blocks, then autosell doesn't consider them at all
Is there a way to make it work? Maybe manually sell the blocks or send a blockbreakevent?
Here you can find the API to hook into Clip's plugin AutoSell, which was made by vk2gpz - https://www.spigotmc.org/resources/62935/
Please do not contact Clip for help with this particular resource.
you might be able to use this api I guess 
declaration: package: me.clip.autosell, class: SellHandler
Alright thank you
oh btw if you have a copy of autosell you can just use that jar. it has an API built in.
and actually clip might just have an api on his maven repo
Alright 👍
Does anyone have any idea on how this works? (https://streamable.com/pq6w9l)
i'm making a score board and i'm having trouble adding entries to it. i'm expecting 500 entries but i end up with 7 because the Set is rejecting entries https://paste.gg/p/anonymous/679512cec12f4649a214d405f773e277
so far i've tried:
- overriding Entry 's equals
- converting Entry to a class and overriding its equals
- making entries not final and setting it to newEntries
i'm sure the copy Set has 500 entries and the queryResult Map gets 300 entries from the sql. any ideas would be appreciated
Fixed it, it was rejecting entries when Entry’s compareTo returned 0
oh maybe give this a read https://www.spigotmc.org/threads/tutorial-maps.136533/
but now I realise the map updates based on how you look. I thought you just want the part at the bottom. lol
that's probably just a lot of calculation. taking every block that's at the surface and painting based on a color you chose
since it doesn't look like that map even has shadows which normal maps take into account if i remember correctly
why doesnt it change the float's values in the Window class, but it changes in the other class?
Window class: https://paste.helpch.at/zukiwuqela.cpp
GameScreen class, where I change the floats: https://paste.helpch.at/arusugenuw.java
there are no errors, does anyone know why this happens?
did you try seeing things with a debugger?
wdym it changes in the other class?
since i see that u set R to 5.0 in GameScreen
so are you saying that it prints 0.0 in line 16?
idk
¯_(ツ)_/¯
no
if I print on that class it prints 5.0f
which is ok
soo
wheres ur print?
what did you try doing when looking with the debugger
then in setR just put ```java
new RuntimeException("HashCode: " + hashCode()).printStackTrace();
or use debugger but idk how debugger works 🤷
so
¯_(ツ)_/¯
looked at the instances and so
it doesnt change the values
so it has a completely different instance of the Window class presumably
apparently
why is the Window constructor public if it's also a singleton
just stupid me being well stupid
mhm
you're literally creating a brand new instance
completely unrelated to the static one
that's why "nothing" gets changed, it is changed but in the new instance you create
That's what I told him in off topic yesterday 
Hey !
How can I parse a placeholder in my java plugin ?
I'm using PAPI on my plugin and I wan't to parse some placeholders to use the return values
Thank you very much 😄
PlaceholderAPI#setPlaceholders
what's the fancy command to show java docs
;d
uhhhh
nvm
don't even have papi indexed lol

Thank you for the tips 😄
np, let us know if you have issues
So bad
Yes I have a small issue
Sometimes when I change the data of my player (I use luckperms and the luckperms PAPI) my placeholder is blank
This is my code to show the placeholder
Bukkit.broadcastMessage(" §f → " + PlaceholderAPI.setPlaceholders(player, "%luckperms_next_group_on_track_skygrades%"));
And this is the same when I want to parse the placeholder
/papi parse Teyir %luckperms_next_group_on_track_skygrades%
well then your code will also work sometimes x)
you can maybe add a check in your code
to see if it returns ""
and if it does replace it with something
No?
Yes, bc the bukkit message is just a log test
Ahhhh
Well maybe consider using something directly linked to your plugin instead of going through placeholders
whats stopping you from using the luckperms api?
Yes, but I have some problem with a placeholder, I can't replicate the placeholder return
(I'm not JAVA dev, I'm php, C++,C# and nodejs dev)
This is my biggest java plugin and I have some difficulties with the luckperms api
If you want an example, this is how I can get the user Highest rank in a track
public static String getHighestOnTrack(Player player){
LuckPerms luckPerms = LuckPermsProvider.get();
Set<String> groups = Collections.singleton(luckPerms.getPlayerAdapter(Player.class).getUser(player).getNodes(NodeType.INHERITANCE).stream()
.map(InheritanceNode::getGroupName)
.map(n -> luckPerms.getGroupManager().getGroup(n))
.filter(Objects::nonNull)
.max(Comparator.comparingInt(g -> g.getWeight().orElse(0)))
.map(Group::getName)
.orElse(""));
return groups.toString().replace("[", "").replace("]", "").toLowerCase();
}
But I can't replicate the placeholder %luckperms_next_group_on_track_skygrades%
Guys do you know if ita possible to create a custom entity class with custom behaviours and ai? so that i can check if I killed that type example Entity.SHARK only with plugins no datapacks or mods
so u probably could do it w a resource pack and extending entity. if u look at my github linked in my profile and look at KatCore, look at how I extended Player to CustomPlayer. You could do the same with Entity (I have, its just not uploaded)
@solemn ocean
Well, it doesnt look like you are getting the groups from a specific track
This is my new function
public static String getNextOnTrack(Player player){
LuckPerms luckPerms = LuckPermsProvider.get();
@Nullable Track track = luckPerms.getTrackManager().getTrack("skygrades");
luckPerms.getUserManager().loadUser(player.getUniqueId());
if (track == null || track.getGroups().size() <= 1) {
return "track == null";
}
List<Group> groups = luckPerms.getPlayerAdapter(Player.class).getUser(player).getNodes(NodeType.INHERITANCE).stream()
.filter(n -> track.containsGroup(n.getGroupName()))
.distinct()
.map(n -> luckPerms.getGroupManager().getGroup(n.getGroupName()))
.collect(Collectors.toList());
if (groups.size() != 1) {
return "size != 1";
}
return Strings.nullToEmpty(track.getNext(groups.get(0)));
}
But I have a lot of problems bc if I remove the group.size() check I have an out of bound and if I keep the check I have always my return
well that means the stream is returning an empty list.
so your groups is basically an empty list.
Okey thx
And how can I fix that ?
Bc my track is not empty → https://prnt.sc/EHEbnwPI349p
well I mean it just means that there are no groups meeting your conditions.
you'll probably have to debug that stream
instead of a stream maybe use a for loop or something and just debug everything you can
Okey thank you, I'm sorry I have a lot of problem with the Luckperms API
And the API is not very documented
they do have some documentation here https://luckperms.net/wiki/Developer-API-Usage
another thing btw. you don't need luckPerms.getUserManager().loadUser(player.getUniqueId());.
line 4 in your method
because your Player is online
since Player represnents an online playert
so that means luckperms already has the user loaded
Ah yes, this is just a small test *
I forgot to remove this line
But I don't understand why, I have some issues with this placeholder
(I have an empty return)
is this their placeholder? or is this yours?
Luckperms placeholder
but do you have a group set to yourself on that track?
bcz that's what the placeholder returns
Yes sire
otherwise it won't count it
it works?
How does one check for when a player falls on the ground?
the player damage event won't fire since they might not have fallen far enough
and Player#isOnGround is depricated iirc
and I'm out of other ideas
boolean isOnGround()```
Returns true if the entity is supported by a block. This value is a state updated by the server and is not recalculated unless the entity moves.
True if entity is on ground.
no its not
on Entity it isn't, on Player it is
how does what work?
interface Player extends Entity {
@Override
@Deprecated
boolean isOnGround();
}
that's how it works
yes. I know emily
smh my head. you should've know I Know by the way I asked the question
/s
so any clue how to detect when someone lands on a block?
check for playermove? ¯_(ツ)_/¯
but how do I know when they hit the ground?
y coord has changed and player is on ground I suppose?
I mean if you're moving vertically, and you are on the ground, then you weren't before that
how do I check the player is on the ground though?
make your own method to check I guess?
isOnGround..?
remember the fact that player#isOnGround is deprecated because it relies on the client, and it super janky supposedly
yes, and so is PlayerMoveEvent
it's called in the movement packet, which is also what determines if the player is on ground
do you have any other options?
just trust it
watching for when their velocity goes from a lot to zero
Well, when you're on the ground your vertical velocity isn't 0 either lol
Just check if players Y cords changed..
ground level is not equal @barren ore? why would you check if a player's Y cord has changed.
Oh wait I read that wrong
Check if player has a block underneath them on movement
If block is air their not on the ground
You can still use #isOnGround if it’s depracted
It will only cause issues if it gets removed in newer versions
Crouching off a ledge will mess with this, iirc
Found the thread, I was looking for. This should be beneficial to you @hard wigeon
https://www.spigotmc.org/threads/determining-block-below-player-subsequently-count-of-blocks.237734/
the problem is what if they're like above the block but the block is a slab?
like there's many checks you need to make
Well obv your going to have to do a lot of checks
Although this is outdated, it may fail on a slab (post from 2017)
If it’s not implemented into spigot or whatever he is using already
He will have to make his own method
Checking it
U can also check using y by seeing if players Y cords went down by X amount and then check if when player finally lands so his Y cords will stay the same
If he doesn’t want it to be fired if player steps down off 1 block if Y changed by -1 then don’t fire any event
And check for how much has the players Y went down by 🤷♂️
im trying to solve a sql syntax exception and i havent been able to find the issue for hours, can anyone see what is wrong with this query?
DROP PROCEDURE IF EXISTS addColumnToTable;
CREATE PROCEDURE addColumnToTable()
BEGIN
IF (NOT EXISTS(
SELECT NULL
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'tableName'
AND table_schema = DATABASE()
AND column_name = 'test') )
THEN
(ALTER TABLE BANKS_PROFILES ADD COLUMN test SMALLINT DEFAULT 0;)
END IF
END;
CALL addColumnToTable();
with the following error
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 9
in this case I'm using mariaDB, of which i know a much simpler query is available, but i want to be able to do this in MySQL too for accessibility
supposedly the issue is in the ALTER TABLE line but i cant tell whats wrong with it
hi
how do i get the name of a player in an event?
you get the Player, then getName on it
ex event.getPlayer().getName()
ok ill try that, tysm ❤️
is there any way to insert a variable into a string?
insert in what way?
add it in the middle of the string? or replace a specific character/substring
lets say I have:
dog = 5
print ("(dog) is after 4")
middle of string
so if your string already contains (dog) you can use replace.
int dog = 5;
String str = "(dog) is after 4";
System.out.println(str.replace("(dog)", dog.toString()));```
btw note that you can also do dog + "is after 4"
¯_(ツ)_/¯
i have it in a bukkit.broadcastMessage()
so it thinks that the variable would be an attribute
yes you can do Bukkit.broadcastMessage(dog + "is after 4")
If you want to format messages for instance, MessageFormatter exists
you are 100% correct tysm
does anybody know a good delay statement i could use?
wait() & .sleep all stop the server for the given amount of delay
https://www.spigotmc.org/wiki/scheduler-programming/
specifically runTaskLater
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ily ❤️
new BukkitRunnable() {
@Override
public void run() {
p.spawnParticle(Particle.FLASH, xInt, yInt, zInt, 1, 0, 15, 0);
}
}
.runTaskTimer(plugin, 20L * 10L /*<-- the initial delay */, 20L * 5L /*<-- the interval */);
how come i cant find symbol of plugin?
do you mean the plugin instance? you have to define it yourself.
Dependency Injection
Dependency Injection is a way of providing objects with the objects they need ("dependencies"). This is usually done with a constructor, but can also be done for individual methods
Read more here: https://en.m.wikipedia.org/wiki/Dependency_injection
Dependency Injection in Java:
https://paste.helpch.at/yijawupoju.java
Dependency Injection in Kotlin:
https://paste.helpch.at/esogakutod.kt
Are template strings a thing in java or only in javascript?? I mean the
Hello ${variable_name} !
I cant use the backtick in discord tho it formats it
Its called interpolation?
yes
Does anyone know modelengine? If I can implement it in my plugin??
kotlin has it though 
google is incredible
Ye i searched but i saw in a server they said you cant implement it so i asked here to know if it was true, im not good at api understanding still, im a newbie hahahah
from what i can see you can import it very easily with maven/gradle
"solved" this issue by simply looking for an exception when trying to select anything from that column and altering the table to add the column when such an exception occurred, i gave up trying to do it the "proper" way because ive been at this for a day and seemingly no one has any explanation
you asked a whole once
you can defo use it but there aren't any docs on how to use it
no javadocs etc
if (timer == 0 ) p.getWorld().playSound((xInt, yInt+10, zInt), Sound.ENTITY_GENERIC_EXPLODE, 1, 1);
for some reason the xInt, yInt+10, zInt is giving me errors
anybody knoi why
You have them in ()
even without () doesnt work
What error is it giving you?
cannot resolve
Needs a location not coords
any way i can use coords with a location
new Location(<world>, x, y, z)
ty ❤️ ill try it out
Guys i saw the persistent data storage class, is it good for custom stats saving of players like level, totalKills etc... or its better to use custom yml config files?
if((timer == 0) && (all.getLocation().getBlockX() > (xInt+10)) && (all.getLocation().getBlockX() < (xInt-10))){
if((all.getLocation().getBlockZ() > (zInt+10)) && (all.getLocation().getBlockZ() < (zInt-10))){
p.setFireTicks(20);
p.damage(1000);
}
}
using this to check if a player is in a square area when timer == 0
for some reason it doesnt work at all
if anybody knows pls lmk as i try to rsolve this
Use boundingbox
Guys, I was creating a plug-in of banknotes and I was looking for a way to recognize them since you can make them by default and infinite from the config. Do you have any ideas? I was thinking about saving the PersistentDataContainer String in the item of the note but thinking about it, maybe generating a lot of banknotes would be a small problem with this?
No, the one from Bukkit
d;spigot boundingbox
public class BoundingBox
extends Object
implements Cloneable, ConfigurationSerializable```
BoundingBox has 2 all implementations, 34 methods, 2 implementations, and 1 extensions.
A mutable axis aligned bounding box (AABB).
This basically represents a rectangular box (specified by minimum and maximum corners) that can for example be used to describe the position and extents of an object (such as an entity, block, or rectangular region) in 3D space. Its edges and faces are parallel to the axes of the cartesian coordinate system.
The bounding box may be degenerate (one or more sides having the length 0).
Because bounding boxes are mutable, storing them long term may be dangerous if they get modified later. If you want to keep around a bounding box, it may be wise to call clone() in order to get a copy.
i was wondering if its possible to make a web based shop in which you would buy with ingame currency? and how it would be done
why is the map empty when referenced in returnAxe?
errors: https://paste.srnyx.xyz/egixumekis.properties
code: https://paste.srnyx.xyz/dalodesaqu.java
debug msgs with color: https://srnyx.has.rocks/java_Wdzq9wXEum.png
your code is incomplete
Yeah, why not. You need to communicate with the game server
how so?
well you removed the important parts
such as?
the calling code
well you're creating new instances every time
but all of the map stuff is in the same class so shouldnt it not matter?
instances matter
so how can i fix?
i think i fixed it, ty!
With protocollib is it possible to create a WrappedDataWatcher with an entity I created? (so not a real entity)?
if not, how might one set the Entity Metadata packet's data manually? (https://wiki.vg/Entity_metadata)
glowPacket.getBytes()
.write(0, (byte) 0x40);
does not seem to make my entity glow
yes, you just do new WrappedDataWatcher()
and if you're on 1.9+ (i think its 1.9?), you have to do setObject(WrappedDataWatcherObject(0, Registry.get(Byte.class)), (byte) 0x40)
i think
I tried something similar to that with no success, let me try again
gotta recreate special xray in spigot, this is a pain
ah I had a small piece different
let me see
also idk if its Byte or byte
no dice, still no glow
can u show more of the code?
primitives don't have a class, and casting won't matter, java auto unboxes
PacketContainer glowPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
WrappedDataWatcher watcher = new WrappedDataWatcher();
WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Byte.class);
watcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, serializer), (byte) 0x40);
glowPacket.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
glowPacket.getIntegers()
.write(0, entityId);
try {
protocolManager.sendServerPacket(player, glowPacket);
} catch (InvocationTargetException e) {
e.printStackTrace();
}
seems like this should work 🤔
hmm
primatives don't have classes though...
oh you deleted
smh
and the entity spawned for it is right above
it's an invisible shulker if it helps
still i think it compiles
try doing byte.class
¯_(ツ)_/¯
i dont think it'll work though
but worth a shot
doesn't mention .class though
byte.class != Byte.class
at least it doesn't print the same things
and ur sure that the ids match?
¯_(ツ)_/¯
positive, let me send the whole thing
only thing i had different was that I used ProtocolLibrary.getProtocolManager().createPacket but I don't think it makes a difference
what version?
1.18.2
only the latest
oh wait
I missed something with lowercase byte
java.lang.IllegalArgumentException: No serializer found for byte
even better
ye use Byte then
oh wait
Don't you have to get the data watcher directly from the entity?
I have no entity, so I can't
u have to make it invisible with the metadata
wiki.vg shows the actual data that is sent through the network and how you should be (de)serializing stuff
no, it works how he does it
ah, easy enough
or it should
0x20 | 0x40 should work btw
You said you make an entity? so... entity.getDataWatcher()
Ah.
he makes a fake entity
packet side entity
I can do the math in my head 😉
math?
yeah, adding to hexadecimal numbers
Yes you can get a data watcher from it
how?
how?
SynchedEntityData syncedData = armorStand.getEntityData();
now I just need to implement all the logic for highlighting and unhighlighting blocks
that's cool
yeah I'm happy
this is good non-destructive xray
because the alternative that works on 1.18 is replacing all blocks with barriers client-side
what class is armorStand?
since note that he can't use NMS, CraftBukkit, or Bukkit entity classes
wait what is SynchedEntityData
DataWatcher when not mapped by spigot.
ArmorStand when not mapped by spigot.
yes but craftbukkit ArmorStand is backed by the nms ArmorStand which he doesn't have
if he makes an instance of it, it'll place it in the world
instead of being packet side
^^ all I have is an ID of the entity
Not the bukkit armorstand NMS armorstand
yes if he makes an instance of that, it'll be placed in the world
NMS stands aren't in the world
im pretty sure they are
not always, but in this case I specifically do not want one
I want it entirely packet side
although nms I don't think sends the packet
so players won't see it
so it's partially packet side ig
No entity exist in any world until you add them to it
right, and I don't want that
I just want to send packets
to tell the client there is a shulker
which I'm doing
successfully
Yes but dkim thinks it spawns an entity.
ah
at least i thought it did since I remember testing it a while ago
idk anymore 🤷
maybe ill experiment with it again sometime later
private void spawnStand(Location loc, String customName, Player player, ArmorStand stand) {
if(stand == null) {
ServerLevel level = ((CraftWorld) loc.getWorld()).getHandle();
ArmorStand nmsStand = new ArmorStand(EntityType.ARMOR_STAND, level);
nmsStand.absMoveTo(loc.getX(), loc.getY(), loc.getZ());
nmsStand.setNoBasePlate(false);
nmsStand.setNoGravity(false);
nmsStand.setInvisible(true);
nmsStand.setInvulnerable(true);
nmsStand.setCustomName(CraftChatMessage.fromStringOrNull(StringsUtil.get().colorize(customName)));
nmsStand.setCustomNameVisible(true);
this.armorStand = nmsStand;
}else {
this.armorStand = stand;
}
SynchedEntityData syncedData = armorStand.getEntityData();
List<Packet<?>> packets = Arrays.asList(
new ClientboundAddEntityPacket(armorStand),
new ClientboundTeleportEntityPacket(armorStand),
new ClientboundSetEntityDataPacket(armorStand.getId(), syncedData, true));
ServerPlayerConnection playerConnection = ((CraftPlayer) player).getHandle().connection;
packets.forEach(packet -> playerConnection.send(packet));
}
``` Full method.
d;map#remove
V remove(Object key)
throws UnsupportedOperationException, ClassCastException, NullPointerException```
Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.
The map will not contain a mapping for the specified key once the call returns.
key - key whose mapping is to be removed from the map
UnsupportedOperationException - if the remove operation is not supported by this map
ClassCastException - if the key is of an inappropriate type for this map (optional)
NullPointerException - if the specified key is null and this map does not permit null keys (optional)
the previous value associated with key, or null if there was no mapping for key.
Anyone know what this error could stem from?
the stacktrace isn't super helpful
https://paste.fredthedoggy.me/nmuKS3.rb
my one cast to byte seems fine
code?
oh oops
thought I attached it
mb
https://paste.fredthedoggy.me/wANcez.java is the relevant method
okay, apparently nevermind
I think I got it
it was my cast, it was just on the wrong part of the byte
wierd
why might my shulker be entirely invis?
it doesn't show it's head or anything
even without setting it to invis
it's wierd, it's kind of like the client knows something is there, but doesn't know to render it at all
Hey,
Im trying to use the Citizens-API in 1.18.2.
I added the dependency to the pom.xml. When I build my Artifact it and reload the Server it says :
Caused by: java.lang.NoClassDefFoundError: net/citizensnpcs/api/CitizensAPI
at de.claascode.casino.commands.SpawnNPC.onCommand(SpawnNPC.java:22) ~[Casino.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more
Caused by: java.lang.ClassNotFoundException: net.citizensnpcs.api.CitizensAPI
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:151) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
at de.claascode.casino.commands.SpawnNPC.onCommand(SpawnNPC.java:22) ~[Casino.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
... 21 more
The Code i used:
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.PLAYER, "ClaasCode");
npc.spawn(player.getLocation());
do I need to have Citizens on the Server? or do I need to replace the <repository> <id> from "everything" to something else?
yes you do need to have citizens on the server
You need it on there, otherwise when your code points to its code, it's going to throw a fit because that code doesn't exist (As you're seeing currently)
You could, but you shouldn't
you could but that doesn't mean it's going to work lol
Use an Npc library if u dont want to use citizens as a plugin
can you have diffrent left click command for people in diffrent groups?
What you mean by groups?
i am using luckyperm groups
You are talking about deluxe menus?
yes
use either of this#general-plugins or #general-plugins-2, this channel is for development related stuffs
i have it so that i have a gui thank ranks people up but i want the items to do somthing else when a staff memeber uses the rank up sytstem
any ideas why I am getting this?
var lastLogin = pdc.get(new NamespacedKey(plugin, "LastLogin"), PersistentDataType.LONG); this is literally line 67 in OfflineRewardsTask.java
I am quite confused at this moment lol
sounds like your code doesn't match the running plugin
well, I can assure you, it's that lol
could you explain me the error?
Since, the line it's printing doesn't make any sense.
well there must be a call to FlatFile#remove at line 67 in OfflineRewardsTask
and it isn't an error, it's just a stacktrace
Could you provide the code for OfflineRewardsTask?
ye sure
1s
be informed, not optimized at all xD https://paste.helpch.at/kaqahoyele.cs
according to the paste, this is your 67th line
totalMoney += amount * sellPrice * multiplier;
But this doesn't do any I/O Operations rather an arithmetic operation, so is there something changed in between the og stacktrace and the code?
you forget imports...
those also count
xd
Well, he didn't really forget anything
I have no way of knowing your imports or how much line it should cost, so you should have posted those...
you just didn't include them in your paste lol
Also are you using SimplixStorage?
FlatFiles is used by SimplixStorage, so there is no way a pdc#get() operation involves calling something from SimplixLibrary... So most prolly the lines might have changed....
The error isn't from what you say...
Wth, I will recheck and yes my bad, didn’t send the importats.
Bukkit.getOfflinePlayer(name).getPlayer().geUniqueId();
only works if player logged in in last 30 days
it will work, if the player has logged into the server once
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Bukkit.html#getOfflinePlayers()
There is no reason for that not to work
I mean if the player never was on Server
it cant get the uuid
so i would need to get it other way
then you would need to get it externally
What's the best way to check If player collided with a block?
On all sides?
Basically I have a skill which will launch player on a whatever direction and I want it when player bump into a block, it will deactivate the skill, right now I only have a timer to set that the skill is completed.
To store for example "currentMana" or "currentHealth" on a player that persists even on logout, (config files are not good for like custom health system: players have up to 10k health since its a scaling rpg and each time they get damage i dont like updating a config file for current health), do you think the best way is to use PersistentDataContainers? Like setting a NamespacedKey for "currentMana" and lower it when he uses spells etc so its binded to a specific player?? What would you do?
I would use PDC
So you don't need to deal with configs
Im just scared of losses of data
like if I remove by mistake the plugin, like I update it and it doesnt load for a bug, would all the data be lost?
Yeah I might just save the data onPlayerLeave in config and load onPlayerJoin PDC if not found, so on runtime I use PDC and backup on configFiles, maybe later Database
Wait, did you update the health and mana to the config everytime it changed?
nope
writing everytime in file someone uses spells or gets damage seems too much thats the reason
You only write to the config on player leave or server stops, I think that's the better option.
Not sure
Not really
Its safe to have a task that can save all the cached player data every 5 mins or 10 mins
Any ideas on how I could optimize the generateDrops() method? https://paste.helpch.at/ximepoyowi.cs seems quite badly coded rn tbh lol
I wanted to use streams but I am not that familiar with them and have no idea how I could do this
Just from a quick look, instead of looping through all the keys and getting values of each key again …you can use a map iterator
Also specifying the variable type would be a lot better in case of readability…
This is my personal opinion tho..might vary
I usually have no issues with it because the IDE shows what they are either way
just did that but doesn't seem to have changed that much
code wise
does it change a lot performance wise?
ty
Do someone know how to display a player the red screen of the worldborder for 1.18 ?
Hi, I wanted to create a /gm command with a GUI and it works for myself but when i want to set the gamemode of someone else inside the GUI it says it didn´t find the target (boolean hasTarget is false) but after i send the command it tells me if it finds the target and if the boolean is true. When I click on something it still says hasTarget is false. (https://paste.helpch.at/okexizepuk.java)
Does anybody know how to modify the permissions of a faction on FactionsUUID?
https://paste.helpch.at/hinejoparu.cs
anyone knwo what this means with Mongo? Sometimes it happens others it doesnt
You’re creating a new instance of the Gamemodecommand class in the listener class
Question, this is not Spigot related, just Java in general. So im taking my Java MTA and im stuck at this how to consume an instance of your own class. What exactly does this mean? Im not sure what all the formal jargin is to all this lol.
ngl i have no clue what that means
Yeah it's very ambiguous
I typically take consume to mean use or interact with, so it seems like a weird question
Just put Consumer<MyClass> 😂
Hello
why is this returning 0:
YamlConfiguration.loadConfiguration(new File(new File(configFolder, "data"), "slots.yml")).getInt("e907083e-5db6-41fc-9e32-5c4d99a08712.locks")```psuedo: `data.getInt("e907083e-5db6-41fc-9e32-5c4d99a08712.locks")`
`slots.yml`: ```yml
e907083e-5db6-41fc-9e32-5c4d99a08712:
locks: '100'```*ping if reply*
Make sure it's loading the file properly
https://paste.helpch.at/rufomezaru.bash Any idea's on this error?
I’m pretty sure it is, I’m using the same method for other files and they work. And I feel like it would return something other than 0 (such as null)
I’m just trying to add a constructor but it’s screwing up the whole plug-in.
How are you adding your plugin to the constructor?
Can we see the code for it?
All the error is saying is you can’t use getConfig on your plugin variable in the EnablePvPEvent class because it’s null.
remove ' from 100
Yeah was gonna suggest that but I wasn’t sure how it read it
Most likely thought it was a string though
integer is just a blank number without any " or '
Okay I tried some things and its not working again so here's the new error https://paste.helpch.at/azevakaquk.bash This is my Main class: https://paste.helpch.at/fiharikiko.java and this is my other class that is having the errors: https://paste.helpch.at/ehiqaburip.java
Is this your code?
Yeah
Pretz aka pretxels is my spigot name. It’s what I usually use for my projects
With spring boot im trying to update a value through a POST request, however when printing the body of the request it tells me like MyObject(valueOne= "value", valueTwo="value") It is as a HttpEntity at the moment, should the body not be in JSON form?
Do you have a “reload-message” key in your config.yml file?
It’s trying to translate the color codes there but it can’t find it
So it becomes “null” since it doesn’t exist, that’s where the “Cannot translate null text” comes from
Just make sure it’s in the config file and you should be good
Yup it’s there
perhaps just storing it in a variable?
if I deal damage to a armorstand it doesnt destroy right? like this ((Damageable) entity).damage(60, player);
I didnt like to check if the entity was an armorstand or whatever entity that has no health value, I would like it to work, I know there's entity.remove() but I think it doesnt call the EntityDeathEvent tho, and I need that
Could just call the event, but I don't think even breaking the armorstand calls that.
Could anyone help me optimize this by a ton? Currently having several lag spikes.
https://paste.helpch.at/esiyehigax.cs
specifically the generateDrops() method
already did some stuff some people here previously suggested, didn't seem to help a lot.
ugh. don't think it will improve performance a lot but still you don't need the online players?
Bukkit#getPlayer will return null if the player is not online
you need a null check instead
the way you store these generators might be something you want to improve tho. it seems like you just store the generators and each have an owner but maybe you just want to have the owner and put all generators under their uuid? so instead of going thru each generator, getting the player every time, just get it once and then loop thru all that player's generator?
So, currently I have all generators stored in an Hashmap with Location and Generator. Thoughts on "filtering" that into another HashMap that would contain the player and the list of generators he has. This would be done async on player join.
Would this maybe fix the issue?
tbh with you, I have no clue xD
You could probably do most of that async and have a queue of sync tasks, where you add a task that drops the items
And if possible split up the drops into different ticks if there are a lot.
this is already being executed async, or should be
no idea how I would do that.
If that’s async it shouldn’t cause lag spikes, and also you shouldn’t be able to drop items async I don’t think
might have done something wrong then.
yeah. that would most likely error out if it was async
bcz item drops are new entities
and spigot doesn't like you to work with entities async
bruh
does Spigot like anything you want to do
just noticed
eh
you might want to generate the drops and return them back and then drop them sync
wait what?
so make generateDrops return a map of location, itemstack
how would that even work?
in the sense of
I execute it async
but how would I get the values of what it returns and execute that sync
I am confused in that part
never did anything similar
that's a good question. xD
bruh
You can create itemstacks async just not drop items async
yes, that's not the issue though
I have no clue how I would even start with it
public void generateItems() {
Map<Location, List<ItemStack>) generatedItems = new Hashmap<>();
Bukkit.getScheduler().runTaskAsynchronously(<JavaPlugin>, () -> {
//generate items
generatedItems.put(location, list<itemstack>);
Bukkit.getScheduler().runTask(<JavaPlugin>, () -> //spawn items using map);
});
}
God that was a bitch to type on phone. I hate auto correct
Almost every char changed like 3+times
Does anyone know which is the maven dependency for NMS 1.18.1 snapshot?
thanks
ye, understand it now, I was mainly confused on how the structure would look like
What I wrote I basically how you could do it but there are better ways.
Structure wise just generate the locations and itemstacks async and switch to sync and spawn said items at the locations.
Any ideas? I’m so lost
what's line 55 in the EnablePvPEvent class?
e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', Main.plugin.getConfig().getString("deactivation.deactivation-countdown" + x[0])));
Main.plugin.getConfig().getString("deactivation.deactivation-countdown" + x[0]) is returning null
or is null
d;spigot ConfigurationSection#getString
@Nullable
String getString(@NotNull String path)```
Gets the requested String by path.
If the String does not exist but a default value has been specified, this will return the default value. If the String does not exist and no default value was specified, this will return null.
path - Path of the String to get.
Requested String.
If the String does not exist and no default value was specified, this will return null.
uhm quick question, since the first part is async, the drop items part won't wait for the first part, so it will drop nothing?
or am I wrong?
I would have to check if it finished
The sync task is the last thing in the async task so it runs last.
And the async task schedules the sync task so it will run after the async task anyways
ye, already figured that out, in your example you placed it outside hence why I was confused
No it's inside
👍
Hey how can I change Skin of a Player so everyone see it? my Code don´t work
how can I detect if a player is looking at another player?
old but probably still working https://bukkit.org/threads/solved-get-the-entity-a-player-is-looking-at.40592/#post-793498
can you help me figure out what "plugin.target" etc
Do i need to shade for hikaricp?
or can I somehow check if a particle hits a Player or shit?
nvm. just use Entity#getBoundingBox and then check if particle is inside it
and then the Vector is the Location of the Particle?
tysm
ohhh alright, ty!
i am back with a other hikaricp problem, so basicly i am trying to store an int on the uuid of the player (in the database) so
i have this class: PlayerModel.java(https://paste.razerstorm.be/axifayuhug.java) this class is where i add the integer to the database
the problem i have is that after using the addGrindCoins method more then 10 times my server freezes and crashes
this is the code in the listener that triggers the method in PlayerModel.java:
PlayerModal playerModal = plugin.getModalManager().getCustomPlayer(player.getUniqueId());
playerModal.addGrindCoins(5);
player.sendMessage("Je hebt nu " + playerModal.getGrindCoins() + " grindcoins!");```
a video of this problem: https://youtu.be/--1UI-jtvw8
well usually you want to not do that. database requests can be pretty expensive. instead cache the data and save it every 5 minutes or so
but a database should be able to handle this right?
I mean it handles it but your server doesn't
but it always crashes after 10 times
thats just weird
i just did it 5 times and waited like 10 - 20minutes and did it 5 times again and it crashed (even after waiting so long)
Hey since I kinda suck at Math can someone help me
When I use player.getTargerBlock to get the Location the player is looking at it gets a Location of the block wich is always smth like this 5.5 5 5. Is there a way to get the exact Location where the Player is looking at? With max distance ofc
there's getTargetBlockExact
try that one maybe?
nvm. that also gets a block lol. not a location
no idea what the exact is for then
weird
i think I really would need to calculate the Location based on yaw and pitch, then go foward etc
There's LivingEntity#rayTraceBlocks
but im not able to do that since Math = hard
you can get the location from the result
LOL Thank you so fucking much ❤️
is there a way to get the Location even if its air tho
like now I need to aim at an Block within the MaxDistance
mm I don't think so
I mean
"can you", yes you can
not with that method tho
maybe with normal rayTrace tho
uh is there even a "normal" rayTrace?
there actually is player.getWorld().rayTrace()
im trying that rn but it doesnt seem to do the Job
I GOT IT
Location end = player.getWorld().rayTrace(player.getEyeLocation(), player.getEyeLocation().getDirection(), 15, FluidCollisionMode.NEVER, true, 5, null).getHitPosition().toLocation(player.getWorld());
Question: How to spawn block break particle like naturally?
i tested with spawnParticle method
it's looks like not natural block break animation (particle not spread like vanilla)
but Origin Realms is
Here is my test (with vanilla command for now)
https://youtu.be/RX92GThYIVM
i think Origin Realms server is using BlockDamageEvent to trigger player is start digging custom block
and put SLOW_DIGGING potion effect for 255 w/Packet to bypass slow arm swinging when apply potion effect (for prevent player digging block by natural)
and play block cracking stage to block, and make it break when block cracking stage is done
this my opinion that make me ask that question
because i don't think Origin Realms server make player break custom block with normal method
Err you don't need to spawn the particles yourself I don't think
I use this plugin, I don't see anything here about particles https://github.com/oraxen/oraxen/blob/master/src/main/java/io/th0rgal/oraxen/mechanics/provided/gameplay/block/BlockMechanicListener.java
I use that method because i want to make custom mining, block place, block break sound
Oraxen have option to set place or break sound
But it's can't do custom mining sound
and it's don't have particle when i break it 😂
https://youtu.be/wIMBLqyI71w
Thats odd, my blocks have particles
anyway, I can solve particles problem
but.. to do custom mining sound
i think it's should use this method?
Anyone that used ModelEngine's api and knows why doing
modeledEntity.getNametagHandler().setCustomName("head", ChatColor.BOLD + "" + ChatColor.YELLOW + entityName + " " + ChatColor.RED + CombatManager.getCurrentHealth(mob) + "❤");
System.out.println(modeledEntity.getNametagHandler().getCustomName("head"));```
returns null on the sout and so doesnt show the custom name above the entity?
Question, so im trying to add the guids plugin to my maven to use the api but im getting this error: Could not find artifact dev.triumphteam:triumph-gui:pom:3.0.3 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
Update to 3.1.2
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>glares-repo</id>
<url>https://repo.glaremasters.me/repository/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.glaremasters</groupId>
<artifactId>guilds</artifactId>
<version>3.5.6.0</version>
</dependency>
</dependencies>```
guilds
^
Ah I see, transitive thing, because the error is not coming from there
Glare will probably need to bump gui version and release another version of guilds
So should i try a different version of Guilds?
If that's the latest then I don't think any will work
Thats not the latest i dont think
Actually 3.5.6.4-SNAPSHOT has the right gui version
The POM for co.aikar:acf-paper:jar:0.5.1-SNAPSHOT is missing, no dependency information available
thats the error i get now
Glare why are you making all this transitive 
-_-
Add
<repository>
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
That fixed it thank you 🙂
Hmm doesn't seem to be transitive
Btw make sure guilds is <scope>provided<scope>, you don't want to shade the plugin
Ok, also as here https://wiki.helpch.at/glares-plugins/guilds-w.i.p-migration/developer-api#hooking-into-the-api the GuildsAPI api = Guilds.getApi(); doesnt seem to work. I get a Cannot resolve symbol 'GuildsAPI' error on GuildsAPI
"yes"
"yes"
I mean
it's as worth as you make it be
if you really love using brig and absolutely thrive when using it, then sure
Blessed that Sponge uses brigader tbh
If my project used spigot instead of spigot-api how would I make it so jitpack would be able to compile that jar? Or is there a better place to host my libraries?
You can't use JitPack with spigot since there is no public repo for it
Sad. So I just gotta manually add the jar to my projects then I suppose?
no, since jitpack has to compile it iirc
so it'll just error out bc of the craftbukkit/nms code
so I think that you'd have to either use reflection or use maven central
Alright thanks, I'll look into maven central. The only NMS in the plugin is just so send a scoreboard packet.
did u figure it out yet? if not ill copy and paste my maven central tutorial here
¯_(ツ)_/¯
no I did not figure it out yet 😂
ok this tutorial isn't perfect since maven central takes a bit of time to setup and I didn't feel like going to every little process, but better than nothing
I hope
if you want to do maven central:
sign up: https://issues.sonatype.org/secure/Signup!default.jspa
apply: https://issues.sonatype.org/secure/CreateIssue.jspa?issuetype=21&pid=10134
- summary can just be group id, same with description (since it's required)
- group id is, again, group id (ex: io.github.dkim19375 - com.github is replaced with io.github)
- project url, a project that you'll upload to sonatype, im assuming its so that they know you're not botting or anything, you only have to include 1 project
- scm url, also known as source control management - if you use github i just did https://github.com/username/project.git and they accepted
- username is your jira username for sonatype
- already synced to central: no
then within a few minutes you'll get a reply which will ask you to verify ownership, for github they just make you create a repository with your ticket name (took 3 minutes for me)
then you reply saying that you did it, then you'll have to publish an artifact, then tell them that you published it so that they can enable syncing (took 6 minutes for me)
btw once you got accepted, you have to upload your pub key:
open cmd prompt and if you type gpg or gpg2 does respond?
with something other than ```
'gpg' is not recognized as an internal or external command,
operable program or batch file.
If it doesn't, then install this: <https://sourceforge.net/p/gpgosx/docu/Download/>
then run `gpg --full-generate-key` to generate a key, with 4096 bit RSA if it asks you to choose
Then do do `gpg --list-keys --keyid-format=long` to view the key you just made, then to export it to a file, run: `gpg --export --armor KEYIDBLAHBLAHBLAHBLAHBLAHBLAHBLAH > key.pgp` (this is our public key) - make sure to *not* include `rsa4096/`
Then publish it on https://keyserver.ubuntu.com/#submitKey and/or https://keys.openpgp.org/upload (make sure it says `PUBLIC` at the top - you don't want to upload your secret key!)
Now run `gpg --list-secret-keys` and export the secret key: `gpg --export --armor KEYIDBLAHBLAHBLAHBLAHBLAH > seckey.gpg` - don't share this
Once you've gotten that, go to `%USERPROFILE%\.gradle\gradle.properties` and here's what I have: ```properties
mavenUsername=dkim19375 - from sonatype
mavenPassword=from sonatype
signing.keyId=last 8 chars of key id
signing.password=password of key
signing.secretKeyRingFile=seckey.gpg
SIGNING_KEY=last 16 chars of key id
SIGNING_PASSWORD=password of key
OpenPGP Keyserver
ok sorry for text wall mods
but
Applying to your build.gradle(.kts):
Single module:
build.gradle:
example: https://github.com/dkim19375/DkimBukkitCore/blob/master/build.gradle
You need: https://paste.helpch.at/labuvafipe.build.gradle
build.gradle.kts:
example: https://github.com/dkim19375/ItemMoveDetectionLib/blob/master/build.gradle.kts
you need: https://paste.helpch.at/xijikevami.build.gradle.kts
Multi-module:
build.gradle:
example: https://github.com/dkim19375/Bedwars/blob/master/build.gradle & https://github.com/dkim19375/Bedwars/blob/master/api/build.gradle
you need: https://paste.helpch.at/sehofufacu.build.gradle in your base build.gradle, then apply https://paste.helpch.at/cedugoqaru.build.gradle
<reserved for future so that i dont spam this again if i need to edit>
🤷
made this a while ago so hopefully its helpful
haven't looked at this in a while
alright lol I'll figure it out
ok
What's the best way to get which item was used to throw which throwable entity?
eg. What item was used to throw a snowball
or egg
or enderpearl
so I can read the data once it's been thrown
and add something to the entities data
and in turn do something when it lands
Paper has PlayerLaunchProjectileEvent which has all that info (player, projectile and item stack)
though I don't know if for arrows it returns the bow or the arrow item, but for an arrow projectile there's AbstractArrow#getItemStack or something like that idk
Spigot has that too doesn't it? If not its just ProjectileLaunchEvent
Yeah its just ProjectileLaunchEvent
The best way would be replacing the wooden step and hit sounds with nothing and faking the rest with the blockdamageevent or packet
Hey, uh, why am I getting this?
processResources {
eachFile {
if (file.name.endsWith(".yml")) {
expand version: version
}
}
}
yeah but it doesn't go you the item that was used
give*
event.getShooter().getInventory().getIteminMainHand() With the proper checks too.
Check both hands 😉
I typed it as you sent that message
You can test for enderpearls lol
not if it's a single item you hold
You can test for anything with that event
lol how
you literally can't check because the single item you had already got consumed
Test that. Last time I checked even when a bow breaks you can view the item.
bows sure, every other throwable, not so much
like this
Ill test it when I can cause I never had an issue with this.
@lyric gyro
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile projectile = (Projectile) event.getEntity();
if(!(projectile.getShooter() instanceof Player shooter)) return;
ItemStack item = shooter.getInventory().getItemInMainHand();
if(item == null) item = shooter.getInventory().getItemInOffHand();
ConsoleOutput.debug("Item: "+(item == null ? "null" : item.toString()));
}
[DEBUG] Item: ItemStack{SNOWBALL x 5}
[DEBUG] Item: ItemStack{SNOWBALL x 4}
[DEBUG] Item: ItemStack{SNOWBALL x 3}
[DEBUG] Item: ItemStack{SNOWBALL x 2}
[DEBUG] Item: ItemStack{SNOWBALL x 1}
Map<Listener, CustomItemDefinedMgr<?>> swapped = customItemTypeMap.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));```
This java code has no error.
```kotlin
val swapped = customItemTypeMap.entries.stream()
.collect(Collectors.toMap(Map.Entry::value, Map.Entry::key))```
But this kotlin code has an error on both Map.Entry saying "2 type arguments expected for interface Entry<out K, out V"
Why is it?
you have to do Map.Entry<K, V>::blah, it's a bit of a pain
however a more idiomatic way of doing this in kotlin would be customItemTypeMap.entries.associate { it.value to it.key}
BiMap moment
package commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Commands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) { return true; }
Player player = (Player) sender;
if(command.getName().equalsIgnoreCase("commandthing")) {
//stuff
}
return true;
}```
"equalsIgnoreCase" doesn't work. Anyone know why?
Forgot to, one second
and then you wouldn't even need to check if it equals commandthing
Anyone able to help me compile PlotSquared V6? I get an Unresolved refernece: grgit even though I have import org.ajoberstar.grgit.Grgit imported in the build.gradle.kts
Wait, what?
Haven't you watched a tutorial or something before starting to code?
If u register a command, then the execute method would be called for that method
how do i make an endpoint request to a website and put the result in a placeholder?
Still can't figure out how to compile it
Question, so im trying to use the Guilds API, but im getting this error not too sure why
If api is null I would assume your either not calling it correctly or it hasn't initialized for some reason
make sure you (soft)depend on guilds and that you call getApi during/after onEnable, rather than putting that in a field directly
ok
like you can put it in a field, but do that in onEnable
When i softdepend, im still getting the same error
SHould i only do that in my main class?
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
