#help-development
1 messages · Page 598 of 1
is that so hard to write own impl of roman
nah
why do it if a perfect implementation is already existing
it worked before i made my skill classes extend an abstract class Skill
I'm tinkering around with making a website run on the server; For a nicer UI... well... it's not going smoothly XD
The site isn't even loading, just getting the raw HTML displayed to the screen
bro, you have a point and that's how programemers should react,
I just don't like it, I think the whole fun of programming is in those kinds of pieces/quick engineering.
I don't think we ultimately program just to make something work.
Plus, the more dependencies / code that ain't yours you use, the more prone to bugs you're about to face, maybe not right now but maybe in some future.
its not a dependency
sure, but we ain't in a corporate rn, we code to have fun
and learn
nah i code to get shit done
personally i dont want to spend 4 hours working on a roman numeral implementation when i can just copy and paste an answer from stackoverflow
dw
well i would have graet fun making it personally,
typically the kind of program i enjoy doing
👍🏿
it doesn't work for him heh
hes probably using it wrong
so instead of brainlessly copypaste he can think
it worked before i made my skill classes extend an abstract class Skill
the other day i made a "maths expression parser", which can calculate maths expressions based on parameters/exact stuff
this shit must exist already but making it myself made me so proud & happy
well if you look at the entire project of the guy, you might find a lot of brainless stuff heh
https://github.com/redempt/crunch check this out very cool
yes because its my second plugin
ik you are new to it yeah
The key is to spend 4 hours reinventing the wheel when you are doing a commission and being paid hourly

like i copy pasted the skill level up message 4 times
BUT SOMEONE HELP ME WITH MY PROBLEM
please
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.TreeMap.floorKey(Object)" is null
at com.amirparsa.hypixelskillcore.Utils.RomanNumber.toRoman(RomanNumber.java:31) ~[?:?]```
These lines should give you all the info you need; Look why there could be a `NullPointerException` in line `31` in your `RomanNumber.java` class.
the problem is surely from the abstract class i made for all the skills. i just dont know why. it worked before extending all my skill classes to the skill abstract class
at com.amirparsa.hypixelskillcore.Commands.SkillsTextCommand.onCommand(SkillsTextCommand.java:21) ~[?:?]
In that case, check line 21 in your SkillsTextCommand.java class, maybe that'll give you more insight. More I cannot deduce from just an error msg.
i provided some code after sending this message
idk what line 21 is
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Farming " + ChatColor.AQUA + RomanNumber.toRoman(playerAccount.getFarming().getLevel()) + ChatColor.DARK_GRAY + " " + playerAccount.getFarming().getXp() + "/" + (playerAccount.getFarming().getStarterXp() * playerAccount.getFarming().getLevel()));
Your toRoman method will break if you pass it a 0
yes i know but the skill level alwaqys starts at 1
Are you sure about that
It's most likely that you pass to the function toRoman an integer with a value of 0 or so, since you try to find the lowest key, which is 1 the map can't find anything lower than 0, so it returns null?
yes
^
Because the error you are getting can only happen with a number < 1
public class Farming extends Skill implements ConfigurationSerializable {
private int STARTER_XP = 150;
private int level = 1;
private int xp = 0;
print out playerAccount.getFarming().getLevel() just to be sure
That’s basically the first step of debugging
its wasting time bcz my pc ony has 6gb of ram, 2gb reserved by windows, just 4gb to work with. i cant have all of those apss open at once
Or better yet, use a debugger, like Intelijis inbuilt Debugger and Breakpoints.
https://www.spigotmc.org/wiki/intellij-debug-your-plugin/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Meh
It's wasting more time, if you are unwilling to debug your own code. Yours and ours.
Most of the time a debugger isn’t worth the effort
I do alot of trial and error coding... hehe
when i run my project it just builds it. it doesnt output anything
Did you read the article?
package com.amirparsa.hypixelskillcore;
import java.util.Map;
public abstract class Skill {
private int STARTER_XP;
private int level;
private int xp;
private double damageRewards;
private double healthRewards;
private double defenseRewards;
private double moneyRewards;
public abstract boolean calculateLevelUp();
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
public int getXp() {
return xp;
}
public void setXp(int xp) {
this.xp = xp;
}
public double getDamageRewards() {
return damageRewards;
}
public double getHealthRewards() {
return healthRewards;
}
public double getDefenseRewards() {
return defenseRewards;
}
public double getMoneyRewards() {
return moneyRewards;
}
public int getStarterXp() {
return STARTER_XP;
}
public Map<String, Object> serialize(){
return Map.of(
"level",level,
"xp",xp
);
}
}
```the whole skill abstract class if that helps
You can use Intelijis Debugger, connect it to a server, like your local test server and get infos about the code you are running
why do u have 15 fire foxes open
Just print out the level of the player in the command, that'll be quicker, cause I can't help any more than I have.
I don't, Firefox is just a bit weird sometimes
its every browser
make the getters final cus u prob aint returning anything else
yea, got plenty of those
Didn't actually know that
those values change
my intellij cpu & ram usage be like:
yea but it still returns the same thing
the getters can be final
Shh don’t confuse them with final methods
public final int getLevel() {
return level;
}
literally still returns level
level aint final
I just learned what they did last week and I've been coding in java for 4 years now XD
same but with abstract shit, picked up a java course, getting certificate and shit
i use a shit ton of abstract now
nothing else rlly new tho
like only that u can give names to while loops and shit
I started going away from abstracts and doing more stuff with interfaces
and then break them by name
wait a minute...
is it normal that im defining the variables both in the abstract skill class and the skill class?
no
no?
what
No
how can i fix that
Only define them in the abstract class?
dont define them
bcz when i do level = 69; it gives an error
cus its private
but i have to change them
use setLevel(69)
Use getters and setters to change them
when i make it public it breaks my plugin
u literally made a function for it
Or make them protected instead of private
keep it private
use your functions
oh ok
literally there for a reason
if only someone offered free java lessons 😭
Who’s java
just use kotlin smh
I’d rather not
So is java
for changing the values outside of the class
you can also use it, inside the class
wow
shocker
i knew that
but kotlin faster
but kotlin kotlin
Yes, that’s even more reason to not use it
🤓
i find it confusing sometimes that kotlin does not have the keyword "new"
It ain't but oki
🤓
even tho i dont even use kotlin but hey
I don’t see a reason to learn a new syntax just so I can… uhh?
Have an extra dependency?

