29
How to start off.Good place to start of with: Plugin Tutorial
If you found this helpfull give it a diamond!
To allow Bukkit to load your plugin, you must create the plugin.yml file. This file will contain essential information, and without it your plugin will NOT work. This time we want to right click on src/main/resources. Select New > File. Name the file "plugin.yml" and click finish.
Now you have setup the project and the main class. To allow Bukkit to load your plugin, you must create the config.yml file. This file will contain essential information,This time we want to right click on src/main/resources. Select New > File. Name the file "config.yml" and click finish
If you found this helpfull give it a diamond!
Importing - click to reveal
To start of you have to import you .jar
1.downlaod the latest bukkit
2.right click on your project folder and goto properties
3.under Java Build Class go add External Jars
4.locate you bukkit.jar and add it
5.done!
1.downlaod the latest bukkit
2.right click on your project folder and goto properties
3.under Java Build Class go add External Jars
4.locate you bukkit.jar and add it
5.done!
How to make it a .jar - click to reveal
How to export:
1. Goto file, export
2. Save it as a jar the hit next
3. Select your resorce then hit Finish
4.Put it in your plugins folder and have fun coding!
1. Goto file, export
2. Save it as a jar the hit next
3. Select your resorce then hit Finish
4.Put it in your plugins folder and have fun coding!
plugin.yml - click to reveal
name: <plugin name>
main: me.<main package>.<main class>
version: <version>
description: <descrpition>
author: <your name>
permissions:
lobby.join.test:
description: <description>
main: me.<main package>.<main class>
version: <version>
description: <descrpition>
author: <your name>
permissions:
lobby.join.test:
description: <description>
config.yml - click to reveal
# Use: %player% for a players name
test: '&d[Join] %player% has joined'
test: '&d[Join] %player% has joined'
main class / code - click to reveal
package me.<your name>.<class>;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class Join extends JavaPlugin implements Listener {
public void onEnable() {
saveDefaultConfig();
//save config on startup/reload
}
@EventHandler
public void onJoin(PlayerJoinEvent event){
for (Player player: Bukkit.getServer().getOnlinePlayers()) {
if (player.hasPermission("lobby.join.test")) {
//check for player has permission
event.setJoinMessage(getConfig().getString("test").replace("&", "§").replace("%player%", player.getDisplayName()));
//set player join message by config
} else {
event.setJoinMessage("");
//if player has no permission set message to null
}
}
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
event.setQuitMessage("");
//set quit message to null
}
}
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class Join extends JavaPlugin implements Listener {
public void onEnable() {
saveDefaultConfig();
//save config on startup/reload
}
@EventHandler
public void onJoin(PlayerJoinEvent event){
for (Player player: Bukkit.getServer().getOnlinePlayers()) {
if (player.hasPermission("lobby.join.test")) {
//check for player has permission
event.setJoinMessage(getConfig().getString("test").replace("&", "§").replace("%player%", player.getDisplayName()));
//set player join message by config
} else {
event.setJoinMessage("");
//if player has no permission set message to null
}
}
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
event.setQuitMessage("");
//set quit message to null
}
}
Tags |
tools/tracking
2809382
6
bukkit-coding-how-to-code-a-custom-join-message
Create an account or sign in to comment.
The other way would be using the permission plugins API (if it has one) and getting the players prefix and adding it into the chat format.
Both work just as well, making a plugin less reliant on another plugin can be very useful if your making a public plugin as it means you don't need to worry about the relent plugins going out of date or waiting for them to update.
Personally I do everything custom now and just have everything all working under a single mainframe to manage everything when I do my custom systems. But that is only useful if it's a one off and it won't be used publicly really.