#help-development
1 messages · Page 320 of 1
acf has too much more stuff
That I don't need
Just need to fix the splitter
And prefer to do it myself
then just dont use it 😛
So I can learn
whats the problem with it?
This
Command: ds Args: [user, add, TSans_]
Sometimes it'll think the command ran is user and user.add
Like makes no sense
super quick question n im not really sure how to word it:
My plugin is depending on mcmmo and i want to make it so that a scoreboard shows up every time a player gains xp in a skill. I have the event, which is "McMmoPlayerXpGainEvent." so i typed "@ eventhandler publicvoidXPGainEvent(McMMOPlayerXpGainEvent e)," but what would i type to check the skill value?
I checked the source of MCMMO and I found this under the event
" public McMMOPlayerXpGainEvent(Player player, PrimarySkillType skill, float xpGained, XPGainReason xpGainReason) {
super(player, skill, xpGainReason);
this.xpGained = xpGained;"
Same command, exact same will sometimes trigger the parent command randomly
So I assume my arg splitter is messing up
event.getSkill() ?
returns a PrimarySkillType
ty!
np
@tender shard Not possible to debug methods using IntelliJ right?
Like not in a plugin
you can do that
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Can I add breaks? Call a method manually with input? etc?
yes, sure
but you gotta set the timeout interval very high, otherwise the server thinks it died
Do you think that's my best solution to test out my method?
I just need to test the 1 method not anything else
the intellij debugger if ofc extremely powerful, but it's a bit annoying to set it up
Happens randomly which is why I'm losing my mind
That why is something called primary debug, if you want to something more advanced you can look into unit testings
I finally ended the beta version, just need to test it
for (Command cmd : subCommands.keySet()) {
final String name = cmd.name(), cmdName = commandName + (possibleArgs.length == 0 ? "" : "." + String.join(".", Arrays.copyOfRange(possibleArgs, 0, name.split("\\.").length - 1)));
if (name.equalsIgnoreCase(cmdName) || Stream.of(cmd.aliases()).anyMatch(commandName::equalsIgnoreCase)) {
command = cmd;
break;
}
}
Narrowed it even more to ```java
final String name = cmd.name(), cmdName = commandName + (possibleArgs.length == 0 ? "" : "." + String.join(".", Arrays.copyOfRange(possibleArgs, 0, name.split("\.").length - 1)));
That's the line that's screwing up the args
that line looks horrible lol
split it up into more detailed steps
Hmmm alr
then always print out the "inbetween" result
I'm straight out debugging
Only way I got to that
String.join(".", Arrays.copyOfRange(possibleArgs, 0, name.split("\\.").length - 1))
That line
That portion of the line
Is there a better way to join String array elements?
FIXED IT
Holy crap
I hate the dev that made that lib
4 hours
Copilot is cheating anyways
Perfectly mirrored method
Yah copilot is nice
Why are you doing args check like this?
Stringbuilder
Must be somewhere else
@Command(
name = "example",
aliases = {"firstAlias", "secondAlias"},
permission = "example.permission",
desc = "Sends an example message to sender",
usage = "/example",
min = 1,
max = 5,
cooldown = 10,
senderType = Command.SenderType.CONSOLE
)
All those
Optionals
Ah
Stringbuilder should probably be used for that code
It's pretty cool tbh
Just had to fix that 1 bug
Took 4 hours
IntelliJ remote debugging
And a walk, but I got it
At least you fixed it. Now time to optimize it
Now fixing the autocomplete :/
Yeah I will
Gonna sort the autocomplete
Here we go again
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, String[] args) {
plugin.getLogger().info("Completions: " + completions);
for (Map.Entry<Completer, Map.Entry<Method, Object>> entry : completions.entrySet()) {
final Completer completer = entry.getKey();
if (command.getName().equalsIgnoreCase(completer.name()) || Stream.of(completer.aliases()).anyMatch(command.getName()::equalsIgnoreCase)) {
try {
final Object instance = entry.getValue().getKey().invoke(entry.getValue().getValue(), new CommandArguments(sender, command, label, args));
return (List<String>) instance;
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}
}
return null;
}
Oh god
I found the autocomplete error :/
The ability to do the same thing 1012312313 different ways is both a bless and a curse
Just fyi unless you are only doing join for one or two things. Stringbuilder is going to be the best in most cases
Isn’g join just a glorified stringbuilder
Isn’t*
Jan help me figure out this death
No
I am busy
Join will not do any extra copying and can work the exact length out. However its downside is having to check twice and ruining the cache for strings to do so. So if you have an array of strings better to use stringbuilder as that is what it is for.
Also its cleaner looking when using stringbuilder if you have a bunch of strings vs doing a bunch of joins everywhere lol
In terms of optimization join only wins if used minimally and stringbuilder wins in all other cases
How to use string Builder to append a String[] with "." delimeter
@wet breach
Since you seem to be loving stringbuilder
Well not really Id say
StringJoiner uses a StringBuilder under the hood
String fullCommand;
if (args.length == 0) {
new StringBuilder(command.getName()).append(" ").append(String.join(".", args)).toString();
}
fullCommand = new StringBuilder(command.getName()).append(".").append(String.join(".", args)).toString();
How would I simplify that block of code?
What are you doing more precisely?
I need to combine a string with a string[]
But if the string[] is 0 then I just need the original string1
Otherwise append all of string[] with "." delimeter
String fullCommand = new StringBuilder(command.getName()).append(" ").append(String.join(".", args)).toString();
if (args.length != 0)
fullCommand = new StringBuilder(command.getName()).append(".").append(String.join(".", args)).toString();
Still kinda long
Couldnt you just
String fullCommand = command.getName();
if (args.length != 0)
fullCommand = new StringBuilder(command.getName()).append(".").append(String.join(".", args)).toString();
yes
.append(args.length == 0 ? " " : ".")
Hmmmm
Which gets rid of you having 2 almost identical code blocks
Wait I got a diff issue at hand now
In a way yes. But the thing that join misses out on is no buffer hence duplicate copying unlike stringbuilder where it does have a buffer and uses that for its copying which doesnt result in allocating.
How can I get the names of all players connected to a server into a List<String>
From bungee or the server?
Arrays.asList(Arrays.toString(Bukkit.getOnlinePlayers().toArray())) returns [CraftPlayer{name=TSans_}]
I just need a array of the names
Server
Yes
I just said it returns [CraftPlayer{name=TSans_}]
How can I extract just the name
You dont need toarray on a method that already returns an array
You are not doing anything that requires a snapshot. All you are doing is making a copy which you can use addAll from the arraylist interface
Anyways
for (Player player : bukkit.getOnlinePlayers()){
player.getName();
}```
So the only way is making a method then
Alr thanks
private List<String> getOnlinePlayers() {
List<String> players = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getName());
}
return players;
}
Just did that
You could make it simpler
Not in never versions.
It did back in the day tho
players.addAll(bukkit.getOnlinePlayers);
Just make players hold the player object. Then when you need to loop you can get the names and do some other stuff in the loop as well that you need done.
What does it return now?
It’s a Collection<? extends Player>
Ah
Not sure why that was changed but alright then
Idk it changed a while back can’t remember when
Seems i was wrong for updated versions
Odd
But my console is spamming
at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.callInventoryOpenEvent(CraftEventFactory.java:1226)
at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.callInventoryOpenEvent(CraftEventFactory.java:1221)
at org.bukkit.craftbukkit.v1_19_R1.entity.CraftHumanEntity.openCustomInventory(CraftHumanEntity.java:322)
at org.bukkit.craftbukkit.v1_19_R1.entity.CraftHumanEntity.openInventory(CraftHumanEntity.java:307)
at me.tomisanhues2.deepstorage.gui.guis.BaseGui.open(BaseGui.java:493)
at me.tomisanhues2.deepstorage.events1.ChestEvents.createNewGUI(ChestEvents.java:91)
at me.tomisanhues2.deepstorage.events1.ChestEvents.lambda$openAddGUI$5(ChestEvents.java:117)
at me.tomisanhues2.deepstorage.gui.guis.GuiListener.onGuiClose(GuiListener.java:143)
at jdk.internal.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589)
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576)
at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.handleInventoryCloseEvent(CraftEventFactory.java:1384)```
I can't see it in latest.log
Weird, unfortunately dont have time right this moment to help with that error. Will be home in about 6 hours though
Send the full error in a paste
?paste
The developer fixed it
He knew about it
Must add at least 1 tick delay
Game limitation he said
What's the best way to detect if a player added a item to a chest?
Shift clicking it in or anything like that
Inventory click event and checking inventory for changes
Nvm
Inventory click event detects shift click
Just get the clicktype and check for shift click
Hold on pause that
And then for normal way its just using inventory drag event
How can I get a Chest object from InventoryClickEvent
new to java:
Trying to set up a command that runs a scoreboard command whenever a player gains XP in a skill. it checks which skill, then runs the command. The problem is, if the scoreboard for the Mining Skill is already up, it still keeps trying to set it to Mining. can anyone help me fix up my code a bit so it will check to see what scoreboard is already running?
Code:
package slug.essentials.slugessentials;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.interfaces.Skill;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.util.player.UserManager;
import net.royawesome.jlibnoise.module.combiner.Min;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.w3c.dom.Text;
import java.awt.*;
public class XpGainReader implements Listener {
@EventHandler
public void onXPGain(McMMOPlayerXpGainEvent e) throws InterruptedException {
Player player = e.getPlayer();
String name = e.getSkill().name();
if (name == "MINING") {
player.sendMessage("Skill: " + e.getSkill());
ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
String command = "usc setScoreboard %player% MINING";
command = command.replace("%player%", player.getName());
Bukkit.dispatchCommand(console, command);
Thread.sleep(4000);
String commandreset = "usc setScoreboard %player% SCOREBOARD";
commandreset = commandreset.replace("%player%", player.getName());
}
}
}
Quickshop plugin is not working not working even if i do /qs there is nothing like quickshop why?
use .equals(...) for comparing strings
Do you know any solution of my problem?
thats the first problem i see
?
in help server?
yeah you just ask your question there, this is for plugin development
help server
oh
Yo, is there any way to suggest player a command without their need to click text component?
thank you
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
?deque
Hey! I'm working on allowing upgrades for my plugin. For example:
MyClass.class
-> int maxNumber
-> Default at 10. {10,20,40,50,etc,etc}
Every tier would have a price associated with it.
How do I define a upgrade collection like that?
Instead of pasting a bunch of code here please use the paste site or at minimum use the code block
?paste
But preferably use the paste site
can you elaborate a bit more? whats maxnumber? where/whats's the tier? what do you mean by price associated with it? like money needed to upgrade? linear, exponentially?
For sure!
maxNumbers is just a int in MyClass.class. It can be upgraded to hard coded tiers that cost money ( Forget about the vault implementation ). Example:
{20, $40}
{40, $100}
etc
So im wondering what's the best way to define those tiers
To then do like:
getNextTier.getPrice() etc etc etc
Is the best thing just to create a Map<Value, Price> as final static?
if you want to have an infinite amount of tiers, you dont define them. otherwise i would keep track of them somewhere
if you want to be able to know the next you would need to keep track of the current tier (what you would have to do anyways) and a kind of hierachy, order.
I don't want infinite, I want to specify which ones and the cost
I'm just wondering if the best way to store this would be inside MyClass.class as a Map<Value, Price> as final static or enums or something else @hybrid spoke
Key/pair value
enums could work
but i think i would prefer the map
even if enums would be more clear
what would MyClass be?
Isn't that waste of resources? Cause everytime you create a MyClass.class object
It would create the upgradeList all over again
no. you would have a global map and the stuff that needs the tiers would just refer to the values inside that map
static
Oh so it doesn't make it again
ok cool
Gonna do that then
Now a more advanced question
I'll dm you a file rq
Why are you storing 20 twice
I want to get the block where an item dropped.
which event will be good for this?
item physics or item spawn?
my bio says it all
If I make a static map for each upgrade you see, since I don't actually need to serialize the static maps, do I still have to include all the data in my deserialize
@warm light BlockBreakEvent.getDrops?
spawn
I'm not asking for support in dms. I just prefer not to send my entire file here
Afraid someone will steal it?
give me a sec, leaking it rn
Didn't think it would matter that much
Alright well thanks for the help anyways ig
well im not exactly sure at what i am looking at
thats only for players. but drop can be from anywhere
what exactly are the upgrades? thought its a tier system?
Use item spawn if you need all items
if you only need block drops you can use BlockDropItemEvent
I did this to get to bottom block (where the item will be dropped)
but server get stuck :/
Location loc = item.getLocation();
Item item = event.getEntity();
Block bottomBlock = loc.getBlock();
while(bottomBlock.getType() == Material.AIR){
bottomBlock = loc.getBlock();
}
on ItemSpawnEvent
you are getting the same block every time and locking the server
Well obviously
there is no spigot method to get the block. how can I get it?
if a player dropped a item, it will be on air first. then on ground
you have to use teh blocks location not a fixed location
If the tier price goes up in a predictable way you only need the base price and what tier upgrade being applied.
but how can I get the block location? there no method like that on spigot api
loop make the server freeze
I can run the task later but it wouldn't work if item drop from very high ._.
Cant you raytrace?
Don’g loop
You have an infinite loop. Ofc the server is going to freeze
Damn station wifi sucks
And spigot does have api methods to get the block
Item spawn gives you a location. Modify that location to subtract 1 from y. Then use World.getBlockAt(location)
or just like elgar said, use getRelative which gives you the block below
Block block = item.getWorld().getBlockAt(item.getLocation().sub(0,1,0));
It despawns
then the block would be just air
as of what i understood he's trying to get the block below on spawn
looks like it
that's a bit more complicated
Gave the code essentially above lol
then just brute force your way down
I'd just do a raycast down with a range of like y level
Why? That is so much slower
ehh
checking a single block is not what he wants
getting the block below is 1 thing
getting the lowest is another
It's basically predicting where it's gonna land
but without actually any physics
Ok make a loop to modify location y with the code i gave, toss all the blocks in an array
Doubt the item is going to have some insane velocities
Or fly off
let it bounce
umm, but the item can be dropped from anywhere
Items are entities. Just wait till it doesnt have velocity.
and don't use a while loop on the main thread to wait
Wont take but a few ticks for it to not have velocity unless you are spawning way up in the air lmao
why dont just iterate your way down to earth
that'd be way less than a tick
if its not spawned at 20000000 y
That is what i essentially said above
thats what we all said
You can just loop over the location modifing the y value of said location
umm. let me try
But yeah solution is nothing complex
How can I get a (Chest) object from InventoryClickEvent only when a custom chest is clicked
No can do
Chest chest = (Chest) event.getClickedInventory().getHolder();
error
Caused by: java.lang.ClassCastException: class me.tomisanhues2.deepstorage.gui.guis.Gui cannot be cast to class org.bukkit.block.Chest (me.tomisanhues2.deepstorage.gui.guis.Gui is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @310f378; org.bukkit.block.Chest is in unnamed module of loader java.net.URLClassLoader @46ee7fe8)
at me.tomisanhues2.deepstorage.events1.ChestEvents.withdrawItem(ChestEvents.java:146) ~[?:?]
at me.tomisanhues2.deepstorage.events1.ChestEvents.lambda$addItemList$4(ChestEvents.java:133) ~[?:?]
at me.tomisanhues2.deepstorage.gui.guis.GuiListener.onGuiClick(GuiListener.java:102) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.19.2-R0.1-SNAPSHOT.jar:?]
Presumably you use a custom inventory holder there ?
TriumphGUI
But idk why that would prevent me from getting it from InventoryClickEvent since the api just adds addAction()
there is no chest there
getView().getTopInventory().getHolder() or getLocation()
its a custom inventory
But if a chest doesnt actually exist. Then i dont see the purpose of getting a chest
Gotta just pass the chest object around ig
A physical chest is not required to do stuff with a chest inventory
Dont see why you need a physical chest
The data is stored in the chest
pdc
It's not a command thing, it's a physical chest
You could just use the chunks at spawn and use the chunk pdc.
This way you dont need physical chests or add them
Was easier to just have a physical chest
or just attach the PDC instance to the custom gui 🤔
you can get the live instance iirc
actually, idk if that is spigot or not
Now we talking to complicated
Its not anymore complex then what you are already doing
Really?
Didn't know that
But I gotta be honest I'm really really happy with how it's turning out\
Anyways if its working like you want it then so be it though. Its your plugin lol
After a lot of hours of figuring stuff out
using a physical item has good properties aswell. you can easily transfer them between players without commands etc.
You dont need commands even if it was virtual
unless its for each player their own storage
You can share the inventory view with multiple players in that case
Yes!
I even made a thing where the chest has a list of UUID
So you can add allowed players to the chest
But still doesnt require a physical chest
But like i said it is your pluging. So if it works the way you want then who are we to complain lol
does ProjectileSource only return entities?
i want to know if the projectilesource is a dispenser but seems like the list is just entities
not just arrows
its good to check for Entity anyway
im trying to now make firecharges not work basically
but just not work if it's from a Source in a different chunk
so trying to check where the source is
declaration: package: org.bukkit.projectiles, interface: BlockProjectileSource
oh amazing
i fcking read the soruces and didnt see that
saw like 5 lines of just entities
yeah i had to look really hard too
you're the man
Map#get(String key)
map.get(key)?
nono
yesyes
Oh wrong phrasing
how to get the key of a value u mean then?
How can I get the key value of index 0
dont think so
.entryset.get(0)
How can I convert ```java
public static final Map<Integer, Double> MAX_ALLOWED_ITEMSTACKS_UPGRADES = new HashMap<>() {{
put(1000, 1.0);
put(5000, 2.0);
put(10000, 3.0);
put(50000, 4.0);
}};
Oh nvm defo using that instead
What do you mean of index 0? Do you have map or an array?
☠️ people creating anonymous subclasses of hashmaps
is there a recommended max of an array/hashmap size before it "starts lagging"(affecting ticks)? 🤔
Not really
as long as your memory is large enough its good
I'm afraid some of my hashmaps will get really big at some point
I have my message above, was the simple way I could think about
so as long as server has enough memory ram then it's fine?
A map does not have an order
Does not exist
or well, a hash map does not
Yeah I know that
Meh it’s a set so that’s why
yeah, just be mindful of server resources, maybe clean up the hash map every now and then
so the concept of an "index" is useless
A hashmap is not sorted
ArrayList.addAll(map.entryset())
Believe that should work
Well not the one i did.
On phone so cant really check lol
it's my own server so it's fine but i basically create a hashmap with the chunks location protected by players and then instead of changing/checking a config everytime, i just update this hashmap and save when server closes.
I meant code i gave
i thought it would be better for server performance
@wet breach It’d probably be jumbled up unless he sorts it
Well that wasnt part of the question lol
seems ok, maybe you wanna use a database for this tho
atm this one hashmap has 120 in size. but it will always increase ofc... 🤔
there's a local yml database when server closes and opens.
It’s probably fine
PDC 
just thought a hashmap would be more efficient than changing the yml all the time
Though don’t make it too big
I would use expiring cache from guava that is shaded in
I meant something like SQLite
never used sqlite, only mysql or ymls
not too much difference tbh
Lets you setup save and load methods and cache takes care of the rest
anyone has a good spigot thread tutorial on how to do it?
?bing
Bing your question before asking it:
https://www.bing.com/
This way your map is never too large
thank you, i will look into it in the near future.
how should the map be too large
just hold the chunk keys in there and invalidate on unload
and boom
server currently:
doesn't seem too bad yet to care much about it
since it can go up like 20x that
Not sure where the threshold is at. But you put enough objects in the map and it starts to lose its speed and can take time to fetch what you are wanting. Also no reason to keep stuff loaded if it is hardly being used.
So an expiring cache from guava which is shaded into spigot already would help with that because you can set when and how it expires as well as set what the save and load methods should be
doesn't even guava recommend caffeine these days
Have no idea and dont know what that is
Does that still exist? Like that is from 2019
is there an event when chunks are loaded/deloaded?
Yes
maybe i can use that to store/delete chunks from my hashmap, no point having chunks there if they are not loaded
Chunkloadevent and chunkunloadevent
oh ok ty, i will keep it in mind for the future then
yes
the javadocs literally tell you to use caffeine xD
Well weak hashmap stuff and what not
ye, so I don't think you can replace guava
maybe ship caffeine ?
but also, just shade it / use library feature
Maybe we can see if we can get caffeine shaded in then? Lol
Would be better then having a bunch of projects having to shade it. Considering guava is EOL it seems like
After java 7 support ends
It is what it said
So whenever that happens guava is EOL unless they change that lol
Consider Caffeine for Caching to Replace Guava After EOL of Java 7 Support```
I don't think guava goes EOL
maybe the caching shit ?
the JRE flavour of the lib already uses java 8 (https://github.com/google/guava/blob/master/README.md?plain=1#L14)
already lol
That could be it? Maybe they might remove the caching from guava?
Is that true for enterprise support?
Typically that is what is usually referred to with these kinds of projects
no idea xD
Anyways enterprise was up 6 months ago
So fairly recent then
So that comment lines up just right as it was posted in 2021
yea, if you just use it for caching I guess its just a nice switch to make
So i guess we could create ticket for spigot in regards to guava caching being eol then. But first need to do some more information gathering
So I've turned off dispenser projectiles on the entity damage entities event from different chunk owners.
But now I want to make it so people can't use fireballs to put other chunks on fire and this isn't a entityDamageEntity event. Which event could I use for this?
I wonder if the API uses caching anywhere
Not sure, but regardless worth letting everyone know who isnt aware
true I guess 😅 at least raising it to md_5, tho I'd guess he knows
Doubt it
¯_(ツ)_/¯
I didnt even know about it
who knows what information makes it to upside down land
But yeah worth letting people know and the fact that bug hasnt been fixed
With the caching eol they are not going to fix any other bugs found
But before i make a ticket i want to gather more information on it to see to what extent
Dont want to raise any alarms if not necessary lol
Is there a way to make PlayerItemMendEvent consume the XP but not repair the tool?

cancel it but remove the experience orb
Cancel the event. Take xp and repair the tool manually.
Alright. Thought there would be a built in way to do that
By take he means remove or kill
They wont notice the difference
Lol nice
Hey i didn’t read contrxt
Just because you are cancelling the event doesnt mean you cant use the methods to obtain the relevant items and xp
Just dont use the methods to change anything and use the other api methods
And with that i am signing off and going home
is there a way to get the coordinates at 4, 4 in any given chunk?
Lynx has got you on this
you can convert a chunk x to an in world location using x << 4
same of z
xD
I was getting ready for the typewriter race
Unfortunately i am getting ready to clock out from work
oh alright
so when you get the location of the chunk, it returns the 0, 0 coordinates?
well it doesn't get you the location at all
alright cause i’m confused how you get a chunk x
it returns the x key of the chunk
chunks are uniquely identified by a combination of their x and z key
yeah it took me a sec lmao
obviously yes, but that shouldnt happen if the chunk hashcode generation is done right. otherwise just count up an integer. doubt that you will get a collision with only chunks if handled right
Well it isnt just collision. Still need to search for the key. Eventually takes longer to fetch if you have a large enough map
Someone knows an Framwork thats works with spigot and velocity?
and if you have enough chunks loaded to overclock the keys you have other problems than that
with different keys and hashes the search will stay O(1)
No that isnt possible after a certain amount since there isnt infinite time
O(1) also does not particularly mean you are going to be fast 😅
sure, and precisely said it isnt O(1), but near to O(1)
nearer than to O(n)
so fuck the size of the map
I mean yea, if you have a shit load of values your map is going to be faster on average than a list iteration (in trade of for more memory needed)
Alright driving home now 
Could be worth a watch 👀
https://www.youtube.com/watch?v=o4-zpAI7qBc
Have you ever analyzed your algorithm and found out that it runs in O(n^2) and thought to yourself, "man I'm a crappy programmer...". Well, you are! But not for the reasons you think! If you think Big Oh = performance, boy have I got news for you. In this video I try to dispel this fallacy that programmers have assumed, that Big Oh complexity eq...
This video was awesome
agree
so basically i should always go O(n!) but only for the first few steps to gain extra speed?
got it
12 iq interpretation, but you do you
why is player still receiving damage from lightning even when i cancel EntityDamageEvent?
fire?
we can only guess
provide some code

event.setCancelled(event.getCause() == EntityDamageEvent.DamageCause.LIGHTNING
&& PersistentDataWrapper.wrap(plugin, event.getEntity()).check("storm", true));
I checked via logging, both conditions are true
to make it more readable, you could do this instead ```java
Boolean isSourceLightning = event.getCause() == EntityDamageEvent.DamageCause.LIGHTNING
Boolean isSomethingStorm = PersistentDataWrapper.wrap(plugin, event.getEntity()).check("storm", true) //I literally have no idea what this is, sorry
event.setCancelled(isSourceLightning && isSomethingStorm)
yeah well but lightning normally sets the player on fire
so you gotta handle that too
agree when you change Boolean to its primitive type
When i use setdamage 0 instead it works, weird
then just do that instead :dogekek:
bump
I've tried entitydeathevent or entityexplodevent and fireball does not call either of them 🤔 wouldn't a fireball when touching a block "die"?
also tried entityinteract but fireballs doesnt call it either 🤔
projectilehitevent
since fireball is an projectile
public static Location stringToLocation(String string) {
// x, y, z, yaw, pitch, world
if(string == null) return null;
String[] alg = string.replaceAll(" ", "").split(",");
if(alg.length < 6) return null;
World world = Bukkit.getWorld(alg[5]);
world = world == null ? Bukkit.createWorld(new WorldCreator(alg[5])) : world;
return new Location(
world,
Double.parseDouble(alg[0]),
Double.parseDouble(alg[1]),
Double.parseDouble(alg[2]),
Float.parseFloat(alg[3]),
Float.parseFloat(alg[4])
);
}
public static void safeTeleport(Player player, Location location) {
if(location == null || player == null || !player.isOnline()) return;
new BukkitRunnable() {
@Override
public void run() {
player.teleport(location);
}
}.runTaskLater(Main.getPlugin(Main.class), 4L);
}
this code often teleporting to void i'm sure for the values but why he's teleporting me to the void or a survival world? am i doing something wrong?
most likely. try to debug your code
Empty lines is lava
i tried the same thing
doesnt tell us much. the survival world makes sense since you create a new world(if none with that name exists) if the destination world is null.
void could mean the unloaded world is still loadng or you fucked up the parameters
Check where you are using the location instance and look what could possibly cause that
@warm mica @hybrid spoke i tried both the survival is unloaded world yep, but the void i checked the parameters and every things is fine someone told me that i have to put the teleport function in the main thread and i didn't understand am i doing something wrong?
as once again, debug your code. we dont know what you enter in there. validate the parameters and give us a log
you could also check your console for exceptions
uhmm i'm gonna debug and see what will happen 🥲
Anyone currently using the serialize /deserialize method for ItemStack ? Are they working property? Containing all data?
I used a custom serializer before, considering going to use the serialize method of spigot
They work.
its not very readable/change-able but they do save everything
Yeah, but having a readable format where all data from the IS included would be tricky anyway
it doesnt seem to be working
And it's only to store data 🙂
not really
@remote swallow , I mean, if you want a properly serialized & deserialized value, you would need everything the IS has
There is not really something you would leave behind
code on cancelling:
event.getEntity().remove();
event.setCancelled(true);
Bukkit.broadcastMessage("supposed to be cancelled");```
i set to remove entity since just cancelling event wasn't doing anything so I deleted entity and put to send a message as "debug" but still it gets on fire 🤔
Yeaa, I use something simular at the moment
But still
If something is changing in the future to the IS format, it would break anyway
i had to make this on another project and it was just painful
I can imagine
so i just started to make this so i never have to do it again
I don't recall why I never went with the serialize and deserialize before tbh
Maybe it wasn't a thing back then
Hey, how would you guys go about writing a plugin that will generate a biome in every new chunk loaded?
It's an old project tbh
if its to a FIleConfiguration you can just use config.set("path", stack) and config.getItemStack("path")
Oh there is getItemStack on the config? didn't knew that
Well, I'm using jackson now also to serialize and deserialize
But having a map would help alot
Because Idk what jackson will try to do with the IS class :p
lol
can you visually rename variables in compiled read only classes using intellij?
not actually change the file, just edit them visually so they are easier to read when reverse engineering
with what
i tried it
ye ye well read
tho dont works
What error do you get
dont works
"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.
idk
dont create the db
BROTHA
?spoon
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
probably came here in hopes someone would give code, especially seeing they deleted the code they needed but had issues
can you visually rename variables in compiled read only classes using intellij?
not actually change the file, just edit them visually so they are easier to read when reverse engineering
not sure what you hoped we would do for you, however this isn't a place where we just drum up some code for you to use. In other words we are not going to do the work for you. The goal of here is to help you with already created code to point out the error or to help you understand where it is that it is going wrong so that you can fix it in hopes it works like are wanting. We do love to help people, just not do their work for them is all 🙂
srry
no worries, give it another try, do a bit of research to attempt to get it working, if all else fails instead of deleting what you have come back here and show us, and tell us what you have tried to do. Then we will be in a better to position to help you and odds are you will learn better from it as well 🙂
fine ty
Hey @wet breach, I finally managed to fix the connection leaks with Hikari. Turns out I'm just stupid. I had a global Connection instance at the core of my implementation and turns out I wasn't closing it. 🥹
i thought from the beginning are you closing your connection lol
I did too. :3
I'm now trying to figure out how to store a list of data into a table, but almost every thread relating to it seems to be against that idea. The problem is, I don't know what a better approach would be. I need what is essentially a Map<UUID, List<UUID>> stored. I'm trying to keep track of unique interactions.
dont you mean a map
Oops, I do.
ig work with foreign keys to link to records in another table?
atleast thats what i remember from classes
uh
i forgor how to do this
and i cant find any new tutorials
but how do you make like a /kit command
and give the p the item
Yea, I'd have to use foreign keys anyways. In this case it would be the uuid as the key and the table value would be the List<UUID>, but it seems that it isn't the best idea.
i forgot how item stacking works
so what you are saying is...you lied about saying you were closing the connections and I should keep pestering you about it until you find it next time
I wouldn't blame you. 😔
Lol all good, at least you fixed it
did you ever try BoneCP?
I would probably still use that
No, I was just so fixated on getting hikari to work. I'll give it a try on another project since this was such a hassle. However, I'm just glad it was an issue with my code and not the library.
I have used it in the past, but like ~2 years ago in the past. It's just that people recommended to switch to hikari, so I finally decided to give it a try when I actually needed to make a MySQL implementation.
and then the recommendation turned out to be hard to implement because it couldn't tell you there was something wrong
all it knew was just that there is a connection leaking somewhere randomly XD
whats the item stack thingy on setting an items name
ItemMeta#setDisplayName()
org.bukkit.inventory.meta.ItemMeta is most definitely a thing.
oh
Google your question before asking it:
https://www.google.com/
I need a help
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
No
yo
java.sql.SQLException: path to 'plugins\SQLite\table_name.db': 'C:\Users\USER\Desktop\Mc Server\1.12.2 2\plugins\SQLite' does not exist
😿
probably means it doesn't exist pal
and if it doesnt exist
then you need to create it
@quaint mantle getItemMeta returns a copy
It doesn't return the item meta actually associated with the itemstack
So you need to get it
Like ItemMeta meta = Item getItemMeta;
Then make all your cjanges to meta
Then do Item.setItemMeta(meta)
java.sql.SQLException: path to 'plugins\SQLite\table_name.db': 'C:\Users\USER\Desktop\Mc Server\1.12.2 2\plugins\SQLite' does not exist
doesnt that create the folder automatically?
what can i do
That should work yes
im newbie
k ty daddy
Show your code so we can fix it
package code.main;
import org.bukkit.plugin.java.JavaPlugin;
import code.database.Database;
import code.database.SQLite;
public final class Main extends JavaPlugin {
private Database db;
@Override
public void onEnable(){
this.db = new SQLite(this);
this.db.load();
System.out.println("Plugin started");
}
public Database getRDatabase() {
return this.db;
}
@Override
public void onDisable() {
}
}
its the normal
database/
Database
Error
Errors
SQLite
oh god new Sqlite
I’d like to search all inventories on a server for an item, anyone know how to do that?
Tried everything and something weird happened..
The player teleports to the default spawn location idk why
And if i try to make /tp to the location something prevent the tp
Should i load the chunks or do something i'm confused
i cant send the file
?paste
?img
Not verified? Upload screenshots here: https://prnt.sc/
true
"Something went wrong!"
ye
use new File(getDataFolder(), "database.db").createNewFile() if it doesnt already exist
i usually do this where ensureFileExists creates it if it wasnt already created
need a plugin instance to call that on
a
If you're new to Java working with SQLite might not be the best idea
😿
pls
i hope they know sql
Doubt
just use the yaml stuff at that point
brh
?cmd
getCommand(name).setExcutor() in main class
Google your question before asking it:
https://www.google.com/
?bing
Bing your question before asking it:
https://www.bing.com/
do i have to put something in the executor thing or just leave it empty
ok
i figured it out
i watched a yt video
but the itemmeta did not work
bruh
like the name and enchants are just not there
getItemMeta returns a copy you can modify
and then you need to put it back on the item
i did .setitemmeta
kpph.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1);
kpph.getItemMeta().setDisplayName("KitPvp Helmet");
kpph.setItemMeta(kpphItemMeta);```
ooop i dunno why its like that
?cba
Jan Tuck#0142 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.
kpph.getItemMeta().setDisplayName("KitPvp Helmet"); does exaclty nothing
wait so then how do you do it?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
1. get item meta
2. modify meta
3. set item meta
4. add enchantments (on ItemStack) etc
ChatColor.WHATEVER + text
or use the color codes (like &c) in a string and use ChatColor.translateAlternateColors('&', text) to colorize it
mv?
any funni code I can do to cheat the system and remove the bugger
multiverse plugin
its not spawned by design
I mean you can just not send the bossbar, but it seems weird.
me
im best dev
trust
i just spent the last 3 hours
figuring our
item meta & stack
worth it but sucks
i should probably learn java
but oh well
lmfao
i legit told him this
shouldnt that be automatic?
it shouldnt
you need to setup the file and the tables
private void createDataFolder() {
if (!getDataFolder().exists()) {
getDataFolder().mkdirs();
}
}```
?paste
I have cleared all of my plugins and I'm trying to use this plugin and it just won't work here is my pastebin:
https://pastebin.com/6k4RkKz5
Why don You use paste md5, pastebin sucks a Lot
ask here intead https://discord.com/invite/LunarClient they would probably be able to help you, its probably an issue with their code
I have asked but they just close the ticket
The plugin works for my friends but not for me
Well it's a problem in their plugin it seems like. Just make sure you're using the right version.
Maybe You are using a not an update client
Check if You have latest lunar launcher
its a server error not caused by client
java.sql.SQLException: The database has been closed
some experienced java dev for hire?
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
tks
im best dev trust
write an itembuilder
?cba
Mission#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.
cuz im 2 gid
doubt
To be fair some plugin devs are quite.... defensive. Asked if there was a way to detect use of world edit area selector server side in X,Y and Z ways as there was concerns of xray attempts, got told flatly "This does not concern us and isnt our problem" and they ong booted me from the discord lmao
sounds like enginehub support
got kicked a few times and then banned cuz 'oh no youre not the person who has to help, we'll do that'
bunch of idiots
Legit on the edge of finding alternatives
to all their plugins as frankly the exposure is a bit
FAWE?
i dont feel right
using em
Cause ngl it does seem this entire community is full of folk who are like "the plugin gets the job done, who cares if the devs are not nice"
Engineer irl myself and tbh i dont like the idea of supporting customer unfriendly folk
Yeah it's unfortunate that some really good plugins are made by complete dicks lol
I mean you say "really good" but there's a reason stuff like WE async exists yknow?
Well just because it's really good doesn't mean that it can't be improved upon
Even if they dev thinks they've made the perfect plugin lol
Yeah I get you but on the other foot, even looking at some of the API's you sorta have to go "This is held together with popsicles and pritstick under the hood isnt it?"
lmao

brits be like
If you tell them that their backend API is trash thats when they'll really get defensive
Like i love the lands plugin, it does the job fantastically and is ong amazing
but lets say hypothetically one looked under the hood
an decompiled
hypothetically of course
Isn't Lands open source?
The one you pay to use? Unlesss im an utter goob and missed it no
Why do i feel this bout to become a leanring day lmao
Huh, I thought it was. Wonder what I'm confusing it with.
Either way
lets say hypothetically you are right and it was accesisble to view
as lovely
nice looking in game it is
and all in all based plugin
lets say hypothetically you'd realise its held together with dreams, tears and the souls of 1000 people who nest if statements every weekend
and they do ```java
if
{
System.out.println("This garbage");
}
get garbage collected
System,gc
I call System.gc after every statement just to make sure my memory is perfectly allocated
guuuuys
if (!dataFolder.exists()){
try {
dataFolder.createNewFile();
} catch (IOException e) {
plugin.getLogger().log(Level.SEVERE, "File write error: "+dbname+".db");
}
}
dont works
define dont works
dont works
is that a folder or a file
[11:16:45 ERROR]: [SQLite] File write error: table_name.db
[11:16:45 ERROR]: [SQLite] SQLite exception on initialize
java.sql.SQLException: path to 'plugins\SQLite\table_name.db': 'C:\Users\USER\Desktop\Mc Server\1.12.2 2\plugins\SQLite' does not exist
file
and where does the file needs to be?
plugins
dont call it folder then
?
is your plugin called SQLite
whats the value of that file object?
bruh
why dont works
how does that path not exist
idk
Just wondering how I would go by doing a command that only works with a user specified so like idk for example. (Username) has permissions then it continues the command but then if its not that user exacuting the command false
well returning false show the usage message so you probably want return true
you could check if player.hasPermission("something.here") or check the players username
Try the next (I havent seen your code):
File database = new File(plugin.getDataFolder(), "users.db");
if (!database.exists()) {
database.createNewFile();
}
// process connection here
alright thank you
thats not the right message to respond to 💀
im thinking that about people sometimes 💀
i never remember, is there a way to map the actual enchantment names to the "well known" ones and vice versa? e.g. "DAMAGE_ALL" <> Sharpness
is there a way to remove all of certain "code" from a file? I was using JDA for discord bot on main plugin but changed. and this added import org.jetbrains.annotations.NotNull; to all of my commands.... and now i removed it so all of my command classes have errors.
Is there a quick way to remove every @NotNull from a class or has to be 1 by 1?

