#help-development
1 messages ยท Page 1955 of 1
System.out.println
private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
System.out.println();
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
System.out.println();
return false;
}
econ = rsp.getProvider();
return econ != null;
}
?paste would be better
well huh? you should add string inside println
like
ok
what the fuck
Files.copy was added in java 7?!
why have I been messing around with bufferedwriters and inputstreams all the time
How do I change project folder in intellij
wdym?
well then rep is null
?paste your full server log pls
oh nvm
um how to change project location
do you actually have any economy plugin
?paste Please use this
this is why printing useful errors is helpful ๐
I'd do something like
public enum EconomyResult {
SUCCESS, NO_VAULT, NO_ECONOMY_PLUGIN;
}
and return that instead of a boolean
reading the pluginyml and catch the command na mes
but i want the server operator to add other commands to config
you can for each getDescription().getCommands()
oh i see xD
getConfig().getConfigurationSection("commands").getKeys(false)
that will not work
getCommand returns null if it's not defined in plugin.yml
^ youโd need to reflect the command map
is System.out.println the only way to print message in console without "[16:38:08] [Server thread/INFO]: "?
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/CommandUtils.java this is how I register custom commands
you should never print to console without the proper log format
why would you ever want to do that?
it's just a fancy text
i don't want that shit over it
also it's not "shit" but the common log format
sorry, i mean it's not neccessary in this case, but ok
A certain fork will also yell at you if you use sysout
it would break all log parsers
it's not forbidden to mention paper here ๐
the log format exists for a reason. e.g. if you open the file with a log parser, you can tell it to "only show errors" and ignore infos, etc
Hello lads
you didn't define your command in plugin.yml
The CraftItemEvent
you forgot @ EventHandler
Nope lol
lol jk
loll
Tryna phsyc
lmao
anyway
Help me out
I need help figuring out how to check if a player Crafted a workbench
you can get the recipe from CraftItemEvent
from the recipe, you can get the result
and check if it's Material.CRAFTING_TABLE
Oh mk
but, and that's important
How can I check the player who crafted it
CraftItemEvent is called when the item is taken out
cus e.getplayer don't work ;-;
NOT when the crafting recipe was finished, if you know what I mean
Yeah ofc
you need the player?
That's what I need
To send a message for example
you can get the INventoryView from the event
and then do getPlayer()
however it returns a HumanEntity, not a player
so you have to check if it's a player, then cast it
something like this: (one min)
@EventHandler
public void onCraft(CraftItemEvent event) {
if(event.getRecipe().getResult().getType() != Material.CRAFTING_TABLE) return;
if(!(event.getView().getPlayer() instanceof Player)) return;
Player player = (Player) event.getView().getPlayer(); // this is a cast
}
although it returns a HumanEntity, you can cast it to Player using (Player)
Does proxiedPlayer return null if player isn't online or isn't connected?
should be mentioned in the javadocs
Last question: how do I get a recipe from CraftItemEvent?
see my code above: event-getRecipe()
ah
Thatโs also in the docs
well
what method exactly
ProxyServer.getPlayer(name) or (uuid) probably returns null if the player is not online
but not sure, the docs don't clarify it
since bungee doesn't save any playerdata though, I'm pretty sure it'll be null if they are not online
Yes, this. And yea I don't see anything about it in the jd. I assume it's not null since there's an isConnected() method but I'm unsure
that probably is for players that were once connected and then left
I highly doubt you'll get a ProxyPlayer when using getPlayer("asdawdasdasdasd");
but - just try it and see ๐
it's 99% the same as in spigot
Bukkit.getPlayer("somePlayerWhosNotOnline") returns null
but Bukkit.getPlayer("mfnalex") returns an object, and when I leave, you still have the player object around
I'll treat it the same as Spigot's Player then
I got a question about my current design for my discord quizbot.
I currently have this:
1. A GameManager that keeps track of open Games.
2. A Game object for every open game. It holds a List<Question> and a HashMap<DiscordUser,List<Question>>. The List<Question> is a list of all questions that will be asked in this quiz, and the hashmap contains the correctly answered questions per player
3. A Question object, containing a List<String> with the question itself, and a List<String> with the correct answers for this question
Anything that I'm missing? From what I see, that's already everything needed lol
NoClassDefFoundError
Why does the UUID that I have in-game doesn't match the UUID that I get from the Mojang API?
offline mode
?
On both online and online mods
is your server set to online-mode: true ?
It's like 3 different uuids
No atm
Wins/Losses
you MUST use online-mode to get proper UUIDs
per user? yeah, I'll add that later ๐ currently I just need the base game working, then later I'll add a Statistics class
Essential playerdata etc
Then why do I get wrong UUIDs on online mode also?
๐
you should get proper UUIDs in online mode. unless your players are using bedrock or sth to connect
It works for online mode, but how do I deal with it on offline mode?
What I want is to get UUIDs of offline players on Bungee
You'd have to store data by yourself
How do I store it if the player has never played on the server before?
you get the list and use List#contains(...)
i recommend using UUIDs
as they are name independant
otherwise it would break if someone changed their name
Hmm
What does the documentation say?
idk im not reading it. YOLO
Hmmm maybe you should
No results found on spigot javadocs
declaration: package: org.bukkit.configuration, class: MemorySection
why don't you just use getString()? o0
that's a string array or string list
ok i will try getStringList
I have an public int function, which returns the player's progress (in a tutorial plugin)
And I want to check if a player who crafted an item (in another RecipeCraft class) has already passed through the other steps
Here's the function
cube gravity
public int getProgress(OfflinePlayer p, int amount) {
if (progress.get(p.getUniqueId()) != null) {
return progress.get(p.getUniqueId());
} else {
return 0;
}
}```
Question is there a way to update a players location without teleporting him?
Update?
So, to move a player
To a loc without tp?
Where do you want their location to be updated?
Yep because the Player is sitting on a PacketSpawned entity and this is moving
And at a range from 45 Blocks it is despawning and the player still has the same loaction on the server and it moves more then 45 blocks that is my problem
Yeah and I also have the other problem
Yep
Hm
Yes
A friend told me in older version it was working with nms but in newer version it should be a other way but he don't know
What version is your library?
1.17.1
Can't update currently because of the annoying lead bug
This is why I'm sticking on 1.17
lead?
is there a way to check if the BungeeCord has online or offline mode?
ahh this lead
Yep
Lol
And 1.18 has a annoying bug
althgough no idea why it's deprecated
which one?
ty
is there a good tutorial on deserialization yaml files into custom objects using SnakeYaml (NOT Spigot/Bukkit API, but plain snakeyaml)?
of course I could just create one fromMap method or sth
but maybe there's already some builtin way
hm what do you people think - is it bad style to set a variable and return it in the same statement?
public Question getNextQuestion() {
if(!hasQuestionsLeft()) {
throw new RuntimeException("No more questions left");
}
return currentQuestion = questions.get(currentQuestionNumber++);
}
Why do you need the current question if you already have an index for it
hi! anyone know that is the problem to my code it logs everything into my console that it should be
https://srcb.in/nDtlEDN1k4
cuz i don't want all blocks to appear at the same time
yes
The reason is because in 2 seconds it's air
Just as a test, instead of doing set type(mat)
yes
Set it to like dirt or something
i figurided uot now
but if i set it to Material.GRASS_BLOCK it doesn't do anything still
because the List<Question> is not public
from the outside you can only get Question getCurrentQuestion() and int getCurrentQuestionNumber()
What's you do
What i meant was, getCurrentQuestion could be just questions.get
i tried that yesterday but it didn't work for some reason xd
but the method I sent is getNextQuestion() which sets the current question to the next question, then returns it
e.g.
new Game();
game.getCurrentQuestion() -> null
game.getNextQuestion() -> returns first question
game.getCurrentQuestino() -> returns first question
game.getNextQuestino() -> returns second question
actually do you have an idea to make it apper not at the same time cuz the for loop run like infinitly fast
and even if i make a runnable it feels the same like if i didn't make the the runnable it just sets the blocks 2 secs after
...
Yea, but im just thinking you do not need to keep a constant reference to the current question itself in Game
why is it questino
because I thought people would recognize it's just a typo and ignore it
yeah true
not really needed
I'll remove it
Because I wont want myself to forget to update that reference
Unless the data structure is a tree
it's this now
public Question getNextQuestion() {
if(!hasQuestionsLeft()) {
throw new RuntimeException("No more questions left");
}
return questions.get(currentQuestionNumber++);
}
public Question getCurrentQuestion() {
return questions.get(currentQuestionNumber);
}
Ye
maybe any more improvement ideas? ๐ https://paste.md-5.net/kabedirofa.java
I think I'll just put the whole thing on github in an hour or two, maybe some other people are willing to contribute. Because I think the current #bot-commands bot sucks so we need our own
I was taught to not use wildcards for imports
intellij did that automatically
i think the default threshold is 3
if you use more than 3 imports of a package, it uses the wildcard
Personally the first thing that came to my mind for trivia is queue
That the asked question can just be discarded
yeah but I might need to get the previous questions again, e.g. to show a summary at the end of each game or sth
I
AM
SO
SMART
There's not
Tho you can use some library like Configurate
I already just wrote my own deserialization stuff
it's really not much
not worth to change it now
๐ฉ
yeah not very smart lmao
is it still up? ๐
I changed the token 5 seconds later lol
I like light mode
Flashbang
dark mode is so depressing
but it's actually amazing
the same second in which I accidently commited my bot token
I got the discord message
I wonder how it works
discord on that grind
they cant possibly scan all public github commits every second
github can scan every repo in a few seconds when searching though so like, maybe
here's the whole code I've written so far, if anyone wants to contribute, feel free to do so :3 https://github.com/JEFF-Media-GbR/Discord-QuizBot
Might only check your account's linked GitHub?
yeah that sounds more reasonable
Was just about to say, you have GH linked
your token is still in the config
Its a useless token now I assume
anyone have an ide to run a for loop but not at the same time?
wdym?
You want to run a for loop but not at the same time? I dont understand
The IDE isnt gonna change whatever problem you might be facing
Ohhh maybe
yes?
Use it?
im using it
the current code is pretty bad
i know...
You're using runTaskTimer
you spawn a new repeating task everytime a creeper explodes
Not runTaskLater
so @wispy bridge that won't help
if 1000 creppers explode, there will be 1000 repeating tasks
then how could i do it?
what exactly are you trying to do?
when a creeper explodes i want to replace the blocks that it exploded but not replace the blocks instantly like 1 block 1 sec
There are 20 ticks per second so multiply that by the index of the block you're looping for the tick offset
but also
your code is still bad because
you only set back the material
you want instead to set back the blockdata
what?
otherwise stuff like signs will have the wrong orientation etc
yeah
you can't clear a block's getDrops list
it's just a "general" method to get the "usual" drops
I think it's even an immutable list
then how do i delete the drops?
You could just cancel the event couldnt you?
Then remove the blocks or set them to air yourself
setYield to 0
Oh I didnt know that was a thing
it's in the explodeevent
e.g. 1 will make every exploded block drop itself
0.5 only 50%
This is help, you are currently being helped
we won't code all the stuff for you
we told you what to do
i didn't ask for it
now it's your task to turn our suggestions into code
to prevent drops from explosions: setYield to 0 in your event
and do NOT use a taskTimer, but runTaskLater
because you only want to restore the blocks once
not unlimited times
does any of you used java.nio classes here before
if so, is there any difference besides architecture to use AsynchronousFileChannel and async OutputFileWriter
and it deletes the dropped items?
Setting the yield to 0 means that no items will drop from the explosion
@deft forum you want to do this, right?
YES!
What a flex
yeah okay so you COULD spawn one runTaskTimer for every block
like I did here, like this:
@EventHandler
public void onExplode(EntityExplodeEvent event) {
event.setYield(0);
long delay = 60;
for(Block block : event.blockList()) {
BlockData data = block.getBlockData().clone();
Bukkit.getScheduler().runTaskLater(this, () -> {
block.setBlockData(data);
},delay);
delay+=5;
}
}
but
BUT
this is very bad
you will end up with a ton of delayed task
that's not what you should do
you should instead schedule ONE repeating timer
you should create a new Map<Block,BlockData>
then run your repeating task and always replace one block with its former blockdata at a time
I think the tasks get cancelled by the scheduler if its a run task later, I dont think they hang in the server?
and once you're done iterating through it, cancel your task
anyway imagine 1000 blocks explode at once
you will now have 1000 delayed tasks
of course, they will all be gone once all blocks were replaced
yea one timer is way better
but you could do the same thing with just one repeating task
Yeahhhh thats true but if its just a creeper explosion I think the performance is negligible
inside the code
yeah sure but imagine you have like 100 players
and they all raid some dungeons or whatever
it probably doesn't matter much but since it's also a tiny bit of work, I'd go for one task fro mthe beginning
Thats fair, I just think for a beginner it might be better to think small first, I dont know how much more complicated that might be for them
The single repeating task is much better in general yes
actually why do u use block.getBlockData().clone()
what does clone "do" here? it should do the same if you don't use .clone()
Clone returns a new instance which contains all of the information of the first but does not modify the original
Nio seems great for me
I dont know if getBlockData() returns a mutable copy
it's a clone
I just wrote a way without one runnable because I was bored
private static class OriginalBlock {
private Location loc;
private BlockData data;
public OriginalBlock(Block block) {
this.loc = block.getLocation();
this.data = block.getBlockData();
}
public void restore() {
loc.getBlock().setBlockData(data);
}
}
@EventHandler
public void onExplode(EntityExplodeEvent event) {
event.setYield(0);
List<OriginalBlock> originalBlocks = new ArrayList<>();
event.blockList().forEach(block -> originalBlocks.add(new OriginalBlock(block)));
new BukkitRunnable() {
int current = 0;
@Override
public void run() {
originalBlocks.get(current++).restore();
if(current >= originalBlocks.size()) cancel();
}
}.runTaskTimer(this,40,2);
}
you'll still have a bad time destroying stuff like signs, containers, etc
they will be empty
why i use getBlockData and setBlockData
use materials instead and see for yourself
hint: signs have orientation, chests have orientations, torches have orientations, blocks can be waterlogged or not, candles can have different amounts and can be lit or unlit, etc
3 red lit candles and 1 unlit red candle both are Material.RED_CANDLE
that's why you should use BlockData instead of material
i know and?
I don't get your question
I literally sent you the fully working finished code that preserves everything except for stuff like block inventories
i use getBlockData and setBlockData it should set the items in a chest etc?
no
BlockState != BlockData
so i should set blockstate too right?
and really there isn't
you have to manually check if something is getState() instanceof Container, then save the inventory and set it back afterwards
fhuuu
you can easily expand my custom class that I provided
private static class OriginalBlock {
private Location loc;
private BlockData data;
private ItemStack[] inventory;
public OriginalBlock(Block block) {
this.loc = block.getLocation();
this.data = block.getBlockData();
if(block.getState() instanceof Container) {
this.inventory = ((Container)block.getState()).getInventory().getContents();
}
}
public void restore() {
loc.getBlock().setBlockData(data);
if(inventory != null) {
((Container)loc.getBlock().getState()).getInventory().setContents(inventory);
}
}
}
no idea why I'm spoonfeeding so much today
I haven't tested this though
it may be possible that you still have to somehow prevent the chest from dropping their contents and/or also create a clone of all the chest contents
but you get the idea
@EventHandler
public void mysticWellClick(PlayerInteractEvent e) {
Player p = e.getPlayer();
if (e.getClickedBlock().equals(Material.END_PORTAL_FRAME)) {
if (e.getAction().equals(ClickType.RIGHT)) { // 176, 263.337
if (e.getClickedBlock().getLocation().getBlockX() == 188.462) {
if (e.getClickedBlock().getLocation().getBlockY() == 176) {
if (e.getClickedBlock().getLocation().getBlockZ() == 263.337) {
p.sendMessage(ChatColor.RED + "[???] This currently isn't ready at the moment...");
}
}
}
}
}
}
Apparently this doesn't work? So i was wondering since this doesn't work how can i get the location of a block?
hm ok,
I delete a file in my plugin, but i get a FileNotFoundFoundException, although it is deleted. I run that task asynchronously.
So then how can i go about getting the location of the given block?
wait nvm i think i got it
well, the file obviously didnt exist then
Its there
anyone free to check out #942934911432687656?
if it is there, you wouldnt get a FileNotFoundException
First it's there. The it is deleted and i suddenly get a FileNotFoundException
So you delete a file and then you wonder why it's not there anymore?
I only delete it one time
Its a class i coded
obviously...
How Can I chance minecraft:iron_sword to mynamespace:emerald_sword?
?
what is "minecraft:iron_sword"?
a string?
a namespacedkey?
I'm fairly certain that cannot be changed
oh, but I guess, I saw this before
Where
it could be changed but im not quite sure how but i think, you need to fiddle with NMS ItemRegistry to edit the namespace
i've saw this in action before too, but i dont remember where
but I don't recommend that
I would instead suggest listening to tab complete packet (that would only work for tab completion, but you can always listen for chat related event)
and change it through there
ok, thx
Huh? Why would there be a packet or event for sending the ItemStack's description GUI thing
i'm talking about serverside command namespaces
you cant change namespaces for clients
Yeah that's what he's asking though
well you cant then
I see what you're saying too though, adding a custom namespace into the commands. Definitely possible to do that
Just can't change what it displays 
you can't change that
it's hidden by default
you only see it because you have advanded tooltips enabled
F3 + H changes whether the client shows it
and no, you cannot prevent players from enabling those
oh! ๐
F3+H
Hello guys, I'm using packets to appear a block in the world, but the block that appears when it breaks does not drop any items and the sound of breaking is stone, but the block is dirt, could anyone help me? I'm using this code:
WrappedBlockData loke = WrappedBlockData.createData(targetBlock.getType());
pacote.getBlockData().write(0, loke);```
well of course it won't drop anything - the block doesn't actually exist
also the API already has a method to send fake blocks, there is no need at all to use weird packets for that
player.sendBlockChange
And how do I make it really exist? Can you help me? It's a very specific situation.
block.setType()?
hey anyone here happen to have tried to spawn minecarts on tracks before?
do you know if they automatically go on the tracks correctly or does that require some dark magic
I'm new to java 17 switch statements. is it correct that I don't need break; after the first case?
dont you have to work on thr track object then?
if it doesn't break it keeps running
to the next case
You don't need breaks for enhanced
that's true for the regular switch / case, but this is enhanced switch case
thx
You can also straight up return the switch statement I think alex
thx
what's enhanced about them?
They r nice
ah yeah thanks
Say that website's name challenge
what happens when you return an enhanced switch and it has no default case and no label matches?
returns null?
idk but it's also explained in the article above
man
iight
that's a lot of tech the switches got huh
It won't let you do that
ey what is yield
wonder if intellij will still yell at you for putting several cases on the same line
it really hates it when you put several things on the same line
that and sonarlint
ah
Error:(11, 26) java: the switch expression does not cover all possible input values
does anyone even uses if (Collection#contains) { Collection#get } instead of ``if (Collection#get != null) { Collection#get
}` ?
yes
Collection::get?
well in case of a map, i most of the time store the variable and nullcheck it instead of calculating it twice
idk if someone understands me
i was thinking if i call get twice or a contains then it basically does extra calculation instead of just storing it and null check it right?
yes
if i just do object o = map.get; if (o != null) // bla bla bla then isnt it faster than calling contains?
I mean, one call is better than two calls; so yeah
i guess
I wouldn't worry about what's faster
unless this is really a bottleneck
premature optimization is always a waste of time
I wonder how people make plugins like Jython
Plugins that lets you code in a different language than Java
does anyone know how it's done?
some other language interpreter?
And another question: Why is there an error? That's the script: https://imgur.com/a/tYIn5dQ
Read the error and it'll tell you
yeah
it doesnt expect a command class instance
Yup and what does that error mean?
ok, and this is ...?
?learnjava moment
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.
it tells you to cast your first parameter to a Plugin, because you provided something other than it expected
it tells you that it needs a plugin
ok, thx
works with me
How are these made?
is that create the folder if not exist?
?notworking
"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.
it should download jar from github to update folder in plugins dir
but it download jar file in plugins dir
Anybody know what triggers intellij to mark my .get as a 'suspicious call'?
at least one case is when you are working with maps and try to compare values that they can not have
or something to that end
what ive got is a ArrayList<HashSet<Faction,Faction>>.contains(Set.of(faction a, faction b))
maybe because i havent written anything to add any sets to the list
@tardy delta help pls
ok now burn it with fire
and start again with something that makes more sense
do it quick, do it twice
either do it good or dont
intellij probably detected that your statement will never result in something valid
good now delete it all and make a proper class
i would
you will
uhh. dentist appointment gtg
hope your dentist isn't in as much of a rush to take care of your teeth as you are to make server software
shit me too LOL
but in reality i was just doing this to test something i was gonna do
i will end up making a proper class and such
cue the dentist showing up with a chainsaw and a pair of aligator clips and saying "yeah I know it's not ideal but i'm in a rush, I have to take my car to the garage in a minute"
then, at the garage...
welds wheel to axle cause mechanic was in a rush to get home
don't blame him, he's in a rush to get home because the electrician is coming by in a minute
just wait till you see what that dude is in a rush for
๐คฃ
Anyone can help me?
does it do anyhting?
Mechanic welds differential because he needed to scoot home in a hurry
you just have the wrong directory
it should download jar from github to update folder in plugins dir
but it download jar file in plugins dir
electrician superglues the electrical panel on because he's in a rush to go have his house treated by pest control
Hey there,
I'm trying to spawn a hologram for a single player using NMS 1.18.1, and the problem starts from DataWatcher section which is required for entity meta data packet.
When it comes to setting 0x20 byte (which makes the entity invisible), it requires a packetdataserializer object. I have no idea where to get that from. I would appreciate any help and please if you don't have enough knowledge about this, do not reply.
https://cdn.discordapp.com/attachments/902581431019135030/943202795127975996/unknown.png
pest control burns the house down cause they were in a rush to get called to the witness stand in a death penalty trial of an innocent man
the jury becomes an impromptu firing squad without a trial because the judge is in a rush to get home to play Minecraft, he heard @olive lance is about to drop a hot plugin
yessirski
see what you did
good, I hope you learned something
Hi, How are permission files with ranks formed?
sounds like you need to go to #help-server
Why, it's for a plugin
xD
No
then we might benefit from some more information
What?
I am creating a rank plugin and I want to assign permissions to each ranks
well it sounds like its completely up to you how those are formed no?
The plugin with the ranks?
well it depends, do you have a permission plugin?
No
do you use the plugin Vault?
It can be useful ?
well its an api for permission, economy, chat based to plugins to easily communicate together
id advice to use a permission plugin tbh
is the onTabComplete method fired in spigot when typing command in console, so can the sender be a CommandSender and not a Player?
Yes
Ah well !
why does it get fired when it isnt useful?
like you cant see any completion options in console
which option will be better for auto update?
- Overwrite in plugins folder
- download plugin in update folder
https://paste.ee/p/WTvRU I keep getting this error when tryign to launch my bungee cord server, anyone know how to fix
admins should always have 100% control over what .jars are running
you don't have a server listening on port 25567
also 0.0.0.0
makes no sense
you must specify a proper IP in your bungee config.yml
but
I am making a command so a busy admin can easily update my plugins
oh okay. use the update folder
overwriting a running .jar is a bad idea
but that need same name in plugins dir :/
where's the problem?
overwriting the current .jar also requires the same .jar name
if someone change plugin name, it wouldn't work
Hey so I am trying to work on a plugin where I have a command to relaod the plugins config.
Basically what I want to achieve:
When a player uses the "reloadConfig" command I want to initialize my PluginConfig object with the new values from the updated file. Right now when I am initializing the object again the written values get removed. How can I avoid that from happening?
That's how I create my Config Object:
public PluginConfig(MyPlugin plugin) {
this.plugin = plugin;
this.config = plugin.getConfig();
initConfig();
}
...
private void initConfig() {
this.config.addDefault("fadeTime", 20);
this.config.addDefault("testValue", false);
config.options().copyDefaults(true);
plugin.saveConfig();
}
you never actually reload the yaml file, do you?
Inside my code nope, I am getting it directly though plugin.getConfig()
Does it reload the yaml file when calling plugin.getConfig() again?
plugin.reloadConfig()
Okay but does that work with this strcuture?
private FileConfiguration config;
private final MyPlugin plugin;
public PluginConfig(MyPlugin plugin) {
this.plugin = plugin;
this.config = plugin.getConfig();
initConfig();
}
public void reloadConfig() {
plugin.reloadConfig();
}
Just asking because reloadConfig is not returning a new FileConfiguration. So do I need to update config in my class manually somehow or does that happen automaticly?
Or would I just need to call plugin.getConfig()afterwards again and init my config FileConfiguration with it?
?paste
just wanna slide in and give you a heads up, any variables you load into memory are also going to have to be reloaded
dunno what this is, just tried to build my jar
https://paste.md-5.net/icukitival.sql
updated my sdk to java 16
no, you misunderstood
JavaPlugin#getConfig() returns the already loaded config
if you want to reload your config, just use JavaPlugin#reloadConfig()
it's a method that already ecists
imagine this:
could i be shading with the wrong version of the shading plugin?
getConfig() -> returns your config
now change something in config.yml
getConfig() -> returns old config
reloadConfig() -> config reloaded
getConfig() -> now it returns your new config
show full erro rmessage
no no
on the left side, click the uppermost thing
then you get the full error message
anyone know what is the problem?
for what?
Ah okay so my last thought was right, thanks for your help :)
?notworking
"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.
https://paste.md-5.net/bugebiqoqa.sql
plugin version missing or what does it say
i wanna create an item stack but it says an err and the err is that i gave material type but it needs IMaterial
but it doesn' exist..
what
the is 2 item stacks
what
this is the build part in my pom:
https://paste.md-5.net/anikaceluv.xml
i've never noticed this
set maven-shade-plugin to 3.3.0-SNAPSHOT
show your full code
looks you imported the NMS ItemStack
instead of the bukkit one
also pls don't call your events "e"
liek this?
yes, you'll need the maven snapshot repo too I guess
one sec
add this to your pom
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>https://repository.apache.org/snapshots/</url>
</pluginRepository>
</pluginRepositories>
oh ye i saw the answer on stackoverflow too :D
and the 3.30-SNAPSHOT version?
doesnt seem to find it
ye that, i typed ir correctly in my pom
np ๐
pom shows an error but i can build plugin :C
meh
ItemMeta
does someone know: how can I schedule a delayed task in java (NOT using bukkit API) that I can also cancel at anytime?
java.util.Timer() allows me to schedule a task but it returns void so no idea on how I can cancel it before it executes
Java has runnables
and how can I schedule it to execute in lets say 20 seconds, but also being able to cancel it before the 20 seconds end?
thanks but that doesn't help me at all
I need something like this:
Task myTask = new Task(...);
myTask.runIn20Seconds();
.....
myTask.iChangedMyMindDontRunIt();
bukkit runnable delay?
NOT using bukkit API
oopsie
Create a class that extends TimerTask
Then get an instance of it and execute it with a Timer
why are you not using the api? whatre u doing lol
You can cancel it before it runs via TimerTask#cancel
discord bot
?
i seem to remember someone saying they would remove it
or somethjing
i have no idea about any discord related news
hmmm
thanks
Listen to him
what's the advantage / differences?
I never did any timer / tasks / stuff in plain java
https://pastebin.com/NvDdnyBv my plugin is giving this error. i dont know why
My code is here: https://pastebin.com/xBhL7m9m
i have code comments just to help me
Caused by: java.lang.NullPointerException
at com.clonkc.vlands.kitpvp.Utils.Rep.rep3(Rep.java:16) ~[?:?]
i know but i dont see why thats a problem
what's Rep line 16
what's Rep line 16
return ChatColor.translateAlternateColorCodes('&', string.replace(placeholder, replace));
placeholder is null
Something there is null
or replace is null
getFireballTotalDamageMessage() is null ;p
Or string
or string is null
hmm ill check that
That being said, the description message would have been far more informative had you been using modern Java and modern game version
You're on a 6 year old version
yea ik
Woo new NPEs
well its a lot more sophisticated and configurable
ok so i fixed it, but e.getDamager() sends a message to the fireball and not to the player who lanuched the fireball
how do i get that player
using entitydamagebyentityevent
Actually you probably have to cast e.getDamager too
what would be the eaziest way to store chunks into a file and then eazily load it?
ok so i cant use e.getDamager().getShooter() because the listener is for the explosion not the fireball throw
does anyone know if bungee has some type of "resend commands" function like bukkit does? bukkit has updateCommands() but I don't see anything like that on bungee
lol i always refreshed the commandmap manually
thanks
anyone know how to access my main file from other files?
Yes
main files properties and like getConfig() and things like that?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
just tested my plugin and all the commands are giving errors ._.
-.- its bad a deal
What is a bad deal?
is 'name' a reserved keyword in mysql or something?
Hey everyone, I have a problem with the PermissionEx plugin, can someone help me?
sry
Yes
so i cant use it in a table ._. lets try
Backticks exist
ugh any idea why I can't print umlauts with my plain java app?
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
@Override
public void onMessageReceived(@NotNull MessageReceivedEvent event) {
System.out.println("รผ");
Your terminal does not support umlauts
Thats because your terminal doesnt support them
it does
As evidently seen in your device name
it works fine using spigot
Spigot has its own stdout
It could be possible that the terminal is using another encoding
does anyone used java.nio package before here
i am pretty sure that my terminal supports umlauts
then why does echo รถรครผร work
Probably because it is another encoding
anyone can help me to access my Main file from outside my main class?
i mean access getConfig() and things like that
รถรครผร and co are all non-ascii chars
JavaPlugin.getPlugin(YourPlugin.class);
I. e. what happens if you use the umlaut value according to codepage 437?
it works fine using utf8 with cat, echo, ...
Yeah, this is interesting
I know that windows acts a bit strange, but this is git bash after all so everything could be at fault here
yeah but as I said - if I get a message from discord that's only "รผ" and I compare it using message.getContentRaw().equals("รผ") it also returns false
seems like something's wrong with my .jar
Perhaps java uses a seperate encoding?
I#ve set maven to use utf8 :/
What happens if you use JDK 18, it should use UTF-8 by default, but eh
Yeah, mysterious
I only have jdk 17 installed
man this makes no sense
JavaPlugin jv = JavaPlugin.getPlugin(Main.class);
jv.
it shows nothing when i type jv.
you're doing this outside a code block
Yes
occasionally
?main
If it were to be encoded in codepage Codepage 437 it would mean that the umlauts are probably in the range of 0xB1 - 0xB3 which would not make much sense if it was utf8 unicode
heh nice my database isnt saving users
I used to very often, but now not that often
very.. pointless arguments
its still doesn't make any sense
Generics
dependency injection please
Main must extend JavaPlugin though
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
m.```
The only thing i agree with is class name should be descriptive
Well, depending on the circumstances, JavaPlugin#getPlugin is the better solution
But seriously, the arguments are nothing
ยฏ_(ใ)_/ยฏ
I donโt know why your IDE isnโt showing you the methods you want
Does it compile?
Are you sure you are importing the right class?
yes
Because with such a name there is an extreme danger that you are importing sun internals
imports:
package me.andris.warppl.commands;
import me.andris.warppl.Main;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
my main is in me.andris.warppl.Main
rename your class so it's not called main please
and it extends org/bukkit/plugin/java/JavaPlugin?
I mean, as long as a package name is set, it isn't too dangerous
Sure, it can lead to many issues, but as long as you know what you are doing it won't create too large issues
notepad
Become a student. Then get the Jetbrains student license and use all their tools including CLion.
Eclipse CDT
It is remarkably good as long as you are willing to ditch windows
you can get Clion for free right?
i cant ditch windows
Id rather use word 2003
Eclipse destroyed many projects before I switched to IntelliJ ๐ค
I'm talking about eclipse CDT here, it is good way to learn cpp
Oh, sorry ๐
Eclipse CPP works fine on windows
On windows it also works but it is less plug-and-play as you have to install MinGW and whatnot
Itโs not that big of a hassle
what do i install
(sure, on linux you have to install GCC, but you are likely to have it preinstalled beforehand)
MinGW is a must for CPP dev on windows
Eclipse for CPP
i dont even have gcc i think
I think you can compile from CLI via gcc when you have MinGW installed
not necessarily good but VS is always an option if ur on windows
u just make a new project pretty sure
theres no option for that
only new folder
actually not even new folder, "open folder"
and new file
You are probably using vs code
yeah actually none of those arguments is really good
vscode is vs?
Vscode is meant for general use, vs is more c/cpp/c# (I think?) centric
Have you installed the C++ toolkit for VS?
Then you should be able to make a new project
I suspect youโre getting lost in the IDE because youโre not familiar with it
You may want to Google how
Keep googling lol
Are you using visual studio or visual studio code?
Can you send a screenshot of your vs
vscode
Then you should search for vscode, those are two different IDEs
virtual studio code is what im using
so do i use visual studio code or visual studio
visual studio is that absolute chonker of an IDE from windows
like im talkin a fuckin hefty, clunky monolith
enough to fill an entire harddrive thicc
And it is prone to failure from what I heard
all the time
Visual studio will install most of the c++ tools for you
but i dont know anything better for .NET on winblows
and i kinda barely write C or Cpp, when i do i use vsc lol
But it is a pretty good one from when I looked at it
Personally Iโve never had an issue with visual studio but Iโm on the enterprise license