sometimes and sometimes not
yea idk
i dont use it
havent used it in 5 months
only thing i would ever use it for is android shit prob
Like why would I use a join message plugin that’s 20kb when I could use one that’s 2000kb
The bigger one must be better
More dependencies = more code = more problems.
That’s why I shade random stock photos into my plugin to boost the size
lmao
if thats the size, it probably has a web panel with 10 customizable database setups, a custom coloring system, an api, a discord bot that announces player joins and it works with vault api, worldedit, all the claim plugins and it has support for minecraft 1.0
Gotta start doing that if it means better public perception.
Tbh I think the main thing to boost downloads is having async in the title
Or maybe some ✨ dazzle ✨
i should prob transfer my party system to a different plugin than my main one
since its in a dungeon crawler plugin?
I hate plugins that use emojis in the title. Hate the trend, hate that people are stupid enough to fall for it too.
✨ Deluxe Async PogSpigot v65.0.1 ✨ (25% SALE!!! 💰)
so real
commits die
✨ Deluxe 🔒 Secure 🎈 ASYNC 🎉 Party 💯 System 💭 + Chat 🔌 Plugin 🇻 53.32.31✨ (50% SALE❗ 💰)
Just end me now. PLEASE
You gotta bump the version up
and double the main price
High version means more updates which means better
fixed
forgot to add async
calm your tits that convo was 30 minutes ago
I will not
aggressively shaking
How to enrage any java dev: mention kotlin
I used kotlin, and I prefer Java
hi so im making bungeecord plugin and i came accross ServerConnectedEvent and im curious can that event be used for when player joins server in a network or when joins from for example factions to survival can it be tracked with that event ?
fixed it
meanwhile my plugins
fr
somebody any help ?
true
best names
Skyblock
Store
NukerFall
carefall
This is rocket league!
FREE JAVA LESSONS
JREE FAVA LESSONS
what the hell is a rpg respawn system?
This is old
should be TESO respawn system
where when you die you turn into a ghost
is it just getting teleported when u die
and can be reviwed for soul gems
or that
i can mass produce plugins but idk how to work with configs
by yourself or by other players(cheaper)
RPG = role playing game
i know that,
also gl amir
so unless you are respawned you are a ghost
but idk what they meant with the respawn system
gotta go test my plugin. wish me luck
oh
.
no
why?
cus i already did
bruh doesn't know how to work with configs
oh wait i forgot to build my plugin
anyone familiar with making bungeecord plugins ?
.
really simple question just asking someone who has experience
javadocs: exists
ServerConnectedEvent
Not to be confused with ServerConnectEvent, this event is called once a connection to a server is fully operational, and is about to hand over control of the session to the player.
where can i here read if it is only when player connects to the proxy server or if it can be used when player connects to any server
?jd-bc
is there a NetworkConnectedEvent? if there is then this is for server switch
what exactly do you want to do
so you ask this
no no
forget it
sometimes it is dumb to ask in this chat for help from someone with experience because there will be at least one dumbass that will say read docs like i didnt even try to read the docs
if it is written in docs and i have clear answer why would i even come ask here about it 🤦🏻♂️
yes and in docs it is not written does it trigger only when player is joining proxy server or does it trigger when player joins any server that is in network
i know there is switch event but also dumb since you dont have past server where player is from you can only get where is he switching to
still
what exactly are you trying to do
when teleporting an entity do i need to be checking if the chunk i'm teleporting it to is loaded?
unsure if that is done by bukkit automatically
so i want to know can that event be used to get to which server in network is player connecting or it is only when he joins proxy and is being sent to lobby
no
just player.teleport(location)
i'm asking about entities though, i know that when a player is teleported they will automatically load the chunk but am unsure if the same applies for other entities
done it and it is the dumbest thing ever but okay nvm
is there isOp() function for ProxiedPlayer
because i cant use it and idk if it is something on my side
I can't say I've worked with this myself but you can't op someone on a proxy so I doubt it's a thing
try it out and hope people in mojang are not dumb and that it is possible
didn't know mojang were the devs of bungeecord
they were replying to my unrelated issue aha
he is not talking about bungeecord
?pdc
ServerConnectedEvent is triggered when a player join the bungee-network
ServerConnectEvent is triggered when a player got connection to the actual spigot server
ServerSwitchEvent is triggered when a player switched servers
not to be that guy but this was literally the result from 1 search
it is not written if ServerConnectedEvent is triggered on only bungee-network join or when joining any server in network
Player player = event.getPlayer();
Material holdingType = player.getInventory().getItemInMainHand().getType();
if (player.isSneaking() && (holdingType == Material.POTION || holdingType == Material.SPLASH_POTION || holdingType == Material.LINGERING_POTION)) {
...
}
any way i can shorten this
without listing all 3 potion materials
I mean
You can get name and check if it containts Potion
an enumset is probably fine too with it listed
well thats a lot slower
true
Do you really need the speed though?
not an enumset tho
no it just bothers me lmao
yeah i could do that thx
if i save a block in a pdc and then place it, will it still be in the pdc?
Where is the block stored
Like where is the pdc?
blocks don't have PDC
Nope
Manual 
If you want to store pdc in a block you can use the chunk pdc
block entities have PDC, so if this block has an associated block entity, then you could manually move the PDC info over from the stack to the block entity
And map it to a coordinate
This too
i want to make a custom effects block or whatever, like giving someone a quartz block that gives them speed2 for example, and i want them to be able to place it aswell
and breaking is really easy if i can somehow identify my block after its been placed
Use PDC like we told you too above
whats a chunk pdc?
Pdc for chunks
^
And then do your stuff
Inject object which have coords of block then other props
Deal with bytebuf
All you need to do in this case is save the location of your blocks in the pdc
and where does the chunk come in
wouldnt it be world and coordinates
Block#getChunk ?
Better to store it in the chunk so it's only loaded when needed
Like why have a bunch of locations loaded when the chunks they are in aren't
i still dont understand how i would save something in a chunk
like does a chunk have its own pdc?
Yes
Yez
Is there a way for my plugin to place a CreatureSpawner block where the player is?
Get the location of the player is and set the block to spawner?
Takes Material and not Block or something like CreatureSpawner
is there an event for when a player swaps an item from main to off hand or vice versa ? (out of the inveentory)
Yeah material is spawner
No I mean Material.SPAWNER
Then I can't set the type since .setType return void and not the block
setmaterial then apply props
You'd get the block again after setting it
I'm trying to boost a potion's level but for reason meta.hasCustomEffects() is always false
PotionMeta meta = (PotionMeta) holding.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(plugin, "boostAmount"), PersistentDataType.INTEGER, multiplier);
// Boost effect level of potion
if (meta.hasCustomEffects()) {
for (PotionEffect effect : meta.getCustomEffects()) {
int newAmplifier = ((effect.getAmplifier() + 1) * multiplier) - 1;
meta.addCustomEffect(new PotionEffect(effect.getType(), effect.getDuration(), newAmplifier), true);
}
}
holding.setItemMeta(meta);
packetplayouttitle for 1.20 not working any ideas?
Why are you using nms for titles
Cannot invoke "org.bukkit.inventory.ItemStack.getEnchantments()" because "tool" is null
Why do I get this error when trying to get the item the player used to mine a block with BlockBreakEvent? (I am using event.getPlayer().getItemInUse())
Does the player have an item in the hand
I mean yea since im testing with a pickaxe
any ideas? I tried messing with getBasePotionData:
PotionType potionType = meta.getBasePotionData().getType();
if (potionType.isUpgradeable()) {
meta.addCustomEffect(new PotionEffect(potionType.getEffectType(), ????), false);
}
But how am I supposed to get the original duration and amplifier?
@EventHandler
public void onAnvilPrepare(PrepareAnvilEvent e) {
Inventory inventory = e.getInventory();
ItemStack leftItem = inventory.getItem(0);
ItemStack rightItem = inventory.getItem(1);
if (leftItem != null && rightItem != null) {
// Get the enchantments on both items
Map<Enchantment, Integer> leftEnchantments = getAllEnchantments(leftItem);
Map<Enchantment, Integer> rightEnchantments = getAllEnchantments(rightItem);
ItemStack resultItem = stripEnchantments(leftItem.clone());
// Add the left enchantments
for (Map.Entry<Enchantment, Integer> entry : leftEnchantments.entrySet()) {
Enchantment enchantment = entry.getKey();
int leftLevel = entry.getValue();
// If the enchantment is on both items, add the higher level or increment the level
// If the enchantment is only on the left item, add it
if (rightEnchantments.containsKey(enchantment)) {
// If the levels are different, add the higher level
// If the levels are the same, increment the level
int rightLevel = rightEnchantments.get(enchantment);
if (leftLevel != rightLevel) {
resultItem.addUnsafeEnchantment(enchantment, Math.max(leftLevel, rightLevel));
} else {
resultItem.addUnsafeEnchantment(enchantment, leftLevel + 1);
}
} else {
// If the enchantment is only on the left item, add it
resultItem.addEnchantment(enchantment, leftLevel);
}
}
// Add the right enchantments
for (Map.Entry<Enchantment, Integer> entry : rightEnchantments.entrySet()) {
Enchantment enchantment = entry.getKey();
int level = entry.getValue();
// If the enchantment is only on the right item, add it
if (!leftEnchantments.containsKey(enchantment)) {
resultItem.addEnchantment(enchantment, level);
}
}
e.setResult(resultItem);
}
}
When I put a Sharpness V sword and Sharpness V book in, it worked. But when I put a Sharpness VI sword and Sharpness VI book, the result is a sword with Sharpness VII but does nothing when I click it
Like I can't pull it out of the anvil
Oddly enough, two Sharpness VI swords work
The Sharpness VII result sword can be pulled out
It seems like enchanted books do not work without their enchantments being meta enchantments
Good afternoon! I have a question.
Now I know this might be very frowned upon, and might not exist, but are there any golang bindings available for which to make spigot plugins with? I know I should be using Java for plugins in general, but I cannot code in Java to save my life. I've gotten used to whatever syntax golang uses, that I cannot even read Java code.
Hello I have a question.
When applying patches using applyPatches.sh file it errors out at:
Applying: Spigot Configuration
error: sha1 information is lacking or useless (src/main/java/net/minecraft/server/dedicated/DedicatedServer.java).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0003 Spigot Configuration
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Something did not apply cleanly to Spigot-Server.
Please review above details and finish the apply then
save the changes with rebuildPatches.sh
I couldn't figure it out.
Are you compiling your own spigot jar?
Yes.
what's the reason for that?
Would make sense yeah
.
Make sure apply patches leads towards a work directory fron build tools for the nms version
hey nerds how do you display a barrier particle in anno domini 2023?
I'm just curious is all, not meaning to tell them they shouldn't compile their own jars
Cry (idk don't hurt me bearded mom)
It’s been turned into a particle that can display any block
block_marker?
Yeah that one
gotcha
thanks nerds
except for you @river oracle , you're not even a real nerd
you're getting the atomic wedgie
Still the same issue
Send the command you ran
I don't know if its the right command but:
./applyPatches.sh
```It should do it automatically right?
You need to provide a path to the work directory for the current version
^ what I was truna say
Would it be feasible to make a plugin that adds a sky block, and an end portal block?
I guess this is not the one
Particle particle = Particle.BLOCK_MARKER;
particle.builder().data(Material.BARRIER.createBlockData());
actualLocation.getWorld().spawnParticle(particle, actualLocation.clone().add(new Vector(0,1,0)), 1);
anyone know off the top of their heads how I inject the block data correctly?
yes
I send the player a message when they mine a block if the tool is null
nvm got it
How would I not do this lol
private static final Map<UUID, Map<Material, List<PlayerGenerator>>> playerGenerators = new HashMap<>();```
I hate this so much
you're doing that wrong
I mean it does what I want but in a horrible way
Make a data class
make a class
To avoid the nested collections
if you have two maps 99% of the time you should've made it a class
Yeah true true
Because I hate adding and removing to this
But I'll change it into a whole class
as well you should
Thanks
How do I make a new ItemMeta?
ArrayListMultiMap
Generally you can just do ItemStack#getItemMeta
don't
Which will create one if it doesn’t exist
i read the rest of it just now
What if it's null
Then it's air.
It will only return null for air
Yeahh I was thinking of making one myself
It's good, but not for that.
True
How do I convert normal enchants to meta enchants
?
?
So you have ItemStack.addEnchantment etc right
Mhm
But meta enchantments are in EnchantmentStorageMeta.addStoredEnchantment
It’s the same enchantment
Wdym?
Normally if I want to dump an entire Map<Enchantment, Integer> into an item I can just use ItemStack.addEnchantments but there is no "multiple enchantment" version of EnchantmentStorageMeta.addStoredEnchantment
For loop
for (Map.Entry<Enchantment, Integer> entry : standardEnchantments.entrySet()) {
metaEnchantments.addStoredEnchant(entry.getKey(), entry.getValue(), true);
}
I can try this but it says it might result in null exception
public static void convertToMetaEnchants(ItemStack item) {
if (item == null) {
return;
}
// Convert the "standard enchantments" of the item to "meta enchantments"
Map<Enchantment, Integer> standardEnchantments = item.getEnchantments();
EnchantmentStorageMeta metaEnchantments = (EnchantmentStorageMeta) item.getItemMeta();
for (Map.Entry<Enchantment, Integer> entry : standardEnchantments.entrySet()) {
metaEnchantments.addStoredEnchant(entry.getKey(), entry.getValue(), true);
}
// Strip the "standard enchantments" of the item
standardEnchantments.keySet().forEach(item::removeEnchantment);
}
The enchantment methods in ItemStack just modify the meta
If you already have the meta you should use the methods in that instead
I don't think that's true because if I add enchantments through ItemStack methods, the enchanted books do not work
For instance, a Sharpness V enchanted book will do more damage than it should, rather than working to add enchantments to swords
ItemStack.addEnchantment just makes a call to ItemMeta.addEnchantment
Keep in mind addEnchantment and addStoredEnchantment are different
How are they different
One adds enchantments to the item, the other adds stored enchantments to the item
Ok, that it what I'm talking about. There is no ItemStack.addStoredEnchantment
You need the meta for that
she's a beaut
How do I basically transfer the enchantments to stored enchantments
farming barrier blocks ain't much but it's honest work
Correct
But like I said, if you already have an ItemMeta instance you should use the methods in that
Rather than the ones in ItemStack
Are stored enchantments only relevant for enchanted books
Yes
So it would be totally fine to have a condition that says "if the result item is an enchanted book, convert all the result enchantments to stored enchantments"
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock cannot be cast to class org.bukkit.block.CreatureSpawner (org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock and org.bukkit.block.CreatureSpawner are in unnamed module of loader java.net.URLClassLoader @7e774085)
Why can't I get a block as CreatureSpawner even after checking if it is with block.getState() instanceof CreatureSpawner?
so CreatureSpawner oldSpawner = (CreatureSpawner) block.getState();?
Yes
In modern java versions (basically minecraft 1.16+) you can do if (block.getState instanceof CreatureSpawner spawner)
If I do EntityType.valueOf("IRON_GOLEM") (the value is an example), does it get the Iron Golem Entity Type?
It should
I am trying to set the spawner type with PDC data but it doesn't set the type.
Show code
NamespacedKey key = new NamespacedKey(plugin, "spawnerType");
String spawnerType = pdc.get(key, PersistentDataType.STRING);
CreatureSpawner spawner = (CreatureSpawner) block.getState();
spawner.setSpawnedType(EntityType.valueOf(spawnerType));
You need to call spawner.update
^
Oh...
It still isn't spawning the mobs
Show the entire code
public class BlockPlaceEvent implements Listener {
private final Silktouch_spawners plugin;
public BlockPlaceEvent(Silktouch_spawners plugin) {
this.plugin = plugin;
}
public void onBlockPlace(org.bukkit.event.block.BlockPlaceEvent e) {
Block block = e.getBlockPlaced();
ItemStack item = e.getItemInHand();
ItemMeta itemMeta = item.getItemMeta();
if (block.getType().equals(Material.SPAWNER)) {
PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(plugin, "spawnerType");
String spawnerType = pdc.get(key, PersistentDataType.STRING);
CreatureSpawner spawner = (CreatureSpawner) block.getState();
spawner.setSpawnedType(EntityType.valueOf(spawnerType));
spawner.update();
}
}
}
``` (Left out imports)
I think you need to wait a tick when using the place event
But I could be wrong
Because the event fires before the block actually gets placed
Anyone know how OrbitClient increases ur ram usage to crash the client?
Still is not setting the type?
scheduler.runTaskLater(plugin, () ->{
spawner.setSpawnedType(EntityType.valueOf(spawnerType));
spawner.update();
}, 1);
Move all of it into the delayed part
I need some help with detecting if a player is in a certain radius of an armor stand and give the player regeneration. I tought of a method but its not working.
all of the code?
At least everything after and including the instanceof check
This is the code just with the spawner updating in a runTaskLater method
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Basicly whats supposed to happen is when I use an ability, this armorstand and a circle of particles appear and I want it when a player is inside that circle it gives the player healing 3. This is my code:
public void hCSpawnEvent(CreatureSpawnEvent e){
if(e.getEntity().getType() != EntityType.ARMOR_STAND){
return;
}
if(e.getEntity().getCustomName() == null){
return;
}
if(e.getEntity().getType() == EntityType.ARMOR_STAND && e.getEntity().getCustomName().contains("Healing Circle")){
healPlayer = (Player) e.getEntity().getNearbyEntities(.1,.1,.1);
while(!(e.getEntity().isDead())){
if(e.getEntity().getNearbyEntities(3,3,3).contains(healPlayer)){
healPlayer.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,PotionEffect.INFINITE_DURATION,2));
}
}
if(e.getEntity().isDead()){
healPlayer.removePotionEffect(PotionEffectType.REGENERATION);
}
}
}```
Yeah you can’t just use a while loop
That’ll lock up the entire server
?scheduling
Yeah, my first idea was to use a runnable, idk why I switched
I still somehow have to find a way to determine the player its supposed to heal
I used healPlayer = (Player) e.getEntity().getNearbyEntities(.1,.1,.1); since it spawns at the player's location so I'd just detect the player with that
Why not just use the player that activates it
Or do you want any player inside the circle to be healed
No, only one. At first i tought of getting the player with the rightclick event, when the player activates the ability, but then if someone else used the ability, it would change the player its supposed to heal, wouldn't it?
No
really?
Make a class that extends Bukkitrunnable and pass the player you want it to heal in the constructor
Then heal said player in the run method
You meant something like this? :
public void HealPlayer(Player p){
p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,10,2));
}
public void run() {
HealPlayer(events.getInstance().healPlayer);
runTaskTimer(HB.getInstance(), 5l, 5l);
}
}```
that will keep starting a new task timer running itself
It also contains no passing of player into constructor
Can you show me what you mean? (Sorry, I do coding occasionally for fun, im no master of Java 💀 )
private final Player player;
public className(Player player) {
this.player = player
}
public class RunnableShit extends BukkitRunnable
private final Player player;
public RunnableShit(Player player) {
this.player = player;
}
@Override
public void run() {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,10,2));
}
}
you can scrape the internet, you won't ever find me putting down protocollib
Too much spoon
if anything, i wish more people didn't shade packetevents
🥄
i've come to realize i don't like the idea of shading
Bro I just need to get this working, no need to be professional 💀
I’m going to shade it twice now
enjoy 100mb file
people complain about packetevents size but forget protocollib is bigger
how big is packet events
thats nothing
i would shade it
maybe
im gonna go find a way to avoid libby
oi
coll
would ur nms thingy break if i shade it into core instead
spark or I use jprofiler sometiems (https://www.ej-technologies.com/products/jprofiler/overview.html)
JProfiler is the leading Java Profiler for profiling on the JVM. JProfiler's intuitive UI helps you resolve
performance bottlenecks, pin down memory leaks and understand threading issues.
bump
someone people complain cause spigotmc size limit is what, i think 4mb
so
then
they have little space for their own shit
idk
Yeah it would but you can exclude from minimization
Just exclude nms packages
Well fuck you ig
Jawa
did you steal that off me
do you like my commit message
No
why not
Perfect
no i didnt realise i missed the D on enabled
I realized that I forgot the @EventHandler before the listener
Me when I forget to register events
My largest plugin that doesn't shade stupidly large things for no reason other than me being lazy is like 450KB kekw
and my largest fully custom plugin w/ no external dependency shading is 168KB 
Hi, Im trying to make an optimizer and right now im trying to make an event that detect when a hopper is getting items inside, but looking in Spigot, I don't see any event, so my question is if somebody can show me how to make an event that detect when a hopper is getting items
InventoryPickupItemEvent
Ammm and with that event can I know when a hopper take an item?
InventoryMoveItemEvent
InventoryMoveItemEvent
Ammm let me see if I can, hold on
between those two events you will know if a hopper picks up an item and or moves it to another inventory or hopper
@EventHandler
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
if (event.getDestination().getHolder() instanceof Hopper) {
Bukkit.broadcastMessage(ChatColor.YELLOW + "¡Un hopper ha agarrado un item!");
}
}
Let me try with that
now, as far as making custom events though, that is easy
I tried but with the code, when I dropped an item into a hopper, the broadcast do not work.
That’s the other event
.
kk
do i have to use fernflower or something to get the source attachment?
use specialsource plugin
jav asource attacher
Since a NamespacedKey can take a String for both parameters, can I leave the first one blank ("") so it is entered as "name": "value"?
What
Lmao this shit still aint working
Can I have a NamespacedKey like new NamespacedKey("", "name")
you can not
I don't like how it sets the data in a PDC as "firstValue:secondValue"
That’s the entire point
Oh
It’s unique to your namespace
Otherwise two plugins trying to use the name “type” would break eachother
So even if I have one plugin?
a namespace must not contain anything other than a-z, 0-9, dot, _, or -. it also must be at least 1 character
Technically a-z
same with keys, but keys can also have a / for whatever reason
fixed
because vanilla keys with / exist
Biome tags for instance have minecraft:generator/can_generate_ancient_city or something like that
ah
hello can someone help me about gradle plugin building
What about it
If they have it set up right it should be as simple as running gradle build
he loves you back :D
:(
oh
btw whats that mean
Project at 'D:\eclipseworkspace\Custom-Nameplates-main' can't be named 'CustomNameplates' because it's located directly under the workspace root. If such a project is renamed, Eclipse would move the container directory. To resolve this problem, move the project out of the workspace root or configure it to have the name 'Custom-Nameplates-main'.
Seems fairly straightforward to me
can you build for me by any chance?
Its actually a paid plugin
but some how it has source code
and i find out it
Generally paid plugins do that for people who are experienced and can solve any issues themselves
i tried to build for a few hours
Being able to build it yourself is basically proof you can handle your own issues
im not the one of them
ik but i live in turkey and i dont have money to pay it its too expensive
and i need it
there is an economic crisis in our country
our money's value decreased by like 25% in 3 days
and we cant afford it
idk man
anyways thanks for helping
Any way to disable tree generation?
I'm looping through all blocks in a area and its picking up every single block except for player heads and wither skull and creeper head... is there a reason that would cause this?
for (x in minPoint.x.toInt()..maxPoint.x.toInt()) {
for (y in minPoint.y.toInt()..maxPoint.y.toInt()) {
zLoop@ for (z in minPoint.z.toInt()..maxPoint.z.toInt()) {
val block = world.getBlockAt(x, y, z)
if (block.type != Material.AIR) Bukkit.broadcastMessage("${block.type} ------------[${block.location}]")
if (block.state is Skull) {
Is there an event that is triggered by player.setMetadata()
no
gotcha, thank youu
Interesting idea tho, ItemChangeDataEvent
hmm
I approve
I'm trying to add support for some Vanish plugins and a handful set the player metadata so was hoping I could use that instead of all the separate APIs
lmaoo
correct me if I misunderstood. Is it really possible to make 1 plugin fill the plaseholder with its data and this plaseholder can be used by another plugin?
if you make a placeholder with PlaceholderAPI other plugins that support it will also be able to use your placeholder
this is cool
but how plaseholder api connect my plaseholder with another plagin? through packages?
Have a look at this: https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Hook-into-PlaceholderAPI
if you want support with working on it you'd probably be better suited joining their server
thf
People I've come to you because I'm truly confused.
So essentially I'm trying to give the item under hand1 to a player but I cannot for the life of my figure out how to access it
This is as far as I got before I gave up.
The second thing is accessing it if it always is changing? It's not always going to be diamond helmet
Nevermind I simplified the config file lol
config 1, alexjones 0
Configs are dumb and I hate them
y
Truth be told I've been coding plugins for about 5 hours now and they just confused the absolute dog piss out of me.
Ah fuck me I'm lost again
' ' - ?
huh
what this - 'UNBREAKING' - why ' '
Idk I think i got it
What?
ur appending ".item" outside of the actual config.getString(), u want to do config.getString(args[1] + ".item");
Oh wow smh
'-' not shold be here in UNBREAKING
Why
bc this not list this key
So like this?
Do I have to reset the item when adding an enchantment? No right?
oh yeah, the same will go for getStringList(), ur appending the rest of the path outside of the method for some reason, lol
What a stupid fucking mistake
so getStringList(args[1] + "hand1.ENCHANTMENTS")
whaaa ?
what obaut '-' not shold be here in UNBREAKING
' ' - not shold be too
no point in me saying it :P u already told them
getStringList(args[1] + "hand1.ENCHANTMENTS") - not tue
true
for(String key: section.getConfigurationSection(path){
wait a moment i write
here is an example. Didn't check but something like this
i'd appreciate help on my issue
you have to update meta i think
yes, getItemMeta is a copy, not the original
something like
ItemMeta meta = entity.getEquipment().getItemInMainHand().getItemMeta();
meta.//do whatever you want
entity.getEquipment().getItemInMainHand().setItemMeta(meta);```
can you please help me
with my issue
depends on the issue
.
im translating color codes correctly
but when i send the message as a TextComponent using .spigot()
it get's messed up
public static String format(String string) {
return ChatColor.translateAlternateColorCodes('&',string);
}```
u probably want to use TextComponent.fromLegacyText(String), not just new TextComponent(String)
lol why you do this?
Do what?
mans wants a custom item, wouldnt blame em
fromLegacyText() returns a string
what
i meam you can just use code which i showed above
read at your leisure about keys in config.yml
this not good code
not to sound like i doubt u but... r u Sure?
net.md_5.bungee.api.chat.TextComponent#fromLegacyText(java.lang.String) returns a String for u?
nah i just thought it would because it wasn't letting me use it as a param in .sendMessage()
weird, u should be able to use it in it, hell, i do
Well now everything works but the enchantments smh
let me give you normal code
Word alrighty then lol
you can broadcast a BaseComponent using server.spigot()
but on player.spigot()
it has to be an array
damn
fromLegacyText very much should be returning BaseComponent[]
intellij is just wilding on my end
maybe try invalidating caches n restart ig
How would one make custom inventory textures ( I just mean opening it and specificying that the client should use it)
here a normal code
am i dumb
or i just have to do that everytime
@EventHandler
public void onChat2(AsyncPlayerChatEvent event){
event.setCancelled(true);
Player player = event.getPlayer();
BaseComponent[] format = TextComponent.fromLegacyText(
TextHelper.format(PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%") +
player.getName() + " &8&l➥ " + event.getMessage()));
for (BaseComponent baseComponent : format) {
baseComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new Text("Hello")));
}
player.getServer().spigot().broadcast(format);
}```
looping through every baseComponent
before looping
after
anyways thank god i figured it out
winn<3
honestly, not sure :p
Np
@upper hazel
How would one make custom inventory textures ( I just mean opening it and specificying that the client should use it)
@upper hazel wya bro help a brotha out
I did
give me screen config
my code not for this config
Welll could you make it for it because I am stumped brother
wait you want setting armor?
you need to do the config first
Why don't you treat the null case separatly ?
Like if null, don't add enchants
NGL I don't like your code
I don't think you should do a for loop to iterate over all main keys
I wasnt planning it this isnt my original code
Hold on lemme do smth for you.
Lemme grab my pc and it takes some time to wake up this grandma
I have a question, what is the level of the config section?
Inside mob1 ?
Or is it the whole file
Inside mob1
Ok
here is APPROXIMATELY if only to cover the hand1 section. There's a lot more to add
look tutorial on youtube obaut config
custom end default config
Configuration#set(key, itemstack) :)
nah bad idea)
serilization best

