#help-development
1 messages · Page 1659 of 1
this is a horrible system and should not be reccommended
why?

told em that twice and sent a better system
and how?
Bro
Ok guys wait everyone, I am currently on adding the open inventories to a list and removing them from that list if they are closed, but somehow I keep running into this:
Cannot invoke "java.util.List.isEmpty()" because "this.inventoryList" is null
that breaches the api, instead you can create a custom holder (non-api)
although InventoryHolder works perfectly its not intended to be used that way
public class InventoryCloser implements Listener
use a set, not a list
HashSet to be exact
what is the advantage of using a set in that case?
sets are way faster and since you arent caring for the order, you should use it
okayy
how?
fsr now the events dont fire anymore at all
send code where you register them
public List<Inventory> inventoryList = new ArrayList<>();
I am opening the inventory called inv and adding it to the list
inventoryList.add(inv);
This event doesnt fire at all
public void onInventoryClick(final InventoryClickEvent e) {
if(inventoryList.isEmpty()) return;
if((inventoryList.contains(e.getInventory()))) {
e.setCancelled(true);
}
}
it needs to be annotated
EventHandler
and registered
show where you register it
it worked before without the checks so i know it works
also like I said use a set
getServer().getPluginManager().registerEvents(new inventoryTest(), this);
public HashSet<Inventory> inventoryList = new HashSet<>();
like I said, the events work
Map = HashMap
Set = HashSet
lemme print the set when it fires, one sec
this happens when i click in the gui i created now.
Above is the set which should contain that inventory, below is the inventory that's opened
i dont know why the set is empty
do you add it
yes...
use a getter not a public field
whats a getter?
sorry, it's 3 am rn and I am kinda confused, is that related to the problem we have rn?
better code development -> less errors -> better code
show where you access the set
public Set<Inventory> inventoryList = new HashSet<>();
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
HumanEntity ent = (HumanEntity) sender;
Inventory inv = Bukkit.createInventory(null, 9, "Example");
inv.addItem(createGuiItem(Material.DIAMOND_SWORD, "Example Sword", "§aFirst line of the lore", "§bSecond line of the lore"));
inv.addItem(createGuiItem(Material.IRON_HELMET, "§bExample Helmet", "§aFirst line of the lore", "§bSecond line of the lore"));
ent.openInventory(inv);
inventoryList.add(inv);
return false;
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent e) {
Bukkit.broadcastMessage(String.valueOf(inventoryList));
Bukkit.broadcastMessage(String.valueOf(e.getInventory()));
if(inventoryList.isEmpty()) return;
if((inventoryList.contains(e.getInventory()))) {
e.setCancelled(true);
}
}
why have you got final on the event?
use the system I sent you
I don't understand the system you sent...
ive been sending these code snippets for no reason? 
I only started Java 1 month ago
I implemented all code snippets you sent but that one
Uh can someone tell me in their dev way why /restart can mess up the server? I'm trying to explain to something that thinks /restart is essential and it's there for a reason
explain to someONE or someTHING?
- Memory leaks
- Inventory guis can leak MASS items
- You can see so many errors
- Memory buildup that wont be removed by the garbage collector
got it
I am so confused, I have the "InventoryList" as a public Set, when I open the Inventory and print the Set, it contains the correct inventory data, but when I then try to interact with it, the list is empty even though the closeEvent is not called
are you somehow clearing it?
no, not at all
create a github so I can look over the code more clearly
yes i know, it's just a thing of myself
if someone steals your code they are either looking for a structure, or are flatout worse at coding then you
bruh I just added the definition of the Set to the main class and made it static and now it works
I moved the definition of the Set from the class where I had all the events to the main class and now it works
ill give you a full java course if I have to
ok I'm a bit confused now. People are telling me /restart doesn't mess up plugins. But is there a plugin you know that can restart the server with a command iwthout accessing console
It's a LOT of code and heavy maths, not worth it anymore at this point
Lol help me also understand the knowledge of everything xD
its 50/50. plugins either hold mass amounts of data or dont. it should be handled correctly, but in most plugins (including my own) its overlooked and the smallest data gets leaked
?
I thought /restart just did basically the same thing as /stop, and that /reload was the only bad thing 
just use BileTools
stop stops the server and restart runs the startup file specified
it supports most plugins
tf is BileTools lol
reload any plugin individually
like /reload for singular plugins and their dependencies
very useful and hard to break
deadass sounds like an individual /reload command
just try the plugin, you'll love it
no
you can just drop your new plugin in and overwrite your old version, it'll automatically reload it from the new file
if you're using linux atleast ^^
Wait I just realized there are 2 different commands
/reload
/restart
thank you for your help btw
Damn, I don't even understand that
@silver shuttle you
wa
send me one of your github repos
make one of the plugin youre making
na
it's probably garbage code, I am getting scolded enough in other areas of my life lol
that used to be my old mentality
do you even make bad code
don't try to convince me, not worth it
I made a discord-twitch chat relay
that one is kekw, first plugin i made
all my events are in one class lol
i was gonna rework it but I didn't feel like it
and it doesn't use a build system iirc?
yes.
- Im sure thats illegal almost in every country
- Its nearly impossible to do safely
just use IGC 😩
ingame currency
yes
you are not going to make a bitcoin depositor safely
gl on finding help
those are payments
you can do this manually
I dont know why you fucking want to
sus
youre losing money
?
so sketchy i cant help you
sounds like you want help creating a scam
if this were ever to get popular it'd be taken down by communities immediately
just dont 😉
who the fuck would fall for that

