#help-development
1 messages Β· Page 2078 of 1
Then don't make arrow code?
well how else would i make my if statement multiple lines
you dont need redundant checks
returns statements :)
if something isAdult, it is ofcourse Agable
but its just to run 2 lines of code
but i need to cast it to ageable to see isAdult
&& event.getDamager() instanceof Ageable && !((Ageable) event.getDamager()).isAdult() &&
Alright im a bit confused.
I was trying to use this to make sure that the item would get removed from the dispenser, however, after I run this https://paste.md-5.net/ocobukifiy.coffeescript I get the bucket being put in the top left side and where ever the bucket originally was, any idea why?
it is also all almost a waste of time for your objective - it really is too bad that intellij does not have a time profiler
is it possible to run a bungeecord command through a plugin on a spigot server
yes
how
ty
so? wont it error if its not an instance of ageable and i try to cast it?
I don't think you understood what I meant
that is not what i said. you check both that its agable and isAdult
I want to run a bungeecord command on the console via a spigot plugin
you think if isAdult fails that Agable is useful to waste time checking?
wdym lol i cant do isadult because i cant cast it unless its an instance of ageable
...
Anyone here knows how to listen for pressure plates using packets?
why would you use packets? an event exists for it
but is it really a β¨ fast async / packets pressure plate plugin β¨ if you use events
that has to be the stupidest thing ive ever heard (not you Lynx, thats great)
Well I'm sorry for asking, I just wondered if any one of you knew if that's possible?
What its wrong i cannot understand?
public void send(Player player, String path) {
this.lang.get(path).equals(String.class) ? player.sendMessage(this.lang.getString(path)) : this.lang.getStringList(path).forEach(player::sendMessage);
}
why
just use the event
use. the. event.
.equals(String.class)?
would that even work
yeah it is possible but unneeded work unless you have an ancient server
Lang its a YamlConfiguration object
So im trying to check if the path is string send player the string and if its a list send the message using foreach
so it will be
lang.isList(path) ? lang.getStringList(path).foreach(text -> player.sendMessage(text)) : player.sendMessage(lang.getString(path))
I believe so
Not working
"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.
Saying its not a statement
Im so annoyed lmao
The error says "that its not a statement"
if (lang.isList(path)) lang.getStringList(path).forEach(Player:sendMessage);
else player.sendMessage(lang.getString(path));
try that
Ok
Isnt possible with "?" ?
it should be but let's make sure its just working for now
also I think im missing a ; on the top if statement
wrote that out in discord so no idea if its right lol
π₯²
Do you kno why it saying "not a statement my code?"
yes but it must be an expression
So a expression?
share the code
Allright
lang.isList(path) ? lang.getStringList(path).forEach(player::sendMessage) : player.sendMessage(lang.getString(path));
the player also isnt capitalized in the lambda
Its a method that why lower case
I believe thats since they want to send every string of the list to the player
this is why I dont do java after work as I am out of my mind lol
π₯²
Oh lmao i dont kno what happens
Java todays is amess
Lot of problems its giving me today
personally id firstly make it work in a normal if statement, then work on condensing it down
I hate debugging a stupid inline if statement lol
prioritize the intermediate working state
Oh so it not possible ho i want :/
I mean
((Runnable)(lang.isList(path)?(() ->lang.getStringList(path).forEach(player::sendMessage)):(()->player.sendMessage(lang.getString(path)))).run() or sth maybe
but it gets extremely unreadable
why runnable?
I mean doesnt have to be
but ternary is what u call syntactic sugar
it compiles down to lower level stuff
"desugaring"
no because you cannot really do anything with void
its just void
like
void x = condition ? send() : disconnect();
that wont work
Oh ok
same with this:
void method(void x) {
}
that does not work either
void is made to just represent nothing
oh ok
what is NMS?
its an acronym for net minecraft server or native minecraft source and basically refers to mojang's server software
what does it do/used for
Statements like this not only need to have a return type but also need to be assigned to a variable. Otherwise you will get an error.
its the server implementation
like
the logic behind entities being able to path finding, ability craft, break and place blocks etc
ah alr
spigot api and plausible forks just create an api (a set of interfaces) which to some extent abstract over the server implementation
this becomes meaningful when the server implementation changes drastically, where apis such as spigot api can resist these changes that causes unexpected and unwanted incompatibilities
In the PlayerInteractEvent, is there a way to detect when a player releases/presses right click?
or is the event based on the keypress
the event is based on what the client tells the server
you won't get key press information
nor a release
You can get if player is sneaking
OnInteract you can check if he is sneaking
how does that relate at all to the question or my statement π
if the click does something, then you would get the event. however that comes with various caveats - (the server itself does not care if the source is a mouse, keyboard, touch screen, controller, etc)
key logging would arguably give too much control
ms wouldnt allow it in any case

out.writeUTF("GetServer");
String servername = in.readUTF();```
in cannot be resolved
what are your parameters
are you writing or reading?
He is doing the 2 things
Because you write the request and them receive a response
in doesnt contain anything
myes but like you usually write the entire thing and then get the array and send that
and somewhere else, like inside the pmc listener would be where you pick up responses
Yeah
try catch (Throwable $ex)???
Thought so
Easiest way is to make a variable "int seconds"
then check if it == 0
I do this through the config
elaborate more
show the config and what u want it to do
Using a jump after a certain time, which can be configured via the config
so in the config u have something like
jump-cooldown: 1
?
yes
and u want it to say "seconds" or "second" where?
I need exactly the ending
In a message sent to the user?
yes
ok so in the message you can do
int cooldownLeft = <get ur cooldown int>;
String message = "Cooldown: " + cooldownLeft + (cooldownLeft == 1 ? " Second" : " Seconds");
if cooldownLeft == 1 then the message will be
Cooldown: 1 Second
otherwise itll be
Cooldown: <number other than 1> Seconds
is it possible somehow without this?
without checking if cooldownLeft is equal to 1?
I need it for different languages
yes
not possible without checking if its equal to 1
so with languages if u have a way to get the plural rather than the singular then change to
int cooldownLeft = <get ur cooldown int>;
String message = "Cooldown: " + cooldownLeft + (cooldownLeft == 1 ? <singular String var> : <plural String var>);
alternatively you could just do "second(s)"
Do all versions of spigot support JDK 18?
?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!
nope
older versions have apache utils which use stuff that was removed in newer jdks iirc
so what would be the best version for 1.13?
It should say when starting the server
Also 1.13 is god awful why...
Like atleast use a more optimized 1.12 or 1.15
basically non lts versions are just experiment and intermediate versions just lowkey (jdk 12 to 16 for instance (but yes they are marked as stable))
I mean since your above 1.8 and your not complaing about pvp why not 1.18
I want to make it cross versions so I didn't know whether you had to have a jdk for all
idk tbh
well
I've not got into cross version support but from what I've done is just use an older version usually the older api works fine but it's awful to manage
It gets really ugly if you use nms
Man people just need to suck it up and use the latest lol. I find it funny that backwards support is such a huge deal. It's not like you can't update your Minecraft. The updates are literally free.
player.getServer().getInfo().getName().equalsIgnoreCase("hub")
error ->
The method getInfo() is undefined for the type Server
spigot 1.16.5
spigot or bungeecord
cuz like, bungeecord and spigot is just one directional
bungeecord knows about spigot servers
not the other way around usually
Anybody here have knowledge on jacksons core?
unless you use sth like pmc
a bit
Im having a mental breakdown
so... how i do?
Dm07 well what are you trying to do?
Ever heard of this error? No content to map due to end-of-input
this
whats the name of the error class?
MismatchedInputException
HashMap hash = mapper.readValue(file, HashMap.class);
i dont get why
its erroring
this SHOULD work 100% fine
how does the file content look like
try{
if(file.createNewFile()){
HashMap<String, Object> hash = new HashMap<>(){{
put("buttonPos", new Vector2(0,0));
put("isBasicGrind", false);
put("isAutoDep", false);
put("isAutoRewards", false);
}};
String json = mapper.writeValueAsString(hash);
FileWriter myWriter = new FileWriter(file);
myWriter.write(json);
myWriter.close();
}
}catch(IOException e){
e.printStackTrace();
}
Generated here
what if u use sth like new TypeReference<HashMap<String,Object>>() {} instead
can i do something? like... put something like
server_name = hub
and take it in the plugin to know that is the hub?
use it where
exactly?
Instead of HashMap.class
Nope
hmm
however that did solve 1 issue i was having
so now i can use <>
for hashmaps
yay
how so?
is there a way i can improve that?
I mean the File class is obsolete and abandoned first and foremost
idk why oracle hasnt deprecated it yet
because Paths are just better
and then you have Files.newBufferedWriter(path,charset) which is just better than FileWriter
(with StandardCharsets.UTF_8)
either with
File#toPath
or Path.of() or Paths.get()
and you use Path#resolve
to walk up or down
and to create the file or directory etc you'd use methods from the Files.java class
A
let me try with jackson
Do paths work the same?
more or less
@fervent gate I remembered.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#setWorldBorder(org.bukkit.WorldBorder)
WorldBorder border = Bukkit.createWorldBorder();
border.setCenter(player.getLocation());
border.setSize(25);
player.setWorldBorder(border);```
try (var writer = Files.newBufferedWriter(file.toPath().toAbsolutePath(),StandardCharsets.UTF_8)) {
writer.write(json);
}
iirc
might have to use sth like if (Files.notExists(path)) Files.createFile(path) (before)
they're not manually serializing with jackson either tho
well manually as in having to create a map like this
I mean they could create a pojo
true true
and like... jackson supports that as much as gson, but ye gson is a bit more intuitive and just better designed imho
@ivory sleet Would you like to know what im doing btw lol
true true, i guess things cant be simple in enterprise applications π
I got lazy and made a macro for a discord bot cause I dont wanna spend all night grinding so it does tasks for me based on settings I want it to do
:P
Dm07 srry but if you wanna get the name of the spigot server from spigot
AKA: Im lazy
oo thats handy
lol ye
or whatever its called idk
average naming
@ivory sleet Bad ui but it works
lol
EDIT nice, typical java ui tho
LowerAndUpperCaseWithUnderscoresStrategy
theres a gui library uhhhm
shit whats its name
sec
lol
sec this might take a while but ik it was really cool
π
π
The heck?
id love a new ui for it lol
java swing
im coding a macro
for a discord bot
cause i dont wanna grind on it all night
so it auto does every taslk for me
logic 100
The robot takeover is here
debounce = !debounce
has a lot of neat features too
oh holy
Yo is that minecraft
thats... fancy
YESYESYESYES
ngl you probably could make some type of block editor with this
THAT LOOKS BEYOND BEAUTIFUL
heres the java port @quaint mantle
I wonder what the first version of minecraft that had a GUI looked like
even nodejs has a port for imgui lmfao
tbf i dont think its every been changed always that grayish themmed stuff
you could use a ooooooold version and look
wait... wont I have to like, redo 99% of my current code
to make it work
with this
only the part that handles your GUI
Nah not the inventory GUI
But like, the first version of the game to actually open something that wasnβt a console window
Probably just an empty void
probably looked really buggy
if u coded ur thing well then ye
theres a video of the first ever mc video thingy
https://www.youtube.com/watch?v=N1JcR6n4fgo
But this isnt likely the first ever version of mc ofc, just the first video of mc ever
this is where 1.8 faction devs usually turn out to be the biggest culprits, bad design per say
sorry i lied with my first link
https://www.youtube.com/watch?v=LEG9feKeQMY&t=0s
This is the first ever MC video, but its made by the same guy who did the mario vid (thats ones the 2nd)
can i do something? like... put something like
server_name = hub
in server.properties
and take it in the plugin to know that is the hub?
you can just make your plugin a bungee plugin and then have the command registered on the proxy
i think i might have an example of this
ok
Okay my example likely wont work as it used a annoted command api as well as other things apologies
but
iirc if you try to send a player to a server theyre already on
it wont reconnect them
as with my examples we didnt do that but there could of been something in our API that handled it
yeah i know i want to if he do /hub he go to 8 4 8 bc i can connect player to server but if he do /hub on the hub it do an error...
8 4 8?
i see, in that case bungee should have an option to get the servers name the player is on, so you can just register a command to the proxy and handle it there
but... can i do this?
what we did is in config.yml we specified the server name in there
idk if your able to add stuff to server.properties
i could be wrong though
yes and just save your servers name/key in there, IE Hub-01 but youll need plugin messaging ofc
its been almost 3 years since ive done any bungee development so things could have changed as well, you can always google this stuff too
install what?
nvm, wait it has to load into a custom window?
wha
imgui
ive only sparingly used it tbh, never used its java port
ah
its a little harder to work with but it definatly looks nice
any ports documentation relies on the native C# variant
wait, so then
how would i change the UI style
without having to make it load a second window
#general
@noble lantern class java.util.LinkedHashMap cannot be cast to class com.emerald.funcs.Vector2
Any reason this may occur?
(I made a custom Vector2 class for java)
Lol
?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.
your custom vector2 class
needs to extend/implement LinkedHashMap in order for you to cast it like that
which i dont rly reccomend
why do you have to?
You just make your command extend/implement that class and then your gonna need to override any methods (Your ide should tell you)
you should be able to just implement it
it requruires an extends, but its not actually a whats it called
its not a hashmap
yeah with extending stuff your gonna have to actually basically re-create linkedhashmap and its methods
which really isnt something you should do
Why not just make the Vector2 class hold a LinkedHashMap variable?
and yourVector2.linkedHashMap
package com.emerald.funcs;
public class Vector2 {
public float x;
public float y;
public Vector2() {
this.x = 0.0f;
this.y = 0.0f;
}
public Vector2(float x, float y) {
this.x = x;
this.y = y;
}
public boolean equals(Vector2 other) {
return (this.x == other.x && this.y == other.y);
}
}
this is what it looks like
?xy
Asking about your attempted solution rather than your actual problem
You thats not a typeof LinkedHashMap its just a class
What are you trying to do
Vector2 data = null;
try {data = (Vector2) new App(false).retrieveData().get("buttonPos");} catch (IOException e) {e.printStackTrace();}
retrieves data from a JSON file
and returns buttonPos inside it
so i can convert it to Vector2 and use it
to move the mouse
yes i am using jackson
if you used gson, you could store that class stupidly easy
how lol
Should be equals(Object)
And you also need to override hashCode if youβre doing that
How so?
The same way youβre overriding equals
With gson you could store that class super easily, youll just have to change these 2 arguments
without any of the LinkedHashMap bs
You donβt need to use gson
im sure jackson has a feature similar to this
i just dont know jacksons api
can probably google it
but spigot provides gson by default
Yes but send a link so I can read into that
ObjectMapper objectMapper = new ObjectMapper();
Car car = new Car("yellow", "renault");
objectMapper.writeValue(new File("target/car.json"), car);
as Im unsure how id do that
oh neat
hell yeah
i took the interesting route to generate that data
without using a class
You took the wrong route
Lmao
Youβre gonna have to parse the strings and create your class manually if you donβt want to use the mapper
if(file.toFile().createNewFile()){
HashMap<String, Object> hash = new HashMap<>(){{
put("test1", false);
put("test2", false);
put("test3", false);
put("test4", false);
}};
String json = new ObjectMapper().writeValueAsString(hash);
try (var writer = Files.newBufferedWriter(file.toAbsolutePath(), StandardCharsets.UTF_8)) {
writer.write(json);
}
}
i used mapper
i just store it as a JSON instead
via a hashmap
Why would you do that
honestly, to see if it could be done
suprisingly its fast
fair
also, why would i need to override the hashcode
Read the article
If you override one youβre supposed to override the other, itβs part of the Java class contract
Okay, but I dont have an id variable
Only X and Y
so what do i return
okay where do you think of that
ok
package com.emerald.funcs;
import java.util.LinkedHashMap;
import java.util.Objects;
public class Vector2 extends LinkedHashMap {
public float x;
public float y;
public Vector2() {
this.x = 0.0f;
this.y = 0.0f;
}
public Vector2(float x, float y) {
this.x = x;
this.y = y;
}
@Override
public boolean equals(Object obj) {
if(this == obj)
return true;
if(obj == null || obj.getClass()!= this.getClass())
return false;
Vector2 vector = (Vector2) obj;
return (vector.x == this.x && vector.y == this.y);
}
@Override
public int hashCode() {
return Objects.hash(this.x, this.y);
}
}
ID is just an example field in that article, not something special that hashcodes are based on for every class
oh
Change the getClass thing to obj instanceof Vector2
Like !(obj instanceof Vector2)
@brave sparrow There, but it still errors
This code is very incorrect
class java.util.LinkedHashMap cannot be cast to class com.emerald.funcs.Vector2
Oh. What will lol
A
Correct
Nah
If youβre doing something like a vector you donβt want to use default equals
because Vector2 isnt a LinkedHashMap
ahhh fair enough
Even if two Vector2s are constructed separately, if they have the same x and y they should be considered equal
How do I attach it properly then
your better making a convertToLinkedHashMap() type method
that returns a LinkedHashMap
No
ohh i see
You made the poor decision to not use an object mapper
So you have to do the parsing of the JSON object into your class manually
public HashMap<String,Object> retrieveData() throws IOException {
return new ObjectMapper().readValue(file.toFile(), new TypeReference<>() {
});
}
How
Its returning the readvalue information
Which is a HashMap<String, Object>
If you look at the method signature
That object mapper is just mapping it to a hashmap
AAAAAAAAAAA
then how do I do this correct
String json = "{ "color" : "Black", "type" : "BMW" }";
Car car = objectMapper.readValue(json, Car.class);
So in your case
I am not changing how this works, I dont want it as a complex class
Np
String json = new ObjectMapper().writeValueAsString(retrieveData().get("buttonPos"));
data = new ObjectMapper().readValue(json, Vector2.class);
thats really dumb however, to workaround like that
idk if its just me but for some reason i cant get my inventory click event registered..... but yet i can get the inventory itself opening...
ping me if u have a solution or wanna see the code or somethin
Sigh. Just send your code. No one here wants to ask you for it just paste it in pastebin and attach it to your message.
how can I solve your problem without any context simply It won't register is so vague
what you are telling me you don't have psychic abilities?
That's a bannable offense I think
... π I'm sorry I just I'm not smart enough for that
don't worry, I don't have those abilities either, just assumed others did lol
but I guess that person above doesn't need help either
Ahaha
Probably realized it was never annotated
ok sorry... sending in a few just let me get the class's all sorted out here in a paste bin
Main Class: https://pastebin.com/pHph8CHd
Inv Click & GUI Class: https://pastebin.com/TUgcyYYZ
Description of my problem: For some reason my inventory click method event wont register but yet the gui opens up fine and all that i don't know what i am doing wrong. ( as its literally 2:25 am and im tired )
im going to bed ping me if you know a fix to this since i most likely will be stuck on this random issue as well tomorrow...
uh oh
You change the instance of the inventory each time you execute that command and that's gonna cause problems, I'm suggesting you to change how you handle it.
The event registers fine. Your issue isn't the event.
Firstly you shouldn't put your listeners and commands together. I mean you can but it gets a bit messy on the reg
Here is your issue
pm.registerEvents(new PracticeXSCommands(this), this);
pm.registerEvents(this, this);
getCommand("practice").setExecutor(new PracticeXSCommands(this));
You register 2 new instances of your class. When you do this the listener gets an inv variable and the command gets an inv variable. Because they are neither static nor of the same instance the listener inv will always be null. The solution is to
- Register 1 instance of the class (you'll still need to solve the issue that if 2 people run the command the inv instance gets set again.)
- Create a custom inventory you can instanceof check
Could not find artifact com.github.koca2000:NoteBlockAPI:pom:1.6.1-SNAPSHOT in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
why do i get this error?
this is what i want to implement
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.koca2000</groupId>
<artifactId>NoteBlockAPI</artifactId>
<version>-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Wrong version
Actually the error doesn't match what you sent
Bukkit.getScheduler().scheduleSyncRepeatingTask(pl, new Runnable() {
@Override
public void run() {
for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
onlinePlayer.getPlayer().sendMessage(ChatColor.GOLD + "[StrengthWave]" + ChatColor.RED + "You have been given Strength I!");
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 80, 0));
}
}
}, 1200, 1200);
Why does this spam the message a lot of times.
it is supposed to do that every minute once.
are you spawning the repeating task multiple times ?
once
Well the ticks look good so
registering multiple ones seems like the only logical explanation
I'm assuming your main class is called "Out", if so then you should receive a nullpointer exception error I believe since you are not setting the "plugin" variable to anything
Pretty sure we told you what was wrong yesterday
This
huh?
This is null and always stay null since you arent setting it to anything.
Use a getter in your main class to get the instance of the plugin.
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Or this ^
i have this getServer().getPluginManager().registerEvents(new Vanish(), this);
but how do i set the variable?
Read what we said above
makes things so much easier
and i still don't now how?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
This should satisfy what you want it for.
?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.
Fair, I'll keep it in mind.
I like my new message / translation api
Msg.get("cooldown").placeholders(player).replace("{cooldown}",String.valueOf(timeLeft)).sendTo(player);
?di instead of a public static main lol
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
?main too
but why
because it goes brr doing Main.PLUGIN.something()
also I don't agree with the "don't name your stuff main" post
what exactly goes brr
why not making every field public then and using static everywhere?
I mean where's the problem with this? https://paste.md-5.net/wojexoxoki.java
its just cleaning in my opinion
i have a cooldownmanager per command
so i instantiate it
i still have to make mine π
like Map<BaseCommand,Map<UUID, Long>>
it went the wrong direction when i made an enum to represent the command
and saving the command instead was like useless
memory waste
i could do it but ye
well references typically have 4 bytes
hmm i could just use a Map<UUID, Long>
in the command class basically
but then i made a proper Cooldown class so that became Map<UUID, Cooldown> and now im stuck lol
if I had more than one command that have cooldowns, I'd probably make an abstract class that extends BaseCommand and has the cooldown stuff builtin
than other commands can just extend that one
then i was trying to save the cooldowns in the user profile class so it could be easily saved to the database
im just trying to put everything the user has in the User class
f.e. it contains the homes
chatprofile
etc
and now i ended up with a Map<CommandType, Cooldown>
Why does Material#GLASS_PANE have Fence.class as itβs BlockData and not GlassPane.class?
Probably a historical decision based upon glass panes and fences being connected blocks
Well, stained glass panes on the other hand have GlassPane.class as a blockdata which is what puzzled me
Probably a legacy thing
Okay yeah I can't explain that lol
Since glass panes have existed much longer than the stained version
for me it returns CraftIronBars lol wtf
class org.bukkit.craftbukkit.v1_18_R2.block.impl.CraftIronBars
Fair point, still seems like a silly design choice
System.out.println(Bukkit.createBlockData(Material.GLASS_PANE).getClass());
According to the docs, it has Fence
(Not) a good API!
minecraft is really weird
no u!
first one
the [] belongs to the type
first one unless im in C/Cpp
yeah that's weird as hell lmao
well if you want to have 2 ints and one int[]
lol
yes, as I said myself, it's only useful for "weird stuff"
depends, you can toggle this inspection
but yeah imho the [] belongs to the type so it should be in front of the var name
just ignore the warning
fun fact, on default settings, intelliJ considers this to be totally fine:
private int[]a,b[];
a is now int[] and b is int[][]
lmao
sure
makes perfect sense
yeah sure
bwt @quaint mantle where is your contribution to #961533327435788348 ?!
:<
Does PlayerInventory#getContents return the contents in order?
That seems to be the case, but I want to make sure.
Gotchu. Thanks
be aware that getContents also contains null elements
unlike getItem(int) which simply returns empty itemstacks
π
I need help with iterating over a configuration section inside a file, my result is that it only goes to the first key and then stops
?paste your code pls
Showing the config file may help as well.
^
sorry, I'm new
just go the website I linked, then paste your code there, click on "save", then send the link
and do the same for your config file pls
looks good to me. are you sure the config.yml in your plugins/<yourplugin> folder actually contains all those sections?
or did you only add them to the default config?
yeah well but that doesn't matter. show the code where you loading your yaml file pls
ok
Hi, the comments explain my problem
How can I get around this?
event.getEntity();
// I need an entity like Zombie or Skeleton to modify health
// But I don't know which type the event.getEntity() has
Zombie entity = (Zombie) event.getEntity();
// Now I can call the method
entity.setHealth(1);```
use LivingEntity instead of ZOmbie, etc
all entities that have health extend/implement LivingEntity
public class PreventMobs implements Listener {
@EventHandler
public void onMobSpawn(EntitySpawnEvent e){
Entity mob = e.getEntity();
if (!(mob instanceof Player)){
Location loc = mob.getLocation();
System.out.println("Only chicks allowed!");
ExplodeChick.createChick(loc);
}
}
}```
im trying to make a plugin that removes all entities and change them into custom chickens but it does not work, it spams this error. can someone help me?
are you 100% sure that the saved file (not the you edit in your IDE) includes all the arenas?
Does that make sense
if(!event.getEntity().getType().isAlive()) return;
can I just dm u
no. check if "entity instanceof LivingEntity"
just check to see if the entity is an instance of living entityt
pls don't
thx
ok
good point, let me check
you only "save" your included file when there is no file existing yet in the datafolder. my guess is, you saved the file oncewhen you only had one arena in the default config, so of course the file still only contains one arena
thanks so much! I had made some adjustments to the file in the IDE and it didn't save properly, thanks!
np π
wtf, what kind of unicode character is that lmao
hey so im making a plugin and in the plugin there is a command that creates a world, however when the plugin starts up i am getting this error Error occurred while enabling OneBlock v1.0 (Is it up to date?) java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "dev.jamieisgeek.oneblock.OneBlock.getCommand(String)" is null at dev.jamieisgeek.oneblock.OneBlock.onEnable(OneBlock.java:12) ~[OneBlock-1.0.jar:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:564) ~[paper-1.18.1.jar:git-Paper-177] at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:478) ~[paper-1.18.1.jar:git-Paper-177] at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:727) ~[paper-1.18.1.jar:git-Paper-177] at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:503) ~[paper-1.18.1.jar:git-Paper-177] at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:313) ~[paper-1.18.1.jar:git-Paper-177] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1202) ~[paper-1.18.1.jar:git-Paper-177] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317) ~[paper-1.18.1.jar:git-Paper-177] at java.lang.Thread.run(Thread.java:833) ~[?:?] when the plugin loads, any ideas?
you didn't register your command in plugin.yml
here is the code i believe is responsible: java getCommand("create").setExecutor(new IslandCreateCommand());
oh fuck
yeah
that'll be it lmaoo
yeah it's pretty obvious, the stacktrace tells you that the return value of "getCommand(String)" is null π
I'm so glad I always use ACF so this kinda stuff cannot happen to me anymore lol
Hey, this might be a stupid question but I try to use a plugin where it uses Redis and they're using Redisson, but for the address I need to put the IP and the port, and where can I find that?
well do you have any redis server?
then they probably tell you the IP, username, port, password somewhere?
ok so apparently the ageable thing was working, it's just returning null when im holding an item
you can also easily install redis on windows -> https://redis.io/docs/getting-started/installation/install-redis-on-windows/
WHAT is returning null?
getItemInUse()
only public endpoint and password
does that only work when they are using it or smth
can you show the public endpoint URL?
just don't include the password :p
i'll dm you
k
people are gonna love me so much
smh
how dare u
but anyways, why is it returning null
when im literally holding an item
ima do getInventory().getItemInMainHand() and see if that does smth
can someone help me with this error pls, i want to make a plugin that changes all entities in custom chickens
you listen to entityspawnevent, then you spawn a new chicken, so you listen to it again, then you spawn a new chicken, etc etc etc
you have to cancel the event or change the mob type (idk if thats possible)
dutch lol
how did you know lmao
you have a discord profile
En ik hou van eten, maar wie niet
and this looks kinda dutch
lol
it is
Ahhh tysm btw, i changed the if statement and now it works
lekker hè, maar hou niet zo van aardappelen
I'd do it like this
private boolean ignoreSpawn = false;
@EventHandler
public void onSpawn(EntitySpawnEvent event) {
if (ignoreSpawn) return;
// Do your stuff
ignoreSpawn = true;
// Spawn your custom Entity
ignoreSpawn = false;
}
meh
yeah, but then it runs the code too if a player spawns
then check if the spawning entity is instanceof Player
i want to use essentials economy with my plugin and i dont know how to implement it
isnt essentials eco using vault?
pretty sure that it does
if you have to install vault then it probably uses it
essentials definitely does not require vault
yeah I think it uses vault when it's installed, but it also works without it
but yeah, you should always use vault to add economy support
read about how to hook into vault
lmao
i cant even leave the server
cuz the games so laggy
heres the code if u want it https://paste.md-5.net/wusecebiqi.java
lmao
im getting decent fps now
kty
loading new chunks makes them all strike at the same time
theres just a border of fire around the edge of chunk range
it spawns chickens now, but everytime the chicken dies it spawns a new chickenjava new BukkitRunnable() { @Override public void run() { if (!chick.isDead()) { if (chick.getTarget() == null) { for (Entity entity : chick.getNearbyEntities(10, 10, 10)) { if (entity instanceof Player) { Player player = (Player) entity; chick.setTarget(player); } } } else { LivingEntity target = chick.getTarget(); if (target.getLocation().distanceSquared(chick.getLocation()) < 25) { chick.getWorld().playSound(chick.getLocation(), Sound.ENTITY_CREEPER_PRIMED, 5, 5); chick.getWorld().spawnParticle(Particle.SMOKE_NORMAL, chick.getLocation(), 10); Bukkit.getScheduler().runTaskLater(main, new Runnable() { @Override public void run() { chick.getWorld().dropItemNaturally(chick.getLocation(), drops); chick.remove(); chick.getWorld().createExplosion(chick.getLocation(), 5, false); chick.getWorld().playSound(chick.getLocation(), Sound.ENTITY_CHICKEN_HURT, 5, 5); } }, (2 * 20)); } } } else { cancel(); } } }.runTaskTimer(main, 0L, 20L);
wtf is "chick"?
an entity you haven't seen because you dont go outside
then only spawn a new one if the entity which died isnt a chicken?
404
lmao
obsessed
I want to get close to you, you are my dream come true. β¨ Obsessed With You by The Orion Experience from the album Cosmicandy. Perfect song for your favorite fandom. ππ
π΅Spotify: https://open.spotify.com/artist/2qU0jqxiFeXrw5NTV1bIQM
πApple Music: https://music.apple.com/us/artist/the-orion-experience/215309076
πORION EXPERIENCE MERCH
https://l...
weird music
no u!
"i wanna have sex with u" π
obviously the singer is obsessed with you
ah yes
speaking skill leveled up
wdym? in which line am i spawning a new chicken if something dies
its actually rlly fun to run around and try to dodge the lightning
what were you doin again?
lol
creating a plugin that spawns custom chickens instead of other mobs
ah right
seems logic that whenever an entity dies a new chicken spawn?
so whenever your custom entity spawn it also spawn a new one?
yeah, but i dont want that.
if the chicken explodes an exact same chicken spawns at the same place as the died chicken
and i want a chicken that explodes without spawning a new chicken
do those custom chickens have any special things applied?
yeah they have a name
you could try to check for the name but that will cause problems with other named mobs, i would set something in the pdc so the entities can be identified as being a custom entity or not
?pdc
Is there a good way to add an entity to a team?
I tried hideNameTags.addEntry(entity.getUniqueId().toString()); but this didn't seem to work
arent teams only for players?
oh
any idea what this means
class not found exception
you need to shade the libs
π
oh oops
it still does not work >_<
But does the showNameTags Option work with showCustomName(true) ?
Works.. Thanks!
Error?
xD
im still getting noClassDefFoundError
that doesnt look valid
you don't need to specify the class, just the package
so the pattern should be de.jeff_media.customblockdata i guess
i think you're pointing it to a class
i have my thing like this
does spigot think a dropped item or a explosion is an entity
then i think i know whats going wrong
its probably not an entity xd
still doesnt work
an explosion is not an entity, but a dropped item actually is
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<configuration>
<relocations>
<relocation>
<pattern>de.jeff_media.customblockdata</pattern>
<shadedPattern>me.hypercodec.hardermode</shadedPattern>
</relocation>
</relocations>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
thats my tuff
stuff
ah
you're putting configurations inside the executions
here's an example of mine https://paste.md-5.net/lugiwawemu.xml
you need a phase too i guess
Hi I made a login and register system. Everything works except imagine you join the server you register you disconnect and when you go to reconnect the password will be said not to exist whereas in the yml file it is present because after a restart of the server if you reconnect it works perfectly. If you have a way to update the file or other I'm interested!
If you need some codes @ me ! Thx
google translate moment
did the password change when they logged out or something?
and it wasnt saved to the file?
It was
But the server if i dont reload it dont seems to see it
im not understanding what you mean
Then you are not updating the data in memory
I just write and save it
sounds like you save to file, but don;t update your data in memory untilyou reload
Yes
?paste I am having a problem creating a log file. I am trying to create it new every time the plugin is enabled, but it keeps creating a new file instead of overwriting the original file. Paste is here -> https://paste.md-5.net/mitusufeyi.cs
how can I send hex colored messages to players?
ChatColor.Of(String hexCode) + "text"
with # or without?
thanks, ill try
np, tell me if it works
works π
ignore the nullpointer at the top. but thats your answer
null means that it has not been changed I believe
So, I'm doing a project and a client wants me to draw a peace sign with redstone particles. How would you approach this? I have no clue where to start.
Have a list of locations that make a peace sign and spawn the particles at each one?
how would you come up with the list of locations though. It has to be relative to the player's location. I assume there would be some math involved.
gradle be like
If you want to make it more versatile you could make a function which writes the locations of blocks to a file when you make something like a peace sign. something like "write all block locations to a file where the block type isnt air"
if the peace sign is all you need you could just hardcode a peace sign and display it at a location you pass into that method
just for later today, id like to know if drawing outlines on blocks the player isn't looking at when holding a certain item is possible with spigot NOTE: Moved from #help-server to here
now with plugins being server side this seems close to impossible, but im just not sure
what world format does spigot use? anvil?
yes
it's not possible
I think all modern servers use Anvil lol
that outline is rendered client-side
Actually wait no there is one server implementation that does not use Anvil
But it's not fully implemented
If you want to get funky, grab a peace-sign image, read all the pixels and do some magic
ah well i was going from a pocketmine world to spigot
and stupid pmmp uses pmanvil so
thanks for the confirmation on that!
i could use particles maybe?
and try to be as light with them as possible
where can i find the usage for this constructor in the bukkti code?
yes
Well you have bukkit's code on spigotmc hub
You might need to import the entire project with your IDE
i tried that
but also are you sure it's even being used π€
you gotta refresh the project
but it is not being recognized as maven project
You need a pom.xml for it to be recognized
how do i refresh
you need check the pom in "Bukkit" "CraftBukkit" and "Spigot" directory for make the IDE read this directory like a maven projecct
could someone send me the spigot git linjk pls
just gonna bump this, cuz im still not getting it
how can i make the effect duration and the effect if you open the inventory invisible
so you cant see the effect
i think it's the ambient tag
ok
ok
any way to detect a plugin's memory leak?
spark
ty
we have a server with 99 plugins and one with 20 and the one with 99 is using 2gb of ram and the one with 20 is using 7
pain
hm
probably my fault >->
do a timings report AND a spark report, then send it in #help-server
how to change a item from creative middle click?
how can i clear this
Okay so i pretty much should just remove this then:
pm.registerEvents(new PracticeXSCommands(this), this);
pm.registerEvents(this, this);
As that is causing it to not work correct?
Look into the InventoryCreativeEvent. You might be able to check the click type there.
get the active potion effects then remove the potion effect(s) from the user.
no i mean that the effect is still there but this menu not
Not sure if that is possible. If you have an effect, it will show up in your inventory and on your screen as the smaller variant. I think this is client sided behavior.
You might be able to remove it with a resource pack.
any resources on how to do so?
how do i send a multiline message in spigot to a player? using the '\n' character does not work
xD
seems unsupported
and i dont want to send multiple msgs
im trying to use CustomBlockData, but i keep getting the ClassDefNotFoundError despite shadowing it
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<configuration>
<relocations>
<relocation>
<pattern>de.jeff_media.customblockdata</pattern>
<shadedPattern>me.hypercodec.hardermode</shadedPattern>
</relocation>
</relocations>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
is this the right shade?
uhhhhhh
did you set its scope?
good
Knowing each message's width, we can spam spaces until it's on the next line
which breaks half the game's chat settings
How can I make an event that fires when a player wears a specific player head?
also team.getPrefix() on an empty prefix returning "" ? or null and thus throwing an error
cause its using the NotNull annotion
so why does it not work
It's probably not getting included in the final jar. Try setting <minimizeJar>false</minimizeJar>
Hello i want to cancel the animation with the chest and done this:
if (block.getType() == Material.CHEST) {
Event.setCancelled(true);
Chest chest = (Chest) block.getState();
Inventory inv = chest.getBlockInventory();
player.openInventory(inv);
}
But dont work, if someone know how can i fix it ? It just open the inventory normal
Its not my question
the animation is showing?
Yep
any other plugins listening for that?