@robust portal here's what i made
if (hand1!=null){
String itemMaterial = hand1.getString("item");
Material mat = Material.getMaterial(itemMaterial);
if (mat!=null){
ItemStack item = new ItemStack(mat);
String itemName = hand1.getString("name");
item.setDisplayName(itemName);
ConfigurationSection enchantments = hand1.getConfigurationSection("ENCHANTMENTS");
if (enchantments!=null){
for (Map.Entry<String,Object> entry: enchantments.getValues(false).entrySet()){
Enchantment ench = Enchantment.getByKey(NamespacedKey.fromString(entry.getKey()));
if (ench!=null) item.addEnchantment(ench, (Integer)entry.getValue());
}
}
}
}```
edited
item.addEnchantment(ench, (Integer)entry.getValue()); - i recomend use addSafeEnchantment
there is no addSafeEnchantment
there is addUnsafe, but read its javadoc
addEnchantment isjust fine so long as you are within the limits of enchantments
yea
also concerning setDisplayName, if it's deprecated it's because of paper whining of their shitty components, but it's not really deprecated tbh
who knows if the way to find the right entity in the worlds is optimized if you constantly record its location in the database
no point in storing an entities location
it means it is better to find it through the usual world methods
i want to get a horse with a specific key, but for this i need to find it in all worlds
tag the entitys PDC
what is PDC ?
?pdc
yea but how to get through the id without going through the horse entities in the world
i think EntitiesLoadEvent is basically what u gonna do bro, try to match your horse there
what are you doing with the horse?
there might be an easiier alternative with NMS, if you modify the Entity class or smth? i ain't an nms expert but either way u'll be going through some listener so eh
in my plugin, the horse is supposedly the property of the player (as in gta rp with cars) and when entering a command, the player teleports the horse to himself
so for teleport i need find horse
in ALL worlds
you can;t guarantee the horse will even be loaded.
you would be better spawning a new horse when you need it and destroy it when it goes out of range
or is unloaded
wait i cant get all entity in world if he not load?
yeah
no
its kinda shit
you only get loaded entities
When refernecing a namespace key from string do I have to specify pluginName:key or can i just put the name of the key.
you have a function which takes both arguments iirc
plugin, string
if you don't precise the plugin it will default to minecraft namespce iirc
but ain't sure
so in my case it woud be "pluginname:mykeyname"
ah, idk sorry
How can I understand that the chunk where the horse was no longer loaded?
there is a Chunkunload event
i hope this not will hard
ah wait
if the horse is not loaded, then the location does not change, right?
so i can find location end load chank
if the location is loaded then the location will be updated
or not updated
how you think this good idea
?
if I were you I'd destroy the horse on chunkUnload. Then when you need the horse, check all worlds for teh horse, if not found, spawn a new one
after checking the source code,
NamespacedKey.fromString("pluginname:mykeyname");
should work
i try
but Is my idea really that bad, I think it's easier no?
fromString(key) calls, fromString(key, defaultNamespace=null);
Major steps of fromString(key, defaultNamespace) code that would make it work for your case key="pluginname:mykeyname"
String[] components = string.split(":", 3);
String key = (components.length == 2) ? components[1] : "";
...
if (components.length == 1) {
//not the case for you
...
return
}
...
String namespace = components[0];
return new NamespacedKey(namespace, key);
@zenith gate so NamespacedKey.fromString("pluginname:mykeyname");
works totally
the idea is to load the location into the database every second and when the command to get the location is entered, load the chunk and find the horse within a radius of 4 blocks
Okay thanks, just wanted to clarify.
nps 🙂
tbh the documentation is sometimes very confusing
i always advise to check at the source code if you can, it's generally quite easy to read
@eternal oxide how you think?
if your IDE has a decompiler (like IntelliJ or VS Code with java language + gradle/maven support), you should be able to shift/ctrl click function names to see their source
if you decompile my source i will sue you
off to download all GodCiphers plugins
dont you dare to also buy the premium ones 😠
I'll use my leet hax0rz skills to not pay
sorry if it doesn't answer your question, I would do the following:
Whenever some entity load (EntitiesLoadEvent),
Check if they match one of the horse of your db,
If they do: Save the horse entity in your memory (ElgarL will heavily disagree with that but eh),
When someone tries to teleport the horse to them, try to retrieve it from your horse array or whatever structure of your memory you saved it in,
If no find, or if the horse.isValid()==False, then either tell them that their horse couldn't be found, or summon a new horse with same nbt
I can just save the serial data about the horse, including skin color and so on?
yaaa
you can;t without loading the chunk
the whole issue is that you can't deal with unloaded shit
i mean there must be a way somewhere to get the unloaded entities
but it's prolly obscure
just delete on chunk unload
ok
then you have no issues with old horses in unloaded chunks
tin will have to work hard with the database
best way to get instant ping of a player?
i realised it's often with a bad update rate, like 5 or 10 seconds or smth ?
I need it to be very dynamic; within a (dt) rather than a (delta t)
the only things you need to store are the details about the horse
which don;t change
Is this plugin expensive?
horse have another skills
ALso is there a way to know about "how much available ram" does the player still have ? (for minecraft)
Player or server?
If the player's max ram no.
yeah thats what i thought
do you guys know how to get a more precise player latency?
the shit it returns is within a 5 or 10 seconds refresh rate
it aint enough
i need a half second (at least) precision
guys i dont know what it is. Custom Structures plugin, and 1 16 5 world edit.
hm
idk
Moving on to my next question, can you guys think of any other way an itemstack can display ?
- container (any kind of inventory/stuff containing slots)
- item display (1.19.2 thinggie)
- item frame
- Item
Item display is 1.19.4
my bad yeah
net.minecraft.util.ReportedException: Ticking entity how can i fix this error?
show the full error
can you imagine anything else i forgot on the list ?
and show your code
its a sv error
If you haven't written any code then you should stay in #help-server instead of posting in multiple channels
why
if you really want it to be as instant as possible youll need to deal with lower level packets
but otherwise you can just use player.getPing() which is updated every ~20 seconds
pretty sure there is a function to change granularity within bukkit api or within ServerPlayer
or something
i forgot which one
i ain't afraid of packets
ok then do it
it's not good enough because 20 seconds is enough for a player to crash due to lag
my plugin does some animation
depending on player connection, it lowers the frame rate, lowers the download rate, lowers the "view angle", etc
what minecraft version are you using
1.20
use ping pong packets
mkay, but u sure there isn't a native way within ServerPlayer or smth to change granularity ? (which already does the packet job)
1 year ago someone told me but i forgot cuz i paused the project since then
hm ok
Not really. The player times out after 30 seconds
putting the horse in a hashmap upon spawning might be a solution
would also need to store the chunk because the entity will no be found if it is in an unloaded chunk
For loop
loop thru what
but i have to adjust the lag i give to him asap
If i adjust the lag only the last 10 seconds, it might be too late already due to the enourmous amount of packets player has to catchup alr
also isnt that inneficient?
Blocks above
so how would i get the blocks above
there ain't a better way if you wanna check all blocks above
Block facing up or get location and add 1
atleast not with the amount of details you gave us
im placing a block, and then another block 10 blocks above OR 10 blocks below and whenever i step on either of them i get teleported to the closest block
either up or down
it can be anywhere from 1-10 blocks distance
I mean you could store the next block via pdc. Although 1-2 blocks below would let you either be in the ground or suffocating
okay so how would i scan 16 blocks in both directions (up and down.)
with 2 for loops?
1 checking for a block above and another checking for a block below
could do 1 loop and use the loop variable to once add and once subtract it from the location
Don't forget to check min and max world height as well as highest block when looping
Will minimize the block lookups required
i only need to check a 16 block radius
then i would store the horse's data in a persistent data container and spawn a new horse with the same properties when the player wants to teleport the horse.
as for the previous spawned horse i would use the EntitiesLoadEvent to remove it whenever someone else finds the horse
does that sound viable?
you are going to end up with a lot of lost horses in the worlds when your server stops/starts
Which persistent data container do you wanna store the horse's data in? Obviously you can't store it on the horse. Will you use the players PDC?
yeah the players pdc
where do you store the horses to remove?
Delete horses in chunk unload so you don;t have junk data stored in unloaded chunks
its simpler to clean up when the data is already loaded than try to catch old data when loading
filter for some properties like if the horse has a saddle with specified name
Then how do you know whether it has to be deleted or was never teleported/recreated?
i'd probably just delete it as players could just respawn one whenever they want to