#help-development
1 messages Β· Page 786 of 1
Can confirm
wait
just using a servers name for anything not on that server is just kinda weird imo
im getting actual numbers from getNumber
assuming there are two variations of the config file, the currently saved one and an updated one. How do you update the new file without losing the configuration settings from the old one? Are you required to load in the old config and iterate it or is there a simpler way?
how can I get the blockface of an angle? I would like that it will only return south, north, east and west only if the angle is 0, 90, 180 or 270. Any other values like 0.0001 will return south east, for example
for what
new:
value_a: 10
value_b: 20
old:
value_a: 20
should merge into
value_a: 20
value_b: 20
it already does that
unless someone manually edited hte config after u loaded it with loadConfiguration then you saved updates to the file
whats the code to do that?
the code for what
saveDefaultConfig doesn't take parameters?
im confused. what is the problem that you're attempting to fix
are you trying to allow this? manually editing the config by an admin after loading by your plugin & still write changes with set()?
no
then what are you attempting
i want to make sure that a configuration gets all new config values, without editing the old ones
it already does that
if you load a configuration, it takes the old ones into memory. then you write new ones. then you save the old and new from memory to a config file
this says it fails
because you don't use saveDefaultConfig(), you use saveConfig()
saveDefaultConfig() is just for the config defaults
yea
It wonβt add those values magically
in code
mate
i want to know how to add new configuration PATHS after version changes
i know how to edit a value in a config
then you store a version key in the config, and you write update logic that will add new paths if the verison is outdated
and you continue running your upgrade code version by version until the old version = the new version
something like this. assume you add a configurable "hearts" in version 8 but want to make it out of 20 instead of 10 in v9.
registerUpdateLogic(8, (config) => {
config.set("hearts", 10.0);
}); // Updates from 7 -> 8
registerUpdateLogic(9, (config) => {
double oldValue = config.getDouble("hearts");
oldValue *= 2;
config.set("hearts", oldValue);
}); // Updates from 8 -> 9
https://github.com/frostalf/ServerTutorial/blob/master/ServerTutorial/src/main/java/pw/hwk/tutorial/data/DataLoading.java#L32
this is how I moved data from config.yml to data.yml
then registerUpdateLogic will toss it into a map, you'll have a constant for the current version, and you'll iterate each version between the key in the config and execute the consumer (if it exists) in the map to upgrade
you can add paths however you want, but if the concern is old paths and want those old paths gone, you would just set them to null and save the file
and then if its missing, you would utilize defaults with the get method
this way, you don't just get NPE's π
and then on the next save that new thing that was missing is now there π
no it wouldn't be
using defaults? yes it would
he'd need to have deserialization logic for it to appear using defaults in get
no...
getInt("hearts", 20) will not add "hearts" = 20 into my yaml file after save
saveConfig()
config.getString("Default", "Path of string you wanted");
config.saveConfig();
if the path was missing, the default is used and on next save will save it to that path
ah the singletron
i mean
i really shouldnt have 4 config handlers with different configs floating around
yeah, that's why you use DI, but whatever
I am curious in where you got singletron from XD
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
are you trying to do singleton pattern?
or maybe lazy loading?
like i want one global shared instance of this class, ideally obtained by calling the constructor
ah yeah singleton
i know how to do it with static and getters but im not sure if its possible with a constructor
[19:22:49 INFO]: JustinS_2006 issued server command: /sc add ASH 5 sand,grass(5),dirt(200)
[19:22:49 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'sc' in plugin ScrapCollection v1.0
....
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.NumberFormatException: Cannot parse null string
...
at me.JustinS_2006.particles.AddParticleCommand.parseItem(AddParticleCommand.java:117) ~[?:?]
at me.JustinS_2006.particles.AddParticleCommand.onCommand(AddParticleCommand.java:69) ~[?:?]
...
private ItemStack parseItem(String input) {
Matcher matcher = PATTERN.matcher(input);
if (!matcher.matches()) return null;
int groupCount = matcher.groupCount();
if (groupCount == 0) return null;
Material material = Material.matchMaterial(matcher.group(1));
int model = (groupCount == 1 ? 0 : Integer.parseInt(matcher.group(2))); // The line that causes the error?
if (material != null) {
ItemStack item = new ItemStack(material);
ItemMeta meta = item.getItemMeta();
if (meta == null) return item;
meta.setCustomModelData(model);
item.setItemMeta(meta);
return item;
}
return null;
}``` Why the heck does that line give an error?
When I change the command to /sc add ASH 5 sand__(3)__,grass(5),dirt(200) then it does work. So it has to do with brackets missing at the first part
no u can't use the constructor as a singleton getter, not to mention how bad of a design that is
now the thing that is missing is that class doesn't have a constructor
however typically people will just make a private empty one to just ensure it isn't possible to use it
frost link me to the spigot src on gitlab please
i cant find it anywhere on google
i want that one too
?stash
?stash
-.-
thats not the code thats a pile of patches lol
?bt
yea thats what i would do but can you do it with a constructor
In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to a singular instance. One of the well-known "Gang of Four" design patterns, which describe how to solve recurring problems in object-oriented software, the pattern is useful when exactly one object is needed to coordinate act...
yeah I checked frost, unless I'm blind then this definitely doesn't save the default:
getConfig().getInt("hearts", 20)
saveConfig()
getInt:
@Override
public int getInt(@NotNull String path, int def) {
Object val = get(path, def);
return (val instanceof Number) ? toInt(val) : def;
}
get:
String key = path.substring(i2);
if (section == this) {
SectionPathData result = map.get(key);
return (result == null) ? def : result.getData();
}
return section.get(key, def);
its just a ternary operator
yeah that is called lazy loading singleton, so how you do that is basically just add in the private constructor of the class to invoke the static method
Just do singleton with init function
wouldnt that still leave me with the issue to somehow return the instance variable from that constructor
bleh cant we just have an @singletron flag lol
first its not a singletron and second its bad design, that's why
^ storng man
DI is trash I'd you're passing it everywhere anyways don't be afraid of a good singleton
OOP itself is flawed itself but that's a whole other discussion
hacky nonsense is the java foundation im not sure what your problem is :kekw:
If you choose to not cave do it properly look up how to use singleton pattern
class someClass {
private static someClass instance;
private someClass() {
instance = this;
}
public static someClass getInstance() {
if(instance == null) {
instance = new someClass();
}
return instance;
}
}
Erm remove the instance = this in the constructor
That's redundant
im aware frost
so its not possible without a getter?
anyways u still have this problem. just do the upgrade logic like I said please, it's the most fool-proof and it's industry standard for versioning data
correct
the getter is there for convience. You could just remove the getter
java's constructor is a method with a void return under the hood, you can't change that
you can't be like MyClass().setThis(20)
and expect MyClass().getThis() == 20
did you just unironically write someClass 4 times with lowercase camel?
no lol
consistency
sadly 5
Bro literally lives to kill clean code
^ ong
imo uppercase doesnt belong in code
?-?
doesn't really matter much except with constants
no it literally matters
otherwise preference as long as your consistent lmao
you are not going to tell me you are using a class named like a field or method
the entire fucking java sdk is written with UppercaseCamel, and you want to make a class lowercaseCamel?
java does not enforce anything except when it comes to constants
It doesn't really matter tbh, its possible he even did it to set you off
What
so while you may have the preference to follow the conventions, it is not enforced by Java
ugh I'm not. I don't even know why I'm still in this discord
I give perfectly good instructions and am being overridden by incorrect ones
well opinions are not facts
I wanna make money
HA
I really don't care how people decide to code their projects as long as I am not the one working on it π
fat chance
DI is also not always the best way to do things. It's good most of the time. But to say it's absolute is foolish, while I agree with the code styling it's not something to get bent out of shape about.
if they want lower case then so be it, its theirs not yours
What decides whether an item has a displayname or not?
The ItemMeta I suppose
you tried to tell me that get(key, def) will add the default so that
getConfig().getInt("hearts", 20)
saveConfig()
will write "hearts": 20 on save
But don't all items have a display name?
it wasn't about DI. it was about code style and the defaults advice
Not a custom one
I mean, all standard items such as white_dye will have the display name White Dye right?
Ah alright
Either it used to work like this since snakeyaml did change or I was probably thinking of some other method
but not sure what that has to do with conventions
Never said it did
this was my message
well the last thing being discussed was conventions so I assumed you were still referring to that
I was frustrated by the 3 instances: upgrading config values on a new version, 'singletron', and the code style
anyways, no worries
and there is nothing wrong with using singleton if its needed
I'm not going to spend my afternoon arguing here
0
0
k
modulo finds that remainder when the numbers are divided π
my brains fired sue me lol
What is the % thingy
so, 2 mod 5 would be 1 as there is a remainder of 1 left
I've used it before, but I don't really know shit about that... shit
well its nicely explained above lmao
its for when you need to know how many remains after a division but don't want like the decimal
Oh
can i just say how annoying it is that auto complete hits those single letter classes instead of the class youre in right now
bcs 2x2 = 4 and 5-1 (the difference) is 1 right?
lol
11%3 = 2
ah you reverse it
I hate when I'm writing code, I need to tab complete something, but there comes copilot with its useless suggestion
lmao
Every time I'm writing something, I keep writing but I see a suggestion so I click tab, but then Im too late because the suggestion already changed and now I have to delete everything and wait for the previous suggestion to load
true but then the previous suggestion doesnt show
then I need to delete the previous letter, and continue writing and then it comes with a suggestion
Space, backspace
It says that sand (with a custom model data) does not have a displayname. How is that right?? anyways, how do I make it display its name then?
oh, Ill try that next time
here is the shortest bitwise function I know of
if (number & 1)
no
What is that
frostalf is objectively right
if its true, the number is odd, else even
Name ot
Name it
Wow
Js people make whole packages for that
I can't just name every item in minecraft so that it displays its normal name
and I just did it in one line XD
getLocaleName or something does it iirc
doesn't JS have bitshifting?
Can you make is-number in one line
Js folks are dumb
tf u mean he is objectively right
I literally checked the source code
naming conventions arent forced
I was talking about 3 things. One of them was including something he was objectively incorrect about
it just makes you look stupid if you don't use them
read the whole conversation please, before bringing me back to something I tried to like 20 minutes ago.
Naming conventions are recommended to use for more readable code, but not required
Naming conventions aren't required in most programming languages
public boolean isOdd(int number) {
return (number & 1);
}
doesn't mean that the recommendation should be to disregard them
Now do isNumber
of detecting if its a number?
Yes
yeah so
u should always use DI?
or smth
was that ur point
public boolean isNumeric(String number) {
return number.chars().allMatch( Character::isDigit );
}
I added java else if(meta.hasLocalizedName()) p.sendMessage(ChatColor.DARK_GREEN + "You found " + ChatColor.BOLD + meta.getLocalizedName() + "!"); but it doesnt get the localizedname, so I don't think that's it.
π
My point was that I gave solid advice 3 times and each time I was ignored for frost's generally bad advice. The reason I got mad is that the person who needed support and I was told something incorrect about saving defaults after I gave good advice on how to upgrade configurations on version changes, which was promptly ignored completely.
Completely ignored for incorrect advice.
is that good @shadow night ?
whatever, I'm not responding again because it doesn't matter. you literally can't show up 20 minutes late to a conversation and defend someone without reading it all, because this is the third time I've restated why I was mad.
what is bro talking about?
I said I was mistaken after you said it was incorrect o.O
exactly the problem. That's why you don't revive an ancient argument from 30 minutes ago.
To be honest, I'm not really that mad at you
Hmmm I'm not sure then
Sorry
No worries, thanks for the help anyway π
I'm just frustrated that I waste a tiny part of my afternoon giving good advice when it's overridden by your (conventionally or objectively) incorrect advice. I didn't receive a single acknowledgement towards the advice I gave Monterius even though it was good advice
well the only thing I can say I was wrong on was that default thing, otherwise the only other thing was they wanted a singleton so I showed them the premise of it
or how it works anyways
that's alright frost, I don't need an apology from you or him, but I appreciate it
I don't really care why someone wants to know how to make a singleton or if they need it. I am not here to hold their hands and walk them through every step lol
they want to use singletons everywhere so be it, its not my program π
now I recongize you, why did you change your name o.O
π€ I don't think that I did
unless it did from Itzdlg to Dominick
it could also be that I'm no longer pink, I had to cancel nitro for a bit to wait for pay
I could have sworn at some point you were itzdlg XD
yeah that makes sense, probs because I was verified and the bot forced it to Itzdlg
but ig when discord changed their username system it became Dominick at some point?
OH
yeah you're right, I changed my display name to Dominick when I no longer had Itzdlg#7444
ah
why is there still an empty description if I didnt set its lore?
if (!customItem.get("description").toString().isEmpty())
itemMeta.setLore(List.of(ChatColor.DARK_PURPLE + customItem.get("description").getAsString()));```
"description": ""
or "description": " "
they still give the lore an empty space as in the pic
man wtf, I even changed to this and it still gives me that weird blank space
if (!customItem.get("description").toString().isEmpty())
itemMeta.setLore(List.of(ChatColor.DARK_PURPLE + customItem.get("description").getAsString()));
else
itemMeta.setLore(null);```
Ah thanks
wdym?
duplicate code
God damn you're the best, that worked
thanks!
how would one go on about spawning custom animals like not the spawning itself but checking for propper spawning regions, entity caps etc
Probably, I was making a little app to loop through all jar files in a folder and find which are mods
I thought maybe you were just wanting to see if there was like more one line methods that people make who programs out of XD
Can anyone explain how paginator works?
I need to wrap the lore text but Im not sure how it works and the docs arent of much use
I have this but it says Operator '+' cannot be applied to 'org.bukkit.ChatColor', 'org.bukkit.util.ChatPaginator.ChatPage', which makes sense, but if I change the paginated part to string it will just become unpaginated again right?
itemMeta.setLore(List.of(ChatColor.DARK_PURPLE + paginate(customItem.get("description").getAsString(), 1, 10, 10)));
Use ChatPaginator.wordWrap
Doesnt work. .wordWrap returns a list of strings, and setLore requires a string
'setLore(java.util.List<java.lang.String>)' in 'org.bukkit.inventory.meta.ItemMeta' cannot be applied to '(java.lang.String[])'
oh... right
..Arrays.asList(ChatPaginator.wordWrap(...))..
But then how do I add the dark purple chatcolour to it?
Sorry if Im asking stupid questions right now
It's probably because I'm stupid
Youβd need to add it to each line
yeah I think I got it
I love each and every one of you. I hope someone gets you cookies from time to time
to make a custom chat format system I'd have to cancel message on send, save it and reformat chat on my own way?
or how am I supposed to do it?
async chat even and set format
whats asyncing
@echo basalt I got a question about this
is it just armorstand effects or also utilty class
ah thatd do it
but this is an api of a plugin hosted on spigotmc
why does it hard depend on paper?
It does not
is that your only dependency?
Oh
Some do
well no but the rest is my own stuff
which only ever depends on spigot
different topic, which of yall had the 'skin to head' code on their website?
oh this is irritating
all the stuff used in that code doesnt provide automatic imports
Yeah just by reading all this code Ive got no idea how to make armor stand management class
UUID.fromString
how do I add stuff to this collection
using something like Map.getOrPut and default collection usage
or more like getOrPut(Map map, alternativeValue)
what
ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [s\open\src\jdk.jdwp.agent\share\native\libjdwp\debugInit.c:734]
so apparantly you can only open one socket with the same port
basically just check if the the map contains player, if not put him on the map with an empty collection; Then get the players collection from the map and add the armorstand to it
if(!playerStands.containsKey(player.getUniqueId()) {playerStands.put(player.getUniwueId(), new AreayList<>());
}
playerStands.get(player.getUniqueId()).add(armorStand);
computeIfAbsent exists
Collections.emptyList() will be fine
no, emptyList is immutable
he hasn't changed anything either
u wrote that..
use List<ArmorStand> instead of Collection<ArmorStand>
why
it should work just fine
List.of Arrays.asList
World.spawnEntity(location, Class<Entity>) should work
castings fine too tho
that's literally irrelevant
your issue is that you want to get or insert a collection first and then append to the collection
playerStands.computeIfAbsent(..., (k) -> new ArrayList<>()).add(...)
neither works
u need an instance of an implementation of list as value
?learnjava put shortly
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.
This collections Java tutorial describes interfaces, implementations, and algorithms in the Java Collections framework
what is k here
the map key, irrelevant for what you want to do
it won't
why?
i think he also doesn't know how to use Map
whats ur current code?
that lambda would get run only to populate the map in case there's no value for that key
u rlly try to keep it complicated lol
many complicated words of which he probably hasnt heard a single one
if key not in map, create new list and put the key and list in map; if key in map, get existing list; return list
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact com.microsoft.onnxruntime:onnxruntime:pom:1.15.1 from/to central (https://repo.maven.apache.org/maven2): Checksum validation failed, no checksums available```
??
I'm trying to read a file in my folder, but Im not sure what the directory is supposed to be. Atm I have this but it says it can't find the directory or file
try (FileReader reader = new FileReader("/home/container/plugins/CUSTOMITEM_DATA.json")) {...
It says the directory it just exactly that, so I'm not sure what's going on here. Should I just do plugins/?
Hey I've made a mute system where it gives a duration then a reason do you think this way to store the reason in a string is a valid way? ```java
private String reason(String[] args) {
StringBuilder reason = new StringBuilder();
for(int i = 3; i < args.length; i++) {
reason.append(args[i]).append(" ");
}
return reason.toString();
}```
I am creating a custom entity that walks on the rails. It works fine but when it is too fast it leaves the rails. The solution I thought for it is to get all rails in the entity's hitbox and get the closest to the center point. My question is: how can I get all blocks in the hitbox?
fuck this Im just totally confused beyond
how the hell do I make a class that would manage armorstands
Use JavaPlugin#getDataFolder to get your plugin folder
Why?
This works on my self hosted server
Why not?
just trying to figure out what directory I should use for this
Why fix something that's not broken
Well it's broken though?
Didn't you just say it doesn't work and that you needed help?
well im asking more of what approach do I take becuase I am really confused
do I need to make each instance of such class for each thing that needs it
or can I go away with only one instance
Manager classes only have one single instance created. Usually when the program starts.
wouldnt it cause problems
like what if its dependent on location and player's uuid
how do I make it so that it'd work with those
The Manager shouldn't ever be dependant on that
I dont understand why they would not work?
its literally armorstand manager
so like do I just make constructor that would take Location and Player and use those?
so how do I pass them
You can pass your armor stands to the manager via a method call
great but that Illusion guy didnt have it and none of his methods depended on it
How do i play the totem of undying animation?
Without the sound or the particles, just the totem
Ive searched online and cant seem to figure it out
Not sure if that will trigger sound and particles
do give it a try
oh well packet time ig
Why output is looking like that?
this.progress += 0.001;
System.out.println("progress: " + getProgress());
I wonder if that packet even has options for only the animation.
does this idea even exist
floating point errors
just round it off at a few decimals
i know you can do it with .format but i suck at .format lol
I was thinking about this... maybe just some round method? π€
DecimalFormat#format(β###.00β)
i was more thinking string format
what about this?
private double round(double number, int decimals) {
int multiplier = (int) Math.pow(10, decimals);
number *= multiplier;
number = Math.round(number);
number /= multiplier;
return number;
}
Ah, well I also suck at that. Lmao
rounding is not needed If I can do this I guess
oh %.#f where # is number of digits
?mappings
Compare different mappings with this website: https://mappings.cephx.dev
oh thats what it was %(numberofcharacters).(numberofdecimalaccuracy)f
this should be fine than or I can just round it with method above (but probably not nesasery)
System.out.println("progress: " + new DecimalFormat("0.000").format(this.progress));
yup its working
ty guys
so when I want to make method to spawn armorstand
and invoke it with player and location
and make it return armorstand id
is it possible to exclude a library in plugin.yml libraries section?
do I just add it to Map<PlayerUUID ArrayList<ArmorStandUUID>>?
why? (don't think so)
so that I could loop through it and find all armorstands in case I need to delete them?
a library isn't downloading properly idk why
wait do I need to put PDCs on armorstands
share the error, if there is one?
or can I use armorstand ID?
or is this a plugin you don't own?
Failed to read artifact descriptor for com.microsoft.onnxruntime:onnxruntime:jar:1.15.1```
this is a sub dependency
huh, cool library... didn't know something like this existed
??
Hey is there any tools to check on plugin performance to see if my code needs improving more?
Spark
Is there any way to communicate Proxy <=> Subserver all the time except another tcp connection? I feel like another tcp connection in a plugin would just make the setup super annoying.
Okay thank you
You could make the plugin save the required information automatically when a player join for the first time
So connection information goes through messaging channel
Makes it less annoying to setup ig
is there a way to force F5 on a player?
No
I'm looking for a feature so that a subserver can see if its part of a network or not. That probably isn't possible until a player joins.
Yeah
ok too bad
Reason I think tcp con is gonna be annoying is because firewall
Like most people already complain when the setup is more complicated than just putting the plugin into the plugins directory
And then you get 1 star reviews because some ppl can't read
Nothing much you can do about that
You'll get 1 star reviews regardless of what you do
Hi, sort of new to the whole Bungeecord messaging thing... I'm working on a global notification system for staff. It works as intended, so that's good.. only staff get them, etc.. but it seems that notifications that are not StaffChat get duplicated by how many players are on the proxy.
If there's 3 players on, and somebody gets banned... the notification gets sent 3 times. If somebody flags the filter and there's 6 players on, the notifications is sent 6 times...
This does not happen with staffchat, why? I'm doing nothing different
The order of events:
- Command or action > spigotmc to bungeecord: _staffNotifications > bungeecord plugin sends message to right people
sounds difficult to fix with no code
Yeah I can send code, sorry:
?paste
use this pls
Yep
idk what happened with the spacing
And ignore the scribble, I ripped it from google
what does globalStaffAlert do
It sends the message out to all staff, I'll send that code as well sorry
public static void globalStaffAlert(String message)
{
for(ProxiedPlayer players : ProxyServer.getInstance().getPlayers())
{
if(ProxyServer.getInstance().getPlayer(players.getUniqueId()).hasPermission("global.staffalerts"))
{
if(RECEIVING_STAFF_ALERTS.getOrDefault(players.getUniqueId(), true))
{
ProxyServer.getInstance().getPlayer(players.getUniqueId()).sendMessage(C.text("&b[STAFF] &f" + message));
}
}
}
}
I would use paste but it's all such small code
RECEIVING_STAFF_ALERTS is a map of uuids with booleans.... hopefully self explanatory
Maybe your plugin message gets sent by all players? That would explain the duplicates depending on player count
That's exactly what I was thinking, any idea what I could be doing wrong
Not without more code i think#
guard clauses π©
why getOrDefault with default value true?
does this mean u put every player on join on this map, or is that the problem?
Like more stuff that is related to the messaging pls
No, they need the staff perm
Ok hi, using paste for this part....
My dear friend recommended using that method with N/A, I thought it was fishy
If you have a better way of doing that, please let me know
So when a person gets banned, the plugin on the server will run BungeeChannel#sendStaffNotification(notification)
It's in the command... /ban
can u show pls
I'm not sure it's too important to show a method being used... I've explained everything
so you dont need help thats ok
It just feels like a lot of code being sent, with minimal help received
I've sent everything PluginMessaging related
There is no direct reference to PluginMessaging in the ban command, only the method BungeeChannel#sendStaffNotification(notification), which you already have
Yea but its important how you call it
It's called once if the ban is present
r u sure its called once
I can't release the ban code because I was paid to develop that part, the rest idm because that is public code found anywhere with enough scowering
Positive
On the plugin? or in the Bungeecord plugin?
Cant really help you if I cant look through the code. Its not always some snippets. Sometimes the bug is in places where you would never expect it. I can only recommend you to debug it step by step to see where the duplication happens
Well, I would love to adopt that logic because it's logical and makes sense... but it has to be in the messaging itself because it duplicates by how many players are on the proxy
It can't be an instance issue
should I use armorstand PDC or ID to cache them?
I've made sure to use the staff notifications as little as possible
well you wouldn't use PDC to cache
that would be counter intuitive
why
Caching would indicate in memory in most cases. PDC is persistent
Yea then debug that or investigate it. I can't remember 100% how messaging worked. But if you send a message i thought its only being sent once. So idk if you have a loop somewhere or it is being sent by all players or whatever
if you need to keep track of an Item PDC is the ideal way to do so
but that wouldn't be caching
that's you just associating data with an item permanently
Technically pdc is cached for you
Exactly my thought! I initially did loop the ban notifications because I forgot I was using global alerts, but then realized that it sent like 10000 times... so I took out the loop and it still sent like 7 or 8 times.
I just can't find any similar issues which is so weird
I want to do armorstand management cuz I use them for animation / hitbox placement
is there a way to get player's direction as vector?
If the PluginMessage does not have a player specified will it just assign the plugin-message to everyone?
might be
Check the docs
True
I will as well because im interested now
Just odd that it doesn't have a problem with StaffChat
Considering it uses the same system, but is just connected to the proxy directly
also is kotlin any good for plugins?
I could assign each notification a specific player if I needed to, it would just be annoying to retrofit
I can't find anything on the docs????
How do you even send a plugin message without a player?
Just assign it to user N/A
Don't you have to call it through the player interface
Ah then thats the issue probably
alr so im trying to change a noteblock's intrument from changing when placed above another noteblock, is that a job for BlockPhysicsEvent or what-
you'd probably need to cancel interactevent and place the block programmatically
You could use the player who was banned to send the plugin message (if not disconnected already) or chose a random player i think
How do I remove armor stand with it's id?
I'm using Player notificationOwner
So... it's not a random player, just related to the notification in one way or another
?
just messing with you, there is a method to remove/kill entities
and you just feed it the UUID
as long as the chunk where the entity is at is loaded, it should remove said entity from existence π
Feels still weird. Why would the normal implementation in server send it multiple times. That is behaviour you would almost never want
Yeah exactly
I hated to be so rude earlier sorry, but it just felt redundant sending code for something that isn't really related
what would be a code to kill entity knowing its UUID?
Can you maybe make a debug on your proxy to see how many messages are received through one ban?
no problem, didn't really feel rude to me
I will, let me apply these changes with the new notificationOwner fix
If the fix I made works, I won't even bother doing anything more
yea, you can try it. But i feel like that wont be it
Β―_(γ)_/Β―
The notificationOwner is now the primary method for the .sendPluginMessage
getServer().getEntity(uuid).remove()
Do note it must be loaded or getEntity will return null
What exactly fixed it now?
Using the Player notificationOwner to send the plugin message instead of the actual getServer() method
Player#sendPluginMessage.. > Server#sendPluginMessage..
would I need anything else for armorstand management for animations?
I feel like this might be enough
bruh its not a bungeecord "issue" then?
Maybe? It's still odd that using the server would include ALL players
Because the subserver sends it multiple times
Because it would still use every player on proxy
I will look into source code now to see what happens there
Getting skull with texture from link
How do I create a library and can be imported with maven?
just create plugin with accesible API class, publish it to github then use jitpack.io
Doesnβt have to be a plugin but yeah
im so confused i dont understand. how would i publish it to maven.
just put it on github and then put your github repo link into jitpack.io. It will build your artifact and then serve it to anyone who imports it with maven
alrighty.
so i can just create a normal java project and just pass the plugin interface?
well someone else also said you can just create a plugin and do it so i got confused
you can do either
does this code look okay?
it actually does π€
if i import a library within my library will the user also have to import it, or will it just import from mine?
if you shade it it'll be avaliable through your plugin
ima do that, cause this uses Lamp.
I'm having the hardest time coming up with good class names
any ideas on why i am getting null exception?
if i fire a custom BlockPlaceEvent will it actually set the block?
i think it should
sadge
getArmorStand() seems to return null
at least it is null somehow
not sure if any issues in the save of uuid... but you need check the nullable return in the methods for avoid the throw...
why?
it shouldnt throw null in the first place
it wont solve shit
it should spawn an armorstand, write it's UUID into the arraylist and then do it again 12 times
What does getEntity() do? @storm crystal
hmmm for any chance that method return armorstands?
maybe armor stand got destroyed/removed or something
bro
the only way that thing returns null is by not finding it through the uuid
so you somehow store shit that doesnt exist
idk
why is intellij saying 'for' statement has empty body about this:
for (int i = 0; i < LEVEL; i++); {
addExperience(player, Experience_Until_Level_Up);
}
the semi colo after the closing paren
ohhhh that makes sense....
i've been at this for way to long lmao
it's still there...
Refresh caches or something then
god damn it you gave me an actual idea
Ive been deleting only 1 armorstand from arraylist
xdxd
I dont get it
this method spawns me only 1 armorstand
despite me looping it
if my map looks like that
do I access ArrayList<UUID> like that?
yes
because the uuid isnt in the map?
World#getEntities() only returns loaded entities
So it's very likely you're trying to get an armour stand that exists but isn't loaded
but it spawns only 1 armor stand
well maybe 2 cuz sometimes it deletes 2 entities
but I can only see 1
That's not really relevant. It's stopping spawning entities because it's running into an exception
Your getEntity(UUID) method returns null and you're invoking a method on the result of it
Well, it does. That exception states very clearly that it does :p
Stacktraces don't lie
Like I said,
World#getEntities()only returns loaded entities
So it's very likely you're trying to get an armour stand that exists but isn't loaded
but its literally copied from another code that worked
Okay, the other code that works probably works under different circumstances where all the entities are loaded
but why wouldnt this work
But the only situation in which your getEntity() method can return null (and it is returning null - all exceptions you've sent stem from this method returning null) is if it cannot find the entity in the world which means either it doesn't exist or it isn't loaded
So it's one of those two things
(also an unnecessary loop by the way because World#getEntity(UUID) does exist :p)
Well no it has the same caveat of requiring the entity to be loaded
Just more concise is all
but what the hell am I supposed to do
Not sure. I don't really have a whole lot of context as to what you're trying to accomplish. But if you're going to be updating armour stands in quick succession, maybe it's a good idea to keep references to the ArmorStand objects themselves. Going from Entity -> UUID -> Entity doesn't make a whole lot of sense anyway
it generates exception when this code is being run:
and its scheduled
2 seconds later
no way armorstands cant be loaded by this time
moreover
this code
which is ran immediately
just doesnt spawn all armorstands
only one
still does same shit
even if I work on armorstands
100% there is something wrong with this shit
it spawns armor stand only once
Getting a TileEntity isn't a huge load right?
final CraftWorld world = (CraftWorld) location.getWorld();
final TileEntity tile = world.getHandle().getBlockEntity(position);
if (tile instanceof TileEntityContainer tileContainer) {
container = tileContainer.createMenu(syncId, inventory, inventory.player);
``` e.g. something like this wouldn't be a massive burden
uhm are you sure you aren't spawning it in the middle of nowhere
if a players location x is idk lets say 5 and your loop is on iteration 2
double x = 5 +(2*5) = 15. And this gets worse as it goes what if your player is at idk lets say then
double x = 150 + (2*150) = 450
π π π π
I fucking
misinterpretated my armorstand spawn formula
turned out that it was the only thing that was faulty
how can I set rotation of armorstand?
as in what direction its facing
anyone got tutorial / guide for using interact entities?
Pitch and yaw
that's how my Bone ability structure looks like, is that optimal way?
I split it into listener and utility
how can i hide methods to users using my library? because there is stuff that like they would never use, and it would be a lot nicer if they wouldn't show up in the tab list
only expose an interface, and implement that interface
I think 2 modules would lend well to your project here. An API module and an actual Implementation Module, then you provide API access by having users depend on your API module rather than implementation module. This goes hand in hand with what machine said above
Is it possible to see who dropped an item from the PlayerDropItemEvent/EntityDropItemEvent?
yeah
probably
there isn't but you could just detect when a player drops a item and when another picks it up u can use a map or smth to get it no?
that would be the best solution if there isn't a uuid or way to get who dropped a item from the item instance
you sure?
declaration: package: org.bukkit.event.player, class: PlayerDropItemEvent
PlayerDropItemEvent extends PlayerEvent
which provides a getPlayer method
likewise you can track who dropped an item on pickup by applying PDC to an item which has the player UUID of who dropped it
??
I mean't for tracking who dropped the item when a player picks it up.
@river oracle @halcyon hemlock ^
This is probably a better solution but it's supposed to be a 1.8.9 plugin and PDC didn't get implemented until 1.14 no?
yeah ^
NBTApi
just make sure you format the NBT so you can retrieve it in later versions with PDC
Here to complain:
currently my IDE is complaining for not using Kyori's Adventure Textcomponenet because everything else is depracated
and my Server is complaining at me because Kyoris adventure Text Componenet doesnt exist
ughhhhhhh
we aren't paper
this sounds like a paper problem
using spigot
You are using paper api on a spigot server
WIAT Im NOT
for some reason my pom has paper api in it
omg
ive been struggling for like 30 minutes
ughhh
Okay thank you yall
now i just feel dumb lmao
Hi, I'm new to java and I'm trying to put a slow falling arrow of 30 seconds into my gui, any idea how I would do this. I already have working code but it sets the duration to 11 seconds as it does the default arrow. I have done addCustomEffect but that just adds another effect and then theres 2 of them.
ItemStack slowFallingArrow = new ItemStack(Material.TIPPED_ARROW, 64);
PotionMeta arrowMeta = (PotionMeta) slowFallingArrow.getItemMeta();
arrowMeta.setBasePotionData(new PotionData(PotionType.SLOW_FALLING));
slowFallingArrow.setItemMeta(arrowMeta);
inv.setItem(37, getItem(slowFallingArrow, arrowMeta.getDisplayName()));```
this is differennttt
I thought i was using spigot api
I wasnt.
u dont need to explain lol
i mean it ended here, no need to say anything more
?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.
can multiple modules in a plugin project run simultaneously?
I mean which plugin has the highest priority in the project out of many
I forgot the name of the informative site with articles on this topic
I have thousands of database entries, and whenever I tried to save all of them on plugin disable, the saving is not successful, the server couldn't wait and force stop happens, how can I solve this issue?
This is my code: https://paste.md-5.net/araqojayir.cs
you mean the compilation order?
yes
and how i can add another plugin?
in my jar
exactly inside
more precisely, not even a Jar, but a project
I searched for tutorials but didn't find any good articles
modules that rely on other modules (for example, if you have a core module that depends on an api module) will have a lower priority
just adding the dependency(?
make sure to relocate
I want it to be in the form of 1 jar
so that you donβt have to install several Jars in the project
and don't make an api
for example like ItemsAdder (theoretically) with several modules
maybe you can create a module that depends on the other modules so the artifact will contain all these classes
Are you running it in the main thread?
It's on plugin disable so I must run it in the main thread.
So a module
maybe you can schedule periodical updates and add a shutdown hook to the runtime
Or a dependency, whatever suits you best
anyway to prevent water from breaking things like redstone or plants?
BlockToFromEvent or smth like that
public void onDisable() {
System.out.println("GriefAlert2 Disabled");
}``` wheres the issue? Says *; expected* though I dont see where I am supposed to put a ; here
Can you screenshot
cant upload screenshots in this channel
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
You messed up ur brackets
lemme see
damnit now I have to go through 107 lines and see where I messed up
uhh where exactly did I mess up, cant find anything? Do you mean on line 111?
found it
Can you elaborate more on that? I didn't quite understand.
The Runtime class provides a method to add a shutdown hook, that is, basically, a task that is executed before the JVM completely shuts down
I'm not sure if that will fix it, but give it a try
You can do it via Runtime.getRuntime().addShutdownHook(Thread). In the thread you must perform the save operation
Save more regularly
That's another solution
Alright, let's see what can I do.
Actually I save the data everytime it gets modified.
I have a plugin that spawns particles every x seconds at a specified block. My worry is that this is wayy too inefficient, because these particles will still spawn even if there arent any players closeby right? So, if I have like 2000 of these locations that keeps spawning particles, even when theres 0 players close, it will cause a lot of lagg. At least, that's my assumption. java public void spawnParticlesEverySecond() { BukkitRunnable runnable = new BukkitRunnable() { public void run() { for (Map.Entry<Location, ChestObject> entry : chests.entrySet()) { if (!entry.getValue().isLooted()) { Particle particle = entry.getValue().getParticle(); Location location = entry.getValue().getLocation(); if(location == null){ Bukkit.broadcastMessage("LOCATION IS NULL"); return; } location.add(0.5, 1.2, 0.5); location.getWorld().spawnParticle(particle, location, 7, 0.15, 0.25, 0.15); location.subtract(0.5, 1.2, 0.5); } } } }; runnable.runTaskTimer(plugin, 0L, 20L); }
Anyone know if this is true? Aka, if this will cause lagg
Probably not
Have a check if the chunk is loaded or not.
But then I need to get the chunk of every location
You can get chunk from Location.
oh k, so thats already stored
This is what I have
public boolean isChunkLoaded() {
int x = this.location.getBlockX() >> 4;
int z = this.location.getBlockZ() >> 4;
World world = this.location.getWorld();
if (world == null) {
return false;
}
return world.isChunkLoaded(x, z);
}
So if the chunk is loaded, spawn the particle.
Isnt it easier to do this? java if(!location.getChunk().isLoaded()) return;
blockSpawners this entity??
Oh I can even remove the first 2 lines
I believe Location#getChunk will load the chunk.
Oh that might be the case. I dont see it in the docs though
Is there a way to test this?
Yeah it's not in the docs but I've actually tested it myself, this thread might be useful https://www.spigotmc.org/threads/when-are-chunks-loaded.58342/
Wat do the >> 4 mean?
I don't know how to explain this properly, but basically a chunk is 16x16 and that's why you can divide by 16 to get chunk coordinates and 16 is the power of 2, we can shift the bits by 4 (>> 4).
ah alright
How do I get the colour from a json file?
I store the chatcolour as "DARK_PURPLE", but how do I retrieve that value as a chatcolour?
Just store it as string
But ChatColor is not a string right?
Incompatible types. Found: 'java.lang.String', required: 'org.bukkit.ChatColor'
.toString
Same issue Incompatible types. Found: 'java.lang.String', required: 'org.bukkit.ChatColor'
A chatcolor isnt a string
Ill try chatcolor.valueof(the string)
I went to sleep, everything was working and when I came back in the morning, I get an error when I start my server with min plugin on it.
https://pastebin.com/ZAmGP1bJ if you want to help me
Shade kyori
} else if(player.hasPermission(VagtSystem.getInstance().getConfig().getString("vagt_perm"))) {
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);
SkullMeta meta = (SkullMeta) skull.getItemMeta();
meta.setOwner(player.getDisplayName());
skull.setItemMeta(meta);
GuiItem head = ItemBuilder.from(skull).asGuiItem();
List<Component> plushDollarLore = new ArrayList<>();
plushDollarLore.add(Component.text(ColorUtil.chat("&8&l&m--------------------")));
plushDollarLore.add(Component.text(ColorUtil.chat("&6&lLΓN &8- &f&lINFO")));
GuiItem plushDollar = ItemBuilder.from((api.getItemHead("20446"))).lore(plushDollarLore).name(Component.text(ColorUtil.chat("&6&lVAGT &f&lLΓN"))).asGuiItem();
GuiItem computer = ItemBuilder.from((api.getItemHead("46431"))).asGuiItem();
GuiItem sculkSensorZ = ItemBuilder.from((api.getItemHead("43979"))).asGuiItem();
GuiItem plus = ItemBuilder.from((api.getItemHead("2293"))).name(Component.text("test")).lore(Component.text("wwgw")).asGuiItem();
Gui vagtMenuMain = Gui.gui()
.title(Component.text(ColorUtil.chat(VagtSystem.getInstance().getConfig().getString("prefix"))))
.rows(5)
.create();
vagtMenuMain.setItem(3, 2, plushDollar);
vagtMenuMain.setItem(3, 4, computer);
vagtMenuMain.setItem(3, 6, sculkSensorZ);
vagtMenuMain.setItem(3, 8, plus);
vagtMenuMain.setItem(1, 5, head);
for (int i : new int[]{0, 1, 2, 3, 5, 6, 7, 8}) {
vagtMenuMain.setItem(i, glassOrg);
}
for (int i : new int[]{36, 37, 38, 39, 40, 41, 42, 43, 44}) {
vagtMenuMain.setItem(i, glassWhi);
}
vagtMenuMain.open(player);
vagtMenuMain.setDefaultClickAction(event -> {
event.setCancelled(true);
});
plushDollar.setAction(inventoryClickEvent -> {
Gui vagtMenuLΓΈn = Gui.gui()
.title(Component.text(ColorUtil.chat(VagtSystem.getInstance().getConfig().getString("prefix"))))
.rows(5)
.create();
for (int i : new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8}) {
vagtMenuLΓΈn.setItem(i, glassOrg);
}
for (int i : new int[]{36, 37, 38, 39, 40, 41, 42, 43, 44}) {
vagtMenuLΓΈn.setItem(i, glassWhi);
}
vagtMenuLΓΈn.open(player);
});
}
why doesnt there show anything up in my GUI? I use triumphteam lib?
aswell as headdatabaseAPI
?paste
What shows up?
Donβt cast it to a hashmap @spare hazel
what should i do
storage.put(NSKeys.ITEM_SPEED_KEY.key, 0f);
storage.put(NSKeys.ITEM_HEALTH_KEY.key, 0f);
storage.put(NSKeys.ITEM_DEFENSE_KEY.key, 0f);
storage.put(NSKeys.ITEM_DAMAGE_KEY.key, 0f);
storage.put(NSKeys.ITEM_TOUGHNESS_KEY.key, 0f);
storage.put(NSKeys.ITEM_FEROCITY_KEY.key, 0f);
storage.put(NSKeys.ITEM_INTELLIGENCE_KEY.key, 0f);
this should work
Ur error is a classcast exception
i have been working day and night to fix this
still no result
now im getting an error about loaading shit from a different class
the glass
I'm giving the player the absorption effect using player.addPotionEffect(PotionEffectType.ABSORPTION.createEffect(60*20, 5)); but the hearts do not appear, yet when I take damage I can hear the damage effect but my hearts do not deplete until after the absorption is gone.
And if u remove the click action?
You can't do this (HashMap<NamespacedKey, Float>) Map.of(
Have this problem:
org.spigotmc:1.20.2-R0.1-SNAPSHOT:maps-spigot:csrg was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/
i ran java -jar BuildTools.jar --rev 1.20.2 --remapped and have this pom.xml - https://pastebin.com/85yEc9g0
Map.of returns an immutable Map
What is the disadvantage of a block placed using the method associated with amorstands?
Which method
ask a specific question
armor stands are used for this
creating blocks with textures has nothing to do with armor stands
custom textures are resource packs
?
to create a texture on a placed block you need an armor stand
no you don't
the block and the texture do not require an armorstand
ok let's say so. How then is a texture created for a custom block?
Iβm not asking about creating my own textures, Iβm asking about adding it to the supplied block
Noteblocks with custom textures
noteBlock has customModelData?
no
How is armorStand not related to the custom textures of the placed block? Do you think you can place your own texture on a placed block without using an armor stand?
hello, how can I add a fake player to the tablist but the actual player character of them being invisible? so just in the tab list with a custom display name
Yes
armor stands are entities
wdym
There is a lot of options
The easiest and without the use of entities
Is to retexture blocks that arenβt used like noteblocks with certain values
Is there any event that can check if an arrow has activated a button?
sponges are a good one
for example, check where the arrow hit when fired
this applies to custom blocks?
yes
and models
custom BlockStates and Custom Textures defined and included in a resource pack
declaration: package: org.bukkit.event.entity, class: EntityInteractEvent
arrows are technically entities
alright thanks
so that should work, just check if the entity in question
is an arrow π
and the block is a button
Is it really possible that these types of blocks cannot be obtained in survival?
this approach clearly must have its downsides, I think
Why
yes, you have to be very careful to not allow state changes to the blocks
wait, is this related to the way the texture of an item with variable durability is changed?
kinda
its closer to how there is a furnace texture and a separate texture for when the furnace is on
durability used to be a way before texture/resource packs
with noteblocks there are a bunch of states that dont occur that you can change the model of if I understand correctly
that is, is it 1 block with different states or several blocks?