espically on a mc server
i read a quick tldr on what you said it would be illegal in a lot of countries
jesus
then you are fucking stupid
can I do it
youre bound to fail
?b
you should
you're gonna loose money in legal fees lol
you will lmao
you are too arrogant to not be
?kick @unreal slate engaging and requesting help with illegal activities
Done. That felt good.
I was gonna ban em

honestly expected a ban
go ahead
Done. That felt good.
prob even talking about it is against discord TOS
How do you give an item an "invisible" name or just make their DisplayName empty?
prefferably via config
""
both those didnt work fsr
redItem.getItemMeta().setDisplayName(Objects.requireNonNull(config.getString("gui.false-item.name")).replace("&", "§"));
Yes, I am not using the color code translator thingy and like this more
I dont see the point of the requireNotNull
gonna throw an error either way
just put a default
y dont u like translate alternate colorcodes
I need to not display the error in ingame chat if the message is empty
either way thats not the problem
I started with this
you are applying the name to a copy of the meta not the actual one
you need to assign the meta again
oh okay
ItemMeta meta = ItemStack#getItemMeta();
... perform stuff on meta
ItemStack#setItemMeta(meta);
cba to find the link on it
?cba
Imajin#0001 definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.
lol
ItemStack redItem = new ItemStack(Material.valueOf(config.getString("gui.false-item.material")));
ItemMeta meta = redItem.getItemMeta();
meta.setDisplayName(Objects.requireNonNull(config.getString("gui.false-item.name")).replace("&", "§"));
redItem.setItemMeta(meta);
Should'nt that work now?
should
well it don't
really should use the translate tho
I have name: "" in my config file so thats not the problem
hey hey
im wondering how i can make a holograms system, without looking at some 3rd party thing for refrence (Holograms API, etc.)
i have the spawning system done
and an easy way to see if its a hologram
now im just wondering how i can remove them...
because they dont delete if i Entity#remove() them
You are using armorstands correct?
They should definitely be removed
yeahhhh
idk why they arent?
im just using ServerLoadEvent
i tried like, converting it frm a skript i made a while back which used on load
Are you sure the method is running?
thats on plugin load
not server
i see
it worked on the ServerLoadEvent im pretty usre?? im really not sure
plugin loads on starutp
Why not use onEnable?
Ah ok
ahhh
i should use WorldLoad?
maybe make a task to wait a bit
bruh
just use onenable
well my plugin loads on startup
Yes and that's after worlds load
then make it post world. what are you even trying to do
d
onload should be used for async/io preperation
Just remove them onEnable
i'll see about that aswell
although im fairly sure they arent even being removed, i can triple check
ya
you shouldnt use real armorstamds anyways
theyll just die if a plugin clears entities
Yeah you should use nms packets
NMS classes seem to be obfusicated afaik
Deobfuscate them then?
@EventHandler
public void onBlaze (EntityDeathEvent event) {
if (event.getEntity() instanceof Blaze && event.getEntity().getKiller()instanceof Player) {
Player player = (Player) event.getEntity().getKiller();
int money = 25;
player.giveExp(money);
player.sendMessage(String.valueOf(money));
}
}
}```
any1 know y that aint working?
when i kill a blaze i dont get the xp or the chat message
you have to register it
i did
sorry if this is a dumb question but is there any way to get the amt of ticks left inside of the method? I want to have like a 30 miinute/15 minute warning, and a command that lets players see how much time is left.
public void run() {
}
}.runTaskTimer(this, 0L, 72000L);```
in other words, get how long until the task runs again
use a scheduler
and add to an int
then check that int
anyone know how i can start making plugins?
?learnjava start here
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Ty
any idea how to send a heart-symbol into the actionbar? i use ```java
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(Math.round(entity.getHealth() / 2) + " <heart-symbol>"));
but i can't find a way to display that symbol
\❤️ ?
❤ or this ig
both should copy into your ide
Does anyone here have experience with registering placeholders for PlaceholderAPI? I'm trying to register a placeholder but it doesn't seem to work. Either that or there's something wrong with Featherboard that doesn't recognize it, but this is my class for the placeholder %islandalias%. I am calling the register method of PlaceholderExpansion in the onEnable() method
https://pastebin.com/CjijTwSn
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
weird, now it works.. before it just showed a weird rectangle idk
private void checkForSight() {
Bukkit.getOnlinePlayers().forEach(p -> {
for (Entity e : p.getNearbyEntities(5, 5, 5)) {
if (e instanceof LivingEntity && p.hasLineOfSight(e)) {
LivingEntity entity = (LivingEntity) e;
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(Math.round(entity.getHealth() / 2) + " §l❤"));
}
}
});
}
i guess i completely misunderstand how it should work? huh
The issue might be that I have load: STARTUP in my plugin.yml and therefor the plugin seems to ignore that PlaceholderAPI is a softdependency, it still loads my plugin before PlaceholderAPI, and therefor I have to delay registering the placeholder with 1 tick so that the PlaceholderAPI plugin is enabled when doing it, but then Featherboard seems to initialize before the placeholder is registered instead. Any idea how I could get around this? 🤔
Not sure, I didn't know there was a difference. Is it possible to check that?
Watch the messages in console
Yeah right, PlaceholderAPI is loaded before my plugin
But my plugin is enabled before though
Looks that way. It loads PlaceholderAPI, then my plugin, and then it enables my plugin and then enables PlaceholderAPI and Featherboard and lastly (delayed by one tick) it registers my placeholder so perhaps Featherboard ignores it for that reason
https://mclo.gs/KahGBdr
111 lines
if i wanted to check if an entity was dead or not would i check if its health is < 1?
or does that not save when an entity dies
My server's memory is constantly adding unnecessary allocated ram all the way to the max, even when a lot of memory is free. The server freezes and CPU usage drops to <.1% and i have to manually kill the server in the panel and start it back up. This happens 1-3x every day and ram just keeps allocating a few MB every minute. Please help.
Server version:
This server is running Purpur version git-Purpur-1331 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: 635d108 on ver/1.17.1)
You are 14 version(s) behind
Previous version: git-Tuinity-"dc9d19c" (MC: 1.17.1)
- Update
- #help-server
- This is something you should ask Purpur about
Looks like an OOM, obvious fix is to set the -xmx at a lower value, since the heap is unused anyways
how to get the health including absorption and stuff?
getHealth and getHealthScale seems to not include absorption
java -Xms128M -Xmx24000M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -jar purpur.jar nogui
These are my startups
Xmx24000M yea
Xms and Xmx should be the same value
Do you really have 24 Gb of ram on your system?
@EventHandler
public void onEntityHit(EntityDamageByEntityEvent e){
if (!lastDamager.containsKey((Player) e.getEntity())) {
e.getEntity().sendMessage("first mob attacked " + e.getDamager().getName());
lastDamager.put((Player) e.getEntity(), e.getDamager());
}else{
e.getEntity().sendMessage("mob attacked " + e.getDamager().getName());
lastDamager.remove((Player) e.getEntity());
lastDamager.put((Player) e.getEntity(), e.getDamager());
}
does anyone know why this isnt working? the messages arent even popping up
im trying to store the last entity that attacked a player
for every player
in a hashmap, as you can tell
Is it registered
yes
32g
probably the map doesnt contain the player
tho, that would display the second message
all that being free?
1g used for proxy bungeecord, and 6g for creative server
so yeah, show your event registration
@quiet ice
try a sysout instead of sending a message.. to see if your event gets called
system overhead makes 1 more Gs, panel overhead another G and a half. You are running over your ram allowance.
I had the server allocated to 20g but it was still happening
Did you ever set xmx=xms?
a spider is a LivingEntity right
also nope it doesnt print hte line
it comes up with an error
Could not pass event EntityDamageByEntityEvent to Gammaplugin v1.0-SNAPSHOT
org.bukkit.event.EventException: null
what do you override in nms to make it so an armour stand has no collision so it cant be hit/shot?
im gonan check if the player getting attacked is an instance of a player before checking
prob wont do anything
i was right
it still comes up with an error
apparently spiders arent entities anymore
the spigot errors are so fking useless
it tells me nothing other than its an error
declaration: package: org.bukkit.entity, interface: Damageable
i havent
installed a filter
unless worldedit is a filter
which
yeah
its not
Need help, showing this for a while now https://gyazo.com/d7f1424c27a531ad46333f3d6afaa75b
idk if its whats causing it but if u go to ur server.properties, you might have online-mode set to false
bruh
wdym?
nvm its nothing to do with ur server.properties
online mode has nothing to do with server loading
in what way?
yes as in i agree
in the error, take a look at the line that comes from your plugin, at the end it shows smt like line x, and show me that line from your code
null error doesnt mean anything casting-related
it starts with at: <your-package>......
o ok found it
its
this
lie
line
ItemMeta bandaidMeta = ItemManager.bandaid.getItemMeta();
even though
this has nothing to do with it???
it was fine beforehand
did you changed something at this event after getting that error?
that could change the line
bandaid is probably null
i didnt change anything in the bandaid section of the event
i talk about in the whole class
if you did, build the plugin again, put it in your server, and run the event again.. then look at the error again
idk what u mean
ok sure
ofc i changed something within the entire class
but i didnt change anything that should affect it
if you get an error, the problematic line of course depends on the current state. if you change anything later, the line changes probably
now its line 142
wait
oh
.
Player p = (Player) e.getDamager();
a spider was hitting me
the damager is null
yeah
anyone know why this doesn't work?
if (player.getItemOnCursor().equals(null)) {
this doesn't either
if (player.getItemOnCursor().equals(new ItemStack(Material.AIR))) {
i tried to send the getItemOnCursor to console and it said something like ItemStack 0 AIR
so then i tried to add 0 to the second one and it still didn't work
Air isn't null
alr, so what do i do?
i want to see if the cursor doesn't have anything in it
Isn’t it meant to be == null
oh riet
that explains why this worked in another class
if (player.getInventory().getHelmet() == null) {
if(itemstack != null || itemstack.getType() != Material.AIR)
^ returns true if the item is anything except air and null
if (player.getItemOnCursor() == null) {
this doesn't work, i'll try the other one
IntelliJ also says it's always gonna be false
Then check if it’s air
how can i check if a server is restarting with packets?
how far is the players reach on blocks in survival?
does anyone know why player.isBlocking() doesnt work?
it always returns false
has there been a change in 1.17
You can not blovk in 1.17
are you serious?
you mean block with the sword?
how do you check if someone is holding a shield
no
im checking if a player is right clicking with a shield
is there a way to get a skeleton entity from an arrow
or to check if the arrow was shot by a skeleton and then get the skeleton from the arrow
Im currently in the process of making a audioclient for minecraft.
I want to create speakers that pan from left to right depending on how the player rotates his head.
I currenty have this code, which works to a ceartain degree but it flips the value when im behind a block, and it only works for a certain radius:
public double getAudioLRValue(Player p, Location target){
Vector look = p.getLocation().getDirection().normalize();
Location head = p.getLocation().add(0, p.getEyeHeight(), 0);
Vector direction = head.subtract(target).toVector().normalize();
Vector cp = direction.crossProduct(look);
return cp.normalize().getZ();
}
How do I check if a location is to the left or right of a players head?
Isn't it possible to change the duration of a effect in the EntityPotionEffectEvent Event ? ;o
getNewEffect()
Gets new potion effect of the changed type to be applied.```
probably change this maybe
This is what I use for snowmen, should be the same code for skeletons:
@EventHandler public void onSnowball(ProjectileLaunchEvent e) { if (e.getEntityType() == EntityType.SNOWBALL) { Entity source = (Entity)e.getEntity().getShooter(); if (source.getType() == EntityType.SNOWMAN) { e.setCancelled(true); } } }
Oh how do you post code on discord :P
''' but replace ' with `
This method returns PotionEffect, which has just a getter for the duration and no setter.
I added a custom enchantment and want to reduce the duration of the negativ potion effect's e.g. slowness.
custom enchantment on your armour?
Yes
why not cancel the event
and then apply a new effect copying the old effects attributes
i know it would loop infinitely but it looks like you can tag the reason it was applied
maybe use that as a guard clause?
other than that,
public Map<String, Object> serialize() {
return ImmutableMap.builder().put("effect", this.type.getId()).put("duration", this.duration).put("amplifier", this.amplifier).put("ambient", this.ambient).put("has-particles", this.particles).put("has-icon", this.icon).build();
}```
this is in PotionEffect.class
can probably play around with nms if you want to go down that rabbit hole
Hi, I have a structure on the main island in the end with gateway block as decoration, I want to teleport a player at a custom position when he join the end but he get's stuck in the gateway block, no matters the teleportCause, any ideas ?
I already thought about that, but i wanted to know if there is a other solution as this looks like a "bad" solution 😄
I though there is maybe a way to change the duration and i don't saw it 😄
could make your own custom event
cancel the EntityPotionEvent, parse in the potion data and then you can adjust it as you'd like
probably simplest way to do it
was going to suggest it first but thought you'd thought of it already
Yea i guess i have to do something like that, i just don't understand why spigot don't implemented a setter for the duration ;o
very niche i guess
how can i save the consol output in linux to a txt file
You can pipe stdout into a File using >
java -jar somejar.jar > console.txt
i want to save the consol from ngrok
What OS is ngrok running on?
linux ubuntu server 20.04 LTS
command | tee output.txt
So in your case
ngrok http 80 | tee output.txt
Spigot 1.8 support was dropped a long time ago.
so it wont work?
The version is full of bugs that will never be fixed
is there no way that it will work?
Looks like FAWE is your problem. Try installing an older version. Same goes for ProtocolLib.
^
So you are starting ngrok from an ubuntu server? Why.
because its my hosting server
Anyways. Tell me if it works.
I does not work
Have you tried both piping and tee?
Yes
How do you determine failure? What did not work?
It do not show the ngrok screen where you see the ip etc.. It just changes the line and do nothing
Did you check if a file was created after the command?
i created it before i ran the command
Because if you pipe then you dont see stdout. It will be written to the file instead.
And you dont need to create it.
yes t creates one
did you check the right location? Call ls from the location you used the command from.
Using the pipe operator should work unless the application does not run in the same terminal.
yes
This worked fine for me.
ps -ax | tee processes_info.txt
Guys , I learned the Types and Control Flows of java , so is that enough?
?
Do you know what an instance is?
Anyone know what this could mean? Some of my users randomly get this error. Method is called from protocollib packet interceptor (doesn't matter if I use protocollib or my own packet interceptor, still happens). No idea what temporary players are.
Ive had the same issue yesterday. ProtocolLib implements the Player interface with a temporary Player.
Yeah I just implemented a check to ignore them
How would you check for a temporary player? No idea what they are
Use an instanceof check and check for TemporaryPlayer
Aha, thank you! Appreciate your help!
whats the return of Player.getScoreboard() when theres no scoreboard shown to the player?
the player always has a scoreboard, if no custom one is set the main scoreboard of the server is returned afaik
there is a default one which every player has by default
ok how can i check if the Player.getScoreboard() is the main scoreboard of the server?
I would like to know if there is a way to cancel tick damage from wither rose ?
check if its https://hub.spigotmc.org/javadocs/spigot/org/bukkit/scoreboard/ScoreboardManager.html#getMainScoreboard()
declaration: package: org.bukkit.scoreboard, interface: ScoreboardManager
EntityDamageEvent, check for the DamageCause
Damage caused by Wither potion effect
thx
already canceled :/
contact*
@EventHandler
public void minionsProtection(EntityDamageEvent e){
if(!(e.getEntity() instanceof Player) && e.getCause() != EntityDamageEvent.DamageCause.ENTITY_ATTACK && e.getCause() != EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK && e.getCause() == EntityDamageEvent.DamageCause.VOID && e.getCause() == EntityDamageEvent.DamageCause.DRAGON_BREATH && e.getCause() == EntityDamageEvent.DamageCause.FIRE)
e.setCancelled(true);
}```
I cancel all damage that is not from ENTITY_ATTACK, ENTITY_SWEEP_ATTACK, VOID, DRAGON_BREATH, FIRE
where is wither in that xD
you didn't read
what ?
wither is already cancelled
oh so you cancel entity potion effect event ?
oh
I didn't put it in the previous list so it is cancelled
my condition is a whitelist, not a black
LOL 😂 no
read your own if statement
carefully
tho tbh you could also just use a nicer event and not fail at boolean logic
@EventHandler
public void on(final EntityPotionEffectEvent event) {
if (event.getCause() == EntityPotionEffectEvent.Cause.WITHER_ROSE) event.setCancelled(true);
}
works great
and you won't fail at a == b && a == c && b != c
lul thnx
🤦♂️ you get one back xD
you'll have to delay by a tick
if(e.getTo().getWorld().getEnvironment() == World.Environment.THE_END && e.getCause() == PlayerTeleportEvent.TeleportCause.END_PORTAL)```
or change the to location
teleporting a player inside a player teleport event will just explode
so what exactly are you doing in that event 😅 could you provide a bit more
?paste
euh...things 😅
😅
the code is very badly written I didn't clean it for the moment
guys so i have an abstract class with a hashmap
i want to accrss the hashmap
without extending the abstract class
becuz im on a listner class rn
and the abstract class implements command executor
you should be fine with just setting the teleport events "to" location right ?
I'm trying to change the to location, I'll be back after the try
how to access protected fields from abstract classes without extending them in java
is it even possible
thnx it works
no that is the entire point of protected fields
yes ?
implementing
but why
cmmandexecutor
Is there any video to learn how to code minecraft plugins?
i have a protected hashmap there
technically your listener just has to be in the same package
to access a protected member
Instance is A file that contains methods and vars (Variables) only , that we can use a reference to it , and edit the methods
Sounds like a class
^
Ok given the class CarTrader
Create an instance of that class.
One line of code pls
You need a bit more to even be an entry level spigot programmer.
You need to understand what an instance is and at least know the 3 basic data structures and one implementation of each.
Ok given the class
CarTrader
Create an instance of that class.
In the Class of CarTrader change the
Public class CarTrader {
}
To
Public instance CarTrader
The to reference it in another class
CarTrader meow = new CarTrader();
And the 3 basic data is
String
Int
Double
Boolean
Float
Char
Those are data types. Data structures are: List, Set, Map for example.
Yes. Not every sentence there makes sense to me but the right answer was CarTrader meow = new CarTrader();
One more thing.
YAY!
So I need to learn the 3 basic type of data and is there other things ??? @lost matrix
?paste
https://paste.md-5.net/gayakaniza.java
is this spaghetti
public class CarTrader {
private String carType = "BMW";
public void setCarType(String type) {
this.carType = carType;
}
public String getCarType() {
return carType;
}
}
public static void main(final String[] args) {
CarTrader traderA = new CarTrader();
CarTrader traderB = new CarTrader();
traderA.setCarType("Audi");
String carType = traderB.getCarType();
System.out.println(carType);
}
What is the outcome of this codes execution?
wait is this just java?
Audi
Nope
lemme try solving it @lost matrix
No is BMW Bec of the setCarType
yeah this is not audi
It also cartype not type
I wouldnt say this is spaghetti code. But this will perform quite poorly. You should also never expose data structures like that.
Never make them public and never use a getter for them. Looking at your BaseCommand.leaders here.
.
BaseCommand is an abstract class
implementing command executor
i couldnt just extend it
so i abused it being in the same package to access the protected hashmaps.e.tc
ew
lol
See my answer
Be patient
as abdo said
.
@sand rune ur last answer was correct, but why do u think it is?
?kick @sand rune stop bumping
Done. That felt good.
wtf
chill conclure lul
hes just tryna learn i feel bad for him
btw im arabic too @sand rune
Bec the setCarType , is set to CarType not type !
Doesn’t mean you can inherently break the rules
Sadly that is not correct.
no matter what "type" is set to, ur not even using it, are you??
its even okay to remove the parameter, am i wrong
bump

String carType = trader.getCartype
Luzifer fr
Maybe this makes it more clear:
CarTrader traderA = new CarTrader();
CarTrader traderB = new CarTrader();
traderA.setCarType("Audi");
traderB.setCarType("Opel");
String carTypeAlpha = traderB.getCarType();
String carTypeBeta = traderA.getCarType();
System.out.println(carTypeAlpha);
System.out.println(carTypeBeta);
What is the outcome?
just wanted to get your attention <3
Mmmm
It should be BMW , Bec getCarType , Gets the Car type that's is BMW Bec the String is Private , is this the right answer ?
Its not. The answer is:
Opel
Audi
"Bec the string is private" no, because the string was never changed from the started, you just got fooled with the method names
._.
Thats a bungeecord problem
The Lobby server isnt online
lemme try it it
..
Then its probably not set up correctly
So how can I setup it?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
try me
Oh wait i fked up in my CarTrader class
lmao
u could remove the type param and it would still be the exact same
?learnjava @sand rune these are links if u wanna learn java
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
I would like to prevent block (flowers) from being destroyed by fireball explosion or water, I tried the BlockExplodeEvent but it is not triggered when the flower is destroyed, same thing for the BlockPhysicsEvent and the water
here u go @lost matrix
public void setCarType(String type) {
this.carType = type;
}
:D
now with that it prints ur original outcome
u 100% know it, it prob was a blunder lol
The BlockExplodeEvent should work if the flower is directly destroyed by the explosion. Just not if the explosion destroys a block that has a flower on it.
just check if blocks destroyed have flowers above them
nop it doesn't work
and yes my event is registered
the blocks isn't destroy by the explosion
it is a fireball explosion on end stone block
the block resistance is too strong
I mean you also have to listen for the EntityExplodeEvent as this one is triggered by creapers and fireballs.
BlockExplode only covers beds.
^
ah
when i am using protocollib and sending entity spawn packet with entityuid sometimes i get warning that entity with same entityuid already exist how to fix that i am on 1.17.1
but there no block option in the EntityExplodeEvent
Don't use an entityuid that exists and you will not get an error
UUID.randomUUID()
moment
jk dont use that
i am using UUID.randomUUID()
my bad I can clear the blockList
@EventHandler
public void onExplode(final EntityExplodeEvent event) {
event.blockList().removeIf(this::isProtected);
}
@EventHandler
public void onExplode(final BlockExplodeEvent event) {
event.blockList().removeIf(this::isProtected);
}
private boolean isProtected(final Block block) {
return Tag.FLOWERS.isTagged(block.getType()) || Tag.FLOWERS.isTagged(block.getRelative(BlockFace.UP).getType());
}
Try this
is there a reason that chunk doesn't implement equals?
then how to assign uuid to entity?
dunno i dont mess with nms
and is there a solution for water ?
big brain
Water doesnt get destroyed by explosions
Ah. Uhm i think the FromToEvent
just
@EventHandler
public void onFlow(final BlockFromToEvent event) {
if (this.isProtected(event.getToBlock())) {
event.setCancelled(true);
}
}
boolean ez = true;
block break event {
for(block : blocks){
if(block is flower){
event.cancel
}
}
}
ez
tbh u couldve just checked the docs but ok
I did
declaration: package: org.bukkit.event.block
if u did u wouldve found it easily lol
its on first page
lol
anyway who cares
Is there any video to learn to code minecraft plugins?
Do you know Java?
There are plenty. But you should start with Java.
i recommend KodySimpson
his tutorial series has 72 episodes
its been going for years
and is still continued, he uploaded a vid on it 1 day ago
or 2
he also has a very good java tutorial
over 20 episodes i dont really remember
i could recommend it more than websites
Thx
Does someone know a program that is able to check a folder on Malformed JSONs? I have a resource pack full of jsons, deleted the ones I don’t use, validated the ones I edited all seems fine but it keeps giving me a Json malformed error. https://0bin.net/paste/yJmiNBOE#lVn1phBXwG933t8FgPzD+Rwyjo5luZAU+NeNGUPzP0B
0bin is a client-side-encrypted alternative pastebin. You can store code/text/images online for a set period of time and share with the world. Featuring burn after reading, history, clipboard.
Im trying to teleport an entity when it is far away from players however i am having an issue where it is not getting teleported when it is that far away (assuming cause it is in unloaded chunks)
im trying to get this to work for both 1.8 and 1.17 so unfortunately i dont have the plugin chunk tickets 
also - the method to cancel chunk unloads has been removed since 1.8 so i cannot use that... any ideas
Run the same teleportation logic on chunk unload ?
To teleport the entity before it is unloaded
yeah... how do the methods like Chunk#load work? does it stay loaded for a while or does it immediately unload when mc sees there is no point of it being loaded?
Pretty much
ig the other way to do it is to despawn the entity when it is about to go into empty chunks? that way i could wait until it is in loaded chunks again and respawn it?
for context i have a list of locations i am iterating thru and teleporting them along
i also avoid loading a tonne of chunks
String resultMessage = deliveryMessage;
if(deliveryMessage.contains("@")) {
resultMessage = deliveryMessage.replace('@', ' ');
}
is this fine
i use result mesage later on
you can still get the location and update the entities location without actually teleporting it.
im new to plugin development, how would i make a command only usable once? like once a player uses the command, they can not use it ever again
you'd store their uuid in a form of persistency (e.g. a database) and validate that, when they run the command, their uuid does not exist in the persistency layer yet
another alternative, maybe better for you as you are new to plugin development, might be the PDC
or just writing it into a config file
Alright! I'll check it out
?pdc
basically allows you to write data onto the player object directly that persists over a server restart
hence you could simply store a byte or something on the player and check agains tthat
yes
thats only in minecraft 1,13+ tho
u gotta use nbt if ur under that
which is also ez
@lofty laurel LOL
I HAVE ANOTHER IDEA
give a player the permission to use it when he joins the server and hasnt played before
then when he runs it his permission get removed
thats the best way to do it imo
and simplest
yeah thats probably better for me bc i've tried like 5 times and just getting an internal error when running the command lol
i have luckperms
o
ok use it
u can use that too
or just use luckperms or pex or whatever
i recommend this way more than nbt if ur under 1.13
if ur not
its easier to do with persistent data containers
i can spoonfeed you if u want
i'm not under 1.13 rn but im planning to switch to 1.12.2 later
I'll try do it myself, but if i need help, then i'll ask
u cant make ur plugin cross version compatible with pdc
you would have to recode the whole thing
it can only be 1.14+
(there is a 1.13 pdc but no one knows it much LOL)
anyone know why my chat method works fine, but when i say something with % or just % it goes back to default minecraft chat?
https://paste.md-5.net/lavayupafe.java
wdym
yeh uuids alot better
oh ok
cuz then data doesn't get lost and stuff when someone changes their name
i got it now
in this context you should use nothing
because its hardcoded
and thats the most bad thing you can do
also how do i do that
just set the format
and replacing & with § in your sent message
the player checks are totally redundant
Usernames are changeable. UUID's are not. This means if you are storing data using player names, and that player changes their name, they'll lose that data.
idk what you mean and i use translate cause someone told me it was better
and it's also a tiny bit easier to use
"better" is wrong here
does it really matter tho
its better for the future since mojang could always remove § as the colorcode what will probably never happen
not really
alright, anyways so what do i do
first of all you should work with scoreboard teams
and not directly checking for the player
wdym
can i use unicode letters for my custom textured ranks?
alr, what about suffixes?
do i do in game or in java
in java
hello, is there something like https://wiki.vg/Entity_metadata but for older versions like 1.16
can i write the contents of a set to a file?
tho a bit harder to find the right page for a version 😅
i saw this but i dunno if its good
https://stackoverflow.com/questions/7673424/how-to-dump-a-hashset-into-a-file-in-java
helpfully the editor left a message for the change to 1.17
yea, tho that message is sadly not uniform for other version updates xD Basically just look for "updated to"
thanks
Same problem, but now with the gold blocks. I can't break them, until the chunk unloads and the loads again. How can I fix this? For the beacon I fixed it by get the block by the persistent data container.
@lost matrix Can you help again?
This SQL query is taking 10ms, I'm wondering if there's a way to reduce that at all. There's 11,621 rows within the database. java this.sendSQLCommand = this.mySQL.getConnection().prepareStatement("Select * from data_table where id="+id); this.allData = this.sendSQLCommand.executeQuery();
10ms seems pretty okay for a full db call no ?
so let it take its time. just call it async
10ms already includes the network connection as well
also why are you even using a prepared statement if you just hammer the variable into it anyway 😭
I just don't know any other way
async?
yes. database operations should be done async
The code is working, but when having to execute the query it takes 10 seconds per query.
I'm not sure how to do database operations async, or what that means
10 seconds or 10 ms
10ms, 1/100th a second
yea again, 10 milliseconds is perfectly fine for a DB call
^
if you cannot live with that blocking your server thread, then execute it off the main thread
When I do it like 50 times in succession though it causes lag
You can also use CompletableFutures
a CF would be better
Ideally you shouldn’t be doing it that much
since you will need the return value
Cache things
How do I cache things
Save the things in a variable
And don't call it every time
For example: By loading the server, store the table in the code and work with. By restarting the server just push the variable to the db
Oh so like, save the resultset in a variable and continuously use a for loop when getting to the correct index?
As example.
There are many ways to store a db.
Are there any more efficient ways? I wanna be as efficient as possible
Just make a class: table
And then add the things to the class a table have and save the table as that class.
That should be a very efficient way
Okay cool thank you :>
is this a good way to try to add an item to someone inventory at the given slot?
public static void tryToAddItemToInventory(Player player, int slot, ItemStack item) {
PlayerInventory inventory = player.getInventory();
while (inventory.getItem(slot) != null || inventory.getItem(slot).getType() != Material.AIR) {
if (slot < inventory.getSize())
slot++;
else return;
}
inventory.setItem(slot, item);
}
@tardy delta Just use inventory.add(item);
that doesnt check if the slot is empty?
Nope. But you could check if it's empty
if(inventory.isEmpty())
I think
no
inventory.getItem(slot) == null >> inventory.setItem(slot)
or the type == material.AIR 🙂
Better use null
just use addItem
i understand but i want to add the item at that slot and if that slot isnt empty add it somewhere else
Yep. Like I said
it returns you a map that contains items that didn't fit
you can just check in there
Top left
i want in hotbar
Upon reloading plugin entire config resets and deletes all changes that happened during runtime, how do I prevent this? I basically want those changes to stay.
Bro. don't make it complicated. What are you trying to do?
int slot = <slot>
slot = inventory.getItem(slot) == null ? slot : inventory.firstEmpty();
if(slot != -1)
inventory.setItem(slot, item);
Did you save anything in a map?
Nope
Did you save the config correctly?
adding an item to slot and if thats not empty check other slots that come after it
How do I even save?
That's what I was wondering
Look at the code of yapper
Ah. that's the point.
saveConfig
Wait
Yes. i wanted to google
firstempty in which direction is that looking for a slot? 🥺
From top left
No. Everytime after editing the config
Alright thanks
i just wanted to let the distance between the target slot and the slot where its finnaly placed as small as possible
but yea if thats isnt possible : (
It is possible. Just use math if you want it that way
math brrr
Part of programming
getConfig().save(fileHere); how do I put file?
yea i dunno how
Did you save the file in a instance?
No ;-;
Try -> If it's not working -> send code and explain
You have to.
ty
The code I posted above does exactly that
Its gets the first empty slot of the inventory
if its -1 there are no empty slots
yea but it checks for empty slots beginning from the top left
They want it as close to the target slot as possible
Say you put it at slot 1 right??? but that slot contains an item.. but slot 2 is empty... firstEmpty will give you slot 2
oh really
yes
Yes but if you want to put it at slot 10 and it’s full, first empty would still find slot 2 first
In a player inventory yes
oh ok
@young knoll is right about firstEmpty though so keep that in mind
If you want it close to a specific slot you can just use a loop and check if slot +- loop value is empty
First empty will find the first empty slot
Which isn’t necessarily the closest empty slot
hello! How can I send a custom sound to a player?
I'm currently using this ENUM: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
declaration: package: org.bukkit, enum: Sound
but some users add new sounds via a resourcepack
you cant use that enum for playing custom sound
you have to use the playSound method with a String
and for the string put the custom sound name
from the resourcepack
Hello. Can someone help?

