#development
1 messages · Page 112 of 1
can those packets be prevented, like with the use of plib?
an anticheat but instead of banning you just lags out your game with a bunch of particles
or just chunk bans you
yes
you can create a counter
btw do u mean sharpness particles?
assuming this is 1.18 (or recent), u can do something like this: ```java
// im typing this in discord so i dont think this is 100% correct
private final Map<UUID, Integer> particles = new HashMap<>();
private final int LIMIT = 10; // particles sent per tick
// particle listener
ProtocolLibrary.getProtocolManager().addPacketListener(
new PacketAdapter(PacketType.Play.Server.WORLD_PARTICLES) {
@Override
public void onPacketSending(PacketEvent event) {
onSend(event);
}
}
)
private void onSend(PacketEvent event) {
final PacketContainer packet = event.getPacket();
final Player player = event.getPlayer();
if (packet.getNewParticles().read(0).getParticle() != Particle.DAMAGE_INDICATOR) { // I think that's what the particle is? if this doesn't work, try printing out the particle
return;
}
final int originalAmount = packet.getIntegers().read(0);
final int storedAmount = particles.getOrDefault(player.getUniqueId(), 0); // particles already sent
if (storedAmount >= LIMIT) {
return;
}
final int amountLeft = LIMIT - storedAmount; // amount of particles left that can be sent this tick
final int amount = Math.min(amountLeft, packet.getIntegers().read(0)); // amount of particles to send, limiting it to amountLeft
if (amount <= 0) { // no particles
event.setCancelled(true); // no point in sending a particle packet if there are none
return;
}
Bukkit.getScheduler().runTask(plugin, () -> {
final int current = particles.getOrDefault(player.getUniqueId());
particles.put(player.getUniqueId(), current - amount);
}); // put the counter down next tick
if (amount == originalAmount) {
return; // nothing to change
}
event.getIntegers().write(0, amount); // set the new particle amount
}
how does one host a discord bot for free?
i know there's ways but i have no clue how to do it
Discord bot in what language?
Java
Have you ever used Linux terminal?
i have not
i was following a tutorial for the oracle hosting but when i got to uploading SSH keys i didn't know what to do
i don't have any of those
I had problems with it
like the server works and all
but it seemed like certains ports are blocked
what's the real way to get player ip on join?
with this i meant minecraft ports 
PlayerLoginEvent#getAddress().getHostName()
PlayerLoginEvent#getRealAddress().getHostName()
PlayerLoginEvent#getHostName()?
i am a beginner at java so whats override and subclass i tried searching it up but google gave me answer i didnt understand
a subclass is a class which extends another class, which gives the subclass the same methods and variables as the super class (not private or package private ones)
then you also get some other cool properties such as that an instance of your subclass can be assumed as just the type of the super class
thus something like:
Superclass variable = new Subclass();
is possible
Hey guys where can i find nbt data for items in a players inventory?
also whats override?
Anybody know where nbt item data is stored?
In regards to overriding...
class IAmTheSuperClass {
void printTen() {
print(10);
}
}
class Sub extends IAmTheSuperClass {
@Override printTen() {
print(11);
}
}
class Main{
public static void main(String... args) {
new Sub().printTen() //would print 11
new IAmTheSuperClass().printTen() //would print 10
}
}```
@graceful hedge u seem to know what you're doing. Where is nbt item data stored?
Stompyblue
mainlevel/playerdata/uuid.dat
Will i find it in the server files?
Ah ok. Im still kind of struggling kinking my plugin to files on the server. How would i do that?
wym
Im using nitropanel. Its got all the folders as shown there, but i dont know how to access those folders on the server using my plugin?
How can i access server files using my plugin?
Meaning like rewriting the nbt data of an item in a players inventory.
1 please stop pinging me in every reply of yours
2 get the primary world by Bukkit.getWorlds().get(0)
3 get the folder of that world
Oh sry i forgot to turn ping off rly sry.
4 locate the playerdata folder
Ah ok. I'll try that.
if you shift click reply, it wont turn on ping by default
Ah ok.
does it work?
🩴
👲
📂
📕
a lot of people got their vps randomly terminated
so
🙃
🟪
🟥
⏱️
lol
Every time I start my waterfall plugin, these messages are printed in red because I think waterfall/bungeecord doesn't like having other loggers being used
[19:17:09 ERROR]: [main] INFO com.github.secretx33.dependencies.friends.hikari.HikariDataSource - HikariPool-1 - Starting...
[19:17:09 ERROR]: [main] INFO com.github.secretx33.dependencies.friends.hikari.HikariDataSource - HikariPool-1 - Start completed.```
Logger used
```kt
runtimeOnly("org.slf4j:slf4j-simple:1.7.32")```
But I just put it there because otherwise Hikari prints a huge complain about operating in "no-op" mode or whatever. Is there a way to make Hikari use Waterfall default logger, and if so, how can I do that?
Ive tried something along those lines and its kinda working now. Tysm.
pog
use logback and in logback.xml located in resources folder put:
<configuration>
<logger name="com.zaxxer.hikari.pool.PoolBase" level="ERROR"/>
<logger name="com.zaxxer.hikari.pool.HikariPool" level="ERROR"/>
<logger name="com.zaxxer.hikari.HikariDataSource" level="ERROR"/>
</configuration>
is IntelliJ Idea Ultimate just a premium version of IntelliJ?
yes, with more features
Will I be okay with the community edition as a beginner
yes
okee dokie thanks!
yeah you must use it
yeah i don't plan on paying for anything yet until it's something i really wanna do
nono the community version is ok
i think that nobody is paying for ij ultimate here lol
santa mitten
lol
but yea i dont need it
is eclipse = intellij?
they both do the same thing right
i thought it was like eclipse = intellij and maven = gradle
i mean
but the new better thins to use are ij and grdl
IDE stands for..?
integrated development environment
gotcha
i'm gonna try some java courses
been trying to learn and keep getting stuck absolutely lost
yeah and also we should move to #dev-general because otherwise some support nerd is going to kick our asses
oh yea lol woops
So i am coding this ticket bot and i want to make like a transcript when someone closes the ticket. So i have all the messages in that ticket stored, where should i put them, in like a file? or in like a pastebin?
#carl #yag #DoWeReallyNeedAnyMore 😂
What does the error
Class 'MyFirstPlugin' is never used:5```
mean? This is my code:
```yaml
package com.magnummc.myfirstplugin;
import org.bukkit.plugin.java.JavaPlugin;
public final class MyFirstPlugin extends JavaPlugin {
@Override
public void onEnable() {
System.out.println("Hello, world!");
}
@Override
public void onDisable() {
System.out.println("Goodbye, world!");
}
}
Trying to learn my errors little at a time.
You can ignore that, it just means that you're never using that class
Later when you have multiple classes (👀) and when you use that class in another class (👀👀), you won't have that error anymore
If for example a listener (that would ex detect when a player joins) said Class 'JoinListener' is never used, that would not be very good
btw use ```java
// code here
```
also, does this main class name look right?
"com.magnummc.myfirstplugin.MyFirstPlugin"
it just means that you're never using that class
this doesn't mean that spigot isn't using it :)
yep
gradle 😋
i've got gradle and intellij installed
can you show me ur build.gradle?
and im using the mcdev plugin on intellij
ah
my only concern, does the plugin only support 1.15 because I see no higher.
in build.gradle, where you see 1.15.2 just change that to whatever version
this is how u build
then the jar will be in build/libs/ProjectName-Version-all.jar
if shadowJar isn't there, then go to build -> build instead
org.bukkit:bukkit:1.15.2-R0.1-SNAPSHOT
this is the only 1.15 i see in my build.gradle
is that right?
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
that doesn't include the spigot api tho
just use what it originally was - org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT i think
in place of the 1.15.2 part i sent?
actually i think it does
but
still
well
in place of org.bukkit:bukkit:1.15.2-R0.1-SNAPSHOT
thats what i meant but yea
You misspelled papermc*
i do not have the shadow folder
ye, use the build folder instead
then double click the build button in there
yep ive got the jar
inside build and whatnot
kaboom
if u want the same theme and stuff i have:
plugins:
.ignoreAtom Material IconsDiscord Integration(although i personally don't use it much now 🤡)Material Theme UI Lite(Or you don't need Lite if you're a student, you can email the author with proof)Minecraft Development(at least have it disabled, it still does things even when disabled.. lol such as plugin.yml checking)Rainbow Brackets( 🌈 )StatisticWakaTime(shows how much you're procastinating 😎)
settings:
- Editor -> Color Scheme -> Color Scheme Font -> Fira Code Medium (or any font that supports ligatures) and enable ligatures, makes everything look nice
- Appearance -> Theme: Atom One Dark (Material)
- Appearance -> Material Theme UI -> Settings -> Advanced Settings: Features -> Striped Tool Windows
|| jeez why do I have so much ||
jesus what is your wpm
🤣
thanks btw :)
oh gotcha
:))))
its still fast af
lol
so, i can only run the plugin ona server version identical to the one I made the code on right
so for example, only spigot 1.18
well
sort of
for now
just think of it like that
🙂
oh also
in plugin.yml
add ```yml
api-version: 1.18 # not 1.18.1
yeah, multiple versions has gotta b confusing
lmao thx for the edit
i just put 1.18.1
🥲
that means i need to rebuild right
since i didnt do that b4
would it be the same process as before?
yep!
also
with the power of gradle (and intellij)
u can build and copy the server and start the server in one click
:))
sounds kinda confusing ngl
intellij is IDE, not text editor 😉
yea
i mean as long as you have the basic idea it's fine 🙃
ill need another gpu
hello world is produced into the console right?
wait dont tell me
ill see soon
👀
actually thats probably bcuz my memory is limited
minecraft was turning on
IT WORKED
[22:33:41 INFO]: [PluginOne] Enabling PluginOne v1.0-SNAPSHOT
[22:33:41 INFO]: Hello, world!
YES
yea but 85s to finally load
lol woops
PoG
85?!?!
now u gotta make it do it on player join and leave
🙂
then build off ur plugin from there
maybe like a /hello command
yk
I'd like to make a greetings plugin
Something simple
seperate from essentials
but IDK how to setup playerjoinevents yet or anything like that
you'll learn soon 😉
thats exactly what it feels like
If I choose Paper for my plugin type will it be exactly the same thing I just have to change the snapshot thingey
https://paste.md-5.net/wicemegufu.js starting at line 194, not sure if there is a better way to do the enchant check for loops for vanilla and my custom ones.
what those for loops are for handling retroactive items, so if i decide to do my own handling of an enchant then i can remove vanilla enchants from said item, if i decide that i dont want to handle an enchantment anymore its vanilla version will be readded to the item, something i need to do later is check if said enchant is actually allowed to be vanilla, if not then dont.
i have completed what i think should be a simple player join/player leave plugin
the question is does it work
holy it worked :O
how do i setup a config file for my plugin?
all i can find are outdated videos that are not using intelliJ
(Mind blank noob question time)
What's the best way to check if a player is falling when they log in (using the PlayerJoinEvent) (spigotapi, not paper)
I tried player.getVelocity().getY() < 0 but it didn't work
Question, so im using mongo db and i have a collection with documents that have something like number: 1 and number: 2 and so fourth, how can i get the highest number?
I'm going to bed, so I'll just leave this here, but I'm curious as how to create a custom config file for my greeting plugin.
I'd like to make a config where the join/leave message would be edit-able through this config, but I'm just not sure where to start.
https://github.com/MrCow98/MilkyGreet This is the plugin I created if you'd like to look through the code.
Just looking for all the help possible! A short example config relative to what I'm doing would be nice, but a good ol' explanation works just fine.
(Please ping me, I'm asleep by the time this gets a response)
how do I get player's IP address? (1.16.5)
PlayerLoginEvent#getAddress().getHostName()
PlayerLoginEvent#getRealAddress().getHostName()
PlayerLoginEvent#getHostName()?
so many confusing methods
Probably get host name
Player.onground
Well I just need their IP as string.
Heyy, What is the easiest way to make a time"listener"? I want to run some methods once its 00:00 on the specified Timezone. aka when its a new day
bruh do you not even test it
How can you ask for help with something so simple and not even test it
Laziness
Odd excuse
Get current time, calculate how long it is until 00:00 and then run a timed task with delay
Is it any create way to make getWord#isChunkLoaded() use less resources or more precisely ways to use other methods to achieve same thing?
Is that method some use most buy fare inside my plugin (it almost 50% of the plugins resources). I thinking on cache not loaded location and after x time clear it do make it updated (but will add some extra delay).
gg on the join/leave! 😄
so, for the config, first you'll have to create the default config
So go to the resources folder (same place as plugin.yml) and create a config.yml file
That'll be the default config.yml that will be created
But spigot wont automatically detect that file, so we have to tell spigot to move that file over to plugins/YourPlugin/config.yml:
public void onEnable() {
saveDefaultConfig();
}
Now, let's say this is our config.yml: ```yml
startup-message: "Hello from my first plugin!"
stop-message: "Bye!!"
To get the data, we have to do this: ```java
getConfig().getString("startup-message");
```and to put it in a variable: ```java
String startupMessage = getConfig().getString("startup-message");
```and to print it out: ```java
System.out.println(startupMessage);
```(note that the variable isn't required, you could just do `System.out.println(getConfig().getString("startup-message"));`)
Same goes for the `stop-message`
If you had a number or something else besides a string in the config, ex ```yml
countdown: 10
damage: 5.5
enabled: true
```you could do ```java
getConfig().getInt("countdown");
getConfig().getDouble("damage");
getConfig().getBoolean("enabled");
But what if the user changes the file? We'd have to reload the config to check for the new data ```java
// reload command
reloadConfig(); // updates the config to the new data
sender.sendMessage(ChatColor.GREEN + "Successfully reloaded!"); // being friendly :)
A couple suggestions: move the events package to com.magnummc.milkygreet.events and rename the listeners to PlayerJoinListener and PlayerQuitListener 🤷
IDK if you read the src or not but I believe I did that
also intellij has git/github support ¯_(ツ)_/¯
in the github it showed as separate
so
I don’t have listener in their name but the events package is in the groupid thingy
wadk
package :))
i was having trouble sharing it last night
and i was really tired so i did what i could quickly and passed out
IntelliJ
ah nice
VSC > Share to github
oh neat
i think its ctrl k
but you said the repo was messed up or somethint?
whats not there that should b
so i can fix it
https://github.com/MrCow98/MilkyGreet/tree/master/src/main/java
well atm the events package isn't in with the others
so u can just drag the events package to the main package
then commit and push
i thought i was supposed to put it with my com
com.magnummc.milkygreet is where everything should be (to keep it separate from other plugins and stuff), so the events package should also be in there, making it com.magnummc.milkygreet.events instead
yeah,alright.
i’ll test out the config creating when i can
hurt my eye from two nights in a row on the computer
for quite some time
I made a little function for generating a random number in a set range. It works fine for negative numbers, example: %Random:-10|10% can turn into -5. But if the result is positive the following will happen: %Random:-10|10% can turn into 5|5. It always happen for positive numbers and never for negative ones. Can some help me spot the error? https://paste.helpch.at/yowazasage.http
i see the problem
events was in the java package
mhm
do i need to rename them
because even if i should idk how to rename them
smh dkim
also, for the part where i'm getting the data, where exactly do I put that?
all g
you don't have to rename them: https://streamable.com/kc7ncc
is that written back in the main class or inthe config
you can just put it wherever you need the data
in my example, you would put that in onEnable since that's where you'd replace this: ```java
System.out.println("MilkyGreet has been enabled.");
so instead of the print i'd put
getConfig().getString("startup-message");```
if that's what i wanted to do
was a startup message
yes: ```java
System.out.println(getConfig().getString("startup-message"));
//
:) thanks
no worries
hmm
this will be tough
how do i insert the player name into the config
i know how i can get the actual players name but how do i write it into the config for that
join-message: "Welcome %player%"
quit-message: "Goodbye %player%"```
this doesn't look right.
i don't have a placeholder or anything
that looks good - but you'll have to replace %player% with the code
so
Let's say the join message is just Welcome ```java
player.sendMessage(getConfig().getString("join-message"));
But if it's `Welcome %player%`, the player will also see `Welcome %player%`
So we'll have to replace `%player%` with the player's name: ```java
player.sendMessage(getConfig().getString("join-message").replace("%player%", player.getName()));

so i'm just a bit confused, where exactly would i be writing that in? is it in my main class or am i making a new class orr
sorry.
hmm, well if you want this in the join listener, then you can't just do getConfig()
well where would you have put it
the join listener is the only place you can put it, you'll have to use something called Dependency Injection (DI) to be able to call the getConfig() method from another class
it's a bit confusing at first since iirc you're new to java, but if you want I can try explaining it
but in the end you'd be able to do ```java
plugin.getConfig() // plugin is a variable of the main class, getConfig() is a method in the main class
well i mean if its my only option to making this work then ig i have to know
Does anybody know if adventure has a way to get all sounds available for the current mc version?
i remember when the term dependency injection scared the hell out of me when i was semi new, only to learn I’d been doing it naturally anyways and it felt like common sense after working with it.
seems like DI is my only option if i want to go thru with changing the messages in the config so
It doesn’t really live up to its name in complexity, once you’ve done it youll realize it’s just sort of the practice of passing parent variables in to bring necessary information
https://paste.helpch.at/yijawupoju.java <- Example
Dependency Injection is a way of providing objects with the objects they need ("dependencies"). This is usually done with a constructor, but can also be done for individual methods
(HelpChat's explanation, but imo if you don't have the basic idea of objects and constructors, it's difficult to understand 🤷)
Remember:
- Methods are functions that are "blocks" of code that can be executed, and they can also have parameters that pass data
lmk if you want extra info on methods, since below I talk about constructors and stuff which is a special type of method - Variables hold data, and there are two types of variables: local variables and fields, fields which belong to a class and local variables which belong to a method
A constructor is a "method" used when creating a new instance/object of a class
For example, when you do java getServer().getPluginManager().registerEvents(new PlayerQuit(), this); you're creating a new instance of PlayerQuit, and since all methods have () (for parameters), and a constructor is a method ("behind the scenes"), that's why when you do new PlayerQuit(), there are parenthesis
And to make constructors even easier to identify, you always have to have new in front of it (since you're creating a new instance of the class)
With objects/instances, you can also store them in a variable: ```java
PlayerQuit playerQuit = new PlayerQuit();
getServer().getPluginManager().registerEvents(playerQuit, this);
But what's the point of the constructor?
It can be used to:
- run code when the instance is created (since remember - it's a method)
- give the class extra data (which is what we're trying to do - we're trying to give the join listener our plugin instance to get the config) - because methods can have parameters
So to create a constructor: ```java
public class JoinListener {
public JoinListener() {
}
}
```this doesn't do anything since the parameters are empty and there is no code inside the {}
If we do this: java public class JoinListener { public JoinListener() { System.out.println("Created JoinListener instance!"); } } now, whenever we do new JoinListener(), it'll print out Created JoinListener instance!
But we need the plugin instance to be able to do getConfig(), so we pass it through a parameter and create a variable/field: java public class JoinListener { private final MilkyGreet plugin; // final just means the variable can't be changed public JoinListener(MilkyGreet plugin) { this.plugin = plugin; // this. just means that we're accessing a field instead of the parameter // If this. is confusing, then think of that as this: // pluginField = pluginParameter; } } then since we have a MilkyGreet instance, anywhere in JoinListener, we can use plugin: ```java
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
String message = plugin.getConfig().getString("join-message").replace("%player%", player.getName()); // get the config message and replace %player% with the player's name
player.sendMessage(message);
}
Now that the constructor has a `MilkyGreet` parameter, we need to fill that in in the main class: ```java
new PlayerJoin(this); // it's "this" because the class we're writing this in is MilkyGreet
Since you're pretty new to java, this might be confusing, so feel free to ask :))
alr 👍
|| end result: https://paste.helpch.at/riseziworo.java ||
so int, which stands for integer, is a variable?
or it isnt itself a variable but it stands for a variable?
yep, it's a variable
Variables store data, so since the int variable stores 5, 10, etc, it's a variable
Variable format: ```java
visibility type name = value;
public int variable = 5;
so should i create two new classes for the join and quit listeners
you already have them created
nope, you're current ones will work fine
can i have more than one event handler
yes
and what is the difference between
@EventHandler
void onPlayerJoin(PlayerJoinEvent e){
{```
and
```java
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e){
}```
what does the public do in this case
in this case, it doesn't matter, it can even be private
if there is no public or private (there's also protected but dw about that), it means that it's package private, meaning that only classes in the same package can access it
spigot does some cool magic called reflection so it can bypass it
so can i just leev it
cool
i'm not gonna lie, you explained it but i'm lost.
which part?
just where do i even start to begin creating it
all i'm trying to do riight now is setup the config, but in order to have the players name said when they join, we are doing all this fancy stuff
https://paste.helpch.at/riseziworo.java
This has all the code
getServer().getPluginManager().registerEvents(new PlayerQuit(this), this);
```this goes in the main class
the other stuff goes in the JoinListener class
and since a constructor is a type of method, it goes in the same place another method would go
i tried just going word for word and got a few errors
for example in the code you sent me you have only
public class JoinListener {
// code here
}```
but mine is
```java
public class PlayerJoin implements Listener {
// code
}```
if i remove implements listener i get errors
oooops
yea
add implements Listener
mb
all g
aswell as this
you put
getServer().getPluginManager().registerEvents(new PlayerJoin(this), this);```
but if i put that with two this' then i get errors
my original one only has the second this
new PlayerJoin(this)
```this is the constructor, so make sure you added the constructor with the parameter
or else it'll error
oh i havent done that
lemme go look at ur msg agin
aw i got no picture perms
it still shows error but theres an option to click this time
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/ to upload images/screenshots.
You can also use a screenshot service like gyazo or jinx and post those links here.
now im guessing you have new PlayerJoin() instead of new PlayerJoin(this)
show both classes
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
ah
well, now you have a constructor but without any parameters and stuff (I explain that later in the message, but just taking it step by step)
atm it'll print out Created PlayerJoin instance! whenever you create the instance - so in onEnable
😮
gg :)
i gotta learn how to read first then ill learn to code
sometimes i jus read to fast and blow ovr stuff
is the warning useless or should I do it other way
oh yeah 🤦♂️ thank you
hha np we've all been there
Very handy tip I use a LOT btw, if you do need to make a variable, append .var to the end and press enter
E.g. new WorldManager().var it'll create a variable you can type straight away
👍 thx
Tbh that could be just a static util method lol
Side effects in constructors 😵💫 😵 🤧 💀 😖
you're going to hell
Hi, how to get safe spawn location location of world? 🤔
and Bukkit#getWorlds#get(0) is always world in server.prop?
world#getHighestBlockAt() and then some checks for the block below this location making sure its not lava or whatever
if you want a random safe location then just do the check but with 2 randoms for x and z
@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
String message = plugin.getConfig().getString("join-message").replace("%player%", player.getName()); // get the config message and replace %player% with the player's name
player.sendMessage(message);
}``` what is this?
and where do i put it?
i dont see it in the code you sent to me so i'm just a little confused as to what it is
wait nvm im blind sorry for the ping
also, now that i have the config all setup, do i need to still have this?
e.setJoinMessage(ChatColor.GRAY + "[" + ChatColor.GREEN + "+" + ChatColor.GRAY + "] " + ChatColor.GOLD + ChatColor.BOLD + player.getDisplayName());```
if you want 🤷
if you have many color codes you could just use the chatcolor.translatecolorcodes thing
alright i think my code might be done :O
complete for now atleast ;p
what do you usually specify as your commit message
second commit? :P
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/ to upload images/screenshots.
You can also use a screenshot service like gyazo or jinx and post those links here.
technically
no
is this the code it shows for?
yea i believe so.
then add a null check for message before sending it
because if the join-message option was removed from config.yml, spigot will return null and when a player joins you'll get an NPE
ill look up what a null check is first and then if i cant figure it out i'll ask but i'll try and figure it out myself first
thanks :)
literally just:
if (message == null) {
return;
}```. you check if the message is null and if it is you exit. you could also do other stuff if its null depends on what you want to do
yes. I have words. I have the best words
that makes sense
it just checks if it's null and if it is then i assume exit means it shuts down the plugin?
no
return;. you just exit from that method
so you don't execute the code after which is player.sendMessage(message);
Anyone know of an API that gets news with certain key words?
this maybe? https://newsapi.org/
it has keyword or phrase searching
and a few other search types
or filters
whatever you want to call em
thanks mate.
im in error land
lol
apparently my "s" is an error
if you want help share code and errors
Using fabric & brigader,
Any clue why this command just isn't registered?
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
LiteralCommandNode<ServerCommandSource> dimensionHunterNode = CommandManager
.literal("testcommand")
.build();
LiteralCommandNode<ServerCommandSource> setNode = CommandManager
.literal("set")
.then(argument("player", EntityArgumentType.player()))
.executes(this::setCommand)
.build();
LiteralCommandNode<ServerCommandSource> removeNode = CommandManager
.literal("remove")
.then(argument("player", EntityArgumentType.player()))
.executes(this::removeCommand)
.build();
dispatcher.getRoot().addChild(dimensionHunterNode);
dimensionHunterNode.addChild(setNode);
dimensionHunterNode.addChild(removeNode);
});
I run it in my onInitialize
and it's just not there when I start the game
weird, looks like it's working now
all i did was switch the notes i made from "//" to "#" and it worked lol
^ for the config
YAML uses # for comments
damn i thought so
i didn't clarify earlier when i asked
so they probably assumed i was making notes on a java class
oops
i thought you were talking about java 🥲
you mean the testcommand?
also the other two cmds are wrong btw lol
LiteralCommandNode<ServerCommandSource> setNode = CommandManager
.literal("set")
.then(argument("player", EntityArgumentType.player()).executes(this::setCommand))
.build();
LiteralCommandNode<ServerCommandSource> removeNode = CommandManager
.literal("remove")
.then(argument("player", EntityArgumentType.player()).executes(this::removeCommand))
.build();
add/remove newlines as you like, but you're adding the execute to the set/remove nodes, not the player nodes
does that code run at all?
I mean i can't really help much with just that, that by itself will work
so err, like, try debugging, lol
fair
how does the reload command work? I'm able to put "reloadConfig();" but
sender.sendMessage(ChatColor.GREEN + "Successfully reloaded!");``` is red in several areas
do i need to do something special somewhere else?
show full code
nope, the callback isn't called
I'm in singleplayer, and this is the server entry, could that matter?
I assumed singleplayer ran it's own server
?paste
Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
• HelpChat Paste - How To Use
no, it goes where u want to reload the config
hm
so the command
Fred can you show any more code, and/or the fabric.mod.json?
Also any errors or something? either in the latest.log or you can keep the log thingy open from the launcher
in console I see nothing
here's the entire class https://paste.fredthedoggy.me/PDrHBO.java
A hastebin server for Fredthedoggy
okay
i'm just unsure where you put those lines since it's not like they can go into a config
and here's my mixin.json (the relevant part)
{
"environment": "server",
"entrypoints": {
"main": [
"me.fredthedoggy.dimensionhunter.Dimensionhunter"
]
}
...
}
yeah, why?
just asking. I know you mentioned it before. I need to set that up as well
there's no way to delete a paste bin right? after its saved
there is
you just go into the KV namespace
and delete it
in the CF workers dashboard
oh. ok. that's ocol
yeah. I saw this. you sent before
I Just didn't realise you have control over the paste bins
well. then I'm going to think about making my own soon
™️
just like last time
oh one more thing
what theme do you use for haste bin
is it custom?
where do i wanna reload the config lol? sorry for all these questions
also is it just me or does your side scroll not work? or whatever it is called
u can reload it in a reload command
so for ex /greet reload
yeah but where should i be putting the reloadConfig(); and other
in the command, dw about it for now
it's a hastebin fork
that I manually copied assets from
lol
this is user error. don't make super long lines 🙃
Btw emily, might it be because it's the server entrypoint?
and I'm in single player?
i don't know if environment server is exclusive to dedicated servers or if it includes the integrated server as well
so yeah it might be, lol
any clue how to make it work on the integrated one?
just use * for env
nice
now i'm getting two join messages, i get one which matches my config but i'm also getting the vanilla joined game message, how do i remove that?
was it hard to set up? doesn't look like there's a tutorial for how to use this. Oh wait I remember you sending me some links before. gonna try and look for them. maybe I'll do it tonight
show the code in your join event listener
it took lots of playing around. CF just released a new feature called pages functions though
so I'm gonna convert mine soon
and maybe make a one-click deploy version
i used to have this in it
e.setJoinMessage(ChatColor.GRAY + "[" + ChatColor.GREEN + "+" + ChatColor.GRAY + "] " + ChatColor.GOLD + ChatColor.BOLD + player.getDisplayName());```
but i removed it since it would post both that and my message that's in the config.
if i could somehow have that message right there listen to the config then it would be fixed
you're sending the message to the player that joined only
remove this player.sendMessage(message);
and add this:
@broken elbow it's rebuild & fixed 🙂
e.setJoinMessage(message);```
damn. it breaks very fast xD
nvm. its not broken. Its just slow af
when giving it quite a bit of text
to save this it took 16 seconds https://paste.fredthedoggy.me/kmXpJC.nginx
A hastebin server for Fredthedoggy
kek
okay, now i just need to add a null check, i know @ blitz you told me the things to type for a null check but this is my second plugin ever and idk where i'm supposed to put that code?
right before the line I sent
no
that's because I'm on the free plan
before. lol
ah
and the other part is guessing what language it is
Hmm. The thing is I have a dedicated server myself but I use it for other stuff. I wonder if I could get hastebin to just work on that instead. probably way better
probably
yeah. will add it to my inexistent todo list
I want to remove some characters from a string, and would like to avoid 2 replaceAll(). The characters I want to replace are every non word character \\W and the "word" @E. I tried something like [@E&&\\W] and @E&&[\\W] but don't really know how patterns work. Is it possible to do what I am after, and if so, how?
Avoid 2 of replaceAll*
oH
@E|\\W, you want to replace if it matches one or the other, a single match will never be both :d
@ Blitz im still getting that error, and now i get
"Condition 'message == null' is always 'false'"
Ahh, ok. Thank you!
hmm. I guess is it is bcz of .replace? it would throw an npe before you even check for it. try this https://paste.helpch.at/minusimoju.java
that worked thanks a ton
is it possible for me to make it so you can use color codes in the config and they'll format in-game?
btw if u dont want to type long ChatColor... everytime you can use color codes
create utils package
make ColorHelper (or smth like that) class
create static method in it
public static String translate(String uncolorized) {
return ChatColor.translateAlternateColorCodes('&', uncolorized)
}
Then you can use
e.setJoinMessage(ColorHelper.translate("&7[&a+&7] &6&l" + player.getDisplayName()));
so thats actually really similar to what i just asked
i'm no longer using what you replied to but can i make it so that when someone changes the config file to "&6Welcome" it'll actually turn gold?
will it be pretty similar to what you just sent? looks similar to an old forum thread i found
yes
player.sendMessage(ColorHelper.translate(config.getString("welcome-text"));
i'm sorry, but i still don't really know where things go, so where would i put a line of code like that? i'm just trying to learn still where each individual thing might go and how they're related
because like i have my main class, and then my two listener classes
i would have thought that would go in my listener class
Okay so
it should look like that
Paint 😌
yez
import class? is that okay to do
ye if you need to use something from other class you need to import the class
okay cool
do you understand the code on image?
btw your twitter reply scares me
whatttt
slowly i'm learning, it's a lot to soak in
I remember when I had same experience as you
its nice to see the progress xd
well if you ever needed to you could become an artist
that was an amazing artistic explenation

a lot of the stuff i read in the code is kinda just empty words to me but ive slowly started to understand it
well i wouldnt say understand yet
but memorize lmao
for example i'll probably keep making greeting plugins and perfecting them/making them faster/with no help until i understand every aspect of it
also, when i go to create a reload command for the plugin that needs a seperate class right?
usually you don't need separate class but you want it because of organization etc.
so yeah create new class 😄
okay imma try nd figure this out now
this caused some issues, now it sends two welcome messages, one message has color and the %player% placeholder is broken one message has no color and %player% placeholder is working
but idk how to include
message = message.replace("%player%", player.getName());```
into the
```java
player.sendMessage(ColorHelper.translate(message));```
can you show the entire code please?
https://paste.helpch.at/ekegusagul.java yea sorry
don't send the player.sendMessage anymore
that sends a message just to the player
all you have to do is set the join message
and translate the colors in the join message as well
Follow up, how do I make this pattern not remove - ?
like this?
e.setJoinMessage(ColorHelper.translate(message));```
Sry for the ping btw, forgot to turn them off
yes
you can just do what \W does
Wat?
Yeah, but how do I add that to the pattern?
@E|[^a-zA-Z0-9_-]
Ahh, I see. Thanks :))
yes.
I thought you had to do something like (@E|\W)&^-, like an if statement
I mean I'm not that good with regex so maybe that also works
btw instead of
if (message == null) {
return;
}
you can do
if (message == null) return;
Doesn't matter what you use just imo 2nd option is cleaner
for you everything that is shorter is cleaner...
nono
well no I reconsidered it
ok. good
and i didnt say its cleaner
let's go my plugin works and it has colors :O
I personally use brackets as much as I can. you might say its clean until you have 5 of them go 1 after another
just not so pain
now i just gotta make a commands thingy or however i even do that
if (something == somethingElse) Do Something Random;
if (abc = 2525525) Another wtf thing random;
if (!boolValue) KGLAJ54252;
ugly af
no do something random
how tf is that more readable/
i use it just for returning
then where's the consistency?
🤦♂️
you see, that's my problem rn. I can't keep just 1 style for the entire project. I don't have a style. and that is not good
🥴
thats part of the style 😏
it is what it is... I try my best but usually I start working on something then come back even weeks or months later
if (!player.getWorld().contains("tt")) return;
if (item.getItemMeta().getName().equals("hi")) return;
if (player.getName().equals("Notch")) return;
doSomething();
if (!player.getWorld().contains("tt")) {
return;
}
if (item.getItemMeta().getName().equals("hi")) {
return;
}
if (player.getName().equals("Notch")) {
return;
}
doSomething();
for me it is
🤷♂️
personal preference
Nah, small things are fine to be inlined
idk man. its not like the code changes but I just prefer brackets
and I still use inline stuff. especially since I'm a kotlin user so I usually just do ?: return bcz yeah
Skipping the braces is a bad idea
why
squabbling over 2 characters being missed 🙄
!!!
Also I guess you can say I've been indoctrinated into using brackets. bcz in highschool the final exam was on paper and some teachers are very very very very very very very very very very very very dumb and take away all your points for 1 missing bracket. bz the program wouldnt run if you were to put it in a compiler...
so u dont like it because of dumb teachers
why writing code on paper tho whats the point
what is an identifier
In terms of?
hm okay
thanks
where could i go to learn how to add a reload command to my plugin ive been searching on google for a bit and the newest piece of help i can find is a year old with the next in line being 3 years old. even with the 1 yr old one i can't seem to get it to work for myself
What all are you trying to reload?
my config file
Just use reloadConfig()? It's built in to JavaPlugin iirc.
someone already told me that but i've never touched java before idk where that goes
there's a million places i could put that and i don't know it
you make a command
you might want to read this https://www.spigotmc.org/wiki/spigot-plugin-development/
rn I have a bunch of kits, but I want to sort them by price, but if a kit is the same price as another, then sorted alphabetically (so that they're always in the same spot)
I have this: ```kt
classes.entries.sortedWith { o1, o2 ->
o1.key.compareTo(o2.key)
}
make your own sorter. ez
kek
classes.entries.sortedWith { o1, o2 ->
if (o1.value.points == o2.value.points) {
o1.key.compareTo(o2.key)
} else {
o1.value.points.compareTo(o2.value.points)
}
}```
😌
nah man. just make your own sorting algorithm
uhhhhhhh
I implemented like 4 or 5 different sorting algorithms today
you learn
but
butt
alrighty, i've read thru and was able to write
reloadConfig();```
my only question is how do i set my reload command?
no i was reading through creating a config file
you should probably go thru all of those at least once
maybe not the database ones
for now
fair enough, sorry for bothering. :) thanks for the info
all good.
All I have to do is make my placeholder extend PlaceholderExpansion, right?
If I wanna make my own
it's arguably ok if you're returning but it's still error-prone
it's more readable and maintainable
OMG. Santa actually agreeing with me? so I'm smart then
im talking only about returning
ended up successfully setting up my reload command (so i thought), and then when trying to run it i get this ->
https://paste.helpch.at/ejukiheban.bash
did you add the command to your plugin.yml?
yep
show the command and where you register it
and your plugin.yml please
any luck @ blitz?
args[0] is null
oh hi. I'm back
lol
yes as death realms said args[0] is null bcz the command itself is reload
not an argument
Hi again Blitz, quick, why does this [^a-zA-Z0-9_-\\:] not work?
might want to escape that -
Huh?
[^a-zA-Z0-9_\\-\\:]
well no. the regex is not really good you know bcz - is a keyword in regex
Ok, that makes sense lol
you see it thinks that the parts before - and after are a range
no problem
could replace a-zA-Z0-9_ with \w btw
that's what they had before but I hanged it kek
but yeah. It could be this @E|\W|[\-\:]
so them i dont need args
well usually I recommend you make your own command instead of having it be reload
i have it as milkygreet reload
so when you register it, register it as something like greetings or whatever
did i specify that wrong
i thought you cant put spaces in the Command part
this.getCommand("reload").setExecutor(new ReloadCommand()); when registering it here register it as milkygreet
you can't. but you will make reload be an argument
oh thatt part
bcz milkygreet:reload is basically pluginnname:command
i would have liked it to be /milkygreet reload
not :
i was wondering why it did that
yeah. it adds those automatically
you need to register the command to be milkygreet
same in plugin.yml
so for example when i do
commands:
reload:```
should i instead do
```java
commands:
milkygreet:```
and then also the public boolean onCommand()
reload will just be an argument to that command
yes
do i?
well yeah you have a check if args[0] == "reload"
i thought i put args[0]
yeah. args[0] doesn't return the command itself
hm okay
can my string label stay the same
well that will be whatever you register the command as
milkygreet
my if statement has an empty body
never happened before i did something wrong
show code please
well yes bcz you haven't added any code in there
i guess i am unaware of what to add in there, i'll keep searching online
well the reload
Is there a listener that listens to just entities killed by the player?
how do i properly null check the setExecutor method?
You could PlayerDeathEvent and Player#getLastDamageCause();
might just go back to this
although i will say, your executor should never be null and neither should the getCommand method
Not really what im looking for, i want the event to be fired when an entity like a cow is killed by a player
I can probably do EntityDeathEvent, but i dont see a way to get the reason why the entity was killed in the docs
EntityDeathEvent getEntity().getKiller()
alright thanks
so i have my local server running
but when i try to join localhost in the direct connect panel of mc
it doesn't let me join ):
"Connection refused: no further information"
same thing happens when i try localhost:25565, 0, 127.0.0.1, 127.0.0.1:25565
nothing is logged in the server console
?? any help
oh i didn't realize that was a reply to me. thanks! :)
it's for a reload command so i'm not sure if that changes anything, but if i don't fix that it gives warnings
if i ignore these will my plugin explode
https://imgur.com/a/Vfu5uLH
u dont need to fix the warnings technically. it will still compile
Can you send the code
yea np do you just want everything
Only the command
Okay ill lyk
now it's just told me it's an unknown command
check console for errors or something
nothing
changing to true doesn’t cause the command to not register
what command did you type
i think i found my mistake
this is my previous main class
https://paste.helpch.at/gayutitivi.java
under onEnable where the command is it's only milkygreet with no reload
but the command is milkygreet reload
remove the reload part from the plugin yml and also the main
ugh
you don’t need reload
well no because then the cmd is only milkygreet
instantiate the subclass command executor
arguments =/= command
the command is milkygreet
this should be new ReloadCommand()
reload is an argument
hm okay so
args are tuff
lemme go thru spigot and see if they have anything helpful and if not ill ask
not really it’s just a java concept
kinda wouldve expected to find atleast one forum relating to what i need but ig not
or im a shitty googler
always recommend learning and understanding basic java before going straight into plugins clueless

👍🏻
codecademy is free 
never known how to set them up though
i'll just go thru some basic java stuff first
what would it be called then if i want to make "reload" as an arguement
what might someone call that action
No, i am just saying that arguments are a very general concept, and its not like something you learn, if that makes sense. like program arguments, method arguments, command arguments, etc
And also i think what you are referring to is a literal
fun information about developers and asking for help with stuff
they're gonna give you the most vague answer you can imagine
enjoy 
yep
cause its a general term, so i cant give a proper definition lol
can be many contexts
much money
well they're talking about command arguments in this context
I'm having an issue with publishing my lib to jitpack using gradle with shadow plugin. I really don't know what's wrong with this, since I got it to work on past projects, but now for some reason it doesn't.
My goal is that people can use the repository as a shadowed lib on their projects, but for some reason, it doesn't build correctly, or it only builds the sources. Here's my build.gradle -> https://github.com/AleIV/Model-Tool/blob/1.17/build.gradle
man. why yall hating on jitpack?
Because it's literal ass
please explain
I can't think of a single person using it more than once that hasn't encountered an issue with it
Sometimes it just straight up doesn't work
Sometimes you have issues with the java version or with the Gradle version or with the whatever version or whatever
It don't work
@half gate for publishing shadow libs instead of doing from(components.java) do project.shadow.component(it)
i’m talking about method parameters in the context of minecraft. need to know java to understand method parameters and arrays if you want to use them for minecraft command implementations
me
😃
although i dont use it anymore
lol
ok. I guess I haven't used it that much. the few times I did, I had no issues tho
jitpack just isn't the best
Didn't you start using central because you had an issue with jitpack?
oh did i? 👀
lol

