Command Errors
Hi, I was wondering if I could get some assistance regarding my code. If you could help, that would be wonderful!

68 Replies
β
This post has been reserved for your question.
Hey @shazim! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
What exactly is the issue you are facing?
π€
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Mind if i budge into this with ya...
but this looks like copy and pasted code from one class to another
Basically the command is "Creative" which i can assume he wants to make a command to change the player to creative mode instead of a "join-message" event thats happening.
usually
event.getPlayer()
would come from an argument from a class that implements Listener interfaceyeah I got that (what it's trying to do) but I am not sure what the actual problem is
the easist way for him to solve this would be to simply create Map that takes in the UUID (player Id) and the value which would be the gamemode! If map contains UUID then do this and he would then need to in the Listener class he makes...he would need a PlayerJoinEvent method and within playerjoinevent then implement the creativeMessage functionality
oh I didn't look at the screenshot and there are compilation errors
Yes
Essentially the following: There is no
this.plugin
and event
he is attempting to access methods from
this.plugin.
but cant because there isnt a JavaPlugin to be instantiated
correctI just wanted to make sure it's clearly written down so that shazim can see it - feel free to continue ;)
Yo I was asleep π
For the βjoin-messageβ, I may or may not have forgotten to change that (mb chat)
For clarification, I am trying to have a /gmc command in which you can edit the message through config.
.
So how would I exactly fix it? Sorry I am a bit confused about what yall are saying
What is
event
supposed to be?
What exactly is Command
?event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', creativeMessage));
In this sectioin, it is suppose to send the message that is found in config.
I copied this from an JoinEvent class, so that is why you see "events"well ig that's the issue
Can you show the content of the
CommandSender
class?
This?
In this case: Can't you just use
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', creativeMessage));
?indeed you can :)
but i believe he would want it to send the message to everyone online
but if that is the case he should create a loop and then just loop through every player online and then send the message from within the loop
nah
Should I change it to just "sender"?

yes
for (Player online : Bukkit.getOnlinePlayers()) { online.sendMessage(ChatColor.translateAlternateColorCodes('&', creativeMessage)); }
Can't you just send a global message?
instead of sending a message to all players
yeah you could also do Bukkit.broadcastMessage
but i dont think broadcast sends in chatcolor...
if not mistakened
unless they fixed it
i know a long time ago that was an issue
@dan1st | Daniel What should I do regarding this?

How are you handling configuration?
(Note: I don't know much about Minecraft - Jordan is probably the better person for that)
Create your main class singleton and use that to retrieve your getConfig method
so in your main class (because you would quite never need to use more than one instance of the main) just create a getInstance method
This is what my config looks like.
.
singleton ugh
Yeahhh
everything would be instantiated within your main class so no need to create more than one instance of it :P
gotta love singletons
Without judge, I also take it you're pretty new to java
yea
I do recommend brushing up on the bare basics of it :P
it could help out a lot
until you want to create unit tests
lmaooo is it safe to say we should ban all instances of the word singleton from this thread
lol
nah it's fine
I mean do Minecraft plugin devs really test their code?
unit testing wouldnt be necessary tbh
All you gotta simply do is...launch server, test plugin functionality...doesnt work? Input System.out.println lines to solve your issue.
:SadMan:
I am following a playlist for it, and trying to distance a bit from it for my own things, like this, so I'm not fully reliate on the playlist and try to learn some stuff myself (clearly you can see this is a disaster lol
Best way you ever get fully developed into this world called software engineering/programming is to do it as you go.
You have a playlist that teaches you things chapter by chapter
learn from each chapter and implement from there
rense and repeat it over and over until you fully grasp the concept of what it is they are teaching
I made the mistake of jumping STRAIGHT into Minecraft Spigot development without knowing a thing of the Java language itself. Wasn't until I got a little older of course and had a want for software engineering as a whole that is when I told myself I need to learn how the language works. Ever since then, programming as a whole became pretty easy.
Another rule of thumb: If you can read Oracle's Java Tutorial Docs...you are a powerful student (fyi) :SadMan:
Im doing the same thing lol
ehh you became smart so I should be fine π
as a person with 0 iq (me), how should I do this π
Whats your main class called?
Also off topic question, how do I format my document in IntellJ IDEA Community Edition
ShazimsPlugin.java
(the name is bound to change lol)I assume you mean indent
I mean how "Format Document" is on Visual Studio, is there a way to do that on IntellJ IDEA Community Edition



go to Code tab on the top taskbar and then you'll see "Reformat Code"
you dont right click
you just select the whole file and then go to the section Code and reformat from there
I'm on windows π

There is no "Code" tab
whats the 3 lines at the top left
Oh nvm when you click the 3 lines it gives you those tabs
ty
No problem
(Also in the screenshot you can see I am getting errors for the code you sent)
I see that
its because you copied and pasted it straight into there :P
I truly do recommend you learn the Java language before you continue :P
You got any playlists that can help without breaking my brain?
Or something that can help
Also @dan1st | Daniel am I suppose to be able to ping these roles?
@

Depends on the playlist you watch but ever heard of a well known youtuber named "Bro Code" ?
Nope lol\
these are moderation roles so yeah you being able to ping these roles is fine
I do recommend checking him out
but be mindful not to fall into "Tutorial Hell"
:P
but doing stupid stuff and pinging these roles as part of it might be a good way to get banned
π€
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Post Closed
This post has been closed by <@810632160418988053>.